Make find_thread_ptid lookup thread map instead of iterate
[deliverable/binutils-gdb.git] / sim / bfin / dv-bfin_ebiu_amc.c
index 504e33ba66f02afecba7fbd85317cbe580f1f44c..ef437c4b8b559a435d9d0ff7121fbb0f07852174 100644 (file)
@@ -1,7 +1,7 @@
 /* Blackfin External Bus Interface Unit (EBIU) Asynchronous Memory Controller
    (AMC) model.
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
    Contributed by Analog Devices, Inc.
 
    This file is part of simulators.
@@ -29,7 +29,7 @@ struct bfin_ebiu_amc
 {
   bu32 base;
   int type;
-  bu32 bank_size;
+  bu32 bank_base, bank_size;
   unsigned (*io_write) (struct hw *, const void *, int, address_word,
                        unsigned, struct bfin_ebiu_amc *, bu32, bu32);
   unsigned (*io_read) (struct hw *, void *, int, address_word, unsigned,
@@ -58,14 +58,17 @@ struct bfin_ebiu_amc
 #define mmr_offset(mmr) (offsetof(struct bfin_ebiu_amc, mmr) - mmr_base())
 #define mmr_idx(mmr)    (mmr_offset (mmr) / 4)
 
-static const char * const bf50x_mmr_names[] = {
+static const char * const bf50x_mmr_names[] =
+{
   "EBIU_AMGCTL", "EBIU_AMBCTL0", "EBIU_AMBCTL1",
   [mmr_idx (bf50x.mode)] = "EBIU_MODE", "EBIU_FCTL",
 };
-static const char * const bf53x_mmr_names[] = {
+static const char * const bf53x_mmr_names[] =
+{
   "EBIU_AMGCTL", "EBIU_AMBCTL0", "EBIU_AMBCTL1",
 };
-static const char * const bf54x_mmr_names[] = {
+static const char * const bf54x_mmr_names[] =
+{
   "EBIU_AMGCTL", "EBIU_AMBCTL0", "EBIU_AMBCTL1",
   "EBIU_MSBCTL", "EBIU_ARBSTAT", "EBIU_MODE", "EBIU_FCTL",
 };
@@ -78,15 +81,15 @@ bfin_ebiu_amc_write_amgctl (struct hw *me, struct bfin_ebiu_amc *amc,
 {
   bu32 amben_old, amben, addr, i;
 
-  amben_old = MIN ((amc->amgctl >> 1) & 0x7, 4);
-  amben = MIN ((amgctl >> 1) & 0x7, 4);
+  amben_old = min ((amc->amgctl >> 1) & 0x7, 4);
+  amben = min ((amgctl >> 1) & 0x7, 4);
 
   HW_TRACE ((me, "reattaching banks: AMGCTL 0x%04x[%u] -> 0x%04x[%u]",
             amc->amgctl, amben_old, amgctl, amben));
 
   for (i = 0; i < 4; ++i)
     {
-      addr = BFIN_EBIU_AMC_BASE + i * amc->bank_size;
+      addr = amc->bank_base + i * amc->bank_size;
 
       if (i < amben_old)
        {
@@ -118,7 +121,8 @@ bf50x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
   switch (mmr_off)
     {
     case mmr_offset(amgctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, true);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true))
+       return 0;
       bfin_ebiu_amc_write_amgctl (me, amc, value);
       break;
     case mmr_offset(bf50x.ambctl0):
@@ -129,15 +133,17 @@ bf50x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
       break;
     case mmr_offset(bf50x.mode):
       /* XXX: implement this.  */
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, true);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true))
+       return 0;
       break;
     case mmr_offset(bf50x.fctl):
       /* XXX: implement this.  */
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, true);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true))
+       return 0;
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, true);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -152,7 +158,8 @@ bf53x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
   switch (mmr_off)
     {
     case mmr_offset(amgctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, true);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true))
+       return 0;
       bfin_ebiu_amc_write_amgctl (me, amc, value);
       break;
     case mmr_offset(bf53x.ambctl0):
@@ -163,7 +170,7 @@ bf53x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, true);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -178,7 +185,8 @@ bf54x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
   switch (mmr_off)
     {
     case mmr_offset(amgctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, true);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true))
