Index: boot/powerpc/ofw/ofwfdt.c =================================================================== --- boot/powerpc/ofw/ofwfdt.c (revision 302205) +++ boot/powerpc/ofw/ofwfdt.c (working copy) @@ -42,15 +42,26 @@ static void add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset) { - int i, child_offset, error; - char name[2048], *lastprop, *subname; + int i, child_offset, error; + char name[255], *lastprop, *subname; void *propbuf; - size_t proplen; + ssize_t proplen; lastprop = NULL; while (OF_nextprop(node, lastprop, name) > 0) { proplen = OF_getproplen(node, name); + + /* Detect and correct for errors and strangeness */ + if (proplen < 0) + proplen = 0; + if (proplen > 2048) + proplen = 1024; + propbuf = malloc(proplen); + if (propbuf == NULL) { + printf("Cannot allocate memory for prop %s\n", name); + return; + } OF_getprop(node, name, propbuf, proplen); error = fdt_setprop(buffer, fdt_offset, name, propbuf, proplen); free(propbuf); @@ -64,7 +75,7 @@ && !OF_hasprop(node, "ibm,phandle")) fdt_setprop(buffer, fdt_offset, "phandle", &node, sizeof(node)); - for (node = OF_child(node); node > 0; node = OF_peer(node)) { + for (node = OF_child(node); node > 0; node = OF_peer(node)) { OF_package_to_path(node, name, sizeof(name)); subname = strrchr(name, '/'); subname++; @@ -76,7 +87,7 @@ } add_node_to_fdt(buffer, node, child_offset); - } + } } static void @@ -123,18 +134,16 @@ fdt_add_mem_rsv(fdtp, base, len); } else { /* - * Remove /memory/available properties, which reflect long-gone OF - * state. Note that this doesn't work if we need RTAS still, since - * that's part of the firmware. + * Remove /memory/available properties, which reflect long-gone + * OF state. Note that this doesn't work if we need RTAS still, + * since that's part of the firmware. */ - offset = fdt_path_offset(fdtp, "/memory@0"); if (offset > 0) fdt_delprop(fdtp, offset, "available"); } - - /* + /* * Convert stored ihandles under /chosen to xref phandles */ Index: powerpc/aim/mmu_oea.c =================================================================== --- powerpc/aim/mmu_oea.c (revision 302221) +++ powerpc/aim/mmu_oea.c (working copy) @@ -921,7 +921,7 @@ Maxmem = powerpc_btop(phys_avail[i + 1]); moea_cpu_bootstrap(mmup,0); - + mtmsr(mfmsr() | PSL_DR | PSL_IR); pmap_bootstrapped++; /* Index: powerpc/powermac/macio.c =================================================================== --- powerpc/powermac/macio.c (revision 302221) +++ powerpc/powermac/macio.c (working copy) @@ -429,6 +429,18 @@ bus_write_4(sc->sc_memr, KEYLARGO_FCR1, fcr1); } + /* + * Enable serial ports if inactive. + */ + if (strcmp(ofw_bus_get_name(cdev), "escc") == 0) { + uint32_t fcr0; + + fcr0 = bus_read_4(sc->sc_memr, KEYLARGO_FCR0); + fcr0 |= (FCR0_SCC_CELL_ENABLE | FCR0_SCCA_ENABLE | + FCR0_SCCB_ENABLE); + bus_write_4(sc->sc_memr, KEYLARGO_FCR0, fcr0); + } + } return (bus_generic_attach(dev)); Index: powerpc/powermac/maciovar.h =================================================================== --- powerpc/powermac/maciovar.h (revision 302221) +++ powerpc/powermac/maciovar.h (working copy) @@ -44,13 +44,29 @@ #define KEYLARGO_FCR0 0x38 #define KEYLARGO_FCR1 0x3c #define KEYLARGO_FCR2 0x40 +#define KEYLARGO_FCR3 0x44 +#define KEYLARGO_FCR4 0x48 +#define KEYLARGO_FCR5 0x4c #define FCR_ENET_ENABLE 0x60000000 #define FCR_ENET_RESET 0x80000000 +#define FCR0_SCCA_ENABLE 0x00000010 +#define FCR0_SCCB_ENABLE 0x00000020 +#define FCR0_SCC_CELL_ENABLE 0x00000040 + #define FCR1_I2S0_CLK_ENABLE 0x00001000 #define FCR1_I2S0_ENABLE 0x00002000 +#define FCR1_EIDE0_ENABLE 0x00800000 +#define FCR1_EIDE0_RESET 0x01000000 +#define FCR1_EIDE1_ENABLE 0x04000000 +#define FCR1_EIDE1_RESET 0x08000000 +#define FCR1_UIDE_ENABLE 0x20000000 +#define FCR1_UIDE_RESET 0x40000000 + +#define FCR2_IOBUS_ENABLE 0x00000002 + /* Used only by macio_enable_wireless() for now. */ #define KEYLARGO_GPIO_BASE 0x6a #define KEYLARGO_EXTINT_GPIO_REG_BASE 0x58 Index: powerpc/powermac/uninorth.c =================================================================== --- powerpc/powermac/uninorth.c (revision 302221) +++ powerpc/powermac/uninorth.c (working copy) @@ -144,7 +144,8 @@ */ static device_t unin_chip; -DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0); +EARLY_DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0, + BUS_PASS_BUS); /* * Add an interrupt to the dev's resource list if present @@ -321,6 +322,11 @@ if (unin_chip == NULL) unin_chip = dev; + /* + * Make sure this thing is on + */ + unin_chip_wake(dev); + /* * Iterate through the sub-devices */ @@ -405,10 +411,12 @@ * GMAC lives under the PCI bus, so just check if enet is gmac. */ child = OF_finddevice("enet"); - memset(compat, 0, sizeof(compat)); - OF_getprop(child, "compatible", compat, sizeof(compat)); - if (strcmp(compat, "gmac") == 0) - unin_enable_gmac(dev); + if (child != -1) { + memset(compat, 0, sizeof(compat)); + OF_getprop(child, "compatible", compat, sizeof(compat)); + if (strcmp(compat, "gmac") == 0) + unin_enable_gmac(dev); + } return (bus_generic_attach(dev)); } Index: powerpc/powerpc/machdep.c =================================================================== --- powerpc/powerpc/machdep.c (revision 302221) +++ powerpc/powerpc/machdep.c (working copy) @@ -251,7 +251,19 @@ if (mdp == (void *)0x65504150) mdp = NULL; +#if AIM /* + * If running from an FDT, make sure we are in real mode to avoid + * tromping on firmware page tables. Everything in the kernel assumes + * 1:1 mappings out of firmware, so this won't break anything not + * already broken. This doesn't work if there is live OF, since OF + * may internally use non-1:1 mappings. + */ + if (ofentry == 0) + mtmsr(mfmsr() & ~(PSL_IR | PSL_DR)); +#endif + + /* * Parse metadata if present and fetch parameters. Must be done * before console is inited so cninit gets the right value of * boothowto.