page.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_PAGE_H
  9. #define __ASM_AVR32_PAGE_H
  10. #include <linux/const.h>
  11. /* PAGE_SHIFT determines the page size */
  12. #define PAGE_SHIFT 12
  13. #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
  14. #define PAGE_MASK (~(PAGE_SIZE-1))
  15. #define PTE_MASK PAGE_MASK
  16. #ifndef __ASSEMBLY__
  17. #include <asm/addrspace.h>
  18. extern void clear_page(void *to);
  19. extern void copy_page(void *to, void *from);
  20. #define clear_user_page(page, vaddr, pg) clear_page(page)
  21. #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  22. /*
  23. * These are used to make use of C type-checking..
  24. */
  25. typedef struct { unsigned long pte; } pte_t;
  26. typedef struct { unsigned long pgd; } pgd_t;
  27. typedef struct { unsigned long pgprot; } pgprot_t;
  28. typedef struct page *pgtable_t;
  29. #define pte_val(x) ((x).pte)
  30. #define pgd_val(x) ((x).pgd)
  31. #define pgprot_val(x) ((x).pgprot)
  32. #define __pte(x) ((pte_t) { (x) })
  33. #define __pgd(x) ((pgd_t) { (x) })
  34. #define __pgprot(x) ((pgprot_t) { (x) })
  35. /* FIXME: These should be removed soon */
  36. extern unsigned long memory_start, memory_end;
  37. /* Pure 2^n version of get_order */
  38. static inline int get_order(unsigned long size)
  39. {
  40. unsigned lz;
  41. size = (size - 1) >> PAGE_SHIFT;
  42. asm("clz %0, %1" : "=r"(lz) : "r"(size));
  43. return 32 - lz;
  44. }
  45. #endif /* !__ASSEMBLY__ */
  46. /* Align the pointer to the (next) page boundary */
  47. #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
  48. /*
  49. * The hardware maps the virtual addresses 0x80000000 -> 0x9fffffff
  50. * permanently to the physical addresses 0x00000000 -> 0x1fffffff when
  51. * segmentation is enabled. We want to make use of this in order to
  52. * minimize TLB pressure.
  53. */
  54. #define PAGE_OFFSET (0x80000000UL)
  55. /*
  56. * ALSA uses virt_to_page() on DMA pages, which I'm not entirely sure
  57. * is a good idea. Anyway, we can't simply subtract PAGE_OFFSET here
  58. * in that case, so we'll have to mask out the three most significant
  59. * bits of the address instead...
  60. *
  61. * What's the difference between __pa() and virt_to_phys() anyway?
  62. */
  63. #define __pa(x) PHYSADDR(x)
  64. #define __va(x) ((void *)(P1SEGADDR(x)))
  65. #define MAP_NR(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> PAGE_SHIFT)
  66. #define phys_to_page(phys) (pfn_to_page(phys >> PAGE_SHIFT))
  67. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  68. #ifndef CONFIG_NEED_MULTIPLE_NODES
  69. #define PHYS_PFN_OFFSET (CONFIG_PHYS_OFFSET >> PAGE_SHIFT)
  70. #define pfn_to_page(pfn) (mem_map + ((pfn) - PHYS_PFN_OFFSET))
  71. #define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PHYS_PFN_OFFSET)
  72. #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
  73. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  74. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  75. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  76. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
  77. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  78. /*
  79. * Memory above this physical address will be considered highmem.
  80. */
  81. #define HIGHMEM_START 0x20000000UL
  82. #endif /* __ASM_AVR32_PAGE_H */