]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] powerpc: Add arch-dependent copy_oldmem_page
authorMichael Ellerman <michael@ellerman.id.au>
Sun, 4 Dec 2005 07:39:51 +0000 (18:39 +1100)
committerPaul Mackerras <paulus@samba.org>
Mon, 9 Jan 2006 03:52:35 +0000 (14:52 +1100)
Signed-off-by: Haren Myneni <haren@us.ibm.com>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/crash_dump.c
include/asm-powerpc/kexec.h
kernel/crash_dump.c

index 5337ab75978067046384cd568367d02a0518fef6..87effa3f21a70db3efc49668567a2892f440a98b 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/kdump.h>
 #include <asm/lmb.h>
 #include <asm/firmware.h>
+#include <asm/uaccess.h>
 
 #ifdef DEBUG
 #include <asm/udbg.h>
@@ -71,3 +72,38 @@ static int __init parse_savemaxmem(char *p)
        return 0;
 }
 __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;
+}
index ae76ed5d973f4910b81d8877e027210617b10ecd..c0f6d6b0d935f7927958a5a3a7bccb3134da848f 100644 (file)
@@ -30,6 +30,8 @@
 #define KEXEC_ARCH KEXEC_ARCH_PPC
 #endif
 
+#define HAVE_ARCH_COPY_OLDMEM_PAGE
+
 #ifndef __ASSEMBLY__
 
 #ifdef CONFIG_KEXEC
index 334c37f5218aa39a2f7851a73181f01b401539b8..fccb27dbc623b95405d2a6defaaf38696d2269d5 100644 (file)
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
+#include <asm/kexec.h>
 
 /* Stores the physical address of elf header of crash image. */
 unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
 
+#ifndef HAVE_ARCH_COPY_OLDMEM_PAGE
 /**
  * copy_oldmem_page - copy one page from "oldmem"
  * @pfn: page frame number to be copied
@@ -59,3 +61,4 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
        kfree(page);
        return csize;
 }
+#endif