Port 92 is an integral part of south bridges. Allow for embedding it there.
South bridges aren't architecture-specific, so move port92.c to hw/isa which is
accessible to other architectures than x86.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
include/hw/i386/pc.h | 5 -----
include/hw/isa/port92.h | 30 ++++++++++++++++++++++++++++++
hw/i386/pc.c | 1 +
hw/{i386 => isa}/port92.c | 14 +-------------
hw/i386/Kconfig | 1 +
hw/i386/meson.build | 3 +--
hw/i386/trace-events | 4 ----
hw/isa/Kconfig | 3 +++
hw/isa/meson.build | 1 +
hw/isa/trace-events | 4 ++++
10 files changed, 42 insertions(+), 24 deletions(-)
create mode 100644 include/hw/isa/port92.h
rename hw/{i386 => isa}/port92.c (91%)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ec0e5efcb2..b2987209b1 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -188,11 +188,6 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus);
void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
-/* port92.c */
-#define PORT92_A20_LINE "a20"
-
-#define TYPE_PORT92 "port92"
-
/* pc_sysfw.c */
void pc_system_flash_create(PCMachineState *pcms);
void pc_system_flash_cleanup_unused(PCMachineState *pcms);
diff --git a/include/hw/isa/port92.h b/include/hw/isa/port92.h
new file mode 100644
index 0000000000..214783d071
--- /dev/null
+++ b/include/hw/isa/port92.h
@@ -0,0 +1,30 @@
+/*
+ * QEMU I/O port 0x92 (System Control Port A, to handle Fast Gate A20)
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HW_PORT92_H
+#define HW_PORT92_H
+
+#include "exec/memory.h"
+#include "hw/irq.h"
+#include "hw/isa/isa.h"
+#include "qom/object.h"
+
+#define TYPE_PORT92 "port92"
+OBJECT_DECLARE_SIMPLE_TYPE(Port92State, PORT92)
+
+struct Port92State {
+ ISADevice parent_obj;
+
+ MemoryRegion io;
+ uint8_t outport;
+ qemu_irq a20_out;
+};
+
+#define PORT92_A20_LINE "a20"
+
+#endif /* HW_PORT92_H */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 196827531a..0b11d4576e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -32,6 +32,7 @@
#include "hw/i386/vmport.h"
#include "sysemu/cpus.h"
#include "hw/ide/internal.h"
+#include "hw/isa/port92.h"
#include "hw/timer/hpet.h"
#include "hw/loader.h"
#include "hw/rtc/mc146818rtc.h"
diff --git a/hw/i386/port92.c b/hw/isa/port92.c
similarity index 91%
rename from hw/i386/port92.c
rename to hw/isa/port92.c
index 1070bfbf36..06df06b088 100644
--- a/hw/i386/port92.c
+++ b/hw/isa/port92.c
@@ -9,20 +9,8 @@
#include "qemu/osdep.h"
#include "sysemu/runstate.h"
#include "migration/vmstate.h"
-#include "hw/irq.h"
-#include "hw/i386/pc.h"
+#include "hw/isa/port92.h"
#include "trace.h"
-#include "qom/object.h"
-
-OBJECT_DECLARE_SIMPLE_TYPE(Port92State, PORT92)
-
-struct Port92State {
- ISADevice parent_obj;
-
- MemoryRegion io;
- uint8_t outport;
- qemu_irq a20_out;
-};
static void port92_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index a1846be6f7..ccf6de4a00 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -37,6 +37,7 @@ config PC
select I8254
select PCKBD
select PCSPK
+ select PORT92
select I8257
select MC146818RTC
# For ACPI builder:
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index b9c1ca39cb..94d558edd6 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -24,8 +24,7 @@ i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
i386_ss.add(when: 'CONFIG_PC', if_true: files(
'pc.c',
'pc_sysfw.c',
- 'acpi-build.c',
- 'port92.c'))
+ 'acpi-build.c'))
i386_ss.add(when: 'CONFIG_X86_FW_OVMF', if_true: files('pc_sysfw_ovmf.c'),
if_false: files('pc_sysfw_ovmf-stubs.c'))
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
index 53c02d7ac8..b730589394 100644
--- a/hw/i386/trace-events
+++ b/hw/i386/trace-events
@@ -118,10 +118,6 @@ vmport_command(unsigned char command) "command: 0x%02x"
x86_gsi_interrupt(int irqn, int level) "GSI interrupt #%d level:%d"
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"
-
# vmmouse.c
vmmouse_get_status(void) ""
vmmouse_mouse_event(int x, int y, int dz, int buttons_state) "event: x=%d y=%d dz=%d state=%d"
diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index 73c6470805..efdf43e92c 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -49,6 +49,9 @@ config PIIX
select MC146818RTC
select USB_UHCI
+config PORT92
+ bool
+
config VT82C686
bool
select ISA_BUS
diff --git a/hw/isa/meson.build b/hw/isa/meson.build
index 3219282217..fb7cd44984 100644
--- a/hw/isa/meson.build
+++ b/hw/isa/meson.build
@@ -5,6 +5,7 @@ system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('isa-bus.c'))
system_ss.add(when: 'CONFIG_ISA_SUPERIO', if_true: files('isa-superio.c'))
system_ss.add(when: 'CONFIG_PC87312', if_true: files('pc87312.c'))
system_ss.add(when: 'CONFIG_PIIX', if_true: files('piix.c'))
+system_ss.add(when: 'CONFIG_PORT92', if_true: files('port92.c'))
system_ss.add(when: 'CONFIG_SMC37C669', if_true: files('smc37c669-superio.c'))
system_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c'))
diff --git a/hw/isa/trace-events b/hw/isa/trace-events
index 1816e8307a..bb5d9f1078 100644
--- a/hw/isa/trace-events
+++ b/hw/isa/trace-events
@@ -10,6 +10,10 @@ superio_create_ide(int id, uint16_t base, unsigned int irq) "id=%d, base 0x%03x,
pc87312_io_read(uint32_t addr, uint32_t val) "read addr=0x%x val=0x%x"
pc87312_io_write(uint32_t addr, uint32_t val) "write addr=0x%x val=0x%x"
+# port92.c
+port92_read(uint8_t val) "port92: read 0x%02x"
+port92_write(uint8_t val) "port92: write 0x%02x"
+
# apm.c
apm_io_read(uint8_t addr, uint8_t val) "read addr=0x%x val=0x%02x"
apm_io_write(uint8_t addr, uint8_t val) "write addr=0x%x val=0x%02x"
--
2.43.2
On 18/02/2024 13:16, Bernhard Beschow wrote:
> Port 92 is an integral part of south bridges. Allow for embedding it there.
>
> South bridges aren't architecture-specific, so move port92.c to hw/isa which is
> accessible to other architectures than x86.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 5 -----
> include/hw/isa/port92.h | 30 ++++++++++++++++++++++++++++++
> hw/i386/pc.c | 1 +
> hw/{i386 => isa}/port92.c | 14 +-------------
> hw/i386/Kconfig | 1 +
> hw/i386/meson.build | 3 +--
> hw/i386/trace-events | 4 ----
> hw/isa/Kconfig | 3 +++
> hw/isa/meson.build | 1 +
> hw/isa/trace-events | 4 ++++
> 10 files changed, 42 insertions(+), 24 deletions(-)
> create mode 100644 include/hw/isa/port92.h
> rename hw/{i386 => isa}/port92.c (91%)
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index ec0e5efcb2..b2987209b1 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -188,11 +188,6 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus);
>
> void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
>
> -/* port92.c */
> -#define PORT92_A20_LINE "a20"
> -
> -#define TYPE_PORT92 "port92"
> -
> /* pc_sysfw.c */
> void pc_system_flash_create(PCMachineState *pcms);
> void pc_system_flash_cleanup_unused(PCMachineState *pcms);
> diff --git a/include/hw/isa/port92.h b/include/hw/isa/port92.h
> new file mode 100644
> index 0000000000..214783d071
> --- /dev/null
> +++ b/include/hw/isa/port92.h
> @@ -0,0 +1,30 @@
> +/*
> + * QEMU I/O port 0x92 (System Control Port A, to handle Fast Gate A20)
> + *
> + * Copyright (c) 2003-2004 Fabrice Bellard
> + *
> + * SPDX-License-Identifier: MIT
> + */
> +
> +#ifndef HW_PORT92_H
> +#define HW_PORT92_H
> +
> +#include "exec/memory.h"
> +#include "hw/irq.h"
> +#include "hw/isa/isa.h"
> +#include "qom/object.h"
> +
> +#define TYPE_PORT92 "port92"
> +OBJECT_DECLARE_SIMPLE_TYPE(Port92State, PORT92)
> +
> +struct Port92State {
> + ISADevice parent_obj;
> +
> + MemoryRegion io;
> + uint8_t outport;
> + qemu_irq a20_out;
> +};
> +
> +#define PORT92_A20_LINE "a20"
> +
> +#endif /* HW_PORT92_H */
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 196827531a..0b11d4576e 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -32,6 +32,7 @@
> #include "hw/i386/vmport.h"
> #include "sysemu/cpus.h"
> #include "hw/ide/internal.h"
> +#include "hw/isa/port92.h"
> #include "hw/timer/hpet.h"
> #include "hw/loader.h"
> #include "hw/rtc/mc146818rtc.h"
> diff --git a/hw/i386/port92.c b/hw/isa/port92.c
> similarity index 91%
> rename from hw/i386/port92.c
> rename to hw/isa/port92.c
> index 1070bfbf36..06df06b088 100644
> --- a/hw/i386/port92.c
> +++ b/hw/isa/port92.c
> @@ -9,20 +9,8 @@
> #include "qemu/osdep.h"
> #include "sysemu/runstate.h"
> #include "migration/vmstate.h"
> -#include "hw/irq.h"
> -#include "hw/i386/pc.h"
> +#include "hw/isa/port92.h"
> #include "trace.h"
> -#include "qom/object.h"
> -
> -OBJECT_DECLARE_SIMPLE_TYPE(Port92State, PORT92)
> -
> -struct Port92State {
> - ISADevice parent_obj;
> -
> - MemoryRegion io;
> - uint8_t outport;
> - qemu_irq a20_out;
> -};
>
> static void port92_write(void *opaque, hwaddr addr, uint64_t val,
> unsigned size)
> diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
> index a1846be6f7..ccf6de4a00 100644
> --- a/hw/i386/Kconfig
> +++ b/hw/i386/Kconfig
> @@ -37,6 +37,7 @@ config PC
> select I8254
> select PCKBD
> select PCSPK
> + select PORT92
> select I8257
> select MC146818RTC
> # For ACPI builder:
> diff --git a/hw/i386/meson.build b/hw/i386/meson.build
> index b9c1ca39cb..94d558edd6 100644
> --- a/hw/i386/meson.build
> +++ b/hw/i386/meson.build
> @@ -24,8 +24,7 @@ i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c'))
> i386_ss.add(when: 'CONFIG_PC', if_true: files(
> 'pc.c',
> 'pc_sysfw.c',
> - 'acpi-build.c',
> - 'port92.c'))
> + 'acpi-build.c'))
> i386_ss.add(when: 'CONFIG_X86_FW_OVMF', if_true: files('pc_sysfw_ovmf.c'),
> if_false: files('pc_sysfw_ovmf-stubs.c'))
>
> diff --git a/hw/i386/trace-events b/hw/i386/trace-events
> index 53c02d7ac8..b730589394 100644
> --- a/hw/i386/trace-events
> +++ b/hw/i386/trace-events
> @@ -118,10 +118,6 @@ vmport_command(unsigned char command) "command: 0x%02x"
> x86_gsi_interrupt(int irqn, int level) "GSI interrupt #%d level:%d"
> 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"
> -
> # vmmouse.c
> vmmouse_get_status(void) ""
> vmmouse_mouse_event(int x, int y, int dz, int buttons_state) "event: x=%d y=%d dz=%d state=%d"
> diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
> index 73c6470805..efdf43e92c 100644
> --- a/hw/isa/Kconfig
> +++ b/hw/isa/Kconfig
> @@ -49,6 +49,9 @@ config PIIX
> select MC146818RTC
> select USB_UHCI
>
> +config PORT92
> + bool
> +
> config VT82C686
> bool
> select ISA_BUS
> diff --git a/hw/isa/meson.build b/hw/isa/meson.build
> index 3219282217..fb7cd44984 100644
> --- a/hw/isa/meson.build
> +++ b/hw/isa/meson.build
> @@ -5,6 +5,7 @@ system_ss.add(when: 'CONFIG_ISA_BUS', if_true: files('isa-bus.c'))
> system_ss.add(when: 'CONFIG_ISA_SUPERIO', if_true: files('isa-superio.c'))
> system_ss.add(when: 'CONFIG_PC87312', if_true: files('pc87312.c'))
> system_ss.add(when: 'CONFIG_PIIX', if_true: files('piix.c'))
> +system_ss.add(when: 'CONFIG_PORT92', if_true: files('port92.c'))
> system_ss.add(when: 'CONFIG_SMC37C669', if_true: files('smc37c669-superio.c'))
> system_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c'))
>
> diff --git a/hw/isa/trace-events b/hw/isa/trace-events
> index 1816e8307a..bb5d9f1078 100644
> --- a/hw/isa/trace-events
> +++ b/hw/isa/trace-events
> @@ -10,6 +10,10 @@ superio_create_ide(int id, uint16_t base, unsigned int irq) "id=%d, base 0x%03x,
> pc87312_io_read(uint32_t addr, uint32_t val) "read addr=0x%x val=0x%x"
> pc87312_io_write(uint32_t addr, uint32_t val) "write addr=0x%x val=0x%x"
>
> +# port92.c
> +port92_read(uint8_t val) "port92: read 0x%02x"
> +port92_write(uint8_t val) "port92: write 0x%02x"
> +
> # apm.c
> apm_io_read(uint8_t addr, uint8_t val) "read addr=0x%x val=0x%02x"
> apm_io_write(uint8_t addr, uint8_t val) "write addr=0x%x val=0x%02x"
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ATB,
Mark.
© 2016 - 2026 Red Hat, Inc.