diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-03-21 00:36:42 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-03-21 00:36:42 +0000 |
commit | 6da2d78cf989833472f76d53bdf84ef2d7fe5309 (patch) | |
tree | 74bcf91c87c96f0ac0f2e717bc5fddd88e57d74c /sys/arch/m68k | |
parent | a3d48a9639a06570044e4ee27fedc2e9d0c0be08 (diff) |
NetBSD sync to sth like 970218
Diffstat (limited to 'sys/arch/m68k')
-rw-r--r-- | sys/arch/m68k/conf/files.m68k | 5 | ||||
-rw-r--r-- | sys/arch/m68k/include/db_machdep.h | 66 | ||||
-rw-r--r-- | sys/arch/m68k/include/frame.h | 9 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/db_interface.c | 5 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/db_trace.c | 81 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/kgdb_m68k.c | 154 |
6 files changed, 234 insertions, 86 deletions
diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k index 112c229a0eb..553db8960b8 100644 --- a/sys/arch/m68k/conf/files.m68k +++ b/sys/arch/m68k/conf/files.m68k @@ -1,10 +1,11 @@ -# $OpenBSD: files.m68k,v 1.5 1997/02/10 11:11:46 downsj Exp $ -# $NetBSD: files.m68k,v 1.15 1997/02/02 06:55:15 thorpej Exp $ +# $OpenBSD: files.m68k,v 1.6 1997/03/21 00:36:34 niklas Exp $ +# $NetBSD: files.m68k,v 1.16 1997/02/12 01:01:07 gwr Exp $ # file arch/m68k/m68k/db_disasm.c ddb file arch/m68k/m68k/db_interface.c ddb file arch/m68k/m68k/db_trace.c ddb file arch/m68k/m68k/in_cksum.c inet +file arch/m68k/m68k/kgdb_m68k.c kgdb file arch/m68k/m68k/mappedcopy.c mappedcopy file arch/m68k/m68k/ns_cksum.c ns file arch/m68k/m68k/oc_cksum.s inet diff --git a/sys/arch/m68k/include/db_machdep.h b/sys/arch/m68k/include/db_machdep.h index 607f4e7caf7..de2907190e3 100644 --- a/sys/arch/m68k/include/db_machdep.h +++ b/sys/arch/m68k/include/db_machdep.h @@ -1,5 +1,5 @@ -/* $OpenBSD: db_machdep.h,v 1.3 1997/01/19 13:53:09 niklas Exp $ */ -/* $NetBSD: db_machdep.h,v 1.14 1997/01/15 23:11:46 gwr Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.4 1997/03/21 00:36:36 niklas Exp $ */ +/* $NetBSD: db_machdep.h,v 1.19 1997/02/18 22:29:58 gwr Exp $ */ /* * Mach Operating System @@ -33,54 +33,35 @@ #ifndef _M68K_DB_MACHDEP_H_ #define _M68K_DB_MACHDEP_H_ -#include <vm/vm_prot.h> +#include <sys/types.h> + +/* + * XXX - Would rather not pull in vm headers, but need boolean_t, + * at least until boolean_t moves to <sys/types.h> or someplace. + */ #include <vm/vm_param.h> -#include <vm/vm_inherit.h> -#include <vm/lock.h> + +#include <machine/frame.h> #include <machine/psl.h> #include <machine/trap.h> typedef vm_offset_t db_addr_t; /* address - unsigned */ -typedef int db_expr_t; /* expression - signed */ -struct mc68020_saved_state { - int d0; /* data registers */ - int d1; - int d2; - int d3; - int d4; - int d5; - int d6; - int d7; - int a0; /* address registers */ - int a1; - int a2; - int a3; - int a4; - int a5; - int a6; - int sp; /* stack pointer */ - short empty; - short stackadj; - unsigned short sr; /* status register */ - unsigned int pc; /* program counter - UNALIGNED!!! */ - unsigned short stkfmt : 4; /* rte stack frame format */ - unsigned short vector : 12; /* vector number */ -}; -typedef struct mc68020_saved_state db_regs_t; -db_regs_t ddb_regs; /* register state */ +typedef long db_expr_t; /* expression - signed */ +typedef struct trapframe db_regs_t; + +extern db_regs_t ddb_regs; /* register state */ #define DDB_REGS (&ddb_regs) -#define PC_REGS(regs) ((db_addr_t)(regs)->pc) +#define PC_REGS(regs) ((db_addr_t)(regs)->tf_pc) #define BKPT_INST 0x4e4f /* breakpoint instruction */ #define BKPT_SIZE (2) /* size of breakpoint inst */ #define BKPT_SET(inst) (BKPT_INST) -#define FIXUP_PC_AFTER_BREAK ddb_regs.pc -= 2; +#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_pc -= BKPT_SIZE) -#define SR_T1 0x8000 -#define db_clear_single_step(regs) ((regs)->sr &= ~SR_T1) -#define db_set_single_step(regs) ((regs)->sr |= SR_T1) +#define db_clear_single_step(regs) ((regs)->tf_sr &= ~PSL_T) +#define db_set_single_step(regs) ((regs)->tf_sr |= PSL_T) #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) #ifdef T_WATCHPOINT @@ -105,10 +86,19 @@ db_regs_t ddb_regs; /* register state */ #define inst_load(ins) 0 #define inst_store(ins) 0 +/* + * Things needed by kgdb: + */ +typedef long kgdb_reg_t; +#define KGDB_NUMREGS (16+2) +#define KGDB_BUFLEN 512 + + #ifdef _KERNEL +void Debugger __P((void)); /* XXX */ void kdb_kintr __P((db_regs_t *)); -int kdb_trap __P((int, db_regs_t *)); +int kdb_trap __P((int, db_regs_t *)); #endif /* _KERNEL */ diff --git a/sys/arch/m68k/include/frame.h b/sys/arch/m68k/include/frame.h index 56c652b0999..95d3a1ee6cd 100644 --- a/sys/arch/m68k/include/frame.h +++ b/sys/arch/m68k/include/frame.h @@ -1,5 +1,5 @@ -/* $OpenBSD: frame.h,v 1.3 1996/05/29 11:31:24 niklas Exp $ */ -/* $NetBSD: frame.h,v 1.12 1996/05/16 16:51:30 is Exp $ */ +/* $OpenBSD: frame.h,v 1.4 1997/03/21 00:36:37 niklas Exp $ */ +/* $NetBSD: frame.h,v 1.13 1997/01/27 22:58:45 gwr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -43,6 +43,9 @@ * @(#)frame.h 8.1 (Berkeley) 6/10/93 */ +#ifndef _M68K_FRAME_H_ +#define _M68K_FRAME_H_ + struct frame { struct trapframe { int tf_regs[16]; @@ -306,3 +309,5 @@ struct fpframe060 { u_long fpf6_upper, fpf6_lower; }; + +#endif /* _M68K_FRAME_H_ */ diff --git a/sys/arch/m68k/m68k/db_interface.c b/sys/arch/m68k/m68k/db_interface.c index d60392bddd0..cb6cf6b5918 100644 --- a/sys/arch/m68k/m68k/db_interface.c +++ b/sys/arch/m68k/m68k/db_interface.c @@ -1,5 +1,5 @@ -/* $OpenBSD: db_interface.c,v 1.8 1997/01/19 13:53:11 niklas Exp $ */ -/* $NetBSD: db_interface.c,v 1.23 1997/01/15 23:11:47 gwr Exp $ */ +/* $OpenBSD: db_interface.c,v 1.9 1997/03/21 00:36:39 niklas Exp $ */ +/* $NetBSD: db_interface.c,v 1.24 1997/02/18 22:27:32 gwr Exp $ */ /* * Mach Operating System @@ -50,6 +50,7 @@ extern label_t *db_recover; int db_active = 0; +db_regs_t ddb_regs; static void kdbprinttrap __P((int, int)); diff --git a/sys/arch/m68k/m68k/db_trace.c b/sys/arch/m68k/m68k/db_trace.c index 7ede3273c45..75f1e50f49e 100644 --- a/sys/arch/m68k/m68k/db_trace.c +++ b/sys/arch/m68k/m68k/db_trace.c @@ -1,5 +1,5 @@ -/* $OpenBSD: db_trace.c,v 1.7 1997/01/19 13:53:11 niklas Exp $ */ -/* $NetBSD: db_trace.c,v 1.17 1997/01/15 23:11:48 gwr Exp $ */ +/* $OpenBSD: db_trace.c,v 1.8 1997/03/21 00:36:40 niklas Exp $ */ +/* $NetBSD: db_trace.c,v 1.20 1997/02/05 05:10:25 scottr Exp $ */ /* * Mach Operating System @@ -47,24 +47,27 @@ extern label_t *db_recover; static int db_var_short __P((struct db_variable *, db_expr_t *, int)); struct db_variable db_regs[] = { - { "d0", (int *)&ddb_regs.d0, FCN_NULL }, - { "d1", (int *)&ddb_regs.d1, FCN_NULL }, - { "d2", (int *)&ddb_regs.d2, FCN_NULL }, - { "d3", (int *)&ddb_regs.d3, FCN_NULL }, - { "d4", (int *)&ddb_regs.d4, FCN_NULL }, - { "d5", (int *)&ddb_regs.d5, FCN_NULL }, - { "d6", (int *)&ddb_regs.d6, FCN_NULL }, - { "d7", (int *)&ddb_regs.d7, FCN_NULL }, - { "a0", (int *)&ddb_regs.a0, FCN_NULL }, - { "a1", (int *)&ddb_regs.a1, FCN_NULL }, - { "a2", (int *)&ddb_regs.a2, FCN_NULL }, - { "a3", (int *)&ddb_regs.a3, FCN_NULL }, - { "a4", (int *)&ddb_regs.a4, FCN_NULL }, - { "a5", (int *)&ddb_regs.a5, FCN_NULL }, - { "a6", (int *)&ddb_regs.a6, FCN_NULL }, - { "sp", (int *)&ddb_regs.sp, FCN_NULL }, - { "pc", (int *)&ddb_regs.pc, FCN_NULL }, - { "sr", (int *)&ddb_regs.sr, db_var_short } + /* D0-D7 */ + { "d0", (long *)&ddb_regs.tf_regs[0], FCN_NULL }, + { "d1", (long *)&ddb_regs.tf_regs[1], FCN_NULL }, + { "d2", (long *)&ddb_regs.tf_regs[2], FCN_NULL }, + { "d3", (long *)&ddb_regs.tf_regs[3], FCN_NULL }, + { "d4", (long *)&ddb_regs.tf_regs[4], FCN_NULL }, + { "d5", (long *)&ddb_regs.tf_regs[5], FCN_NULL }, + { "d6", (long *)&ddb_regs.tf_regs[6], FCN_NULL }, + { "d7", (long *)&ddb_regs.tf_regs[7], FCN_NULL }, + /* A0-A7 */ + { "a0", (long *)&ddb_regs.tf_regs[8+0], FCN_NULL }, + { "a1", (long *)&ddb_regs.tf_regs[8+1], FCN_NULL }, + { "a2", (long *)&ddb_regs.tf_regs[8+2], FCN_NULL }, + { "a3", (long *)&ddb_regs.tf_regs[8+3], FCN_NULL }, + { "a4", (long *)&ddb_regs.tf_regs[8+4], FCN_NULL }, + { "a5", (long *)&ddb_regs.tf_regs[8+5], FCN_NULL }, + { "a6", (long *)&ddb_regs.tf_regs[8+6], FCN_NULL }, + { "sp", (long *)&ddb_regs.tf_regs[8+7], FCN_NULL }, + /* misc. */ + { "pc", (long *)&ddb_regs.tf_pc, FCN_NULL }, + { "sr", (long *)&ddb_regs.tf_sr, db_var_short } }; struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); @@ -125,23 +128,16 @@ stacktop(regs, sp) register db_regs_t *regs; register struct stackpos *sp; { - sp->k_regloc[0] = (int) ®s->d0; - sp->k_regloc[1] = (int) ®s->d1; - sp->k_regloc[2] = (int) ®s->d2; - sp->k_regloc[3] = (int) ®s->d3; - sp->k_regloc[4] = (int) ®s->d4; - sp->k_regloc[5] = (int) ®s->d5; - sp->k_regloc[6] = (int) ®s->d6; - sp->k_regloc[7] = (int) ®s->d7; - sp->k_regloc[8] = (int) ®s->a0; - sp->k_regloc[9] = (int) ®s->a1; - sp->k_regloc[10] = (int) ®s->a2; - sp->k_regloc[11] = (int) ®s->a3; - sp->k_regloc[12] = (int) ®s->a4; - sp->k_regloc[13] = (int) ®s->a5; - - sp->k_fp = get(®s->a6, 0); - sp->k_pc = get(®s->pc, 0); + int i; + + /* Note: leave out a6, a7 */ + for (i = 0; i < (8+6); i++) { + sp->k_regloc[i] = (int) ®s->tf_regs[i]; + } + + sp->k_fp = get(®s->tf_regs[8+6], 0); + /* skip sp (a7) */ + sp->k_pc = get(®s->tf_pc, 0); sp->k_flags = 0; findentry(sp); @@ -478,7 +474,8 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_expr_t count; char *modif; { - int i, val, nargs; + int i, nargs; + long val; db_addr_t regp; char * name; struct stackpos pos; @@ -509,7 +506,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) t_pcb = (pcb_t) get(&th->pcb, 0); user_regs = (db_regs_t *) - get(&t_pcb->user_regs, 0); + get(&t_pcb->user_regs, 0); stacktop(user_regs, &pos); @@ -544,7 +541,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("%s", name); if (pos.k_entry != MAXINT && name) { char * entry_name; - int e_val; + long e_val; db_find_sym_and_offset(pos.k_entry, &entry_name, &e_val); @@ -557,7 +554,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) regp = pos.k_fp + FR_SAVFP + 4; if ((nargs = pos.k_nargs)) { while (nargs--) { - db_printf("%x", get(regp += 4, DSP)); + db_printf("%lx", get(regp += 4, DSP)); if (nargs) db_printf(","); } @@ -565,7 +562,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) if (val == MAXINT) db_printf(") at %x\n", pos.k_pc); else - db_printf(") + %x\n", val); + db_printf(") + %lx\n", val); /* * Stop tracing if frame ptr no longer points into kernel diff --git a/sys/arch/m68k/m68k/kgdb_m68k.c b/sys/arch/m68k/m68k/kgdb_m68k.c new file mode 100644 index 00000000000..9862bafe783 --- /dev/null +++ b/sys/arch/m68k/m68k/kgdb_m68k.c @@ -0,0 +1,154 @@ +/* $OpenBSD: kgdb_m68k.c,v 1.1 1997/03/21 00:36:41 niklas Exp $ */ +/* $NetBSD: kgdb_m68k.c,v 1.1 1997/02/12 00:58:01 gwr Exp $ */ + +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratories. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94 + */ + +/* + * Machine-dependent (m68k) part of the KGDB remote "stub" + */ + +#include <sys/param.h> +#include <sys/kgdb.h> + +#include <machine/frame.h> +#include <machine/trap.h> + +/* + * Translate a trap number into a unix compatible signal value. + * (gdb only understands unix signal numbers). + */ +int +kgdb_signal(type) + int type; +{ + int sigval; + + switch (type) { + + case T_ASTFLT: + case T_SSIR: + sigval = SIGINT; + break; + + case T_ILLINST: + case T_PRIVINST: + case T_FMTERR: + sigval = SIGILL; + break; + + case T_TRACE: + case T_TRAP15: + sigval = SIGTRAP; + break; + + case T_ZERODIV: + case T_CHKINST: + case T_TRAPVINST: + case T_FPERR: + case T_COPERR: + sigval = SIGFPE; + break; + + case T_BUSERR: + case T_ADDRERR: + sigval = SIGBUS; + break; + + case T_MMUFLT: + sigval = SIGSEGV; + break; + + default: + sigval = SIGEMT; + break; + } + return (sigval); +} + +/* + * Definitions exported from gdb. + */ +/* KGDB_NUMREGS == 18 */ + +#define GDB_SR 16 +#define GDB_PC 17 + + +/* + * Translate the values stored in the kernel regs struct to/from + * the format understood by gdb. + * + * There is a short pad word between SP (A7) and SR which keeps the + * kernel stack long word aligned (note that this is in addition to + * the stack adjust short that we treat as the upper half of the SR + * (always zero). We must skip this when copying to/from gdb regs. + */ + +void +kgdb_getregs(regs, gdb_regs) + db_regs_t *regs; + kgdb_reg_t *gdb_regs; +{ + int i; + + for (i = 0; i < 16; i++) + gdb_regs[i] = regs->tf_regs[i]; + gdb_regs[GDB_SR] = regs->tf_sr; + gdb_regs[GDB_PC] = regs->tf_pc; +} + +void +kgdb_setregs(regs, gdb_regs) + db_regs_t *regs; + kgdb_reg_t *gdb_regs; +{ + int i; + + for (i = 0; i < 16; i++) + regs->tf_regs[i] = gdb_regs[i]; + regs->tf_sr = gdb_regs[GDB_SR] | + (regs->tf_sr & PSL_T); + regs->tf_pc = gdb_regs[GDB_PC]; +} |