summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorgallatin <gallatin@FreeBSD.org>2002-05-11 21:53:46 +0000
committergallatin <gallatin@FreeBSD.org>2002-05-11 21:53:46 +0000
commit475814a8e21d201663c75979c687c04eb795070b (patch)
tree9a924e41cfac51c3dfff693a5b2fea968b5be2a8 /sys
parent4daf43a4a40405027bad81aa4cfe171ef365f208 (diff)
downloadFreeBSD-src-475814a8e21d201663c75979c687c04eb795070b.zip
FreeBSD-src-475814a8e21d201663c75979c687c04eb795070b.tar.gz
Restore the ability to take crashdumps on alpha. This was cut and pasted
nearly in its entirety from i386, so it retains the phk/nati copyright. Savecore likes the results, but I have no way to test it as gdb is still broken.
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/alphadump.c116
-rw-r--r--sys/alpha/alpha/dump_machdep.c116
-rw-r--r--sys/conf/files.alpha1
-rw-r--r--sys/sys/kerneldump.h1
4 files changed, 234 insertions, 0 deletions
diff --git a/sys/alpha/alpha/alphadump.c b/sys/alpha/alpha/alphadump.c
new file mode 100644
index 0000000..aff1594
--- /dev/null
+++ b/sys/alpha/alpha/alphadump.c
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/kerneldump.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <machine/md_var.h>
+
+CTASSERT(sizeof(struct kerneldumpheader) == 512);
+
+static struct kerneldumpheader kdh;
+
+void
+dumpsys(struct dumperinfo *di)
+{
+ off_t dumplo;
+ vm_offset_t a, addr;
+ u_int count, left, u;
+ void *va;
+ int i, mb;
+
+ printf("Dumping %u MB\n", Maxmem / (1024*1024 / PAGE_SIZE));
+
+ /* Fill in the kernel dump header */
+ strcpy(kdh.magic, KERNELDUMPMAGIC);
+ strcpy(kdh.architecture, "alpha");
+ kdh.version = htod32(KERNELDUMPVERSION);
+ kdh.architectureversion = htod32(KERNELDUMP_ALPHA_VERSION);
+ kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
+ kdh.dumptime = htod64(time_second);
+ kdh.blocksize = htod32(di->blocksize);
+ strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
+ strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
+ if (panicstr != NULL)
+ strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
+ kdh.parity = kerneldump_parity(&kdh);
+
+ dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
+ dumplo -= sizeof kdh * 2;
+ i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
+ if (i)
+ printf("\nDump failed writing header (%d)\n", i);
+ dumplo += sizeof kdh;
+ i = 0;
+ addr = 0;
+ va = 0;
+ mb = 0;
+ for (count = 0; count < Maxmem;) {
+ left = Maxmem - count;
+ if (left > MAXDUMPPGS)
+ left = MAXDUMPPGS;
+ for (u = 0; u < left; u++) {
+ a = addr + u * PAGE_SIZE;
+ if (!is_physical_memory(a))
+ a = 0;
+ va = pmap_kenter_temporary(trunc_page(a), u);
+ }
+ i = count / (16*1024*1024 / PAGE_SIZE);
+ if (i != mb) {
+ printf(" %d", count / (1024 * 1024 / PAGE_SIZE));
+ mb = i;
+ }
+ i = di->dumper(di->priv, va, NULL, dumplo, left * PAGE_SIZE);
+ if (i)
+ break;
+ count += left;
+ dumplo += left * PAGE_SIZE;
+ addr += left * PAGE_SIZE;
+ }
+ if (i)
+ printf("\nDump failed writing data (%d)\n", i);
+ i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
+ if (i)
+ printf("\nDump failed writing trailer (%d)\n", i);
+ di->dumper(di->priv, NULL, NULL, 0, 0); /* tell them we are done */
+ printf("\nDump complete\n");
+ return;
+}
diff --git a/sys/alpha/alpha/dump_machdep.c b/sys/alpha/alpha/dump_machdep.c
new file mode 100644
index 0000000..aff1594
--- /dev/null
+++ b/sys/alpha/alpha/dump_machdep.c
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2002 Poul-Henning Kamp
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Poul-Henning Kamp
+ * and NAI Labs, the Security Research Division of Network Associates, Inc.
+ * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
+ * DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/kerneldump.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <machine/md_var.h>
+
+CTASSERT(sizeof(struct kerneldumpheader) == 512);
+
+static struct kerneldumpheader kdh;
+
+void
+dumpsys(struct dumperinfo *di)
+{
+ off_t dumplo;
+ vm_offset_t a, addr;
+ u_int count, left, u;
+ void *va;
+ int i, mb;
+
+ printf("Dumping %u MB\n", Maxmem / (1024*1024 / PAGE_SIZE));
+
+ /* Fill in the kernel dump header */
+ strcpy(kdh.magic, KERNELDUMPMAGIC);
+ strcpy(kdh.architecture, "alpha");
+ kdh.version = htod32(KERNELDUMPVERSION);
+ kdh.architectureversion = htod32(KERNELDUMP_ALPHA_VERSION);
+ kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
+ kdh.dumptime = htod64(time_second);
+ kdh.blocksize = htod32(di->blocksize);
+ strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
+ strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
+ if (panicstr != NULL)
+ strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
+ kdh.parity = kerneldump_parity(&kdh);
+
+ dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
+ dumplo -= sizeof kdh * 2;
+ i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
+ if (i)
+ printf("\nDump failed writing header (%d)\n", i);
+ dumplo += sizeof kdh;
+ i = 0;
+ addr = 0;
+ va = 0;
+ mb = 0;
+ for (count = 0; count < Maxmem;) {
+ left = Maxmem - count;
+ if (left > MAXDUMPPGS)
+ left = MAXDUMPPGS;
+ for (u = 0; u < left; u++) {
+ a = addr + u * PAGE_SIZE;
+ if (!is_physical_memory(a))
+ a = 0;
+ va = pmap_kenter_temporary(trunc_page(a), u);
+ }
+ i = count / (16*1024*1024 / PAGE_SIZE);
+ if (i != mb) {
+ printf(" %d", count / (1024 * 1024 / PAGE_SIZE));
+ mb = i;
+ }
+ i = di->dumper(di->priv, va, NULL, dumplo, left * PAGE_SIZE);
+ if (i)
+ break;
+ count += left;
+ dumplo += left * PAGE_SIZE;
+ addr += left * PAGE_SIZE;
+ }
+ if (i)
+ printf("\nDump failed writing data (%d)\n", i);
+ i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
+ if (i)
+ printf("\nDump failed writing trailer (%d)\n", i);
+ di->dumper(di->priv, NULL, NULL, 0, 0); /* tell them we are done */
+ printf("\nDump complete\n");
+ return;
+}
diff --git a/sys/conf/files.alpha b/sys/conf/files.alpha
index 8fb4df3..1ea656a 100644
--- a/sys/conf/files.alpha
+++ b/sys/conf/files.alpha
@@ -31,6 +31,7 @@ atkbdmap.h optional atkbd_dflt_keymap \
clean "atkbdmap.h"
#
alpha/alpha/alpha-gdbstub.c optional ddb
+alpha/alpha/alphadump.c standard
alpha/alpha/api_up1000.c optional api_up1000
alpha/alpha/atomic.s standard
alpha/alpha/autoconf.c standard
diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h
index 3a4e17b..6ab3854 100644
--- a/sys/sys/kerneldump.h
+++ b/sys/sys/kerneldump.h
@@ -65,6 +65,7 @@ struct kerneldumpheader {
uint32_t version;
#define KERNELDUMPVERSION 1
uint32_t architectureversion;
+#define KERNELDUMP_ALPHA_VERSION 1
#define KERNELDUMP_I386_VERSION 1
#define KERNELDUMP_IA64_VERSION 1
uint64_t dumplength; /* excl headers */
OpenPOWER on IntegriCloud