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