page.h 2.0 KB

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