Home | History | Annotate | Line # | Download | only in include
      1  1.28       rin /*	$NetBSD: db_machdep.h,v 1.28 2020/12/01 02:48:29 rin Exp $	*/
      2   1.1   reinoud 
      3   1.1   reinoud /*
      4   1.1   reinoud  * Copyright (c) 1996 Scott K Stevens
      5  1.24     skrll  *
      6   1.1   reinoud  * Mach Operating System
      7   1.1   reinoud  * Copyright (c) 1991,1990 Carnegie Mellon University
      8   1.1   reinoud  * All Rights Reserved.
      9  1.24     skrll  *
     10   1.1   reinoud  * Permission to use, copy, modify and distribute this software and its
     11   1.1   reinoud  * documentation is hereby granted, provided that both the copyright
     12   1.1   reinoud  * notice and this permission notice appear in all copies of the
     13   1.1   reinoud  * software, derivative works or modified versions, and any portions
     14   1.1   reinoud  * thereof, and that both notices appear in supporting documentation.
     15  1.24     skrll  *
     16   1.1   reinoud  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     17   1.1   reinoud  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     18   1.1   reinoud  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     19  1.24     skrll  *
     20   1.1   reinoud  * Carnegie Mellon requests users of this software to return to
     21  1.24     skrll  *
     22   1.1   reinoud  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     23   1.1   reinoud  *  School of Computer Science
     24   1.1   reinoud  *  Carnegie Mellon University
     25   1.1   reinoud  *  Pittsburgh PA 15213-3890
     26  1.24     skrll  *
     27   1.1   reinoud  * any improvements or extensions that they make and grant Carnegie Mellon
     28   1.1   reinoud  * the rights to redistribute these changes.
     29   1.1   reinoud  */
     30   1.1   reinoud 
     31   1.3     bjh21 #ifndef	_ARM_DB_MACHDEP_H_
     32   1.3     bjh21 #define	_ARM_DB_MACHDEP_H_
     33   1.1   reinoud 
     34  1.27       ryo #if defined(__arm__)
     35  1.27       ryo 
     36   1.1   reinoud /*
     37   1.1   reinoud  * Machine-dependent defines for new kernel debugger.
     38   1.1   reinoud  */
     39  1.18  christos #include <sys/types.h>
     40   1.1   reinoud #include <uvm/uvm_extern.h>
     41   1.3     bjh21 #include <arm/armreg.h>
     42  1.28       rin #include <arm/cdefs.h>
     43   1.1   reinoud #include <machine/frame.h>
     44   1.1   reinoud #include <machine/trap.h>
     45   1.1   reinoud 
     46   1.1   reinoud /* end of mangling */
     47   1.1   reinoud 
     48   1.2      matt typedef	vaddr_t		db_addr_t;	/* address - unsigned */
     49  1.17     joerg #define	DDB_EXPR_FMT	"l"		/* expression is long */
     50   1.1   reinoud typedef	long		db_expr_t;	/* expression - signed */
     51   1.1   reinoud 
     52   1.1   reinoud typedef trapframe_t db_regs_t;
     53   1.1   reinoud 
     54  1.21     skrll #ifndef MULTIPROCESSOR
     55  1.21     skrll extern db_regs_t ddb_regs;	/* register state */
     56  1.21     skrll #define	DDB_REGS	(&ddb_regs)
     57  1.21     skrll #else
     58  1.21     skrll extern db_regs_t *ddb_regp;
     59  1.21     skrll #define DDB_REGS	(ddb_regp)
     60  1.21     skrll #define ddb_regs	(*ddb_regp)
     61  1.21     skrll #endif
     62   1.1   reinoud 
     63  1.14  christos #define	PC_REGS(regs)	((regs)->tf_pc)
     64  1.13     skrll #define PC_ADVANCE(r)   ((r)->tf_r15 += BKPT_SIZE)
     65   1.1   reinoud 
     66   1.7       scw #define	BKPT_ADDR(addr)	(addr)			/* breakpoint address */
     67  1.14  christos #if defined(DDB)
     68   1.1   reinoud #define	BKPT_INST	(KERNEL_BREAKPOINT)	/* breakpoint instruction */
     69  1.14  christos #else
     70  1.14  christos /* breakpoint instruction if we use KGDB, this is used in db_set_temp_breakpoint() */
     71  1.14  christos #define BKPT_INST	(GDB5_BREAKPOINT)
     72  1.14  christos #endif
     73   1.1   reinoud #define	BKPT_SIZE	(INSN_SIZE)		/* size of breakpoint inst */
     74  1.28       rin #ifdef __ARM_ARCH_BE8
     75  1.28       rin #define	BKPT_SET(inst, addr)	(bswap32(BKPT_INST))
     76  1.28       rin #else
     77  1.10    cherry #define	BKPT_SET(inst, addr)	(BKPT_INST)
     78  1.28       rin #endif
     79   1.1   reinoud 
     80   1.1   reinoud /*#define FIXUP_PC_AFTER_BREAK(regs)	((regs)->tf_pc -= BKPT_SIZE)*/
     81   1.1   reinoud 
     82   1.8   thorpej #define	T_FAULT				(0)
     83   1.1   reinoud #define T_BREAKPOINT			(1)
     84   1.1   reinoud 
     85   1.1   reinoud #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
     86  1.23     skrll #define	IS_WATCHPOINT_TRAP(type, code)	(0)
     87   1.1   reinoud 
     88   1.1   reinoud #define	inst_trap_return(ins)	(0)
     89   1.1   reinoud /* ldmxx reg, {..., pc}
     90   1.1   reinoud 					    01800000  stack mode
     91   1.1   reinoud 					    000f0000  register
     92   1.1   reinoud 					    0000ffff  register list */
     93   1.1   reinoud /* mov pc, reg
     94   1.1   reinoud 					    0000000f  register */
     95   1.1   reinoud #define	inst_return(ins)	(((ins) & 0x0e108000) == 0x08108000 || \
     96   1.1   reinoud 				 ((ins) & 0x0ff0fff0) == 0x01a0f000)
     97   1.1   reinoud /* bl ...
     98   1.1   reinoud 					    00ffffff  offset>>2 */
     99   1.1   reinoud #define	inst_call(ins)		(((ins) & 0x0f000000) == 0x0b000000)
    100   1.1   reinoud /* b ...
    101   1.1   reinoud 					    00ffffff  offset>>2 */
    102   1.1   reinoud /* ldr pc, [pc, reg, lsl #2]
    103   1.1   reinoud 					    0000000f  register */
    104   1.1   reinoud #define	inst_branch(ins)	(((ins) & 0x0f000000) == 0x0a000000 || \
    105  1.14  christos 				 ((ins) & 0x0fdffff0) == 0x079ff100 || \
    106  1.14  christos 				 ((ins) & 0x0ff0f000) == 0x0590f000)
    107   1.1   reinoud #define inst_load(ins)		(0)
    108   1.1   reinoud #define inst_store(ins)		(0)
    109   1.1   reinoud #define inst_unconditional_flow_transfer(ins)	\
    110  1.19      matt 	(__SHIFTOUT((ins), INSN_COND_MASK) == INSN_COND_AL \
    111  1.19      matt 	 && (inst_branch(ins) || inst_call(ins) || inst_return(ins)))
    112   1.1   reinoud 
    113   1.1   reinoud #define getreg_val			(0)
    114   1.1   reinoud #define next_instr_address(pc, bd)	((bd) ? (pc) : ((pc) + INSN_SIZE))
    115   1.1   reinoud 
    116   1.1   reinoud #define DB_MACHINE_COMMANDS
    117   1.1   reinoud 
    118   1.1   reinoud #define SOFTWARE_SSTEP
    119   1.1   reinoud 
    120  1.16       dsl u_int branch_taken(u_int insn, u_int pc, db_regs_t *db_regs);
    121  1.16       dsl int kdb_trap(int, db_regs_t *);
    122  1.16       dsl void db_machine_init(void);
    123  1.22      matt int db_validate_address(vaddr_t addr);
    124   1.1   reinoud 
    125   1.4     bjh21 #define DB_ELF_SYMBOLS
    126   1.6    briggs 
    127   1.6    briggs /*
    128   1.6    briggs  * kgdb
    129   1.6    briggs  */
    130   1.6    briggs typedef register_t	kgdb_reg_t;
    131   1.6    briggs #define KGDB_NUMREGS	(16 + 8*3 + 2)	/* r0..r15, f0..f7, fps, cpsr
    132   1.6    briggs 					 * fp-registers are 12 bytes wide */
    133   1.6    briggs #define KGDB_REGNUM_R0		0
    134   1.6    briggs #define KGDB_REGNUM_SPSR	16 + 8*3 + 1
    135   1.6    briggs #define KGDB_BUFLEN		1024
    136   1.1   reinoud 
    137  1.20      matt /*
    138  1.20      matt  * MP stuff
    139  1.20      matt  */
    140  1.20      matt extern volatile struct cpu_info *db_onproc;
    141  1.20      matt extern volatile struct cpu_info *db_newcpu;
    142  1.27       ryo 
    143  1.27       ryo #elif defined(__aarch64__)
    144  1.27       ryo 
    145  1.27       ryo #include <aarch64/db_machdep.h>
    146  1.27       ryo 
    147  1.27       ryo #endif
    148  1.27       ryo 
    149   1.3     bjh21 #endif	/* _ARM_DB_MACHDEP_H_ */
    150