Add cmpxchg_local to m68knommu
[linux/fpc-iii.git] / include / asm-powerpc / abs_addr.h
blob4aa220718b19a09b00cd137ca384bc4a7fa9f292
1 #ifndef _ASM_POWERPC_ABS_ADDR_H
2 #define _ASM_POWERPC_ABS_ADDR_H
3 #ifdef __KERNEL__
6 /*
7 * c 2001 PPC 64 Team, IBM Corp
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.
15 #include <asm/types.h>
16 #include <asm/page.h>
17 #include <asm/prom.h>
18 #include <asm/lmb.h>
19 #include <asm/firmware.h>
21 struct mschunks_map {
22 unsigned long num_chunks;
23 unsigned long chunk_size;
24 unsigned long chunk_shift;
25 unsigned long chunk_mask;
26 u32 *mapping;
29 extern struct mschunks_map mschunks_map;
31 /* Chunks are 256 KB */
32 #define MSCHUNKS_CHUNK_SHIFT (18)
33 #define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
34 #define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
36 static inline unsigned long chunk_to_addr(unsigned long chunk)
38 return chunk << MSCHUNKS_CHUNK_SHIFT;
41 static inline unsigned long addr_to_chunk(unsigned long addr)
43 return addr >> MSCHUNKS_CHUNK_SHIFT;
46 static inline unsigned long phys_to_abs(unsigned long pa)
48 unsigned long chunk;
50 /* This is a no-op on non-iSeries */
51 if (!firmware_has_feature(FW_FEATURE_ISERIES))
52 return pa;
54 chunk = addr_to_chunk(pa);
56 if (chunk < mschunks_map.num_chunks)
57 chunk = mschunks_map.mapping[chunk];
59 return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK);
62 /* Convenience macros */
63 #define virt_to_abs(va) phys_to_abs(__pa(va))
64 #define abs_to_virt(aa) __va(aa)
67 * Converts Virtual Address to Real Address for
68 * Legacy iSeries Hypervisor calls
70 #define iseries_hv_addr(virtaddr) \
71 (0x8000000000000000 | virt_to_abs(virtaddr))
73 #endif /* __KERNEL__ */
74 #endif /* _ASM_POWERPC_ABS_ADDR_H */