Date: Tue, 9 Dec 2008 16:59:00 GMT From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 154403 for review Message-ID: <200812091659.mB9Gx0mu097053@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=154403 Change 154403 by nwhitehorn@nwhitehorn_trantor on 2008/12/09 16:58:04 Adapt ofw_syscons to use bus_space_map() so that it gets remapped when the MMU turns on with bs_remap_earlyboot(). This removes the assumption that the framebuffer is BAT-mapped. Affected files ... .. //depot/projects/ppc-g5/sys/powerpc/aim/mmu_oea64.c#11 edit .. //depot/projects/ppc-g5/sys/powerpc/ofw/ofw_syscons.c#5 edit .. //depot/projects/ppc-g5/sys/powerpc/powerpc/cpu.c#5 edit Differences ... ==== //depot/projects/ppc-g5/sys/powerpc/aim/mmu_oea64.c#11 (text+ko) ==== @@ -369,8 +369,6 @@ static void moea64_bridge_cpu_bootstrap(mmu_t, int ap); static void moea64_enter_locked(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, boolean_t); -static void moea64_bootstrap_find_framebuffer(vm_offset_t *va, - vm_size_t *size); static boolean_t moea64_query_bit(vm_page_t, u_int64_t); static u_int moea64_clear_bit(vm_page_t, u_int64_t, u_int64_t *); static void moea64_kremove(mmu_t, vm_offset_t); @@ -729,8 +727,8 @@ int sz; int i, j; int ofw_mappings; - vm_size_t size, physsz, hwphyssz, fbsize; - vm_offset_t pa, va, off, fbva; + vm_size_t size, physsz, hwphyssz; + vm_offset_t pa, va, off; uint32_t msr; /* We don't have a direct map since there is no BAT */ @@ -873,11 +871,6 @@ moea64_kenter(mmup, pa, pa); ENABLE_TRANS(msr); - /* Find the framebuffer, so we can extract its mapping from OF */ - - fbva = 0; fbsize = 0; - moea64_bootstrap_find_framebuffer(&fbva,&fbsize); - /* * Map certain important things, like ourselves and the exception * vectors @@ -932,32 +925,20 @@ DISABLE_TRANS(msr); for (off = 0; off < translations[i].om_len; off += PAGE_SIZE) { - struct vm_page m; - pmap_t pmap = &ofw_pmap; - vm_prot_t prot = VM_PROT_ALL; + struct vm_page m; - m.phys_addr = translations[i].om_pa_lo + off; - /* Map low memory mappings into the kernel pmap, too. * These are typically mappings made by the loader, * so we need them if we want to keep executing. */ - if (translations[i].om_va + off < SEGMENT_LENGTH) { - moea64_enter_locked(kernel_pmap, - translations[i].om_va + off, &m, - prot, 1); - } + if (translations[i].om_va + off < SEGMENT_LENGTH) + moea64_kenter(mmup, translations[i].om_va + off, + translations[i].om_va + off); - /* Map the frame buffer into the kernel pmap instead */ + m.phys_addr = translations[i].om_pa_lo + off; + moea64_enter_locked(&ofw_pmap, + translations[i].om_va + off, &m, VM_PROT_ALL, 1); - if ((translations[i].om_va + off >= fbva) && - (translations[i].om_va + off < fbva + fbsize)) { - pmap = kernel_pmap; - prot = VM_PROT_READ | VM_PROT_WRITE; - } - - moea64_enter_locked(pmap, translations[i].om_va + off, - &m, prot, 1); ofw_mappings++; } ENABLE_TRANS(msr); @@ -1049,32 +1030,6 @@ } } -static void -moea64_bootstrap_find_framebuffer(vm_offset_t *va, vm_size_t *size) -{ - phandle_t chosen, node; - ihandle_t stdout; - - uint32_t depth, height, linebytes; - char type[16]; - - chosen = OF_finddevice("/chosen"); - OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); - node = OF_instance_to_package(stdout); - OF_getprop(node, "device_type", type, sizeof(type)); - - if (strcmp(type, "display") != 0) - return; - - OF_getprop(node, "depth", &depth, sizeof(depth)); - OF_getprop(node, "height", &height, sizeof(height)); - OF_getprop(node, "linebytes", &linebytes, sizeof(linebytes)); - OF_getprop(node, "address", va, sizeof(*va)); - - *size = height * depth/8 * linebytes; -} - - /* * Activate a user pmap. The pmap must be activated before it's address * space can be accessed in any way. @@ -1215,8 +1170,8 @@ * will be wired down. */ void -moea64_enter(mmu_t mmu, pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, - boolean_t wired) +moea64_enter(mmu_t mmu, pmap_t pmap, vm_offset_t va, vm_page_t m, + vm_prot_t prot, boolean_t wired) { vm_page_lock_queues(); @@ -1364,7 +1319,6 @@ moea64_enter_quick(mmu_t mmu, pmap_t pm, vm_offset_t va, vm_page_t m, vm_prot_t prot) { - PMAP_LOCK(pm); moea64_enter_locked(pm, va, m, prot & (VM_PROT_READ | VM_PROT_EXECUTE), FALSE); @@ -1600,11 +1554,6 @@ uint64_t pte_lo; int error; -#if 0 - if (va < VM_MIN_KERNEL_ADDRESS) - panic("moea64_kenter: attempt to enter non-kernel address %#x", - va); -#endif if (!pmap_bootstrapped) { if (va >= VM_MIN_KERNEL_ADDRESS && va < VM_MAX_KERNEL_ADDRESS) panic("Trying to enter an address in KVA -- %#x!\n",pa); ==== //depot/projects/ppc-g5/sys/powerpc/ofw/ofw_syscons.c#5 (text+ko) ==== @@ -214,6 +214,7 @@ phandle_t chosen; ihandle_t stdout; phandle_t node; + bus_addr_t fb_phys; int depth; int disable; int len; @@ -266,10 +267,16 @@ OF_getprop(node, "linebytes", &sc->sc_stride, sizeof(sc->sc_stride)); /* - * XXX the physical address of the frame buffer is assumed to be - * BAT-mapped so it can be accessed directly + * Grab the physical address of the framebuffer, and then map it + * into our memory space. If the MMU is not yet up, it will be + * remapped for us when relocation turns on. + * + * XXX We assume #address-cells is 1 at this point. */ - OF_getprop(node, "address", &sc->sc_addr, sizeof(sc->sc_addr)); + OF_getprop(node, "address", &fb_phys, sizeof(fb_phys)); + + bus_space_map(&bs_be_tag, fb_phys, sc->sc_height * sc->sc_stride, + 0, &sc->sc_addr); /* * Get the PCI addresses of the adapter. The node may be the @@ -279,8 +286,8 @@ len = OF_getprop(node, "assigned-addresses", sc->sc_pciaddrs, sizeof(sc->sc_pciaddrs)); if (len == -1) { - len = OF_getprop(OF_parent(node), "assigned-addresses", sc->sc_pciaddrs, - sizeof(sc->sc_pciaddrs)); + len = OF_getprop(OF_parent(node), "assigned-addresses", + sc->sc_pciaddrs, sizeof(sc->sc_pciaddrs)); } if (len != -1) { @@ -846,13 +853,17 @@ static int ofwfb_scprobe(device_t dev) { - /* This is a fake device, so make sure there is no OF node for it */ - if (ofw_bus_get_node(dev) != -1) - return ENXIO; - + int error; + device_set_desc(dev, "System console"); - return (sc_probe_unit(device_get_unit(dev), - device_get_flags(dev) | SC_AUTODETECT_KBD)); + + error = sc_probe_unit(device_get_unit(dev), + device_get_flags(dev) | SC_AUTODETECT_KBD); + if (error != 0) + return (error); + + /* This is a fake device, so make sure we added it ourselves */ + return (BUS_PROBE_NOWILDCARD); } static int ==== //depot/projects/ppc-g5/sys/powerpc/powerpc/cpu.c#5 (text+ko) ==== @@ -120,7 +120,7 @@ void cpu_setup(u_int cpuid) { - u_int pvr, maj, min, msr, hid0; + u_int pvr, maj, min, hid0; uint16_t vers, rev, revfmt; const struct cputab *cp; const char *name; @@ -171,6 +171,8 @@ break; } + hid0 = mfspr(SPR_HID0); + /* * Configure power-saving mode. */ @@ -233,6 +235,8 @@ break; } + mtspr(SPR_HID0, hid0); + switch (vers) { case MPC7447A: case MPC7448:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812091659.mB9Gx0mu097053>