/***********************************************************/
/* general data structure for event handling & request     */
/* queuing                                                 */
/***********************************************************/
#ifndef REQ_H_
#define REQ_H_

#include <system.h>

struct req_st;

typedef void (*handler_t)(struct req_st* req, void* response);

typedef struct req_st {
  struct req_st* caller_req;
  struct req_st* callee_req;

  handler_t handler;
  void*     specific;

  struct req_st* prev;
  struct req_st* next;
} req_t;

typedef struct list_st {
  struct list_st* prev;
  struct list_st* next;

  uint32_t lba;
  req_t*   req;
} list_t;

void reqFree(req_t* req);

void reqEnqueue(req_t* req, req_t** queue_p);

req_t* reqDequeue(req_t** queue_p);

bool_t reqPop(req_t** queue_p, req_t* req);

void req_activate(req_t* req, void* response);

void req_activate_caller(req_t* req, void* response);
#endif
