1#ifndef _ASM_X86_CRASH_DRIVER_H
2#define _ASM_X86_CRASH_DRIVER_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifdef __KERNEL__
26
27#include <linux/mm.h>
28#include <linux/highmem.h>
29#include <asm/mmzone.h>
30
31extern int page_is_ram(unsigned long);
32
33static inline void *
34map_virtual(u64 offset, struct page **pp)
35{
36 struct page *page;
37 unsigned long pfn;
38 void *vaddr;
39
40 pfn = (unsigned long)(offset >> PAGE_SHIFT);
41
42 if (!page_is_ram(pfn)) {
43 printk(KERN_INFO
44 "crash memory driver: !page_is_ram(pfn: %lx)\n", pfn);
45 return NULL;
46 }
47
48 if (!pfn_valid(pfn)) {
49 printk(KERN_INFO
50 "crash memory driver: invalid pfn: %lx )\n", pfn);
51 return NULL;
52 }
53
54 page = pfn_to_page(pfn);
55
56 vaddr = kmap(page);
57 if (!vaddr) {
58 printk(KERN_INFO
59 "crash memory driver: pfn: %lx kmap(page: %lx) failed\n",
60 pfn, (unsigned long)page);
61 return NULL;
62 }
63
64 *pp = page;
65 return (vaddr + (offset & (PAGE_SIZE-1)));
66}
67
68static inline void unmap_virtual(struct page *page)
69{
70 kunmap(page);
71}
72
73#endif
74
75#endif
76