Date: Mon, 17 Nov 2008 01:51:53 GMT From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 153064 for review Message-ID: <200811170151.mAH1prIE053328@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=153064 Change 153064 by nwhitehorn@nwhitehorn_trantor on 2008/11/17 01:51:19 Adapt sparc64 to the new pluggable Open Firmware client layer. This involved changes to machdep.c as well as renaming the sparc64 OF entry point from openfirmware to ofw_entry to prevent a naming conflict. This commit also modifies the MI KOBJ routines to provide better support for running very, very early in the boot process. Apparently, sparc64 requires the system to be much further booted than PowerPC to enable mutexes (interrupt handlers and PMAP enabled), which are required by KOBJ. To get there, however, requires Open Firmware, and thus KOBJ. Expand the spirit of the kobj_machdep_init() call by making KOBJ not try to lock or assert its global mutex if it has not been initialized. This early in the boot process, there will be no races, so this should be fine. Tested on: Sun Ultra 5 Affected files ... .. //depot/projects/ppc-g5/sys/conf/files.sparc64#4 edit .. //depot/projects/ppc-g5/sys/dev/ofw/openpromio.c#2 edit .. //depot/projects/ppc-g5/sys/kern/subr_kobj.c#2 edit .. //depot/projects/ppc-g5/sys/sparc64/include/ofw_machdep.h#2 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/machdep.c#3 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/mp_machdep.c#4 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/ofw_machdep.c#3 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/support.S#3 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/trap.c#3 edit .. //depot/projects/ppc-g5/sys/sparc64/sparc64/vm_machdep.c#2 edit Differences ... ==== //depot/projects/ppc-g5/sys/conf/files.sparc64#4 (text+ko) ==== @@ -52,8 +52,10 @@ dev/le/if_le_lebuffer.c optional le sbus dev/le/if_le_ledma.c optional le sbus dev/le/lebuffer_sbus.c optional le sbus +dev/ofw/ofw_if.m standard dev/ofw/ofw_bus_if.m standard dev/ofw/ofw_bus_subr.c standard +dev/ofw/ofw_standard.c standard dev/ofw/ofw_console.c optional ofw_console dev/ofw/openfirm.c standard dev/ofw/openfirmio.c standard ==== //depot/projects/ppc-g5/sys/dev/ofw/openpromio.c#2 (text+ko) ==== @@ -174,7 +174,7 @@ error = OF_getprop(node, prop, buf, proplen); break; case OPROMNXTPROP: - error = OF_nextprop(node, prop, buf); + error = OF_nextprop(node, prop, buf, OPROMMAXPARAM); proplen = strlen(buf); break; } ==== //depot/projects/ppc-g5/sys/kern/subr_kobj.c#2 (text+ko) ==== @@ -60,6 +60,10 @@ static int kobj_mutex_inited; static int kobj_next_id = 1; +#define KOBJ_LOCK() if (kobj_mutex_inited) mtx_lock(&kobj_mtx); +#define KOBJ_UNLOCK() if (kobj_mutex_inited) mtx_unlock(&kobj_mtx); +#define KOBJ_ASSERT(what) if (kobj_mutex_inited) mtx_assert(&kobj_mtx,what); + SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, &kobj_next_id, 0, ""); @@ -99,8 +103,8 @@ static void kobj_register_method(struct kobjop_desc *desc) { + KOBJ_ASSERT(MA_OWNED); - mtx_assert(&kobj_mtx, MA_OWNED); if (desc->id == 0) { desc->id = kobj_next_id++; } @@ -117,7 +121,7 @@ kobj_method_t *m; int i; - mtx_assert(&kobj_mtx, MA_OWNED); + KOBJ_ASSERT(MA_OWNED); /* * Don't do anything if we are already compiled. @@ -145,7 +149,7 @@ { kobj_ops_t ops; - mtx_assert(&kobj_mtx, MA_NOTOWNED); + KOBJ_ASSERT(MA_NOTOWNED); /* * Allocate space for the compiled ops table. @@ -154,7 +158,7 @@ if (!ops) panic("kobj_compile_methods: out of memory"); - mtx_lock(&kobj_mtx); + KOBJ_LOCK(); /* * We may have lost a race for kobj_class_compile here - check @@ -162,28 +166,30 @@ * class. */ if (cls->ops) { - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); free(ops, M_KOBJ); return; } kobj_class_compile_common(cls, ops); - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); } void kobj_class_compile_static(kobj_class_t cls, kobj_ops_t ops) { - mtx_assert(&kobj_mtx, MA_NOTOWNED); + KOBJ_ASSERT(MA_NOTOWNED); /* * Increment refs to make sure that the ops table is not freed. */ - mtx_lock(&kobj_mtx); + KOBJ_LOCK(); + cls->refs++; kobj_class_compile_common(cls, ops); - mtx_unlock(&kobj_mtx); + + KOBJ_UNLOCK(); } static kobj_method_t* @@ -254,8 +260,8 @@ kobj_method_t *m; void* ops = 0; - mtx_assert(&kobj_mtx, MA_NOTOWNED); - mtx_lock(&kobj_mtx); + KOBJ_ASSERT(MA_NOTOWNED); + KOBJ_LOCK(); /* * Protect against a race between kobj_create and @@ -275,7 +281,7 @@ cls->ops = 0; } - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); if (ops) free(ops, M_KOBJ); @@ -302,9 +308,9 @@ void kobj_init(kobj_t obj, kobj_class_t cls) { - mtx_assert(&kobj_mtx, MA_NOTOWNED); + KOBJ_ASSERT(MA_NOTOWNED); retry: - mtx_lock(&kobj_mtx); + KOBJ_LOCK(); /* * Consider compiling the class' method table. @@ -315,7 +321,7 @@ * because of the call to malloc - we drop the lock * and re-try. */ - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); kobj_class_compile(cls); goto retry; } @@ -323,7 +329,7 @@ obj->ops = cls->ops; cls->refs++; - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); } void @@ -337,11 +343,11 @@ * after its last instance is deleted. As an optimisation, we * should defer this for a short while to avoid thrashing. */ - mtx_assert(&kobj_mtx, MA_NOTOWNED); - mtx_lock(&kobj_mtx); + KOBJ_ASSERT(MA_NOTOWNED); + KOBJ_LOCK(); cls->refs--; refs = cls->refs; - mtx_unlock(&kobj_mtx); + KOBJ_UNLOCK(); if (!refs) kobj_class_free(cls); ==== //depot/projects/ppc-g5/sys/sparc64/include/ofw_machdep.h#2 (text+ko) ==== @@ -29,10 +29,15 @@ #define _MACHINE_OFW_MACHDEP_H_ #include <sys/bus.h> +#include <machine/bus.h> +#include <dev/ofw/openfirm.h> + +typedef uint64_t cell_t; int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); void OF_getetheraddr(device_t, u_char *); void cpu_shutdown(void *); -void openfirmware_exit(void *); +int ofw_entry(void *); +void ofw_exit(void *); #endif /* _MACHINE_OFW_MACHDEP_H_ */ ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/machdep.c#3 (text+ko) ==== @@ -275,10 +275,9 @@ */ tick_stop(); - /* - * Initialize Open Firmware (needed for console). - */ - OF_init(vec); + /* Set up Open Firmware entry points */ + ofw_tba = rdpr(tba); + ofw_vec = (u_long)vec; /* * Parse metadata if present and fetch parameters. Must be before the @@ -301,6 +300,14 @@ init_param1(); /* + * Initialize Open Firmware (needed for console). + */ + OF_install(OFW_STD_DIRECT, 0); + OF_init(ofw_entry); + + //OF_printf("Real Open Firmware is working\n"); + + /* * Prime our per-CPU data page for use. Note, we are using it for * our stack, so don't pass the real size (PAGE_SIZE) to pcpu_init * or it'll zero it out from under us. @@ -463,6 +470,7 @@ * Finish pmap initialization now that we're ready for mutexes. */ PMAP_LOCK_INIT(kernel_pmap); + kobj_machdep_init(); OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1); @@ -475,14 +483,6 @@ } void -set_openfirm_callback(ofw_vec_t *vec) -{ - - ofw_tba = rdpr(tba); - ofw_vec = (u_long)vec; -} - -void sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) { struct trapframe *tf; @@ -719,7 +719,7 @@ #ifdef SMP cpu_mp_shutdown(); #endif - openfirmware_exit(args); + ofw_exit(args); } /* Get current clock frequency for the given CPU ID. */ ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/mp_machdep.c#4 (text+ko) ==== @@ -221,7 +221,7 @@ args.cpu = cpu; args.func = (cell_t)func; args.arg = (cell_t)arg; - openfirmware(&args); + ofw_entry(&args); } /* @@ -238,7 +238,7 @@ (cell_t)SUNW_STOPSELF, }; - openfirmware_exit(&args); + ofw_exit(&args); panic("%s: failed.", __func__); } ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/ofw_machdep.c#3 (text+ko) ==== @@ -270,13 +270,3 @@ return (ENXIO); } -/* - * Map a pointer from kernel address space to OFW address space. Since OFW - * lives in the same address space, do nothing. - */ - -cell_t -openfirm_mapptr(const void *arg) -{ - return ((cell_t)arg); -} ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/support.S#3 (text+ko) ==== @@ -749,9 +749,9 @@ END(setjmp) /* - * void openfirmware(cell_t args[]) + * void ofw_entry(cell_t args[]) */ -ENTRY(openfirmware) +ENTRY(ofw_entry) save %sp, -CCFSZ, %sp SET(ofw_vec, %l7, %l6) ldx [%l6], %l6 @@ -762,12 +762,12 @@ wrpr %l7, 0, %pil ret restore %o0, %g0, %o0 -END(openfirmware) +END(ofw_entry) /* - * void openfirmware_exit(cell_t args[]) + * void ofw_exit(cell_t args[]) */ -ENTRY(openfirmware_exit) +ENTRY(ofw_exit) save %sp, -CCFSZ, %sp flushw wrpr %g0, PIL_TICK, %pil @@ -787,7 +787,7 @@ call %l6 mov %i0, %o0 ! never to return -END(openfirmware_exit) +END(ofw_exit) #ifdef GPROF ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/trap.c#3 (text+ko) ==== @@ -71,6 +71,7 @@ #include <security/audit/audit.h> #include <dev/ofw/openfirm.h> +#include <machine/ofw_machdep.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -248,7 +249,7 @@ }; args.tba_addr = (cell_t)tba_addr; - openfirmware(&args); + ofw_entry(&args); } void ==== //depot/projects/ppc-g5/sys/sparc64/sparc64/vm_machdep.c#2 (text+ko) ==== @@ -334,7 +334,7 @@ bspec[sizeof(bspec) - 1] = '\0'; } - openfirmware_exit(&args); + ofw_exit(&args); } /*help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811170151.mAH1prIE053328>
