Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/crash/arch crash(8): Add powerpc support.
details: https://anonhg.NetBSD.org/src/rev/292b7985b56b
branches: trunk
changeset: 374243:292b7985b56b
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Apr 12 17:53:32 2023 +0000
description:
crash(8): Add powerpc support.
XXX pullup-8
XXX pullup-9
XXX pullup-10
diffstat:
sys/arch/powerpc/powerpc/db_disasm.c | 150 +++++++++++++++-------------------
sys/arch/powerpc/powerpc/db_trace.c | 22 +++-
usr.sbin/crash/Makefile | 10 +-
usr.sbin/crash/arch/generic.c | 6 +-
usr.sbin/crash/arch/powerpc.c | 66 +++++++++++++++
usr.sbin/crash/arch/powerpc64.c | 1 +
usr.sbin/crash/crash.c | 8 +-
7 files changed, 166 insertions(+), 97 deletions(-)
diffs (truncated from 685 to 300 lines):
diff -r a8ed50258782 -r 292b7985b56b sys/arch/powerpc/powerpc/db_disasm.c
--- a/sys/arch/powerpc/powerpc/db_disasm.c Wed Apr 12 06:57:28 2023 +0000
+++ b/sys/arch/powerpc/powerpc/db_disasm.c Wed Apr 12 17:53:32 2023 +0000
@@ -1,14 +1,16 @@
-/* $NetBSD: db_disasm.c,v 1.29 2020/07/06 10:31:24 rin Exp $ */
+/* $NetBSD: db_disasm.c,v 1.30 2023/04/12 17:53:32 riastradh Exp $ */
/* $OpenBSD: db_disasm.c,v 1.2 1996/12/28 06:21:48 rahnds Exp $ */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.29 2020/07/06 10:31:24 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.30 2023/04/12 17:53:32 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ppcarch.h"
#endif
#include <sys/param.h>
+#include <sys/types.h>
+
#include <sys/proc.h>
#include <sys/systm.h>
@@ -84,8 +86,7 @@ typedef u_int32_t instr_t;
typedef void (op_class_func) (instr_t, vaddr_t);
u_int32_t extract_field(u_int32_t value, u_int32_t base, u_int32_t width);
-void disasm_fields(const struct opcode *popcode, instr_t instr, vaddr_t loc,
- char *disasm_str, size_t slen);
+void disasm_fields(const struct opcode *popcode, instr_t instr, vaddr_t loc);
void dis_ppc(const struct opcode *opcodeset, instr_t instr, vaddr_t loc);
op_class_func op_ill, op_base;
@@ -412,7 +413,7 @@ const struct opcode opcodes_3f[] = {
struct specialreg {
- int reg;
+ unsigned reg;
const char *name;
};
@@ -619,22 +620,9 @@ extract_field(u_int32_t value, u_int32_t
const struct opcode * search_op(const struct opcode *);
void
-disasm_fields(const struct opcode *popcode, instr_t instr, vaddr_t loc,
- char *disasm_str, size_t slen)
+disasm_fields(const struct opcode *popcode, instr_t instr, vaddr_t loc)
{
- char * pstr;
enum function_mask func;
- int len;
-
-#define ADD_LEN(s) do { \
- len = (s); \
- slen -= len; \
- pstr += len; \
- } while(0)
-#define APP_PSTR(fmt, arg) ADD_LEN(snprintf(pstr, slen, (fmt), (arg)))
-#define APP_PSTRS(fmt) ADD_LEN(snprintf(pstr, slen, "%s", (fmt)))
-
- pstr = disasm_str;
func = popcode->func;
if (func & Op_BC) {
@@ -646,12 +634,13 @@ disasm_fields(const struct opcode *popco
/* standard, no decrement */
if (BO & 16) {
if (popcode->code == 0x40000000) {
- APP_PSTRS("c");
+ db_printf("c");
func |= Op_BO | Op_BI;
}
}
else {
- APP_PSTRS(condstr[((BO & 8) >> 1) + (BI & 3)]);
+ db_printf("%s",
+ condstr[((BO & 8) >> 1) + (BI & 3)]);
if (BI >= 4)
func |= Op_crfS;
}
@@ -659,20 +648,20 @@ disasm_fields(const struct opcode *popco
else {
/* decrement and branch */
if (BO & 2)
- APP_PSTRS("dz");
+ db_printf("dz");
else
- APP_PSTRS("dnz");
+ db_printf("dnz");
if ((BO & 24) == 0)
- APP_PSTRS("f");
+ db_printf("f");
else if ((BO & 24) == 8)
- APP_PSTRS("t");
+ db_printf("t");
else
func |= Op_BI;
}
if (popcode->code == 0x4c000020)
- APP_PSTRS("lr");
+ db_printf("lr");
else if (popcode->code == 0x4c000420)
- APP_PSTRS("ctr");
+ db_printf("ctr");
if ((BO & 20) != 20 && (func & Op_BO) == 0)
func |= Op_BP; /* branch prediction hint */
}
@@ -680,26 +669,26 @@ disasm_fields(const struct opcode *popco
u_int OE;
OE = extract_field(instr, 31 - 21, 1);
if (OE) {
- APP_PSTRS("o");
+ db_printf("o");
}
func &= ~Op_OE;
}
switch (func & Op_LKM) {
case Op_Rc:
if (instr & 0x1)
- APP_PSTRS(".");
+ db_printf(".");
break;
case Op_AA:
if (instr & 0x1)
- APP_PSTRS("l");
+ db_printf("l");
if (instr & 0x2) {
- APP_PSTRS("a");
+ db_printf("a");
loc = 0; /* Absolute address */
}
break;
case Op_LK:
if (instr & 0x1)
- APP_PSTRS("l");
+ db_printf("l");
break;
default:
func &= ~Op_LKM;
@@ -716,91 +705,91 @@ disasm_fields(const struct opcode *popco
if ((vaddr_t)BD < loc)
y ^= 1;
}
- APP_PSTR("%c", y ? '+' : '-');
+ db_printf("%c", y ? '+' : '-');
func &= ~Op_BP;
}
- APP_PSTRS("\t");
+ db_printf("\t");
/* XXX: special cases here, out of flags in a 32bit word. */
if (strcmp(popcode->name, "wrteei") == 0) {
int E;
E = extract_field(instr, 31 - 16, 5);
- APP_PSTR("%d", E);
+ db_printf("%d", E);
return;
}
else if (strcmp(popcode->name, "mtfsfi") == 0) {
u_int UI;
UI = extract_field(instr, 31 - 8, 3);
- APP_PSTR("crf%u, ", UI);
+ db_printf("crf%u, ", UI);
UI = extract_field(instr, 31 - 19, 4);
- APP_PSTR("0x%x", UI);
+ db_printf("0x%x", UI);
}
/* XXX: end of special cases here. */
if ((func & Op_FM) == Op_FM) {
u_int FM;
FM = extract_field(instr, 31 - 14, 8);
- APP_PSTR("0x%x, ", FM);
+ db_printf("0x%x, ", FM);
func &= ~Op_FM;
}
if (func & Op_D) { /* Op_ST is the same */
u_int D;
D = extract_field(instr, 31 - 10, 5);
- APP_PSTR("r%d, ", D);
+ db_printf("r%d, ", D);
func &= ~Op_D;
}
if (func & Op_crbD) {
u_int crbD;
crbD = extract_field(instr, 31 - 10, 5);
- APP_PSTR("crb%d, ", crbD);
+ db_printf("crb%d, ", crbD);
func &= ~Op_crbD;
}
if (func & Op_crfD) {
u_int crfD;
crfD = extract_field(instr, 31 - 8, 3);
- APP_PSTR("crf%d, ", crfD);
+ db_printf("crf%d, ", crfD);
func &= ~Op_crfD;
}
if (func & Op_TO) {
u_int TO;
TO = extract_field(instr, 31 - 10, 1);
- APP_PSTR("%d, ", TO);
+ db_printf("%d, ", TO);
func &= ~Op_TO;
}
if (func & Op_crfS) {
u_int crfS;
crfS = extract_field(instr, 31 - 13, 3);
- APP_PSTR("crf%d, ", crfS);
+ db_printf("crf%d, ", crfS);
func &= ~Op_crfS;
}
if (func & Op_CRM) {
u_int CRM;
CRM = extract_field(instr, 31 - 19, 8);
- APP_PSTR("0x%x, ", CRM);
+ db_printf("0x%x, ", CRM);
func &= ~Op_CRM;
}
if (func & Op_BO) {
u_int BO;
BO = extract_field(instr, 31 - 10, 5);
- APP_PSTR("%d, ", BO);
+ db_printf("%d, ", BO);
func &= ~Op_BO;
}
if (func & Op_BI) {
u_int BI;
BI = extract_field(instr, 31 - 15, 5);
- APP_PSTR("%d, ", BI);
+ db_printf("%d, ", BI);
func &= ~Op_BI;
}
if (func & Op_dA) { /* register A indirect with displacement */
u_int A;
A = extract_field(instr, 31 - 31, 16);
if (A & 0x8000) {
- APP_PSTRS("-");
+ db_printf("-");
A = 0x10000-A;
}
- APP_PSTR("0x%x", A);
+ db_printf("0x%x", A);
A = extract_field(instr, 31 - 15, 5);
- APP_PSTR("(r%d)", A);
+ db_printf("(r%d)", A);
func &= ~Op_dA;
}
if (func & Op_spr) {
@@ -822,56 +811,56 @@ disasm_fields(const struct opcode *popco
if (spr == regs[i].reg)
break;
if (regs[i].name == NULL)
- APP_PSTR("[unknown special reg (%d)]", spr);
+ db_printf("[unknown special reg (%d)]", spr);
else
- APP_PSTR("%s", regs[i].name);
+ db_printf("%s", regs[i].name);
if (popcode->name[1] == 't') /* spr is destination */
- APP_PSTRS(", ");
+ db_printf(", ");
func &= ~Op_spr;
}
if (func & Op_SR) {
u_int SR;
SR = extract_field(instr, 31 - 15, 3);
- APP_PSTR("sr%d", SR);
+ db_printf("sr%d", SR);
if (popcode->name[1] == 't') /* SR is destination */
- APP_PSTRS(", ");
+ db_printf(", ");
func &= ~Op_SR;
}
if (func & Op_A) {
u_int A;
A = extract_field(instr, 31 - 15, 5);
- APP_PSTR("r%d, ", A);
+ db_printf("r%d, ", A);
func &= ~Op_A;
}
if (func & Op_S) {
u_int D;
D = extract_field(instr, 31 - 10, 5);
- APP_PSTR("r%d, ", D);
+ db_printf("r%d, ", D);
func &= ~Op_S;
}
if (func & Op_C) {
u_int C;
C = extract_field(instr, 31 - 25, 5);
- APP_PSTR("r%d, ", C);
+ db_printf("r%d, ", C);
func &= ~Op_C;
}
if (func & Op_B) {
u_int B;
B = extract_field(instr, 31 - 20, 5);
- APP_PSTR("r%d", B);
+ db_printf("r%d", B);
Home |
Main Index |
Thread Index |
Old Index