Mon Mar 29 03:07:33 2021 UTC ()
Move the cpu_reset_address() declaration inside #ifdef _KERNEL, add a
comment.


(simonb)
diff -r1.35 -r1.36 src/sys/arch/mips/include/db_machdep.h

cvs diff -r1.35 -r1.36 src/sys/arch/mips/include/db_machdep.h (switch to unified diff)

--- src/sys/arch/mips/include/db_machdep.h 2021/03/29 03:03:48 1.35
+++ src/sys/arch/mips/include/db_machdep.h 2021/03/29 03:07:33 1.36
@@ -1,144 +1,149 @@ @@ -1,144 +1,149 @@
1/* $NetBSD: db_machdep.h,v 1.35 2021/03/29 03:03:48 simonb Exp $ */ 1/* $NetBSD: db_machdep.h,v 1.36 2021/03/29 03:07:33 simonb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author) 4 * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software 15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement: 16 * must display the following acknowledgement:
17 * This product includes software developed by Jonathan Stone for 17 * This product includes software developed by Jonathan Stone for
18 * the NetBSD Project. 18 * the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products 19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission. 20 * derived from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34#ifndef _MIPS_DB_MACHDEP_H_ 34#ifndef _MIPS_DB_MACHDEP_H_
35#define _MIPS_DB_MACHDEP_H_ 35#define _MIPS_DB_MACHDEP_H_
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/stdbool.h> 38#include <sys/stdbool.h>
39 39
40#include <uvm/uvm_param.h> /* XXX boolean_t */ 40#include <uvm/uvm_param.h> /* XXX boolean_t */
41 41
42#include <mips/trap.h> /* T_BREAK */ 42#include <mips/trap.h> /* T_BREAK */
43#include <mips/reg.h> /* register state */ 43#include <mips/reg.h> /* register state */
44#include <mips/regnum.h> /* symbolic register indices */ 44#include <mips/regnum.h> /* symbolic register indices */
45#include <mips/pcb.h> 45#include <mips/pcb.h>
46 46
47#define DB_ELF_SYMBOLS 47#define DB_ELF_SYMBOLS
48 48
49typedef vaddr_t db_addr_t; /* address - unsigned */ 49typedef vaddr_t db_addr_t; /* address - unsigned */
50#ifdef __mips_n32 50#ifdef __mips_n32
51#define DDB_EXPR_FMT "ll" /* expression is long long */ 51#define DDB_EXPR_FMT "ll" /* expression is long long */
52typedef int64_t db_expr_t; /* expression - signed */ 52typedef int64_t db_expr_t; /* expression - signed */
53#else 53#else
54#define DDB_EXPR_FMT "l" /* expression is long */ 54#define DDB_EXPR_FMT "l" /* expression is long */
55typedef long db_expr_t; /* expression - signed */ 55typedef long db_expr_t; /* expression - signed */
56#endif 56#endif
57 57
58typedef struct reg db_regs_t; 58typedef struct reg db_regs_t;
59 59
60extern db_regs_t ddb_regs; /* register state */ 60extern db_regs_t ddb_regs; /* register state */
61#define DDB_REGS (&ddb_regs) 61#define DDB_REGS (&ddb_regs)
62 62
63#define PC_REGS(regs) ((regs)->r_regs[_R_PC]) 63#define PC_REGS(regs) ((regs)->r_regs[_R_PC])
64 64
65#define PC_ADVANCE(regs) do { \ 65#define PC_ADVANCE(regs) do { \
66 if ((db_get_value((regs)->r_regs[_R_PC], sizeof(int), false) &\ 66 if ((db_get_value((regs)->r_regs[_R_PC], sizeof(int), false) &\
67 0xfc00003f) == 0xd) \ 67 0xfc00003f) == 0xd) \
68 (regs)->r_regs[_R_PC] += BKPT_SIZE; \ 68 (regs)->r_regs[_R_PC] += BKPT_SIZE; \
69} while(0) 69} while(0)
70 70
71/* Similar to PC_ADVANCE(), except only advance on cpu_Debugger()'s bpt */ 71/* Similar to PC_ADVANCE(), except only advance on cpu_Debugger()'s bpt */
72#define PC_BREAK_ADVANCE(regs) do { \ 72#define PC_BREAK_ADVANCE(regs) do { \
73 if (db_get_value((regs)->r_regs[_R_PC], sizeof(int), false) == 0xd) \ 73 if (db_get_value((regs)->r_regs[_R_PC], sizeof(int), false) == 0xd) \
74 (regs)->r_regs[_R_PC] += BKPT_SIZE; \ 74 (regs)->r_regs[_R_PC] += BKPT_SIZE; \
75} while(0) 75} while(0)
76 76
77#define BKPT_ADDR(addr) (addr) /* breakpoint address */ 77#define BKPT_ADDR(addr) (addr) /* breakpoint address */
78#define BKPT_INST 0x0001000D 78#define BKPT_INST 0x0001000D
79#define BKPT_SIZE (4) /* size of breakpoint inst */ 79#define BKPT_SIZE (4) /* size of breakpoint inst */
80#define BKPT_SET(inst, addr) (BKPT_INST) 80#define BKPT_SET(inst, addr) (BKPT_INST)
81 81
82#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAK) 82#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAK)
83#define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX mips3 watchpoint */ 83#define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX mips3 watchpoint */
84 84
85/* 85/*
86 * Interface to disassembly (shared with mdb) 86 * Interface to disassembly (shared with mdb)
87 */ 87 */
88db_addr_t db_disasm_insn(int insn, db_addr_t loc, bool altfmt); 88db_addr_t db_disasm_insn(int insn, db_addr_t loc, bool altfmt);
89 89
90/* 90/*
91 * Entrypoints to DDB for kernel, keyboard drivers, init hook 91 * Entrypoints to DDB for kernel, keyboard drivers, init hook
92 */ 92 */
93void kdb_kbd_trap(db_regs_t *); 93void kdb_kbd_trap(db_regs_t *);
94int kdb_trap(int type, struct reg *); 94int kdb_trap(int type, struct reg *);
95 95
96static inline void 96static inline void
97db_set_ddb_regs(int type, struct reg *regs) 97db_set_ddb_regs(int type, struct reg *regs)
98{ 98{
99 ddb_regs = *regs; 99 ddb_regs = *regs;
100} 100}
101 101
102 102
103/* 103/*
104 * Constants for KGDB. 104 * Constants for KGDB.
105 */ 105 */
106typedef mips_reg_t kgdb_reg_t; 106typedef mips_reg_t kgdb_reg_t;
107#define KGDB_NUMREGS 90 107#define KGDB_NUMREGS 90
108#define KGDB_BUFLEN 1024 108#define KGDB_BUFLEN 1024
109 109
110/* 110/*
111 * MIPS cpus have no hardware single-step. 111 * MIPS cpus have no hardware single-step.
112 */ 112 */
113#define SOFTWARE_SSTEP 113#define SOFTWARE_SSTEP
114 114
115#define inst_trap_return(ins) ((ins)&0) 115#define inst_trap_return(ins) ((ins)&0)
116 116
117bool inst_branch(int inst); 117bool inst_branch(int inst);
118bool inst_call(int inst); 118bool inst_call(int inst);
119bool inst_return(int inst); 119bool inst_return(int inst);
120bool inst_load(int inst); 120bool inst_load(int inst);
121bool inst_store(int inst); 121bool inst_store(int inst);
122bool inst_unconditional_flow_transfer(int inst); 122bool inst_unconditional_flow_transfer(int inst);
123db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs); 123db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
124db_addr_t next_instr_address(db_addr_t pc, bool bd); 124db_addr_t next_instr_address(db_addr_t pc, bool bd);
125 125
126bool ddb_running_on_this_cpu_p(void); 126bool ddb_running_on_this_cpu_p(void);
127bool ddb_running_on_any_cpu_p(void); 127bool ddb_running_on_any_cpu_p(void);
128void db_resume_others(void); 128void db_resume_others(void);
129void db_mips_stack_trace(void *, void *, void (*pr)(const char *, ...)); 129void db_mips_stack_trace(void *, void *, void (*pr)(const char *, ...));
130 130
131extern void (*cpu_reset_address)(void); 
132 131
133#ifdef _KERNEL 132#ifdef _KERNEL
134/* 133/*
 134 * Optional function to perform machine- or cpu-specific reset.
 135 * Called from ddb "machine reset".
 136 */
 137extern void (*cpu_reset_address)(void);
 138
 139/*
135 * We have machine-dependent commands. 140 * We have machine-dependent commands.
136 */ 141 */
137#define DB_MACHINE_COMMANDS 142#define DB_MACHINE_COMMANDS
138#endif 143#endif
139 144
140#define db_stacktrace_print(prfunc) \ 145#define db_stacktrace_print(prfunc) \
141 db_mips_stack_trace(__builtin_return_address(0), \ 146 db_mips_stack_trace(__builtin_return_address(0), \
142 __builtin_frame_address(0), prfunc) 147 __builtin_frame_address(0), prfunc)
143 148
144#endif /* _MIPS_DB_MACHDEP_H_ */ 149#endif /* _MIPS_DB_MACHDEP_H_ */