This introduces a get_fw_dev_path() callback. This fixes SCSI disks device node names (which are wildcard nodes in the device-tree).
This fixes PHB name from "pci" to "pci@XXXX" where XXXX is a BUID as there is no bus on top of sPAPRPHBState where PHB firmware name could be fixed using the BusClass::get_fw_dev_path mechanism. This stores the boot list in the /chosen/qemu,boot-list property of the device tree. SLOF needs an update in order to support the boot list. Signed-off-by: Alexey Kardashevskiy <a...@ozlabs.ru> --- Changes: v2: * \n replaced with space as this is what SLOF expects there * qemu,bootlist renamed to qemu,boot-list --- hw/ppc/spapr.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 7e53a5f..fe02f23 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -45,6 +45,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pci.h" +#include "hw/scsi/scsi.h" #include "exec/address-spaces.h" #include "hw/usb.h" @@ -587,9 +588,11 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, hwaddr rtas_addr, hwaddr rtas_size) { - int ret; + int ret, i; void *fdt; sPAPRPHBState *phb; + size_t cb = 0; + char *bootlist; fdt = g_malloc(FDT_MAX_SIZE); @@ -633,6 +636,21 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr, spapr_populate_chosen_stdout(fdt, spapr->vio_bus); } + bootlist = get_boot_devices_list(&cb, true); + if (cb && bootlist) { + int offset = fdt_path_offset(fdt, "/chosen"); + if (offset < 0) { + exit(1); + } + for (i = 0; i < cb; i++) { + if (bootlist[i] == '\n') { + bootlist[i] = ' '; + } + + } + ret = fdt_setprop_string(fdt, offset, "qemu,boot-list", bootlist); + } + _FDT((fdt_pack(fdt))); if (fdt_totalsize(fdt) > FDT_MAX_SIZE) { @@ -1357,6 +1375,34 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) assert(spapr->fdt_skel != NULL); } +#define CAST(type, obj, name) \ + ((type *)object_dynamic_cast(OBJECT(obj), (name))) + +static char *spapr_get_fw_dev_path(BusState *bus, DeviceState *dev) +{ + SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE); + sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE); + + if (d) { + /* + * Replace "channel@0/disk@0,0" with "disk@8000000000000000": + * We use SRP luns of the form 8000 | (bus << 8) | (id << 5) | lun + * in the top 16 bits of the 64-bit LUN + */ + unsigned id = 0x8000 | (d->channel << 8) | (d->id << 5) | d->lun; + + return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), + (uint64_t)id << 48); + } + + if (phb) { + /* Replace "pci" with "pci@800000020000000" */ + return g_strdup_printf("pci@%"PRIX64, phb->buid); + } + + return NULL; +} + static QEMUMachine spapr_machine = { .name = "pseries", .desc = "pSeries Logical Partition (PAPR compliant)", @@ -1367,6 +1413,7 @@ static QEMUMachine spapr_machine = { .max_cpus = MAX_CPUS, .no_parallel = 1, .default_boot_order = NULL, + .get_fw_dev_path = spapr_get_fw_dev_path }; static void spapr_machine_init(void) -- 1.8.4.rc4