From 4ee635532e74883b8e09656dc7dc0d4607759b25 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 17 Nov 2013 19:01:13 +0000 Subject: [PATCH] Use #address-cells and #size-cells here too instead of guessing. There is some comment I wrote about these values "lying" in the negative diff, which referes to an earlier misunderstanding about which node to read them from. This gets at least the PPC64 kernel booting in the mac99 system model in QEMU after bypassing the MacIO ATA driver, which apparently still has problems. --- sys/powerpc/powermac/uninorth.c | 20 +++++++++++++++----- sys/powerpc/powermac/uninorthvar.h | 4 ++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c index e9ab291e33f..748148e7806 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -264,6 +264,7 @@ unin_chip_attach(device_t dev) phandle_t child; phandle_t iparent; device_t cdev; + cell_t acells, scells; char compat[32]; char name[32]; u_int irq, reg[3]; @@ -275,12 +276,21 @@ unin_chip_attach(device_t dev) if (OF_getprop(root, "reg", reg, sizeof(reg)) < 8) return (ENXIO); - if (strcmp(ofw_bus_get_name(dev), "u3") == 0 - || strcmp(ofw_bus_get_name(dev), "u4") == 0) - i = 1; /* #address-cells lies */ + acells = scells = 1; + OF_getprop(OF_parent(root), "#address-cells", &acells, sizeof(acells)); + OF_getprop(OF_parent(root), "#size-cells", &scells, sizeof(scells)); - sc->sc_physaddr = reg[i]; - sc->sc_size = reg[i+1]; + i = 0; + sc->sc_physaddr = reg[i++]; + if (acells == 2) { + sc->sc_physaddr <<= 32; + sc->sc_physaddr |= reg[i++]; + } + sc->sc_size = reg[i++]; + if (scells == 2) { + sc->sc_size <<= 32; + sc->sc_size |= reg[i++]; + } sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_descr = "UniNorth Device Memory"; diff --git a/sys/powerpc/powermac/uninorthvar.h b/sys/powerpc/powermac/uninorthvar.h index 43aa01d0e00..aa834f6a1e8 100644 --- a/sys/powerpc/powermac/uninorthvar.h +++ b/sys/powerpc/powermac/uninorthvar.h @@ -38,9 +38,9 @@ struct uninorth_softc { }; struct unin_chip_softc { - u_int32_t sc_physaddr; + uint64_t sc_physaddr; + uint64_t sc_size; vm_offset_t sc_addr; - u_int32_t sc_size; struct rman sc_mem_rman; int sc_version; };