1/* 2 * Copyright 2018, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the GNU General Public License version 2. Note that NO WARRANTY is provided. 8 * See "LICENSE_GPLv2.txt" for details. 9 * 10 * @TAG(DATA61_GPL) 11 */ 12 13/* 14 * 15 * Copyright 2016, 2017 Hesham Almatary, Data61/CSIRO <hesham.almatary@data61.csiro.au> 16 * Copyright 2015, 2016 Hesham Almatary <heshamelmatary@gmail.com> 17 */ 18 19#include <config.h> 20#include <util.h> 21 22.section .boot.text, "ax" 23.global _start 24.extern init_kernel 25.extern kernel_stack_alloc 26.extern __global_pointer$ 27.extern restore_user_context 28.extern trap_entry 29 30_start: 31.option push 32.option norelax 331:auipc gp, %pcrel_hi(__global_pointer$) 34 addi gp, gp, %pcrel_lo(1b) 35.option pop 36 37 /* hartid is in a4 */ 38 li sp, BIT(CONFIG_KERNEL_STACK_BITS) 39 mul sp, sp, a4 40 la x1, (kernel_stack_alloc + (BIT(CONFIG_KERNEL_STACK_BITS))) 41 add sp, sp, x1 42 43 csrrw x0, sscratch, a4 /* zero sscratch for the init task */ 44 45 /* la sp, (kernel_stack_alloc + BIT(CONFIG_KERNEL_STACK_BITS)) */ 46 jal init_kernel 47 48 la ra, restore_user_context 49 jr ra 50