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_
39 typedef struct _device_callbacks device_callbacks
;
42 /* The creator, returns a pointer to any data that should be allocated
43 once during (multiple) simulation runs */
45 typedef void *(device_creator
)
47 const device_unit
*unit_address
,
51 /* two stages of initialization */
53 typedef void (device_init_callback
)
56 typedef struct _device_init_callbacks
{
57 device_init_callback
*address
; /* NULL - ignore */
58 device_init_callback
*data
; /* NULL - ignore */
59 } device_init_callbacks
;
62 /* attaching/detaching a devices address space to its parent */
64 typedef void (device_address_callback
)
72 device
*who
); /*callback/default*/
74 typedef struct _device_address_callbacks
{
75 device_address_callback
*attach
;
76 device_address_callback
*detach
;
77 } device_address_callbacks
;
80 /* I/O operations - from parent */
82 typedef unsigned (device_io_read_buffer_callback
)
91 typedef unsigned (device_io_write_buffer_callback
)
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
;
106 /* DMA transfers by a device via its parent */
108 typedef unsigned (device_dma_read_buffer_callback
)
115 typedef unsigned (device_dma_write_buffer_callback
)
121 int violate_read_only_section
);
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
;
131 typedef void (device_interrupt_event_callback
)
140 typedef void (device_child_interrupt_event_callback
)
149 typedef struct _device_interrupt_port_descriptor
{
153 } device_interrupt_port_descriptor
;
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
;
162 /* symbolic value decoding */
164 typedef int (device_unit_decode_callback
)
167 device_unit
*address
);
169 typedef int (device_unit_encode_callback
)
171 const device_unit
*unit_address
,
175 typedef struct _device_convert_callbacks
{
176 device_unit_decode_callback
*decode_unit
;
177 device_unit_encode_callback
*encode_unit
;
178 } device_convert_callbacks
;
183 typedef void (device_instance_delete_callback
)
184 (device_instance
*instance
);
186 typedef int (device_instance_read_callback
)
187 (device_instance
*instance
,
191 typedef int (device_instance_write_callback
)
192 (device_instance
*instance
,
196 typedef int (device_instance_seek_callback
)
197 (device_instance
*instance
,
198 unsigned_word pos_hi
,
199 unsigned_word pos_lo
);
201 typedef unsigned_word (device_instance_claim_callback
)
202 (device_instance
*instance
,
203 unsigned_word address
,
204 unsigned_word length
,
205 unsigned_word alignment
);
207 typedef void (device_instance_release_callback
)
208 (device_instance
*instance
,
209 unsigned_word address
,
210 unsigned_word length
);
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
;
221 typedef device_instance
*(device_create_instance_callback
)
226 typedef device_instance
*(package_create_instance_callback
)
227 (device_instance
*parent
,
233 typedef int (device_ioctl_callback
)
239 typedef void (device_usage_callback
)
245 struct _device_callbacks
{
248 device_init_callbacks init
;
250 /* address/data config - from child */
251 device_address_callbacks address
;
253 /* address/data transfer - from parent */
254 device_io_callbacks io
;
256 /* address/data transfer - from child */
257 device_dma_callbacks dma
;
259 /* interrupt signalling */
260 device_interrupt_callbacks interrupt
;
262 /* bus address decoding */
263 device_convert_callbacks convert
;
266 device_create_instance_callback
*instance_create
;
268 /* back door to anything we've forgot */
269 device_ioctl_callback
*ioctl
;
270 device_usage_callback
*usage
;
274 /* Table of all the devices and a function to lookup/create a device
277 typedef struct _device_descriptor device_descriptor
;
278 struct _device_descriptor
{
280 device_creator
*creator
;
281 const device_callbacks
*callbacks
;
284 extern const device_descriptor
*const device_table
[];
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 */
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
;
297 extern device_unit_decode_callback ignore_device_unit_decode
;
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
;
304 extern const device_callbacks passthrough_device_callbacks
;
306 #endif /* _DEVICE_TABLE_H_ */