mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Move kernel panic implementation to the kfmt package
This commit is contained in:
parent
dc37e86421
commit
d8793bd530
@ -1,6 +1,7 @@
|
||||
package kernel
|
||||
package kfmt
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/kfmt/early"
|
||||
)
|
||||
@ -9,7 +10,7 @@ var (
|
||||
// cpuHaltFn is mocked by tests and is automatically inlined by the compiler.
|
||||
cpuHaltFn = cpu.Halt
|
||||
|
||||
errRuntimePanic = &Error{Module: "rt", Message: "unknown cause"}
|
||||
errRuntimePanic = &kernel.Error{Module: "rt", Message: "unknown cause"}
|
||||
)
|
||||
|
||||
// Panic outputs the supplied error (if not nil) to the console and halts the
|
||||
@ -17,10 +18,10 @@ var (
|
||||
// for calls to panic() (resolved via runtime.gopanic)
|
||||
//go:redirect-from runtime.gopanic
|
||||
func Panic(e interface{}) {
|
||||
var err *Error
|
||||
var err *kernel.Error
|
||||
|
||||
switch t := e.(type) {
|
||||
case *Error:
|
||||
case *kernel.Error:
|
||||
err = t
|
||||
case string:
|
||||
panicString(t)
|
@ -1,8 +1,9 @@
|
||||
package kernel
|
||||
package kfmt
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
@ -23,7 +24,7 @@ func TestPanic(t *testing.T) {
|
||||
t.Run("with *kernel.Error", func(t *testing.T) {
|
||||
cpuHaltCalled = false
|
||||
fb := mockTTY()
|
||||
err := &Error{Module: "test", Message: "panic test"}
|
||||
err := &kernel.Error{Module: "test", Message: "panic test"}
|
||||
|
||||
Panic(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user