Path: blob/master/arch/powerpc/include/asm/abs_addr.h
15117 views
#ifndef _ASM_POWERPC_ABS_ADDR_H1#define _ASM_POWERPC_ABS_ADDR_H2#ifdef __KERNEL__345/*6* c 2001 PPC 64 Team, IBM Corp7*8* This program is free software; you can redistribute it and/or9* modify it under the terms of the GNU General Public License10* as published by the Free Software Foundation; either version11* 2 of the License, or (at your option) any later version.12*/1314#include <linux/memblock.h>1516#include <asm/types.h>17#include <asm/page.h>18#include <asm/prom.h>19#include <asm/firmware.h>2021struct mschunks_map {22unsigned long num_chunks;23unsigned long chunk_size;24unsigned long chunk_shift;25unsigned long chunk_mask;26u32 *mapping;27};2829extern struct mschunks_map mschunks_map;3031/* 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)3536static inline unsigned long chunk_to_addr(unsigned long chunk)37{38return chunk << MSCHUNKS_CHUNK_SHIFT;39}4041static inline unsigned long addr_to_chunk(unsigned long addr)42{43return addr >> MSCHUNKS_CHUNK_SHIFT;44}4546static inline unsigned long phys_to_abs(unsigned long pa)47{48unsigned long chunk;4950/* This is a no-op on non-iSeries */51if (!firmware_has_feature(FW_FEATURE_ISERIES))52return pa;5354chunk = addr_to_chunk(pa);5556if (chunk < mschunks_map.num_chunks)57chunk = mschunks_map.mapping[chunk];5859return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK);60}6162/* Convenience macros */63#define virt_to_abs(va) phys_to_abs(__pa(va))64#define abs_to_virt(aa) __va(aa)6566/*67* Converts Virtual Address to Real Address for68* Legacy iSeries Hypervisor calls69*/70#define iseries_hv_addr(virtaddr) \71(0x8000000000000000UL | virt_to_abs(virtaddr))7273#endif /* __KERNEL__ */74#endif /* _ASM_POWERPC_ABS_ADDR_H */757677