Module Name:    src
Committed By:   phx
Date:           Sat Mar 12 16:49:17 UTC 2011

Modified Files:
        src/sys/arch/sandpoint/sandpoint: machdep.c satmgr.c

Log Message:
The DSM-G600's satellite microcontroller provides no possibility to reboot
or powerdown the board, so we can only support reboot by falling back to
a default reboot procedure.
The default procedure will turn off interrupts and the MMU, then jump
through the firmware's reset vector (0xfff00100).


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/sandpoint/satmgr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.54 src/sys/arch/sandpoint/sandpoint/machdep.c:1.55
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.54	Wed Jan 12 07:38:44 2011
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Sat Mar 12 16:49:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.54 2011/01/12 07:38:44 nisimura Exp $	*/
+/*	$NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.54 2011/01/12 07:38:44 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.55 2011/03/12 16:49:16 phx Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -353,7 +353,9 @@
 void
 cpu_reboot(int howto, char *what)
 {
+	extern void jump_to_ppc_reset_entry(void);	/* from locore.S */
 	static int syncing;
+	register_t msr;
 
 	boothowto = howto;
 	if ((howto & RB_NOSYNC) == 0 && syncing == 0) {
@@ -383,11 +385,21 @@
 		howto = RB_AUTOBOOT;
 	}
 
-	if (md_reboot != NULL) {
+	if (md_reboot != NULL)
 		(*md_reboot)(howto);
-		/* should not come here */
-	}
-	while (1) ; /* may practice PPC processor reset sequence here */
+
+	/*
+	 * No reboot method defined. So we disable the MMU and jump
+	 * through the firmware's reset vector.
+	 */
+	msr = mfmsr();
+	msr &= ~PSL_EE;
+	mtmsr(msr);
+	__asm volatile("mtspr %0,%1" : : "K"(81), "r"(0));
+	msr &= ~(PSL_ME | PSL_DR | PSL_IR);
+	mtmsr(msr);
+	jump_to_ppc_reset_entry();
+	for (;;);
 }
 
 #ifdef MODULAR

Index: src/sys/arch/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.5 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.5	Wed Mar  9 20:33:57 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sat Mar 12 16:49:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.5 2011/03/09 20:33:57 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.6 2011/03/12 16:49:16 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -115,11 +115,9 @@
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
-static void dreboot(struct satmgr_softc *);
 static void kpwroff(struct satmgr_softc *);
 static void spwroff(struct satmgr_softc *);
 static void qpwroff(struct satmgr_softc *);
-static void dpwroff(struct satmgr_softc *);
 static void kbutton(struct satmgr_softc *, int);
 static void sbutton(struct satmgr_softc *, int);
 static void qbutton(struct satmgr_softc *, int);
@@ -138,7 +136,7 @@
     { "kurobox",  kreboot, kpwroff, kbutton },
     { "synology", sreboot, spwroff, sbutton },
     { "qnap",     qreboot, qpwroff, qbutton },
-    { "dlink",    dreboot, dpwroff, dbutton }
+    { "dlink",    NULL, NULL, dbutton }
 };
 
 /* single byte stride register layout */
@@ -266,11 +264,16 @@
 satmgr_reboot(int howto)
 {
 	struct satmgr_softc *sc = device_lookup_private(&satmgr_cd, 0);
-	
-	if ((howto & RB_POWERDOWN) == RB_AUTOBOOT)
-		(*sc->sc_ops->reboot)(sc);	/* REBOOT */
-	else
-		(*sc->sc_ops->pwroff)(sc);	/* HALT or POWERDOWN */
+
+	if ((howto & RB_POWERDOWN) == RB_AUTOBOOT) {
+		if (sc->sc_ops->reboot != NULL)
+			(*sc->sc_ops->reboot)(sc);	/* REBOOT */
+		else
+			return;				/* default reboot */
+	} else
+		if (sc->sc_ops->pwroff != NULL)
+			(*sc->sc_ops->pwroff)(sc);	/* HALT or POWERDOWN */
+
 	tsleep(satmgr_reboot, PWAIT, "reboot", 0);
 	/*NOTREACHED*/
 }
@@ -699,20 +702,6 @@
 }
 
 static void
-dreboot(struct satmgr_softc *sc)
-{
-
-	/* XXX cause a machine check exception? */
-}
-
-static void
-dpwroff(struct satmgr_softc *sc)
-{
-
-	/* not possible */
-}
-
-static void
 dbutton(struct satmgr_softc *sc, int ch)
 {
 

Reply via email to