page.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _ASM_PAGE_H
  2. #define _ASM_PAGE_H
  3. #include <asm/virtconvert.h>
  4. #include <asm/mem-layout.h>
  5. #include <asm/sections.h>
  6. #include <asm/setup.h>
  7. #ifndef __ASSEMBLY__
  8. #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
  9. #define free_user_page(page, addr) free_page(addr)
  10. #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
  11. #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
  12. #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
  13. #define copy_user_page(vto, vfrom, vaddr, topg) memcpy((vto), (vfrom), PAGE_SIZE)
  14. /*
  15. * These are used to make use of C type-checking..
  16. */
  17. typedef struct { unsigned long pte; } pte_t;
  18. typedef struct { unsigned long ste[64];} pmd_t;
  19. typedef struct { pmd_t pue[1]; } pud_t;
  20. typedef struct { pud_t pge[1]; } pgd_t;
  21. typedef struct { unsigned long pgprot; } pgprot_t;
  22. typedef struct page *pgtable_t;
  23. #define pte_val(x) ((x).pte)
  24. #define pmd_val(x) ((x).ste[0])
  25. #define pud_val(x) ((x).pue[0])
  26. #define pgd_val(x) ((x).pge[0])
  27. #define pgprot_val(x) ((x).pgprot)
  28. #define __pte(x) ((pte_t) { (x) } )
  29. #define __pmd(x) ((pmd_t) { (x) } )
  30. #define __pud(x) ((pud_t) { (x) } )
  31. #define __pgd(x) ((pgd_t) { (x) } )
  32. #define __pgprot(x) ((pgprot_t) { (x) } )
  33. #define PTE_MASK PAGE_MASK
  34. #define devmem_is_allowed(pfn) 1
  35. #define __pa(vaddr) virt_to_phys((void *) (unsigned long) (vaddr))
  36. #define __va(paddr) phys_to_virt((unsigned long) (paddr))
  37. #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
  38. extern unsigned long max_low_pfn;
  39. extern unsigned long min_low_pfn;
  40. extern unsigned long max_pfn;
  41. #ifdef CONFIG_MMU
  42. #define pfn_valid(pfn) ((pfn) < max_mapnr)
  43. #else
  44. #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
  45. #define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
  46. #endif
  47. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  48. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  49. #define VM_DATA_DEFAULT_FLAGS \
  50. (VM_READ | VM_WRITE | \
  51. ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
  52. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  53. #endif /* __ASSEMBLY__ */
  54. #include <asm-generic/memory_model.h>
  55. #include <asm-generic/getorder.h>
  56. #endif /* _ASM_PAGE_H */