[PATCH 37/57][Arm][OBJDUMP] Add framework for MVE instructions
[binutils-gdb.git] / sim / ppc / hw_core.c
blob0aa0fdd1009ce3bde533d5f3f657c79c8babbdac
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 _HW_CORE_C_
22 #define _HW_CORE_C_
24 #include "device_table.h"
26 #include "corefile.h"
29 /* DEVICE
31 core - root of the device tree
33 DESCRIPTION
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
37 device in the tree.
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.
44 PROPERTIES
46 None.
51 static void
52 hw_core_init_address_callback(device *me)
54 core *memory = (core*)device_data(me);
55 core_init(memory);
59 static void
60 hw_core_attach_address_callback(device *me,
61 attach_type attach,
62 int space,
63 unsigned_word addr,
64 unsigned nr_bytes,
65 access_type access,
66 device *client) /*callback/default*/
68 core *memory = (core*)device_data(me);
69 if (space != 0)
70 error("core_attach_address_callback() invalid address space\n");
71 core_attach(memory,
72 attach,
73 space,
74 access,
75 addr,
76 nr_bytes,
77 client);
81 static unsigned
82 hw_core_dma_read_buffer_callback(device *me,
83 void *dest,
84 int space,
85 unsigned_word addr,
86 unsigned nr_bytes)
88 core *memory = (core*)device_data(me);
89 return core_map_read_buffer(core_readable(memory),
90 dest,
91 addr,
92 nr_bytes);
96 static unsigned
97 hw_core_dma_write_buffer_callback(device *me,
98 const void *source,
99 int space,
100 unsigned_word addr,
101 unsigned nr_bytes,
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,
109 source,
110 addr,
111 nr_bytes);
114 static device_callbacks const hw_core_callbacks = {
115 { hw_core_init_address_callback, },
116 { hw_core_attach_address_callback, },
117 { NULL, }, /* IO */
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, },
128 static void *
129 hw_core_create(const char *name,
130 const device_unit *unit_address,
131 const char *args)
133 core *memory = core_create();
134 return memory;
137 const device_descriptor hw_core_device_descriptor[] = {
138 { "core", hw_core_create, &hw_core_callbacks },
139 { NULL },
142 #endif /* _HW_CORE_C_ */