First version committed to git
[zpugcc/jano.git] / toolchain / gdb / sim / ppc / device_table.h
blobaf6c28d697d16d16c8319f33d5b400b8fb005f5d
1 /* This file is part of the program psim.
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
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.
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.
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.
22 #ifndef _DEVICE_TABLE_H_
23 #define _DEVICE_TABLE_H_
25 #include "basics.h"
26 #include "device.h"
27 #include "tree.h"
29 #ifdef HAVE_STRING_H
30 #include <string.h>
31 #else
32 #ifdef HAVE_STRINGS_H
33 #include <strings.h>
34 #endif
35 #endif
38 typedef struct _device_callbacks device_callbacks;
41 /* The creator, returns a pointer to any data that should be allocated
42 once during (multiple) simulation runs */
44 typedef void *(device_creator)
45 (const char *name,
46 const device_unit *unit_address,
47 const char *args);
50 /* two stages of initialization */
52 typedef void (device_init_callback)
53 (device *me);
55 typedef struct _device_init_callbacks {
56 device_init_callback *address; /* NULL - ignore */
57 device_init_callback *data; /* NULL - ignore */
58 } device_init_callbacks;
61 /* attaching/detaching a devices address space to its parent */
63 typedef void (device_address_callback)
64 (device *me,
65 attach_type attach,
66 int space,
67 unsigned_word addr,
68 unsigned nr_bytes,
69 access_type access,
70 device *client); /*callback/default*/
72 typedef struct _device_address_callbacks {
73 device_address_callback *attach;
74 device_address_callback *detach;
75 } device_address_callbacks;
78 /* I/O operations - from parent */
80 typedef unsigned (device_io_read_buffer_callback)
81 (device *me,
82 void *dest,
83 int space,
84 unsigned_word addr,
85 unsigned nr_bytes,
86 cpu *processor,
87 unsigned_word cia);
89 typedef unsigned (device_io_write_buffer_callback)
90 (device *me,
91 const void *source,
92 int space,
93 unsigned_word addr,
94 unsigned nr_bytes,
95 cpu *processor,
96 unsigned_word cia);
98 typedef struct _device_io_callbacks { /* NULL - error */
99 device_io_read_buffer_callback *read_buffer;
100 device_io_write_buffer_callback *write_buffer;
101 } device_io_callbacks;
104 /* DMA transfers by a device via its parent */
106 typedef unsigned (device_dma_read_buffer_callback)
107 (device *me,
108 void *dest,
109 int space,
110 unsigned_word addr,
111 unsigned nr_bytes);
113 typedef unsigned (device_dma_write_buffer_callback)
114 (device *me,
115 const void *source,
116 int space,
117 unsigned_word addr,
118 unsigned nr_bytes,
119 int violate_read_only_section);
121 typedef struct _device_dma_callbacks { /* NULL - error */
122 device_dma_read_buffer_callback *read_buffer;
123 device_dma_write_buffer_callback *write_buffer;
124 } device_dma_callbacks;
127 /* Interrupts */
129 typedef void (device_interrupt_event_callback)
130 (device *me,
131 int my_port,
132 device *source,
133 int source_port,
134 int level,
135 cpu *processor,
136 unsigned_word cia);
138 typedef void (device_child_interrupt_event_callback)
139 (device *me,
140 device *parent,
141 device *source,
142 int source_port,
143 int level,
144 cpu *processor,
145 unsigned_word cia);
147 typedef struct _device_interrupt_port_descriptor {
148 const char *name;
149 int number;
150 int nr_ports;
151 port_direction direction;
152 } device_interrupt_port_descriptor;
154 typedef struct _device_interrupt_callbacks {
155 device_interrupt_event_callback *event;
156 device_child_interrupt_event_callback *child_event;
157 const device_interrupt_port_descriptor *ports;
158 } device_interrupt_callbacks;
161 /* symbolic value decoding */
163 typedef int (device_unit_decode_callback)
164 (device *bus,
165 const char *unit,
166 device_unit *address);
168 typedef int (device_unit_encode_callback)
169 (device *bus,
170 const device_unit *unit_address,
171 char *buf,
172 int sizeof_buf);
174 typedef int (device_address_to_attach_address_callback)
175 (device *bus,
176 const device_unit *address,
177 int *attach_space,
178 unsigned_word *attach_address,
179 device *client);
181 typedef int (device_size_to_attach_size_callback)
182 (device *bus,
183 const device_unit *size,
184 unsigned *nr_bytes,
185 device *client);
187 typedef struct _device_convert_callbacks {
188 device_unit_decode_callback *decode_unit;
189 device_unit_encode_callback *encode_unit;
190 device_address_to_attach_address_callback *address_to_attach_address;
191 device_size_to_attach_size_callback *size_to_attach_size;
192 } device_convert_callbacks;
195 /* instances */
197 typedef void (device_instance_delete_callback)
198 (device_instance *instance);
200 typedef int (device_instance_read_callback)
201 (device_instance *instance,
202 void *buf,
203 unsigned_word len);
205 typedef int (device_instance_write_callback)
206 (device_instance *instance,
207 const void *buf,
208 unsigned_word len);
210 typedef int (device_instance_seek_callback)
211 (device_instance *instance,
212 unsigned_word pos_hi,
213 unsigned_word pos_lo);
215 typedef int (device_instance_method)
216 (device_instance *instance,
217 int n_stack_args,
218 unsigned_cell stack_args[/*n_stack_args*/],
219 int n_stack_returns,
220 unsigned_cell stack_returns[/*n_stack_returns*/]);
222 typedef struct _device_instance_methods {
223 const char *name;
224 device_instance_method *method;
225 } device_instance_methods;
227 struct _device_instance_callbacks { /* NULL - error */
228 device_instance_delete_callback *delete;
229 device_instance_read_callback *read;
230 device_instance_write_callback *write;
231 device_instance_seek_callback *seek;
232 const device_instance_methods *methods;
235 typedef device_instance *(device_create_instance_callback)
236 (device *me,
237 const char *full_path,
238 const char *args);
240 typedef device_instance *(package_create_instance_callback)
241 (device_instance *parent,
242 const char *args);
245 /* all else fails */
247 typedef int (device_ioctl_callback)
248 (device *me,
249 cpu *processor,
250 unsigned_word cia,
251 device_ioctl_request request,
252 va_list ap);
254 typedef void (device_usage_callback)
255 (int verbose);
258 /* the callbacks */
260 struct _device_callbacks {
262 /* initialization */
263 device_init_callbacks init;
265 /* address/data config - from child */
266 device_address_callbacks address;
268 /* address/data transfer - from parent */
269 device_io_callbacks io;
271 /* address/data transfer - from child */
272 device_dma_callbacks dma;
274 /* interrupt signalling */
275 device_interrupt_callbacks interrupt;
277 /* bus address decoding */
278 device_convert_callbacks convert;
280 /* instances */
281 device_create_instance_callback *instance_create;
283 /* back door to anything we've forgot */
284 device_ioctl_callback *ioctl;
285 device_usage_callback *usage;
289 /* Table of all the devices and a function to lookup/create a device
290 from its name */
292 typedef struct _device_descriptor device_descriptor;
293 struct _device_descriptor {
294 const char *name;
295 device_creator *creator;
296 const device_callbacks *callbacks;
299 extern const device_descriptor *const device_table[];
300 #include "hw.h"
303 /* Pass through, ignore and generic callback functions. A call going
304 towards the root device are passed on up, local calls are ignored
305 and call downs abort */
307 extern device_address_callback passthrough_device_address_attach;
308 extern device_address_callback passthrough_device_address_detach;
309 extern device_dma_read_buffer_callback passthrough_device_dma_read_buffer;
310 extern device_dma_write_buffer_callback passthrough_device_dma_write_buffer;
312 extern device_unit_decode_callback ignore_device_unit_decode;
314 extern device_init_callback generic_device_init_address;
315 extern device_unit_decode_callback generic_device_unit_decode;
316 extern device_unit_encode_callback generic_device_unit_encode;
317 extern device_address_to_attach_address_callback generic_device_address_to_attach_address;
318 extern device_size_to_attach_size_callback generic_device_size_to_attach_size;
321 extern const device_callbacks passthrough_device_callbacks;
323 #endif /* _DEVICE_TABLE_H_ */