Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.13
      1 /*	$OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $	*/
      2 /*	$NetBSD: db_machdep.h,v 1.13 2002/05/13 06:05:32 matt Exp $	*/
      3 
      4 /*
      5  * Mach Operating System
      6  * Copyright (c) 1992 Carnegie Mellon University
      7  * All Rights Reserved.
      8  *
      9  * Permission to use, copy, modify and distribute this software and its
     10  * documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     17  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie Mellon
     27  * the rights to redistribute these changes.
     28  */
     29 
     30 /*
     31  * Machine-dependent defines for new kernel debugger.
     32  */
     33 #ifndef	_PPC_DB_MACHDEP_H_
     34 #define	_PPC_DB_MACHDEP_H_
     35 
     36 #include <uvm/uvm_prot.h>
     37 #include <uvm/uvm_param.h>
     38 #include <machine/trap.h>
     39 
     40 #ifdef _KERNEL
     41 #include "opt_ppcarch.h"
     42 #endif
     43 
     44 #define	DB_ELF_SYMBOLS
     45 #define	DB_ELFSIZE	32
     46 
     47 typedef	vaddr_t		db_addr_t;	/* address - unsigned */
     48 typedef	long		db_expr_t;	/* expression - signed */
     49 struct powerpc_saved_state {
     50 	u_int32_t	r[32];		/* data registers */
     51 	u_int32_t	iar;
     52 	u_int32_t	msr;
     53 	u_int32_t	lr;
     54 	u_int32_t	ctr;
     55 	u_int32_t	cr;
     56 	u_int32_t	xer;
     57 	u_int32_t	dear;
     58 	u_int32_t	esr;
     59 	u_int32_t	pid;
     60 };
     61 typedef struct powerpc_saved_state db_regs_t;
     62 extern	db_regs_t	ddb_regs;		/* register state */
     63 #define DDB_REGS	(&ddb_regs)
     64 
     65 #define	PC_REGS(regs)	((db_addr_t)(regs)->iar)
     66 
     67 #define	BKPT_ASM	"trap"				/* should match BKPT_INST */
     68 #define	BKPT_INST	0x7fe00008	/* breakpoint instruction */
     69 
     70 #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
     71 #define	BKPT_SET(inst)	(BKPT_INST)
     72 
     73 #define SR_SINGLESTEP	0x400
     74 #define	db_clear_single_step(regs)	((regs)->msr &= ~SR_SINGLESTEP)
     75 #define	db_set_single_step(regs)	((regs)->msr |=  SR_SINGLESTEP)
     76 
     77 #define T_BREAKPOINT	0xffff
     78 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
     79 
     80 #define T_WATCHPOINT	0xeeee
     81 #ifdef T_WATCHPOINT
     82 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
     83 #else
     84 #define	IS_WATCHPOINT_TRAP(type, code)	0
     85 #endif
     86 
     87 #define	M_RTS		0xfc0007fe
     88 #define I_RTS		0x4c000020
     89 #define M_BC		0xfc000000
     90 #define I_BC		0x40000000
     91 #define M_B		0xfc000000
     92 #define I_B		0x50000000
     93 #define	M_RFI		0xfc0007fe
     94 #define	I_RFI		0x4c000064
     95 
     96 #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
     97 #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
     98 #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
     99 				 ((ins)&M_B  ) == I_B )
    100 #define inst_load(ins)		0
    101 #define inst_store(ins)		0
    102 
    103 /*
    104  * GDB's register array is:
    105  *  32 4-byte GPRs
    106  *  32 8-byte FPRs
    107  *   7 4-byte UISA special-purpose registers
    108  *  16 4-byte segment registers
    109  *  32 4-byte standard OEA special-purpose registers,
    110  * and up to 64 4-byte non-standard OES special-purpose registers.
    111  * GDB keeps some extra space, so the total size of the register array
    112  * they use is 880 bytes (gdb-5.0).
    113  */
    114 typedef long	kgdb_reg_t;
    115 #define KGDB_NUMREGS	220	/* Treat all registers as 4-byte */
    116 #define KGDB_BUFLEN	(2*KGDB_NUMREGS*sizeof(kgdb_reg_t)+1)
    117 #define KGDB_PPC_PC_REG		96	/* first UISA SP register */
    118 #define KGDB_PPC_MSR_REG	97
    119 #define KGDB_PPC_CR_REG		98
    120 #define KGDB_PPC_LR_REG		99
    121 #define KGDB_PPC_CTR_REG	100
    122 #define KGDB_PPC_XER_REG	101
    123 #define KGDB_PPC_MQ_REG		102
    124 
    125 #ifdef _KERNEL
    126 
    127 void	kdb_kintr __P((void *));
    128 int	kdb_trap __P((int, void *));
    129 
    130 #ifdef PPC_IBM4XX
    131 /*
    132  * We have machine-dependent commands.
    133  */
    134 #define	DB_MACHINE_COMMANDS
    135 #endif
    136 
    137 #endif /* _KERNEL */
    138 
    139 #endif	/* _PPC_DB_MACHDEP_H_ */
    140