hw/i386/postcard.c: New ISA POST card device
PATCH 1/1 hw/i386/postcard.c: New ISA POST card device
Move the ioport80 memory functionality within hw/i386/pc.c into a new ISA POST card device capable of being instantiated at different ports.
Emulate actual i440FX hardware by storing the value written to the port, regardless of the presence of a POST card, a behavior relied upon by firmware for these systems (e.g., AMIBIOS) to track the state of the boot process.
To aid firmware debugging, allow for tracing POST card values, mimicking the [new value, old value] display format of actual cards.
Tested with AMIBIOS.
Signed-off-by Lev Kujawski <[email protected]>
--- hw/i386/Kconfig | 5 ++ hw/i386/meson.build | 1 + hw/i386/pc.c | 25 +------ hw/i386/postcard.c | 149 +++++++++++++++++++++++++++++++++++++ hw/i386/trace-events | 3 + include/hw/i386/postcard.h | 35 +++++++++ 6 files changed, 195 insertions(+), 23 deletions(-) create mode 100644 hw/i386/postcard.c create mode 100644 include/hw/i386/postcard.h
hw/i386/Kconfig +5 -0
@@ -10,6 +10,10 @@ config SGX bool depends on KVM +config POST_CARD + bool + depends on ISA_BUS + config PC bool imply APPLESMC
@@ -40,6 +44,7 @@ config PC select PCSPK select I8257 select MC146818RTC + select POST_CARD # For ACPI builder: select SERIAL_ISA select ACPI_PCI
hw/i386/meson.build +1 -0
@@ -28,6 +28,7 @@ i386_ss.add(when: 'CONFIG_PC', if_true: files( 'port92.c')) i386_ss.add(when: 'CONFIG_X86_FW_OVMF', if_true: files('pc_sysfw_ovmf.c'), if_false: files('pc_sysfw_ovmf-stubs.c')) +i386_ss.add(when: 'CONFIG_POST_CARD', if_true: files('postcard.c')) subdir('kvm') subdir('xen')
hw/i386/pc.c +2 -23
@@ -32,6 +32,7 @@#include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/vmport.h" +#include "hw/i386/postcard.h" #include "sysemu/cpus.h" #include "hw/block/fdc.h" #include "hw/ide.h"
@@ -403,16 +404,6 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled)return s; } -static void ioport80_write (void *opaque,hwaddr addr,uint64_t data, -unsigned size) -{ -} - -static uint64_t ioport80_read (void *opaque,hwaddr addr,unsigned size) -{ -return 0xffffffffffffffffULL ; -} -/* MSDOS compatibility mode FPU exception support */ static void ioportF0_write (void *opaque,hwaddr addr,uint64_t data,unsigned size)
@@ -1059,16 +1050,6 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)return dev; } -static const MemoryRegionOps ioport80_io_ops = { - .write = ioport80_write, - .read = ioport80_read, - .endianness =DEVICE_NATIVE_ENDIAN , - .impl = { - .min_access_size =1 , - .max_access_size =1 , - }, -}; -static const MemoryRegionOps ioportF0_io_ops = { .write = ioportF0_write, .read = ioportF0_read,
@@ -1139,12 +1120,10 @@ void pc_basic_device_init(struct PCMachineState *pcms,qemu_irq pit_alt_irq =NULL ;qemu_irq rtc_irq =NULL ;ISADevice *pit =NULL ; -MemoryRegion *ioport80_io =g_new (MemoryRegion,1 );MemoryRegion *ioportF0_io =g_new (MemoryRegion,1 );X86MachineState *x86ms =X86_MACHINE (pcms); -memory_region_init_io (ioport80_io,NULL , &ioport80_io_ops,NULL ,"ioport80" ,1 ); -memory_region_add_subregion (isa_bus->address_space_io,0x80 , ioport80_io); + (void )post_card_init (isa_bus,POST_CARD_PORT_DEFAULT );memory_region_init_io (ioportF0_io,NULL , &ioportF0_io_ops,NULL ,"ioportF0" ,1 );memory_region_add_subregion (isa_bus->address_space_io,0xf0 , ioportF0_io);
hw/i386/postcard.c new file +149 -0
149 lines not on this page · raw message
hw/i386/trace-events +3 -0
@@ -119,3 +119,6 @@ x86_pic_interrupt(int irqn, int level) "PIC interrupt #%d level:%d" # port92.c port92_read(uint8_t val) "port92: read 0x%02x" port92_write(uint8_t val) "port92: write 0x%02x" + +# postcard.c +post_card_write(uint8_t new_val, uint8_t old_val) "[%.2x %.2x]"
include/hw/i386/postcard.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* QEMU PC System Emulator +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* 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. +*/ + +#ifndef HW_I386_POSTCARD_H +#define HW_I386_POSTCARD_H + +#include "hw/isa/isa.h" + +#define POST_CARD_PORT_DEFAULT 0x80 + +ISADevice * +post_card_init (ISABus *bus,uint16_t iobase); + +#endif /* HW_I386_POSTCARD_H */
Signature · 1 line
2.34.1