Update objcopy's --section-alignment option so that it sets the alignment flag on...
[binutils-gdb.git] / sim / ppc / device_table.h
blobb61f4bd06d731b90d614e5290a939ded60ad823c
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 3 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, see <http://www.gnu.org/licenses/>.
21 #ifndef _DEVICE_TABLE_H_
22 #define _DEVICE_TABLE_H_
24 #include "basics.h"
25 #include "device.h"
26 #include "tree.h"
28 #include <string.h>
31 typedef struct _device_callbacks device_callbacks;
34 /* The creator, returns a pointer to any data that should be allocated
35 once during (multiple) simulation runs */
37 typedef void *(device_creator)
38 (const char *name,
39 const device_unit *unit_address,
40 const char *args);
43 /* two stages of initialization */
45 typedef void (device_init_callback)
46 (device *me);
48 typedef struct _device_init_callbacks {
49 device_init_callback *address; /* NULL - ignore */
50 device_init_callback *data; /* NULL - ignore */
51 } device_init_callbacks;
54 /* attaching/detaching a devices address space to its parent */
56 typedef void (device_address_callback)
57 (device *me,
58 attach_type attach,
59 int space,
60 unsigned_word addr,
61 unsigned nr_bytes,
62 access_type access,
63 device *client); /*callback/default*/
65 typedef struct _device_address_callbacks {
66 device_address_callback *attach;
67 device_address_callback *detach;
68 } device_address_callbacks;
71 /* I/O operations - from parent */
73 typedef unsigned (device_io_read_buffer_callback)
74 (device *me,
75 void *dest,
76 int space,
77 unsigned_word addr,
78 unsigned nr_bytes,
79 cpu *processor,
80 unsigned_word cia);
82 typedef unsigned (device_io_write_buffer_callback)
83 (device *me,
84 const void *source,
85 int space,
86 unsigned_word addr,
87 unsigned nr_bytes,
88 cpu *processor,
89 unsigned_word cia);
91 typedef struct _device_io_callbacks { /* NULL - error */
92 device_io_read_buffer_callback *read_buffer;
93 device_io_write_buffer_callback *write_buffer;
94 } device_io_callbacks;
97 /* DMA transfers by a device via its parent */
99 typedef unsigned (device_dma_read_buffer_callback)
100 (device *me,
101 void *dest,
102 int space,
103 unsigned_word addr,
104 unsigned nr_bytes);
106 typedef unsigned (device_dma_write_buffer_callback)
107 (device *me,
108 const void *source,
109 int space,
110 unsigned_word addr,
111 unsigned nr_bytes,
112 int violate_read_only_section);
114 typedef struct _device_dma_callbacks { /* NULL - error */
115 device_dma_read_buffer_callback *read_buffer;
116 device_dma_write_buffer_callback *write_buffer;
117 } device_dma_callbacks;
120 /* Interrupts */
122 typedef void (device_interrupt_event_callback)
123 (device *me,
124 int my_port,
125 device *source,
126 int source_port,
127 int level,
128 cpu *processor,
129 unsigned_word cia);
131 typedef void (device_child_interrupt_event_callback)
132 (device *me,
133 device *parent,
134 device *source,
135 int source_port,
136 int level,
137 cpu *processor,
138 unsigned_word cia);
140 typedef struct _device_interrupt_port_descriptor {
141 const char *name;
142 int number;
143 int nr_ports;
144 port_direction direction;
145 } device_interrupt_port_descriptor;
147 typedef struct _device_interrupt_callbacks {
148 device_interrupt_event_callback *event;
149 device_child_interrupt_event_callback *child_event;
150 const device_interrupt_port_descriptor *ports;
151 } device_interrupt_callbacks;
154 /* symbolic value decoding */
156 typedef int (device_unit_decode_callback)
157 (device *bus,
158 const char *unit,
159 device_unit *address);
161 typedef int (device_unit_encode_callback)
162 (device *bus,
163 const device_unit *unit_address,
164 char *buf,
165 int sizeof_buf);
167 typedef int (device_address_to_attach_address_callback)
168 (device *bus,
169 const device_unit *address,
170 int *attach_space,
171 unsigned_word *attach_address,
172 device *client);
174 typedef int (device_size_to_attach_size_callback)
175 (device *bus,
176 const device_unit *size,
177 unsigned *nr_bytes,
178 device *client);
180 typedef struct _device_convert_callbacks {
181 device_unit_decode_callback *decode_unit;
182 device_unit_encode_callback *encode_unit;
183 device_address_to_attach_address_callback *address_to_attach_address;
184 device_size_to_attach_size_callback *size_to_attach_size;
185 } device_convert_callbacks;
188 /* instances */
190 typedef void (device_instance_delete_callback)
191 (device_instance *instance);
193 typedef int (device_instance_read_callback)
194 (device_instance *instance,
195 void *buf,
196 unsigned_word len);
198 typedef int (device_instance_write_callback)
199 (device_instance *instance,
200 const void *buf,
201 unsigned_word len);
203 typedef int (device_instance_seek_callback)
204 (device_instance *instance,
205 unsigned_word pos_hi,
206 unsigned_word pos_lo);
208 typedef int (device_instance_method)
209 (device_instance *instance,
210 int n_stack_args,
211 unsigned_cell stack_args[/*n_stack_args*/],
212 int n_stack_returns,
213 unsigned_cell stack_returns[/*n_stack_returns*/]);
215 typedef struct _device_instance_methods {
216 const char *name;
217 device_instance_method *method;
218 } device_instance_methods;
220 struct _device_instance_callbacks { /* NULL - error */
221 device_instance_delete_callback *delete;
222 device_instance_read_callback *read;
223 device_instance_write_callback *write;
224 device_instance_seek_callback *seek;
225 const device_instance_methods *methods;
228 typedef device_instance *(device_create_instance_callback)
229 (device *me,
230 const char *full_path,
231 const char *args);
233 typedef device_instance *(package_create_instance_callback)
234 (device_instance *parent,
235 const char *args);
238 /* all else fails */
240 typedef int (device_ioctl_callback)
241 (device *me,
242 cpu *processor,
243 unsigned_word cia,
244 device_ioctl_request request,
245 va_list ap);
247 typedef void (device_usage_callback)
248 (int verbose);
251 /* the callbacks */
253 struct _device_callbacks {
255 /* initialization */
256 device_init_callbacks init;
258 /* address/data config - from child */
259 device_address_callbacks address;
261 /* address/data transfer - from parent */
262 device_io_callbacks io;
264 /* address/data transfer - from child */
265 device_dma_callbacks dma;
267 /* interrupt signalling */
268 device_interrupt_callbacks interrupt;
270 /* bus address decoding */
271 device_convert_callbacks convert;
273 /* instances */
274 device_create_instance_callback *instance_create;
276 /* back door to anything we've forgot */
277 device_ioctl_callback *ioctl;
278 device_usage_callback *usage;
282 /* Table of all the devices and a function to lookup/create a device
283 from its name */
285 typedef struct _device_descriptor device_descriptor;
286 struct _device_descriptor {
287 const char *name;
288 device_creator *creator;
289 const device_callbacks *callbacks;
292 extern const device_descriptor *const device_table[];
293 #include "hw.h"
296 /* Pass through, ignore and generic callback functions. A call going
297 towards the root device are passed on up, local calls are ignored
298 and call downs abort */
300 extern device_address_callback passthrough_device_address_attach;
301 extern device_address_callback passthrough_device_address_detach;
302 extern device_dma_read_buffer_callback passthrough_device_dma_read_buffer;
303 extern device_dma_write_buffer_callback passthrough_device_dma_write_buffer;
305 extern device_unit_decode_callback ignore_device_unit_decode;
307 extern device_init_callback generic_device_init_address;
308 extern device_unit_decode_callback generic_device_unit_decode;
309 extern device_unit_encode_callback generic_device_unit_encode;
310 extern device_address_to_attach_address_callback generic_device_address_to_attach_address;
311 extern device_size_to_attach_size_callback generic_device_size_to_attach_size;
314 extern const device_callbacks passthrough_device_callbacks;
316 #endif /* _DEVICE_TABLE_H_ */