[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v2] spapr: define get_fw_dev_path() callback
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-ppc] [PATCH v2] spapr: define get_fw_dev_path() callback |
Date: |
Tue, 26 Nov 2013 15:05:44 +1100 |
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 "address@hidden" 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 <address@hidden>
---
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 "address@hidden/address@hidden,0" with "address@hidden":
+ * 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("address@hidden"PRIX64, qdev_fw_name(dev),
+ (uint64_t)id << 48);
+ }
+
+ if (phb) {
+ /* Replace "pci" with "address@hidden" */
+ return g_strdup_printf("address@hidden"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
- [Qemu-ppc] [RFC PATCH 0/5] spapr: support bootindex, Alexey Kardashevskiy, 2013/11/25
- [Qemu-ppc] [PATCH 4/5] spapr-vio: fix firmware names, Alexey Kardashevskiy, 2013/11/25
- [Qemu-ppc] [PATCH 5/5] spapr: define get_fw_dev_path() callback, Alexey Kardashevskiy, 2013/11/25
- [Qemu-ppc] [PATCH v2] spapr: define get_fw_dev_path() callback,
Alexey Kardashevskiy <=
- [Qemu-ppc] [PATCH 3/5] spapr-llan: add to boot device list, Alexey Kardashevskiy, 2013/11/25
- [Qemu-ppc] [PATCH 1/5] boot: extend get_boot_devices_list() to ignore suffixes, Alexey Kardashevskiy, 2013/11/25
- [Qemu-ppc] [PATCH 2/5] machine: introduce get_fw_dev_path() callback, Alexey Kardashevskiy, 2013/11/25