This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-x86_64 / crash.h
1 #ifndef _ASM_X86_64_CRASH_H
2 #define _ASM_X86_64_CRASH_H
3
4 /*
5  * linux/include/asm-x86_64/crash.h
6  *
7  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  */
24
25 #ifdef __KERNEL__
26
27 #include <linux/mm.h>
28 #include <linux/highmem.h>
29 #include <asm/mmzone.h>
30
31 extern int page_is_ram(unsigned long);
32
33 static inline void *
34 map_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
68 static inline void unmap_virtual(struct page *page) 
69
70         kunmap(page);
71 }
72
73 #endif /* __KERNEL__ */
74
75 #endif /* _ASM_X86_64_CRASH_H */