mmu.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __MMU_H
  3. #define __MMU_H
  4. /*
  5. * Privileged Space Mapping Buffer (PMB) definitions
  6. */
  7. #define PMB_PASCR 0xff000070
  8. #define PMB_IRMCR 0xff000078
  9. #define PASCR_SE 0x80000000
  10. #define PMB_ADDR 0xf6100000
  11. #define PMB_DATA 0xf7100000
  12. #define NR_PMB_ENTRIES 16
  13. #define PMB_E_MASK 0x0000000f
  14. #define PMB_E_SHIFT 8
  15. #define PMB_PFN_MASK 0xff000000
  16. #define PMB_SZ_16M 0x00000000
  17. #define PMB_SZ_64M 0x00000010
  18. #define PMB_SZ_128M 0x00000080
  19. #define PMB_SZ_512M 0x00000090
  20. #define PMB_SZ_MASK PMB_SZ_512M
  21. #define PMB_C 0x00000008
  22. #define PMB_WT 0x00000001
  23. #define PMB_UB 0x00000200
  24. #define PMB_CACHE_MASK (PMB_C | PMB_WT | PMB_UB)
  25. #define PMB_V 0x00000100
  26. #define PMB_NO_ENTRY (-1)
  27. #ifndef __ASSEMBLY__
  28. #include <linux/errno.h>
  29. #include <linux/threads.h>
  30. #include <asm/page.h>
  31. /* Default "unsigned long" context */
  32. typedef unsigned long mm_context_id_t[NR_CPUS];
  33. typedef struct {
  34. #ifdef CONFIG_MMU
  35. mm_context_id_t id;
  36. void *vdso;
  37. #else
  38. unsigned long end_brk;
  39. #endif
  40. #ifdef CONFIG_BINFMT_ELF_FDPIC
  41. unsigned long exec_fdpic_loadmap;
  42. unsigned long interp_fdpic_loadmap;
  43. #endif
  44. } mm_context_t;
  45. #ifdef CONFIG_PMB
  46. /* arch/sh/mm/pmb.c */
  47. bool __in_29bit_mode(void);
  48. void pmb_init(void);
  49. int pmb_bolt_mapping(unsigned long virt, phys_addr_t phys,
  50. unsigned long size, pgprot_t prot);
  51. void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
  52. pgprot_t prot, void *caller);
  53. int pmb_unmap(void __iomem *addr);
  54. #else
  55. static inline int
  56. pmb_bolt_mapping(unsigned long virt, phys_addr_t phys,
  57. unsigned long size, pgprot_t prot)
  58. {
  59. return -EINVAL;
  60. }
  61. static inline void __iomem *
  62. pmb_remap_caller(phys_addr_t phys, unsigned long size,
  63. pgprot_t prot, void *caller)
  64. {
  65. return NULL;
  66. }
  67. static inline int pmb_unmap(void __iomem *addr)
  68. {
  69. return -EINVAL;
  70. }
  71. #define pmb_init(addr) do { } while (0)
  72. #ifdef CONFIG_29BIT
  73. #define __in_29bit_mode() (1)
  74. #else
  75. #define __in_29bit_mode() (0)
  76. #endif
  77. #endif /* CONFIG_PMB */
  78. static inline void __iomem *
  79. pmb_remap(phys_addr_t phys, unsigned long size, pgprot_t prot)
  80. {
  81. return pmb_remap_caller(phys, size, prot, __builtin_return_address(0));
  82. }
  83. #endif /* __ASSEMBLY__ */
  84. #endif /* __MMU_H */