ARM: Add support for a dumb IDE controller
authorAli Saidi <Ali.Saidi@ARM.com>
Mon, 15 Nov 2010 20:04:03 +0000 (14:04 -0600)
committerAli Saidi <Ali.Saidi@ARM.com>
Mon, 15 Nov 2010 20:04:03 +0000 (14:04 -0600)
configs/common/FSConfig.py
src/dev/Ide.py
src/dev/arm/realview.cc
src/dev/ide_ctrl.cc
src/dev/ide_ctrl.hh
src/dev/pcidev.cc

index fe57b5cab3457589f29d37f28d7dc808b1e40fd0..53ab0681370ea2a52cb5b39f10971aa9541ab284 100644 (file)
@@ -209,6 +209,16 @@ def makeLinuxArmSystem(mem_mode, mdesc = None, bare_metal=False,
 
     self.mem_mode = mem_mode
 
+    #self.cf0 = CowIdeDisk(driveID='master')
+    #self.cf0.childImage(mdesc.disk())
+    #self.cf_ctrl = IdeController(disks=[self.cf0],
+    #                             pci_func = 0, pci_dev = 0, pci_bus = 0,
+    #                             io_shift = 1, ctrl_offset = 2, Command = 0x1,
+    #                             BAR0 = 0x18000000, BAR0Size = '16B',
+    #                             BAR1 = 0x18000100, BAR1Size = '1B',
+    #                             BAR0LegacyIO = True, BAR1LegacyIO = True,)
+    #self.cf_ctrl.pio = self.iobus.port
+
     if machine_type == "RealView_PBX":
         self.realview = RealViewPBX()
     elif machine_type == "RealView_EB":
index a396c969020e38640337cb3a0263521bd29bd9bf..7d97c42b67231c0a73aaaaa8f936acbc0e901bb9 100644 (file)
@@ -64,3 +64,5 @@ class IdeController(PciDevice):
     BAR3Size = '4B'
     BAR4Size = '16B'
 
+    io_shift = Param.UInt32(0x0, "IO port shift");
+    ctrl_offset = Param.UInt32(0x0, "IDE disk control offset")
index 303c40912e78dc1d047abed52786b6ef82c556e7..b27c3e58dce86419cc66be2712dcff0921f18463 100644 (file)
@@ -108,15 +108,13 @@ RealView::pciToDma(Addr pciAddr) const
 Addr
 RealView::calcPciConfigAddr(int bus, int dev, int func)
 {
-    panic("Need implementation\n");
-    M5_DUMMY_RETURN
+    return ULL(-1);
 }
 
 Addr
 RealView::calcPciIOAddr(Addr addr)
 {
-    panic("Need implementation\n");
-    M5_DUMMY_RETURN
+    return addr;
 }
 
 Addr
index 87dc0b2aa986c27025b19cd0e55d0d4f49f73793..4bbad883d7bfb97d74142a4c884f4f579097dfed 100644 (file)
@@ -84,7 +84,8 @@ IdeController::IdeController(Params *p)
     primaryTiming(htole(timeRegWithDecodeEn)),
     secondaryTiming(htole(timeRegWithDecodeEn)),
     deviceTiming(0), udmaControl(0), udmaTiming(0), ideConfig(0),
-    ioEnabled(false), bmEnabled(false)
+    ioEnabled(false), bmEnabled(false),
+    ioShift(p->io_shift), ctrlOffset(p->ctrl_offset)
 {
     if (params()->disks.size() > 3)
         panic("IDE controllers support a maximum of 4 devices attached!\n");
@@ -106,6 +107,15 @@ IdeController::IdeController(Params *p)
     primary.select(false);
     secondary.select(false);
 
+    if ((BARAddrs[0] & ~BAR_IO_MASK) != 0){
+        primary.cmdAddr = BARAddrs[0];  primary.cmdSize = BARSize[0];
+        primary.ctrlAddr = BARAddrs[1]; primary.ctrlSize = BARAddrs[1];
+    }
+    if ((BARAddrs[2] & ~BAR_IO_MASK) != 0){
+        secondary.cmdAddr = BARAddrs[2];  secondary.cmdSize = BARSize[2];
+        secondary.ctrlAddr = BARAddrs[3]; secondary.ctrlSize = BARAddrs[3];
+    }
+
     ioEnabled = (config.command & htole(PCI_CMD_IOSE));
     bmEnabled = (config.command & htole(PCI_CMD_BME));
 }
@@ -441,10 +451,14 @@ IdeController::dispatchAccess(PacketPtr pkt, bool read)
     if (addr >= primary.cmdAddr &&
             addr < (primary.cmdAddr + primary.cmdSize)) {
         addr -= primary.cmdAddr;
+        // linux may have shifted the address by ioShift,
+        // here we shift it back, similarly for ctrlOffset.
+        addr >>= ioShift;
         primary.accessCommand(addr, size, dataPtr, read);
     } else if (addr >= primary.ctrlAddr &&
                addr < (primary.ctrlAddr + primary.ctrlSize)) {
         addr -= primary.ctrlAddr;
+        addr += ctrlOffset;
         primary.accessControl(addr, size, dataPtr, read);
     } else if (addr >= secondary.cmdAddr &&
                addr < (secondary.cmdAddr + secondary.cmdSize)) {
index 89dc1ee9ddbf5cbef99bea9eeca8c206ab462b67..430b3fc1b1868e95a4a1249b73b33ef6f4e50a08 100644 (file)
@@ -133,6 +133,8 @@ class IdeController : public PciDev
     bool ioEnabled;
     bool bmEnabled;
 
+    uint32_t ioShift, ctrlOffset;
+
     void dispatchAccess(PacketPtr pkt, bool read);
 
   public:
index 26286c208c581881f569a375248fb7ce5e66c0fb..db68a37998585dc083d0207a2d3a18e642ff09b5 100644 (file)
@@ -76,7 +76,8 @@ PciDev::PciConfigPort::getDeviceAddressRanges(AddrRangeList &resp,
                                               bool &snoop)
 {
     snoop = false;;
-    resp.push_back(RangeSize(configAddr, PCI_CONFIG_SIZE+1));
+    if (configAddr != ULL(-1))
+        resp.push_back(RangeSize(configAddr, PCI_CONFIG_SIZE+1));
 }