ARM: Add support for a dumb IDE controller

This commit is contained in:
Ali Saidi 2010-11-15 14:04:03 -06:00
parent 13931b9b82
commit d7b8efa0df
6 changed files with 33 additions and 6 deletions

View file

@ -209,6 +209,16 @@ def makeLinuxArmSystem(mem_mode, mdesc = None, bare_metal=False,
self.mem_mode = mem_mode 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": if machine_type == "RealView_PBX":
self.realview = RealViewPBX() self.realview = RealViewPBX()
elif machine_type == "RealView_EB": elif machine_type == "RealView_EB":

View file

@ -64,3 +64,5 @@ class IdeController(PciDevice):
BAR3Size = '4B' BAR3Size = '4B'
BAR4Size = '16B' BAR4Size = '16B'
io_shift = Param.UInt32(0x0, "IO port shift");
ctrl_offset = Param.UInt32(0x0, "IDE disk control offset")

View file

@ -108,15 +108,13 @@ RealView::pciToDma(Addr pciAddr) const
Addr Addr
RealView::calcPciConfigAddr(int bus, int dev, int func) RealView::calcPciConfigAddr(int bus, int dev, int func)
{ {
panic("Need implementation\n"); return ULL(-1);
M5_DUMMY_RETURN
} }
Addr Addr
RealView::calcPciIOAddr(Addr addr) RealView::calcPciIOAddr(Addr addr)
{ {
panic("Need implementation\n"); return addr;
M5_DUMMY_RETURN
} }
Addr Addr

View file

@ -84,7 +84,8 @@ IdeController::IdeController(Params *p)
primaryTiming(htole(timeRegWithDecodeEn)), primaryTiming(htole(timeRegWithDecodeEn)),
secondaryTiming(htole(timeRegWithDecodeEn)), secondaryTiming(htole(timeRegWithDecodeEn)),
deviceTiming(0), udmaControl(0), udmaTiming(0), ideConfig(0), 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) if (params()->disks.size() > 3)
panic("IDE controllers support a maximum of 4 devices attached!\n"); panic("IDE controllers support a maximum of 4 devices attached!\n");
@ -106,6 +107,15 @@ IdeController::IdeController(Params *p)
primary.select(false); primary.select(false);
secondary.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)); ioEnabled = (config.command & htole(PCI_CMD_IOSE));
bmEnabled = (config.command & htole(PCI_CMD_BME)); bmEnabled = (config.command & htole(PCI_CMD_BME));
} }
@ -441,10 +451,14 @@ IdeController::dispatchAccess(PacketPtr pkt, bool read)
if (addr >= primary.cmdAddr && if (addr >= primary.cmdAddr &&
addr < (primary.cmdAddr + primary.cmdSize)) { addr < (primary.cmdAddr + primary.cmdSize)) {
addr -= primary.cmdAddr; 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); primary.accessCommand(addr, size, dataPtr, read);
} else if (addr >= primary.ctrlAddr && } else if (addr >= primary.ctrlAddr &&
addr < (primary.ctrlAddr + primary.ctrlSize)) { addr < (primary.ctrlAddr + primary.ctrlSize)) {
addr -= primary.ctrlAddr; addr -= primary.ctrlAddr;
addr += ctrlOffset;
primary.accessControl(addr, size, dataPtr, read); primary.accessControl(addr, size, dataPtr, read);
} else if (addr >= secondary.cmdAddr && } else if (addr >= secondary.cmdAddr &&
addr < (secondary.cmdAddr + secondary.cmdSize)) { addr < (secondary.cmdAddr + secondary.cmdSize)) {

View file

@ -133,6 +133,8 @@ class IdeController : public PciDev
bool ioEnabled; bool ioEnabled;
bool bmEnabled; bool bmEnabled;
uint32_t ioShift, ctrlOffset;
void dispatchAccess(PacketPtr pkt, bool read); void dispatchAccess(PacketPtr pkt, bool read);
public: public:

View file

@ -76,6 +76,7 @@ PciDev::PciConfigPort::getDeviceAddressRanges(AddrRangeList &resp,
bool &snoop) bool &snoop)
{ {
snoop = false;; snoop = false;;
if (configAddr != ULL(-1))
resp.push_back(RangeSize(configAddr, PCI_CONFIG_SIZE+1)); resp.push_back(RangeSize(configAddr, PCI_CONFIG_SIZE+1));
} }