page_32.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  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. #include <linux/const.h>
  10. #define PAGE_SHIFT 12
  11. #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
  12. #define PAGE_MASK (~(PAGE_SIZE-1))
  13. #ifndef __ASSEMBLY__
  14. #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
  15. #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  16. #define clear_user_page(addr, vaddr, page) \
  17. do { clear_page(addr); \
  18. sparc_flush_page_to_ram(page); \
  19. } while (0)
  20. #define copy_user_page(to, from, vaddr, page) \
  21. do { copy_page(to, from); \
  22. sparc_flush_page_to_ram(page); \
  23. } while (0)
  24. /* The following structure is used to hold the physical
  25. * memory configuration of the machine. This is filled in
  26. * prom_meminit() and is later used by mem_init() to set up
  27. * mem_map[]. We statically allocate SPARC_PHYS_BANKS+1 of
  28. * these structs, this is arbitrary. The entry after the
  29. * last valid one has num_bytes==0.
  30. */
  31. struct sparc_phys_banks {
  32. unsigned long base_addr;
  33. unsigned long num_bytes;
  34. };
  35. #define SPARC_PHYS_BANKS 32
  36. extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
  37. /* passing structs on the Sparc slow us down tremendously... */
  38. /* #define STRICT_MM_TYPECHECKS */
  39. #ifdef STRICT_MM_TYPECHECKS
  40. /*
  41. * These are used to make use of C type-checking..
  42. */
  43. typedef struct { unsigned long pte; } pte_t;
  44. typedef struct { unsigned long iopte; } iopte_t;
  45. typedef struct { unsigned long pmdv[16]; } pmd_t;
  46. typedef struct { unsigned long pgd; } pgd_t;
  47. typedef struct { unsigned long ctxd; } ctxd_t;
  48. typedef struct { unsigned long pgprot; } pgprot_t;
  49. typedef struct { unsigned long iopgprot; } iopgprot_t;
  50. #define pte_val(x) ((x).pte)
  51. #define iopte_val(x) ((x).iopte)
  52. #define pmd_val(x) ((x).pmdv[0])
  53. #define pgd_val(x) ((x).pgd)
  54. #define ctxd_val(x) ((x).ctxd)
  55. #define pgprot_val(x) ((x).pgprot)
  56. #define iopgprot_val(x) ((x).iopgprot)
  57. #define __pte(x) ((pte_t) { (x) } )
  58. #define __iopte(x) ((iopte_t) { (x) } )
  59. /* #define __pmd(x) ((pmd_t) { (x) } ) */ /* XXX procedure with loop */
  60. #define __pgd(x) ((pgd_t) { (x) } )
  61. #define __ctxd(x) ((ctxd_t) { (x) } )
  62. #define __pgprot(x) ((pgprot_t) { (x) } )
  63. #define __iopgprot(x) ((iopgprot_t) { (x) } )
  64. #else
  65. /*
  66. * .. while these make it easier on the compiler
  67. */
  68. typedef unsigned long pte_t;
  69. typedef unsigned long iopte_t;
  70. typedef struct { unsigned long pmdv[16]; } pmd_t;
  71. typedef unsigned long pgd_t;
  72. typedef unsigned long ctxd_t;
  73. typedef unsigned long pgprot_t;
  74. typedef unsigned long iopgprot_t;
  75. #define pte_val(x) (x)
  76. #define iopte_val(x) (x)
  77. #define pmd_val(x) ((x).pmdv[0])
  78. #define pgd_val(x) (x)
  79. #define ctxd_val(x) (x)
  80. #define pgprot_val(x) (x)
  81. #define iopgprot_val(x) (x)
  82. #define __pte(x) (x)
  83. #define __iopte(x) (x)
  84. /* #define __pmd(x) (x) */ /* XXX later */
  85. #define __pgd(x) (x)
  86. #define __ctxd(x) (x)
  87. #define __pgprot(x) (x)
  88. #define __iopgprot(x) (x)
  89. #endif
  90. typedef struct page *pgtable_t;
  91. #define TASK_UNMAPPED_BASE 0x50000000
  92. #else /* !(__ASSEMBLY__) */
  93. #define __pgprot(x) (x)
  94. #endif /* !(__ASSEMBLY__) */
  95. #define PAGE_OFFSET 0xf0000000
  96. #ifndef __ASSEMBLY__
  97. extern unsigned long phys_base;
  98. extern unsigned long pfn_base;
  99. #endif
  100. #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base)
  101. #define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
  102. #define virt_to_phys __pa
  103. #define phys_to_virt __va
  104. #define ARCH_PFN_OFFSET (pfn_base)
  105. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  106. #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
  107. #define virt_addr_valid(kaddr) ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
  108. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  109. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  110. #include <asm-generic/memory_model.h>
  111. #include <asm-generic/getorder.h>
  112. #endif /* _SPARC_PAGE_H */