Commit e28f988427c3a27cf42ef2229f12f0a7e67cb00c
Committed by
Anthony Liguori
1 parent
d4d698f0
register reset handler for option_roms
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 <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
25 additions
and
0 deletions
hw/pc.c
@@ -63,6 +63,30 @@ static PITState *pit; | @@ -63,6 +63,30 @@ static PITState *pit; | ||
63 | static IOAPICState *ioapic; | 63 | static IOAPICState *ioapic; |
64 | static PCIDevice *i440fx_state; | 64 | static PCIDevice *i440fx_state; |
65 | 65 | ||
66 | +typedef struct rom_reset_data { | ||
67 | + uint8_t *data; | ||
68 | + target_phys_addr_t addr; | ||
69 | + unsigned size; | ||
70 | +} RomResetData; | ||
71 | + | ||
72 | +static void option_rom_reset(void *_rrd) | ||
73 | +{ | ||
74 | + RomResetData *rrd = _rrd; | ||
75 | + | ||
76 | + cpu_physical_memory_write_rom(rrd->addr, rrd->data, rrd->size); | ||
77 | +} | ||
78 | + | ||
79 | +static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size) | ||
80 | +{ | ||
81 | + RomResetData *rrd = qemu_malloc(sizeof *rrd); | ||
82 | + | ||
83 | + rrd->data = qemu_malloc(size); | ||
84 | + cpu_physical_memory_read(addr, rrd->data, size); | ||
85 | + rrd->addr = addr; | ||
86 | + rrd->size = size; | ||
87 | + qemu_register_reset(option_rom_reset, rrd); | ||
88 | +} | ||
89 | + | ||
66 | static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) | 90 | static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) |
67 | { | 91 | { |
68 | } | 92 | } |
@@ -806,6 +830,7 @@ static int load_option_rom(const char *oprom, target_phys_addr_t start, | @@ -806,6 +830,7 @@ static int load_option_rom(const char *oprom, target_phys_addr_t start, | ||
806 | } | 830 | } |
807 | /* Round up optiom rom size to the next 2k boundary */ | 831 | /* Round up optiom rom size to the next 2k boundary */ |
808 | size = (size + 2047) & ~2047; | 832 | size = (size + 2047) & ~2047; |
833 | + option_rom_setup_reset(start, size); | ||
809 | return size; | 834 | return size; |
810 | } | 835 | } |
811 | 836 |