summaryrefslogtreecommitdiff
path: root/sys/arch/landisk
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-03-03 21:37:28 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-03-03 21:37:28 +0000
commit301ce3789c0dded4c40ebb4c1197dee00cf0fc3e (patch)
tree44351c56ccd077c95b601f112ad6c7c4d156911e /sys/arch/landisk
parent8f58ce59b66d35d5d484c5cfb9f5967571339ac9 (diff)
Kernel crash dumps and associated libkvm bits for landisk.
Diffstat (limited to 'sys/arch/landisk')
-rw-r--r--sys/arch/landisk/include/kcore.h1
-rw-r--r--sys/arch/landisk/landisk/autoconf.c8
-rw-r--r--sys/arch/landisk/landisk/machdep.c94
3 files changed, 89 insertions, 14 deletions
diff --git a/sys/arch/landisk/include/kcore.h b/sys/arch/landisk/include/kcore.h
new file mode 100644
index 00000000000..9aafa045767
--- /dev/null
+++ b/sys/arch/landisk/include/kcore.h
@@ -0,0 +1 @@
+#include <sh/kcore.h>
diff --git a/sys/arch/landisk/landisk/autoconf.c b/sys/arch/landisk/landisk/autoconf.c
index 3f99c61e347..7facbd1c6fc 100644
--- a/sys/arch/landisk/landisk/autoconf.c
+++ b/sys/arch/landisk/landisk/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.4 2006/11/06 19:42:52 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.5 2007/03/03 21:37:27 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -43,6 +43,7 @@
#include <dev/cons.h>
+#include <machine/cpu.h>
#include <machine/intr.h>
int cold = 1;
@@ -51,9 +52,6 @@ struct device *booted_device;
struct device *root_device;
void diskconf(void);
-#ifdef notyet
-void dumpconf(void);
-#endif
struct device *parsedisk(char *, int, int, dev_t *);
void setroot(void);
int findblkmajor(struct device *);
@@ -85,9 +83,7 @@ diskconf(void)
printf("boot device: %s\n",
booted_device ? booted_device->dv_xname : "<unknown>");
setroot();
-#ifdef notyet
dumpconf();
-#endif
}
static struct nam2blk {
diff --git a/sys/arch/landisk/landisk/machdep.c b/sys/arch/landisk/landisk/machdep.c
index cce14dadb6a..82a34ba864f 100644
--- a/sys/arch/landisk/landisk/machdep.c
+++ b/sys/arch/landisk/landisk/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.8 2007/02/06 23:13:37 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.9 2007/03/03 21:37:27 miod Exp $ */
/* $NetBSD: machdep.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -81,6 +81,9 @@
#include <sys/mount.h>
#include <sys/reboot.h>
#include <sys/sysctl.h>
+#include <sys/exec.h>
+#include <sys/core.h>
+#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
@@ -95,6 +98,7 @@
#include <sh/mmu_sh4.h>
#include <machine/cpu.h>
+#include <machine/kcore.h>
#include <landisk/landisk/landiskreg.h>
@@ -109,6 +113,7 @@ char machine[] = MACHINE; /* landisk */
__dead void landisk_startup(int, char *);
__dead void main(void);
+void cpu_init_kcore_hdr(void);
extern u_int32_t getramsize(void);
@@ -153,6 +158,7 @@ landisk_startup(int howto, char *_esym)
uvm_page_physload(atop(IOM_RAM_BEGIN),
atop(IOM_RAM_BEGIN + ramsize), kernend,
atop(IOM_RAM_BEGIN + ramsize), VM_FREELIST_DEFAULT);
+ cpu_init_kcore_hdr(); /* need to be done before pmap_bootstrap */
/* Initialize proc0 u-area */
sh_proc0_init();
@@ -193,7 +199,8 @@ boot(int howto)
{
if (cold) {
- howto |= RB_HALT;
+ if ((howto & RB_USERREQ) == 0)
+ howto |= RB_HALT;
goto haltsys;
}
@@ -204,19 +211,18 @@ boot(int howto)
* If we've been adjusting the clock, the todr
* will be out of synch; adjust it now.
*/
- resettodr();
+ if ((howto & RB_TIMEBAD) == 0)
+ resettodr();
+ else
+ printf("WARNING: not updating battery clock\n");
}
- /* wait 1s */
- delay(1 * 1000 * 1000);
-
/* Disable interrupts. */
splhigh();
/* Do a dump if requested. */
- if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP) {
+ if (howto & RB_DUMP)
dumpsys();
- }
haltsys:
doshutdownhooks();
@@ -225,6 +231,7 @@ haltsys:
_reg_write_1(LANDISK_PWRMNG, PWRMNG_POWEROFF);
delay(1 * 1000 * 1000);
printf("POWEROFF FAILED!\n");
+ howto |= RB_HALT;
}
if (howto & RB_HALT) {
@@ -376,3 +383,74 @@ InitializeBsc(void)
_reg_write_2(SH4_FRQCR, FRQCR_VAL);
}
#endif /* !DONT_INIT_BSC */
+
+/*
+ * Dump the machine-dependent dump header.
+ */
+u_int
+cpu_dump(int (*dump)(dev_t, daddr_t, caddr_t, size_t), daddr_t *blknop)
+{
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
+ char buf[dbtob(1)];
+ cpu_kcore_hdr_t *h;
+ kcore_seg_t *kseg;
+ int rc;
+
+#ifdef DIAGNOSTIC
+ if (cpu_dumpsize() > btodb(sizeof buf)) {
+ printf("buffer too small in cpu_dump, ");
+ return (EINVAL); /* "aborted" */
+ }
+#endif
+
+ bzero(buf, sizeof buf);
+ kseg = (kcore_seg_t *)buf;
+ h = (cpu_kcore_hdr_t *)(buf + ALIGN(sizeof(kcore_seg_t)));
+
+ /* Create the segment header */
+ CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
+ kseg->c_size = dbtob(1) - ALIGN(sizeof(kcore_seg_t));
+
+ bcopy(&cpu_kcore_hdr, h, sizeof(*h));
+ /* We can now fill kptp in the header... */
+ h->kcore_kptp = SH3_P1SEG_TO_PHYS((vaddr_t)pmap_kernel()->pm_ptp);
+
+ rc = (*dump)(dumpdev, *blknop, buf, sizeof buf);
+ *blknop += btodb(sizeof buf);
+ return (rc);
+}
+
+/*
+ * Return the size of the machine-dependent dump header, in disk blocks.
+ */
+u_int
+cpu_dumpsize()
+{
+ u_int size;
+
+ size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t));
+ return (btodb(roundup(size, dbtob(1))));
+}
+
+/*
+ * Fill the machine-dependent dump header.
+ */
+void
+cpu_init_kcore_hdr()
+{
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
+ cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
+ phys_ram_seg_t *seg = cpu_kcore_hdr.kcore_segs;
+ struct vm_physseg *physseg = vm_physmem;
+ u_int i;
+
+ bzero(h, sizeof(*h));
+
+ h->kcore_nsegs = min(NPHYS_RAM_SEGS, (u_int)vm_nphysseg);
+ for (i = h->kcore_nsegs; i != 0; i--) {
+ seg->start = ptoa(physseg->start);
+ seg->size = (psize_t)ptoa(physseg->end - physseg->start);
+ seg++;
+ physseg++;
+ }
+}