page.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* $Id: page.h,v 1.55 2000/10/30 21:01:41 davem Exp $
  2. * page.h: Various defines and such for MMU operations on the Sparc for
  3. * the Linux kernel.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. */
  7. #ifndef _SPARC_PAGE_H
  8. #define _SPARC_PAGE_H
  9. #ifdef CONFIG_SUN4
  10. #define PAGE_SHIFT 13
  11. #else
  12. #define PAGE_SHIFT 12
  13. #endif
  14. #ifndef __ASSEMBLY__
  15. /* I have my suspicions... -DaveM */
  16. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  17. #else
  18. #define PAGE_SIZE (1 << PAGE_SHIFT)
  19. #endif
  20. #define PAGE_MASK (~(PAGE_SIZE-1))
  21. #include <asm/btfixup.h>
  22. #ifndef __ASSEMBLY__
  23. #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
  24. #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  25. #define clear_user_page(addr, vaddr, page) \
  26. do { clear_page(addr); \
  27. sparc_flush_page_to_ram(page); \
  28. } while (0)
  29. #define copy_user_page(to, from, vaddr, page) \
  30. do { copy_page(to, from); \
  31. sparc_flush_page_to_ram(page); \
  32. } while (0)
  33. /* The following structure is used to hold the physical
  34. * memory configuration of the machine. This is filled in
  35. * probe_memory() and is later used by mem_init() to set up
  36. * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
  37. * these structs, this is arbitrary. The entry after the
  38. * last valid one has num_bytes==0.
  39. */
  40. struct sparc_phys_banks {
  41. unsigned long base_addr;
  42. unsigned long num_bytes;
  43. };
  44. #define SPARC_PHYS_BANKS 32
  45. extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
  46. /* Cache alias structure. Entry is valid if context != -1. */
  47. struct cache_palias {
  48. unsigned long vaddr;
  49. int context;
  50. };
  51. extern struct cache_palias *sparc_aliases;
  52. /* passing structs on the Sparc slow us down tremendously... */
  53. /* #define STRICT_MM_TYPECHECKS */
  54. #ifdef STRICT_MM_TYPECHECKS
  55. /*
  56. * These are used to make use of C type-checking..
  57. */
  58. typedef struct { unsigned long pte; } pte_t;
  59. typedef struct { unsigned long iopte; } iopte_t;
  60. typedef struct { unsigned long pmdv[16]; } pmd_t;
  61. typedef struct { unsigned long pgd; } pgd_t;
  62. typedef struct { unsigned long ctxd; } ctxd_t;
  63. typedef struct { unsigned long pgprot; } pgprot_t;
  64. typedef struct { unsigned long iopgprot; } iopgprot_t;
  65. #define pte_val(x) ((x).pte)
  66. #define iopte_val(x) ((x).iopte)
  67. #define pmd_val(x) ((x).pmdv[0])
  68. #define pgd_val(x) ((x).pgd)
  69. #define ctxd_val(x) ((x).ctxd)
  70. #define pgprot_val(x) ((x).pgprot)
  71. #define iopgprot_val(x) ((x).iopgprot)
  72. #define __pte(x) ((pte_t) { (x) } )
  73. #define __iopte(x) ((iopte_t) { (x) } )
  74. /* #define __pmd(x) ((pmd_t) { (x) } ) */ /* XXX procedure with loop */
  75. #define __pgd(x) ((pgd_t) { (x) } )
  76. #define __ctxd(x) ((ctxd_t) { (x) } )
  77. #define __pgprot(x) ((pgprot_t) { (x) } )
  78. #define __iopgprot(x) ((iopgprot_t) { (x) } )
  79. #else
  80. /*
  81. * .. while these make it easier on the compiler
  82. */
  83. typedef unsigned long pte_t;
  84. typedef unsigned long iopte_t;
  85. typedef struct { unsigned long pmdv[16]; } pmd_t;
  86. typedef unsigned long pgd_t;
  87. typedef unsigned long ctxd_t;
  88. typedef unsigned long pgprot_t;
  89. typedef unsigned long iopgprot_t;
  90. #define pte_val(x) (x)
  91. #define iopte_val(x) (x)
  92. #define pmd_val(x) ((x).pmdv[0])
  93. #define pgd_val(x) (x)
  94. #define ctxd_val(x) (x)
  95. #define pgprot_val(x) (x)
  96. #define iopgprot_val(x) (x)
  97. #define __pte(x) (x)
  98. #define __iopte(x) (x)
  99. /* #define __pmd(x) (x) */ /* XXX later */
  100. #define __pgd(x) (x)
  101. #define __ctxd(x) (x)
  102. #define __pgprot(x) (x)
  103. #define __iopgprot(x) (x)
  104. #endif
  105. typedef struct page *pgtable_t;
  106. extern unsigned long sparc_unmapped_base;
  107. BTFIXUPDEF_SETHI(sparc_unmapped_base)
  108. #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base)
  109. #else /* !(__ASSEMBLY__) */
  110. #define __pgprot(x) (x)
  111. #endif /* !(__ASSEMBLY__) */
  112. /* to align the pointer to the (next) page boundary */
  113. #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  114. #define PAGE_OFFSET 0xf0000000
  115. #ifndef __ASSEMBLY__
  116. extern unsigned long phys_base;
  117. extern unsigned long pfn_base;
  118. #endif
  119. #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base)
  120. #define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
  121. #define virt_to_phys __pa
  122. #define phys_to_virt __va
  123. #define ARCH_PFN_OFFSET (pfn_base)
  124. #define virt_to_page(kaddr) (mem_map + ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT)))
  125. #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
  126. #define virt_addr_valid(kaddr) ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
  127. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  128. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  129. #include <asm-generic/memory_model.h>
  130. #include <asm-generic/page.h>
  131. #endif /* _SPARC_PAGE_H */