Add ddb commands: machine {abort|halt|reboot}
This commit is contained in:
parent
a3df365e06
commit
dd81695cb9
|
@ -1,3 +1,7 @@
|
|||
/* $NetBSD: db_machdep.h,v 1.6 1994/11/21 21:33:34 gwr Exp $ */
|
||||
/* $NetBSD: db_machdep.h,v 1.7 1995/02/07 04:34:45 gwr Exp $ */
|
||||
|
||||
#include <m68k/db_machdep.h>
|
||||
|
||||
/* This enables some code in db_command.c */
|
||||
#define DB_MACHINE_COMMANDS
|
||||
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/* $NetBSD: db_machdep.c,v 1.1 1995/02/07 04:39:39 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Gordon W. Ross
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* 4. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Gordon Ross
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent functions used by ddb
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
#include <ddb/db_command.h>
|
||||
|
||||
#include <machine/pte.h>
|
||||
|
||||
/*
|
||||
* Interface to the debugger for virtual memory read/write.
|
||||
*
|
||||
* To write in the text segment, we have to first make
|
||||
* the page writable, do the write, then restore the PTE.
|
||||
* For writes outside the text segment, and all reads,
|
||||
* just do the access -- if it causes a fault, the debugger
|
||||
* will recover with a longjmp to an appropriate place.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Read bytes from kernel address space for debugger.
|
||||
* This used to check for valid PTEs, but now that
|
||||
* traps in DDB work correctly, "Just Do It!"
|
||||
*/
|
||||
void
|
||||
db_read_bytes(addr, size, data)
|
||||
vm_offset_t addr;
|
||||
register int size;
|
||||
register char *data;
|
||||
{
|
||||
register char *src;
|
||||
|
||||
src = (char *)addr;
|
||||
while (--size >= 0)
|
||||
*data++ = *src++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write one byte somewhere in kernel text.
|
||||
* It does not matter if this is slow. -gwr
|
||||
*/
|
||||
static void
|
||||
db_write_text(dst, ch)
|
||||
char *dst;
|
||||
int ch;
|
||||
{
|
||||
int oldpte, tmppte;
|
||||
vm_offset_t pgva;
|
||||
|
||||
pgva = sun3_trunc_page((long)dst);
|
||||
oldpte = get_pte(pgva);
|
||||
|
||||
if ((oldpte & PG_VALID) == 0) {
|
||||
db_printf(" address 0x%x not a valid page\n", dst);
|
||||
return;
|
||||
}
|
||||
|
||||
tmppte = oldpte | PG_WRITE;
|
||||
set_pte(pgva, tmppte);
|
||||
|
||||
*dst = (char) ch;
|
||||
|
||||
set_pte(pgva, oldpte);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write bytes to kernel address space for debugger.
|
||||
*/
|
||||
void
|
||||
db_write_bytes(addr, size, data)
|
||||
vm_offset_t addr;
|
||||
int size;
|
||||
char *data;
|
||||
{
|
||||
extern char start[], etext[] ;
|
||||
char *dst;
|
||||
|
||||
dst = (char *)addr;
|
||||
while (--size >= 0) {
|
||||
if ((dst >= start) && (dst < etext))
|
||||
db_write_text(dst, *data);
|
||||
else
|
||||
*dst = *data;
|
||||
dst++; data++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Machine-specific ddb commands for the sun3:
|
||||
* abort: Drop into monitor via abort (allows continue)
|
||||
* halt: Exit to monitor as in halt(8)
|
||||
* reboot: Reboot the machine as in reboot(8)
|
||||
*/
|
||||
|
||||
extern void sun3_mon_abort();
|
||||
extern void sun3_mon_halt();
|
||||
|
||||
void
|
||||
db_mon_reboot()
|
||||
{
|
||||
sun3_mon_reboot("");
|
||||
}
|
||||
|
||||
struct db_command db_machine_cmds[] = {
|
||||
{ "abort", sun3_mon_abort, 0, 0 },
|
||||
{ "halt", sun3_mon_halt, 0, 0 },
|
||||
{ "reboot", db_mon_reboot, 0, 0 },
|
||||
{ (char *)0, }
|
||||
};
|
||||
|
||||
/*
|
||||
* This is called before ddb_init() to install the
|
||||
* machine-specific command table. (see machdep.c)
|
||||
*/
|
||||
void
|
||||
db_machine_init()
|
||||
{
|
||||
db_machine_commands_install(db_machine_cmds);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: db_memrw.c,v 1.6 1994/12/12 18:59:58 gwr Exp $ */
|
||||
/* $NetBSD: db_memrw.c,v 1.7 1995/02/07 04:37:48 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
* Copyright (c) 1994, 1995 Gordon W. Ross
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -14,6 +14,9 @@
|
|||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* 4. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Gordon Ross
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
|
@ -28,12 +31,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Interface to the debugger for virtual memory read/write.
|
||||
* To write in the text segment, we have to first make
|
||||
* the page writable, do the write, then restore the PTE.
|
||||
* For writes outside the text segment, and all reads,
|
||||
* just do the access -- if it causes a fault, the debugger
|
||||
* will recover with a longjmp to an appropriate place.
|
||||
* Machine-dependent functions used by ddb
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -42,8 +40,20 @@
|
|||
#include <vm/vm.h>
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
#include <ddb/db_command.h>
|
||||
|
||||
#include <machine/pte.h>
|
||||
|
||||
/*
|
||||
* Interface to the debugger for virtual memory read/write.
|
||||
*
|
||||
* To write in the text segment, we have to first make
|
||||
* the page writable, do the write, then restore the PTE.
|
||||
* For writes outside the text segment, and all reads,
|
||||
* just do the access -- if it causes a fault, the debugger
|
||||
* will recover with a longjmp to an appropriate place.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Read bytes from kernel address space for debugger.
|
||||
* This used to check for valid PTEs, but now that
|
||||
|
@ -111,3 +121,37 @@ db_write_bytes(addr, size, data)
|
|||
dst++; data++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Machine-specific ddb commands for the sun3:
|
||||
* abort: Drop into monitor via abort (allows continue)
|
||||
* halt: Exit to monitor as in halt(8)
|
||||
* reboot: Reboot the machine as in reboot(8)
|
||||
*/
|
||||
|
||||
extern void sun3_mon_abort();
|
||||
extern void sun3_mon_halt();
|
||||
|
||||
void
|
||||
db_mon_reboot()
|
||||
{
|
||||
sun3_mon_reboot("");
|
||||
}
|
||||
|
||||
struct db_command db_machine_cmds[] = {
|
||||
{ "abort", sun3_mon_abort, 0, 0 },
|
||||
{ "halt", sun3_mon_halt, 0, 0 },
|
||||
{ "reboot", db_mon_reboot, 0, 0 },
|
||||
{ (char *)0, }
|
||||
};
|
||||
|
||||
/*
|
||||
* This is called before ddb_init() to install the
|
||||
* machine-specific command table. (see machdep.c)
|
||||
*/
|
||||
void
|
||||
db_machine_init()
|
||||
{
|
||||
db_machine_commands_install(db_machine_cmds);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: locore2.c,v 1.31 1995/01/18 17:22:42 gwr Exp $ */
|
||||
/* $NetBSD: locore2.c,v 1.32 1995/02/07 04:39:42 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
|
@ -142,7 +142,7 @@ static void sun3_mode_normal()
|
|||
* also put our hardware state back into place after
|
||||
* the PROM "c" (continue) command is given.
|
||||
*/
|
||||
void sun3_rom_abort()
|
||||
void sun3_mon_abort()
|
||||
{
|
||||
int s = splhigh();
|
||||
|
||||
|
@ -158,7 +158,7 @@ void sun3_rom_abort()
|
|||
* and then do a trap. Needs PROM vector table in RAM.
|
||||
*/
|
||||
old_vector_table[32] = (int)romp->abortEntry;
|
||||
asm(" trap #0 ; _sun3_rom_continued: nop");
|
||||
asm(" trap #0 ; _sun3_mon_continued: nop");
|
||||
|
||||
/* We have continued from a PROM abort! */
|
||||
|
||||
|
@ -166,7 +166,7 @@ void sun3_rom_abort()
|
|||
splx(s);
|
||||
}
|
||||
|
||||
void sun3_rom_halt()
|
||||
void sun3_mon_halt()
|
||||
{
|
||||
(void) splhigh();
|
||||
sun3_mode_monitor();
|
||||
|
@ -174,7 +174,7 @@ void sun3_rom_halt()
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
void sun3_rom_reboot(bootstring)
|
||||
void sun3_mon_reboot(bootstring)
|
||||
char *bootstring;
|
||||
{
|
||||
(void) splhigh();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machdep.c,v 1.44 1995/01/24 06:18:16 gwr Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.45 1995/02/07 04:39:41 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
|
@ -402,7 +402,8 @@ void consinit()
|
|||
cninit();
|
||||
|
||||
#ifdef DDB
|
||||
/* Well, this is where the hp300 does it... -gwr */
|
||||
/* Now that we have a console, we can stop in DDB. */
|
||||
db_machine_init();
|
||||
ddb_init();
|
||||
if (boothowto & RB_KDB)
|
||||
Debugger();
|
||||
|
@ -1163,7 +1164,7 @@ static int reboot2(howto, user_boot_string)
|
|||
|
||||
if (howto & RB_HALT) {
|
||||
printf("Kernel halted.\n");
|
||||
sun3_rom_halt();
|
||||
sun3_mon_halt();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1193,7 +1194,7 @@ static int reboot2(howto, user_boot_string)
|
|||
}
|
||||
}
|
||||
printf("Kernel rebooting...\n");
|
||||
sun3_rom_reboot(bs);
|
||||
sun3_mon_reboot(bs);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sun3_startup.c,v 1.31 1995/01/18 17:22:42 gwr Exp $ */
|
||||
/* $NetBSD: sun3_startup.c,v 1.32 1995/02/07 04:39:42 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
|
@ -142,7 +142,7 @@ static void sun3_mode_normal()
|
|||
* also put our hardware state back into place after
|
||||
* the PROM "c" (continue) command is given.
|
||||
*/
|
||||
void sun3_rom_abort()
|
||||
void sun3_mon_abort()
|
||||
{
|
||||
int s = splhigh();
|
||||
|
||||
|
@ -158,7 +158,7 @@ void sun3_rom_abort()
|
|||
* and then do a trap. Needs PROM vector table in RAM.
|
||||
*/
|
||||
old_vector_table[32] = (int)romp->abortEntry;
|
||||
asm(" trap #0 ; _sun3_rom_continued: nop");
|
||||
asm(" trap #0 ; _sun3_mon_continued: nop");
|
||||
|
||||
/* We have continued from a PROM abort! */
|
||||
|
||||
|
@ -166,7 +166,7 @@ void sun3_rom_abort()
|
|||
splx(s);
|
||||
}
|
||||
|
||||
void sun3_rom_halt()
|
||||
void sun3_mon_halt()
|
||||
{
|
||||
(void) splhigh();
|
||||
sun3_mode_monitor();
|
||||
|
@ -174,7 +174,7 @@ void sun3_rom_halt()
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
void sun3_rom_reboot(bootstring)
|
||||
void sun3_mon_reboot(bootstring)
|
||||
char *bootstring;
|
||||
{
|
||||
(void) splhigh();
|
||||
|
|
Loading…
Reference in New Issue