1/*
2 * nds32_init.inc
3 *
4 * NDS32 architecture startup assembler header file
5 *
6 */
7
8.macro nds32_init
9
10	! Initialize GP for data access
11	la      $gp, _SDA_BASE_
12
13#if defined(__NDS32_EXT_EX9__)
14	! Check HW for EX9
15	mfsr    $r0, $MSC_CFG
16	li      $r1, (1 << 24)
17	and     $r2, $r0, $r1
18	beqz    $r2, 1f
19
20	! Initialize the table base of EX9 instruction
21	la      $r0, _ITB_BASE_
22	mtusr   $r0, $ITB
231:
24#endif
25
26#if defined(__NDS32_EXT_FPU_DP__) || defined(__NDS32_EXT_FPU_SP__)
27	! Enable FPU
28	mfsr    $r0, $FUCOP_CTL
29	ori     $r0, $r0, #0x1
30	mtsr    $r0, $FUCOP_CTL
31	dsb
32
33	! Enable denormalized flush-to-Zero mode
34	fmfcsr  $r0
35	ori     $r0,$r0,#0x1000
36	fmtcsr  $r0
37	dsb
38#endif
39
40	! Initialize default stack pointer
41	la      $sp, _stack
42
43.endm
44