1 /* Hardware event manager.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
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)
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.
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. */
25 #include "sim-events.h"
28 /* The hw-events object is implemented using sim-events */
33 hw_event_callback *callback;
35 struct hw_event_data *entry;
38 struct hw_event_data {
39 struct hw_event event;
40 struct hw_event_data *next;
41 struct hw_event_data **prev;
45 create_hw_event_data (struct hw *me)
51 delete_hw_event_data (struct hw *me)
53 if (me->events_of_hw != NULL)
54 hw_abort (me, "stray events");
59 delete_hw_event (struct hw *me,
60 struct hw_event **event)
62 struct hw_event_data *entry = (*event)->entry;
63 *(entry->prev) = entry->next;
64 entry->next->prev = entry->prev;
70 create_hw_event (struct hw *me,
71 struct hw_event **event)
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;
83 /* Pass the H/W event onto the real callback */
86 bounce_hw_event (SIM_DESC sd,
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;
96 callback (me, event_data);
101 /* Map onto the event functions */
104 hw_event_queue_schedule (struct hw *me,
106 hw_event_callback *callback,
109 struct hw_event *event;
110 create_hw_event (me, &event);
113 event->callback = callback;
115 event->real = sim_events_schedule (hw_system (me),
124 hw_event_queue_deschedule (struct hw *me,
125 struct hw_event *event_to_remove)
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);
135 hw_event_queue_time (struct hw *me)
137 return sim_events_time (hw_system (me));