Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. /*
  2. mapper config for 5.1 (3.6)
  3. */
  4. #define VA_BITS (48)
  5. #define BIT(nr) (1UL << (nr))
  6.  
  7. #define CONFIG_ARM64_PA_BITS 48
  8.  
  9. #define __AC(X,Y) (X##Y)
  10. #define _AC(X,Y) __AC(X,Y)
  11. #define _UL(x) (_AC(x, UL))
  12. #define UL(x) (_UL(x))
  13.  
  14. #define PAGE_OFFSET (UL(0xffffffffffffffff) - \
  15. (UL(1) << (VA_BITS - 1)) + 1)
  16.  
  17. #define kimage_voffset 0xfffeffffd0000000
  18. #define PHYS_OFFSET 0x0000000040000000
  19.  
  20. #define PTRS_PER_PTE (1 << (PAGE_SHIFT - 3))
  21. #define PTRS_PER_PMD PTRS_PER_PTE
  22. #define PMD_BLOCK_SHIFT 21
  23.  
  24. #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
  25. #define PAGE_SHIFT 12
  26. #define PAGE_MASK (~(PAGE_SIZE-1))
  27.  
  28. #define PGDIR_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(4 - CONFIG_PGTABLE_LEVELS)
  29. #define ARM64_HW_PGTABLE_LEVEL_SHIFT(n) ((PAGE_SHIFT - 3) * (4 - (n)) + 3)
  30. #define CONFIG_PGTABLE_LEVELS 4
  31.  
  32. #define PTRS_PER_PGD (1 << (MAX_USER_VA_BITS - PGDIR_SHIFT))
  33. #define MAX_USER_VA_BITS VA_BITS
  34.  
  35. #define PHYS_MASK ((UL(1) << PHYS_MASK_SHIFT) - 1)
  36. #define PHYS_MASK_SHIFT (CONFIG_ARM64_PA_BITS)
  37.  
  38. #define PMD_SHIFT ARM64_HW_PGTABLE_LEVEL_SHIFT(2)
  39.  
  40.  
  41.  
  42. #define __is_lm_address(addr) (!!((addr) & BIT(VA_BITS - 1)))
  43.  
  44. #define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)
  45. #define __kimg_to_phys(addr) ((addr) - kimage_voffset)
  46.  
  47. #define __virt_to_phys_nodebug(x) ({ \
  48. phys_addr_t __x = (phys_addr_t)(x); \
  49. __is_lm_address(__x) ? __lm_to_phys(__x) : \
  50. __kimg_to_phys(__x); \
  51. })
  52.  
  53. inline static paddr_t kern_vtop(vaddr_t x)
  54. {
  55. return __virt_to_phys_nodebug(x);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement