* cgen-trace.c (trace_insn): Pass pc to trace_prefix for virtual insns.
[deliverable/binutils-gdb.git] / sim / common / hw-events.c
1 /* Hardware event manager.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5 This file is part of GDB, the GNU debugger.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21
22 #include "sim-main.h"
23 #include "hw-base.h"
24
25 #include "sim-events.h"
26
27
28 /* The hw-events object is implemented using sim-events */
29
30 struct hw_event {
31 void *data;
32 struct hw *me;
33 hw_event_callback *callback;
34 sim_event *real;
35 struct hw_event_data *entry;
36 };
37
38 struct hw_event_data {
39 struct hw_event event;
40 struct hw_event_data *next;
41 struct hw_event_data **prev;
42 };
43
44 void
45 create_hw_event_data (struct hw *me)
46 {
47 /* NOP */
48 }
49
50 void
51 delete_hw_event_data (struct hw *me)
52 {
53 if (me->events_of_hw != NULL)
54 hw_abort (me, "stray events");
55 }
56
57
58 static void
59 delete_hw_event (struct hw *me,
60 struct hw_event **event)
61 {
62 struct hw_event_data *entry = (*event)->entry;
63 *(entry->prev) = entry->next;
64 entry->next->prev = entry->prev;
65 (*event) = NULL;
66 }
67
68
69 static void
70 create_hw_event (struct hw *me,
71 struct hw_event **event)
72 {
73 struct hw_event_data *entry = HW_ZALLOC (me, struct hw_event_data);
74 entry->next = me->events_of_hw;
75 entry->prev = &me->events_of_hw;
76 me->events_of_hw->prev = &entry->next;
77 me->events_of_hw = entry;
78 (*event) = &entry->event;
79 }
80
81
82
83 /* Pass the H/W event onto the real callback */
84
85 static void
86 bounce_hw_event (SIM_DESC sd,
87 void *data)
88 {
89 /* save the data */
90 struct hw_event *event = (struct hw_event*)data;
91 struct hw *me = event->me;
92 void *event_data = event->data;
93 hw_event_callback *callback = event->callback;
94 hw_free (me, data);
95 event = NULL;
96 callback (me, event_data);
97 }
98
99
100
101 /* Map onto the event functions */
102
103 struct hw_event *
104 hw_event_queue_schedule (struct hw *me,
105 signed64 delta_time,
106 hw_event_callback *callback,
107 void *data)
108 {
109 struct hw_event *event;
110 create_hw_event (me, &event);
111 /* fill it in */
112 event->data = data;
113 event->callback = callback;
114 event->me = me;
115 event->real = sim_events_schedule (hw_system (me),
116 delta_time,
117 bounce_hw_event,
118 event);
119 return event;
120 }
121
122
123 void
124 hw_event_queue_deschedule (struct hw *me,
125 struct hw_event *event_to_remove)
126 {
127 /* remove it from the event queue */
128 sim_events_deschedule (hw_system (me),
129 event_to_remove->real);
130 delete_hw_event (me, &event_to_remove);
131 }
132
133
134 signed64
135 hw_event_queue_time (struct hw *me)
136 {
137 return sim_events_time (hw_system (me));
138 }
139
140
This page took 0.031693 seconds and 4 git commands to generate.