Commit | Line | Data |
---|---|---|
8882a4da DG |
1 | #ifndef _ASM_POWERPC_ABS_ADDR_H |
2 | #define _ASM_POWERPC_ABS_ADDR_H | |
88ced031 | 3 | #ifdef __KERNEL__ |
1da177e4 | 4 | |
1da177e4 LT |
5 | |
6 | /* | |
7 | * c 2001 PPC 64 Team, IBM Corp | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU General Public License | |
11 | * as published by the Free Software Foundation; either version | |
12 | * 2 of the License, or (at your option) any later version. | |
13 | */ | |
14 | ||
d9b2b2a2 DM |
15 | #include <linux/lmb.h> |
16 | ||
1da177e4 LT |
17 | #include <asm/types.h> |
18 | #include <asm/page.h> | |
19 | #include <asm/prom.h> | |
bef56862 | 20 | #include <asm/firmware.h> |
56e97b71 ME |
21 | |
22 | struct mschunks_map { | |
1da177e4 LT |
23 | unsigned long num_chunks; |
24 | unsigned long chunk_size; | |
25 | unsigned long chunk_shift; | |
26 | unsigned long chunk_mask; | |
56e97b71 | 27 | u32 *mapping; |
1da177e4 LT |
28 | }; |
29 | ||
56e97b71 | 30 | extern struct mschunks_map mschunks_map; |
1da177e4 | 31 | |
34c8f696 ME |
32 | /* Chunks are 256 KB */ |
33 | #define MSCHUNKS_CHUNK_SHIFT (18) | |
34 | #define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT) | |
35 | #define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1) | |
36 | ||
38e85dc1 | 37 | static inline unsigned long chunk_to_addr(unsigned long chunk) |
1da177e4 | 38 | { |
34c8f696 | 39 | return chunk << MSCHUNKS_CHUNK_SHIFT; |
1da177e4 LT |
40 | } |
41 | ||
38e85dc1 | 42 | static inline unsigned long addr_to_chunk(unsigned long addr) |
1da177e4 | 43 | { |
34c8f696 | 44 | return addr >> MSCHUNKS_CHUNK_SHIFT; |
1da177e4 LT |
45 | } |
46 | ||
ce217952 | 47 | static inline unsigned long phys_to_abs(unsigned long pa) |
1da177e4 | 48 | { |
ce217952 | 49 | unsigned long chunk; |
1da177e4 | 50 | |
bef56862 ME |
51 | /* This is a no-op on non-iSeries */ |
52 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | |
53 | return pa; | |
54 | ||
ce217952 | 55 | chunk = addr_to_chunk(pa); |
38e85dc1 | 56 | |
ce217952 ME |
57 | if (chunk < mschunks_map.num_chunks) |
58 | chunk = mschunks_map.mapping[chunk]; | |
1da177e4 | 59 | |
ce217952 ME |
60 | return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK); |
61 | } | |
1da177e4 | 62 | |
1da177e4 LT |
63 | /* Convenience macros */ |
64 | #define virt_to_abs(va) phys_to_abs(__pa(va)) | |
e88bcd1b | 65 | #define abs_to_virt(aa) __va(aa) |
1da177e4 | 66 | |
426c1a11 SR |
67 | /* |
68 | * Converts Virtual Address to Real Address for | |
69 | * Legacy iSeries Hypervisor calls | |
70 | */ | |
71 | #define iseries_hv_addr(virtaddr) \ | |
72 | (0x8000000000000000 | virt_to_abs(virtaddr)) | |
73 | ||
88ced031 | 74 | #endif /* __KERNEL__ */ |
8882a4da | 75 | #endif /* _ASM_POWERPC_ABS_ADDR_H */ |