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