page.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _CRIS_PAGE_H
  2. #define _CRIS_PAGE_H
  3. #ifdef __KERNEL__
  4. #include <asm/arch/page.h>
  5. /* PAGE_SHIFT determines the page size */
  6. #define PAGE_SHIFT 13
  7. #ifndef __ASSEMBLY__
  8. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  9. #else
  10. #define PAGE_SIZE (1 << PAGE_SHIFT)
  11. #endif
  12. #define PAGE_MASK (~(PAGE_SIZE-1))
  13. #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
  14. #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  15. #define clear_user_page(page, vaddr, pg) clear_page(page)
  16. #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  17. #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
  18. #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
  19. /*
  20. * These are used to make use of C type-checking..
  21. */
  22. #ifndef __ASSEMBLY__
  23. typedef struct { unsigned long pte; } pte_t;
  24. typedef struct { unsigned long pgd; } pgd_t;
  25. typedef struct { unsigned long pgprot; } pgprot_t;
  26. #endif
  27. #define pte_val(x) ((x).pte)
  28. #define pgd_val(x) ((x).pgd)
  29. #define pgprot_val(x) ((x).pgprot)
  30. #define __pte(x) ((pte_t) { (x) } )
  31. #define __pgd(x) ((pgd_t) { (x) } )
  32. #define __pgprot(x) ((pgprot_t) { (x) } )
  33. /* On CRIS the PFN numbers doesn't start at 0 so we have to compensate */
  34. /* for that before indexing into the page table starting at mem_map */
  35. #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
  36. #define pfn_valid(pfn) (((pfn) - (PAGE_OFFSET >> PAGE_SHIFT)) < max_mapnr)
  37. /* to index into the page map. our pages all start at physical addr PAGE_OFFSET so
  38. * we can let the map start there. notice that we subtract PAGE_OFFSET because
  39. * we start our mem_map there - in other ports they map mem_map physically and
  40. * use __pa instead. in our system both the physical and virtual address of DRAM
  41. * is too high to let mem_map start at 0, so we do it this way instead (similar
  42. * to arm and m68k I think)
  43. */
  44. #define virt_to_page(kaddr) (mem_map + (((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT))
  45. #define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
  46. #define virt_addr_valid(kaddr) pfn_valid((unsigned)(kaddr) >> PAGE_SHIFT)
  47. /* convert a page (based on mem_map and forward) to a physical address
  48. * do this by figuring out the virtual address and then use __pa
  49. */
  50. #define page_to_phys(page) __pa((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
  51. /* to align the pointer to the (next) page boundary */
  52. #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  53. #ifndef __ASSEMBLY__
  54. #endif /* __ASSEMBLY__ */
  55. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  56. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  57. #include <asm-generic/memory_model.h>
  58. #include <asm-generic/page.h>
  59. #endif /* __KERNEL__ */
  60. #endif /* _CRIS_PAGE_H */