page.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _ASM_SCORE_PAGE_H
  2. #define _ASM_SCORE_PAGE_H
  3. #include <linux/pfn.h>
  4. #include <linux/const.h>
  5. /* PAGE_SHIFT determines the page size */
  6. #define PAGE_SHIFT (12)
  7. #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
  8. #define PAGE_MASK (~(PAGE_SIZE-1))
  9. #ifdef __KERNEL__
  10. #ifndef __ASSEMBLY__
  11. #define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
  12. #define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1)))
  13. /* align addr on a size boundary - adjust address up/down if needed */
  14. #define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1)))
  15. #define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1)))
  16. /* align addr on a size boundary - adjust address up if needed */
  17. #define _ALIGN(addr, size) _ALIGN_UP(addr, size)
  18. /*
  19. * PAGE_OFFSET -- the first address of the first page of memory. When not
  20. * using MMU this corresponds to the first free page in physical memory (aligned
  21. * on a page boundary).
  22. */
  23. #define PAGE_OFFSET (0xA0000000UL)
  24. #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
  25. #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
  26. #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
  27. #define copy_user_page(vto, vfrom, vaddr, topg) \
  28. memcpy((vto), (vfrom), PAGE_SIZE)
  29. /*
  30. * These are used to make use of C type-checking..
  31. */
  32. typedef struct { unsigned long pte; } pte_t; /* page table entry */
  33. typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
  34. typedef struct { unsigned long pgprot; } pgprot_t;
  35. typedef struct page *pgtable_t;
  36. #define pte_val(x) ((x).pte)
  37. #define pgd_val(x) ((x).pgd)
  38. #define pgprot_val(x) ((x).pgprot)
  39. #define __pte(x) ((pte_t) { (x) })
  40. #define __pgd(x) ((pgd_t) { (x) })
  41. #define __pgprot(x) ((pgprot_t) { (x) })
  42. extern unsigned long max_low_pfn;
  43. extern unsigned long min_low_pfn;
  44. extern unsigned long max_pfn;
  45. #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
  46. #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
  47. #define phys_to_pfn(phys) (PFN_DOWN(phys))
  48. #define pfn_to_phys(pfn) (PFN_PHYS(pfn))
  49. #define virt_to_pfn(vaddr) (phys_to_pfn((__pa(vaddr))))
  50. #define pfn_to_virt(pfn) __va(pfn_to_phys((pfn)))
  51. #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
  52. #define page_to_virt(page) (pfn_to_virt(page_to_pfn(page)))
  53. #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
  54. #define page_to_bus(page) (page_to_phys(page))
  55. #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr)))
  56. #define pfn_valid(pfn) (((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn))
  57. #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
  58. #endif /* __ASSEMBLY__ */
  59. #define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
  60. #endif /* __KERNEL__ */
  61. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  62. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  63. #include <asm-generic/memory_model.h>
  64. #include <asm-generic/getorder.h>
  65. #endif /* _ASM_SCORE_PAGE_H */