]>
Commit | Line | Data |
---|---|---|
34cf5112 MF |
1 | /* Handle 0x900000xx addresses in the sim. |
2 | ||
4a94e368 | 3 | Copyright (C) 2004-2022 Free Software Foundation, Inc. |
34cf5112 MF |
4 | Contributed by Axis Communications. |
5 | ||
6 | This file is part of the GNU simulators. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
20 | ||
6df01ab8 MF |
21 | /* This must come before any other includes. */ |
22 | #include "defs.h" | |
23 | ||
34cf5112 MF |
24 | #include "sim-main.h" |
25 | #include "hw-main.h" | |
26 | ||
27 | struct cris_900000xx_hw | |
28 | { | |
29 | }; | |
30 | ||
31 | static unsigned | |
32 | cris_io_write_buffer (struct hw *me, const void *source, | |
33 | int space, address_word addr, unsigned nr_bytes) | |
34 | { | |
35 | static const unsigned char ok[] = { 4, 0, 0, 0x90}; | |
36 | static const unsigned char bad[] = { 8, 0, 0, 0x90}; | |
37 | SIM_CPU *cpu = hw_system_cpu (me); | |
38 | SIM_DESC sd = CPU_STATE (cpu); | |
39 | sim_cia cia = CPU_PC_GET (cpu); | |
40 | ||
41 | if (addr == 0x90000004 && memcmp (source, ok, sizeof ok) == 0) | |
42 | return cris_break_13_handler (cpu, 1, 0, 0, 0, 0, 0, 0, cia); | |
43 | else if (addr == 0x90000008 | |
44 | && memcmp (source, bad, sizeof bad) == 0) | |
45 | return cris_break_13_handler (cpu, 1, 34, 0, 0, 0, 0, 0, cia); | |
46 | ||
47 | /* If it wasn't one of those, send an invalid-memory signal. */ | |
48 | sim_core_signal (sd, cpu, cia, 0, nr_bytes, addr, | |
49 | write_transfer, sim_core_unmapped_signal); | |
50 | ||
51 | return 0; | |
52 | } | |
53 | ||
54 | /* Instance initializer function. */ | |
55 | ||
56 | static void | |
57 | attach_regs (struct hw *me, struct cris_900000xx_hw *hw) | |
58 | { | |
59 | address_word attach_address; | |
60 | int attach_space; | |
61 | unsigned attach_size; | |
62 | reg_property_spec reg; | |
63 | ||
64 | if (hw_find_property (me, "reg") == NULL) | |
65 | hw_abort (me, "Missing \"reg\" property"); | |
66 | ||
67 | if (!hw_find_reg_array_property (me, "reg", 0, ®)) | |
68 | hw_abort (me, "\"reg\" property must contain three addr/size entries"); | |
69 | ||
70 | hw_unit_address_to_attach_address (hw_parent (me), | |
71 | ®.address, | |
72 | &attach_space, &attach_address, me); | |
73 | hw_unit_size_to_attach_size (hw_parent (me), ®.size, &attach_size, me); | |
74 | ||
75 | hw_attach_address (hw_parent (me), | |
76 | 0, attach_space, attach_address, attach_size, me); | |
77 | } | |
78 | ||
79 | static void | |
80 | cris_900000xx_finish (struct hw *me) | |
81 | { | |
82 | struct cris_900000xx_hw *hw; | |
83 | ||
84 | hw = HW_ZALLOC (me, struct cris_900000xx_hw); | |
85 | set_hw_data (me, hw); | |
86 | set_hw_io_write_buffer (me, cris_io_write_buffer); | |
87 | ||
88 | attach_regs (me, hw); | |
89 | } | |
90 | ||
91 | const struct hw_descriptor dv_cris_900000xx_descriptor[] = { | |
92 | { "cris_900000xx", cris_900000xx_finish, }, | |
93 | { NULL }, | |
94 | }; |