head_64.S 3.9 KB

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