db_machdep.h revision 1.12.2.1 1 /* $NetBSD: db_machdep.h,v 1.12.2.1 2016/07/13 08:25:44 snj Exp $ */
2
3 /* $OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $ */
4
5 /*
6 * Copyright (c) 1998-2004 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 *
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.
29 */
30
31 #ifndef _HPPA_DB_MACHDEP_H_
32 #define _HPPA_DB_MACHDEP_H_
33
34 #include <sys/param.h>
35
36 #include <uvm/uvm_extern.h>
37
38 #include <machine/pcb.h>
39 #include <machine/frame.h>
40
41 #define DB_ELF_SYMBOLS
42 #define DB_ELFSIZE 32
43
44 /* types the generic ddb module needs */
45 typedef vaddr_t db_addr_t;
46 #define DDB_EXPR_FMT "l" /* expression is long */
47 typedef long db_expr_t;
48
49 typedef struct trapframe db_regs_t;
50 extern db_regs_t ddb_regs;
51 #define DDB_REGS (&ddb_regs)
52
53 /* DDB commands not in db_interface.c */
54 void db_dump_trap(db_expr_t, bool, db_expr_t, const char *);
55
56 /*
57 * Things needed by kgdb:
58 */
59 typedef long kgdb_reg_t;
60 /* From gdb's config/pa/tm-pa.h NUM_REGS value */
61 #define KGDB_NUMREGS (128)
62 /* XXX fredette - I think this is just a "big enough" kind of value */
63 #define KGDB_BUFLEN 2048
64
65 #define PC_REGS(regs) ((db_addr_t)(regs)->tf_iioq_head)
66
67 /* Breakpoint related definitions */
68 #define BKPT_ADDR(addr) (addr) /* breakpoint address */
69 #define BKPT_INST 0x00010000 /* break 0,8 */
70 #define BKPT_SIZE sizeof(int)
71 #define BKPT_SET(inst, addr) BKPT_INST
72
73 #define IS_BREAKPOINT_TRAP(type, code) (type != T_RECOVERY)
74 #define IS_WATCHPOINT_TRAP(type, code) 0
75
76 /*
77 * The PA-RISC leaves tf_iioq_head pointing to the break
78 * instruction, so we don't have to define FIXUP_PC_AFTER_BREAK.
79 * However, we can't allow ddb/kgdb to simply add BKPT_SIZE to
80 * tf_iioq_head to advance past the breakpoint, since this doesn't
81 * address tf_iioq_tail. So, we define PC_ADVANCE.
82 */
83 #define PC_ADVANCE(regs) do { \
84 (regs)->tf_iioq_head = (regs)->tf_iioq_tail; \
85 (regs)->tf_iioq_tail += BKPT_SIZE; \
86 } while(/* CONSTCOND */ 0)
87
88 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr)
89
90 static __inline int inst_call(u_int ins) {
91 return (ins & 0xfc00e000) == 0xe8000000 ||
92 (ins & 0xfc00e000) == 0xe8004000 ||
93 (ins & 0xfc000000) == 0xe4000000;
94 }
95 static __inline int inst_branch(u_int ins) {
96 return (ins & 0xf0000000) == 0xe0000000 ||
97 (ins & 0xf0000000) == 0xc0000000 ||
98 (ins & 0xf0000000) == 0xa0000000 ||
99 (ins & 0xf0000000) == 0x80000000;
100 }
101 static __inline int inst_load(u_int ins) {
102 return (ins & 0xf0000000) == 0x40000000 ||
103 (ins & 0xf4000200) == 0x24000000 ||
104 (ins & 0xfc000200) == 0x0c000000 ||
105 (ins & 0xfc001fc0) != 0x0c0011c0;
106 }
107 static __inline int inst_store(u_int ins) {
108 return (ins & 0xf0000000) == 0x60000000 || /* st */
109 (ins & 0xf4000200) == 0x24000200 || /* fst/cst */
110 (ins & 0xfc000200) == 0x0c000200 || /* stby */
111 (ins & 0xfc0003c0) == 0xc0001c0; /* ldcw */
112 }
113 static __inline int inst_return(u_int ins) {
114 return (ins & 0xfc00e000) == 0xe800c000 ||
115 (ins & 0xfc000000) == 0xe0000000;
116 }
117 static __inline int inst_trap_return(u_int ins) {
118 return (ins & 0xfc001fe0) == 0x00000c00 ||
119 (ins & 0xfc001fe0) == 0x00000ca0;
120 }
121
122 #define db_clear_single_step(r) ((r)->tf_ipsw &= ~PSW_R)
123 #define db_set_single_step(r) ((r)->tf_ipsw |= PSW_R)
124
125 #define DB_MACHINE_COMMANDS
126
127 int db_valid_breakpoint(db_addr_t);
128 int kdb_trap(int, int, db_regs_t *);
129
130 #endif /* _HPPA_DB_MACHDEP_H_ */
131