]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __VIRT_CONVERT__ |
2 | #define __VIRT_CONVERT__ | |
3 | ||
4 | /* | |
5 | * Macros used for converting between virtual and physical mappings. | |
6 | */ | |
7 | ||
8 | #ifdef __KERNEL__ | |
9 | ||
1da177e4 | 10 | #include <linux/compiler.h> |
12d810c1 | 11 | #include <linux/mmzone.h> |
1da177e4 LT |
12 | #include <asm/setup.h> |
13 | #include <asm/page.h> | |
14 | ||
1da177e4 LT |
15 | /* |
16 | * Change virtual addresses to physical addresses and vv. | |
17 | */ | |
1da177e4 LT |
18 | static inline unsigned long virt_to_phys(void *address) |
19 | { | |
12d810c1 | 20 | return __pa(address); |
1da177e4 LT |
21 | } |
22 | ||
23 | static inline void *phys_to_virt(unsigned long address) | |
24 | { | |
12d810c1 | 25 | return __va(address); |
1da177e4 | 26 | } |
1da177e4 LT |
27 | |
28 | /* Permanent address of a page. */ | |
682137f7 | 29 | #ifdef CONFIG_MMU |
12d810c1 RZ |
30 | #ifdef CONFIG_SINGLE_MEMORY_CHUNK |
31 | #define page_to_phys(page) \ | |
32 | __pa(PAGE_OFFSET + (((page) - pg_data_map[0].node_mem_map) << PAGE_SHIFT)) | |
33 | #else | |
34 | #define page_to_phys(_page) ({ \ | |
35 | struct page *__page = _page; \ | |
36 | struct pglist_data *pgdat; \ | |
37 | pgdat = pg_data_table[page_to_nid(__page)]; \ | |
38 | page_to_pfn(__page) << PAGE_SHIFT; \ | |
39 | }) | |
40 | #endif | |
682137f7 GU |
41 | #else |
42 | #define page_to_phys(page) (((page) - mem_map) << PAGE_SHIFT) | |
43 | #endif | |
1da177e4 LT |
44 | |
45 | /* | |
46 | * IO bus memory addresses are 1:1 with the physical address, | |
1da177e4 | 47 | */ |
1da177e4 LT |
48 | #define virt_to_bus virt_to_phys |
49 | #define bus_to_virt phys_to_virt | |
1da177e4 LT |
50 | |
51 | #endif | |
52 | #endif |