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.
25 #include "device_table.h"
32 core - root of the device tree
36 The core device positioned at the root of the device tree appears
37 to its child devices as a normal device just like every other
40 Internally it is implemented using a core object. Requests to
41 attach (or detach) address spaces are passed to that core object.
42 Requests to transfer (DMA) data are reflected back down the device
43 tree using the core_map data transfer methods.
53 hw_core_init_address_callback(device *me)
55 core *memory = (core*)device_data(me);
61 hw_core_attach_address_callback(device *me,
67 device *client) /*callback/default*/
69 core *memory = (core*)device_data(me);
71 error("core_attach_address_callback() invalid address space\n");
83 hw_core_dma_read_buffer_callback(device *me,
89 core *memory = (core*)device_data(me);
90 return core_map_read_buffer(core_readable(memory),
98 hw_core_dma_write_buffer_callback(device *me,
103 int violate_read_only_section)
105 core *memory = (core*)device_data(me);
106 core_map *map = (violate_read_only_section
107 ? core_readable(memory)
108 : core_writeable(memory));
109 return core_map_write_buffer(map,
115 static device_callbacks const hw_core_callbacks = {
116 { hw_core_init_address_callback, },
117 { hw_core_attach_address_callback, },
119 { hw_core_dma_read_buffer_callback,
120 hw_core_dma_write_buffer_callback, },
121 { NULL, }, /* interrupt */
122 { generic_device_unit_decode,
123 generic_device_unit_encode,
124 generic_device_address_to_attach_address,
125 generic_device_size_to_attach_size, },
130 hw_core_create(const char *name,
131 const device_unit *unit_address,
134 core *memory = core_create();
138 const device_descriptor hw_core_device_descriptor[] = {
139 { "core", hw_core_create, &hw_core_callbacks },
143 #endif /* _HW_CORE_C_ */