PERFORCE change 151640 for review

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Oct 21 02:31:57 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=151640

Change 151640 by nwhitehorn at nwhitehorn_trantor on 2008/10/21 02:31:49

	Get serial console working on IBM-ish machines, including Mambo. Also
	implement what promises to be a generic solution to nastiness like
	moea64_find_framebuffer(). Calling bus_space_map() before pmap is
	bootstrapped gets you on a special list of things that need to be
	remapped 1:1 the instant pmap comes up.

Affected files ...

.. //depot/projects/ppc-g5/sys/dev/uart/uart_cpu_powerpc.c#2 edit
.. //depot/projects/ppc-g5/sys/powerpc/aim/mmu_oea64.c#8 edit
.. //depot/projects/ppc-g5/sys/powerpc/include/param.h#2 edit
.. //depot/projects/ppc-g5/sys/powerpc/powermac/cpcht.c#6 edit
.. //depot/projects/ppc-g5/sys/powerpc/powerpc/bus_machdep.c#2 edit

Differences ...

==== //depot/projects/ppc-g5/sys/dev/uart/uart_cpu_powerpc.c#2 (text) ====

@@ -116,7 +116,14 @@
 		return (ENXIO);
 	if (OF_getprop(input, "name", buf, sizeof(buf)) == -1)
 		return (ENXIO);
-	if (strcmp(buf, "ch-a"))
+
+	if (strcmp(buf, "ch-a") == 0) {
+		class = &uart_z8530_class;
+		di->bas.regshft = 4;
+	} else if (strcmp(buf,"serial") == 0) {
+		class = &uart_ns8250_class;
+		di->bas.regshft = 0;
+	} else
 		return (ENXIO);
 
 	error = OF_decode_addr(input, 0, &di->bas.bst, &di->bas.bsh);
@@ -125,9 +132,10 @@
 
 	di->ops = uart_getops(class);
 
-	di->bas.rclk = 230400;
+	if (OF_getprop(input, "current-speed", &di->bas.rclk, 
+	    sizeof(di->bas.rclk)) == -1)
+		di->bas.rclk = 230400;
 	di->bas.chan = 1;
-	di->bas.regshft = 4;
 
 	di->baudrate = 0;
 	di->databits = 8;

==== //depot/projects/ppc-g5/sys/powerpc/aim/mmu_oea64.c#8 (text+ko) ====

@@ -278,6 +278,7 @@
 
 extern struct pmap ofw_pmap;
 
+extern void bs_remap_earlyboot(void);
 
 
 /*
@@ -975,11 +976,12 @@
 	Maxmem = powerpc_btop(phys_avail[i + 1]);
 
 	/*
-	 * Initialize MMU
+	 * Initialize MMU and remap early physical mappings
 	 */
 	moea64_bridge_cpu_bootstrap(0);
 	mtmsr(mfmsr() | PSL_DR | PSL_IR); isync();
 	pmap_bootstrapped++;
+	bs_remap_earlyboot();
 
 	/*
 	 * Set the start and end of kva.

==== //depot/projects/ppc-g5/sys/powerpc/include/param.h#2 (text+ko) ====

@@ -56,6 +56,9 @@
 
 #ifndef _NO_NAMESPACE_POLLUTION
 
+/* Needed to display interrupts on OFW PCI */
+#define __PCI_REROUTE_INTERRUPT
+
 #ifndef _MACHINE_PARAM_H_
 #define	_MACHINE_PARAM_H_
 

==== //depot/projects/ppc-g5/sys/powerpc/powermac/cpcht.c#6 (text+ko) ====

@@ -77,6 +77,7 @@
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
 
 	/* ofw_bus interface */
@@ -184,6 +185,7 @@
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
 
 	{0,0}

==== //depot/projects/ppc-g5/sys/powerpc/powerpc/bus_machdep.c#2 (text+ko) ====

@@ -37,17 +37,28 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/bus_machdep.c,v 1.1 2007/12/19 18:00:50 marcel Exp $");
+__FBSDID("$FreeBSD: head/sys/powerpc/powerpc/bus_machdep.c 174782 2007-12-19 18:00:50Z marcel $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
 
 #include <machine/bus.h>
 #include <machine/pio.h>
+#include <machine/md_var.h>
 
 #define TODO panic("%s: not implemented", __func__)
 
+static struct {
+	bus_addr_t addr;
+	bus_size_t size;
+} earlyboot_mappings[6];
+static int earlyboot_map_idx = 0;
+
+void bs_remap_earlyboot(void);
+
 static __inline void *
 __ppc_ba(bus_space_handle_t bsh, bus_size_t ofs)
 {
@@ -58,10 +69,42 @@
 bs_gen_map(bus_addr_t addr, bus_size_t size __unused, int flags __unused,
     bus_space_handle_t *bshp)
 {
-	*bshp = addr;
+	/*
+	 * Record what we did if we haven't enabled the MMU yet. We
+	 * will need to remap it as soon as the MMU comes up.
+	 */
+	if (!pmap_bootstrapped) {
+		earlyboot_mappings[earlyboot_map_idx].addr = addr;
+		earlyboot_mappings[earlyboot_map_idx].size = size;
+		earlyboot_map_idx++;
+		*bshp = addr;
+	} else {
+		*bshp = (bus_space_handle_t)pmap_mapdev(addr,size);
+	}
+
 	return (0);
 }
 
+void
+bs_remap_earlyboot(void)
+{
+	int i;
+	vm_offset_t pa, spa;
+
+	if (hw_direct_map)
+		return;
+
+	for (i = 0; i < earlyboot_map_idx; i++) {
+		spa = earlyboot_mappings[i].addr;
+
+		pa = trunc_page(spa);
+		while (pa < spa + earlyboot_mappings[i].size) {
+			pmap_kenter(pa,pa);
+			pa += PAGE_SIZE;
+		}
+	}
+}
+
 static void
 bs_gen_unmap(bus_size_t size __unused)
 {


More information about the p4-projects mailing list