Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
crash_dump.c
Go to the documentation of this file.
1 /*
2  * arch/arm/kernel/crash_dump.c
3  *
4  * Copyright (C) 2010 Nokia Corporation.
5  * Author: Mika Westerberg
6  *
7  * This code is taken from arch/x86/kernel/crash_dump_64.c
8  * Created by: Hariprasad Nellitheertha ([email protected])
9  * Copyright (C) IBM Corporation, 2004. All rights reserved
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  */
15 
16 #include <linux/errno.h>
17 #include <linux/crash_dump.h>
18 #include <linux/uaccess.h>
19 #include <linux/io.h>
20 
33 ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
34  size_t csize, unsigned long offset,
35  int userbuf)
36 {
37  void *vaddr;
38 
39  if (!csize)
40  return 0;
41 
42  vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
43  if (!vaddr)
44  return -ENOMEM;
45 
46  if (userbuf) {
47  if (copy_to_user(buf, vaddr + offset, csize)) {
48  iounmap(vaddr);
49  return -EFAULT;
50  }
51  } else {
52  memcpy(buf, vaddr + offset, csize);
53  }
54 
55  iounmap(vaddr);
56  return csize;
57 }