page.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* MN10300 Page table definitions
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_PAGE_H
  12. #define _ASM_PAGE_H
  13. /* PAGE_SHIFT determines the page size */
  14. #define PAGE_SHIFT 12
  15. #ifndef __ASSEMBLY__
  16. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  17. #define PAGE_MASK (~(PAGE_SIZE - 1))
  18. #else
  19. #define PAGE_SIZE +(1 << PAGE_SHIFT) /* unary plus marks an
  20. * immediate val not an addr */
  21. #define PAGE_MASK +(~(PAGE_SIZE - 1))
  22. #endif
  23. #ifdef __KERNEL__
  24. #ifndef __ASSEMBLY__
  25. #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
  26. #define copy_page(to, from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  27. #define clear_user_page(addr, vaddr, page) clear_page(addr)
  28. #define copy_user_page(vto, vfrom, vaddr, to) copy_page(vto, vfrom)
  29. /*
  30. * These are used to make use of C type-checking..
  31. */
  32. typedef struct { unsigned long pte; } pte_t;
  33. typedef struct { unsigned long pgd; } pgd_t;
  34. typedef struct { unsigned long pgprot; } pgprot_t;
  35. typedef struct page *pgtable_t;
  36. #define PTE_MASK PAGE_MASK
  37. #define HPAGE_SHIFT 22
  38. #ifdef CONFIG_HUGETLB_PAGE
  39. #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
  40. #define HPAGE_MASK (~(HPAGE_SIZE - 1))
  41. #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
  42. #endif
  43. #define pte_val(x) ((x).pte)
  44. #define pgd_val(x) ((x).pgd)
  45. #define pgprot_val(x) ((x).pgprot)
  46. #define __pte(x) ((pte_t) { (x) })
  47. #define __pgd(x) ((pgd_t) { (x) })
  48. #define __pgprot(x) ((pgprot_t) { (x) })
  49. #include <asm-generic/pgtable-nopmd.h>
  50. #endif /* !__ASSEMBLY__ */
  51. /*
  52. * This handles the memory map.. We could make this a config
  53. * option, but too many people screw it up, and too few need
  54. * it.
  55. *
  56. * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
  57. * a virtual address space of one gigabyte, which limits the
  58. * amount of physical memory you can use to about 950MB.
  59. */
  60. #ifndef __ASSEMBLY__
  61. /* Pure 2^n version of get_order */
  62. static inline int get_order(unsigned long size) __attribute__((const));
  63. static inline int get_order(unsigned long size)
  64. {
  65. int order;
  66. size = (size - 1) >> (PAGE_SHIFT - 1);
  67. order = -1;
  68. do {
  69. size >>= 1;
  70. order++;
  71. } while (size);
  72. return order;
  73. }
  74. #endif /* __ASSEMBLY__ */
  75. #include <asm/page_offset.h>
  76. #define __PAGE_OFFSET (PAGE_OFFSET_RAW)
  77. #define PAGE_OFFSET ((unsigned long) __PAGE_OFFSET)
  78. /*
  79. * main RAM and kernel working space are coincident at 0x90000000, but to make
  80. * life more interesting, there's also an uncached virtual shadow at 0xb0000000
  81. * - these mappings are fixed in the MMU
  82. */
  83. #define __pfn_disp (CONFIG_KERNEL_RAM_BASE_ADDRESS >> PAGE_SHIFT)
  84. #define __pa(x) ((unsigned long)(x))
  85. #define __va(x) ((void *)(unsigned long)(x))
  86. #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
  87. #define pfn_to_page(pfn) (mem_map + ((pfn) - __pfn_disp))
  88. #define page_to_pfn(page) ((unsigned long)((page) - mem_map) + __pfn_disp)
  89. #define pfn_valid(pfn) \
  90. ({ \
  91. unsigned long __pfn = (pfn) - __pfn_disp; \
  92. __pfn < max_mapnr; \
  93. })
  94. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  95. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  96. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  97. #define VM_DATA_DEFAULT_FLAGS \
  98. (VM_READ | VM_WRITE | \
  99. ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
  100. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  101. #endif /* __KERNEL__ */
  102. #endif /* _ASM_PAGE_H */