Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.22
      1 /* $NetBSD: db_machdep.h,v 1.22 2007/02/28 04:21:53 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Jonathan Stone for
     18  *      the NetBSD Project.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
     26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  */
     34 #ifndef	_MIPS_DB_MACHDEP_H_
     35 #define	_MIPS_DB_MACHDEP_H_
     36 
     37 #include <uvm/uvm_param.h>		/* XXX  boolean_t */
     38 #include <mips/trap.h>			/* T_BREAK */
     39 #include <mips/reg.h>			/* register state */
     40 #include <mips/regnum.h>		/* symbolic register indices */
     41 #include <mips/proc.h>			/* register state */
     42 
     43 
     44 typedef	vaddr_t		db_addr_t;	/* address - unsigned */
     45 typedef	long		db_expr_t;	/* expression - signed */
     46 
     47 typedef struct frame db_regs_t;
     48 
     49 extern db_regs_t	ddb_regs;	/* register state */
     50 #define	DDB_REGS	(&ddb_regs)
     51 
     52 #define	PC_REGS(regs)	((regs)->f_regs[_R_PC])
     53 
     54 #define PC_ADVANCE(regs) do {						\
     55 	if ((db_get_value((regs)->f_regs[_R_PC], sizeof(int), false) &\
     56 	     0xfc00003f) == 0xd)					\
     57 		(regs)->f_regs[_R_PC] += BKPT_SIZE;			\
     58 } while(0)
     59 
     60 /* Similar to PC_ADVANCE(), except only advance on cpu_Debugger()'s bpt */
     61 #define PC_BREAK_ADVANCE(regs) do {					 \
     62 	if (db_get_value((regs)->f_regs[_R_PC], sizeof(int), false) == 0xd) \
     63 		(regs)->f_regs[_R_PC] += BKPT_SIZE;			 \
     64 } while(0)
     65 
     66 #define	BKPT_ADDR(addr)	(addr)		/* breakpoint address */
     67 #define BKPT_INST	0x0001000D
     68 #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
     69 #define	BKPT_SET(inst, addr)	(BKPT_INST)
     70 
     71 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAK)
     72 #define IS_WATCHPOINT_TRAP(type, code)	(0)	/* XXX mips3 watchpoint */
     73 
     74 /*
     75  * Interface to  disassembly (shared with mdb)
     76  */
     77 db_addr_t	db_disasm_insn(int insn, db_addr_t loc, bool altfmt);
     78 
     79 
     80 /*
     81  * Entrypoints to DDB for kernel, keyboard drivers, init hook
     82  */
     83 void 	kdb_kbd_trap(db_regs_t *);
     84 void 	db_set_ddb_regs(int type, mips_reg_t *);
     85 int 	kdb_trap(int type, mips_reg_t *);
     86 
     87 
     88 /*
     89  * Constants for KGDB.
     90  */
     91 typedef	mips_reg_t	kgdb_reg_t;
     92 #define	KGDB_NUMREGS	90
     93 #define	KGDB_BUFLEN	1024
     94 
     95 /*
     96  * MIPS cpus have no hardware single-step.
     97  */
     98 #define SOFTWARE_SSTEP
     99 
    100 #define inst_trap_return(ins)	((ins)&0)
    101 
    102 bool	inst_branch(int inst);
    103 bool	inst_call(int inst);
    104 bool	inst_return(int inst);
    105 bool	inst_load(int inst);
    106 bool	inst_store(int inst);
    107 bool	inst_unconditional_flow_transfer(int inst);
    108 db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
    109 db_addr_t next_instr_address(db_addr_t pc, bool bd);
    110 
    111 /*
    112  * We have machine-dependent commands.
    113  */
    114 #define DB_MACHINE_COMMANDS
    115 
    116 #endif	/* _MIPS_DB_MACHDEP_H_ */
    117