[PATCH 01/10] Add test device for use with the test suite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 hw/pc.c         |   28 ++++++++++++++++++++++++++++
 qemu-options.hx |    2 ++
 vl.c            |    4 ++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 5e384d0..360dbfb 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -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;
diff --git a/qemu-options.hx b/qemu-options.hx
index f2e602a..42a3096 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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")
diff --git a/vl.c b/vl.c
index 4d186e5..2a3629d 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
 		 {
-- 
1.6.1.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux