db_machdep.h revision 1.6 1 /* $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ */
2 /* $NetBSD: db_machdep.h,v 1.6 2000/06/26 14:20:54 mrg Exp $ */
3
4 /*
5 * Mach Operating System
6 * Copyright (c) 1992 Carnegie Mellon University
7 * All Rights Reserved.
8 *
9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie Mellon
27 * the rights to redistribute these changes.
28 */
29
30 /*
31 * Machine-dependent defines for new kernel debugger.
32 */
33 #ifndef _PPC_DB_MACHDEP_H_
34 #define _PPC_DB_MACHDEP_H_
35
36 #include <uvm/uvm_prot.h>
37 #include <uvm/uvm_inherit.h>
38
39 #include <vm/vm_param.h>
40 #include <machine/trap.h>
41
42 #define DB_ELF_SYMBOLS
43 #define DB_ELFSIZE 32
44
45 typedef vaddr_t db_addr_t; /* address - unsigned */
46 typedef long db_expr_t; /* expression - signed */
47 struct powerpc_saved_state {
48 u_int32_t r[32]; /* data registers */
49 u_int32_t iar;
50 u_int32_t msr;
51 };
52 typedef struct powerpc_saved_state db_regs_t;
53 db_regs_t ddb_regs; /* register state */
54 #define DDB_REGS (&ddb_regs)
55
56 #define PC_REGS(regs) ((db_addr_t)(regs)->iar)
57
58 #define BKPT_INST 0x7C810808 /* breakpoint instruction */
59
60 #define BKPT_SIZE (4) /* size of breakpoint inst */
61 #define BKPT_SET(inst) (BKPT_INST)
62
63 #define FIXUP_PC_AFTER_BREAK(regs) ((regs)->iar -= 4)
64
65 #define SR_SINGLESTEP 0x400
66 #define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP)
67 #define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP)
68
69 #define T_BREAKPOINT 0xffff
70 #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
71
72 #define T_WATCHPOINT 0xeeee
73 #ifdef T_WATCHPOINT
74 #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT)
75 #else
76 #define IS_WATCHPOINT_TRAP(type, code) 0
77 #endif
78
79 #define M_RTS 0xfc0007fe
80 #define I_RTS 0x4c000020
81 #define M_BC 0xfc000000
82 #define I_BC 0x40000000
83 #define M_B 0xfc000000
84 #define I_B 0x50000000
85 #define M_RFI 0xfc0007fe
86 #define I_RFI 0x4c000064
87
88 #define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI)
89 #define inst_return(ins) (((ins)&M_RTS) == I_RTS)
90 #define inst_call(ins) (((ins)&M_BC ) == I_BC || \
91 ((ins)&M_B ) == I_B )
92 #define inst_load(ins) 0
93 #define inst_store(ins) 0
94
95 #ifdef _KERNEL
96
97 void kdb_kintr __P((void *));
98 int kdb_trap __P((int, void *));
99
100 #endif /* _KERNEL */
101
102 #endif /* _PPC_DB_MACHDEP_H_ */
103