sim: sim-core: pass down cpu to hw accesses when available
authorMike Frysinger <vapier@gentoo.org>
Sat, 26 Dec 2015 19:16:51 +0000 (14:16 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 26 Dec 2015 19:22:14 +0000 (14:22 -0500)
The bfin port has been using the device callback largely so it could be
passed the cpu when available.  Add this logic to the common core code
so all ports get access to the active cpu.

The semantics of these buffer functions are changed slightly in that
errors halt the engine synchronously rather than returning the length
to the caller.  We'll probably adjust this in a follow up commit.

The bfin code isn't updated just yet as it has a bit more logic in the
device layer that needs to be unwound at which point we can delete it
entirely.

sim/common/ChangeLog
sim/common/sim-core.c

index 3e6e3d9f8bbca4542aa51db14dfc8c3cc7ac56be..05cdda8086f542da5d5d1222cfc7235dfe13fbef 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-26  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-core.c (sim_core_read_buffer): Move cia decl to top of func.
+       Call sim_cpu_hw_io_read_buffer if cpu is valid.
+       (sim_core_write_buffer): Move cia decl to top of func.  Call
+       sim_cpu_hw_io_write_buffer if cpu is valid.
+
 2015-12-25  Mike Frysinger  <vapier@gentoo.org>
 
        * hw-properties.c (hw_find_ihandle_runtime_property): Delete
index 26fabd56e55cdfa0f806b7e82da23cfb07d6d424..68212e9c24f43efa9aed163bad41f22190f20c2b 100644 (file)
@@ -511,11 +511,23 @@ sim_core_read_buffer (SIM_DESC sd,
        int nr_bytes = len - count;
        if (raddr + nr_bytes - 1> mapping->bound)
          nr_bytes = mapping->bound - raddr + 1;
-       if (sim_hw_io_read_buffer (sd, mapping->device,
-                                  (unsigned_1*)buffer + count,
-                                  mapping->space,
-                                  raddr,
-                                  nr_bytes) != nr_bytes)
+       /* If the access was initiated by a cpu, pass it down so errors can
+          be propagated properly.  For other sources (e.g. GDB or DMA), we
+          can only signal errors via the return value.  */
+       if (cpu)
+         {
+           sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA;
+           sim_cpu_hw_io_read_buffer (cpu, cia, mapping->device,
+                                      (unsigned_1*)buffer + count,
+                                      mapping->space,
+                                      raddr,
+                                      nr_bytes);
+         }
+       else if (sim_hw_io_read_buffer (sd, mapping->device,
+                                       (unsigned_1*)buffer + count,
+                                       mapping->space,
+                                       raddr,
+                                       nr_bytes) != nr_bytes)
          break;
        count += nr_bytes;
        continue;
@@ -577,11 +589,23 @@ sim_core_write_buffer (SIM_DESC sd,
          int nr_bytes = len - count;
          if (raddr + nr_bytes - 1 > mapping->bound)
            nr_bytes = mapping->bound - raddr + 1;
-         if (sim_hw_io_write_buffer (sd, mapping->device,
-                                     (unsigned_1*)buffer + count,
-                                     mapping->space,
-                                     raddr,
-                                     nr_bytes) != nr_bytes)
+         /* If the access was initiated by a cpu, pass it down so errors can
+            be propagated properly.  For other sources (e.g. GDB or DMA), we
+            can only signal errors via the return value.  */
+         if (cpu)
+           {
+             sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA;
+             sim_cpu_hw_io_write_buffer (cpu, cia, mapping->device,
+                                         (unsigned_1*)buffer + count,
+                                         mapping->space,
+                                         raddr,
+                                         nr_bytes);
+           }
+         else if (sim_hw_io_write_buffer (sd, mapping->device,
+                                         (unsigned_1*)buffer + count,
+                                         mapping->space,
+                                         raddr,
+                                         nr_bytes) != nr_bytes)
            break;
          count += nr_bytes;
          continue;
This page took 0.028002 seconds and 4 git commands to generate.