page.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 get_user_page(vaddr) __get_free_page(GFP_KERNEL)
  21. #define free_user_page(page, addr) free_page(addr)
  22. #define clear_page(page) memset((page), 0, PAGE_SIZE)
  23. #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
  24. #define clear_user_page(page, vaddr, pg) clear_page(page)
  25. #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  26. /*
  27. * These are used to make use of C type-checking..
  28. */
  29. typedef struct {
  30. unsigned long pte;
  31. } pte_t;
  32. typedef struct {
  33. unsigned long pmd[16];
  34. } pmd_t;
  35. typedef struct {
  36. unsigned long pgd;
  37. } pgd_t;
  38. typedef struct {
  39. unsigned long pgprot;
  40. } pgprot_t;
  41. typedef struct page *pgtable_t;
  42. #define pte_val(x) ((x).pte)
  43. #define pmd_val(x) ((&x)->pmd[0])
  44. #define pgd_val(x) ((x).pgd)
  45. #define pgprot_val(x) ((x).pgprot)
  46. #define __pte(x) ((pte_t) { (x) } )
  47. #define __pmd(x) ((pmd_t) { (x) } )
  48. #define __pgd(x) ((pgd_t) { (x) } )
  49. #define __pgprot(x) ((pgprot_t) { (x) } )
  50. extern unsigned long memory_start;
  51. extern unsigned long memory_end;
  52. #endif /* !__ASSEMBLY__ */
  53. #ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
  54. #define PAGE_OFFSET (CONFIG_KERNEL_RAM_BASE_ADDRESS)
  55. #else
  56. #define PAGE_OFFSET (0)
  57. #endif
  58. #ifndef __ASSEMBLY__
  59. #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
  60. #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
  61. #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
  62. #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
  63. #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
  64. #define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
  65. #ifndef page_to_phys
  66. #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
  67. #endif
  68. #define pfn_valid(pfn) ((pfn) < max_mapnr)
  69. #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
  70. ((void *)(kaddr) < (void *)memory_end))
  71. #endif /* __ASSEMBLY__ */
  72. #include <asm-generic/memory_model.h>
  73. #include <asm-generic/getorder.h>
  74. #endif /* __ASM_GENERIC_PAGE_H */