hw/i386/postcard.c: New ISA POST card device
PATCH v2 1/2 hw/i386/postcard.c: New ISA POST card device
Relocate the ioport80 functionality within hw/i386/pc.c into a new ISA POST card device (postcard.c) that is capable of being instantiated at different ports as well, such as for the following platforms [1]:
0x84 for COMPAQ
0x90 for PS/2 (ISA)
0x300 for AWARD BIOS
0x680 for PS/2 (MCA)
Emulate i440FX hardware by storing the value written to the port, a behavior relied upon by firmware for these systems (e.g., AMIBIOS) to track the state of the boot process. Despite the name of this device, said behavior does not rely upon the presence of an installed POST card, as the chipset provides an extraneous DMA page register at the POST address.
To aid firmware debugging, allow for tracing POST card values, mimicking the [new value, old value] display format of physical cards.
Reference platform:
TYAN S1686D (i440FX system board)
References:
[1] F. v. Gilluwe, The Undocumented PC. Boston, MA: Addison-Wesley,
1997, p. 800-801.
---
(v2) No functional changes. Add myself as the maintainer of this device,
per checkpatch; add technical details and references to commit log.
MAINTAINERS | 5 ++ 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 +++++++++ 7 files changed, 200 insertions(+), 23 deletions(-) create mode 100644 hw/i386/postcard.c create mode 100644 include/hw/i386/postcard.h
MAINTAINERS +5 -0
@@ -1719,6 +1719,11 @@ F: include/sysemu/numa.h F: tests/unit/test-smp-parse.c T: git https://gitlab.com/ehabkost/qemu.git machine-next +ISA POST card +M: Lev Kujawski <[email protected]> +S: Supported +F: hw/i386/postcard.c + Xtensa Machines --------------- sim
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
PATCH v2 2/2 hw/i386/postcard: New test suite for the ISA POST card device
Verify that port 0x80 behavior corresponds with i440FX hardware. Despite the name of the device, said behavior is implemented by the system board and does not depend upon the actual presence of a POST card.
In particular:
a) Writes to port 0x80 are retained and may be read afterwards.
b) Word and double word reads return a repeated sequence of the written octet.
Reference platform:
TYAN S1686D (i440FX system board)
---
(v2) First revision of test suite.
MAINTAINERS | 1 + tests/qtest/meson.build | 1 + tests/qtest/postcard-test.c | 122 ++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 tests/qtest/postcard-test.c
MAINTAINERS +1 -0
@@ -1723,6 +1723,7 @@ ISA POST card M: Lev Kujawski <[email protected]> S: Supported F: hw/i386/postcard.c +F: tests/qtest/postcard-test.c Xtensa Machines ---------------
tests/qtest/meson.build +1 -0
@@ -47,6 +47,7 @@ qtests_i386 = \ (config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) + \ (config_host.has_key('CONFIG_LINUX') and \ config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ + (config_all_devices.has_key('CONFIG_POST_CARD') ? ['postcard-test'] : []) + \ (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \
tests/qtest/postcard-test.c new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.34.1
hw/i386/pc.c void pc_basic_device_init(struct PCMachineState *pcms, · line 1127
Quoted 12 lines · Lev Kujawski
hw/i386/pc.c +1
-3@@ -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 );
This unfortunately breaks live migration of old machine types (new QEMU to old QEMU).
The simplest (though not very simple) way to do it is to add a new property to the machine (e.g. "postcard-rw") and keep the old ioport80_io_ops if the property is false. Default the property to true, and in hw/i386/pc.c make the property false with an entry like
{ TYPE_PC_MACHINE "postcard-rw", "off" },
in pc_compat_7_1.
hw/i386/postcard.c line 103
Quoted 1 line
hw/i386/postcard.c new file +1
-0+ VMSTATE_UINT16(port, POSTCardState),
port doesn't have to be stored.
Paolo