/*---------------------------------------------------------------------------*/
/* ios_event.cpp                                                         */
/* copyright (c) innovaphone 2012                                            */
/*                                                                           */
/*---------------------------------------------------------------------------*/

#define IOS_EVENT_CPP_

#include "platform/platform.h"
#include "ios_event.h"

#define FILE_ "ios_event.cpp"

USING_NAMESPACE;

/*----------------------------------------------------------------------------*/

volatile t_ios_event_queue_arg *ios_event_queue;

volatile dword ios_event_in_doorbell_req;
dword ios_event_in_doorbell_ack;
volatile dword ios_event_out_doorbell_req;
dword ios_event_out_doorbell_ack;

/*----------------------------------------------------------------------------*/

ios_event::ios_event()
{
}

bool ios_event::init(t_ios_event_handler *handler_table, unsigned int handler_count)
{
    this->handler_table = handler_table;
    this->handler_count = handler_count;
    return (true);
}

dword ios_event::dequeue()
{
    queue_pos = ios_event_in_doorbell_ack;
    int event_id = get_int();
    (*(handler_table[event_id].handler))(this);
    return (queue_pos & IOS_EVENT_QUEUE_MASK);
}


/*----------------------------------------------------------------------------*/
