1 /* $NetBSD: db_machdep.h,v 1.7 2007/04/07 08:38:28 skrll Exp $ */
3 /* $OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $ */
6 * Copyright (c) 1998-2004 Michael Shalayeff
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef _HPPA_DB_MACHDEP_H_
32 #define _HPPA_DB_MACHDEP_H_
34 #include <uvm/uvm_extern.h>
36 #define DB_ELF_SYMBOLS
39 /* types the generic ddb module needs */
40 typedef vaddr_t db_addr_t
;
41 typedef long db_expr_t
;
43 typedef struct trapframe db_regs_t
;
44 extern db_regs_t ddb_regs
;
45 #define DDB_REGS (&ddb_regs)
48 * Things needed by kgdb:
50 typedef long kgdb_reg_t
;
51 /* From gdb's config/pa/tm-pa.h NUM_REGS value */
52 #define KGDB_NUMREGS (128)
53 /* XXX fredette - I think this is just a "big enough" kind of value */
54 #define KGDB_BUFLEN 2048
56 #define PC_REGS(regs) ((db_addr_t)(regs)->tf_iioq_head)
58 /* Breakpoint related definitions */
59 #define BKPT_ADDR(addr) (addr) /* breakpoint address */
60 #define BKPT_INST 0x00010000 /* break 0,8 */
61 #define BKPT_SIZE sizeof(int)
62 #define BKPT_SET(inst, addr) BKPT_INST
64 #define IS_BREAKPOINT_TRAP(type, code) (type != T_RECOVERY)
65 #define IS_WATCHPOINT_TRAP(type, code) 0
68 * The PA-RISC leaves tf_iioq_head pointing to the break
69 * instruction, so we don't have to define FIXUP_PC_AFTER_BREAK.
70 * However, we can't allow ddb/kgdb to simply add BKPT_SIZE to
71 * tf_iioq_head to advance past the breakpoint, since this doesn't
72 * address tf_iioq_tail. So, we define PC_ADVANCE.
74 #define PC_ADVANCE(regs) do { \
75 (regs)->tf_iioq_head = (regs)->tf_iioq_tail; \
76 (regs)->tf_iioq_tail += BKPT_SIZE; \
77 } while(/* CONSTCOND */ 0)
79 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr)
81 static __inline
int inst_call(u_int ins
) {
82 return (ins
& 0xfc00e000) == 0xe8000000 ||
83 (ins
& 0xfc00e000) == 0xe8004000 ||
84 (ins
& 0xfc000000) == 0xe4000000;
86 static __inline
int inst_branch(u_int ins
) {
87 return (ins
& 0xf0000000) == 0xe0000000 ||
88 (ins
& 0xf0000000) == 0xc0000000 ||
89 (ins
& 0xf0000000) == 0xa0000000 ||
90 (ins
& 0xf0000000) == 0x80000000;
92 static __inline
int inst_load(u_int ins
) {
93 return (ins
& 0xf0000000) == 0x40000000 ||
94 (ins
& 0xf4000200) == 0x24000000 ||
95 (ins
& 0xfc000200) == 0x0c000000 ||
96 (ins
& 0xfc001fc0) != 0x0c0011c0;
98 static __inline
int inst_store(u_int ins
) {
99 return (ins
& 0xf0000000) == 0x60000000 || /* st */
100 (ins
& 0xf4000200) == 0x24000200 || /* fst/cst */
101 (ins
& 0xfc000200) == 0x0c000200 || /* stby */
102 (ins
& 0xfc0003c0) == 0xc0001c0; /* ldcw */
104 static __inline
int inst_return(u_int ins
) {
105 return (ins
& 0xfc00e000) == 0xe800c000 ||
106 (ins
& 0xfc000000) == 0xe0000000;
108 static __inline
int inst_trap_return(u_int ins
) {
109 return (ins
& 0xfc001fc0) == 0x00000ca0;
112 #define db_clear_single_step(r) ((r)->tf_ipsw &= ~PSW_R)
113 #define db_set_single_step(r) ((r)->tf_ipsw |= PSW_R)
115 int db_valid_breakpoint(db_addr_t
);
116 int kdb_trap(int, int, db_regs_t
*);
118 #endif /* _HPPA_DB_MACHDEP_H_ */