File indexing completed on 2025-05-11 08:24:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include <rtems/asm.h>
0033 #include <rtems/score/percpu.h>
0034 #include <rtems/score/riscv-utility.h>
0035 #include <bsp/linker-symbols.h>
0036 #include <bspopts.h>
0037
0038 PUBLIC(_start)
0039
0040 .section .bsp_start_text, "wax", @progbits
0041 .align 2
0042 .option arch, +zicsr
0043 .option norelax
0044
0045 TYPE_FUNC(_start)
0046 SYM(_start):
0047
0048 .option push
0049 .option norelax
0050 LADDR gp, __global_pointer$
0051 .option pop
0052
0053
0054 #ifdef __riscv_flen
0055 li t0, MSTATUS_FS
0056 csrs mstatus, t0
0057 csrw fcsr, zero
0058 #endif
0059
0060
0061 LADDR t0, _RISCV_Exception_handler
0062 csrw mtvec, t0
0063
0064
0065 #ifdef RTEMS_SMP
0066 LADDR sp, _ISR_Stack_area_begin
0067 LADDR t2, _ISR_Stack_size
0068 csrr s0, mhartid
0069 li t3, RISCV_BOOT_HARTID
0070 sub s0, s0, t3
0071
0072
0073
0074
0075
0076
0077 LREG t3, _SMP_Processor_configured_maximum
0078 bgeu s0, t3, .Lwfi
0079
0080 LADDR t0, _Per_CPU_Information
0081 slli t1, s0, PER_CPU_CONTROL_SIZE_LOG2
0082 add s1, t0, t1
0083 csrw mscratch, s1
0084 bnez s0, .Lstart_on_secondary_processor
0085 add sp, sp, t2
0086 #else
0087 LADDR sp, _ISR_Stack_area_end
0088 #endif
0089
0090 #ifdef BSP_START_COPY_FDT_FROM_U_BOOT
0091 mv a0, a1
0092 call bsp_fdt_copy
0093 #endif
0094
0095
0096 LADDR a0, bsp_section_bss_begin
0097 li a1, 0
0098 LADDR a2, bsp_section_bss_size
0099 call memset
0100
0101 #ifdef RTEMS_SMP
0102
0103 LADDR t0, .Lsecondary_processor_go
0104 fence iorw,ow
0105 amoswap.w zero, zero, 0(t0)
0106 #endif
0107
0108 li a0, 0
0109 tail boot_card
0110
0111 #ifdef RTEMS_SMP
0112 .Lwfi:
0113 wfi
0114 j .Lwfi
0115
0116 .Lstart_on_secondary_processor:
0117
0118
0119 #ifdef __riscv_mul
0120 addi t0, s0, 1
0121 mul t2, t2, t0
0122 #else
0123 mv t0, s0
0124 mv t3, t2
0125
0126 .Ladd_more:
0127
0128 add t2, t2, t3
0129 addi t0, t0, -1
0130 bnez t0, .Ladd_more
0131 #endif
0132 add sp, sp, t2
0133
0134
0135 LADDR t0, .Lsecondary_processor_go
0136
0137 .Lwait_for_go_again:
0138
0139 lw t1, 0(t0)
0140 fence iorw, iorw
0141 bnez t1, .Lwait_for_go_again
0142
0143 mv a0, s1
0144 call bsp_start_on_secondary_processor
0145
0146 .section .bsp_start_data, "aw"
0147
0148 .type .Lsecondary_processor_go, @object
0149
0150 #if __riscv_xlen == 32
0151 .size .Lsecondary_processor_go, 4
0152 .align 2
0153 #elif __riscv_xlen == 64
0154 .size .Lsecondary_processor_go, 8
0155 .align 3
0156 #endif
0157
0158 .Lsecondary_processor_go:
0159
0160
0161
0162
0163
0164 .word 0x00100073
0165 #if __riscv_xlen == 64
0166 .word 0x00100073
0167 #endif
0168
0169 #endif