1
0
mirror of https://github.com/taigrr/gopher-os synced 2026-04-01 11:48:41 -07:00

Use pwd as a workspace; move sources to src/gopheros and rewrite imports

By setting up pwd as a Go workspace, we can trim import paths from
something like "github.com/achilleasa/gopher-os/kernel" to just
"kernel".

These changes make forking easier and also allows us to move the code to
a different git hosting provider without having to rewrite the imports.
This commit is contained in:
Achilleas Anagnostopoulos
2017-07-01 20:37:09 +01:00
parent 7b93d01c6e
commit 8dfc5d4e92
61 changed files with 93 additions and 114 deletions

View File

@@ -0,0 +1,45 @@
package kmain
import (
"gopheros/kernel"
"gopheros/kernel/goruntime"
"gopheros/kernel/hal"
"gopheros/kernel/hal/multiboot"
"gopheros/kernel/mem/pmm/allocator"
"gopheros/kernel/mem/vmm"
)
var (
errKmainReturned = &kernel.Error{Module: "kmain", Message: "Kmain returned"}
)
// Kmain is the only Go symbol that is visible (exported) from the rt0 initialization
// code. This function is invoked by the rt0 assembly code after setting up the GDT
// and setting up a a minimal g0 struct that allows Go code using the 4K stack
// allocated by the assembly code.
//
// The rt0 code passes the address of the multiboot info payload provided by the
// bootloader as well as the physical addresses for the kernel start/end.
//
// Kmain is not expected to return. If it does, the rt0 code will halt the CPU.
//
//go:noinline
func Kmain(multibootInfoPtr, kernelStart, kernelEnd uintptr) {
multiboot.SetInfoPtr(multibootInfoPtr)
hal.InitTerminal()
hal.ActiveTerminal.Clear()
var err *kernel.Error
if err = allocator.Init(kernelStart, kernelEnd); err != nil {
panic(err)
} else if err = vmm.Init(); err != nil {
panic(err)
} else if err = goruntime.Init(); err != nil {
panic(err)
}
// Use kernel.Panic instead of panic to prevent the compiler from
// treating kernel.Panic as dead-code and eliminating it.
kernel.Panic(errKmainReturned)
}