dev: Get PageBytes from the system in the ide_disk model.
authorGabe Black <gabeblack@google.com>
Tue, 29 Oct 2019 02:52:23 +0000 (19:52 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 30 Oct 2019 08:51:02 +0000 (08:51 +0000)
This avoids having to use TheISA::.

Change-Id: I020860ab343f9b6fafbcb0e23479d0b64f094512
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22268
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/dev/storage/ide_ctrl.cc
src/dev/storage/ide_disk.cc
src/dev/storage/ide_disk.hh

index 91f27bea38577b680534533cd4a885bf66576c9b..3851c83297336909968dbe2772e5f1c22c0b8703 100644 (file)
@@ -124,7 +124,7 @@ IdeController::IdeController(Params *p)
             panic("IDE controllers support a maximum "
                   "of 4 devices attached!\n");
         }
-        params()->disks[i]->setController(this);
+        params()->disks[i]->setController(this, sys->getPageBytes());
     }
 
     primary.select(false);
index c31c0928f7d2f662e8d3b453e464b8d1425980b0..f2cea5e5e9b9613f336a5956383b894ec70ca963 100644 (file)
@@ -56,7 +56,6 @@
 #include "base/chunk_generator.hh"
 #include "base/cprintf.hh" // csprintf
 #include "base/trace.hh"
-#include "config/the_isa.hh"
 #include "debug/IdeDisk.hh"
 #include "dev/storage/disk_image.hh"
 #include "dev/storage/ide_ctrl.hh"
@@ -440,7 +439,7 @@ IdeDisk::doDmaRead()
         // clear out the data buffer
         memset(dataBuffer, 0, MAX_DMA_SIZE);
         dmaReadCG = new ChunkGenerator(curPrd.getBaseAddr(),
-                curPrd.getByteCount(), TheISA::PageBytes);
+                curPrd.getByteCount(), pageBytes);
 
     }
     if (ctrl->dmaPending() || ctrl->drainState() != DrainState::Running) {
@@ -452,7 +451,7 @@ IdeDisk::doDmaRead()
                 &dmaReadWaitEvent, dataBuffer + dmaReadCG->complete());
         dmaReadBytes += dmaReadCG->size();
         dmaReadTxs++;
-        if (dmaReadCG->size() == TheISA::PageBytes)
+        if (dmaReadCG->size() == pageBytes)
             dmaReadFullPages++;
         dmaReadCG->next();
     } else {
@@ -523,7 +522,7 @@ IdeDisk::doDmaWrite()
     if (!dmaWriteCG) {
         // clear out the data buffer
         dmaWriteCG = new ChunkGenerator(curPrd.getBaseAddr(),
-                curPrd.getByteCount(), TheISA::PageBytes);
+                curPrd.getByteCount(), pageBytes);
     }
     if (ctrl->dmaPending() || ctrl->drainState() != DrainState::Running) {
         schedule(dmaWriteWaitEvent, curTick() + DMA_BACKOFF_PERIOD);
@@ -537,7 +536,7 @@ IdeDisk::doDmaWrite()
                 curPrd.getByteCount(), curPrd.getEOT());
         dmaWriteBytes += dmaWriteCG->size();
         dmaWriteTxs++;
-        if (dmaWriteCG->size() == TheISA::PageBytes)
+        if (dmaWriteCG->size() == pageBytes)
             dmaWriteFullPages++;
         dmaWriteCG->next();
     } else {
index fa5bb760de1694e946908acff3e56a08be5d4865..37aa9eed128306e4a6e89a472d290ec56a5bde5c 100644 (file)
@@ -241,6 +241,8 @@ class IdeDisk : public SimObject
     DmaState_t dmaState;
     /** Dma transaction is a read */
     bool dmaRead;
+    /** Size of OS pages. */
+    Addr pageBytes;
     /** PRD table base address */
     uint32_t curPrdAddr;
     /** PRD entry */
@@ -282,9 +284,12 @@ class IdeDisk : public SimObject
      * Set the controller for this device
      * @param c The IDE controller
      */
-    void setController(IdeController *c) {
-        if (ctrl) panic("Cannot change the controller once set!\n");
+    void
+    setController(IdeController *c, Addr page_bytes)
+    {
+        panic_if(ctrl, "Cannot change the controller once set!\n");
         ctrl = c;
+        pageBytes = page_bytes;
     }
 
     // Device register read/write