| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: db_disasm.c,v 1.19 2023/11/21 22:19:12 thorpej Exp $ */ | | 1 | /* $NetBSD: db_disasm.c,v 1.20 2023/11/21 22:25:16 thorpej Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Mach Operating System | | 4 | * Mach Operating System |
5 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | | 5 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University |
6 | * All Rights Reserved. | | 6 | * All Rights Reserved. |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify and distribute this software and its | | 8 | * Permission to use, copy, modify and distribute this software and its |
9 | * documentation is hereby granted, provided that both the copyright | | 9 | * documentation is hereby granted, provided that both the copyright |
10 | * notice and this permission notice appear in all copies of the | | 10 | * notice and this permission notice appear in all copies of the |
11 | * software, derivative works or modified versions, and any portions | | 11 | * software, derivative works or modified versions, and any portions |
12 | * thereof, and that both notices appear in supporting documentation. | | 12 | * thereof, and that both notices appear in supporting documentation. |
13 | * | | 13 | * |
14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | | 14 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
| @@ -38,27 +38,27 @@ | | | @@ -38,27 +38,27 @@ |
38 | * Christopher G. Demetriou, Carnegie Mellon University | | 38 | * Christopher G. Demetriou, Carnegie Mellon University |
39 | * | | 39 | * |
40 | * Jason R. Thorpe, Numerical Aerospace Simulation Facility, | | 40 | * Jason R. Thorpe, Numerical Aerospace Simulation Facility, |
41 | * NASA Ames Research Center | | 41 | * NASA Ames Research Center |
42 | * | | 42 | * |
43 | * This code was derived exclusively from information available in | | 43 | * This code was derived exclusively from information available in |
44 | * "Alpha Architecture Reference Manual", Richard L. Sites ed. | | 44 | * "Alpha Architecture Reference Manual", Richard L. Sites ed. |
45 | * Digital Press, Burlington, MA 01803 | | 45 | * Digital Press, Burlington, MA 01803 |
46 | * ISBN 1-55558-098-X, Order no. EY-L520E-DP | | 46 | * ISBN 1-55558-098-X, Order no. EY-L520E-DP |
47 | */ | | 47 | */ |
48 | | | 48 | |
49 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 49 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
50 | | | 50 | |
51 | __KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.19 2023/11/21 22:19:12 thorpej Exp $"); | | 51 | __KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.20 2023/11/21 22:25:16 thorpej Exp $"); |
52 | | | 52 | |
53 | #include <sys/param.h> | | 53 | #include <sys/param.h> |
54 | #include <sys/systm.h> | | 54 | #include <sys/systm.h> |
55 | #include <sys/proc.h> | | 55 | #include <sys/proc.h> |
56 | #include <machine/db_machdep.h> | | 56 | #include <machine/db_machdep.h> |
57 | #include <machine/alpha_instruction.h> | | 57 | #include <machine/alpha_instruction.h> |
58 | | | 58 | |
59 | #include <machine/pal.h> | | 59 | #include <machine/pal.h> |
60 | | | 60 | |
61 | #include <ddb/db_access.h> | | 61 | #include <ddb/db_access.h> |
62 | #include <ddb/db_sym.h> | | 62 | #include <ddb/db_sym.h> |
63 | #include <ddb/db_output.h> | | 63 | #include <ddb/db_output.h> |
64 | #include <ddb/db_interface.h> | | 64 | #include <ddb/db_interface.h> |
| @@ -181,35 +181,35 @@ static const struct tbl pal_op_tbl[] = { | | | @@ -181,35 +181,35 @@ static const struct tbl pal_op_tbl[] = { |
181 | { "osf1_wrperfmon", PAL_OSF1_wrperfmon }, | | 181 | { "osf1_wrperfmon", PAL_OSF1_wrperfmon }, |
182 | { "osf1_rdusp", PAL_OSF1_rdusp }, | | 182 | { "osf1_rdusp", PAL_OSF1_rdusp }, |
183 | { "osf1_whami", PAL_OSF1_whami }, | | 183 | { "osf1_whami", PAL_OSF1_whami }, |
184 | { "osf1_retsys", PAL_OSF1_retsys }, | | 184 | { "osf1_retsys", PAL_OSF1_retsys }, |
185 | { "osf1_rti", PAL_OSF1_rti }, | | 185 | { "osf1_rti", PAL_OSF1_rti }, |
186 | { "osf1_callsys", PAL_OSF1_callsys }, | | 186 | { "osf1_callsys", PAL_OSF1_callsys }, |
187 | | | 187 | |
188 | { NULL, -1 }, | | 188 | { NULL, -1 }, |
189 | }; | | 189 | }; |
190 | | | 190 | |
191 | static const char * | | 191 | static const char * |
192 | pal_opname(int op) | | 192 | pal_opname(int op) |
193 | { | | 193 | { |
194 | static char unk[8]; | | 194 | static char unk[11]; |
195 | int i; | | 195 | int i; |
196 | | | 196 | |
197 | for (i = 0; pal_op_tbl[i].name != NULL; i++) { | | 197 | for (i = 0; pal_op_tbl[i].name != NULL; i++) { |
198 | if (pal_op_tbl[i].code == op) | | 198 | if (pal_op_tbl[i].code == op) |
199 | return (pal_op_tbl[i].name); | | 199 | return (pal_op_tbl[i].name); |
200 | } | | 200 | } |
201 | | | 201 | |
202 | snprintf(unk, sizeof(unk), "0x%x", op); | | 202 | snprintf(unk, sizeof(unk), "0x%08x", op); |
203 | return (unk); | | 203 | return (unk); |
204 | } | | 204 | } |
205 | | | 205 | |
206 | /* HW (PAL) instruction qualifiers, stright tables */ | | 206 | /* HW (PAL) instruction qualifiers, stright tables */ |
207 | static const char * const mXpr_name[8] = { | | 207 | static const char * const mXpr_name[8] = { |
208 | "", "/i", "/a", "/ai", "/p", "/pi", "/pa", "/pai" | | 208 | "", "/i", "/a", "/ai", "/p", "/pi", "/pa", "/pai" |
209 | }; | | 209 | }; |
210 | static const char * const hwlds_name[8] = { | | 210 | static const char * const hwlds_name[8] = { |
211 | "", "/r", "/a", "/ar", "/p", "/p?r", "_l-c", "_l-c/?r" | | 211 | "", "/r", "/a", "/ar", "/p", "/p?r", "_l-c", "_l-c/?r" |
212 | }; | | 212 | }; |
213 | | | 213 | |
214 | /* | | 214 | /* |
215 | * For this one we take the low nibble (valid values 0/2/9/b/d) | | 215 | * For this one we take the low nibble (valid values 0/2/9/b/d) |
| @@ -803,26 +803,29 @@ insn_printf(struct alpha_print_instructi | | | @@ -803,26 +803,29 @@ insn_printf(struct alpha_print_instructi |
803 | } else { | | 803 | } else { |
804 | db_vprintf(fmt, ap); | | 804 | db_vprintf(fmt, ap); |
805 | } | | 805 | } |
806 | | | 806 | |
807 | va_end(ap); | | 807 | va_end(ap); |
808 | } | | 808 | } |
809 | | | 809 | |
810 | /* | | 810 | /* |
811 | * Disassemble instruction at 'loc'. 'altfmt' specifies an | | 811 | * Disassemble instruction at 'loc'. 'altfmt' specifies an |
812 | * (optional) alternate format. Return address of start of | | 812 | * (optional) alternate format. Return address of start of |
813 | * next instruction. | | 813 | * next instruction. |
814 | */ | | 814 | */ |
815 | | | 815 | |
| | | 816 | #ifndef _KERNEL |
| | | 817 | static |
| | | 818 | #endif |
816 | int | | 819 | int |
817 | alpha_print_instruction(struct alpha_print_instruction_context *ctx) | | 820 | alpha_print_instruction(struct alpha_print_instruction_context *ctx) |
818 | { | | 821 | { |
819 | const char *opcode; | | 822 | const char *opcode; |
820 | long signed_immediate; | | 823 | long signed_immediate; |
821 | bool fstore; | | 824 | bool fstore; |
822 | pal_instruction p; | | 825 | pal_instruction p; |
823 | | | 826 | |
824 | fstore = false; | | 827 | fstore = false; |
825 | opcode = op_name[ctx->insn.mem_format.opcode]; | | 828 | opcode = op_name[ctx->insn.mem_format.opcode]; |
826 | | | 829 | |
827 | /* | | 830 | /* |
828 | * Dispatch directly on the opcode, save code | | 831 | * Dispatch directly on the opcode, save code |