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.
This commit is contained in:
nwhitehorn 2013-11-17 19:01:13 +00:00
parent 7b594c7f80
commit 3c6cdd40e1
2 changed files with 17 additions and 7 deletions

View File

@ -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";

View File

@ -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;
};