Add some basic statistics to the disk model
authorRon Dreslinski <rdreslin@umich.edu>
Wed, 29 Mar 2006 19:27:10 +0000 (14:27 -0500)
committerRon Dreslinski <rdreslin@umich.edu>
Wed, 29 Mar 2006 19:27:10 +0000 (14:27 -0500)
--HG--
extra : convert_revision : 0f3a45745b0122de64a2f434604a474df04f2938

dev/ide_disk.cc
dev/ide_disk.hh

index 41400c59042c2dc562c948d265ac9cd3fdb6eeb6..c13556ed633568369b56dfa289dd781f30703e78 100644 (file)
@@ -377,6 +377,37 @@ IdeDisk::dmaPrdReadDone()
         doDmaWrite();
 }
 
+void
+IdeDisk::regStats()
+{
+    using namespace Stats;
+    dmaReadFullPages
+        .name(name() + ".dma_read_full_pages")
+        .desc("Number of full page size DMA reads (not PRD).")
+        ;
+    dmaReadBytes
+        .name(name() + ".dma_read_bytes")
+        .desc("Number of bytes transfered via DMA reads (not PRD).")
+        ;
+    dmaReadTxs
+        .name(name() + ".dma_read_txs")
+        .desc("Number of DMA read transactions (not PRD).")
+        ;
+
+    dmaWriteFullPages
+        .name(name() + ".dma_write_full_pages")
+        .desc("Number of full page size DMA writes.")
+        ;
+    dmaWriteBytes
+        .name(name() + ".dma_write_bytes")
+        .desc("Number of bytes transfered via DMA writes.")
+        ;
+    dmaWriteTxs
+        .name(name() + ".dma_write_txs")
+        .desc("Number of DMA write transactions.")
+        ;
+}
+
 void
 IdeDisk::doDmaRead()
 {
@@ -399,6 +430,10 @@ IdeDisk::doDmaRead()
 
         dmaInterfaceBytes = bytesInPage;
 
+        if (bytesInPage == TheISA::VMPageSize)
+            dmaReadFullPages++;
+        dmaReadBytes += bytesInPage;
+        dmaReadTxs++;
         dmaInterface->doDMA(Read, dmaAddr, bytesInPage,
                             curTick + totalDiskDelay, &dmaReadEvent);
     } else {
@@ -430,6 +465,11 @@ IdeDisk::dmaReadDone()
         bytesInPage = bytesInDmaPage(curAddr, bytesLeft);
         dmaInterfaceBytes += bytesInPage;
 
+        if (bytesInPage == TheISA::VMPageSize)
+            dmaReadFullPages++;
+        dmaReadBytes += bytesInPage;
+        dmaReadTxs++;
+
         dmaInterface->doDMA(Read, dmaAddr, bytesInPage,
                             curTick, &dmaReadEvent);
 
@@ -504,6 +544,11 @@ IdeDisk::doDmaWrite()
 
         dmaInterfaceBytes = bytesInPage;
 
+        if (bytesInPage == TheISA::VMPageSize)
+            dmaWriteFullPages++;
+        dmaWriteBytes += bytesInPage;
+        dmaWriteTxs++;
+
         dmaInterface->doDMA(WriteInvalidate, dmaAddr,
                             bytesInPage, curTick + totalDiskDelay,
                             &dmaWriteEvent);
@@ -535,6 +580,11 @@ IdeDisk::dmaWriteDone()
         bytesInPage = bytesInDmaPage(curAddr, bytesLeft);
         dmaInterfaceBytes += bytesInPage;
 
+        if (bytesInPage == TheISA::VMPageSize)
+            dmaWriteFullPages++;
+        dmaWriteBytes += bytesInPage;
+        dmaWriteTxs++;
+
         dmaInterface->doDMA(WriteInvalidate, dmaAddr,
                             bytesInPage, curTick,
                             &dmaWriteEvent);
index a656ca464ef8c14ae52a5480fa0ecc9800ffbf60..f743e7a45533307c6566b77038429f392b1f41b9 100644 (file)
@@ -33,6 +33,7 @@
 #ifndef __IDE_DISK_HH__
 #define __IDE_DISK_HH__
 
+#include "base/statistics.hh"
 #include "dev/disk_image.hh"
 #include "dev/ide_atareg.h"
 #include "dev/ide_ctrl.hh"
@@ -237,6 +238,13 @@ class IdeDisk : public SimObject
     /** Interrupt pending */
     bool intrPending;
 
+    Stats::Scalar<> dmaReadFullPages;
+    Stats::Scalar<> dmaReadBytes;
+    Stats::Scalar<> dmaReadTxs;
+    Stats::Scalar<> dmaWriteFullPages;
+    Stats::Scalar<> dmaWriteBytes;
+    Stats::Scalar<> dmaWriteTxs;
+
   public:
     /**
      * Create and initialize this Disk.
@@ -259,6 +267,12 @@ class IdeDisk : public SimObject
      */
     void reset(int id);
 
+    /**
+     * Register statistics.
+     */
+    void regStats();
+
+
     /**
      * Set the controller for this device
      * @param c The IDE controller