From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2IXh-0002Z4-09 for qemu-devel@nongnu.org; Fri, 08 May 2009 01:22:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2IXc-0002WO-Pb for qemu-devel@nongnu.org; Fri, 08 May 2009 01:22:40 -0400 Received: from [199.232.76.173] (port=33190 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2IXc-0002WI-FR for qemu-devel@nongnu.org; Fri, 08 May 2009 01:22:36 -0400 Received: from mx2.redhat.com ([66.187.237.31]:60140) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M2IXc-0002WO-31 for qemu-devel@nongnu.org; Fri, 08 May 2009 01:22:36 -0400 From: Glauber Costa Date: Fri, 8 May 2009 02:22:12 -0300 Message-Id: <1241760133-4207-2-git-send-email-glommer@redhat.com> In-Reply-To: <1241760133-4207-1-git-send-email-glommer@redhat.com> References: <1241760133-4207-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] register reset handler for option_roms List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com Currently, boot options are not preserved across a system reset. option roms can modify themselves, or can for instance restore the real int 0x19 vector after they tried to boot from it. To properly do that, we need a reset handler registered to deal with option roms. This patch is based on current version on qemu-kvm.git Signed-off-by: Glauber Costa --- hw/pc.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 61f6e7b..0025474 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -63,6 +63,30 @@ static PITState *pit; static IOAPICState *ioapic; static PCIDevice *i440fx_state; +typedef struct rom_reset_data { + uint8_t *data; + target_phys_addr_t addr; + unsigned size; +} RomResetData; + +static void option_rom_reset(void *_rrd) +{ + RomResetData *rrd = _rrd; + + cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size); +} + +static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size) +{ + RomResetData *rrd = qemu_malloc(sizeof *rrd); + + rrd->data = qemu_malloc(size); + cpu_physical_memory_read(addr, rrd->data, size); + rrd->addr = addr; + rrd->size = size; + qemu_register_reset(option_rom_reset, rrd); +} + static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) { } @@ -806,6 +830,7 @@ static int load_option_rom(const char *oprom, target_phys_addr_t start, } /* Round up optiom rom size to the next 2k boundary */ size = (size + 2047) & ~2047; + option_rom_setup_reset(start, size); return size; } -- 1.6.2.2