db_machdep.h revision 1.14 1 1.1 sakamoto /* $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ */
2 1.14 scw /* $NetBSD: db_machdep.h,v 1.14 2002/12/20 15:23:13 scw Exp $ */
3 1.1 sakamoto
4 1.1 sakamoto /*
5 1.1 sakamoto * Mach Operating System
6 1.1 sakamoto * Copyright (c) 1992 Carnegie Mellon University
7 1.1 sakamoto * All Rights Reserved.
8 1.1 sakamoto *
9 1.1 sakamoto * Permission to use, copy, modify and distribute this software and its
10 1.1 sakamoto * documentation is hereby granted, provided that both the copyright
11 1.1 sakamoto * notice and this permission notice appear in all copies of the
12 1.1 sakamoto * software, derivative works or modified versions, and any portions
13 1.1 sakamoto * thereof, and that both notices appear in supporting documentation.
14 1.1 sakamoto *
15 1.1 sakamoto * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.1 sakamoto * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17 1.1 sakamoto * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.1 sakamoto *
19 1.1 sakamoto * Carnegie Mellon requests users of this software to return to
20 1.1 sakamoto *
21 1.1 sakamoto * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.1 sakamoto * School of Computer Science
23 1.1 sakamoto * Carnegie Mellon University
24 1.1 sakamoto * Pittsburgh PA 15213-3890
25 1.1 sakamoto *
26 1.1 sakamoto * any improvements or extensions that they make and grant Carnegie Mellon
27 1.1 sakamoto * the rights to redistribute these changes.
28 1.1 sakamoto */
29 1.1 sakamoto
30 1.1 sakamoto /*
31 1.1 sakamoto * Machine-dependent defines for new kernel debugger.
32 1.1 sakamoto */
33 1.1 sakamoto #ifndef _PPC_DB_MACHDEP_H_
34 1.1 sakamoto #define _PPC_DB_MACHDEP_H_
35 1.1 sakamoto
36 1.5 mrg #include <uvm/uvm_prot.h>
37 1.7 mrg #include <uvm/uvm_param.h>
38 1.1 sakamoto #include <machine/trap.h>
39 1.1 sakamoto
40 1.9 simonb #ifdef _KERNEL
41 1.9 simonb #include "opt_ppcarch.h"
42 1.9 simonb #endif
43 1.9 simonb
44 1.1 sakamoto #define DB_ELF_SYMBOLS
45 1.1 sakamoto #define DB_ELFSIZE 32
46 1.1 sakamoto
47 1.4 tsubai typedef vaddr_t db_addr_t; /* address - unsigned */
48 1.3 tsubai typedef long db_expr_t; /* expression - signed */
49 1.1 sakamoto struct powerpc_saved_state {
50 1.2 mycroft u_int32_t r[32]; /* data registers */
51 1.1 sakamoto u_int32_t iar;
52 1.1 sakamoto u_int32_t msr;
53 1.9 simonb u_int32_t lr;
54 1.9 simonb u_int32_t ctr;
55 1.9 simonb u_int32_t cr;
56 1.9 simonb u_int32_t xer;
57 1.9 simonb u_int32_t dear;
58 1.9 simonb u_int32_t esr;
59 1.9 simonb u_int32_t pid;
60 1.1 sakamoto };
61 1.1 sakamoto typedef struct powerpc_saved_state db_regs_t;
62 1.13 matt extern db_regs_t ddb_regs; /* register state */
63 1.1 sakamoto #define DDB_REGS (&ddb_regs)
64 1.1 sakamoto
65 1.1 sakamoto #define PC_REGS(regs) ((db_addr_t)(regs)->iar)
66 1.1 sakamoto
67 1.14 scw #define BKPT_ASM "trap" /* should match BKPT_INST */
68 1.12 dbj #define BKPT_INST 0x7fe00008 /* breakpoint instruction */
69 1.1 sakamoto #define BKPT_SIZE (4) /* size of breakpoint inst */
70 1.1 sakamoto #define BKPT_SET(inst) (BKPT_INST)
71 1.1 sakamoto
72 1.14 scw #ifndef PPC_IBM4XX
73 1.1 sakamoto #define SR_SINGLESTEP 0x400
74 1.1 sakamoto #define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP)
75 1.1 sakamoto #define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP)
76 1.14 scw #else
77 1.14 scw #define SOFTWARE_SSTEP
78 1.14 scw #endif
79 1.1 sakamoto
80 1.12 dbj #define T_BREAKPOINT 0xffff
81 1.1 sakamoto #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
82 1.1 sakamoto
83 1.1 sakamoto #define T_WATCHPOINT 0xeeee
84 1.1 sakamoto #ifdef T_WATCHPOINT
85 1.1 sakamoto #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT)
86 1.1 sakamoto #else
87 1.1 sakamoto #define IS_WATCHPOINT_TRAP(type, code) 0
88 1.1 sakamoto #endif
89 1.1 sakamoto
90 1.14 scw #define M_RTS 0xfc0007ff
91 1.1 sakamoto #define I_RTS 0x4c000020
92 1.14 scw #define I_BLRL 0x4c000021
93 1.14 scw #define M_BC 0xfc000001
94 1.1 sakamoto #define I_BC 0x40000000
95 1.14 scw #define I_BCL 0x40000001
96 1.14 scw #define M_B 0xfc000001
97 1.14 scw #define I_B 0x48000000
98 1.14 scw #define I_BL 0x48000001
99 1.14 scw #define M_BCTR 0xfc0007fe
100 1.14 scw #define I_BCTR 0x4c000420
101 1.14 scw #define I_BCTRL 0x4c000421
102 1.1 sakamoto #define M_RFI 0xfc0007fe
103 1.1 sakamoto #define I_RFI 0x4c000064
104 1.1 sakamoto
105 1.1 sakamoto #define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI)
106 1.1 sakamoto #define inst_return(ins) (((ins)&M_RTS) == I_RTS)
107 1.14 scw #define inst_call(ins) (((ins)&M_BC ) == I_BCL || \
108 1.14 scw ((ins)&M_B ) == I_BL || \
109 1.14 scw ((ins)&M_BCTR) == I_BCTRL || \
110 1.14 scw ((ins)&M_RTS ) == I_BLRL )
111 1.14 scw #define inst_branch(ins) (((ins)&M_BC ) == I_BC || \
112 1.14 scw ((ins)&M_B ) == I_B || \
113 1.14 scw ((ins)&M_BCTR) == I_BCTR )
114 1.14 scw #define inst_unconditional_flow_transfer(ins) \
115 1.14 scw (((ins)&M_B ) == I_B || \
116 1.14 scw ((ins)&M_BCTR) == I_BCTR )
117 1.1 sakamoto #define inst_load(ins) 0
118 1.1 sakamoto #define inst_store(ins) 0
119 1.14 scw #ifdef PPC_IBM4XX
120 1.14 scw #define next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4)))
121 1.14 scw extern db_addr_t branch_taken(int, db_addr_t, db_regs_t *);
122 1.14 scw #endif
123 1.10 briggs
124 1.10 briggs /*
125 1.10 briggs * GDB's register array is:
126 1.10 briggs * 32 4-byte GPRs
127 1.10 briggs * 32 8-byte FPRs
128 1.10 briggs * 7 4-byte UISA special-purpose registers
129 1.10 briggs * 16 4-byte segment registers
130 1.10 briggs * 32 4-byte standard OEA special-purpose registers,
131 1.10 briggs * and up to 64 4-byte non-standard OES special-purpose registers.
132 1.10 briggs * GDB keeps some extra space, so the total size of the register array
133 1.10 briggs * they use is 880 bytes (gdb-5.0).
134 1.10 briggs */
135 1.10 briggs typedef long kgdb_reg_t;
136 1.10 briggs #define KGDB_NUMREGS 220 /* Treat all registers as 4-byte */
137 1.12 dbj #define KGDB_BUFLEN (2*KGDB_NUMREGS*sizeof(kgdb_reg_t)+1)
138 1.10 briggs #define KGDB_PPC_PC_REG 96 /* first UISA SP register */
139 1.10 briggs #define KGDB_PPC_MSR_REG 97
140 1.10 briggs #define KGDB_PPC_CR_REG 98
141 1.10 briggs #define KGDB_PPC_LR_REG 99
142 1.10 briggs #define KGDB_PPC_CTR_REG 100
143 1.10 briggs #define KGDB_PPC_XER_REG 101
144 1.10 briggs #define KGDB_PPC_MQ_REG 102
145 1.1 sakamoto
146 1.1 sakamoto #ifdef _KERNEL
147 1.1 sakamoto
148 1.1 sakamoto void kdb_kintr __P((void *));
149 1.1 sakamoto int kdb_trap __P((int, void *));
150 1.9 simonb
151 1.9 simonb #ifdef PPC_IBM4XX
152 1.9 simonb /*
153 1.9 simonb * We have machine-dependent commands.
154 1.9 simonb */
155 1.9 simonb #define DB_MACHINE_COMMANDS
156 1.9 simonb #endif
157 1.1 sakamoto
158 1.1 sakamoto #endif /* _KERNEL */
159 1.1 sakamoto
160 1.1 sakamoto #endif /* _PPC_DB_MACHDEP_H_ */
161