pgtable-types.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Page table types definitions.
  3. *
  4. * Copyright (C) 2014 ARM Ltd.
  5. * Author: Catalin Marinas <catalin.marinas@arm.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __ASM_PGTABLE_TYPES_H
  20. #define __ASM_PGTABLE_TYPES_H
  21. #include <asm/types.h>
  22. typedef u64 pteval_t;
  23. typedef u64 pmdval_t;
  24. typedef u64 pudval_t;
  25. typedef u64 pgdval_t;
  26. #undef STRICT_MM_TYPECHECKS
  27. #ifdef STRICT_MM_TYPECHECKS
  28. /*
  29. * These are used to make use of C type-checking..
  30. */
  31. typedef struct { pteval_t pte; } pte_t;
  32. #define pte_val(x) ((x).pte)
  33. #define __pte(x) ((pte_t) { (x) } )
  34. #if CONFIG_PGTABLE_LEVELS > 2
  35. typedef struct { pmdval_t pmd; } pmd_t;
  36. #define pmd_val(x) ((x).pmd)
  37. #define __pmd(x) ((pmd_t) { (x) } )
  38. #endif
  39. #if CONFIG_PGTABLE_LEVELS > 3
  40. typedef struct { pudval_t pud; } pud_t;
  41. #define pud_val(x) ((x).pud)
  42. #define __pud(x) ((pud_t) { (x) } )
  43. #endif
  44. typedef struct { pgdval_t pgd; } pgd_t;
  45. #define pgd_val(x) ((x).pgd)
  46. #define __pgd(x) ((pgd_t) { (x) } )
  47. typedef struct { pteval_t pgprot; } pgprot_t;
  48. #define pgprot_val(x) ((x).pgprot)
  49. #define __pgprot(x) ((pgprot_t) { (x) } )
  50. #else /* !STRICT_MM_TYPECHECKS */
  51. typedef pteval_t pte_t;
  52. #define pte_val(x) (x)
  53. #define __pte(x) (x)
  54. #if CONFIG_PGTABLE_LEVELS > 2
  55. typedef pmdval_t pmd_t;
  56. #define pmd_val(x) (x)
  57. #define __pmd(x) (x)
  58. #endif
  59. #if CONFIG_PGTABLE_LEVELS > 3
  60. typedef pudval_t pud_t;
  61. #define pud_val(x) (x)
  62. #define __pud(x) (x)
  63. #endif
  64. typedef pgdval_t pgd_t;
  65. #define pgd_val(x) (x)
  66. #define __pgd(x) (x)
  67. typedef pteval_t pgprot_t;
  68. #define pgprot_val(x) (x)
  69. #define __pgprot(x) (x)
  70. #endif /* STRICT_MM_TYPECHECKS */
  71. #if CONFIG_PGTABLE_LEVELS == 2
  72. #include <asm-generic/pgtable-nopmd.h>
  73. #elif CONFIG_PGTABLE_LEVELS == 3
  74. #include <asm-generic/pgtable-nopud.h>
  75. #endif
  76. #endif /* __ASM_PGTABLE_TYPES_H */