page.h 2.5 KB

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