blob: 9d92ba04b033891544f154e26e28f853ec42d64e [file] [log] [blame]
David Gibson8882a4d2005-11-09 13:38:01 +11001#ifndef _ASM_POWERPC_ABS_ADDR_H
2#define _ASM_POWERPC_ABS_ADDR_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01003#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
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 Lu95f72d12010-07-12 14:36:09 +100015#include <linux/memblock.h>
David S. Millerd9b2b2a2008-02-13 16:56:49 -080016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/types.h>
18#include <asm/page.h>
19#include <asm/prom.h>
Michael Ellerman56e97b72005-08-03 20:21:23 +100020
21struct mschunks_map {
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 unsigned long num_chunks;
23 unsigned long chunk_size;
24 unsigned long chunk_shift;
25 unsigned long chunk_mask;
Michael Ellerman56e97b72005-08-03 20:21:23 +100026 u32 *mapping;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
Michael Ellerman56e97b72005-08-03 20:21:23 +100029extern struct mschunks_map mschunks_map;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Michael Ellerman34c8f692005-08-03 20:21:23 +100031/* 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 Ellerman38e85dc2005-08-03 20:21:23 +100036static inline unsigned long chunk_to_addr(unsigned long chunk)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037{
Michael Ellerman34c8f692005-08-03 20:21:23 +100038 return chunk << MSCHUNKS_CHUNK_SHIFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039}
40
Michael Ellerman38e85dc2005-08-03 20:21:23 +100041static inline unsigned long addr_to_chunk(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
Michael Ellerman34c8f692005-08-03 20:21:23 +100043 return addr >> MSCHUNKS_CHUNK_SHIFT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
Michael Ellermance217952005-08-03 20:21:23 +100046static inline unsigned long phys_to_abs(unsigned long pa)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Stephen Rothwellf5339272012-03-15 18:18:00 +000048 return pa;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051/* Convenience macros */
52#define virt_to_abs(va) phys_to_abs(__pa(va))
Michael Ellermane88bcd12005-08-03 20:21:25 +100053#define abs_to_virt(aa) __va(aa)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Arnd Bergmann88ced032005-12-16 22:43:46 +010055#endif /* __KERNEL__ */
David Gibson8882a4d2005-11-09 13:38:01 +110056#endif /* _ASM_POWERPC_ABS_ADDR_H */