dv-m32r_cache.c revision 1.1.1.4.2.1 1 1.1 christos /* Handle cache related addresses.
2 1.1 christos
3 1.1.1.4.2.1 perseant Copyright (C) 1996-2023 Free Software Foundation, Inc.
4 1.1 christos Contributed by Cygnus Solutions and Mike Frysinger.
5 1.1 christos
6 1.1 christos This file is part of the GNU simulators.
7 1.1 christos
8 1.1 christos This program is free software; you can redistribute it and/or modify
9 1.1 christos it under the terms of the GNU General Public License as published by
10 1.1 christos the Free Software Foundation; either version 3 of the License, or
11 1.1 christos (at your option) any later version.
12 1.1 christos
13 1.1 christos This program is distributed in the hope that it will be useful,
14 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
15 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 1.1 christos GNU General Public License for more details.
17 1.1 christos
18 1.1 christos You should have received a copy of the GNU General Public License
19 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 1.1 christos
21 1.1.1.4.2.1 perseant /* This must come before any other includes. */
22 1.1.1.4.2.1 perseant #include "defs.h"
23 1.1 christos
24 1.1 christos #include "sim-main.h"
25 1.1 christos #include "hw-main.h"
26 1.1 christos
27 1.1 christos #include "dv-m32r_cache.h"
28 1.1 christos
29 1.1 christos struct m32r_cache_hw
30 1.1 christos {
31 1.1 christos };
32 1.1 christos
33 1.1 christos static unsigned
34 1.1 christos cris_io_write_buffer (struct hw *me, const void *source,
35 1.1 christos int space, address_word addr, unsigned nr_bytes)
36 1.1 christos {
37 1.1 christos SIM_DESC sd = hw_system (me);
38 1.1 christos
39 1.1 christos #if WITH_SCACHE
40 1.1 christos /* MSPR support is deprecated but is kept in for upward compatibility
41 1.1 christos with existing overlay support. */
42 1.1 christos switch (addr)
43 1.1 christos {
44 1.1 christos case MSPR_ADDR:
45 1.1 christos if ((*(const char *) source & MSPR_PURGE) != 0)
46 1.1 christos scache_flush (sd);
47 1.1 christos break;
48 1.1 christos
49 1.1 christos case MCCR_ADDR:
50 1.1 christos if ((*(const char *) source & MCCR_CP) != 0)
51 1.1 christos scache_flush (sd);
52 1.1 christos break;
53 1.1 christos }
54 1.1 christos #endif
55 1.1 christos
56 1.1 christos return nr_bytes;
57 1.1 christos }
58 1.1 christos
59 1.1 christos static void
60 1.1 christos attach_regs (struct hw *me, struct m32r_cache_hw *hw)
61 1.1 christos {
62 1.1 christos address_word attach_address;
63 1.1 christos int attach_space;
64 1.1 christos unsigned attach_size;
65 1.1 christos reg_property_spec reg;
66 1.1 christos
67 1.1 christos if (hw_find_property (me, "reg") == NULL)
68 1.1 christos hw_abort (me, "Missing \"reg\" property");
69 1.1 christos
70 1.1 christos if (!hw_find_reg_array_property (me, "reg", 0, ®))
71 1.1 christos hw_abort (me, "\"reg\" property must contain three addr/size entries");
72 1.1 christos
73 1.1 christos hw_unit_address_to_attach_address (hw_parent (me),
74 1.1 christos ®.address,
75 1.1 christos &attach_space, &attach_address, me);
76 1.1 christos hw_unit_size_to_attach_size (hw_parent (me), ®.size, &attach_size, me);
77 1.1 christos
78 1.1 christos hw_attach_address (hw_parent (me),
79 1.1 christos 0, attach_space, attach_address, attach_size, me);
80 1.1 christos }
81 1.1 christos
82 1.1 christos static void
83 1.1 christos m32r_cache_finish (struct hw *me)
84 1.1 christos {
85 1.1 christos struct m32r_cache_hw *hw;
86 1.1 christos
87 1.1 christos hw = HW_ZALLOC (me, struct m32r_cache_hw);
88 1.1 christos set_hw_data (me, hw);
89 1.1 christos set_hw_io_write_buffer (me, cris_io_write_buffer);
90 1.1 christos
91 1.1 christos attach_regs (me, hw);
92 1.1 christos }
93 1.1 christos
94 1.1 christos const struct hw_descriptor dv_m32r_cache_descriptor[] = {
95 1.1 christos { "m32r_cache", m32r_cache_finish, },
96 1.1 christos { NULL },
97 1.1 christos };
98