Add io memory to test device
PATCH 1/1 Add io memory to test device
Add io memory to test device. This is needed by emulator test.
Signed-off-by Gleb Natapov <[email protected]>
hw/testdev.c +48 -0
@@ -34,14 +34,62 @@ static void test_device_irq_line(void *opaque, uint32_t addr, uint32_t data)qemu_set_irq (ioapic_irq_hack[addr -0x2000 ], !!data); } +static char *iomem_buf; + +static uint32_t test_iomem_readb (void *opaque,target_phys_addr_t addr) +{ +return iomem_buf[addr]; +} + +static uint32_t test_iomem_readw (void *opaque,target_phys_addr_t addr) +{ +return *(uint16_t *)(iomem_buf + addr); +} + +static uint32_t test_iomem_readl (void *opaque,target_phys_addr_t addr) +{ +return *(uint32_t *)(iomem_buf + addr); +} + +static void test_iomem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +{ + iomem_buf[addr] = val; +} + +static void test_iomem_writew (void *opaque,target_phys_addr_t addr,uint32_t val) +{ + *(uint16_t *)(iomem_buf + addr) = val; +} + +static void test_iomem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) +{ + *(uint32_t *)(iomem_buf + addr) = val; +} + +static CPUReadMemoryFunc *const test_iomem_read[3 ] = { + test_iomem_readb, + test_iomem_readw, + test_iomem_readl, +}; + +static CPUWriteMemoryFunc *const test_iomem_write[3 ] = { + test_iomem_writeb, + test_iomem_writew, + test_iomem_writel, +}; +static int init_test_device (ISADevice *isa) { struct testdev *dev = DO_UPCAST(struct testdev, dev, isa); +int iomem;register_ioport_write (0xf1 ,1 ,1 , test_device_serial_write, dev);register_ioport_write (0xf4 ,1 ,4 , test_device_exit, dev);register_ioport_read (0xd1 ,1 ,4 , test_device_memsize_read, dev);register_ioport_write (0x2000 ,24 ,1 , test_device_irq_line,NULL ); + iomem_buf =qemu_mallocz (0x10000 ); + iomem =cpu_register_io_memory (test_iomem_read, test_iomem_write,NULL ); +cpu_register_physical_memory (0xff000000 ,0x10000 , iomem);return 0 ; }
--
Gleb.
Avi Kivity
AppliedQuoted 3 lines · Gleb Natapov
Add io memory to test device. This is needed by emulator test.
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function