Home | History | Annotate | Line # | Download | only in m32r
dv-m32r_cache.c revision 1.1
      1  1.1  christos /* Handle cache related addresses.
      2  1.1  christos 
      3  1.1  christos    Copyright (C) 1996-2016 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  christos #include "config.h"
     22  1.1  christos 
     23  1.1  christos #include "sim-main.h"
     24  1.1  christos #include "hw-main.h"
     25  1.1  christos 
     26  1.1  christos #include "dv-m32r_cache.h"
     27  1.1  christos 
     28  1.1  christos struct m32r_cache_hw
     29  1.1  christos {
     30  1.1  christos };
     31  1.1  christos 
     32  1.1  christos static unsigned
     33  1.1  christos cris_io_write_buffer (struct hw *me, const void *source,
     34  1.1  christos 		      int space, address_word addr, unsigned nr_bytes)
     35  1.1  christos {
     36  1.1  christos   SIM_DESC sd = hw_system (me);
     37  1.1  christos 
     38  1.1  christos #if WITH_SCACHE
     39  1.1  christos   /* MSPR support is deprecated but is kept in for upward compatibility
     40  1.1  christos      with existing overlay support.  */
     41  1.1  christos   switch (addr)
     42  1.1  christos     {
     43  1.1  christos     case MSPR_ADDR:
     44  1.1  christos       if ((*(const char *) source & MSPR_PURGE) != 0)
     45  1.1  christos 	scache_flush (sd);
     46  1.1  christos       break;
     47  1.1  christos 
     48  1.1  christos     case MCCR_ADDR:
     49  1.1  christos       if ((*(const char *) source & MCCR_CP) != 0)
     50  1.1  christos 	scache_flush (sd);
     51  1.1  christos       break;
     52  1.1  christos     }
     53  1.1  christos #endif
     54  1.1  christos 
     55  1.1  christos   return nr_bytes;
     56  1.1  christos }
     57  1.1  christos 
     58  1.1  christos static void
     59  1.1  christos attach_regs (struct hw *me, struct m32r_cache_hw *hw)
     60  1.1  christos {
     61  1.1  christos   address_word attach_address;
     62  1.1  christos   int attach_space;
     63  1.1  christos   unsigned attach_size;
     64  1.1  christos   reg_property_spec reg;
     65  1.1  christos 
     66  1.1  christos   if (hw_find_property (me, "reg") == NULL)
     67  1.1  christos     hw_abort (me, "Missing \"reg\" property");
     68  1.1  christos 
     69  1.1  christos   if (!hw_find_reg_array_property (me, "reg", 0, &reg))
     70  1.1  christos     hw_abort (me, "\"reg\" property must contain three addr/size entries");
     71  1.1  christos 
     72  1.1  christos   hw_unit_address_to_attach_address (hw_parent (me),
     73  1.1  christos 				     &reg.address,
     74  1.1  christos 				     &attach_space, &attach_address, me);
     75  1.1  christos   hw_unit_size_to_attach_size (hw_parent (me), &reg.size, &attach_size, me);
     76  1.1  christos 
     77  1.1  christos   hw_attach_address (hw_parent (me),
     78  1.1  christos 		     0, attach_space, attach_address, attach_size, me);
     79  1.1  christos }
     80  1.1  christos 
     81  1.1  christos static void
     82  1.1  christos m32r_cache_finish (struct hw *me)
     83  1.1  christos {
     84  1.1  christos   struct m32r_cache_hw *hw;
     85  1.1  christos 
     86  1.1  christos   hw = HW_ZALLOC (me, struct m32r_cache_hw);
     87  1.1  christos   set_hw_data (me, hw);
     88  1.1  christos   set_hw_io_write_buffer (me, cris_io_write_buffer);
     89  1.1  christos 
     90  1.1  christos   attach_regs (me, hw);
     91  1.1  christos }
     92  1.1  christos 
     93  1.1  christos const struct hw_descriptor dv_m32r_cache_descriptor[] = {
     94  1.1  christos   { "m32r_cache", m32r_cache_finish, },
     95  1.1  christos   { NULL },
     96  1.1  christos };
     97