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