page.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * linux/include/asm-xtensa/page.h
  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 version2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_PAGE_H
  11. #define _XTENSA_PAGE_H
  12. #ifdef __KERNEL__
  13. #include <asm/processor.h>
  14. #define XCHAL_KSEG_CACHED_VADDR 0xd0000000
  15. #define XCHAL_KSEG_BYPASS_VADDR 0xd8000000
  16. #define XCHAL_KSEG_PADDR 0x00000000
  17. #define XCHAL_KSEG_SIZE 0x08000000
  18. /*
  19. * PAGE_SHIFT determines the page size
  20. * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
  21. */
  22. #define PAGE_SHIFT 12
  23. #define PAGE_SIZE (1 << PAGE_SHIFT)
  24. #define PAGE_MASK (~(PAGE_SIZE-1))
  25. #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
  26. #define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
  27. #define MAX_MEM_PFN XCHAL_KSEG_SIZE
  28. #define PGTABLE_START 0x80000000
  29. #ifdef __ASSEMBLY__
  30. #define __pgprot(x) (x)
  31. #else
  32. /*
  33. * These are used to make use of C type-checking..
  34. */
  35. typedef struct { unsigned long pte; } pte_t; /* page table entry */
  36. typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
  37. typedef struct { unsigned long pgprot; } pgprot_t;
  38. #define pte_val(x) ((x).pte)
  39. #define pgd_val(x) ((x).pgd)
  40. #define pgprot_val(x) ((x).pgprot)
  41. #define __pte(x) ((pte_t) { (x) } )
  42. #define __pgd(x) ((pgd_t) { (x) } )
  43. #define __pgprot(x) ((pgprot_t) { (x) } )
  44. /*
  45. * Pure 2^n version of get_order
  46. */
  47. static inline int get_order(unsigned long size)
  48. {
  49. int order;
  50. #ifndef XCHAL_HAVE_NSU
  51. unsigned long x1, x2, x4, x8, x16;
  52. size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
  53. x1 = size & 0xAAAAAAAA;
  54. x2 = size & 0xCCCCCCCC;
  55. x4 = size & 0xF0F0F0F0;
  56. x8 = size & 0xFF00FF00;
  57. x16 = size & 0xFFFF0000;
  58. order = x2 ? 2 : 0;
  59. order += (x16 != 0) * 16;
  60. order += (x8 != 0) * 8;
  61. order += (x4 != 0) * 4;
  62. order += (x1 != 0);
  63. return order;
  64. #else
  65. size = (size - 1) >> PAGE_SHIFT;
  66. asm ("nsau %0, %1" : "=r" (order) : "r" (size));
  67. return 32 - order;
  68. #endif
  69. }
  70. struct page;
  71. extern void clear_page(void *page);
  72. extern void copy_page(void *to, void *from);
  73. /*
  74. * If we have cache aliasing and writeback caches, we might have to do
  75. * some extra work
  76. */
  77. #if (DCACHE_WAY_SIZE > PAGE_SIZE)
  78. void clear_user_page(void *addr, unsigned long vaddr, struct page* page);
  79. void copy_user_page(void *to,void* from,unsigned long vaddr,struct page* page);
  80. #else
  81. # define clear_user_page(page,vaddr,pg) clear_page(page)
  82. # define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  83. #endif
  84. /*
  85. * This handles the memory map. We handle pages at
  86. * XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
  87. * These macros are for conversion of kernel address, not user
  88. * addresses.
  89. */
  90. #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
  91. #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
  92. #define pfn_valid(pfn) ((unsigned long)pfn < max_mapnr)
  93. #ifdef CONFIG_DISCONTIGMEM
  94. # error CONFIG_DISCONTIGMEM not supported
  95. #endif
  96. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  97. #define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
  98. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  99. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  100. #define WANT_PAGE_VIRTUAL
  101. #endif /* __ASSEMBLY__ */
  102. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  103. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  104. #endif /* __KERNEL__ */
  105. #include <asm-generic/memory_model.h>
  106. #endif /* _XTENSA_PAGE_H */