eventcallback.h 1.92 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

/*****************************************************************
 * eventcallback.h
 *
 * Interface timed eventcall routine for simos.. 
 *
 * $Author: blythe $
 * $Date: 2002/05/29 01:09:09 $
 ****************************************************************/

#ifndef EVENTCALLBACK_H
#define EVENTCALLBACK_H

#include "simtypes.h"

typedef struct EventCallbackHdr {
   struct    EventCallbackHdr *next;
   int cpuNum;
   bool active;
   SimTime when;
   void (*rout) (int, struct EventCallbackHdr *,void*);
   void *arg;
} EventCallbackHdr;

typedef struct EventQueue {
   SimTime calltime;
   SimTime lastCall;
   int lock;
   EventCallbackHdr sentinel;
   char padding2[128-sizeof(int)-2*sizeof(SimTime)-sizeof(EventCallbackHdr)];
} EventQueue;

#ifdef notdef
typedef (*EventCallback) (int, struct EventCallbackHdr *,void*);
#endif
extern void EventCallbackInit(int cpuNum);
extern void EventDoCallback(int cpuNum,void (*rout)(int,EventCallbackHdr *,void*), 
                            EventCallbackHdr *, void *arg, SimTime timeInFuture);
extern void EventCallbackRemove(EventCallbackHdr * event);
extern void EventCallbackUpdate(EventCallbackHdr * event, SimTime  when);

extern void EventProcess(int cpuNum,SimTime now);


extern EventQueue *eventQueues;

#define SingleEventQueueCalltimeAddr (&eventQueues->calltime)

#define EventPendingSingleQueue(_tim) (eventQueues->calltime <= (_tim))
#define EventProcessSingleQueue(_tim) EventProcess(-1,(_tim))
#define EventPollSingleQueue(_tim) \
     if (eventQueues->calltime <= (_tim)) EventProcess(-1,_tim);

#define EventPollMultipleQueue(_cpu,_tim) \
     if (eventQueues[_cpu].calltime <= (_tim)) EventProcess(_cpu,_tim);

#define EventCallbackActive(_ev) ((_ev)->active)

#endif /* EVENTCALLBACK_H */