Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.10.8.5
      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.5  nathanw /*	$NetBSD: db_machdep.h,v 1.10.8.5 2002/06/20 03:40:31 nathanw 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.3  nathanw #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 
     70  1.10.8.2  nathanw #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
     71  1.10.8.2  nathanw #define	BKPT_SET(inst)	(BKPT_INST)
     72  1.10.8.2  nathanw 
     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.2  nathanw 
     77  1.10.8.3  nathanw #define T_BREAKPOINT	0xffff
     78  1.10.8.2  nathanw #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
     79  1.10.8.2  nathanw 
     80  1.10.8.2  nathanw #define T_WATCHPOINT	0xeeee
     81  1.10.8.2  nathanw #ifdef T_WATCHPOINT
     82  1.10.8.2  nathanw #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
     83  1.10.8.2  nathanw #else
     84  1.10.8.2  nathanw #define	IS_WATCHPOINT_TRAP(type, code)	0
     85  1.10.8.2  nathanw #endif
     86  1.10.8.2  nathanw 
     87  1.10.8.2  nathanw #define	M_RTS		0xfc0007fe
     88  1.10.8.2  nathanw #define I_RTS		0x4c000020
     89  1.10.8.2  nathanw #define M_BC		0xfc000000
     90  1.10.8.2  nathanw #define I_BC		0x40000000
     91  1.10.8.2  nathanw #define M_B		0xfc000000
     92  1.10.8.2  nathanw #define I_B		0x50000000
     93  1.10.8.2  nathanw #define	M_RFI		0xfc0007fe
     94  1.10.8.2  nathanw #define	I_RFI		0x4c000064
     95  1.10.8.2  nathanw 
     96  1.10.8.2  nathanw #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
     97  1.10.8.2  nathanw #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
     98  1.10.8.2  nathanw #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
     99  1.10.8.2  nathanw 				 ((ins)&M_B  ) == I_B )
    100  1.10.8.2  nathanw #define inst_load(ins)		0
    101  1.10.8.2  nathanw #define inst_store(ins)		0
    102  1.10.8.2  nathanw 
    103  1.10.8.2  nathanw /*
    104  1.10.8.2  nathanw  * GDB's register array is:
    105  1.10.8.2  nathanw  *  32 4-byte GPRs
    106  1.10.8.2  nathanw  *  32 8-byte FPRs
    107  1.10.8.2  nathanw  *   7 4-byte UISA special-purpose registers
    108  1.10.8.2  nathanw  *  16 4-byte segment registers
    109  1.10.8.2  nathanw  *  32 4-byte standard OEA special-purpose registers,
    110  1.10.8.2  nathanw  * and up to 64 4-byte non-standard OES special-purpose registers.
    111  1.10.8.2  nathanw  * GDB keeps some extra space, so the total size of the register array
    112  1.10.8.2  nathanw  * they use is 880 bytes (gdb-5.0).
    113  1.10.8.2  nathanw  */
    114  1.10.8.2  nathanw typedef long	kgdb_reg_t;
    115  1.10.8.2  nathanw #define KGDB_NUMREGS	220	/* Treat all registers as 4-byte */
    116  1.10.8.3  nathanw #define KGDB_BUFLEN	(2*KGDB_NUMREGS*sizeof(kgdb_reg_t)+1)
    117  1.10.8.2  nathanw #define KGDB_PPC_PC_REG		96	/* first UISA SP register */
    118  1.10.8.2  nathanw #define KGDB_PPC_MSR_REG	97
    119  1.10.8.2  nathanw #define KGDB_PPC_CR_REG		98
    120  1.10.8.2  nathanw #define KGDB_PPC_LR_REG		99
    121  1.10.8.2  nathanw #define KGDB_PPC_CTR_REG	100
    122  1.10.8.2  nathanw #define KGDB_PPC_XER_REG	101
    123  1.10.8.2  nathanw #define KGDB_PPC_MQ_REG		102
    124  1.10.8.2  nathanw 
    125  1.10.8.2  nathanw #ifdef _KERNEL
    126  1.10.8.2  nathanw 
    127  1.10.8.2  nathanw void	kdb_kintr __P((void *));
    128  1.10.8.2  nathanw int	kdb_trap __P((int, void *));
    129  1.10.8.2  nathanw 
    130  1.10.8.2  nathanw #ifdef PPC_IBM4XX
    131  1.10.8.2  nathanw /*
    132  1.10.8.2  nathanw  * We have machine-dependent commands.
    133  1.10.8.2  nathanw  */
    134  1.10.8.2  nathanw #define	DB_MACHINE_COMMANDS
    135  1.10.8.2  nathanw #endif
    136  1.10.8.2  nathanw 
    137  1.10.8.2  nathanw #endif /* _KERNEL */
    138  1.10.8.2  nathanw 
    139  1.10.8.2  nathanw #endif	/* _PPC_DB_MACHDEP_H_ */
    140