Pouya Fotouhi has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/22082 )

Change subject: dev: Adding support for large BAR
......................................................................

dev: Adding support for large BAR

Checks if a BAR is used as a large BAR, and return proper address range.
Bit 2 in a BAR indicates a 64-bit decoder. The addresses in BARAddrs are full
addresses.

Change-Id: I93303d36ac83dab9ed6837c81e77c9dfb778f409
---
M src/dev/pci/device.cc
M src/dev/pci/device.hh
2 files changed, 31 insertions(+), 3 deletions(-)



diff --git a/src/dev/pci/device.cc b/src/dev/pci/device.cc
index 1097573..efe24f8 100644
--- a/src/dev/pci/device.cc
+++ b/src/dev/pci/device.cc
@@ -380,9 +380,28 @@
// does it mean something special to write 0 to a BAR?
                         he_new_bar &= ~bar_mask;
                         if (he_new_bar) {
-                            BARAddrs[barnum] = BAR_IO_SPACE(he_old_bar) ?
-                                hostInterface.pioAddr(he_new_bar) :
-                                hostInterface.memAddr(he_new_bar);
+                            if (isLargeBAR(barnum)) {
+                                // IO BARs can't be set as large BAR
+                                assert(!BAR_IO_SPACE(he_old_bar));
+                                uint64_t he_large_bar =
+                                         letoh(config.baseAddr[barnum+1]);
+                                he_large_bar = he_large_bar << 32;
+                                he_large_bar += he_new_bar;
+                                BARAddrs[barnum] =
+ hostInterface.memAddr(he_large_bar);
+                            } else if (isLargeBAR(barnum-1)) {
+                                BARAddrs[barnum] = 0;
+                                uint64_t he_large_bar = he_new_bar;
+                                he_large_bar = he_large_bar << 32;
+                                he_large_bar +=
+                                         letoh(config.baseAddr[barnum-1]);
+                                BARAddrs[barnum-1] =
+ hostInterface.memAddr(he_large_bar);
+                           } else {
+ BARAddrs[barnum] = BAR_IO_SPACE(he_old_bar) ?
+                                    hostInterface.pioAddr(he_new_bar) :
+                                    hostInterface.memAddr(he_new_bar);
+                            }
                             pioPort.sendRangeChange();
                         }
                     }
diff --git a/src/dev/pci/device.hh b/src/dev/pci/device.hh
index ba783a6..306dda7 100644
--- a/src/dev/pci/device.hh
+++ b/src/dev/pci/device.hh
@@ -116,6 +116,15 @@
     bool legacyIO[6];

     /**
+     * Does the given BAR represent is 64-bit address?
+     */
+    bool
+    isLargeBAR(int bar) const
+    {
+        return bits(config.baseAddr[bar],2,1) == 0x2;
+    }
+
+    /**
      * Does the given address lie within the space mapped by the given
      * base address register?
      */

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/22082
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I93303d36ac83dab9ed6837c81e77c9dfb778f409
Gerrit-Change-Number: 22082
Gerrit-PatchSet: 1
Gerrit-Owner: Pouya Fotouhi <pfoto...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to