@@ -1116,6 +1116,29 @@ CPUState *pc_new_cpu(const char *cpu_model)
return env;
}
+static void test_device_serial_write(void *opaque, uint32_t addr, uint32_t data)
+{
+ putchar(data);
+}
+
+static void test_device_exit(void *opaque, uint32_t addr, uint32_t data)
+{
+ exit(data);
+}
+
+static uint32_t test_device_memsize_read(void *opaque, uint32_t addr)
+{
+ return (intptr_t)opaque;
+}
+
+static void create_test_device(ram_addr_t ram_size)
+{
+ register_ioport_write(0xf1, 1, 1, test_device_serial_write, NULL);
+ register_ioport_write(0xf4, 1, 4, test_device_exit, NULL);
+ register_ioport_read(0xd1, 1, 4, test_device_memsize_read,
+ (void *)(intptr_t)ram_size);
+}
+
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
@@ -1144,6 +1167,11 @@ static void pc_init1(ram_addr_t ram_size,
BlockDriverState *fd[MAX_FD];
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
void *fw_cfg;
+ extern int testdevice;
+
+ if (testdevice) {
+ create_test_device(ram_size);
+ }
if (ram_size >= 0xe0000000 ) {
above_4g_mem_size = ram_size - 0xe0000000;
@@ -1693,3 +1693,5 @@ DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
"-mem-prealloc preallocate guest memory (use with -mempath)\n")
#endif
+DEF("test-device", 0, QEMU_OPTION_testdevice,
+ "-test-device include testsuite support device")
@@ -251,6 +251,7 @@ const char *mem_path = NULL;
#ifdef MAP_POPULATE
int mem_prealloc = 1; /* force preallocation of physical target memory */
#endif
+int testdevice;
#ifdef TARGET_ARM
int old_param = 0;
#endif
@@ -5559,6 +5560,9 @@ int main(int argc, char **argv, char **envp)
mem_prealloc = !mem_prealloc;
break;
#endif
+ case QEMU_OPTION_testdevice:
+ testdevice = 1;
+ break;
case QEMU_OPTION_name:
qemu_name = qemu_strdup(optarg);
{
The test device implements: - a serial port (0xf1) - an exit port (0xf4) - a memory size port (0xd1) It is planned to replace these with the standard serial and firmware configuration ports. Signed-off-by: Avi Kivity <avi@redhat.com> --- hw/pc.c | 28 ++++++++++++++++++++++++++++ qemu-options.hx | 2 ++ vl.c | 4 ++++ 3 files changed, 34 insertions(+), 0 deletions(-)