head_64.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * arch/shmedia/boot/compressed/head.S
  7. *
  8. * Copied from
  9. * arch/shmedia/kernel/head.S
  10. * which carried the copyright:
  11. * Copyright (C) 2000, 2001 Paolo Alberelli
  12. *
  13. * Modification for compressed loader:
  14. * Copyright (C) 2002 Stuart Menefy (stuart.menefy@st.com)
  15. */
  16. #include <asm/cache.h>
  17. #include <cpu/mmu_context.h>
  18. #include <cpu/registers.h>
  19. /*
  20. * Fixed TLB entries to identity map the beginning of RAM
  21. */
  22. #define MMUIR_TEXT_H 0x0000000000000003 | CONFIG_MEMORY_START
  23. /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
  24. #define MMUIR_TEXT_L 0x000000000000009a | CONFIG_MEMORY_START
  25. /* 512 Mb, Cacheable (Write-back), execute, Not User, Ph. Add. */
  26. #define MMUDR_CACHED_H 0x0000000000000003 | CONFIG_MEMORY_START
  27. /* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */
  28. #define MMUDR_CACHED_L 0x000000000000015a | CONFIG_MEMORY_START
  29. /* 512 Mb, Cacheable (Write-back), read/write, Not User, Ph. Add. */
  30. #define ICCR0_INIT_VAL ICCR0_ON | ICCR0_ICI /* ICE + ICI */
  31. #define ICCR1_INIT_VAL ICCR1_NOLOCK /* No locking */
  32. #if 1
  33. #define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WB /* OCE + OCI + WB */
  34. #else
  35. #define OCCR0_INIT_VAL OCCR0_OFF
  36. #endif
  37. #define OCCR1_INIT_VAL OCCR1_NOLOCK /* No locking */
  38. .text
  39. .global startup
  40. startup:
  41. /*
  42. * Prevent speculative fetch on device memory due to
  43. * uninitialized target registers.
  44. * This must be executed before the first branch.
  45. */
  46. ptabs/u r63, tr0
  47. ptabs/u r63, tr1
  48. ptabs/u r63, tr2
  49. ptabs/u r63, tr3
  50. ptabs/u r63, tr4
  51. ptabs/u r63, tr5
  52. ptabs/u r63, tr6
  53. ptabs/u r63, tr7
  54. synci
  55. /*
  56. * Set initial TLB entries for cached and uncached regions.
  57. * Note: PTA/BLINK is PIC code, PTABS/BLINK isn't !
  58. */
  59. /* Clear ITLBs */
  60. pta 1f, tr1
  61. movi ITLB_FIXED, r21
  62. movi ITLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22
  63. 1: putcfg r21, 0, r63 /* Clear MMUIR[n].PTEH.V */
  64. addi r21, TLB_STEP, r21
  65. bne r21, r22, tr1
  66. /* Clear DTLBs */
  67. pta 1f, tr1
  68. movi DTLB_FIXED, r21
  69. movi DTLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22
  70. 1: putcfg r21, 0, r63 /* Clear MMUDR[n].PTEH.V */
  71. addi r21, TLB_STEP, r21
  72. bne r21, r22, tr1
  73. /* Map one big (512Mb) page for ITLB */
  74. movi ITLB_FIXED, r21
  75. movi MMUIR_TEXT_L, r22 /* PTEL first */
  76. putcfg r21, 1, r22 /* Set MMUIR[0].PTEL */
  77. movi MMUIR_TEXT_H, r22 /* PTEH last */
  78. putcfg r21, 0, r22 /* Set MMUIR[0].PTEH */
  79. /* Map one big CACHED (512Mb) page for DTLB */
  80. movi DTLB_FIXED, r21
  81. movi MMUDR_CACHED_L, r22 /* PTEL first */
  82. putcfg r21, 1, r22 /* Set MMUDR[0].PTEL */
  83. movi MMUDR_CACHED_H, r22 /* PTEH last */
  84. putcfg r21, 0, r22 /* Set MMUDR[0].PTEH */
  85. /* ICache */
  86. movi ICCR_BASE, r21
  87. movi ICCR0_INIT_VAL, r22
  88. movi ICCR1_INIT_VAL, r23
  89. putcfg r21, ICCR_REG0, r22
  90. putcfg r21, ICCR_REG1, r23
  91. synci
  92. /* OCache */
  93. movi OCCR_BASE, r21
  94. movi OCCR0_INIT_VAL, r22
  95. movi OCCR1_INIT_VAL, r23
  96. putcfg r21, OCCR_REG0, r22
  97. putcfg r21, OCCR_REG1, r23
  98. synco
  99. /*
  100. * Enable the MMU.
  101. * From here-on code can be non-PIC.
  102. */
  103. movi SR_HARMLESS | SR_ENABLE_MMU, r22
  104. putcon r22, SSR
  105. movi 1f, r22
  106. putcon r22, SPC
  107. synco
  108. rte /* And now go into the hyperspace ... */
  109. 1: /* ... that's the next instruction ! */
  110. /* Set initial stack pointer */
  111. movi datalabel stack_start, r0
  112. ld.l r0, 0, r15
  113. /*
  114. * Clear bss
  115. */
  116. pt 1f, tr1
  117. movi datalabel __bss_start, r22
  118. movi datalabel _end, r23
  119. 1: st.l r22, 0, r63
  120. addi r22, 4, r22
  121. bne r22, r23, tr1
  122. /*
  123. * Decompress the kernel.
  124. */
  125. pt decompress_kernel, tr0
  126. blink tr0, r18
  127. /*
  128. * Disable the MMU.
  129. */
  130. movi SR_HARMLESS, r22
  131. putcon r22, SSR
  132. movi 1f, r22
  133. putcon r22, SPC
  134. synco
  135. rte /* And now go into the hyperspace ... */
  136. 1: /* ... that's the next instruction ! */
  137. /* Jump into the decompressed kernel */
  138. movi datalabel (CONFIG_MEMORY_START + 0x2000)+1, r19
  139. ptabs r19, tr0
  140. blink tr0, r18
  141. /* Shouldn't return here, but just in case, loop forever */
  142. pt 1f, tr0
  143. 1: blink tr0, r63