PowerPC64 .branch_lt address
[binutils-gdb.git] / sim / bfin / dv-bfin_wdog.c
index 07c249ec06397365737c787696290a52ce9d78ce..b402f114a24ee9bc5fa42f4c5c63b7930ae16c5e 100644 (file)
@@ -1,6 +1,6 @@
 /* Blackfin Watchdog (WDOG) model.
 
-   Copyright (C) 2010-2013 Free Software Foundation, Inc.
+   Copyright (C) 2010-2022 Free Software Foundation, Inc.
    Contributed by Analog Devices, Inc.
 
    This file is part of simulators.
@@ -18,7 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "config.h"
+/* This must come before any other includes.  */
+#include "defs.h"
 
 #include "sim-main.h"
 #include "dv-sockser.h"
@@ -61,13 +62,17 @@ bfin_wdog_io_write_buffer (struct hw *me, const void *source,
   bu32 *value32p;
   void *valuep;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true))
+    return 0;
+
   if (nr_bytes == 4)
     value = dv_load_4 (source);
   else
     value = dv_load_2 (source);
 
   mmr_off = addr - wdog->base;
-  valuep = (void *)((unsigned long)wdog + mmr_base() + mmr_off);
+  valuep = (void *)((uintptr_t)wdog + mmr_base() + mmr_off);
   value16p = valuep;
   value32p = valuep;
 
@@ -111,8 +116,12 @@ bfin_wdog_io_read_buffer (struct hw *me, void *dest,
   bu32 *value32p;
   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 - wdog->base;
-  valuep = (void *)((unsigned long)wdog + mmr_base() + mmr_off);
+  valuep = (void *)((uintptr_t)wdog + mmr_base() + mmr_off);
   value16p = valuep;
   value32p = valuep;
 
@@ -121,7 +130,8 @@ bfin_wdog_io_read_buffer (struct hw *me, void *dest,
   switch (mmr_off)
     {
     case mmr_offset(ctl):
-      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, *value16p);
       break;