kernel-entry-init.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. * Chris Dearman (chris@mips.com)
  7. * Copyright (C) 2007 Mips Technologies, Inc.
  8. * Copyright (C) 2014 Imagination Technologies Ltd.
  9. */
  10. #ifndef __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
  11. #define __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
  12. #include <asm/regdef.h>
  13. #include <asm/mipsregs.h>
  14. /*
  15. * Prepare segments for EVA boot:
  16. *
  17. * This is in case the processor boots in legacy configuration
  18. * (SI_EVAReset is de-asserted and CONFIG5.K == 0)
  19. *
  20. * ========================= Mappings =============================
  21. * Virtual memory Physical memory Mapping
  22. * 0x00000000 - 0x7fffffff 0x80000000 - 0xfffffffff MUSUK (kuseg)
  23. * Flat 2GB physical memory
  24. *
  25. * 0x80000000 - 0x9fffffff 0x00000000 - 0x1ffffffff MUSUK (kseg0)
  26. * 0xa0000000 - 0xbf000000 0x00000000 - 0x1ffffffff MUSUK (kseg1)
  27. * 0xc0000000 - 0xdfffffff - MK (kseg2)
  28. * 0xe0000000 - 0xffffffff - MK (kseg3)
  29. *
  30. *
  31. * Lowmem is expanded to 2GB
  32. *
  33. * The following code uses the t0, t1, t2 and ra registers without
  34. * previously preserving them.
  35. *
  36. */
  37. .macro platform_eva_init
  38. .set push
  39. .set reorder
  40. /*
  41. * Get Config.K0 value and use it to program
  42. * the segmentation registers
  43. */
  44. mfc0 t1, CP0_CONFIG
  45. andi t1, 0x7 /* CCA */
  46. move t2, t1
  47. ins t2, t1, 16, 3
  48. /* SegCtl0 */
  49. li t0, ((MIPS_SEGCFG_MK << MIPS_SEGCFG_AM_SHIFT) | \
  50. (0 << MIPS_SEGCFG_PA_SHIFT) | \
  51. (1 << MIPS_SEGCFG_EU_SHIFT)) | \
  52. (((MIPS_SEGCFG_MK << MIPS_SEGCFG_AM_SHIFT) | \
  53. (0 << MIPS_SEGCFG_PA_SHIFT) | \
  54. (1 << MIPS_SEGCFG_EU_SHIFT)) << 16)
  55. or t0, t2
  56. mtc0 t0, CP0_SEGCTL0
  57. /* SegCtl1 */
  58. li t0, ((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \
  59. (0 << MIPS_SEGCFG_PA_SHIFT) | \
  60. (2 << MIPS_SEGCFG_C_SHIFT) | \
  61. (1 << MIPS_SEGCFG_EU_SHIFT)) | \
  62. (((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \
  63. (0 << MIPS_SEGCFG_PA_SHIFT) | \
  64. (1 << MIPS_SEGCFG_EU_SHIFT)) << 16)
  65. ins t0, t1, 16, 3
  66. mtc0 t0, CP0_SEGCTL1
  67. /* SegCtl2 */
  68. li t0, ((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \
  69. (6 << MIPS_SEGCFG_PA_SHIFT) | \
  70. (1 << MIPS_SEGCFG_EU_SHIFT)) | \
  71. (((MIPS_SEGCFG_MUSUK << MIPS_SEGCFG_AM_SHIFT) | \
  72. (4 << MIPS_SEGCFG_PA_SHIFT) | \
  73. (1 << MIPS_SEGCFG_EU_SHIFT)) << 16)
  74. or t0, t2
  75. mtc0 t0, CP0_SEGCTL2
  76. jal mips_ihb
  77. mfc0 t0, $16, 5
  78. li t2, 0x40000000 /* K bit */
  79. or t0, t0, t2
  80. mtc0 t0, $16, 5
  81. sync
  82. jal mips_ihb
  83. .set pop
  84. .endm
  85. .macro kernel_entry_setup
  86. #ifdef CONFIG_EVA
  87. sync
  88. ehb
  89. mfc0 t1, CP0_CONFIG
  90. bgez t1, 9f
  91. mfc0 t0, CP0_CONFIG, 1
  92. bgez t0, 9f
  93. mfc0 t0, CP0_CONFIG, 2
  94. bgez t0, 9f
  95. mfc0 t0, CP0_CONFIG, 3
  96. sll t0, t0, 6 /* SC bit */
  97. bgez t0, 9f
  98. platform_eva_init
  99. b 0f
  100. 9:
  101. /* Assume we came from YAMON... */
  102. PTR_LA v0, 0x9fc00534 /* YAMON print */
  103. lw v0, (v0)
  104. move a0, zero
  105. PTR_LA a1, nonsc_processor
  106. jal v0
  107. PTR_LA v0, 0x9fc00520 /* YAMON exit */
  108. lw v0, (v0)
  109. li a0, 1
  110. jal v0
  111. 1: b 1b
  112. nop
  113. __INITDATA
  114. nonsc_processor:
  115. .asciz "EVA kernel requires a MIPS core with Segment Control implemented\n"
  116. __FINIT
  117. #endif /* CONFIG_EVA */
  118. 0:
  119. .endm
  120. /*
  121. * Do SMP slave processor setup necessary before we can safely execute C code.
  122. */
  123. .macro smp_slave_setup
  124. #ifdef CONFIG_EVA
  125. sync
  126. ehb
  127. platform_eva_init
  128. #endif
  129. .endm
  130. #endif /* __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H */