/*1* arch/arm/kernel/crash_dump.c2*3* Copyright (C) 2010 Nokia Corporation.4* Author: Mika Westerberg5*6* This code is taken from arch/x86/kernel/crash_dump_64.c7* Created by: Hariprasad Nellitheertha ([email protected])8* Copyright (C) IBM Corporation, 2004. All rights reserved9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of the GNU General Public License version 2 as12* published by the Free Software Foundation.13*/1415#include <linux/errno.h>16#include <linux/crash_dump.h>17#include <linux/uaccess.h>18#include <linux/io.h>1920/**21* copy_oldmem_page() - copy one page from old kernel memory22* @pfn: page frame number to be copied23* @buf: buffer where the copied page is placed24* @csize: number of bytes to copy25* @offset: offset in bytes into the page26* @userbuf: if set, @buf is int he user address space27*28* This function copies one page from old kernel memory into buffer pointed by29* @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes30* copied or negative error in case of failure.31*/32ssize_t copy_oldmem_page(unsigned long pfn, char *buf,33size_t csize, unsigned long offset,34int userbuf)35{36void *vaddr;3738if (!csize)39return 0;4041vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);42if (!vaddr)43return -ENOMEM;4445if (userbuf) {46if (copy_to_user(buf, vaddr + offset, csize)) {47iounmap(vaddr);48return -EFAULT;49}50} else {51memcpy(buf, vaddr + offset, csize);52}5354iounmap(vaddr);55return csize;56}575859