From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLuPy-00066b-S4 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 03:39:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLuPt-000667-Um for qemu-devel@nongnu.org; Wed, 01 Jul 2009 03:39:46 -0400 Received: from [199.232.76.173] (port=49209 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLuPt-000664-Pk for qemu-devel@nongnu.org; Wed, 01 Jul 2009 03:39:41 -0400 Received: from rv-out-0708.google.com ([209.85.198.240]:44502) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MLuPt-0004m6-8Z for qemu-devel@nongnu.org; Wed, 01 Jul 2009 03:39:41 -0400 Received: by rv-out-0708.google.com with SMTP id b17so209156rvf.22 for ; Wed, 01 Jul 2009 00:39:39 -0700 (PDT) From: Jordan Justen Date: Wed, 1 Jul 2009 00:39:04 -0700 Message-Id: <1246433944-5742-1-git-send-email-jljusten@gmail.com> In-Reply-To: <4A490A62.5030101@codemonkey.ws> References: <4A490A62.5030101@codemonkey.ws> In-Reply-To: <4A490A62.5030101@codemonkey.ws> References: <4A490A62.5030101@codemonkey.ws> Subject: [Qemu-devel] [PATCH] Implement PC port80 debug register. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jordan Justen In PC systems, the byte I/O port 0x80 is commonly written to by BIOS and/or system software as a simple checkpoint method. This change adds an 'info port80' monitor command to retrieve the last value written out to port80. Signed-off-by: Jordan Justen --- Makefile.target | 2 +- hw/pc.c | 6 +--- hw/pc.h | 7 ++++ hw/port80.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 6 +++ 5 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 hw/port80.c diff --git a/Makefile.target b/Makefile.target index a593503..155d9c3 100644 --- a/Makefile.target +++ b/Makefile.target @@ -563,7 +563,7 @@ obj-y += wdt_ib700.o wdt_i6300esb.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support obj-y += ide.o pckbd.o vga.o $(sound-obj-y) dma.o -obj-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o +obj-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o port80.o pc.o obj-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o obj-y += device-hotplug.o pci-hotplug.o smbios.o diff --git a/hw/pc.c b/hw/pc.c index 553ba5c..95ea295 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -87,10 +87,6 @@ static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size) qemu_register_reset(option_rom_reset, rrd); } -static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) -{ -} - /* MSDOS compatibility mode FPU exception support */ static qemu_irq ferr_irq; /* XXX: add IGNNE support */ @@ -1253,7 +1249,7 @@ static void pc_init1(ram_addr_t ram_size, } /* init basic PC hardware */ - register_ioport_write(0x80, 1, 1, ioport80_write, NULL); + port80_init(); register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); diff --git a/hw/pc.h b/hw/pc.h index 9fbae20..1d0423e 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -166,4 +166,11 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn, void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd); int cpu_is_bsp(CPUState *env); + +/* port80.c */ + +typedef struct Port80State Port80State; + +Port80State *port80_init(void); + #endif diff --git a/hw/port80.c b/hw/port80.c new file mode 100644 index 0000000..947b3cd --- /dev/null +++ b/hw/port80.c @@ -0,0 +1,104 @@ +/* + * QEMU debug port 80 emulation + * + * Copyright (c) 2003-2004 Fabrice Bellard + * Copyright (c) 2009 Jordan Justen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "hw.h" +#include "sysemu.h" +#include "pc.h" +#include "isa.h" +#include "monitor.h" + +void do_monitor_info_port80(Monitor *mon); + +//#define DEBUG_PORT80 +//#define PORT80_READ_SUPPORT + +struct Port80State { + uint8_t data; +}; + +static Port80State *state; + +static void port80_ioport_write(void *opaque, uint32_t addr, uint32_t data) +{ + Port80State *s = opaque; + +#ifdef DEBUG_PORT80 + printf("port%02x: write val=0x%02x\n", addr, data); +#endif + s->data = data; +} + +#ifdef PORT80_READ_SUPPORT +static uint32_t port80_ioport_read(void *opaque, uint32_t addr) +{ + Port80State *s = opaque; + int ret; + ret = s->data; +#ifdef DEBUG_PORT80 + printf("port%02x: read val=0x%02x\n", addr, ret); +#endif + return ret; +} +#endif + +static void port80_save(QEMUFile *f, void *opaque) +{ + Port80State *s = opaque; + + qemu_put_byte(f, s->data); +} + +static int port80_load(QEMUFile *f, void *opaque, int version_id) +{ + Port80State *s = opaque; + + if (version_id != 1) + return -EINVAL; + + s->data = qemu_get_byte(f); + state = s; + return 0; +} + +void do_monitor_info_port80(Monitor *mon) +{ + monitor_printf(mon, "0x%02x\n", state->data); +} + +Port80State *port80_init() +{ + Port80State *s; + + s = qemu_mallocz(sizeof(Port80State)); + state = s; + + register_ioport_write(0x80, 1, 1, port80_ioport_write, s); +#ifdef PORT80_READ_SUPPORT + register_ioport_read(0x80, 1, 1, port80_ioport_read, s); +#endif + + register_savevm("port80", 0x80, 1, port80_save, port80_load, s); + return s; +} + diff --git a/monitor.c b/monitor.c index bad79fe..a128d43 100644 --- a/monitor.c +++ b/monitor.c @@ -1677,6 +1677,10 @@ static void do_acl_remove(Monitor *mon, const char *aclname, const char *match) } } +#if defined(TARGET_I386) +void do_monitor_info_port80(Monitor *mon); +#endif + static const mon_cmd_t mon_cmds[] = { #include "qemu-monitor.h" { NULL, NULL, }, @@ -1715,6 +1719,8 @@ static const mon_cmd_t info_cmds[] = { "", "show the active virtual memory mappings", }, { "hpet", "", do_info_hpet, "", "show state of HPET", }, + { "port80", "", do_monitor_info_port80, + "", "show value of the last write to i/o port 0x80", }, #endif { "jit", "", do_info_jit, "", "show dynamic compiler info", }, -- 1.6.0.4