• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/******************************************************************************
2 * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3 * All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************/
18
19#ifndef _RESET_VECTOR_S
20#define _RESET_VECTOR_S
21
22#define LOSCFG_IRQ_STACK_SIZE 0x800
23#define LOSCFG_NMI_STACK_SIZE 0x800
24#define LOSCFG_STARTUP_STACK_SIZE 0x800
25#define LOSCFG_EXC_STACK_SIZE 0x800
26
27.extern HalTrapVector
28.global __start_and_irq_stack_top
29.global __nmi_stack_top
30.global __except_stack_top
31.global reset_vector
32.extern BoardConfig
33
34.option rvc
35.section .entry.text, "ax"
36reset_vector:
37    tail HandleReset
38
39.section .text
40.option rvc
41HandleReset:
42    la      t0, HalTrapVector
43    csrw    mtvec, t0
44    csrwi   mstatus, 0
45    csrwi   mie, 0
46
47#ifdef LOSCFG_ARCH_FPU_ENABLE
48   /* set to initial state of FPU */
49    li      t0, RISCV_MSTATUS_FS
50    csrs    mstatus, t0
51    fssr    x0
52#endif
53
54    .option push
55    .option norelax
56    /* initialize global pointer */
57    la      gp, __global_pointer$
58    .option pop
59
60    /* initialize stack pointer */
61    la      sp, __start_and_irq_stack_top
62
63    /* Board features. */
64    call    BoardConfig
65
66    /* jump to main func. */
67    tail    main
68
69.section ".int_stack", "wa", %nobits
70
71__start_and_irq_stack:
72    .space LOSCFG_STARTUP_STACK_SIZE
73__start_and_irq_stack_top:
74
75__except_stack:
76    .space LOSCFG_EXC_STACK_SIZE
77__except_stack_top:
78
79__nmi_stack:
80    .space LOSCFG_NMI_STACK_SIZE
81__nmi_stack_top:
82
83#endif
84