page.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * U-boot - page.h
  3. *
  4. * Copyright (c) 2005 blackfin.uclinux.org
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef _BLACKFIN_PAGE_H
  25. #define _BLACKFIN_PAGE_H
  26. #include <linux/config.h>
  27. /* PAGE_SHIFT determines the page size */
  28. #define PAGE_SHIFT (12)
  29. #define PAGE_SIZE (4096)
  30. #define PAGE_MASK (~(PAGE_SIZE-1))
  31. #ifdef __KERNEL__
  32. #include <asm/setup.h>
  33. #if PAGE_SHIFT < 13
  34. #define KTHREAD_SIZE (8192)
  35. #else
  36. #define KTHREAD_SIZE PAGE_SIZE
  37. #endif
  38. #ifndef __ASSEMBLY__
  39. #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
  40. #define free_user_page(page, addr) free_page(addr)
  41. #define clear_page(page) memset((page), 0, PAGE_SIZE)
  42. #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
  43. #define clear_user_page(page, vaddr) clear_page(page)
  44. #define copy_user_page(to, from, vaddr) copy_page(to, from)
  45. /*
  46. * These are used to make use of C type-checking..
  47. */
  48. typedef struct {
  49. unsigned long pte;
  50. } pte_t;
  51. typedef struct {
  52. unsigned long pmd[16];
  53. } pmd_t;
  54. typedef struct {
  55. unsigned long pgd;
  56. } pgd_t;
  57. typedef struct {
  58. unsigned long pgprot;
  59. } pgprot_t;
  60. #define pte_val(x) ((x).pte)
  61. #define pmd_val(x) ((&x)->pmd[0])
  62. #define pgd_val(x) ((x).pgd)
  63. #define pgprot_val(x) ((x).pgprot)
  64. #define __pte(x) ((pte_t) { (x) } )
  65. #define __pmd(x) ((pmd_t) { (x) } )
  66. #define __pgd(x) ((pgd_t) { (x) } )
  67. #define __pgprot(x) ((pgprot_t) { (x) } )
  68. /* to align the pointer to the (next) page boundary */
  69. #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  70. /* Pure 2^n version of get_order */
  71. extern __inline__ int get_order(unsigned long size)
  72. {
  73. int order;
  74. size = (size - 1) >> (PAGE_SHIFT - 1);
  75. order = -1;
  76. do {
  77. size >>= 1;
  78. order++;
  79. } while (size);
  80. return order;
  81. }
  82. #endif /* !__ASSEMBLY__ */
  83. #include <asm/page_offset.h>
  84. #define PAGE_OFFSET (PAGE_OFFSET_RAW)
  85. #ifndef __ASSEMBLY__
  86. #define __pa(vaddr) virt_to_phys((void *)vaddr)
  87. #define __va(paddr) phys_to_virt((unsigned long)paddr)
  88. #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
  89. #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
  90. #define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
  91. #define BUG() do { \
  92. \
  93. while (1); /* dead-loop */ \
  94. } while (0)
  95. #define PAGE_BUG(page) do { \
  96. BUG(); \
  97. } while (0)
  98. #endif
  99. #endif
  100. #endif