Commit | Line | Data |
---|---|---|
34cf5112 MF |
1 | /* Handle 0x900000xx addresses in the sim. |
2 | ||
618f726f | 3 | Copyright (C) 2004-2016 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 | ||
21 | #include "sim-main.h" | |
22 | #include "hw-main.h" | |
23 | ||
24 | struct cris_900000xx_hw | |
25 | { | |
26 | }; | |
27 | ||
28 | static unsigned | |
29 | cris_io_write_buffer (struct hw *me, const void *source, | |
30 | int space, address_word addr, unsigned nr_bytes) | |
31 | { | |
32 | static const unsigned char ok[] = { 4, 0, 0, 0x90}; | |
33 | static const unsigned char bad[] = { 8, 0, 0, 0x90}; | |
34 | SIM_CPU *cpu = hw_system_cpu (me); | |
35 | SIM_DESC sd = CPU_STATE (cpu); | |
36 | sim_cia cia = CPU_PC_GET (cpu); | |
37 | ||
38 | if (addr == 0x90000004 && memcmp (source, ok, sizeof ok) == 0) | |
39 | return cris_break_13_handler (cpu, 1, 0, 0, 0, 0, 0, 0, cia); | |
40 | else if (addr == 0x90000008 | |
41 | && memcmp (source, bad, sizeof bad) == 0) | |
42 | return cris_break_13_handler (cpu, 1, 34, 0, 0, 0, 0, 0, cia); | |
43 | ||
44 | /* If it wasn't one of those, send an invalid-memory signal. */ | |
45 | sim_core_signal (sd, cpu, cia, 0, nr_bytes, addr, | |
46 | write_transfer, sim_core_unmapped_signal); | |
47 | ||
48 | return 0; | |
49 | } | |
50 | ||
51 | /* Instance initializer function. */ | |
52 | ||
53 | static void | |
54 | attach_regs (struct hw *me, struct cris_900000xx_hw *hw) | |
55 | { | |
56 | address_word attach_address; | |
57 | int attach_space; | |
58 | unsigned attach_size; | |
59 | reg_property_spec reg; | |
60 | ||
61 | if (hw_find_property (me, "reg") == NULL) | |
62 | hw_abort (me, "Missing \"reg\" property"); | |
63 | ||
64 | if (!hw_find_reg_array_property (me, "reg", 0, ®)) | |
65 | hw_abort (me, "\"reg\" property must contain three addr/size entries"); | |
66 | ||
67 | hw_unit_address_to_attach_address (hw_parent (me), | |
68 | ®.address, | |
69 | &attach_space, &attach_address, me); | |
70 | hw_unit_size_to_attach_size (hw_parent (me), ®.size, &attach_size, me); | |
71 | ||
72 | hw_attach_address (hw_parent (me), | |
73 | 0, attach_space, attach_address, attach_size, me); | |
74 | } | |
75 | ||
76 | static void | |
77 | cris_900000xx_finish (struct hw *me) | |
78 | { | |
79 | struct cris_900000xx_hw *hw; | |
80 | ||
81 | hw = HW_ZALLOC (me, struct cris_900000xx_hw); | |
82 | set_hw_data (me, hw); | |
83 | set_hw_io_write_buffer (me, cris_io_write_buffer); | |
84 | ||
85 | attach_regs (me, hw); | |
86 | } | |
87 | ||
88 | const struct hw_descriptor dv_cris_900000xx_descriptor[] = { | |
89 | { "cris_900000xx", cris_900000xx_finish, }, | |
90 | { NULL }, | |
91 | }; |