1/* 2 * Copyright (c) 2021 Antony Pavlov <antonynpavlov@gmail.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7#include <zephyr/toolchain.h> 8#include <zephyr/linker/sections.h> 9#include <mips/regdef.h> 10#include <mips/mipsregs.h> 11 12GTEXT(__initialize) 13GTEXT(__stack) 14GTEXT(z_prep_c) 15 16/* 17 * Remainder of asm-land initialization code before we can jump into 18 * the C domain. 19 */ 20SECTION_FUNC(TEXT, __initialize) 21 .set noreorder 22 23 mtc0 zero, CP0_CAUSE 24 ehb 25 26 mfc0 k0, CP0_STATUS 27 li k1, ~(ST0_ERL | ST0_IE) 28 and k0, k1 29 mtc0 k0, CP0_STATUS 30 ehb 31 32#ifdef CONFIG_INIT_STACKS 33 /* Pre-populate all bytes in z_interrupt_stacks with 0xAA */ 34 la t0, z_interrupt_stacks 35 li t1, CONFIG_ISR_STACK_SIZE 36 add t1, t1, t0 37 38 /* Populate z_interrupt_stacks with 0xaaaaaaaa */ 39 li t2, 0xaaaaaaaa 40aa_loop: 41 sw t2, 0(t0) 42 addi t0, t0, 4 43 blt t0, t1, aa_loop 44 nop /* delay slot */ 45#endif 46 47 /* 48 * Setup stack pointer. 49 */ 50 la sp, __stack 51 52 /* 53 * Jump into C domain. 54 */ 55 la v0, z_prep_c 56 jal v0 57 nop /* delay slot */ 58