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