From patchwork Sun Sep 13 15:18:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 47158 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8DFJ1fU027168 for ; Sun, 13 Sep 2009 15:19:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754627AbZIMPSz (ORCPT ); Sun, 13 Sep 2009 11:18:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754560AbZIMPSz (ORCPT ); Sun, 13 Sep 2009 11:18:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33019 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbZIMPSx (ORCPT ); Sun, 13 Sep 2009 11:18:53 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8DFIvFw008695 for ; Sun, 13 Sep 2009 11:18:57 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8DFIuSe011036; Sun, 13 Sep 2009 11:18:56 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 9B56925004D; Sun, 13 Sep 2009 18:18:55 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH 01/10] Add test device for use with the test suite Date: Sun, 13 Sep 2009 18:18:46 +0300 Message-Id: <1252855135-2519-2-git-send-email-avi@redhat.com> In-Reply-To: <1252855135-2519-1-git-send-email-avi@redhat.com> References: <1252855135-2519-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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); {