diff options
| author | rin <rin@NetBSD.org> | 2021-03-30 01:33:50 +0000 |
|---|---|---|
| committer | rin <rin@NetBSD.org> | 2021-03-30 01:33:50 +0000 |
| commit | ef377d64293f64273bad03665e26b9d298df17fe (patch) | |
| tree | db84dda24161fc48f94d280dbe4fa2cfb2397c4c /sys/arch | |
| parent | 4a922844f4ccb003b1314bff78d6d8127b09090a (diff) | |
Centralize cpu_reboot().
Diffstat (limited to 'sys/arch')
| -rw-r--r-- | sys/arch/evbppc/explora/machdep.c | 48 | ||||
| -rw-r--r-- | sys/arch/evbppc/obs405/obs200_machdep.c | 90 | ||||
| -rw-r--r-- | sys/arch/evbppc/obs405/obs266_machdep.c | 90 | ||||
| -rw-r--r-- | sys/arch/evbppc/obs405/obs600_machdep.c | 90 | ||||
| -rw-r--r-- | sys/arch/evbppc/virtex/machdep.c | 99 | ||||
| -rw-r--r-- | sys/arch/evbppc/walnut/machdep.c | 91 | ||||
| -rw-r--r-- | sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c | 83 |
7 files changed, 93 insertions, 498 deletions
diff --git a/sys/arch/evbppc/explora/machdep.c b/sys/arch/evbppc/explora/machdep.c index ed4313384ef..1ab508a6350 100644 --- a/sys/arch/evbppc/explora/machdep.c +++ b/sys/arch/evbppc/explora/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.46 2021/03/07 09:43:56 rin Exp $ */ +/* $NetBSD: machdep.c,v 1.47 2021/03/30 01:33:50 rin Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.46 2021/03/07 09:43:56 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.47 2021/03/30 01:33:50 rin Exp $"); #include "opt_explora.h" #include "opt_modular.h" @@ -178,47 +178,3 @@ cpu_startup(void) */ fake_mapiodev = 0; } - -void -cpu_reboot(int howto, char *what) -{ - static int syncing = 0; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); - resettodr(); - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - /*XXX dumpsys()*/; - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if (howto & RB_HALT) { - printf("halted\n\n"); - - while (1) - ; - } - - printf("rebooting\n\n"); - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - - ppc4xx_reset(); - -#ifdef DDB - while (1) - Debugger(); -#else - while (1) - ; -#endif -} diff --git a/sys/arch/evbppc/obs405/obs200_machdep.c b/sys/arch/evbppc/obs405/obs200_machdep.c index 82d49806eef..793549d9647 100644 --- a/sys/arch/evbppc/obs405/obs200_machdep.c +++ b/sys/arch/evbppc/obs405/obs200_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: obs200_machdep.c,v 1.21 2021/03/30 01:16:45 rin Exp $ */ +/* $NetBSD: obs200_machdep.c,v 1.22 2021/03/30 01:33:50 rin Exp $ */ /* Original: machdep.c,v 1.3 2005/01/17 17:24:09 shige Exp */ /* @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obs200_machdep.c,v 1.21 2021/03/30 01:16:45 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obs200_machdep.c,v 1.22 2021/03/30 01:33:50 rin Exp $"); #include "opt_compat_netbsd.h" #include "opt_ddb.h" @@ -122,11 +122,6 @@ __KERNEL_RCSID(0, "$NetBSD: obs200_machdep.c,v 1.21 2021/03/30 01:16:45 rin Exp #define TLB_PG_SIZE (16*1024*1024) -/* - * Global variables used here and there - */ -extern paddr_t msgbuf_paddr; - void initppc(vaddr_t, vaddr_t, char *, void *); void @@ -212,87 +207,6 @@ cpu_startup(void) fake_mapiodev = 0; } -/* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -cpu_reboot(int howto, char *what) -{ - static int syncing; - static char str[256]; - char *ap = str, *ap1 = ap; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); /* sync */ - resettodr(); /* set wall clock */ - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - ibm4xx_dumpsys(); - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { - /* Power off here if we know how...*/ - } - - if (howto & RB_HALT) { - printf("halted\n\n"); - -#if 0 - goto reboot; /* XXX for now... */ -#endif - -#ifdef DDB - printf("dropping to debugger\n"); - while(1) - Debugger(); -#endif - } - - printf("rebooting\n\n"); - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - -#if 0 - reboot: -#endif - ppc4xx_reset(); - - printf("ppc4xx_reset() failed!\n"); -#ifdef DDB - while(1) - Debugger(); -#else - while (1) - /* nothing */; -#endif -} - int ibm4xx_pci_bus_maxdevs(void *v, int busno) { diff --git a/sys/arch/evbppc/obs405/obs266_machdep.c b/sys/arch/evbppc/obs405/obs266_machdep.c index 1aed1045b1b..91e1f6283d5 100644 --- a/sys/arch/evbppc/obs405/obs266_machdep.c +++ b/sys/arch/evbppc/obs405/obs266_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: obs266_machdep.c,v 1.22 2021/03/30 01:16:45 rin Exp $ */ +/* $NetBSD: obs266_machdep.c,v 1.23 2021/03/30 01:33:50 rin Exp $ */ /* Original: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $ */ /* @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obs266_machdep.c,v 1.22 2021/03/30 01:16:45 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obs266_machdep.c,v 1.23 2021/03/30 01:33:50 rin Exp $"); #include "opt_compat_netbsd.h" #include "opt_ddb.h" @@ -122,11 +122,6 @@ __KERNEL_RCSID(0, "$NetBSD: obs266_machdep.c,v 1.22 2021/03/30 01:16:45 rin Exp #define TLB_PG_SIZE (16*1024*1024) -/* - * Global variables used here and there - */ -extern paddr_t msgbuf_paddr; - void initppc(vaddr_t, vaddr_t, char *, void *); void @@ -203,87 +198,6 @@ cpu_startup(void) fake_mapiodev = 0; } -/* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -cpu_reboot(int howto, char *what) -{ - static int syncing; - static char str[256]; - char *ap = str, *ap1 = ap; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); /* sync */ - resettodr(); /* set wall clock */ - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - ibm4xx_dumpsys(); - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { - /* Power off here if we know how...*/ - } - - if (howto & RB_HALT) { - printf("halted\n\n"); - -#if 0 - goto reboot; /* XXX for now... */ -#endif - -#ifdef DDB - printf("dropping to debugger\n"); - while(1) - Debugger(); -#endif - } - - printf("rebooting\n\n"); - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - -#if 0 - reboot: -#endif - ppc4xx_reset(); - - printf("ppc4xx_reset() failed!\n"); -#ifdef DDB - while(1) - Debugger(); -#else - while (1) - /* nothing */; -#endif -} - int ibm4xx_pci_bus_maxdevs(void *v, int busno) { diff --git a/sys/arch/evbppc/obs405/obs600_machdep.c b/sys/arch/evbppc/obs405/obs600_machdep.c index 4aa5a01ece1..469030a1e60 100644 --- a/sys/arch/evbppc/obs405/obs600_machdep.c +++ b/sys/arch/evbppc/obs405/obs600_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: obs600_machdep.c,v 1.13 2021/03/30 01:16:45 rin Exp $ */ +/* $NetBSD: obs600_machdep.c,v 1.14 2021/03/30 01:33:50 rin Exp $ */ /* Original: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $ */ /* @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obs600_machdep.c,v 1.13 2021/03/30 01:16:45 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obs600_machdep.c,v 1.14 2021/03/30 01:33:50 rin Exp $"); #include "opt_compat_netbsd.h" #include "opt_ddb.h" @@ -130,11 +130,6 @@ __KERNEL_RCSID(0, "$NetBSD: obs600_machdep.c,v 1.13 2021/03/30 01:16:45 rin Exp #define TLB_PG_SIZE (16 * 1024 * 1024) -/* - * Global variables used here and there - */ -extern paddr_t msgbuf_paddr; - void initppc(vaddr_t, vaddr_t, int, char *[], char *); static int read_eeprom(int, char *); @@ -264,87 +259,6 @@ cpu_startup(void) } /* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -cpu_reboot(int howto, char *what) -{ - static int syncing; - static char str[256]; - char *ap = str, *ap1 = ap; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); /* sync */ - resettodr(); /* set wall clock */ - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - ibm4xx_dumpsys(); - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { - /* Power off here if we know how...*/ - } - - if (howto & RB_HALT) { - printf("halted\n\n"); - -#if 0 - goto reboot; /* XXX for now... */ -#endif - -#ifdef DDB - printf("dropping to debugger\n"); - while(1) - Debugger(); -#endif - } - - printf("rebooting\n\n"); - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - -#if 0 - reboot: -#endif - ppc4xx_reset(); - - printf("ppc4xx_reset() failed!\n"); -#ifdef DDB - while(1) - Debugger(); -#else - while (1) - /* nothing */; -#endif -} - -/* * Read EEPROM via I2C. We don't use bus_space(9) here. This is MD-part and, * don't support bus_space_unmap() to a space on reserved space? X-< * diff --git a/sys/arch/evbppc/virtex/machdep.c b/sys/arch/evbppc/virtex/machdep.c index d0f74f53271..029728633c7 100644 --- a/sys/arch/evbppc/virtex/machdep.c +++ b/sys/arch/evbppc/virtex/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.27 2021/03/30 01:16:45 rin Exp $ */ +/* $NetBSD: machdep.c,v 1.28 2021/03/30 01:33:50 rin Exp $ */ /* * Copyright (c) 2006 Jachym Holecek @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.27 2021/03/30 01:16:45 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28 2021/03/30 01:33:50 rin Exp $"); #include "opt_compat_netbsd.h" #include "opt_ddb.h" @@ -101,8 +101,6 @@ char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ void initppc(vaddr_t, vaddr_t); -static void dumpsys(void); - /* BSS segment start & end. */ extern char edata[], end[]; @@ -227,13 +225,6 @@ cpu_startup(void) fake_mapiodev = 0; } - -static void -dumpsys(void) -{ - printf("dumpsys: TBD\n"); -} - /* Hook used by 405 pmap module. */ void mem_regions(struct mem_region **mem, struct mem_region **avail) @@ -241,89 +232,3 @@ mem_regions(struct mem_region **mem, struct mem_region **avail) *mem = physmemr; *avail = availmemr; } - -/* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -cpu_reboot(int howto, char *what) -{ - static int syncing; - static char str[256]; - char *ap = str, *ap1 = ap; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); /* sync */ - resettodr(); /* set wall clock */ - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - dumpsys(); - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { - /* Power off here if we know how...*/ - } - - if (howto & RB_HALT) { - printf("halted\n\n"); - - goto reboot; /* XXX for now... */ - -#ifdef DDB - printf("dropping to debugger\n"); - while(1) - Debugger(); -#endif -#ifdef KGDB - printf("dropping to kgdb\n"); - while(1) - kgdb_connect(1); -#endif - } - - printf("rebooting\n\n"); - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - - reboot: - ppc4xx_reset(); - - printf("ppc4xx_reset() failed!\n"); -#ifdef DDB - while(1) - Debugger(); -#endif -#ifdef KGDB - while(1) - kgdb_connect(1); -#else - while (1) - /* nothing */; -#endif -} diff --git a/sys/arch/evbppc/walnut/machdep.c b/sys/arch/evbppc/walnut/machdep.c index 28ae0387c6b..b46d9b05389 100644 --- a/sys/arch/evbppc/walnut/machdep.c +++ b/sys/arch/evbppc/walnut/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.63 2021/03/30 01:16:45 rin Exp $ */ +/* $NetBSD: machdep.c,v 1.64 2021/03/30 01:33:50 rin Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.63 2021/03/30 01:16:45 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.64 2021/03/30 01:33:50 rin Exp $"); #include "opt_compat_netbsd.h" #include "opt_ddb.h" @@ -139,8 +139,6 @@ char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ void initppc(vaddr_t, vaddr_t, char *, void *); -static void dumpsys(void); - struct board_cfg_data board_data; void @@ -250,91 +248,6 @@ cpu_startup(void) fake_mapiodev = 0; } - -static void -dumpsys(void) -{ - - printf("dumpsys: TBD\n"); -} - -/* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -cpu_reboot(int howto, char *what) -{ - static int syncing; - static char str[256]; - char *ap = str, *ap1 = ap; - - boothowto = howto; - if (!cold && !(howto & RB_NOSYNC) && !syncing) { - syncing = 1; - vfs_shutdown(); /* sync */ - resettodr(); /* set wall clock */ - } - - splhigh(); - - if (!cold && (howto & RB_DUMP)) - dumpsys(); - - doshutdownhooks(); - - pmf_system_shutdown(boothowto); - - if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { - /* Power off here if we know how...*/ - } - - if (howto & RB_HALT) { - printf("halted\n\n"); - - goto reboot; /* XXX for now... */ - -#ifdef DDB - printf("dropping to debugger\n"); - while(1) - Debugger(); -#endif - } - - printf("rebooting\n\n"); - if (what && *what) { - if (strlen(what) > sizeof str - 5) - printf("boot string too large, ignored\n"); - else { - strcpy(str, what); - ap1 = ap = str + strlen(str); - *ap++ = ' '; - } - } - *ap++ = '-'; - if (howto & RB_SINGLE) - *ap++ = 's'; - if (howto & RB_KDB) - *ap++ = 'd'; - *ap++ = 0; - if (ap[-2] == '-') - *ap1 = 0; - - /* flush cache for msgbuf */ - __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); - - reboot: - ppc4xx_reset(); - - printf("ppc4xx_reset() failed!\n"); -#ifdef DDB - while(1) - Debugger(); -#else - while (1) - /* nothing */; -#endif -} - int ibm4xx_pci_bus_maxdevs(void *v, int busno) { diff --git a/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c b/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c index f8a78fe1dd9..fdef9044143 100644 --- a/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c +++ b/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibm4xx_machdep.c,v 1.35 2021/03/06 08:08:19 rin Exp $ */ +/* $NetBSD: ibm4xx_machdep.c,v 1.36 2021/03/30 01:33:50 rin Exp $ */ /* Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */ /* @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.35 2021/03/06 08:08:19 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.36 2021/03/30 01:33:50 rin Exp $"); #include "ksyms.h" @@ -81,8 +81,14 @@ __KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.35 2021/03/06 08:08:19 rin Exp #include <sys/param.h> #include <sys/cpu.h> #include <sys/ksyms.h> +#include <sys/mount.h> #include <sys/msgbuf.h> +#include <sys/pmf.h> #include <sys/proc.h> +#include <sys/reboot.h> +#include <sys/systm.h> + +#include <dev/cons.h> #include <uvm/uvm_extern.h> @@ -153,6 +159,79 @@ static const struct exc_info trap_table[] = { #endif }; +void +cpu_reboot(int howto, char *what) +{ + static int syncing; + static char str[256]; + char *ap = str, *ap1 = ap; + + boothowto = howto; + if (!cold && !(howto & RB_NOSYNC) && !syncing) { + syncing = 1; + vfs_shutdown(); /* sync */ + resettodr(); /* set wall clock */ + } + + splhigh(); + + if (!cold && (howto & RB_DUMP)) + ibm4xx_dumpsys(); + + doshutdownhooks(); + + pmf_system_shutdown(boothowto); + + if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { + /* Power off here if we know how... */ + } + + if (howto & RB_HALT) { + printf("The operating system has halted.\n" + "Press any key to reboot.\n\n"); + + cnpollc(1); + cngetc(); + cnpollc(0); + } + + printf("rebooting...\n\n"); + if (what && *what) { + if (strlen(what) > sizeof(str) - 5) + printf("boot string too large, ignored\n"); + else { + strcpy(str, what); + ap1 = ap = str + strlen(str); + *ap++ = ' '; + } + } + *ap++ = '-'; + if (howto & RB_SINGLE) + *ap++ = 's'; + if (howto & RB_KDB) + *ap++ = 'd'; + *ap++ = '\0'; + if (ap[-2] == '-') + *ap1 = '\0'; + + /* flush cache for msgbuf */ + __syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE)); + + ppc4xx_reset(); + + printf("ppc4xx_reset() failed!\n"); + + while (1 /* CONSTCOND */) { +#if defined(DDB) + Debugger(); +#elif defined(KGDB) + kgdb_connect(1); +#else + continue; +#endif + } +} + /* * Install a trap vector. We cannot use memcpy because the * destination may be zero. |
