xref: /freebsd/sys/arm/arm/machdep_kdb.c (revision 0957b409)
1 /*	$NetBSD: arm32_machdep.c,v 1.44 2004/03/24 15:34:47 atatat Exp $	*/
2 
3 /*-
4  * Copyright (c) 2004 Olivier Houchard
5  * Copyright (c) 1994-1998 Mark Brinicombe.
6  * Copyright (c) 1994 Brini.
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 AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #include "opt_ddb.h"
32 
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35 
36 #include <sys/param.h>
37 #include <sys/proc.h>
38 #include <sys/systm.h>
39 
40 #include <machine/cpu.h>
41 #include <machine/reg.h>
42 
43 #ifdef DDB
44 #include <ddb/ddb.h>
45 
46 #if __ARM_ARCH >= 6
47 
48 DB_SHOW_COMMAND(cp15, db_show_cp15)
49 {
50 	u_int reg;
51 
52 	reg = cp15_midr_get();
53 	db_printf("Cpu ID: 0x%08x\n", reg);
54 	reg = cp15_ctr_get();
55 	db_printf("Current Cache Lvl ID: 0x%08x\n",reg);
56 
57 	reg = cp15_sctlr_get();
58 	db_printf("Ctrl: 0x%08x\n",reg);
59 	reg = cp15_actlr_get();
60 	db_printf("Aux Ctrl: 0x%08x\n",reg);
61 
62 	reg = cp15_id_pfr0_get();
63 	db_printf("Processor Feat 0: 0x%08x\n", reg);
64 	reg = cp15_id_pfr1_get();
65 	db_printf("Processor Feat 1: 0x%08x\n", reg);
66 	reg = cp15_id_dfr0_get();
67 	db_printf("Debug Feat 0: 0x%08x\n", reg);
68 	reg = cp15_id_afr0_get();
69 	db_printf("Auxiliary Feat 0: 0x%08x\n", reg);
70 	reg = cp15_id_mmfr0_get();
71 	db_printf("Memory Model Feat 0: 0x%08x\n", reg);
72 	reg = cp15_id_mmfr1_get();
73 	db_printf("Memory Model Feat 1: 0x%08x\n", reg);
74 	reg = cp15_id_mmfr2_get();
75 	db_printf("Memory Model Feat 2: 0x%08x\n", reg);
76 	reg = cp15_id_mmfr3_get();
77 	db_printf("Memory Model Feat 3: 0x%08x\n", reg);
78 	reg = cp15_ttbr_get();
79 	db_printf("TTB0: 0x%08x\n", reg);
80 }
81 
82 DB_SHOW_COMMAND(vtop, db_show_vtop)
83 {
84 	u_int reg;
85 
86 	if (have_addr) {
87 		cp15_ats1cpr_set(addr);
88 		reg = cp15_par_get();
89 		db_printf("Physical address reg: 0x%08x\n",reg);
90 	} else
91 		db_printf("show vtop <virt_addr>\n");
92 }
93 #endif /* __ARM_ARCH >= 6 */
94 #endif /* DDB */
95 
96 int
97 fill_regs(struct thread *td, struct reg *regs)
98 {
99 	struct trapframe *tf = td->td_frame;
100 	bcopy(&tf->tf_r0, regs->r, sizeof(regs->r));
101 	regs->r_sp = tf->tf_usr_sp;
102 	regs->r_lr = tf->tf_usr_lr;
103 	regs->r_pc = tf->tf_pc;
104 	regs->r_cpsr = tf->tf_spsr;
105 	return (0);
106 }
107 
108 int
109 fill_fpregs(struct thread *td, struct fpreg *regs)
110 {
111 	bzero(regs, sizeof(*regs));
112 	return (0);
113 }
114 
115 int
116 set_regs(struct thread *td, struct reg *regs)
117 {
118 	struct trapframe *tf = td->td_frame;
119 
120 	bcopy(regs->r, &tf->tf_r0, sizeof(regs->r));
121 	tf->tf_usr_sp = regs->r_sp;
122 	tf->tf_usr_lr = regs->r_lr;
123 	tf->tf_pc = regs->r_pc;
124 	tf->tf_spsr &=  ~PSR_FLAGS;
125 	tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS;
126 	return (0);
127 }
128 
129 int
130 set_fpregs(struct thread *td, struct fpreg *regs)
131 {
132 	return (0);
133 }
134 
135 int
136 fill_dbregs(struct thread *td, struct dbreg *regs)
137 {
138 
139 	bzero(regs, sizeof(*regs));
140 	return (0);
141 }
142 
143 int
144 set_dbregs(struct thread *td, struct dbreg *regs)
145 {
146 	return (0);
147 }
148