summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-05-19 15:49:07 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-05-19 15:49:07 +0000
commit55effb9ba5d36fabab2ee9010d12cba4ce97f7ab (patch)
tree9f72f6739eed57055aad3e02023fabf3ecd7de93 /sys/arch/arm
parent912729879adc44cafe45c930dcbb3a9ffb07ea0e (diff)
Kernel crash dump support for arm-based platform, with minimal support in
libkvm, but all the necessary information for a complete _kvm_kvatop() is available in the crash dump.
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/arm/stubs.c47
-rw-r--r--sys/arch/arm/include/kcore.h15
2 files changed, 52 insertions, 10 deletions
diff --git a/sys/arch/arm/arm/stubs.c b/sys/arch/arm/arm/stubs.c
index 6e91e149e40..5d595a7568d 100644
--- a/sys/arch/arm/arm/stubs.c
+++ b/sys/arch/arm/arm/stubs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stubs.c,v 1.2 2004/02/01 06:10:33 drahn Exp $ */
+/* $OpenBSD: stubs.c,v 1.3 2007/05/19 15:49:05 miod Exp $ */
/* $NetBSD: stubs.c,v 1.14 2003/07/15 00:24:42 lukem Exp $ */
/*
@@ -47,11 +47,15 @@
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/msgbuf.h>
+#include <sys/exec.h>
+#include <sys/core.h>
+#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
+#include <machine/bootconfig.h>
#include <machine/cpu.h>
#include <machine/intr.h>
-#include <machine/bootconfig.h>
#include <machine/pcb.h>
+#include <arm/kcore.h>
#include <arm/machdep.h>
extern dev_t dumpdev;
@@ -62,7 +66,7 @@ extern dev_t dumpdev;
u_int32_t dumpmag = 0x8fca0101; /* magic number */
int dumpsize = 0; /* pages */
long dumplo = 0; /* blocks */
-
+cpu_kcore_hdr_t cpu_kcore_hdr;
struct pcb dumppcb;
/*
@@ -79,7 +83,7 @@ void
dumpconf()
{
const struct bdevsw *bdev;
- int nblks; /* size of dump area */
+ int block, nblks;
if (dumpdev == NODEV)
return;
@@ -99,10 +103,17 @@ dumpconf()
dumplo = ctod(1);
/* Put dump at end of partition, and make it fit. */
- if (dumpsize > dtoc(nblks - dumplo))
- dumpsize = dtoc(nblks - dumplo);
- if (dumplo < nblks - ctod(dumpsize))
- dumplo = nblks - ctod(dumpsize);
+ if (dumpsize + 1 > dtoc(nblks - dumplo))
+ dumpsize = dtoc(nblks - dumplo) - 1;
+ if (dumplo < nblks - ctod(dumpsize) - 1)
+ dumplo = nblks - ctod(dumpsize) - 1;
+
+ for (block = 0; block < bootconfig.dramblocks; block++) {
+ cpu_kcore_hdr.ram_segs[block].start =
+ bootconfig.dram[block].address;
+ cpu_kcore_hdr.ram_segs[block].size =
+ ptoa(bootconfig.dram[block].pages);
+ }
}
/* This should be moved to machdep.c */
@@ -126,6 +137,9 @@ dumpsys()
int block;
int len;
vaddr_t dumpspace;
+ kcore_seg_t *kseg_p;
+ cpu_kcore_hdr_t *chdr_p;
+ char dump_hdr[dbtob(1)]; /* assumes header fits in one block */
/* Save registers. */
savectx(&dumppcb);
@@ -160,9 +174,21 @@ dumpsys()
return;
}
- error = 0;
- len = 0;
+ /* Setup the dump header */
+ kseg_p = (kcore_seg_t *)dump_hdr;
+ chdr_p = (cpu_kcore_hdr_t *)&dump_hdr[ALIGN(sizeof(*kseg_p))];
+ bzero(dump_hdr, sizeof(dump_hdr));
+
+ CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
+ kseg_p->c_size = sizeof(dump_hdr) - ALIGN(sizeof(*kseg_p));
+ *chdr_p = cpu_kcore_hdr;
+ error = (*bdev->d_dump)(dumpdev, blkno++, (caddr_t)dump_hdr,
+ sizeof(dump_hdr));
+ if (error != 0)
+ goto abort;
+
+ len = 0;
for (block = 0; block < bootconfig.dramblocks && error == 0; ++block) {
addr = bootconfig.dram[block].address;
for (;addr < (bootconfig.dram[block].address
@@ -183,6 +209,7 @@ dumpsys()
}
}
+abort:
switch (error) {
case ENXIO:
printf("device bad\n");
diff --git a/sys/arch/arm/include/kcore.h b/sys/arch/arm/include/kcore.h
new file mode 100644
index 00000000000..02050490bbc
--- /dev/null
+++ b/sys/arch/arm/include/kcore.h
@@ -0,0 +1,15 @@
+/* $OpenBSD: kcore.h,v 1.1 2007/05/19 15:49:05 miod Exp $ */
+/* public domain */
+
+/* Make sure this is larger than DRAM_BLOCKS on all arm-based platforms */
+#define NPHYS_RAM_SEGS 8
+
+typedef struct cpu_kcore_hdr {
+ u_int32_t kernelbase; /* value of KERNEL_BASE */
+ u_int32_t kerneloffs; /* offset of kernel in RAM */
+ u_int32_t staticsize; /* size of contiguous mapping */
+ u_int32_t pmap_kernel_l1; /* pmap_kernel()->pm_l1 */
+ u_int32_t pmap_kernel_l2; /* pmap_kernel()->pm_l2 */
+ u_int32_t reserved[11];
+ phys_ram_seg_t ram_segs[NPHYS_RAM_SEGS];
+} cpu_kcore_hdr_t;