]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/dv-core.c
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / sim / common / dv-core.c
1 /* This file is part of the program psim.
2
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4
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.
9
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.
14
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.
18
19 */
20
21
22 #include "sim-main.h"
23 #include "hw-main.h"
24
25 /* DEVICE
26
27 core - root of the device tree
28
29 DESCRIPTION
30
31 The core device, positioned at the root of the device tree appears
32 to its child devices as a normal device just like every other
33 device in the tree.
34
35 Internally it is implemented using a core object. Requests to
36 attach (or detach) address spaces are passed to that core object.
37 Requests to transfer (DMA) data are reflected back down the device
38 tree using the core_map data transfer methods.
39
40 PROPERTIES
41
42 None.
43
44 */
45
46
47 static void
48 dv_core_attach_address_callback (struct hw *me,
49 int level,
50 int space,
51 address_word addr,
52 address_word nr_bytes,
53 struct hw *client)
54 {
55 HW_TRACE ((me, "attach - level=%d, space=%d, addr=0x%lx, nr_bytes=%ld, client=%s",
56 level, space, (unsigned long) addr, (unsigned long) nr_bytes, hw_path (client)));
57 /* NOTE: At preset the space is assumed to be zero. Perhaphs the
58 space should be mapped onto something for instance: space0 -
59 unified memory; space1 - IO memory; ... */
60 if (space != 0)
61 hw_abort (me, "Hey! Unknown space %d", space);
62 sim_core_attach (hw_system (me),
63 NULL, /*cpu*/
64 level,
65 access_read_write_exec,
66 space, addr,
67 nr_bytes,
68 0, /* modulo */
69 client,
70 NULL);
71 }
72
73
74 static unsigned
75 dv_core_dma_read_buffer_callback (struct hw *me,
76 void *dest,
77 int space,
78 unsigned_word addr,
79 unsigned nr_bytes)
80 {
81 return sim_core_read_buffer (hw_system (me),
82 NULL, /*CPU*/
83 space, /*???*/
84 dest,
85 addr,
86 nr_bytes);
87 }
88
89
90 static unsigned
91 dv_core_dma_write_buffer_callback (struct hw *me,
92 const void *source,
93 int space,
94 unsigned_word addr,
95 unsigned nr_bytes,
96 int violate_read_only_section)
97 {
98 return sim_core_write_buffer (hw_system (me),
99 NULL, /*cpu*/
100 space, /*???*/
101 source,
102 addr,
103 nr_bytes);
104 }
105
106
107 static void
108 dv_core_finish (struct hw *me)
109 {
110 set_hw_attach_address (me, dv_core_attach_address_callback);
111 set_hw_dma_write_buffer (me, dv_core_dma_write_buffer_callback);
112 set_hw_dma_read_buffer (me, dv_core_dma_read_buffer_callback);
113 }
114
115 const struct hw_descriptor dv_core_descriptor[] = {
116 { "core", dv_core_finish, },
117 { NULL },
118 };