abs_addr.h 1.8 KB

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