[PATCH 09/12] hw/hppa: Export machine name, BTLBs, power-button address via fw_cfg

deller@kernel.org posted 12 patches 1 year, 1 month ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, Sven Schnelle <svens@stackframe.org>, Jason Wang <jasowang@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
There is a newer version of this series
[PATCH 09/12] hw/hppa: Export machine name, BTLBs, power-button address via fw_cfg
Posted by deller@kernel.org 1 year, 1 month ago
From: Helge Deller <deller@gmx.de>

Provide necessary info to SeaBIOS-hppa.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 hw/hppa/machine.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c6d8deffcf..be0caf4675 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -37,6 +37,7 @@
 
 #define enable_lasi_lan()       0
 
+static PCIBus *pci_bus;
 
 static void hppa_powerdown_req(Notifier *n, void *opaque)
 {
@@ -123,6 +124,8 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     FWCfgState *fw_cfg;
     uint64_t val;
     const char qemu_version[] = QEMU_VERSION;
+    MachineClass *mc = MACHINE_GET_CLASS(ms);
+    int len;
 
     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);
@@ -137,8 +140,20 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     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));
+
+    len = strlen(mc->name) + 1;
+    fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
+                    g_memdup(mc->name, len), len);
+
     val = cpu_to_le64(HPA_POWER_BUTTON);
-    fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",
+    fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
+                    g_memdup(&val, sizeof(val)), sizeof(val));
+
+    val = cpu_to_le64(CPU_HPA + 24);
+    fw_cfg_add_file(fw_cfg, "/etc/hppa/DebugOutputPort",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]);
@@ -148,6 +163,8 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
                     g_memdup(qemu_version, sizeof(qemu_version)),
                     sizeof(qemu_version));
 
+    fw_cfg_add_extra_pci_roots(pci_bus, fw_cfg);
+
     return fw_cfg;
 }
 
-- 
2.41.0
Re: [PATCH 09/12] hw/hppa: Export machine name, BTLBs, power-button address via fw_cfg
Posted by Philippe Mathieu-Daudé 1 year, 1 month ago
Hi Helge,

On 14/10/23 21:57, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> Provide necessary info to SeaBIOS-hppa.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   hw/hppa/machine.c | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
> index c6d8deffcf..be0caf4675 100644
> --- a/hw/hppa/machine.c
> +++ b/hw/hppa/machine.c
> @@ -37,6 +37,7 @@
>   
>   #define enable_lasi_lan()       0
>   
> +static PCIBus *pci_bus;

I don't understand what this unassigned variable is doing here.

>   static void hppa_powerdown_req(Notifier *n, void *opaque)
>   {
> @@ -123,6 +124,8 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
>       FWCfgState *fw_cfg;
>       uint64_t val;
>       const char qemu_version[] = QEMU_VERSION;
> +    MachineClass *mc = MACHINE_GET_CLASS(ms);
> +    int len;
>   
>       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);
> @@ -137,8 +140,20 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
>       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));
> +
> +    len = strlen(mc->name) + 1;
> +    fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
> +                    g_memdup(mc->name, len), len);
> +
>       val = cpu_to_le64(HPA_POWER_BUTTON);
> -    fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",
> +    fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
> +                    g_memdup(&val, sizeof(val)), sizeof(val));
> +
> +    val = cpu_to_le64(CPU_HPA + 24);
> +    fw_cfg_add_file(fw_cfg, "/etc/hppa/DebugOutputPort",
>                       g_memdup(&val, sizeof(val)), sizeof(val));
>   
>       fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]);
> @@ -148,6 +163,8 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
>                       g_memdup(qemu_version, sizeof(qemu_version)),
>                       sizeof(qemu_version));
>   
> +    fw_cfg_add_extra_pci_roots(pci_bus, fw_cfg);

IIUC you have a MachineState pointer, so you can resolve the bus
from there, or in all qomtree using:

   object_resolve_path_type("", TYPE_PCI_BUS, ...);

>       return fw_cfg;
>   }
>