ahci: modify ahci_mem_read_32 to work on register numbers

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180531222835.16558-12-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
John Snow 2018-06-08 13:17:38 -04:00
parent 96034081dd
commit 215c41aa67

View File

@ -386,22 +386,27 @@ static uint64_t ahci_mem_read_32(void *opaque, hwaddr addr)
uint32_t val = 0;
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
switch (addr) {
case HOST_CAP:
enum AHCIHostReg regnum = addr / 4;
assert(regnum < AHCI_HOST_REG__COUNT);
switch (regnum) {
case AHCI_HOST_REG_CAP:
val = s->control_regs.cap;
break;
case HOST_CTL:
case AHCI_HOST_REG_CTL:
val = s->control_regs.ghc;
break;
case HOST_IRQ_STAT:
case AHCI_HOST_REG_IRQ_STAT:
val = s->control_regs.irqstatus;
break;
case HOST_PORTS_IMPL:
case AHCI_HOST_REG_PORTS_IMPL:
val = s->control_regs.impl;
break;
case HOST_VERSION:
case AHCI_HOST_REG_VERSION:
val = s->control_regs.version;
break;
default:
break;
}
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +