test_burst_lib.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * (C) Copyright 2005
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <config.h>
  24. #include <ppc_asm.tmpl>
  25. #include <ppc_defs.h>
  26. #include <asm/cache.h>
  27. #include <asm/mmu.h>
  28. #include "test_burst.h"
  29. .text
  30. /*
  31. * void mmu_init(void);
  32. *
  33. * This function turns the MMU on
  34. *
  35. * Three 8 MByte regions are mapped 1:1, uncached
  36. * - SDRAM lower 8 MByte
  37. * - SDRAM higher 8 MByte
  38. * - IMMR
  39. */
  40. .global mmu_init
  41. mmu_init:
  42. tlbia /* Invalidate all TLB entries */
  43. li r8, 0
  44. mtspr MI_CTR, r8 /* Set instruction control to zero */
  45. lis r8, MD_RESETVAL@h
  46. mtspr MD_CTR, r8 /* Set data TLB control */
  47. /* Now map the lower 8 Meg into the TLBs. For this quick hack,
  48. * we can load the instruction and data TLB registers with the
  49. * same values.
  50. */
  51. li r8, MI_EVALID /* Create EPN for address 0 */
  52. mtspr MI_EPN, r8
  53. mtspr MD_EPN, r8
  54. li r8, MI_PS8MEG /* Set 8M byte page */
  55. ori r8, r8, MI_SVALID /* Make it valid */
  56. mtspr MI_TWC, r8
  57. mtspr MD_TWC, r8
  58. li r8, MI_BOOTINIT|0x2 /* Create RPN for address 0 */
  59. mtspr MI_RPN, r8 /* Store TLB entry */
  60. mtspr MD_RPN, r8
  61. lis r8, MI_Kp@h /* Set the protection mode */
  62. mtspr MI_AP, r8
  63. mtspr MD_AP, r8
  64. /* Now map the higher 8 Meg into the TLBs. For this quick hack,
  65. * we can load the instruction and data TLB registers with the
  66. * same values.
  67. */
  68. lwz r9,20(r2) /* gd->ram_size */
  69. addis r9,r9,-0x80
  70. mr r8, r9 /* Higher 8 Meg in SDRAM */
  71. ori r8, r8, MI_EVALID /* Mark page valid */
  72. mtspr MI_EPN, r8
  73. mtspr MD_EPN, r8
  74. li r8, MI_PS8MEG /* Set 8M byte page */
  75. ori r8, r8, MI_SVALID /* Make it valid */
  76. mtspr MI_TWC, r8
  77. mtspr MD_TWC, r8
  78. mr r8, r9
  79. ori r8, r8, MI_BOOTINIT|0x2
  80. mtspr MI_RPN, r8 /* Store TLB entry */
  81. mtspr MD_RPN, r8
  82. lis r8, MI_Kp@h /* Set the protection mode */
  83. mtspr MI_AP, r8
  84. mtspr MD_AP, r8
  85. /* Map another 8 MByte at the IMMR to get the processor
  86. * internal registers (among other things).
  87. */
  88. mfspr r9, 638 /* Get current IMMR */
  89. andis. r9, r9, 0xff80 /* Get 8Mbyte boundary */
  90. mr r8, r9 /* Create vaddr for TLB */
  91. ori r8, r8, MD_EVALID /* Mark it valid */
  92. mtspr MD_EPN, r8
  93. li r8, MD_PS8MEG /* Set 8M byte page */
  94. ori r8, r8, MD_SVALID /* Make it valid */
  95. mtspr MD_TWC, r8
  96. mr r8, r9 /* Create paddr for TLB */
  97. ori r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */
  98. mtspr MD_RPN, r8
  99. /* We now have the lower and higher 8 Meg mapped into TLB entries,
  100. * and the caches ready to work.
  101. */
  102. mfmsr r0
  103. ori r0,r0,MSR_DR|MSR_IR
  104. mtspr SRR1,r0
  105. mflr r0
  106. mtspr SRR0,r0
  107. SYNC
  108. rfi /* enables MMU */
  109. /*
  110. * void caches_init(void);
  111. */
  112. .globl caches_init
  113. caches_init:
  114. sync
  115. mfspr r3, IC_CST /* Clear error bits */
  116. mfspr r3, DC_CST
  117. lis r3, IDC_UNALL@h /* Unlock all */
  118. mtspr IC_CST, r3
  119. mtspr DC_CST, r3
  120. lis r3, IDC_INVALL@h /* Invalidate all */
  121. mtspr IC_CST, r3
  122. mtspr DC_CST, r3
  123. lis r3, IDC_ENABLE@h /* Enable all */
  124. mtspr IC_CST, r3
  125. mtspr DC_CST, r3
  126. blr
  127. /*
  128. * void flush_dcache_range(unsigned long start, unsigned long stop);
  129. */
  130. .global flush_dcache_range
  131. flush_dcache_range:
  132. li r5,CACHE_LINE_SIZE-1
  133. andc r3,r3,r5
  134. subf r4,r3,r4
  135. add r4,r4,r5
  136. srwi. r4,r4,LG_CACHE_LINE_SIZE
  137. beqlr
  138. mtctr r4
  139. 1: dcbf 0,r3
  140. addi r3,r3,CACHE_LINE_SIZE
  141. bdnz 1b
  142. sync /* wait for dcbf's to get to ram */
  143. blr
  144. /*
  145. * void disable_interrupts(void);
  146. */
  147. .global disable_interrupts
  148. disable_interrupts:
  149. mfmsr r0
  150. rlwinm r0,r0,0,17,15
  151. mtmsr r0
  152. blr