+       return 0;
       bfin_ebiu_amc_write_amgctl (me, amc, value);
       break;
     case mmr_offset(bf54x.ambctl0):
@@ -201,7 +209,7 @@ bf54x_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, true);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -215,6 +223,10 @@ bfin_ebiu_amc_io_write_buffer (struct hw *me, const void *source, int space,
   bu32 mmr_off;
   bu32 value;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true))
+    return 0;
+
   value = dv_load_4 (source);
   mmr_off = addr - amc->base;
 
@@ -234,7 +246,8 @@ bf50x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
     {
     case mmr_offset(amgctl):
     case mmr_offset(bf50x.fctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, false);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false))
+       return 0;
       dv_store_2 (dest, *value16);
       break;
     case mmr_offset(bf50x.ambctl0):
@@ -244,7 +257,7 @@ bf50x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, false);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -259,7 +272,8 @@ bf53x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
   switch (mmr_off)
     {
     case mmr_offset(amgctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, false);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false))
+       return 0;
       dv_store_2 (dest, *value16);
       break;
     case mmr_offset(bf53x.ambctl0):
@@ -268,7 +282,7 @@ bf53x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, false);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -283,7 +297,8 @@ bf54x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
   switch (mmr_off)
     {
     case mmr_offset(amgctl):
-      dv_bfin_mmr_require_16 (me, addr, nr_bytes, false);
+      if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false))
+       return 0;
       dv_store_2 (dest, *value16);
       break;
     case mmr_offset(bf54x.ambctl0):
@@ -296,7 +311,7 @@ bf54x_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, false);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -310,6 +325,10 @@ bfin_ebiu_amc_io_read_buffer (struct hw *me, void *dest, int space,
   bu32 mmr_off;
   void *valuep;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, false))
+    return 0;
+
   mmr_off = addr - amc->base;
   valuep = (void *)((unsigned long)amc + mmr_base() + mmr_off);
 
@@ -332,7 +351,7 @@ bfin_ebiu_amc_attach_address_callback (struct hw *me,
   HW_TRACE ((me, "attach - level=%d, space=%d, addr=0x%lx, nr_bytes=%lu, client=%s",
             level, space, (unsigned long) addr, (unsigned long) nr_bytes, hw_path (client)));
 
-  if (addr + nr_bytes > 4)
+  if (addr + nr_bytes > ARRAY_SIZE (amc->slaves))
     hw_abort (me, "ebiu amc attaches are done in terms of banks");
 
   while (nr_bytes--)
@@ -398,6 +417,7 @@ bfin_ebiu_amc_finish (struct hw *me)
       reg_size = sizeof (amc->bf50x) + 4;
 
       /* Initialize the AMC.  */
+      amc->bank_base     = BFIN_EBIU_AMC_BASE;
       amc->bank_size     = 1 * 1024 * 1024;
       amgctl             = 0x00F3;
       amc->bf50x.ambctl0 = 0x0000FFC2;
@@ -412,6 +432,7 @@ bfin_ebiu_amc_finish (struct hw *me)
       reg_size = sizeof (amc->bf54x) + 4;
 
       /* Initialize the AMC.  */
+      amc->bank_base     = BFIN_EBIU_AMC_BASE;
       amc->bank_size     = 64 * 1024 * 1024;
       amgctl             = 0x0002;
       amc->bf54x.ambctl0 = 0xFFC2FFC2;
@@ -432,6 +453,7 @@ bfin_ebiu_amc_finish (struct hw *me)
       reg_size = sizeof (amc->bf53x) + 4;
 
       /* Initialize the AMC.  */
+      amc->bank_base     = BFIN_EBIU_AMC_BASE;
       if (amc->type == 561)
        amc->bank_size   = 64 * 1024 * 1024;
       else
@@ -450,7 +472,8 @@ bfin_ebiu_amc_finish (struct hw *me)
   bfin_ebiu_amc_write_amgctl (me, amc, amgctl);
 }
 
-const struct hw_descriptor dv_bfin_ebiu_amc_descriptor[] = {
+const struct hw_descriptor dv_bfin_ebiu_amc_descriptor[] =
+{
   {"bfin_ebiu_amc", bfin_ebiu_amc_finish,},
   {NULL, NULL},
 };
This page took 0.027424 seconds and 4 git commands to generate.