Home | History | Annotate | Line # | Download | only in ofppc
machdep.c revision 1.96
      1  1.96   garbled /*	$NetBSD: machdep.c,v 1.96 2007/11/04 16:28:28 garbled Exp $	*/
      2  1.96   garbled /*-
      3  1.96   garbled  * Copyright (c) 2007 The NetBSD Foundation, Inc.
      4   1.1        ws  * All rights reserved.
      5   1.1        ws  *
      6  1.96   garbled  * This code is derived from software contributed to The NetBSD Foundation
      7  1.96   garbled  * by Tim Rightnour
      8  1.96   garbled  *
      9   1.1        ws  * Redistribution and use in source and binary forms, with or without
     10   1.1        ws  * modification, are permitted provided that the following conditions
     11   1.1        ws  * are met:
     12   1.1        ws  * 1. Redistributions of source code must retain the above copyright
     13   1.1        ws  *    notice, this list of conditions and the following disclaimer.
     14   1.1        ws  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1        ws  *    notice, this list of conditions and the following disclaimer in the
     16   1.1        ws  *    documentation and/or other materials provided with the distribution.
     17   1.1        ws  * 3. All advertising materials mentioning features or use of this software
     18   1.1        ws  *    must display the following acknowledgement:
     19  1.96   garbled  *        This product includes software developed by the NetBSD
     20  1.96   garbled  *        Foundation, Inc. and its contributors.
     21  1.96   garbled  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  1.96   garbled  *    contributors may be used to endorse or promote products derived
     23  1.96   garbled  *    from this software without specific prior written permission.
     24   1.1        ws  *
     25  1.96   garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  1.96   garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  1.96   garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  1.96   garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  1.96   garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  1.96   garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  1.96   garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  1.96   garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  1.96   garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  1.96   garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  1.96   garbled  * POSSIBILITY OF SUCH DAMAGE.
     36   1.1        ws  */
     37  1.86     lukem 
     38  1.86     lukem #include <sys/cdefs.h>
     39  1.96   garbled __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.96 2007/11/04 16:28:28 garbled Exp $");
     40   1.1        ws 
     41   1.1        ws #include <sys/param.h>
     42   1.1        ws #include <sys/buf.h>
     43  1.93   garbled #include <sys/boot_flag.h>
     44   1.1        ws #include <sys/mount.h>
     45  1.43   thorpej #include <sys/kernel.h>
     46   1.1        ws 
     47  1.19  sakamoto #include <uvm/uvm_extern.h>
     48  1.19  sakamoto 
     49  1.70   thorpej #include <dev/ofw/openfirm.h>
     50  1.93   garbled #include <dev/cons.h>
     51  1.70   thorpej 
     52  1.68      matt #include <machine/autoconf.h>
     53   1.1        ws #include <machine/pmap.h>
     54   1.1        ws #include <machine/powerpc.h>
     55   1.1        ws #include <machine/trap.h>
     56  1.93   garbled #include <machine/bus.h>
     57  1.93   garbled #include <machine/isa_machdep.h>
     58  1.54   thorpej 
     59  1.87      matt #include <powerpc/oea/bat.h>
     60  1.93   garbled #include <powerpc/ofw_cons.h>
     61  1.71   thorpej 
     62  1.93   garbled struct pmap ofw_pmap;
     63  1.78       chs char bootpath[256];
     64   1.1        ws 
     65  1.93   garbled void ofwppc_batinit(void);
     66  1.71   thorpej void	ofppc_bootstrap_console(void);
     67  1.77      matt 
     68   1.1        ws void
     69  1.93   garbled initppc(u_int startkernel, u_int endkernel, char *args)
     70   1.1        ws {
     71  1.93   garbled 	ofwoea_initppc(startkernel, endkernel, args);
     72   1.1        ws }
     73   1.1        ws 
     74   1.1        ws void
     75  1.93   garbled cpu_startup(void)
     76   1.1        ws {
     77  1.82      matt 	oea_startup(NULL);
     78   1.1        ws }
     79   1.1        ws 
     80  1.96   garbled 
     81   1.1        ws void
     82  1.93   garbled consinit(void)
     83   1.1        ws {
     84  1.93   garbled 	ofwoea_consinit();
     85  1.71   thorpej }
     86  1.96   garbled 
     87  1.71   thorpej 
     88  1.71   thorpej void
     89  1.93   garbled dumpsys(void)
     90  1.71   thorpej {
     91  1.93   garbled 	printf("dumpsys: TBD\n");
     92   1.1        ws }
     93   1.1        ws 
     94   1.1        ws /*
     95  1.93   garbled  * Halt or reboot the machine after syncing/dumping according to howto.
     96   1.1        ws  */
     97  1.95   garbled void rtas_reboot(void);
     98   1.1        ws 
     99   1.1        ws void
    100  1.93   garbled cpu_reboot(int howto, char *what)
    101   1.1        ws {
    102   1.1        ws 	static int syncing;
    103   1.1        ws 	static char str[256];
    104   1.1        ws 	char *ap = str, *ap1 = ap;
    105   1.1        ws 
    106   1.1        ws 	boothowto = howto;
    107   1.1        ws 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    108   1.1        ws 		syncing = 1;
    109  1.93   garbled 		vfs_shutdown();         /* sync */
    110  1.93   garbled 		resettodr();            /* set wall clock */
    111   1.1        ws 	}
    112   1.1        ws 	splhigh();
    113   1.1        ws 	if (howto & RB_HALT) {
    114   1.1        ws 		doshutdownhooks();
    115   1.3  christos 		printf("halted\n\n");
    116   1.1        ws 		ppc_exit();
    117   1.1        ws 	}
    118   1.1        ws 	if (!cold && (howto & RB_DUMP))
    119  1.82      matt 		oea_dumpsys();
    120   1.1        ws 	doshutdownhooks();
    121   1.3  christos 	printf("rebooting\n\n");
    122  1.95   garbled 
    123  1.95   garbled 	rtas_reboot();
    124  1.95   garbled 
    125   1.1        ws 	if (what && *what) {
    126   1.1        ws 		if (strlen(what) > sizeof str - 5)
    127   1.3  christos 			printf("boot string too large, ignored\n");
    128   1.1        ws 		else {
    129   1.1        ws 			strcpy(str, what);
    130   1.1        ws 			ap1 = ap = str + strlen(str);
    131   1.1        ws 			*ap++ = ' ';
    132   1.1        ws 		}
    133   1.1        ws 	}
    134   1.1        ws 	*ap++ = '-';
    135   1.1        ws 	if (howto & RB_SINGLE)
    136   1.1        ws 		*ap++ = 's';
    137   1.1        ws 	if (howto & RB_KDB)
    138   1.1        ws 		*ap++ = 'd';
    139   1.1        ws 	*ap++ = 0;
    140   1.1        ws 	if (ap[-2] == '-')
    141   1.1        ws 		*ap1 = 0;
    142   1.1        ws 	ppc_boot(str);
    143   1.1        ws }
    144