2020-03-03 20:27:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 Tokita, Hiroshi <tokita.hiroshi@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2024-01-03 19:20:19 +08:00
|
|
|
#include "nuclei_csr.h"
|
|
|
|
|
2022-05-09 19:56:13 +08:00
|
|
|
#include <zephyr/toolchain.h>
|
|
|
|
#include <zephyr/arch/riscv/csr.h>
|
2020-03-03 20:27:10 +08:00
|
|
|
|
|
|
|
GTEXT(__nuclei_start)
|
2023-11-28 18:18:42 +08:00
|
|
|
SECTION_FUNC(init, __nuclei_start)
|
2020-03-03 20:27:10 +08:00
|
|
|
/* Disable Global Interrupt */
|
|
|
|
csrc mstatus, MSTATUS_MIE
|
|
|
|
/* Jump to logical address first to ensure correct operation of RAM region */
|
|
|
|
la a0, __nuclei_start
|
|
|
|
li a1, 1
|
2023-11-28 18:16:41 +08:00
|
|
|
slli a1, a1, 29 # 0x2000 0000
|
2020-03-03 20:27:10 +08:00
|
|
|
bleu a1, a0, _start0800
|
2023-11-28 18:16:41 +08:00
|
|
|
srli a1, a1, 2 # 0x0800 0000
|
2020-03-03 20:27:10 +08:00
|
|
|
bleu a1, a0, _start0800
|
|
|
|
la a0, _start0800
|
|
|
|
add a0, a0, a1
|
|
|
|
jr a0
|
|
|
|
|
|
|
|
_start0800:
|
2024-06-21 16:37:21 +08:00
|
|
|
/* Set the NMI base to share with mtvec by setting CSR_MMISC_CTL */
|
2020-03-03 20:27:10 +08:00
|
|
|
li t0, 0x200
|
|
|
|
csrs CSR_MMISC_CTL, t0
|
|
|
|
|
|
|
|
/* Disable performance counter */
|
|
|
|
csrsi mcountinhibit, 0x5
|
|
|
|
|
2023-11-28 18:16:41 +08:00
|
|
|
/* Jump to common start */
|
|
|
|
tail __start
|