diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2011-02-05 14:34:41 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2011-02-12 08:28:24 +0000 |
commit | 6872ef610bad337701e0dcb0ab06558c04a0146f (patch) | |
tree | a0b80249727f81b681c133f58582c5ee4648271a | |
parent | 7ba7e49e6a7493e1cd0fe07cc67403846d642fc5 (diff) |
vmport: convert to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r-- | hw/pc.c | 1 | ||||
-rw-r--r-- | hw/pc.h | 5 | ||||
-rw-r--r-- | hw/pc_piix.c | 2 | ||||
-rw-r--r-- | hw/vmport.c | 24 |
4 files changed, 26 insertions, 6 deletions
@@ -1133,6 +1133,7 @@ void pc_basic_device_init(qemu_irq *isa_irq, a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042 = isa_create_simple("i8042"); i8042_setup_a20_line(i8042, &a20_line[0]); + vmport_init(); vmmouse_init(i8042); port92 = isa_create_simple("port92"); port92_init(port92, &a20_line[1]); @@ -65,7 +65,10 @@ void hpet_pit_disable(void); void hpet_pit_enable(void); /* vmport.c */ -void vmport_init(void); +static inline void vmport_init(void) +{ + isa_create_simple("vmport"); +} void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); /* vmmouse.c */ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 7b744730f7..d0bd0cd1fa 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -86,8 +86,6 @@ static void pc_init1(ram_addr_t ram_size, pc_cpus_init(cpu_model); - vmport_init(); - /* allocate ram and load rom/bios */ pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename, &below_4g_mem_size, &above_4g_mem_size); diff --git a/hw/vmport.c b/hw/vmport.c index 6c9d7c9651..4432be02f7 100644 --- a/hw/vmport.c +++ b/hw/vmport.c @@ -26,6 +26,7 @@ #include "pc.h" #include "sysemu.h" #include "kvm.h" +#include "qdev.h" //#define VMPORT_DEBUG @@ -37,6 +38,7 @@ typedef struct _VMPortState { + ISADevice dev; IOPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; } VMPortState; @@ -100,12 +102,28 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) return ram_size; } -void vmport_init(void) +static int vmport_initfn(ISADevice *dev) { - register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state); - register_ioport_write(0x5658, 1, 4, vmport_ioport_write, &port_state); + VMPortState *s = DO_UPCAST(VMPortState, dev, dev); + register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &s); + register_ioport_write(0x5658, 1, 4, vmport_ioport_write, &s); + isa_init_ioport(dev, 0x5658); /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); + return 0; } + +static ISADeviceInfo vmport_info = { + .qdev.name = "vmport", + .qdev.size = sizeof(VMPortState), + .qdev.no_user = 1, + .init = vmport_initfn, +}; + +static void vmport_dev_register(void) +{ + isa_qdev_register(&vmport_info); +} +device_init(vmport_dev_register) |