eventcallback.h
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* 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 */