Commit | Line | Data |
---|---|---|
231de1b8 AC |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef _SIM_EVENTS_H_ | |
23 | #define _SIM_EVENTS_H_ | |
24 | ||
25 | ||
26 | typedef void event_handler(void *data); | |
27 | ||
28 | typedef struct _event_entry event_entry; | |
29 | struct _event_entry { | |
30 | void *data; | |
31 | event_handler *handler; | |
32 | signed64 time_of_event; | |
33 | event_entry *next; | |
34 | }; | |
35 | ||
36 | typedef struct _event_queue event_queue; | |
37 | struct _event_queue { | |
38 | int processing; | |
39 | event_entry *queue; | |
40 | event_entry *volatile held; | |
41 | event_entry *volatile *volatile held_end; | |
42 | signed64 time_of_event; | |
43 | signed64 time_from_event; | |
44 | int trace; | |
45 | }; | |
46 | ||
47 | typedef struct event_entry *event_entry_tag; | |
48 | ||
49 | ||
50 | /* Initialization */ | |
51 | ||
52 | INLINE_SIM_EVENTS\ | |
53 | (void) event_queue_init | |
54 | (engine *system); | |
55 | ||
56 | ||
57 | /* Tracing level */ | |
58 | ||
59 | INLINE_SIM_EVENTS\ | |
60 | (void) event_queue_trace | |
61 | (engine *system, | |
62 | int level); | |
63 | ||
64 | ||
65 | /* (de)Schedule things to happen in the future. */ | |
66 | ||
67 | INLINE_SIM_EVENTS\ | |
68 | (event_entry_tag) event_queue_schedule | |
69 | (engine *system, | |
70 | signed64 delta_time, | |
71 | event_handler *handler, | |
72 | void *data); | |
73 | ||
74 | INLINE_SIM_EVENTS\ | |
75 | (event_entry_tag) event_queue_schedule_after_signal | |
76 | (engine *system, | |
77 | signed64 delta_time, | |
78 | event_handler *handler, | |
79 | void *data); | |
80 | ||
81 | INLINE_SIM_EVENTS\ | |
82 | (void) event_queue_deschedule | |
83 | (engine *system, | |
84 | event_entry_tag event_to_remove); | |
85 | ||
86 | ||
87 | /* progress time. Broken into two parts so that if something is | |
88 | pending, the caller has a chance to save any cached state */ | |
89 | ||
90 | INLINE_SIM_EVENTS\ | |
91 | (int) event_queue_tick | |
92 | (engine *system); | |
93 | ||
94 | INLINE_SIM_EVENTS\ | |
95 | (void) event_queue_process | |
96 | (engine *system); | |
97 | ||
98 | ||
99 | /* local concept of time */ | |
100 | ||
101 | INLINE_SIM_EVENTS\ | |
102 | (signed64) event_queue_time | |
103 | (engine *system); | |
104 | ||
105 | ||
106 | #endif |