hppa power button support and firmware fixes
cover hppa power button support and firmware fixes
This patch adds emulation for a power button on hppa, makes the number of TLB/BTLB entries configurable from qemu and includes a new hppa firmware with some bugs fixed.
Helge Deller (5):
seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag hw/hppa: Make number of TLB and BTLB entries configurable hw/hppa: Store boot device in fw_cfg section hw/hppa: Inform SeaBIOS about fw_cfg port address hw/hppa: Add power button emulation
hw/hppa/hppa_hardware.h | 3 +- hw/hppa/machine.c | 56 +++++++++++++++++++++++++++++++++++++- pc-bios/hppa-firmware.img | Bin 783192 -> 783456 bytes roms/seabios-hppa | 2 +- target/hppa/cpu.h | 5 +++- 5 files changed, 61 insertions(+), 5 deletions(-)
--
2.21.3
PATCH 1/5 seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag
Changes:
* If only one bootable device is available, boot from it.
* Silence PDC warnings with HP-UX 11.11
* Inform Linux about fw_cfg port addresses
* Make power switch button configurable from qemu
--- pc-bios/hppa-firmware.img | Bin 783192 -> 783456 bytes roms/seabios-hppa | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/hppa-firmware.img binary +0 -0
roms/seabios-hppa +1 -1
@@ -1 +1 @@ -Subproject commit 4ff7639e2b86d5775fa7d5cd0dbfa4d3a385a701 +Subproject commit 573576115a576642b1c253deca727be9631c72fb
--
2.21.3
PATCH 2/5 hw/hppa: Make number of TLB and BTLB entries configurable
In reply to Helge DellerUntil now the TLB size was fixed at 256 entries. To allow operating systems to utilize more TLB entries in the future, we need to tell firmware how many TLB entries we actually support in the emulation. Firmware then reports this to the operating system via the PDC_CACHE_INFO call.
This patch simply does the preparation to allow more TLB entries.
--- hw/hppa/machine.c | 8 ++++++++ target/hppa/cpu.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-)
hw/hppa/machine.c +8 -0
@@ -72,6 +72,14 @@ static FWCfgState *create_fw_cfg(MachineState *ms)fw_cfg_add_file (fw_cfg,"/etc/firmware-min-version" ,g_memdup (&val,sizeof (val)),sizeof (val)); + val =cpu_to_le64 (HPPA_TLB_ENTRIES ); +fw_cfg_add_file (fw_cfg,"/etc/cpu/tlb_entries" , +g_memdup (&val,sizeof (val)),sizeof (val)); + + val =cpu_to_le64 (HPPA_BTLB_ENTRIES ); +fw_cfg_add_file (fw_cfg,"/etc/cpu/btlb_entries" , +g_memdup (&val,sizeof (val)),sizeof (val)); +return fw_cfg; }
target/hppa/cpu.h +4 -1
@@ -196,9 +196,12 @@ struct CPUHPPAState {target_ureg shadow[7 ];/* shadow registers */ /* ??? The number of entries isn't specified by the architecture. */ +#define HPPA_TLB_ENTRIES 256 +#define HPPA_BTLB_ENTRIES 0 +/* ??? Implement a unified itlb/dtlb for the moment. */ /* ??? We should use a more intelligent data structure. */ -hppa_tlb_entry tlb[256 ]; +hppa_tlb_entry tlb[HPPA_TLB_ENTRIES ];uint32_t tlb_last; };
--
2.21.3
PATCH 3/5 hw/hppa: Store boot device in fw_cfg section
In reply to Helge Deller--- hw/hppa/machine.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/hppa/machine.c +9 -0
@@ -58,6 +58,12 @@ static uint64_t cpu_hppa_to_phys(void *opaque, uint64_t addr)static HPPACPU *cpu[HPPA_MAX_CPUS ];static uint64_t firmware_entry; +static void fw_cfg_boot_set (void *opaque,const char *boot_device, +Error **errp) +{ +fw_cfg_modify_i16 (opaque,FW_CFG_BOOT_DEVICE , boot_device[0 ]); +} +static FWCfgState *create_fw_cfg (MachineState *ms) {FWCfgState *fw_cfg;
@@ -80,6 +86,9 @@ static FWCfgState *create_fw_cfg(MachineState *ms)fw_cfg_add_file (fw_cfg,"/etc/cpu/btlb_entries" ,g_memdup (&val,sizeof (val)),sizeof (val)); +fw_cfg_add_i16 (fw_cfg,FW_CFG_BOOT_DEVICE , ms->boot_order[0 ]); +qemu_register_boot_set (fw_cfg_boot_set, fw_cfg); +return fw_cfg; }
--
2.21.3
PATCH 4/5 hw/hppa: Inform SeaBIOS about fw_cfg port address
In reply to Helge Deller--- hw/hppa/hppa_hardware.h | 3 +-- hw/hppa/machine.c | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-)
hw/hppa/hppa_hardware.h +1 -2
@@ -38,8 +38,7 @@#define PORT_PCI_CMD (PCI_HPA + DINO_PCI_ADDR)#define PORT_PCI_DATA (PCI_HPA + DINO_CONFIG_DATA) -/* QEMU fw_cfg interface port */ -#define QEMU_FW_CFG_IO_BASE (MEMORY_HPA + 0x80) +#define FW_CFG_IO_BASE 0xfffa0000#define PORT_SERIAL1 (DINO_UART_HPA + 0x800)#define PORT_SERIAL2 (LASI_UART_HPA + 0x800)
hw/hppa/machine.c +6 -1
@@ -69,7 +69,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms)FWCfgState *fw_cfg;uint64_t val; - fw_cfg =fw_cfg_init_mem (QEMU_FW_CFG_IO_BASE ,QEMU_FW_CFG_IO_BASE +4 ); + fw_cfg =fw_cfg_init_mem (FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 );fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , ms->smp.cpus);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS ,HPPA_MAX_CPUS );fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , ram_size);
@@ -290,6 +290,9 @@ static void machine_hppa_init(MachineState *machine)/* tell firmware how many SMP CPUs to present in inventory table */ cpu[0 ]->env.gr[21 ] = smp_cpus; + +/* tell firmware fw_cfg port */ + cpu[0 ]->env.gr[19 ] =FW_CFG_IO_BASE ; }static void hppa_machine_reset (MachineState *ms)
@@ -317,6 +320,8 @@ static void hppa_machine_reset(MachineState *ms) cpu[0 ]->env.gr[24 ] ='c' ;/* gr22/gr23 unused, no initrd while reboot. */ cpu[0 ]->env.gr[21 ] = smp_cpus; +/* tell firmware fw_cfg port */ + cpu[0 ]->env.gr[19 ] =FW_CFG_IO_BASE ; }
--
2.21.3
PATCH 5/5 hw/hppa: Add power button emulation
In reply to Helge DellerEmulate a power button switch, tell SeaBIOS the address via fw_cfg and bind the power button to the qemu UI.
--- hw/hppa/machine.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
hw/hppa/machine.c +32 -0
@@ -12,6 +12,7 @@#include "qemu/error-report.h" #include "sysemu/reset.h" #include "sysemu/sysemu.h" +#include "sysemu/runstate.h" #include "hw/rtc/mc146818rtc.h" #include "hw/timer/i8254.h" #include "hw/char/serial.h"
@@ -27,6 +28,30 @@#define MIN_SEABIOS_HPPA_VERSION 1/* require at least this fw version */ +#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10) + +static void hppa_powerdown_req (Notifier *n,void *opaque) +{ +hwaddr soft_power_reg =HPA_POWER_BUTTON ; +uint32_t val; + + val =ldl_be_phys (&address_space_memory, soft_power_reg); +if ((val >>8 ) ==0 ) { +/* immediately shut down when under hardware control */ +qemu_system_shutdown_request (SHUTDOWN_CAUSE_GUEST_SHUTDOWN ); +return ; + } + +/* clear bit 31 to indicate that the power switch was pressed. */ + val &= ~1 ; +stl_be_phys (&address_space_memory, soft_power_reg, val); +} + +static Notifier hppa_system_powerdown_notifier = { + .notify = hppa_powerdown_req +}; + +static ISABus *hppa_isa_bus (void ) {ISABus *isa_bus;
@@ -86,6 +111,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)fw_cfg_add_file (fw_cfg,"/etc/cpu/btlb_entries" ,g_memdup (&val,sizeof (val)),sizeof (val)); + val =cpu_to_le64 (HPA_POWER_BUTTON ); +fw_cfg_add_file (fw_cfg,"/etc/power-button-addr" , +g_memdup (&val,sizeof (val)),sizeof (val)); +fw_cfg_add_i16 (fw_cfg,FW_CFG_BOOT_DEVICE , ms->boot_order[0 ]);qemu_register_boot_set (fw_cfg_boot_set, fw_cfg);
@@ -177,6 +206,9 @@ static void machine_hppa_init(MachineState *machine) } } +/* register power switch emulation */ +qemu_register_powerdown_notifier (&hppa_system_powerdown_notifier); +/* Load firmware. Given that this is not "real" firmware, but one explicitly written for the emulation, we might as well load it directly from an ELF image. */
--
2.21.3