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 (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
"gopheros/kernel/cpu"
|
"gopheros/kernel/cpu"
|
||||||
"gopheros/kernel/kfmt/early"
|
"gopheros/kernel/kfmt/early"
|
||||||
)
|
)
|
||||||
@ -9,7 +10,7 @@ var (
|
|||||||
// cpuHaltFn is mocked by tests and is automatically inlined by the compiler.
|
// cpuHaltFn is mocked by tests and is automatically inlined by the compiler.
|
||||||
cpuHaltFn = cpu.Halt
|
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
|
// 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)
|
// for calls to panic() (resolved via runtime.gopanic)
|
||||||
//go:redirect-from runtime.gopanic
|
//go:redirect-from runtime.gopanic
|
||||||
func Panic(e interface{}) {
|
func Panic(e interface{}) {
|
||||||
var err *Error
|
var err *kernel.Error
|
||||||
|
|
||||||
switch t := e.(type) {
|
switch t := e.(type) {
|
||||||
case *Error:
|
case *kernel.Error:
|
||||||
err = t
|
err = t
|
||||||
case string:
|
case string:
|
||||||
panicString(t)
|
panicString(t)
|
@ -1,8 +1,9 @@
|
|||||||
package kernel
|
package kfmt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"gopheros/kernel"
|
||||||
"gopheros/kernel/cpu"
|
"gopheros/kernel/cpu"
|
||||||
"gopheros/kernel/driver/video/console"
|
"gopheros/kernel/driver/video/console"
|
||||||
"gopheros/kernel/hal"
|
"gopheros/kernel/hal"
|
||||||
@ -23,7 +24,7 @@ func TestPanic(t *testing.T) {
|
|||||||
t.Run("with *kernel.Error", func(t *testing.T) {
|
t.Run("with *kernel.Error", func(t *testing.T) {
|
||||||
cpuHaltCalled = false
|
cpuHaltCalled = false
|
||||||
fb := mockTTY()
|
fb := mockTTY()
|
||||||
err := &Error{Module: "test", Message: "panic test"}
|
err := &kernel.Error{Module: "test", Message: "panic test"}
|
||||||
|
|
||||||
Panic(err)
|
Panic(err)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user