1
0
mirror of https://github.com/taigrr/gopher-os synced 2026-03-29 13:35:17 -07:00
Files
gopher-os/kernel/panic.go
2017-06-21 21:41:24 +01:00

25 lines
654 B
Go

package kernel
import (
"github.com/achilleasa/gopher-os/kernel/cpu"
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
)
var (
// cpuHaltFn is mocked by tests and is automatically inlined by the compiler.
cpuHaltFn = cpu.Halt
)
// Panic outputs the supplied error (if not nil) to the console and halts the
// CPU. Calls to Panic never return.
func Panic(err *Error) {
early.Printf("\n-----------------------------------\n")
if err != nil {
early.Printf("[%s] unrecoverable error: %s\n", err.Module, err.Message)
}
early.Printf("*** kernel panic: system halted ***")
early.Printf("\n-----------------------------------\n")
cpuHaltFn()
}