head.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. * Copyright (C) 1994, 1995 Waldorf Electronics
  7. * Written by Ralf Baechle and Andreas Busse
  8. * Copyright (C) 1994 - 99, 2003, 06 Ralf Baechle
  9. * Copyright (C) 1996 Paul M. Antoine
  10. * Modified for DECStation and hence R3000 support by Paul M. Antoine
  11. * Further modifications by David S. Miller and Harald Koerfgen
  12. * Copyright (C) 1999 Silicon Graphics, Inc.
  13. * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  14. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/threads.h>
  18. #include <asm/addrspace.h>
  19. #include <asm/asm.h>
  20. #include <asm/asmmacro.h>
  21. #include <asm/irqflags.h>
  22. #include <asm/regdef.h>
  23. #include <asm/pgtable-bits.h>
  24. #include <asm/mipsregs.h>
  25. #include <asm/stackframe.h>
  26. #include <kernel-entry-init.h>
  27. /*
  28. * For the moment disable interrupts, mark the kernel mode and
  29. * set ST0_KX so that the CPU does not spit fire when using
  30. * 64-bit addresses. A full initialization of the CPU's status
  31. * register is done later in per_cpu_trap_init().
  32. */
  33. .macro setup_c0_status set clr
  34. .set push
  35. mfc0 t0, CP0_STATUS
  36. or t0, ST0_CU0|\set|0x1f|\clr
  37. xor t0, 0x1f|\clr
  38. mtc0 t0, CP0_STATUS
  39. .set noreorder
  40. sll zero,3 # ehb
  41. .set pop
  42. .endm
  43. .macro setup_c0_status_pri
  44. #ifdef CONFIG_64BIT
  45. setup_c0_status ST0_KX 0
  46. #else
  47. setup_c0_status 0 0
  48. #endif
  49. .endm
  50. .macro setup_c0_status_sec
  51. #ifdef CONFIG_64BIT
  52. setup_c0_status ST0_KX ST0_BEV
  53. #else
  54. setup_c0_status 0 ST0_BEV
  55. #endif
  56. .endm
  57. #ifndef CONFIG_NO_EXCEPT_FILL
  58. /*
  59. * Reserved space for exception handlers.
  60. * Necessary for machines which link their kernels at KSEG0.
  61. */
  62. .fill 0x400
  63. #endif
  64. EXPORT(_stext)
  65. #ifdef CONFIG_BOOT_RAW
  66. /*
  67. * Give us a fighting chance of running if execution beings at the
  68. * kernel load address. This is needed because this platform does
  69. * not have a ELF loader yet.
  70. */
  71. FEXPORT(__kernel_entry)
  72. j kernel_entry
  73. #endif
  74. __REF
  75. NESTED(kernel_entry, 16, sp) # kernel entry point
  76. kernel_entry_setup # cpu specific setup
  77. setup_c0_status_pri
  78. /* We might not get launched at the address the kernel is linked to,
  79. so we jump there. */
  80. PTR_LA t0, 0f
  81. jr t0
  82. 0:
  83. #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
  84. PTR_LA t0, __appended_dtb
  85. #ifdef CONFIG_CPU_BIG_ENDIAN
  86. li t1, 0xd00dfeed
  87. #else
  88. li t1, 0xedfe0dd0
  89. #endif
  90. lw t2, (t0)
  91. bne t1, t2, not_found
  92. nop
  93. move a1, t0
  94. PTR_LI a0, -2
  95. not_found:
  96. #endif
  97. PTR_LA t0, __bss_start # clear .bss
  98. LONG_S zero, (t0)
  99. PTR_LA t1, __bss_stop - LONGSIZE
  100. 1:
  101. PTR_ADDIU t0, LONGSIZE
  102. LONG_S zero, (t0)
  103. bne t0, t1, 1b
  104. LONG_S a0, fw_arg0 # firmware arguments
  105. LONG_S a1, fw_arg1
  106. LONG_S a2, fw_arg2
  107. LONG_S a3, fw_arg3
  108. MTC0 zero, CP0_CONTEXT # clear context register
  109. PTR_LA $28, init_thread_union
  110. /* Set the SP after an empty pt_regs. */
  111. PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE
  112. PTR_ADDU sp, $28
  113. back_to_back_c0_hazard
  114. set_saved_sp sp, t0, t1
  115. PTR_SUBU sp, 4 * SZREG # init stack pointer
  116. j start_kernel
  117. END(kernel_entry)
  118. #ifdef CONFIG_SMP
  119. /*
  120. * SMP slave cpus entry point. Board specific code for bootstrap calls this
  121. * function after setting up the stack and gp registers.
  122. */
  123. NESTED(smp_bootstrap, 16, sp)
  124. smp_slave_setup
  125. setup_c0_status_sec
  126. j start_secondary
  127. END(smp_bootstrap)
  128. #endif /* CONFIG_SMP */