commandProcessing.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * linux/arch/arm/mm/mmu.c
  3. *
  4. * Copyright (C) 1995-2005 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/init.h>
  14. #include <linux/mman.h>
  15. #include <linux/nodemask.h>
  16. #include <linux/memblock.h>
  17. #include <linux/fs.h>
  18. #include <linux/vmalloc.h>
  19. #include <linux/sizes.h>
  20. #include <asm/cp15.h>
  21. #include <asm/cputype.h>
  22. #include <asm/sections.h>
  23. #include <asm/cachetype.h>
  24. #include <asm/setup.h>
  25. #include <asm/smp_plat.h>
  26. #include <asm/tlb.h>
  27. #include <asm/highmem.h>
  28. #include <asm/system_info.h>
  29. #include <asm/traps.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/pci.h>
  33. #include "mm.h"
  34. /*
  35. * empty_zero_page is a special page that is used for
  36. * zero-initialized data and COW.
  37. */
  38. struct page *empty_zero_page;
  39. EXPORT_SYMBOL(empty_zero_page);
  40. /*
  41. * The pmd table for the upper-most set of pages.
  42. */
  43. pmd_t *top_pmd;
  44. #define CPOLICY_UNCACHED 0
  45. #define CPOLICY_BUFFERED 1
  46. #define CPOLICY_WRITETHROUGH 2
  47. #define CPOLICY_WRITEBACK 3
  48. #define CPOLICY_WRITEALLOC 4
  49. static unsigned int cachepolicy __initdata = CPOLICY_WRITEBACK;
  50. static unsigned int ecc_mask __initdata = 0;
  51. pgprot_t pgprot_user;
  52. pgprot_t pgprot_kernel;
  53. EXPORT_SYMBOL(pgprot_user);
  54. EXPORT_SYMBOL(pgprot_kernel);
  55. struct cachepolicy {
  56. const char policy[16];
  57. unsigned int cr_mask;
  58. pmdval_t pmd;
  59. pteval_t pte;
  60. };
  61. static struct cachepolicy cache_policies[] __initdata = {
  62. {
  63. .policy = "uncached",
  64. .cr_mask = CR_W|CR_C,
  65. .pmd = PMD_SECT_UNCACHED,
  66. .pte = L_PTE_MT_UNCACHED,
  67. }, {
  68. .policy = "buffered",
  69. .cr_mask = CR_C,
  70. .pmd = PMD_SECT_BUFFERED,
  71. .pte = L_PTE_MT_BUFFERABLE,
  72. }, {
  73. .policy = "writethrough",
  74. .cr_mask = 0,
  75. .pmd = PMD_SECT_WT,
  76. .pte = L_PTE_MT_WRITETHROUGH,
  77. }, {
  78. .policy = "writeback",
  79. .cr_mask = 0,
  80. .pmd = PMD_SECT_WB,
  81. .pte = L_PTE_MT_WRITEBACK,
  82. }, {
  83. .policy = "writealloc",
  84. .cr_mask = 0,
  85. .pmd = PMD_SECT_WBWA,
  86. .pte = L_PTE_MT_WRITEALLOC,
  87. }
  88. };
  89. /*
  90. * These are useful for identifying cache coherency
  91. * problems by allowing the cache or the cache and
  92. * writebuffer to be turned off. (Note: the write
  93. * buffer should not be on and the cache off).
  94. */
  95. static int __init early_cachepolicy(char *p)
  96. {
  97. int i;
  98. for (i = 0; i < ARRAY_SIZE(cache_policies); i++) {
  99. int len = strlen(cache_policies[i].policy);
  100. if (memcmp(p, cache_policies[i].policy, len) == 0) {
  101. cachepolicy = i;
  102. cr_alignment &= ~cache_policies[i].cr_mask;
  103. cr_no_alignment &= ~cache_policies[i].cr_mask;
  104. break;
  105. }
  106. }
  107. if (i == ARRAY_SIZE(cache_policies))
  108. printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n");
  109. /*
  110. * This restriction is partly to do with the way we boot; it is
  111. * unpredictable to have memory mapped using two different sets of
  112. * memory attributes (shared, type, and cache attribs). We can not
  113. * change these attributes once the initial assembly has setup the
  114. * page tables.
  115. */
  116. if (cpu_architecture() >= CPU_ARCH_ARMv6) {
  117. printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n");
  118. cachepolicy = CPOLICY_WRITEBACK;
  119. }
  120. flush_cache_all();
  121. set_cr(cr_alignment);
  122. return 0;
  123. }
  124. early_param("cachepolicy", early_cachepolicy);
  125. static int __init early_nocache(char *__unused)
  126. {
  127. char *p = "buffered";
  128. printk(KERN_WARNING "nocache is deprecated; use cachepolicy=%s\n", p);
  129. early_cachepolicy(p);
  130. return 0;
  131. }
  132. early_param("nocache", early_nocache);
  133. static int __init early_nowrite(char *__unused)
  134. {
  135. char *p = "uncached";
  136. printk(KERN_WARNING "nowb is deprecated; use cachepolicy=%s\n", p);
  137. early_cachepolicy(p);
  138. return 0;
  139. }
  140. early_param("nowb", early_nowrite);
  141. #ifndef CONFIG_ARM_LPAE
  142. static int __init early_ecc(char *p)
  143. {
  144. if (memcmp(p, "on", 2) == 0)
  145. ecc_mask = PMD_PROTECTION;
  146. else if (memcmp(p, "off", 3) == 0)
  147. ecc_mask = 0;
  148. return 0;
  149. }
  150. early_param("ecc", early_ecc);
  151. #endif
  152. static int __init noalign_setup(char *__unused)
  153. {
  154. cr_alignment &= ~CR_A;
  155. cr_no_alignment &= ~CR_A;
  156. set_cr(cr_alignment);
  157. return 1;
  158. }
  159. __setup("noalign", noalign_setup);
  160. #ifndef CONFIG_SMP
  161. void adjust_cr(unsigned long mask, unsigned long set)
  162. {
  163. unsigned long flags;
  164. mask &= ~CR_A;
  165. set &= mask;
  166. local_irq_save(flags);
  167. cr_no_alignment = (cr_no_alignment & ~mask) | set;
  168. cr_alignment = (cr_alignment & ~mask) | set;
  169. set_cr((get_cr() & ~mask) | set);