1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Defer kernel panic when Kmain returns

This commit is contained in:
Achilleas Anagnostopoulos 2017-07-14 07:51:04 +01:00
parent ccba8877ce
commit 66d471f442

View File

@ -39,10 +39,13 @@ func Kmain(multibootInfoPtr, kernelStart, kernelEnd, kernelPageOffset uintptr) {
panic(err)
}
// Detect and initialize hardware
hal.DetectHardware()
// After goruntime.Init returns we can safely use defer
defer func() {
// Use kfmt.Panic instead of panic to prevent the compiler from
// treating kernel.Panic as dead-code and eliminating it.
kfmt.Panic(errKmainReturned)
}()
// Detect and initialize hardware
hal.DetectHardware()
}