abs_addr.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _ASM_POWERPC_ABS_ADDR_H
  2. #define _ASM_POWERPC_ABS_ADDR_H
  3. #ifdef __KERNEL__
  4. /*
  5. * c 2001 PPC 64 Team, IBM Corp
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <asm/types.h>
  13. #include <asm/page.h>
  14. #include <asm/prom.h>
  15. #include <asm/lmb.h>
  16. #include <asm/firmware.h>
  17. struct mschunks_map {
  18. unsigned long num_chunks;
  19. unsigned long chunk_size;
  20. unsigned long chunk_shift;
  21. unsigned long chunk_mask;
  22. u32 *mapping;
  23. };
  24. extern struct mschunks_map mschunks_map;
  25. /* Chunks are 256 KB */
  26. #define MSCHUNKS_CHUNK_SHIFT (18)
  27. #define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
  28. #define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
  29. static inline unsigned long chunk_to_addr(unsigned long chunk)
  30. {
  31. return chunk << MSCHUNKS_CHUNK_SHIFT;
  32. }
  33. static inline unsigned long addr_to_chunk(unsigned long addr)
  34. {
  35. return addr >> MSCHUNKS_CHUNK_SHIFT;
  36. }
  37. static inline unsigned long phys_to_abs(unsigned long pa)
  38. {
  39. unsigned long chunk;
  40. /* This is a no-op on non-iSeries */
  41. if (!firmware_has_feature(FW_FEATURE_ISERIES))
  42. return pa;
  43. chunk = addr_to_chunk(pa);
  44. if (chunk < mschunks_map.num_chunks)
  45. chunk = mschunks_map.mapping[chunk];
  46. return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK);
  47. }
  48. /* Convenience macros */
  49. #define virt_to_abs(va) phys_to_abs(__pa(va))
  50. #define abs_to_virt(aa) __va(aa)
  51. /*
  52. * Converts Virtual Address to Real Address for
  53. * Legacy iSeries Hypervisor calls
  54. */
  55. #define iseries_hv_addr(virtaddr) \
  56. (0x8000000000000000 | virt_to_abs(virtaddr))
  57. #endif /* __KERNEL__ */
  58. #endif /* _ASM_POWERPC_ABS_ADDR_H */