Home | History | Annotate | Line # | Download | only in arm32
db_machdep.c revision 1.12.12.1
      1  1.12.12.1   yamt /*	$NetBSD: db_machdep.c,v 1.12.12.1 2012/04/17 00:06:04 yamt Exp $	*/
      2        1.1   matt 
      3        1.1   matt /*
      4        1.1   matt  * Copyright (c) 1996 Mark Brinicombe
      5        1.1   matt  *
      6        1.1   matt  * Mach Operating System
      7        1.1   matt  * Copyright (c) 1991,1990 Carnegie Mellon University
      8        1.1   matt  * All Rights Reserved.
      9        1.1   matt  *
     10        1.1   matt  * Permission to use, copy, modify and distribute this software and its
     11        1.1   matt  * documentation is hereby granted, provided that both the copyright
     12        1.1   matt  * notice and this permission notice appear in all copies of the
     13        1.1   matt  * software, derivative works or modified versions, and any portions
     14        1.1   matt  * thereof, and that both notices appear in supporting documentation.
     15        1.1   matt  *
     16        1.1   matt  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     17        1.1   matt  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     18        1.1   matt  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     19        1.1   matt  *
     20        1.1   matt  * Carnegie Mellon requests users of this software to return to
     21        1.1   matt  *
     22        1.1   matt  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     23        1.1   matt  *  School of Computer Science
     24        1.1   matt  *  Carnegie Mellon University
     25        1.1   matt  *  Pittsburgh PA 15213-3890
     26        1.1   matt  *
     27        1.1   matt  * any improvements or extensions that they make and grant Carnegie the
     28        1.1   matt  * rights to redistribute these changes.
     29        1.1   matt  */
     30        1.8  lukem 
     31        1.8  lukem #include <sys/cdefs.h>
     32  1.12.12.1   yamt __KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12.12.1 2012/04/17 00:06:04 yamt Exp $");
     33        1.1   matt 
     34        1.1   matt #include <sys/param.h>
     35        1.1   matt #include <sys/proc.h>
     36        1.1   matt #include <sys/vnode.h>
     37        1.1   matt #include <sys/systm.h>
     38        1.1   matt 
     39        1.7  chris #include <arm/arm32/db_machdep.h>
     40  1.12.12.1   yamt #include <arm/cpufunc.h>
     41        1.1   matt 
     42        1.1   matt #include <ddb/db_access.h>
     43        1.1   matt #include <ddb/db_sym.h>
     44        1.1   matt #include <ddb/db_output.h>
     45  1.12.12.1   yamt #include <ddb/db_variables.h>
     46  1.12.12.1   yamt #include <ddb/db_command.h>
     47        1.1   matt 
     48  1.12.12.1   yamt static long nil;
     49        1.1   matt 
     50  1.12.12.1   yamt int db_access_und_sp(const struct db_variable *, db_expr_t *, int);
     51  1.12.12.1   yamt int db_access_abt_sp(const struct db_variable *, db_expr_t *, int);
     52  1.12.12.1   yamt int db_access_irq_sp(const struct db_variable *, db_expr_t *, int);
     53  1.12.12.1   yamt 
     54  1.12.12.1   yamt const struct db_variable db_regs[] = {
     55  1.12.12.1   yamt 	{ "spsr", (long *)&DDB_REGS->tf_spsr, FCN_NULL, NULL },
     56  1.12.12.1   yamt 	{ "r0", (long *)&DDB_REGS->tf_r0, FCN_NULL, NULL },
     57  1.12.12.1   yamt 	{ "r1", (long *)&DDB_REGS->tf_r1, FCN_NULL, NULL },
     58  1.12.12.1   yamt 	{ "r2", (long *)&DDB_REGS->tf_r2, FCN_NULL, NULL },
     59  1.12.12.1   yamt 	{ "r3", (long *)&DDB_REGS->tf_r3, FCN_NULL, NULL },
     60  1.12.12.1   yamt 	{ "r4", (long *)&DDB_REGS->tf_r4, FCN_NULL, NULL },
     61  1.12.12.1   yamt 	{ "r5", (long *)&DDB_REGS->tf_r5, FCN_NULL, NULL },
     62  1.12.12.1   yamt 	{ "r6", (long *)&DDB_REGS->tf_r6, FCN_NULL, NULL },
     63  1.12.12.1   yamt 	{ "r7", (long *)&DDB_REGS->tf_r7, FCN_NULL, NULL },
     64  1.12.12.1   yamt 	{ "r8", (long *)&DDB_REGS->tf_r8, FCN_NULL, NULL },
     65  1.12.12.1   yamt 	{ "r9", (long *)&DDB_REGS->tf_r9, FCN_NULL, NULL },
     66  1.12.12.1   yamt 	{ "r10", (long *)&DDB_REGS->tf_r10, FCN_NULL, NULL },
     67  1.12.12.1   yamt 	{ "r11", (long *)&DDB_REGS->tf_r11, FCN_NULL, NULL },
     68  1.12.12.1   yamt 	{ "r12", (long *)&DDB_REGS->tf_r12, FCN_NULL, NULL },
     69  1.12.12.1   yamt 	{ "usr_sp", (long *)&DDB_REGS->tf_usr_sp, FCN_NULL, NULL },
     70  1.12.12.1   yamt 	{ "usr_lr", (long *)&DDB_REGS->tf_usr_lr, FCN_NULL, NULL },
     71  1.12.12.1   yamt 	{ "svc_sp", (long *)&DDB_REGS->tf_svc_sp, FCN_NULL, NULL },
     72  1.12.12.1   yamt 	{ "svc_lr", (long *)&DDB_REGS->tf_svc_lr, FCN_NULL, NULL },
     73  1.12.12.1   yamt 	{ "pc", (long *)&DDB_REGS->tf_pc, FCN_NULL, NULL },
     74  1.12.12.1   yamt 	{ "und_sp", &nil, db_access_und_sp, NULL },
     75  1.12.12.1   yamt 	{ "abt_sp", &nil, db_access_abt_sp, NULL },
     76  1.12.12.1   yamt 	{ "irq_sp", &nil, db_access_irq_sp, NULL },
     77  1.12.12.1   yamt };
     78  1.12.12.1   yamt 
     79  1.12.12.1   yamt const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
     80  1.12.12.1   yamt 
     81  1.12.12.1   yamt const struct db_command db_machine_command_table[] = {
     82  1.12.12.1   yamt 	{ DDB_ADD_CMD("frame",	db_show_frame_cmd,	0,
     83  1.12.12.1   yamt 			"Displays the contents of a trapframe",
     84  1.12.12.1   yamt 			"[address]",
     85  1.12.12.1   yamt 			"   address:\taddress of trapfame to display")},
     86  1.12.12.1   yamt #ifdef _KERNEL
     87  1.12.12.1   yamt 	{ DDB_ADD_CMD("panic",	db_show_panic_cmd,	0,
     88  1.12.12.1   yamt 			"Displays the last panic string",
     89  1.12.12.1   yamt 		     	NULL,NULL) },
     90  1.12.12.1   yamt #endif
     91  1.12.12.1   yamt #ifdef ARM32_DB_COMMANDS
     92  1.12.12.1   yamt 	ARM32_DB_COMMANDS,
     93  1.12.12.1   yamt #endif
     94  1.12.12.1   yamt 	{ DDB_ADD_CMD(NULL,     NULL,           0,NULL,NULL,NULL) }
     95  1.12.12.1   yamt };
     96  1.12.12.1   yamt 
     97  1.12.12.1   yamt int
     98  1.12.12.1   yamt db_access_und_sp(const struct db_variable *vp, db_expr_t *valp, int rw)
     99  1.12.12.1   yamt {
    100  1.12.12.1   yamt 
    101  1.12.12.1   yamt 	if (rw == DB_VAR_GET)
    102  1.12.12.1   yamt 		*valp = get_stackptr(PSR_UND32_MODE);
    103  1.12.12.1   yamt 	return(0);
    104  1.12.12.1   yamt }
    105  1.12.12.1   yamt 
    106  1.12.12.1   yamt int
    107  1.12.12.1   yamt db_access_abt_sp(const struct db_variable *vp, db_expr_t *valp, int rw)
    108  1.12.12.1   yamt {
    109  1.12.12.1   yamt 
    110  1.12.12.1   yamt 	if (rw == DB_VAR_GET)
    111  1.12.12.1   yamt 		*valp = get_stackptr(PSR_ABT32_MODE);
    112  1.12.12.1   yamt 	return(0);
    113  1.12.12.1   yamt }
    114  1.12.12.1   yamt 
    115  1.12.12.1   yamt int
    116  1.12.12.1   yamt db_access_irq_sp(const struct db_variable *vp, db_expr_t *valp, int rw)
    117  1.12.12.1   yamt {
    118  1.12.12.1   yamt 
    119  1.12.12.1   yamt 	if (rw == DB_VAR_GET)
    120  1.12.12.1   yamt 		*valp = get_stackptr(PSR_IRQ32_MODE);
    121  1.12.12.1   yamt 	return(0);
    122  1.12.12.1   yamt }
    123  1.12.12.1   yamt 
    124  1.12.12.1   yamt #ifdef _KERNEL
    125        1.1   matt void
    126       1.12    dsl db_show_panic_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
    127        1.1   matt {
    128        1.1   matt 	int s;
    129        1.1   matt 	s = splhigh();
    130        1.1   matt 
    131        1.1   matt 	db_printf("Panic string: %s\n", panicstr);
    132        1.1   matt 	(void)splx(s);
    133        1.1   matt }
    134  1.12.12.1   yamt #endif
    135        1.1   matt 
    136        1.1   matt 
    137        1.1   matt void
    138       1.12    dsl db_show_frame_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
    139        1.1   matt {
    140        1.1   matt 	struct trapframe *frame;
    141        1.1   matt 
    142        1.1   matt 	if (!have_addr) {
    143        1.1   matt 		db_printf("frame address must be specified\n");
    144        1.1   matt 		return;
    145        1.1   matt 	}
    146        1.1   matt 
    147        1.1   matt 	frame = (struct trapframe *)addr;
    148        1.1   matt 
    149        1.1   matt 	db_printf("frame address = %08x  ", (u_int)frame);
    150        1.1   matt 	db_printf("spsr=%08x\n", frame->tf_spsr);
    151        1.1   matt 	db_printf("r0 =%08x r1 =%08x r2 =%08x r3 =%08x\n",
    152        1.1   matt 	    frame->tf_r0, frame->tf_r1, frame->tf_r2, frame->tf_r3);
    153        1.1   matt 	db_printf("r4 =%08x r5 =%08x r6 =%08x r7 =%08x\n",
    154        1.1   matt 	    frame->tf_r4, frame->tf_r5, frame->tf_r6, frame->tf_r7);
    155        1.1   matt 	db_printf("r8 =%08x r9 =%08x r10=%08x r11=%08x\n",
    156        1.1   matt 	    frame->tf_r8, frame->tf_r9, frame->tf_r10, frame->tf_r11);
    157        1.1   matt 	db_printf("r12=%08x r13=%08x r14=%08x r15=%08x\n",
    158        1.1   matt 	    frame->tf_r12, frame->tf_usr_sp, frame->tf_usr_lr, frame->tf_pc);
    159        1.1   matt 	db_printf("slr=%08x\n", frame->tf_svc_lr);
    160        1.1   matt }
    161