]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/bfin/dv-bfin_cec.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / sim / bfin / dv-bfin_cec.c
index 88fe9ddeabd36561ab5317edeef1297b7aaf10f1..2236830d24d2151eeb86ee24001ad78f44135939 100644 (file)
@@ -1,6 +1,6 @@
 /* Blackfin Core Event Controller (CEC) model.
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2021 Free Software Foundation, Inc.
    Contributed by Analog Devices, Inc.
 
    This file is part of simulators.
@@ -39,7 +39,8 @@ struct bfin_cec
 #define mmr_base()      offsetof(struct bfin_cec, evt_override)
 #define mmr_offset(mmr) (offsetof(struct bfin_cec, mmr) - mmr_base())
 
-static const char * const mmr_names[] = {
+static const char * const mmr_names[] =
+{
   "EVT_OVERRIDE", "IMASK", "IPEND", "ILAT", "IPRIO",
 };
 #define mmr_name(off) mmr_names[(off) / 4]
@@ -81,6 +82,10 @@ bfin_cec_io_write_buffer (struct hw *me, const void *source,
   bu32 mmr_off;
   bu32 value;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, true))
+    return 0;
+
   value = dv_load_4 (source);
   mmr_off = addr - cec->base;
 
@@ -99,7 +104,7 @@ bfin_cec_io_write_buffer (struct hw *me, const void *source,
       /* Read-only register.  */
       break;
     case mmr_offset(ilat):
-      dv_w1c_4 (&cec->ilat, value, 0);
+      dv_w1c_4 (&cec->ilat, value, 0xffee);
       break;
     case mmr_offset(iprio):
       cec->iprio = (value & IVG_UNMASKABLE_B);
@@ -117,6 +122,10 @@ bfin_cec_io_read_buffer (struct hw *me, void *dest,
   bu32 mmr_off;
   bu32 *valuep;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false))
+    return 0;
+
   mmr_off = addr - cec->base;
   valuep = (void *)((unsigned long)cec + mmr_base() + mmr_off);
 
@@ -127,7 +136,8 @@ bfin_cec_io_read_buffer (struct hw *me, void *dest,
   return nr_bytes;
 }
 
-static const struct hw_port_descriptor bfin_cec_ports[] = {
+static const struct hw_port_descriptor bfin_cec_ports[] =
+{
   { "emu",   IVG_EMU,   0, input_port, },
   { "rst",   IVG_RST,   0, input_port, },
   { "nmi",   IVG_NMI,   0, input_port, },
@@ -205,12 +215,14 @@ bfin_cec_finish (struct hw *me)
   cec->ipend = IVG_RST_B | IVG_IRPTEN_B;
 }
 
-const struct hw_descriptor dv_bfin_cec_descriptor[] = {
+const struct hw_descriptor dv_bfin_cec_descriptor[] =
+{
   {"bfin_cec", bfin_cec_finish,},
   {NULL, NULL},
 };
 
-static const char * const excp_decoded[] = {
+static const char * const excp_decoded[] =
+{
   [VEC_SYS        ] = "Custom exception 0 (system call)",
   [VEC_EXCPT01    ] = "Custom exception 1 (software breakpoint)",
   [VEC_EXCPT02    ] = "Custom exception 2 (KGDB hook)",
@@ -595,7 +607,7 @@ _cec_raise (SIM_CPU *cpu, struct bfin_cec *cec, int ivg)
       else
        SET_PCREG (cec_get_evt (cpu, ivg));
 
-      TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC (to EVT%i):", ivg);
+      BFIN_TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC (to EVT%i):", ivg);
       BFIN_CPU_STATE.did_jump = true;
 
       /* Enable the global interrupt mask upon interrupt entry.  */
@@ -644,7 +656,7 @@ cec_latch (SIM_CPU *cpu, int ivg)
     {
       bu32 oldpc = PCREG;
       SET_PCREG (cec_read_ret_reg (cpu, ivg));
-      TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC");
+      BFIN_TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC");
       return;
     }
 
@@ -675,7 +687,7 @@ cec_return (SIM_CPU *cpu, int ivg)
   if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
     {
       SET_PCREG (cec_read_ret_reg (cpu, ivg));
-      TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC");
+      BFIN_TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC");
       return;
     }
 
@@ -740,9 +752,9 @@ cec_return (SIM_CPU *cpu, int ivg)
   /* XXX: Delayed clear shows bad PCREG register trace above ?  */
   SET_PCREG (newpc & ~1);
 
-  TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC (from EVT%i)", ivg);
+  BFIN_TRACE_BRANCH (cpu, oldpc, PCREG, -1, "CEC changed PC (from EVT%i)", ivg);
 
-  /* Update ipend after the TRACE_BRANCH so dv-bfin_trace
+  /* Update ipend after the BFIN_TRACE_BRANCH so dv-bfin_trace
      knows current CEC state wrt overflow.  */
   if (!snen)
     cec->ipend &= ~(1 << ivg);