Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips port crash(8) to mips. (most of the kernel si...
details: https://anonhg.NetBSD.org/src/rev/5493dfc48686
branches: trunk
changeset: 974930:5493dfc48686
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Aug 17 03:19:35 2020 +0000
description:
port crash(8) to mips. (most of the kernel side.)
- expose parts of _KERNEL to _KMEMUSER as well
- hide more things for _KERNEL
- avoid DB_MACHINE_COMMANDS in crash(8)
- XXX add mips_label_t for !_KERNEL and use it in the pcb to
avoid conflicting with the ddb/crash one
- enable dumppcb
some changes to make stack trace fail instead of SEGV and
the userland changes to crash itself not part of this change.
diffstat:
sys/arch/mips/include/cpu.h | 8 ++++++--
sys/arch/mips/include/db_machdep.h | 8 +++++++-
sys/arch/mips/include/locore.h | 6 +++---
sys/arch/mips/include/mips3_pte.h | 4 +++-
sys/arch/mips/include/pcb.h | 4 ++--
sys/arch/mips/include/pmap.h | 3 ++-
sys/arch/mips/include/types.h | 10 +++++++++-
sys/arch/mips/mips/db_interface.c | 10 ++++++++--
sys/arch/mips/mips/mips_stacktrace.c | 21 ++++++++++++++-------
9 files changed, 54 insertions(+), 20 deletions(-)
diffs (truncated from 320 to 300 lines):
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/cpu.h
--- a/sys/arch/mips/include/cpu.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/cpu.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.130 2020/08/09 06:26:49 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.131 2020/08/17 03:19:35 mrg Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#error Use assym.h to get definitions from <mips/cpu.h>
#endif
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(_KMEMUSER)
#if defined(_KERNEL_OPT)
#include "opt_cputype.h"
@@ -57,6 +57,7 @@
#include <sys/device_if.h>
#include <sys/evcnt.h>
#include <sys/kcpuset.h>
+#include <sys/intr.h>
typedef struct cpu_watchpoint {
register_t cw_addr;
@@ -158,6 +159,9 @@
#endif
};
+#endif /* _KERNEL || _KMEMUSER */
+
+#ifdef _KERNEL
#ifdef MULTIPROCESSOR
#define CPU_INFO_ITERATOR int
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/db_machdep.h
--- a/sys/arch/mips/include/db_machdep.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/db_machdep.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.32 2020/07/26 08:08:41 simonb Exp $ */
+/* $NetBSD: db_machdep.h,v 1.33 2020/08/17 03:19:35 mrg Exp $ */
/*
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -34,7 +34,11 @@
#ifndef _MIPS_DB_MACHDEP_H_
#define _MIPS_DB_MACHDEP_H_
+#include <sys/types.h>
+#include <sys/stdbool.h>
+
#include <uvm/uvm_param.h> /* XXX boolean_t */
+
#include <mips/trap.h> /* T_BREAK */
#include <mips/reg.h> /* register state */
#include <mips/regnum.h> /* symbolic register indices */
@@ -126,9 +130,11 @@
extern void (*cpu_reset_address)(void);
+#ifdef _KERNEL
/*
* We have machine-dependent commands.
*/
#define DB_MACHINE_COMMANDS
+#endif
#endif /* _MIPS_DB_MACHDEP_H_ */
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/locore.h
--- a/sys/arch/mips/include/locore.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/locore.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.114 2020/08/15 07:42:07 mrg Exp $ */
+/* $NetBSD: locore.h,v 1.115 2020/08/17 03:19:35 mrg Exp $ */
/*
* This file should not be included by MI code!!!
@@ -95,6 +95,7 @@
/* XXX some .S files look for MIPS3_PLUS */
#ifndef __ASSEMBLER__
+#ifdef _KERNEL
/* XXX simonb
* Should the following be in a cpu_info type structure?
@@ -753,7 +754,6 @@
#define MIPS_PRID_CID_INGENIC 0xe1
#define MIPS_PRID_COPTS(x) (((x) >> 24) & 0x00ff) /* Company Options */
-#ifdef _KERNEL
/*
* Global variables used to communicate CPU type, and parameters
* such as cache size, from locore to higher-level code (e.g., pmap).
@@ -917,7 +917,7 @@
# define MIPS_CIDFL_RMI_L2SZ(cidfl) \
((256*1024) << (((cidfl) & MIPS_CIDFL_RMI_L2SZ_MASK) \
>> MIPS_CIDFL_RMI_L2SZ_SHIFT))
+#endif /* _KERNEL */
#endif /* !__ASSEMBLER__ */
-#endif /* _KERNEL */
#endif /* _MIPS_LOCORE_H */
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/mips3_pte.h
--- a/sys/arch/mips/include/mips3_pte.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/mips3_pte.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips3_pte.h,v 1.30 2020/07/26 08:08:41 simonb Exp $ */
+/* $NetBSD: mips3_pte.h,v 1.31 2020/08/17 03:19:35 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -174,6 +174,7 @@
#define MIPS3_PG_SIZE_64M 0x07ffe000
#define MIPS3_PG_SIZE_256M 0x1fffe000
+#ifdef _KERNEL
#define MIPS3_PG_SIZE_MASK_TO_SIZE(pg_mask) \
((((pg_mask) | 0x00001fff) + 1) / 2)
@@ -182,6 +183,7 @@
CTASSERT(MIPS3_PG_SIZE_TO_MASK(4096) == MIPS3_PG_SIZE_4K);
CTASSERT(MIPS3_PG_SIZE_TO_MASK(8192) == MIPS3_PG_SIZE_4K);
+#endif
/* NEC Vr41xx uses different pagemask values. */
#define MIPS4100_PG_SIZE_1K 0x00000000
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/pcb.h
--- a/sys/arch/mips/include/pcb.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/pcb.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.24 2011/08/16 06:58:15 matt Exp $ */
+/* $NetBSD: pcb.h,v 1.25 2020/08/17 03:19:35 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -56,7 +56,7 @@
* MIPS process control block
*/
struct pcb {
- label_t pcb_context; /* kernel context for resume */
+ mips_label_t pcb_context; /* kernel context for resume */
void * pcb_onfault; /* for copyin/copyout faults */
uint32_t pcb_ppl; /* previous priority level */
struct fpreg pcb_fpregs; /* saved floating point registers */
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/pmap.h
--- a/sys/arch/mips/include/pmap.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/pmap.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.73 2020/08/07 07:19:45 skrll Exp $ */
+/* $NetBSD: pmap.h,v 1.74 2020/08/17 03:19:35 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -175,6 +175,7 @@
#define PMAP_SEGTABSIZE (1 << (31 - SEGSHIFT))
#endif
+#include <uvm/uvm_pmap.h>
#include <uvm/pmap/vmpagemd.h>
#include <uvm/pmap/pmap.h>
#include <uvm/pmap/pmap_tlb.h>
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/include/types.h
--- a/sys/arch/mips/include/types.h Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/include/types.h Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.71 2020/07/30 06:54:07 skrll Exp $ */
+/* $NetBSD: types.h,v 1.72 2020/08/17 03:19:35 mrg Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -115,9 +115,17 @@
#define PRIxUREGISTER PRIx64
#endif /* __mips_o32 */
+#if defined(_KMEMUSER)
+typedef struct mips_label_t {
+ register_t val[14];
+} mips_label_t;
+#else
typedef struct label_t {
register_t val[14];
} label_t;
+typedef label_t mips_label_t;
+#endif
+
#define _L_S0 0
#define _L_S1 1
#define _L_S2 2
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/mips/db_interface.c
--- a/sys/arch/mips/mips/db_interface.c Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/mips/db_interface.c Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.89 2020/08/15 07:42:07 mrg Exp $ */
+/* $NetBSD: db_interface.c,v 1.90 2020/08/17 03:19:35 mrg Exp $ */
/*
* Mach Operating System
@@ -27,12 +27,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.89 2020/08/15 07:42:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.90 2020/08/17 03:19:35 mrg Exp $");
+#ifdef _KERNEL_OPT
#include "opt_multiprocessor.h"
#include "opt_cputype.h" /* which mips CPUs do we support? */
#include "opt_ddb.h"
#include "opt_kgdb.h"
+#endif
#define __PMAP_PRIVATE
@@ -57,6 +59,7 @@
#include <machine/int_fmtio.h>
#include <machine/db_machdep.h>
#include <ddb/db_access.h>
+#include <ddb/db_user.h>
#ifndef KGDB
#include <ddb/db_command.h>
#include <ddb/db_output.h>
@@ -92,6 +95,7 @@
paddr_t kvtophys(vaddr_t);
+#ifdef _KERNEL
CTASSERT(sizeof(ddb_regs) == sizeof(struct reg));
#ifndef KGDB
@@ -1041,3 +1045,5 @@
}
}
#endif /* MULTIPROCESSOR */
+
+#endif /* _KERNEL */
diff -r 66183c53f0c9 -r 5493dfc48686 sys/arch/mips/mips/mips_stacktrace.c
--- a/sys/arch/mips/mips/mips_stacktrace.c Mon Aug 17 03:14:08 2020 +0000
+++ b/sys/arch/mips/mips/mips_stacktrace.c Mon Aug 17 03:19:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_stacktrace.c,v 1.1 2020/08/15 07:42:07 mrg Exp $ */
+/* $NetBSD: mips_stacktrace.c,v 1.2 2020/08/17 03:19:35 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mips_stacktrace.c,v 1.1 2020/08/15 07:42:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_stacktrace.c,v 1.2 2020/08/17 03:19:35 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -59,6 +59,7 @@
#include <machine/db_machdep.h>
#include <ddb/db_sym.h>
#endif
+#include <ddb/db_user.h>
#ifdef KGDB
#include <sys/kgdb.h>
@@ -122,7 +123,8 @@
* Functions ``special'' enough to print by name
*/
#define Name(_fn) { (void*)_fn, # _fn }
-const static struct { void *addr; const char *name;} names[] = {
+static const struct { void *addr; const char *name;} names[] = {
+#ifdef _KERNEL
Name(stacktrace),
Name(stacktrace_subr),
Name(main),
@@ -178,12 +180,13 @@
Name(cpu_idle),
Name(cpu_switchto),
+#endif /* _KERNEL */
{0, 0}
};
-bool
-static kdbpeek(vaddr_t addr, int *valp)
+static bool
+kdbpeek(vaddr_t addr, unsigned *valp)
{
if (addr & 3) {
printf("kdbpeek: unaligned address %#"PRIxVADDR"\n", addr);
@@ -193,7 +196,7 @@
printf("kdbpeek: NULL\n");
return false;
} else {
- *valp = *(int *)addr;
+ *valp = *(unsigned *)addr;
return true;
}
}
@@ -312,7 +315,7 @@
sym = db_search_symbol(pc, DB_STGY_ANY, &diff);
Home |
Main Index |
Thread Index |
Old Index