]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/kernel/crash_dump.c
[PATCH] drop task argument of audit_syscall_{entry,exit}
[linux-2.6-omap-h63xx.git] / arch / powerpc / kernel / crash_dump.c
index 63919bcfc9fe212011ba21fded8be0d88d62837c..764d073297165cc4792e83c1d3a1191ac34d09c0 100644 (file)
 
 #undef DEBUG
 
+#include <linux/crash_dump.h>
+#include <linux/bootmem.h>
 #include <asm/kdump.h>
 #include <asm/lmb.h>
 #include <asm/firmware.h>
+#include <asm/uaccess.h>
 
 #ifdef DEBUG
 #include <asm/udbg.h>
@@ -51,3 +54,58 @@ void __init kdump_setup(void)
 
        DBG(" <- kdump_setup()\n");
 }
+
+#ifdef CONFIG_PROC_VMCORE
+static int __init parse_elfcorehdr(char *p)
+{
+       if (p)
+               elfcorehdr_addr = memparse(p, &p);
+
+       return 1;
+}
+__setup("elfcorehdr=", parse_elfcorehdr);
+#endif
+
+static int __init parse_savemaxmem(char *p)
+{
+       if (p)
+               saved_max_pfn = (memparse(p, &p) >> PAGE_SHIFT) - 1;
+
+       return 1;
+}
+__setup("savemaxmem=", parse_savemaxmem);
+
+/*
+ * copy_oldmem_page - copy one page from "oldmem"
+ * @pfn: page frame number to be copied
+ * @buf: target memory address for the copy; this can be in kernel address
+ *      space or user address space (see @userbuf)
+ * @csize: number of bytes to copy
+ * @offset: offset in bytes into the page (based on pfn) to begin the copy
+ * @userbuf: if set, @buf is in user address space, use copy_to_user(),
+ *      otherwise @buf is in kernel address space, use memcpy().
+ *
+ * Copy a page from "oldmem". For this page, there is no pte mapped
+ * in the current kernel. We stitch up a pte, similar to kmap_atomic.
+ */
+ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
+                       size_t csize, unsigned long offset, int userbuf)
+{
+       void  *vaddr;
+
+       if (!csize)
+               return 0;
+
+       vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0);
+
+       if (userbuf) {
+               if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) {
+                       iounmap(vaddr);
+                       return -EFAULT;
+               }
+       } else
+               memcpy(buf, (vaddr + offset), csize);
+
+       iounmap(vaddr);
+       return csize;
+}