Linux 2.6.16.36
[linux/fpc-iii.git] / include / asm-powerpc / abs_addr.h
blobc5c3259e0f86f3d147f9daf50719ea5e6311162c
1 #ifndef _ASM_POWERPC_ABS_ADDR_H
2 #define _ASM_POWERPC_ABS_ADDR_H
3 #ifdef __KERNEL__
5 #include <linux/config.h>
7 /*
8 * c 2001 PPC 64 Team, IBM Corp
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
16 #include <asm/types.h>
17 #include <asm/page.h>
18 #include <asm/prom.h>
19 #include <asm/lmb.h>
20 #include <asm/firmware.h>
22 struct mschunks_map {
23 unsigned long num_chunks;
24 unsigned long chunk_size;
25 unsigned long chunk_shift;
26 unsigned long chunk_mask;
27 u32 *mapping;
30 extern struct mschunks_map mschunks_map;
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)
37 static inline unsigned long chunk_to_addr(unsigned long chunk)
39 return chunk << MSCHUNKS_CHUNK_SHIFT;
42 static inline unsigned long addr_to_chunk(unsigned long addr)
44 return addr >> MSCHUNKS_CHUNK_SHIFT;
47 static inline unsigned long phys_to_abs(unsigned long pa)
49 unsigned long chunk;
51 /* This is a no-op on non-iSeries */
52 if (!firmware_has_feature(FW_FEATURE_ISERIES))
53 return pa;
55 chunk = addr_to_chunk(pa);
57 if (chunk < mschunks_map.num_chunks)
58 chunk = mschunks_map.mapping[chunk];
60 return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK);
63 /* Convenience macros */
64 #define virt_to_abs(va) phys_to_abs(__pa(va))
65 #define abs_to_virt(aa) __va(aa)
68 * Converts Virtual Address to Real Address for
69 * Legacy iSeries Hypervisor calls
71 #define iseries_hv_addr(virtaddr) \
72 (0x8000000000000000 | virt_to_abs(virtaddr))
74 #endif /* __KERNEL__ */
75 #endif /* _ASM_POWERPC_ABS_ADDR_H */