[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/5] spapr: define get_fw_dev_path() callback
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-devel] [PATCH 5/5] spapr: define get_fw_dev_path() callback |
Date: |
Mon, 25 Nov 2013 18:27:40 +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,boolist property of
the device tree. SLOF needs an update in order to support the boot list.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
hw/ppc/spapr.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7e53a5f..88bb9ce 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"
@@ -590,6 +591,8 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
int ret;
void *fdt;
sPAPRPHBState *phb;
+ size_t cb = 0;
+ char *bootlist;
fdt = g_malloc(FDT_MAX_SIZE);
@@ -633,6 +636,15 @@ 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);
+ }
+ ret = fdt_setprop_string(fdt, offset, "qemu,bootlist", bootlist);
+ }
+
_FDT((fdt_pack(fdt)));
if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
@@ -711,7 +723,6 @@ static void ppc_spapr_reset(void)
first_ppc_cpu->env.gpr[5] = 0;
first_cpu->halted = 0;
first_ppc_cpu->env.nip = spapr->entry_point;
-
}
static void spapr_cpu_reset(void *opaque)
@@ -1357,6 +1368,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 +1406,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