aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ioemu/hw/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ioemu/hw/pci.c')
-rw-r--r--tools/ioemu/hw/pci.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/ioemu/hw/pci.c b/tools/ioemu/hw/pci.c
index 77737c8615..cea81f7b7f 100644
--- a/tools/ioemu/hw/pci.c
+++ b/tools/ioemu/hw/pci.c
@@ -221,16 +221,23 @@ uint32_t pci_default_read_config(PCIDevice *d,
uint32_t address, int len)
{
uint32_t val;
+
switch(len) {
- case 1:
- val = d->config[address];
- break;
- case 2:
- val = le16_to_cpu(*(uint16_t *)(d->config + address));
- break;
default:
case 4:
- val = le32_to_cpu(*(uint32_t *)(d->config + address));
+ if (address <= 0xfc) {
+ val = le32_to_cpu(*(uint32_t *)(d->config + address));
+ break;
+ }
+ /* fall through */
+ case 2:
+ if (address <= 0xfe) {
+ val = le16_to_cpu(*(uint16_t *)(d->config + address));
+ break;
+ }
+ /* fall through */
+ case 1:
+ val = d->config[address];
break;
}
return val;
@@ -333,7 +340,8 @@ void pci_default_write_config(PCIDevice *d,
d->config[addr] = val;
}
- addr++;
+ if (++addr > 0xff)
+ break;
val >>= 8;
}