Home | History | Annotate | Line # | Download | only in include
db_machdep.h revision 1.4
      1 /*	$NetBSD: db_machdep.h,v 1.4 2006/02/16 20:17:13 perry Exp $	*/
      2 
      3 /*	$OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $	*/
      4 
      5 /*
      6  * Copyright (c) 1998 Michael Shalayeff
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by Michael Shalayeff.
     20  * 4. The name of the author may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #ifndef	_HPPA_DB_MACHDEP_H_
     36 #define	_HPPA_DB_MACHDEP_H_
     37 
     38 #include <uvm/uvm_extern.h>
     39 
     40 #define	DB_ELF_SYMBOLS
     41 #define	DB_ELFSIZE	32
     42 
     43 /* types the generic ddb module needs */
     44 typedef	vaddr_t db_addr_t;
     45 typedef	long db_expr_t;
     46 
     47 typedef struct trapframe db_regs_t;
     48 extern db_regs_t	ddb_regs;
     49 #define	DDB_REGS	(&ddb_regs)
     50 
     51 /*
     52  * Things needed by kgdb:
     53  */
     54 typedef long kgdb_reg_t;
     55 /* From gdb's config/pa/tm-pa.h NUM_REGS value */
     56 #define KGDB_NUMREGS	(128)
     57 /* XXX fredette - I think this is just a "big enough" kind of value */
     58 #define KGDB_BUFLEN     2048
     59 
     60 #define	PC_REGS(regs)	((db_addr_t)(regs)->tf_iioq_head)
     61 
     62 /* Breakpoint related definitions */
     63 #define	BKPT_ADDR(addr)	(addr)		/* breakpoint address */
     64 #define	BKPT_INST	0x00010000	/* break 0,8 */
     65 #define	BKPT_SIZE	sizeof(int)
     66 #define	BKPT_SET(inst)	BKPT_INST
     67 
     68 #define	IS_BREAKPOINT_TRAP(type, code) (type != T_RECOVERY)
     69 #define	IS_WATCHPOINT_TRAP(type, code) 0
     70 
     71 /*
     72  * The PA-RISC leaves tf_iioq_head pointing to the break
     73  * instruction, so we don't have to define FIXUP_PC_AFTER_BREAK.
     74  * However, we can't allow ddb/kgdb to simply add BKPT_SIZE to
     75  * tf_iioq_head to advance past the breakpoint, since this doesn't
     76  * address tf_iioq_tail.  So, we define PC_ADVANCE.
     77  */
     78 #define	PC_ADVANCE(regs) do { 				\
     79 	(regs)->tf_iioq_head = (regs)->tf_iioq_tail;	\
     80 	(regs)->tf_iioq_tail += BKPT_SIZE;		\
     81 } while(/* CONSTCOND */ 0)
     82 
     83 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr)
     84 
     85 static __inline int inst_call(u_int ins) {
     86 	return (ins & 0xfc00e000) == 0xe8000000 ||
     87 	       (ins & 0xfc00e000) == 0xe8004000 ||
     88 	       (ins & 0xfc000000) == 0xe4000000;
     89 }
     90 static __inline int inst_branch(u_int ins) {
     91 	return (ins & 0xf0000000) == 0xe0000000 ||
     92 	       (ins & 0xf0000000) == 0xc0000000 ||
     93 	       (ins & 0xf0000000) == 0xa0000000 ||
     94 	       (ins & 0xf0000000) == 0x80000000;
     95 }
     96 static __inline int inst_load(u_int ins) {
     97 	return (ins & 0xf0000000) == 0x40000000 ||
     98 	       (ins & 0xf4000200) == 0x24000000 ||
     99 	       (ins & 0xfc000200) == 0x0c000000 ||
    100 	       (ins & 0xfc001fc0) != 0x0c0011c0;
    101 }
    102 static __inline int inst_store(u_int ins) {
    103 	return (ins & 0xf0000000) == 0x60000000 ||
    104 	       (ins & 0xf4000200) == 0x24000200 ||
    105 	       (ins & 0xfc000200) == 0x0c000200;
    106 }
    107 static __inline int inst_return(u_int ins) {
    108 	return (ins & 0xfc00e000) == 0xe800c000 ||
    109 	       (ins & 0xfc000000) == 0xe0000000;
    110 }
    111 static __inline int inst_trap_return(u_int ins)	{
    112 	return (ins & 0xfc001fc0) == 0x00000ca0;
    113 }
    114 
    115 #define db_clear_single_step(r)	((r)->tf_ipsw &= ~PSW_R)
    116 #define db_set_single_step(r)	((r)->tf_ipsw |= PSW_R)
    117 
    118 int db_valid_breakpoint __P((db_addr_t));
    119 int kdb_trap __P((int, int, db_regs_t *));
    120 
    121 #endif /* _HPPA_DB_MACHDEP_H_ */
    122