David Gibson | 8882a4d | 2005-11-09 13:38:01 +1100 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_ABS_ADDR_H |
| 2 | #define _ASM_POWERPC_ABS_ADDR_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 15 | #include <linux/memblock.h> |
David S. Miller | d9b2b2a | 2008-02-13 16:56:49 -0800 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/types.h> |
| 18 | #include <asm/page.h> |
| 19 | #include <asm/prom.h> |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 20 | |
| 21 | struct mschunks_map { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | unsigned long num_chunks; |
| 23 | unsigned long chunk_size; |
| 24 | unsigned long chunk_shift; |
| 25 | unsigned long chunk_mask; |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 26 | u32 *mapping; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | }; |
| 28 | |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 29 | extern struct mschunks_map mschunks_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 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) |
| 35 | |
Michael Ellerman | 38e85dc | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 36 | static inline unsigned long chunk_to_addr(unsigned long chunk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 38 | return chunk << MSCHUNKS_CHUNK_SHIFT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Michael Ellerman | 38e85dc | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 41 | static inline unsigned long addr_to_chunk(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | { |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 43 | return addr >> MSCHUNKS_CHUNK_SHIFT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Michael Ellerman | ce21795 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 46 | static inline unsigned long phys_to_abs(unsigned long pa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | { |
Stephen Rothwell | f533927 | 2012-03-15 18:18:00 +0000 | [diff] [blame] | 48 | return pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | /* Convenience macros */ |
| 52 | #define virt_to_abs(va) phys_to_abs(__pa(va)) |
Michael Ellerman | e88bcd1 | 2005-08-03 20:21:25 +1000 | [diff] [blame] | 53 | #define abs_to_virt(aa) __va(aa) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 55 | #endif /* __KERNEL__ */ |
David Gibson | 8882a4d | 2005-11-09 13:38:01 +1100 | [diff] [blame] | 56 | #endif /* _ASM_POWERPC_ABS_ADDR_H */ |