1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Early initialization code for RISC-V
*
* Copyright 2013 Google Inc.
* Copyright 2016 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of
* the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*/
#include <arch/encoding.h>
#include <mcall.h>
.section ".text._start", "ax", %progbits
.globl _stack
.global _estack
.globl _start
_start:
# The boot ROM may pass the following arguments to coreboot:
# a0: the value of mhartid
# a1: a pointer to the flattened devicetree
#
# Preserve only the FDT pointer. We can query mhartid ourselves at any
# time.
#
csrw mscratch, a1
# N.B. This only works on low 4G of the address space
# and the stack must be page-aligned.
la sp, _estack
# poison the stack
la t1, _stack
li t0, 0xdeadbeef
sd t0, 0(t1)
# make room for HLS and initialize it
addi sp, sp, -HLS_SIZE
// Once again, the docs and toolchain disagree.
// Rather than get fancy I'll just lock this down
// until it all stabilizes.
//csrr a0, mhartid
csrr a0, 0xf14
call hls_init
la t0, trap_entry
csrw mtvec, t0
# clear any pending interrupts
csrwi mip, 0
# set up the mstatus register for VM
call mstatus_init
tail main
|