Commit | Line | Data |
---|---|---|
1e1e3b61 IC |
1 | /* Copyright (C) 1998, Cygnus Solutions |
2 | ||
3 | */ | |
4 | ||
5 | #include "sim-main.h" | |
6 | ||
7 | #include "device.h" | |
8 | #include "dma.h" | |
9 | ||
10 | int | |
11 | dma_io_read_buffer(device *me, | |
12 | void *dest, | |
13 | int space, | |
14 | address_word addr, | |
15 | unsigned nr_bytes, | |
16 | sim_cpu *processor, | |
17 | sim_cia cia) | |
18 | { | |
19 | printf("%s: Read!\n", me->name); | |
20 | return nr_bytes; | |
21 | } | |
22 | ||
23 | static sim_event_handler do_the_dma_thing_handler; | |
24 | ||
25 | int | |
26 | dma_io_write_buffer(device *me, | |
27 | const void *source, | |
28 | int space, | |
29 | address_word addr, | |
30 | unsigned nr_bytes, | |
31 | sim_cpu *processor, | |
32 | sim_cia cia) | |
33 | { | |
34 | printf("%s: Write!\n", me->name); | |
35 | ||
36 | /* Do an event before the next instruction! */ | |
37 | sim_events_schedule (CPU_STATE(processor), | |
38 | 0 /*time*/, | |
39 | do_the_dma_thing_handler, | |
40 | CPU_STATE(processor) /*data*/); | |
41 | return nr_bytes; | |
42 | } | |
43 | ||
44 | device dma_device = | |
45 | { | |
46 | "Dma Controller", | |
47 | &dma_io_read_buffer, | |
48 | &dma_io_write_buffer | |
49 | }; | |
50 | ||
51 | void | |
52 | dma_attach(SIM_DESC sd) | |
53 | { | |
54 | sim_core_attach (sd, | |
55 | NULL, | |
56 | 0 /*level*/, | |
57 | access_read_write, | |
58 | 0 /*space ???*/, | |
59 | DMA_REGISTER_WINDOW_START, | |
60 | DMA_REGISTER_WINDOW_SIZE /*nr_bytes*/, | |
61 | 0 /*modulo*/, | |
62 | &dma_device, | |
63 | NULL /*buffer*/); | |
64 | } | |
65 | ||
66 | static void | |
67 | do_the_dma_thing_handler(SIM_DESC sd, void *data) | |
68 | { | |
69 | printf("Dma Event!!!\n"); | |
70 | } |