1 /* ICU device: icu@<address>
3 <address> : read - processor nr
4 <address> : write - interrupt processor nr
5 <address> + 4 : read - nr processors
7 Single byte registers that control a simple ICU.
9 Illustrates passing of events to parent device. Passing of
10 interrupts to an interrupt destination. */
14 icu_io_read_buffer_callback(device
*me
,
22 memset(dest
, 0, nr_bytes
);
25 *(unsigned_1
*)dest
= cpu_nr(processor
);
29 device_find_integer_property(me
, "/openprom/options/smp");
37 icu_io_write_buffer_callback(device
*me
,
45 unsigned_1 val
= H2T_1(*(unsigned_1
*)source
);
46 /* tell the parent device that the interrupt lines have changed.
47 For this fake ICU. The interrupt lines just indicate the cpu to
49 device_interrupt_event(me
,
57 icu_do_interrupt(event_queue
*queue
,
60 cpu
*target
= (cpu
*)data
;
61 /* try to interrupt the processor. If the attempt fails, try again
63 if (!external_interrupt(target
))
64 event_queue_schedule(queue
, 1, icu_do_interrupt
, target
);
69 icu_interrupt_event_callback(device
*me
,
77 /* the interrupt controller can't interrupt a cpu at any time.
78 Rather it must synchronize with the system clock before
79 performing an interrupt on the given processor */
80 psim
*system
= cpu_system(processor
);
81 cpu
*target
= psim_cpu(system
, my_port
);
83 event_queue
*events
= cpu_event_queue(target
);
84 event_queue_schedule(events
, 1, icu_do_interrupt
, target
);
88 static device_callbacks
const icu_callbacks
= {
89 { generic_device_init_address
, },
90 { NULL
, }, /* address */
91 { icu_io_read_buffer_callback
,
92 icu_io_write_buffer_callback
, },
94 { icu_interrupt_event_callback
, },