Skip to content

Commit a9174d9

Browse files
aykevldeadprogram
authored andcommitted
runtime/fe310: do peripheral initialization in an explicit call
This avoids some issues with interp in the next commit.
1 parent 46ccb67 commit a9174d9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/runtime/runtime_fe310.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func main() {
4646
riscv.MSTATUS.SetBits(1 << 3) // MIE
4747

4848
preinit()
49+
initPeripherals()
4950
initAll()
5051
callMain()
5152
abort()
@@ -76,12 +77,8 @@ func handleInterrupt() {
7677
}
7778
}
7879

79-
func init() {
80-
pric_init()
81-
machine.UART0.Configure(machine.UARTConfig{})
82-
}
83-
84-
func pric_init() {
80+
// initPeripherals configures periperhals the way the runtime expects them.
81+
func initPeripherals() {
8582
// Make sure the HFROSC is on
8683
sifive.PRCI.HFROSCCFG.SetBits(sifive.PRCI_HFROSCCFG_ENABLE)
8784

@@ -94,6 +91,9 @@ func pric_init() {
9491

9592
// Enable the RTC.
9693
sifive.RTC.RTCCFG.Set(sifive.RTC_RTCCFG_ENALWAYS)
94+
95+
// Configure the UART.
96+
machine.UART0.Configure(machine.UARTConfig{})
9797
}
9898

9999
func preinit() {

0 commit comments

Comments
 (0)