]> Git Repo - binutils.git/blob - sim/ppc/device_table.h
* COPYING: Update FSF address.
[binutils.git] / sim / ppc / device_table.h
1 /*  This file is part of the program psim.
2
3     Copyright (C) 1994-1996, Andrew Cagney <[email protected]>
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 _DEVICE_TABLE_H_
23 #define _DEVICE_TABLE_H_
24
25 #include <stdarg.h>
26
27 #include "basics.h"
28 #include "device.h"
29
30 #ifdef HAVE_STRING_H
31 #include <string.h>
32 #else
33 #ifdef HAVE_STRINGS_H
34 #include <strings.h>
35 #endif
36 #endif
37
38
39 typedef struct _device_callbacks device_callbacks;
40
41
42 /* The creator, returns a pointer to any data that should be allocated
43    once during (multiple) simulation runs */
44
45 typedef void *(device_creator)
46      (const char *name,
47       const device_unit *unit_address,
48       const char *args);
49
50
51 /* two stages of initialization */
52
53 typedef void (device_init_callback)
54      (device *me);
55      
56 typedef struct _device_init_callbacks {
57   device_init_callback *address; /* NULL - ignore */
58   device_init_callback *data; /* NULL - ignore */
59 } device_init_callbacks;
60
61
62 /* attaching/detaching a devices address space to its parent */
63
64 typedef void (device_address_callback)
65      (device *me,
66       const char *name,
67       attach_type attach,
68       int space,
69       unsigned_word addr,
70       unsigned nr_bytes,
71       access_type access,
72       device *who); /*callback/default*/
73
74 typedef struct _device_address_callbacks {
75   device_address_callback *attach;
76   device_address_callback *detach;
77 } device_address_callbacks;
78
79
80 /* I/O operations - from parent */
81
82 typedef unsigned (device_io_read_buffer_callback)
83      (device *me,
84       void *dest,
85       int space,
86       unsigned_word addr,
87       unsigned nr_bytes,
88       cpu *processor,
89       unsigned_word cia);
90
91 typedef unsigned (device_io_write_buffer_callback)
92      (device *me,
93       const void *source,
94       int space,
95       unsigned_word addr,
96       unsigned nr_bytes,
97       cpu *processor,
98       unsigned_word cia);
99
100 typedef struct _device_io_callbacks { /* NULL - error */
101   device_io_read_buffer_callback *read_buffer;
102   device_io_write_buffer_callback *write_buffer;
103 } device_io_callbacks;
104
105
106 /* DMA transfers by a device via its parent */
107
108 typedef unsigned (device_dma_read_buffer_callback)
109      (device *me,
110       void *dest,
111       int space,
112       unsigned_word addr,
113       unsigned nr_bytes);
114
115 typedef unsigned (device_dma_write_buffer_callback)
116      (device *me,
117       const void *source,
118       int space,
119       unsigned_word addr,
120       unsigned nr_bytes,
121       int violate_read_only_section);
122
123 typedef struct _device_dma_callbacks { /* NULL - error */
124   device_dma_read_buffer_callback *read_buffer;
125   device_dma_write_buffer_callback *write_buffer;
126 } device_dma_callbacks;
127
128
129 /* Interrupts */
130
131 typedef void (device_interrupt_event_callback)
132      (device *me,
133       int my_port,
134       device *source,
135       int source_port,
136       int level,
137       cpu *processor,
138       unsigned_word cia);
139
140 typedef void (device_child_interrupt_event_callback)
141      (device *me,
142       device *parent,
143       device *source,
144       int source_port,
145       int level,
146       cpu *processor,
147       unsigned_word cia);
148       
149 typedef struct _device_interrupt_port_descriptor {
150   const char *name;
151   int number; 
152   int bound;
153 } device_interrupt_port_descriptor;
154
155 typedef struct _device_interrupt_callbacks {
156   device_interrupt_event_callback *event;
157   device_child_interrupt_event_callback *child_event;
158   const device_interrupt_port_descriptor *ports;
159 } device_interrupt_callbacks;
160
161
162 /* symbolic value decoding */
163
164 typedef int (device_unit_decode_callback)
165      (device *me,
166       const char *unit,
167       device_unit *address);
168
169 typedef int (device_unit_encode_callback)
170      (device *me,
171       const device_unit *unit_address,
172       char *buf,
173       int sizeof_buf);
174
175 typedef struct _device_convert_callbacks {
176   device_unit_decode_callback *decode_unit;
177   device_unit_encode_callback *encode_unit;
178 } device_convert_callbacks;
179
180
181 /* instances */
182
183 typedef void (device_instance_delete_callback)
184      (device_instance *instance);
185
186 typedef int (device_instance_read_callback)
187      (device_instance *instance,
188       void *buf,
189       unsigned_word len);
190
191 typedef int (device_instance_write_callback)
192      (device_instance *instance,
193       const void *buf,
194       unsigned_word len);
195
196 typedef int (device_instance_seek_callback)
197      (device_instance *instance,
198       unsigned_word pos_hi,
199       unsigned_word pos_lo);
200
201 typedef unsigned_word (device_instance_claim_callback)
202      (device_instance *instance,
203       unsigned_word address,
204       unsigned_word length,
205       unsigned_word alignment);
206
207 typedef void (device_instance_release_callback)
208      (device_instance *instance,
209       unsigned_word address,
210       unsigned_word length);
211
212 struct _device_instance_callbacks { /* NULL - error */
213   device_instance_delete_callback *delete;
214   device_instance_read_callback *read;
215   device_instance_write_callback *write;
216   device_instance_seek_callback *seek;
217   device_instance_claim_callback *claim;
218   device_instance_release_callback *release;
219 };
220
221 typedef device_instance *(device_create_instance_callback)
222      (device *me,
223       const char *path,
224       const char *args);
225
226 typedef device_instance *(package_create_instance_callback)
227      (device_instance *parent,
228       const char *args);
229
230
231 /* all else fails */
232
233 typedef int (device_ioctl_callback)
234      (device *me,
235       cpu *processor,
236       unsigned_word cia,
237       va_list ap);
238
239 typedef void (device_usage_callback)
240      (int verbose);
241
242
243 /* the callbacks */
244
245 struct _device_callbacks {
246
247   /* initialization */
248   device_init_callbacks init;
249
250   /* address/data config - from child */
251   device_address_callbacks address;
252
253   /* address/data transfer - from parent */
254   device_io_callbacks io;
255
256   /* address/data transfer - from child */
257   device_dma_callbacks dma;
258
259   /* interrupt signalling */
260   device_interrupt_callbacks interrupt;
261
262   /* bus address decoding */
263   device_convert_callbacks convert;
264
265   /* instances */
266   device_create_instance_callback *instance_create;
267
268   /* back door to anything we've forgot */
269   device_ioctl_callback *ioctl;
270   device_usage_callback *usage;
271 };
272
273
274 /* Table of all the devices and a function to lookup/create a device
275    from its name */
276
277 typedef struct _device_descriptor device_descriptor;
278 struct _device_descriptor {
279   const char *name;
280   device_creator *creator;
281   const device_callbacks *callbacks;
282 };
283
284 extern const device_descriptor *const device_table[];
285 #include "hw.h"
286
287
288 /* Pass through, ignore and generic callback functions.  A call going
289    towards the root device are passed on up, local calls are ignored
290    and call downs abort */
291
292 extern device_address_callback passthrough_device_address_attach;
293 extern device_address_callback passthrough_device_address_detach;
294 extern device_dma_read_buffer_callback passthrough_device_dma_read_buffer;
295 extern device_dma_write_buffer_callback passthrough_device_dma_write_buffer;
296
297 extern device_unit_decode_callback ignore_device_unit_decode;
298
299 extern device_init_callback generic_device_init_address;
300 extern device_unit_decode_callback generic_device_unit_decode;
301 extern device_unit_encode_callback generic_device_unit_encode;
302
303
304 extern const device_callbacks passthrough_device_callbacks;
305
306 #endif /* _DEVICE_TABLE_H_ */
This page took 0.039063 seconds and 4 git commands to generate.