mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Update rt0 code to check for multiboot support and call kernel.Kmain
We still keep the required main func in stub.go to prevent the compiler from optimizing the code out. We also force the compiler not to inline the call to kernel.Kmain so we can find the symbol in the generated .o file.
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
package kernel
|
||||
|
||||
// Kmain is invoked by the boot.go and implements the actual kernel entrypoint.
|
||||
func Kmain() {
|
||||
import (
|
||||
_ "unsafe" // required for go:linkname
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/multiboot"
|
||||
)
|
||||
|
||||
// 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.
|
||||
//
|
||||
// Kmain is not expected to return. If it does, the rt0 code will halt the CPU.
|
||||
//
|
||||
//go:noinline
|
||||
func Kmain(multibootInfoPtr uint32) {
|
||||
multiboot.SetInfoPtr(uintptr(multibootInfoPtr))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user