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