1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Refactor allocator and unexport it

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.
This commit is contained in:
Achilleas Anagnostopoulos
2017-06-17 08:02:39 +01:00
parent c0a9e07e83
commit ad0bf0a4ca
3 changed files with 118 additions and 87 deletions

View File

@@ -3,7 +3,8 @@ package kmain
import (
"github.com/achilleasa/gopher-os/kernel/hal"
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
"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
@@ -23,5 +24,7 @@ func Kmain(multibootInfoPtr uintptr) {
hal.InitTerminal()
hal.ActiveTerminal.Clear()
pmm.EarlyAllocator.Init()
if err := allocator.Init(); err != nil {
early.Printf("[%s] error: %s\n", err.Module, err.Message)
}
}