diff mbox

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

Message ID 1252855135-2519-2-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Sept. 13, 2009, 3:18 p.m. UTC
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(-)

Comments

Anthony Liguori Sept. 14, 2009, 12:59 p.m. UTC | #1
Avi Kivity wrote:
> 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>
>   

Should be a qdev-based ISA device.  Then a new option wouldn't be needed 
as you could just use -device.

These tests should all be runnable against upstream tcg, no?

Regards,

Anthony Liguori
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Sept. 14, 2009, 1:01 p.m. UTC | #2
On 09/14/2009 03:59 PM, Anthony Liguori wrote:
> Avi Kivity wrote:
>> 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>
>
> Should be a qdev-based ISA device.  Then a new option wouldn't be 
> needed as you could just use -device.

It really shouldn't be at all.  It's for transition only.

> These tests should all be runnable against upstream tcg, no?

Yes, and I plan to eventually submit them against qemu upstream.  Note 
the access test fails, though it might be due to the test itself, not qemu.
diff mbox

Patch

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);
 		 {