10 static void test_device_serial_write(void *opaque
, uint32_t addr
, uint32_t data
)
12 struct testdev
*dev
= opaque
;
13 uint8_t buf
[1] = { data
};
16 qemu_chr_write(dev
->chr
, buf
, 1);
20 static void test_device_exit(void *opaque
, uint32_t addr
, uint32_t data
)
25 static uint32_t test_device_memsize_read(void *opaque
, uint32_t addr
)
30 static void test_device_irq_line(void *opaque
, uint32_t addr
, uint32_t data
)
32 extern qemu_irq
*ioapic_irq_hack
;
34 qemu_set_irq(ioapic_irq_hack
[addr
- 0x2000], !!data
);
37 static int init_test_device(ISADevice
*isa
)
39 struct testdev
*dev
= DO_UPCAST(struct testdev
, dev
, isa
);
41 register_ioport_write(0xf1, 1, 1, test_device_serial_write
, dev
);
42 register_ioport_write(0xf4, 1, 4, test_device_exit
, dev
);
43 register_ioport_read(0xd1, 1, 4, test_device_memsize_read
, dev
);
44 register_ioport_write(0x2000, 24, 1, test_device_irq_line
, NULL
);
48 static ISADeviceInfo testdev_info
= {
49 .qdev
.name
= "testdev",
50 .qdev
.size
= sizeof(struct testdev
),
51 .init
= init_test_device
,
52 .qdev
.props
= (Property
[]) {
53 DEFINE_PROP_CHR("chardev", struct testdev
, chr
),
54 DEFINE_PROP_END_OF_LIST(),
58 static void testdev_register_devices(void)
60 isa_qdev_register(&testdev_info
);
63 device_init(testdev_register_devices
)