page.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef __ASM_GENERIC_PAGE_H
  2. #define __ASM_GENERIC_PAGE_H
  3. /*
  4. * Generic page.h implementation, for NOMMU architectures.
  5. * This provides the dummy definitions for the memory management.
  6. */
  7. #ifdef CONFIG_MMU
  8. #error need to prove a real asm/page.h
  9. #endif
  10. /* PAGE_SHIFT determines the page size */
  11. #define PAGE_SHIFT 12
  12. #ifdef __ASSEMBLY__
  13. #define PAGE_SIZE (1 << PAGE_SHIFT)
  14. #else
  15. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  16. #endif
  17. #define PAGE_MASK (~(PAGE_SIZE-1))
  18. #include <asm/setup.h>
  19. #ifndef __ASSEMBLY__
  20. #define clear_page(page) memset((page), 0, PAGE_SIZE)
  21. #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
  22. #define clear_user_page(page, vaddr, pg) clear_page(page)
  23. #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  24. /*
  25. * These are used to make use of C type-checking..
  26. */
  27. typedef struct {
  28. unsigned long pte;
  29. } pte_t;
  30. typedef struct {
  31. unsigned long pmd[16];
  32. } pmd_t;
  33. typedef struct {
  34. unsigned long pgd;
  35. } pgd_t;
  36. typedef struct {
  37. unsigned long pgprot;
  38. } pgprot_t;
  39. typedef struct page *pgtable_t;
  40. #define pte_val(x) ((x).pte)
  41. #define pmd_val(x) ((&x)->pmd[0])
  42. #define pgd_val(x) ((x).pgd)
  43. #define pgprot_val(x) ((x).pgprot)
  44. #define __pte(x) ((pte_t) { (x) } )
  45. #define __pmd(x) ((pmd_t) { (x) } )
  46. #define __pgd(x) ((pgd_t) { (x) } )
  47. #define __pgprot(x) ((pgprot_t) { (x) } )
  48. extern unsigned long memory_start;
  49. extern unsigned long memory_end;
  50. #endif /* !__ASSEMBLY__ */
  51. #ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
  52. #define PAGE_OFFSET (CONFIG_KERNEL_RAM_BASE_ADDRESS)
  53. #else
  54. #define PAGE_OFFSET (0)
  55. #endif
  56. #ifndef ARCH_PFN_OFFSET
  57. #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
  58. #endif
  59. #ifndef __ASSEMBLY__
  60. #define __va(x) ((void *)((unsigned long) (x)))
  61. #define __pa(x) ((unsigned long) (x))
  62. #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
  63. #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
  64. #define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr))
  65. #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
  66. #ifndef page_to_phys
  67. #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
  68. #endif
  69. #define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
  70. #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
  71. ((void *)(kaddr) < (void *)memory_end))
  72. #endif /* __ASSEMBLY__ */
  73. #include <asm-generic/memory_model.h>
  74. #include <asm-generic/getorder.h>
  75. #endif /* __ASM_GENERIC_PAGE_H */