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/>.
24 #include "device_table.h"
31 core - root of the device tree
35 The core device positioned at the root of the device tree appears
36 to its child devices as a normal device just like every other
39 Internally it is implemented using a core object. Requests to
40 attach (or detach) address spaces are passed to that core object.
41 Requests to transfer (DMA) data are reflected back down the device
42 tree using the core_map data transfer methods.
52 hw_core_init_address_callback(device
*me
)
54 core
*memory
= (core
*)device_data(me
);
60 hw_core_attach_address_callback(device
*me
,
66 device
*client
) /*callback/default*/
68 core
*memory
= (core
*)device_data(me
);
70 error("core_attach_address_callback() invalid address space\n");
82 hw_core_dma_read_buffer_callback(device
*me
,
88 core
*memory
= (core
*)device_data(me
);
89 return core_map_read_buffer(core_readable(memory
),
97 hw_core_dma_write_buffer_callback(device
*me
,
102 int violate_read_only_section
)
104 core
*memory
= (core
*)device_data(me
);
105 core_map
*map
= (violate_read_only_section
106 ? core_readable(memory
)
107 : core_writeable(memory
));
108 return core_map_write_buffer(map
,
114 static device_callbacks
const hw_core_callbacks
= {
115 { hw_core_init_address_callback
, },
116 { hw_core_attach_address_callback
, },
118 { hw_core_dma_read_buffer_callback
,
119 hw_core_dma_write_buffer_callback
, },
120 { NULL
, }, /* interrupt */
121 { generic_device_unit_decode
,
122 generic_device_unit_encode
,
123 generic_device_address_to_attach_address
,
124 generic_device_size_to_attach_size
, },
129 hw_core_create(const char *name
,
130 const device_unit
*unit_address
,
133 core
*memory
= core_create();
137 const device_descriptor hw_core_device_descriptor
[] = {
138 { "core", hw_core_create
, &hw_core_callbacks
},
142 #endif /* _HW_CORE_C_ */