hiddenDangerAnalysis.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* pgtable.h: FR-V page table mangling
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. * Derived from:
  12. * include/asm-m68knommu/pgtable.h
  13. * include/asm-i386/pgtable.h
  14. */
  15. #ifndef _ASM_PGTABLE_H
  16. #define _ASM_PGTABLE_H
  17. #include <asm/mem-layout.h>
  18. #include <asm/setup.h>
  19. #include <asm/processor.h>
  20. #ifndef __ASSEMBLY__
  21. #include <linux/threads.h>
  22. #include <linux/slab.h>
  23. #include <linux/list.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/sched.h>
  26. struct vm_area_struct;
  27. #endif
  28. #ifndef __ASSEMBLY__
  29. #if defined(CONFIG_HIGHPTE)
  30. typedef unsigned long pte_addr_t;
  31. #else
  32. typedef pte_t *pte_addr_t;
  33. #endif
  34. #endif
  35. /*****************************************************************************/
  36. /*
  37. * MMU-less operation case first
  38. */
  39. #ifndef CONFIG_MMU
  40. #define pgd_present(pgd) (1) /* pages are always present on NO_MM */
  41. #define pgd_none(pgd) (0)
  42. #define pgd_bad(pgd) (0)
  43. #define pgd_clear(pgdp)
  44. #define kern_addr_valid(addr) (1)
  45. #define pmd_offset(a, b) ((void *) 0)
  46. #define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
  47. #define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
  48. #define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
  49. #define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
  50. #define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
  51. #define __swp_type(x) (0)
  52. #define __swp_offset(x) (0)
  53. #define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
  54. #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  55. #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
  56. #ifndef __ASSEMBLY__
  57. static inline int pte_file(pte_t pte) { return 0; }
  58. #endif
  59. #define ZERO_PAGE(vaddr) ({ BUG(); NULL; })
  60. #define swapper_pg_dir ((pgd_t *) NULL)
  61. #define pgtable_cache_init() do {} while (0)
  62. #include <asm-generic/pgtable.h>
  63. #else /* !CONFIG_MMU */
  64. /*****************************************************************************/
  65. /*
  66. * then MMU operation
  67. */
  68. /*
  69. * ZERO_PAGE is a global shared page that is always zero: used
  70. * for zero-mapped memory areas etc..
  71. */
  72. #ifndef __ASSEMBLY__
  73. extern unsigned long empty_zero_page;
  74. #define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
  75. #endif
  76. /*
  77. * we use 2-level page tables, folding the PMD (mid-level table) into the PGE (top-level entry)
  78. * [see Documentation/frv/mmu-layout.txt]
  79. *
  80. * Page Directory:
  81. * - Size: 16KB
  82. * - 64 PGEs per PGD
  83. * - Each PGE holds 1 PUD and covers 64MB
  84. *
  85. * Page Upper Directory:
  86. * - Size: 256B
  87. * - 1 PUE per PUD
  88. * - Each PUE holds 1 PMD and covers 64MB
  89. *
  90. * Page Mid-Level Directory
  91. * - Size: 256B
  92. * - 1 PME per PMD
  93. * - Each PME holds 64 STEs, all of which point to separate chunks of the same Page Table
  94. * - All STEs are instantiated at the same time
  95. *
  96. * Page Table
  97. * - Size: 16KB
  98. * - 4096 PTEs per PT
  99. * - Each Linux PT is subdivided into 64 FR451 PT's, each of which holds 64 entries
  100. *
  101. * Pages
  102. * - Size: 4KB
  103. *
  104. * total PTEs
  105. * = 1 PML4E * 64 PGEs * 1 PUEs * 1 PMEs * 4096 PTEs
  106. * = 1 PML4E * 64 PGEs * 64 STEs * 64 PTEs/FR451-PT
  107. * = 262144 (or 256 * 1024)
  108. */
  109. #define PGDIR_SHIFT 26
  110. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  111. #define PGDIR_MASK (~(PGDIR_SIZE - 1))
  112. #define PTRS_PER_PGD 64
  113. #define PUD_SHIFT 26
  114. #define PTRS_PER_PUD 1
  115. #define PUD_SIZE (1UL << PUD_SHIFT)
  116. #define PUD_MASK (~(PUD_SIZE - 1))
  117. #define PUE_SIZE 256
  118. #define PMD_SHIFT 26
  119. #define PMD_SIZE (1UL << PMD_SHIFT)
  120. #define PMD_MASK (~(PMD_SIZE - 1))
  121. #define PTRS_PER_PMD 1
  122. #define PME_SIZE 256
  123. #define __frv_PT_SIZE 256
  124. #define PTRS_PER_PTE 4096
  125. #define USER_PGDS_IN_LAST_PML4 (TASK_SIZE / PGDIR_SIZE)
  126. #define FIRST_USER_ADDRESS 0
  127. #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
  128. #define KERNEL_PGD_PTRS (PTRS_PER_PGD - USER_PGD_PTRS)
  129. #define TWOLEVEL_PGDIR_SHIFT 26
  130. #define BOOT_USER_PGD_PTRS (__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT)
  131. #define BOOT_KERNEL_PGD_PTRS (PTRS_PER_PGD - BOOT_USER_PGD_PTRS)
  132. #ifndef __ASSEMBLY__
  133. extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
  134. #define pte_ERROR(e) \
  135. printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte)
  136. #define pmd_ERROR(e) \
  137. printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
  138. #define pud_ERROR(e) \
  139. printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(e)))
  140. #define pgd_ERROR(e) \
  141. printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(pgd_val(e))))