summary refs log tree commit diff stats
path: root/hw/ide/ahci.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2018-06-08 13:17:38 -0400
committerJohn Snow <jsnow@redhat.com>2018-06-08 13:17:38 -0400
commit215c41aa67febfab018dbc4c5d2ac2d2de26c4d2 (patch)
treef12f1ecf9cda6d6d223eb73572988ac314c721a2 /hw/ide/ahci.c
parent96034081dd2dd5177ffdf19475712264783c7bef (diff)
downloadfocaccia-qemu-215c41aa67febfab018dbc4c5d2ac2d2de26c4d2.tar.gz
focaccia-qemu-215c41aa67febfab018dbc4c5d2ac2d2de26c4d2.zip
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>
Diffstat (limited to 'hw/ide/ahci.c')
-rw-r--r--hw/ide/ahci.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 5be43ba2d0..99cbfe6447 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -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 +