head_rom.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/init.h>
  3. #include <asm/thread_info.h>
  4. #if defined(CONFIG_CPU_H8300H)
  5. .h8300h
  6. #define SYSCR 0xfee012
  7. #define IRAMTOP 0xffff20
  8. #define NR_INT 64
  9. #endif
  10. #if defined(CONFIG_CPU_H8S)
  11. .h8300s
  12. #define INTCR 0xffff31
  13. #define IRAMTOP 0xffc000
  14. #define NR_INT 128
  15. #endif
  16. __HEAD
  17. .global _start
  18. _start:
  19. mov.l #IRAMTOP,sp
  20. #if !defined(CONFIG_H8300H_SIM) && \
  21. !defined(CONFIG_H8S_SIM)
  22. jsr @lowlevel_init
  23. /* copy .data */
  24. mov.l #_begin_data,er5
  25. mov.l #_sdata,er6
  26. mov.l #_edata,er4
  27. sub.l er6,er4
  28. shlr.l er4
  29. shlr.l er4
  30. 1:
  31. mov.l @er5+,er0
  32. mov.l er0,@er6
  33. adds #4,er6
  34. dec.l #1,er4
  35. bne 1b
  36. /* .bss clear */
  37. mov.l #_sbss,er5
  38. mov.l #_ebss,er4
  39. sub.l er5,er4
  40. shlr er4
  41. shlr er4
  42. sub.l er0,er0
  43. 1:
  44. mov.l er0,@er5
  45. adds #4,er5
  46. dec.l #1,er4
  47. bne 1b
  48. #else
  49. /* get cmdline from gdb */
  50. jsr @0xcc
  51. ;; er0 - argc
  52. ;; er1 - argv
  53. mov.l #command_line,er3
  54. adds #4,er1
  55. dec.l #1,er0
  56. beq 4f
  57. 1:
  58. mov.l @er1+,er2
  59. 2:
  60. mov.b @er2+,r4l
  61. beq 3f
  62. mov.b r4l,@er3
  63. adds #1,er3
  64. bra 2b
  65. 3:
  66. mov.b #' ',r4l
  67. mov.b r4l,@er3
  68. adds #1,er3
  69. dec.l #1,er0
  70. bne 1b
  71. subs #1,er3
  72. mov.b #0,r4l
  73. mov.b r4l,@er3
  74. 4:
  75. #endif
  76. sub.l er0,er0
  77. jsr @h8300_fdt_init
  78. /* linux kernel start */
  79. #if defined(CONFIG_CPU_H8300H)
  80. ldc #0xd0,ccr /* running kernel */
  81. mov.l #SYSCR,er0
  82. bclr #3,@er0
  83. #endif
  84. #if defined(CONFIG_CPU_H8S)
  85. ldc #0x07,exr
  86. bclr #4,@INTCR:8
  87. bset #5,@INTCR:8 /* Interrupt mode 2 */
  88. ldc #0x90,ccr /* running kernel */
  89. #endif
  90. mov.l #init_thread_union,sp
  91. add.l #0x2000,sp
  92. jsr @start_kernel
  93. 1:
  94. bra 1b
  95. #if defined(CONFIG_ROMKERNEL)
  96. /* interrupt vector */
  97. .section .vectors,"ax"
  98. .long _start
  99. .long _start
  100. vector = 2
  101. .rept NR_INT - 2
  102. .long _interrupt_redirect_table+vector*4
  103. vector = vector + 1
  104. .endr
  105. #endif
  106. .end