head_32.S 2.9 KB

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