fixmap.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Fixmap support for Hexagon - enough to support highmem features
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef _ASM_FIXMAP_H
  21. #define _ASM_FIXMAP_H
  22. /*
  23. * A lot of the fixmap info is already in mem-layout.h
  24. */
  25. #include <asm/mem-layout.h>
  26. /*
  27. * Full fixmap support involves set_fixmap() functions, but
  28. * these may not be needed if all we're after is an area for
  29. * highmem kernel mappings.
  30. */
  31. #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
  32. #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
  33. extern void __this_fixmap_does_not_exist(void);
  34. /**
  35. * fix_to_virt -- "index to address" translation.
  36. *
  37. * If anyone tries to use the idx directly without translation,
  38. * we catch the bug with a NULL-deference kernel oops. Illegal
  39. * ranges of incoming indices are caught too.
  40. */
  41. static inline unsigned long fix_to_virt(const unsigned int idx)
  42. {
  43. /*
  44. * This branch gets completely eliminated after inlining,
  45. * except when someone tries to use fixaddr indices in an
  46. * illegal way. (such as mixing up address types or using
  47. * out-of-range indices).
  48. *
  49. * If it doesn't get removed, the linker will complain
  50. * loudly with a reasonably clear error message..
  51. */
  52. if (idx >= __end_of_fixed_addresses)
  53. __this_fixmap_does_not_exist();
  54. return __fix_to_virt(idx);
  55. }
  56. static inline unsigned long virt_to_fix(const unsigned long vaddr)
  57. {
  58. BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
  59. return __virt_to_fix(vaddr);
  60. }
  61. #define kmap_get_fixmap_pte(vaddr) \
  62. pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), \
  63. (vaddr)), (vaddr)), (vaddr))
  64. #endif