head_32.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* $Id: head.S,v 1.7 2003/09/01 17:58:19 lethal Exp $
  2. *
  3. * arch/sh/kernel/head.S
  4. *
  5. * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. *
  11. * Head.S contains the SH exception handlers and startup code.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/linkage.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/mmu.h>
  17. #include <cpu/mmu_context.h>
  18. #ifdef CONFIG_CPU_SH4A
  19. #define SYNCO() synco
  20. #define PREFI(label, reg) \
  21. mov.l label, reg; \
  22. prefi @reg
  23. #else
  24. #define SYNCO()
  25. #define PREFI(label, reg)
  26. #endif
  27. .section .empty_zero_page, "aw"
  28. ENTRY(empty_zero_page)
  29. .long 1 /* MOUNT_ROOT_RDONLY */
  30. .long 0 /* RAMDISK_FLAGS */
  31. .long 0x0200 /* ORIG_ROOT_DEV */
  32. .long 1 /* LOADER_TYPE */
  33. .long 0x00000000 /* INITRD_START */
  34. .long 0x00000000 /* INITRD_SIZE */
  35. #ifdef CONFIG_32BIT
  36. .long 0x53453f00 + 32 /* "SE?" = 32 bit */
  37. #else
  38. .long 0x53453f00 + 29 /* "SE?" = 29 bit */
  39. #endif
  40. 1:
  41. .skip PAGE_SIZE - empty_zero_page - 1b
  42. __HEAD
  43. /*
  44. * Condition at the entry of _stext:
  45. *
  46. * BSC has already been initialized.
  47. * INTC may or may not be initialized.
  48. * VBR may or may not be initialized.
  49. * MMU may or may not be initialized.
  50. * Cache may or may not be initialized.
  51. * Hardware (including on-chip modules) may or may not be initialized.
  52. *
  53. */
  54. ENTRY(_stext)
  55. ! Initialize Status Register
  56. mov.l 1f, r0 ! MD=1, RB=0, BL=0, IMASK=0xF
  57. ldc r0, sr
  58. ! Initialize global interrupt mask
  59. #ifdef CONFIG_CPU_HAS_SR_RB
  60. mov #0, r0
  61. ldc r0, r6_bank
  62. #endif
  63. /*
  64. * Prefetch if possible to reduce cache miss penalty.
  65. *
  66. * We do this early on for SH-4A as a micro-optimization,
  67. * as later on we will have speculative execution enabled
  68. * and this will become less of an issue.
  69. */
  70. PREFI(5f, r0)
  71. PREFI(6f, r0)
  72. !
  73. mov.l 2f, r0
  74. mov r0, r15 ! Set initial r15 (stack pointer)
  75. #ifdef CONFIG_CPU_HAS_SR_RB
  76. mov.l 7f, r0
  77. ldc r0, r7_bank ! ... and initial thread_info
  78. #endif
  79. #ifndef CONFIG_SH_NO_BSS_INIT
  80. /*
  81. * Don't clear BSS if running on slow platforms such as an RTL simulation,
  82. * remote memory via SHdebug link, etc. For these the memory can be guaranteed
  83. * to be all zero on boot anyway.
  84. */
  85. ! Clear BSS area
  86. #ifdef CONFIG_SMP
  87. mov.l 3f, r0
  88. cmp/eq #0, r0 ! skip clear if set to zero
  89. bt 10f
  90. #endif
  91. mov.l 3f, r1
  92. add #4, r1
  93. mov.l 4f, r2
  94. mov #0, r0
  95. 9: cmp/hs r2, r1
  96. bf/s 9b ! while (r1 < r2)
  97. mov.l r0,@-r2
  98. 10:
  99. #endif
  100. ! Additional CPU initialization
  101. mov.l 6f, r0
  102. jsr @r0
  103. nop
  104. SYNCO() ! Wait for pending instructions..
  105. ! Start kernel
  106. mov.l 5f, r0
  107. jmp @r0
  108. nop
  109. .balign 4
  110. #if defined(CONFIG_CPU_SH2)
  111. 1: .long 0x000000F0 ! IMASK=0xF
  112. #else
  113. 1: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
  114. #endif
  115. ENTRY(stack_start)
  116. 2: .long init_thread_union+THREAD_SIZE
  117. 3: .long __bss_start
  118. 4: .long _end
  119. 5: .long start_kernel
  120. 6: .long sh_cpu_init
  121. 7: .long init_thread_union