add reset method.

This commit is contained in:
uch 2002-02-11 17:13:28 +00:00
parent f8bc44a14f
commit 3cde195353
3 changed files with 42 additions and 7 deletions

View File

@ -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 @@ struct kloader {
vaddr_t loader_sp;
kloader_bootfunc_t *loader;
int setuped;
int called;
struct kloader_ops *ops;
};
@ -90,6 +91,7 @@ STATIC void kloader_bootinfo_dump(void);
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_reboot_setup(struct kloader_ops *ops, const char *filename)
}
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 @@ __kloader_reboot_setup(struct kloader_ops *ops, const char *filename)
if (kloader_load() != 0)
goto end;
kloader.setuped = 1;
kloader.setuped = TRUE;
#ifdef KLOADER_DEBUG
kloader_pagetag_dump();
#endif
@ -128,7 +152,7 @@ kloader_reboot()
#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);

View File

@ -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 @@ struct kloader_ops {
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 {

View File

@ -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 <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 @@ kloader_mips_jump(kloader_bootfunc_t func, vaddr_t sp,
(*func)(info, tag); /* 2nd-bootloader don't use stack */
/* NOTREACHED */
}
void
kloader_mips_reset()
{
(*platform.reboot)(0, 0);
}