Separate out the stuff used to get in and out of the PROM monitor.
This file can be shared between the sun3 and sun3x.
This commit is contained in:
parent
7878fdb4f2
commit
ad79a66933
317
sys/arch/sun3/sun3/sunmon.c
Normal file
317
sys/arch/sun3/sun3/sunmon.c
Normal file
@ -0,0 +1,317 @@
|
||||
/* $NetBSD: sunmon.c,v 1.1 1997/01/21 00:04:37 gwr Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Adam Glass and Gordon W. Ross.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
#include <machine/mon.h>
|
||||
#include <machine/pte.h>
|
||||
|
||||
#include <sun3/sun3/interreg.h>
|
||||
#include <sun3/sun3/vector.h>
|
||||
|
||||
#include <sun3/sun3/sunmon.h>
|
||||
|
||||
/* XXX - Hmmm... */
|
||||
#ifdef sun3
|
||||
#include <sun3/sun3/machdep.h>
|
||||
#endif
|
||||
#ifdef sun3x
|
||||
#include <sun3x/sun3x/machdep.h>
|
||||
#endif
|
||||
|
||||
static void **sunmon_vbr;
|
||||
|
||||
static void tracedump __P((int));
|
||||
static void v_handler __P((int addr, char *str));
|
||||
|
||||
|
||||
/*
|
||||
* Prepare for running the PROM monitor
|
||||
*/
|
||||
static void
|
||||
_mode_monitor __P((void))
|
||||
{
|
||||
/* Disable our level-5 clock. */
|
||||
set_clk_mode(0, IREG_CLOCK_ENAB_5, 0);
|
||||
/* Restore the PROM vector table */
|
||||
setvbr(sunmon_vbr);
|
||||
/* Enable the PROM NMI clock. */
|
||||
set_clk_mode(IREG_CLOCK_ENAB_7, 0, 1);
|
||||
/* XXX - Disable watchdog action? */
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare for running the kernel
|
||||
*/
|
||||
static void
|
||||
_mode_kernel __P((void))
|
||||
{
|
||||
/* Disable the PROM NMI clock. */
|
||||
set_clk_mode(0, IREG_CLOCK_ENAB_7, 0);
|
||||
/* Restore our own vector table */
|
||||
setvbr(vector_table);
|
||||
/* Enable our level-5 clock. */
|
||||
set_clk_mode(IREG_CLOCK_ENAB_5, 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function takes care of restoring enough of the
|
||||
* hardware state to allow the PROM to run normally.
|
||||
* The PROM needs: NMI enabled, it's own vector table.
|
||||
* In case of a temporary "drop into PROM", this will
|
||||
* also put our hardware state back into place after
|
||||
* the PROM "c" (continue) command is given.
|
||||
*/
|
||||
void sunmon_abort()
|
||||
{
|
||||
int s = splhigh();
|
||||
|
||||
_mode_monitor();
|
||||
mon_printf("kernel stop: enter c to continue or g0 to panic\n");
|
||||
delay(100000);
|
||||
|
||||
/*
|
||||
* Drop into the PROM in a way that allows a continue.
|
||||
* That's what the PROM function (romp->abortEntry) is for,
|
||||
* but that wants to be entered as a trap hander, so just
|
||||
* stuff it into the PROM interrupt vector for trap zero
|
||||
* and then do a trap. Needs PROM vector table in RAM.
|
||||
*/
|
||||
sunmon_vbr[32] = romVectorPtr->abortEntry;
|
||||
asm(" trap #0 ; _sunmon_continued: nop");
|
||||
|
||||
/* We have continued from a PROM abort! */
|
||||
|
||||
_mode_kernel();
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void sunmon_halt()
|
||||
{
|
||||
(void) splhigh();
|
||||
_mode_monitor();
|
||||
#ifdef sun3x
|
||||
loadcrp(&mon_crp);
|
||||
#endif
|
||||
mon_exit_to_mon();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Caller must pass a string that is in our data segment.
|
||||
*/
|
||||
void sunmon_reboot(bs)
|
||||
char *bs;
|
||||
{
|
||||
#ifdef DIAGNOSTIC
|
||||
extern char end[];
|
||||
|
||||
if (bs > end)
|
||||
bs = "?";
|
||||
#endif
|
||||
|
||||
(void) splhigh();
|
||||
_mode_monitor();
|
||||
|
||||
#ifdef sun3x
|
||||
loadcrp(&mon_crp);
|
||||
#endif
|
||||
mon_reboot(bs);
|
||||
mon_exit_to_mon();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print out a traceback for the caller - can be called anywhere
|
||||
* within the kernel or from the monitor by typing "g4" (for sun-2
|
||||
* compatibility) or "w trace". This causes the monitor to call
|
||||
* the v_handler() routine which will call tracedump() for these cases.
|
||||
*/
|
||||
struct funcall_frame {
|
||||
struct funcall_frame *fr_savfp;
|
||||
int fr_savpc;
|
||||
int fr_arg[1];
|
||||
};
|
||||
/*VARARGS0*/
|
||||
static void
|
||||
tracedump(x1)
|
||||
int x1;
|
||||
{
|
||||
struct funcall_frame *fp = (struct funcall_frame *)(&x1 - 2);
|
||||
u_int stackpage = ((u_int)fp) & ~PGOFSET;
|
||||
|
||||
mon_printf("Begin traceback...fp = %x\n", fp);
|
||||
do {
|
||||
if (fp == fp->fr_savfp) {
|
||||
mon_printf("FP loop at %x", fp);
|
||||
break;
|
||||
}
|
||||
mon_printf("Called from %x, fp=%x, args=%x %x %x %x\n",
|
||||
fp->fr_savpc, fp->fr_savfp,
|
||||
fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3]);
|
||||
fp = fp->fr_savfp;
|
||||
} while ( (((u_int)fp) & ~PGOFSET) == stackpage);
|
||||
mon_printf("End traceback...\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for monitor vector cmd -
|
||||
* For now we just implement the old "g0" and "g4"
|
||||
* commands and a printf hack. [lifted from freed cmu mach3 sun3 port]
|
||||
*/
|
||||
static void
|
||||
v_handler(addr, str)
|
||||
int addr;
|
||||
char *str;
|
||||
{
|
||||
|
||||
switch (*str) {
|
||||
case '\0':
|
||||
/*
|
||||
* No (non-hex) letter was specified on
|
||||
* command line, use only the number given
|
||||
*/
|
||||
switch (addr) {
|
||||
case 0: /* old g0 */
|
||||
case 0xd: /* 'd'ump short hand */
|
||||
_mode_kernel();
|
||||
panic("zero");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case 4: /* old g4 */
|
||||
goto do_trace;
|
||||
|
||||
default:
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p': /* 'p'rint string command */
|
||||
case 'P':
|
||||
mon_printf("%s\n", (char *)addr);
|
||||
break;
|
||||
|
||||
case '%': /* p'%'int anything a la printf */
|
||||
mon_printf(str, addr);
|
||||
mon_printf("\n");
|
||||
break;
|
||||
|
||||
do_trace:
|
||||
case 't': /* 't'race kernel stack */
|
||||
case 'T':
|
||||
tracedump(addr);
|
||||
break;
|
||||
|
||||
case 'u': /* d'u'mp hack ('d' look like hex) */
|
||||
case 'U':
|
||||
goto err;
|
||||
break;
|
||||
|
||||
default:
|
||||
err:
|
||||
mon_printf("Don't understand 0x%x '%s'\n", addr, str);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the PROM vector handler (for g0, g4, etc.)
|
||||
* and set boothowto from the PROM arg strings.
|
||||
*
|
||||
* Note, args are always:
|
||||
* argv[0] = boot_device (i.e. "sd(0,0,0)")
|
||||
* argv[1] = options (i.e. "-ds" or NULL)
|
||||
* argv[2] = NULL
|
||||
*/
|
||||
void
|
||||
sunmon_init()
|
||||
{
|
||||
MachMonRomVector *rvec;
|
||||
MachMonBootParam *bpp;
|
||||
char **argp;
|
||||
char *p;
|
||||
|
||||
/* Save the PROM monitor Vector Base Register (VBR). */
|
||||
sunmon_vbr = getvbr();
|
||||
|
||||
rvec = romVectorPtr;
|
||||
if (rvec->romvecVersion >= 2)
|
||||
*rvec->vector_cmd = v_handler;
|
||||
|
||||
/* Set boothowto flags from PROM args. */
|
||||
bpp = *rvec->bootParam;
|
||||
argp = bpp->argPtr;
|
||||
|
||||
/* Skip argp[0] (the device string) */
|
||||
argp++;
|
||||
|
||||
/* Have options? */
|
||||
if (*argp == NULL)
|
||||
return;
|
||||
p = *argp;
|
||||
if (*p == '-') {
|
||||
/* yes, parse options */
|
||||
#ifdef DEBUG
|
||||
mon_printf("boot option: %s\n", p);
|
||||
#endif
|
||||
for (++p; *p; p++) {
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
boothowto |= RB_ASKNAME;
|
||||
break;
|
||||
case 's':
|
||||
boothowto |= RB_SINGLE;
|
||||
break;
|
||||
case 'd':
|
||||
boothowto |= RB_KDB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
argp++;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Have init name? */
|
||||
if (*argp == NULL)
|
||||
return;
|
||||
p = *argp;
|
||||
mon_printf("boot initpath: %s\n", p);
|
||||
#endif
|
||||
}
|
44
sys/arch/sun3/sun3/sunmon.h
Normal file
44
sys/arch/sun3/sun3/sunmon.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* $NetBSD: sunmon.h,v 1.1 1997/01/21 00:04:38 gwr Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Adam Glass and Gordon W. Ross.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
void sunmon_init __P((void));
|
||||
|
||||
void sunmon_abort __P((void));
|
||||
void sunmon_halt __P((void));
|
||||
void sunmon_reboot __P((char *));
|
||||
|
Loading…
Reference in New Issue
Block a user