Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch add reset method.



details:   https://anonhg.NetBSD.org/src/rev/7caaf16922c7
branches:  trunk
changeset: 522111:7caaf16922c7
user:      uch <uch%NetBSD.org@localhost>
date:      Mon Feb 11 17:13:28 2002 +0000

description:
add reset method.

diffstat:

 sys/arch/hpc/hpc/kloader.c                 |  30 +++++++++++++++++++++++++++---
 sys/arch/hpc/include/kloader.h             |   3 ++-
 sys/arch/hpcmips/hpcmips/kloader_machdep.c |  16 +++++++++++++---
 3 files changed, 42 insertions(+), 7 deletions(-)

diffs (133 lines):

diff -r 1e0f23890b2f -r 7caaf16922c7 sys/arch/hpc/hpc/kloader.c
--- a/sys/arch/hpc/hpc/kloader.c        Mon Feb 11 17:11:48 2002 +0000
+++ b/sys/arch/hpc/hpc/kloader.c        Mon Feb 11 17:13:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kloader.c,v 1.1 2002/01/29 18:44:25 uch Exp $  */
+/*     $NetBSD: kloader.c,v 1.2 2002/02/11 17:13:28 uch Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@
        vaddr_t loader_sp;
        kloader_bootfunc_t *loader;
        int setuped;
+       int called;
 
        struct kloader_ops *ops;
 };
@@ -90,6 +91,7 @@
 void
 __kloader_reboot_setup(struct kloader_ops *ops, const char *filename)
 {
+       static const char fatal_msg[] = "*** FATAL ERROR ***\n";
 
        if (kloader.bootinfo == NULL) {
                PRINTF("No bootinfo.\n");
@@ -102,6 +104,28 @@
        }
        kloader.ops = ops;
 
+       switch (kloader.called++) {
+       case 0:
+               /* normal operation */
+               break;
+       case 1:
+               /* try to reboot anyway. */
+               printf("%s", fatal_msg);
+               kloader.setuped = TRUE;
+               kloader_load ();
+               kloader_reboot();
+               /* NOTREACHED */
+               break;
+       case 2:
+               /* if reboot method exits, reboot. */
+               printf("%s", fatal_msg);
+               /* try to reset */
+               if (kloader.ops->reset != NULL)
+                       (*kloader.ops->reset) ();
+               /* NOTREACHED */
+               break;
+       }
+
        PRINTF("kernel file name: %s\n", filename);
        kloader.vp = kloader_open(filename);
        if (kloader.vp == NULL)
@@ -110,7 +134,7 @@
        if (kloader_load() != 0)
                goto end;
 
-       kloader.setuped = 1;
+       kloader.setuped = TRUE;
 #ifdef KLOADER_DEBUG
        kloader_pagetag_dump();
 #endif
@@ -128,7 +152,7 @@
 #ifdef KLOADER_DEBUG
        kloader_bootinfo_dump();
 #endif
-       PRINTF("Rebooting...\n");
+       printf("Rebooting...\n");
 
        (*kloader.ops->jump) (kloader.loader, kloader.loader_sp,
            kloader.bootinfo, kloader.tagstart);
diff -r 1e0f23890b2f -r 7caaf16922c7 sys/arch/hpc/include/kloader.h
--- a/sys/arch/hpc/include/kloader.h    Mon Feb 11 17:11:48 2002 +0000
+++ b/sys/arch/hpc/include/kloader.h    Mon Feb 11 17:13:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kloader.h,v 1.1 2002/01/29 18:44:26 uch Exp $  */
+/*     $NetBSD: kloader.h,v 1.2 2002/02/11 17:13:28 uch Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -46,6 +46,7 @@
        void (*jump)(kloader_bootfunc_t *, vaddr_t, struct kloader_bootinfo *,
            struct kloader_page_tag *);
        kloader_bootfunc_t *boot;
+       void (*reset)(void);
 };
 
 struct kloader_page_tag {
diff -r 1e0f23890b2f -r 7caaf16922c7 sys/arch/hpcmips/hpcmips/kloader_machdep.c
--- a/sys/arch/hpcmips/hpcmips/kloader_machdep.c        Mon Feb 11 17:11:48 2002 +0000
+++ b/sys/arch/hpcmips/hpcmips/kloader_machdep.c        Mon Feb 11 17:13:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kloader_machdep.c,v 1.1 2002/01/29 18:47:26 uch Exp $  */
+/*     $NetBSD: kloader_machdep.c,v 1.2 2002/02/11 17:13:28 uch Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -35,18 +35,21 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <mips/cache.h>
 
-#include <mips/cache.h>
+#include <machine/sysconf.h>
 #include <machine/kloader.h>
 
 void kloader_mips_jump(kloader_bootfunc_t *, vaddr_t,
     struct kloader_bootinfo *, struct kloader_page_tag *);
+void kloader_mips_reset(void);
 extern kloader_bootfunc_t kloader_vr_boot;
 extern kloader_bootfunc_t kloader_tx_boot;
 
 struct kloader_ops kloader_mips_ops = {
        .jump = kloader_mips_jump,
-       .boot = 0
+       .boot = 0,
+       .reset = kloader_mips_reset
 };
 
 void
@@ -68,3 +71,10 @@
        (*func)(info, tag);     /* 2nd-bootloader don't use stack */
        /* NOTREACHED */
 }
+
+void
+kloader_mips_reset()
+{
+
+       (*platform.reboot)(0, 0);
+}



Home | Main Index | Thread Index | Old Index