Get rid of unneeded union.
authorSteve Reinhardt <stever@eecs.umich.edu>
Mon, 28 Aug 2006 18:01:25 +0000 (11:01 -0700)
committerSteve Reinhardt <stever@eecs.umich.edu>
Mon, 28 Aug 2006 18:01:25 +0000 (11:01 -0700)
Verify that BAR sizes are powers of two.

--HG--
extra : convert_revision : ce8dca07aaf1a340cc166b99b5858613a954e2fd

src/dev/pcidev.cc
src/dev/pcireg.h

index 9e6d5cd378bfa2b3db453a217f092be603b19d46..3e4238908bc6fc3c8344d81a0d5c41d866e3659c 100644 (file)
@@ -429,12 +429,12 @@ CREATE_SIM_OBJECT(PciConfigData)
     data->config.headerType = htole(HeaderType);
     data->config.bist = htole(BIST);
 
-    data->config.baseAddr0 = htole(BAR0);
-    data->config.baseAddr1 = htole(BAR1);
-    data->config.baseAddr2 = htole(BAR2);
-    data->config.baseAddr3 = htole(BAR3);
-    data->config.baseAddr4 = htole(BAR4);
-    data->config.baseAddr5 = htole(BAR5);
+    data->config.baseAddr[0] = htole(BAR0);
+    data->config.baseAddr[1] = htole(BAR1);
+    data->config.baseAddr[2] = htole(BAR2);
+    data->config.baseAddr[3] = htole(BAR3);
+    data->config.baseAddr[4] = htole(BAR4);
+    data->config.baseAddr[5] = htole(BAR5);
     data->config.cardbusCIS = htole(CardbusCIS);
     data->config.subsystemVendorID = htole(SubsystemVendorID);
     data->config.subsystemID = htole(SubsystemVendorID);
@@ -451,6 +451,14 @@ CREATE_SIM_OBJECT(PciConfigData)
     data->BARSize[4] = BAR4Size;
     data->BARSize[5] = BAR5Size;
 
+    for (int i = 0; i < 6; ++i) {
+        uint32_t barsize = data->BARSize[i];
+        if (barsize != 0 && !isPowerOf2(barsize)) {
+            fatal("%s: BAR %d size %d is not a power of 2\n",
+                  getInstanceName(), i, data->BARSize[i]);
+        }
+    }
+
     return data;
 }
 
index a48abd4fa507892766619d0e1c92f52b41795a61..df57acdb0e3edf772cebb1fa367d62cb75543c57 100644 (file)
@@ -54,18 +54,7 @@ union PCIConfig {
         uint8_t latencyTimer;
         uint8_t headerType;
         uint8_t bist;
-        union {
-            uint32_t baseAddr[6];
-
-            struct {
-                uint32_t baseAddr0;
-                uint32_t baseAddr1;
-                uint32_t baseAddr2;
-                uint32_t baseAddr3;
-                uint32_t baseAddr4;
-                uint32_t baseAddr5;
-            };
-        };
+        uint32_t baseAddr[6];
         uint32_t cardbusCIS;
         uint16_t subsystemVendorID;
         uint16_t subsystemID;