mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
AllocFrame now rounds up the region start address to the nearest page multiple and rounds down the region end address to the nearest page multiple. It also ignores memory regions with size smaller than a page. Instead of using frame indices and converting them to a pmm.Frame, the allocator now just keeps track of the last allocated pmm.Frame. As the allocator is now unexported, a package-exported Init() method is now provided whose purpose is to initialize the physical allocator sub-system.
31 lines
961 B
Go
31 lines
961 B
Go
package kmain
|
|
|
|
import (
|
|
"github.com/achilleasa/gopher-os/kernel/hal"
|
|
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
|
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
|
"github.com/achilleasa/gopher-os/kernel/mem/pmm/allocator"
|
|
)
|
|
|
|
// 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 uintptr) {
|
|
multiboot.SetInfoPtr(multibootInfoPtr)
|
|
|
|
hal.InitTerminal()
|
|
hal.ActiveTerminal.Clear()
|
|
|
|
if err := allocator.Init(); err != nil {
|
|
early.Printf("[%s] error: %s\n", err.Module, err.Message)
|
|
}
|
|
}
|