2 * Minimal Nios2 system boot code.
4 * Copyright Linaro Ltd 2022
5 * SPDX-License-Identifier: GPL-2.0-or-later
14 /* Linker script defines stack at end of ram. */
17 /* Install trampoline to _fast_tlb_miss at hardcoded vector. */
20 movi r6, .L__ftm_end - _ftm_tramp
23 /* Zero the bss to satisfy C. */
33 /* Exit with main's return value. */
39 .type _start, @function
40 .size _start, . - _start
43 movia et, _fast_tlb_miss
47 .type _ftm_tramp, @function
48 .size _ftm_tramp, . - _ftm_tramp
55 /* Store return value right away, per API */
58 /* Check for both dst and src aligned. */
61 bne at, zero, .L_mc_test1
63 /* Copy blocks of 8. */
66 bltu len, at, .L_mc_test4
76 bgeu len, at, .L_mc_loop8
78 /* Copy final aligned block of 4. */
82 bltu len, at, .L_mc_test1
90 /* Copy single bytes to finish. */
93 beq len, zero, .L_mc_done
101 bne len, zero, .L_mc_loop1
111 .type memcpy, @function
112 .size memcpy, . - memcpy
119 /* Store return value right away, per API */
122 /* Check for small blocks; fall back to bytewise. */
124 bltu len, r3, .L_ms_test1
126 /* Replicate the byte across the word. */
133 /* Check for destination alignment; realign if needed. */
135 bne at, zero, .L_ms_align
137 /* Set blocks of 8. */
144 bgeu len, r3, .L_ms_loop8
146 /* Set final aligned block of 4. */
150 bltu len, at, .L_ms_test1
157 /* Set single bytes to finish. */
160 beq len, zero, .L_ms_done
166 bne len, zero, .L_ms_loop1
171 /* Realign for a large block, len >= 8. */
187 4: bgeu len, r3, .L_ms_loop8
195 .type memset, @function
196 .size memset, . - memset
199 * void __sys_outc(char c);
203 stb r4, 0(sp) /* buffer[0] = c */
205 stw at, 4(sp) /* STDOUT_FILENO */
206 stw sp, 8(sp) /* buffer */
207 stw at, 12(sp) /* len */
209 movi r4, HOSTED_WRITE
217 .type __sys_outc, @function
218 .size __sys_outc, . - __sys_outc