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

Rename pfn pkg to pmm and export boot allocator Init method

This commit is contained in:
Achilleas Anagnostopoulos 2017-05-15 10:00:41 +01:00 committed by Achilleas Anagnostopoulos
parent 412bcf8402
commit 13d5f494e2
5 changed files with 11 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package kernel
import (
"github.com/achilleasa/gopher-os/kernel/hal"
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
)
// Kmain is the only Go symbol that is visible (exported) from the rt0 initialization
@ -19,7 +20,8 @@ import (
func Kmain(multibootInfoPtr uintptr) {
multiboot.SetInfoPtr(multibootInfoPtr)
// Initialize and clear the terminal
hal.InitTerminal()
hal.ActiveTerminal.Clear()
pmm.EarlyAllocator.Init()
}

View File

@ -1,4 +1,4 @@
package pfn
package pmm
import (
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
@ -30,8 +30,6 @@ var (
// blocks will be handed over to a more advanced memory allocator that does
// support freeing.
type BootMemAllocator struct {
initialized bool
// allocCount tracks the total number of allocated frames.
allocCount uint64
@ -39,11 +37,10 @@ type BootMemAllocator struct {
lastAllocIndex int64
}
// init sets up the boot memory allocator internal state and prints out the
// Init sets up the boot memory allocator internal state and prints out the
// system memory map.
func (alloc *BootMemAllocator) init() {
func (alloc *BootMemAllocator) Init() {
alloc.lastAllocIndex = -1
alloc.initialized = true
early.Printf("[boot_mem_alloc] system memory map:\n")
var totalFree mem.Size
@ -69,10 +66,6 @@ func (alloc *BootMemAllocator) init() {
// error then the compiler would call runtime.convT2I which in turn invokes the
// yet uninitialized Go allocator.
func (alloc *BootMemAllocator) AllocFrame(order mem.PageOrder) (Frame, bool) {
if !alloc.initialized {
alloc.init()
}
if order > 0 {
return InvalidFrame, false
}

View File

@ -1,4 +1,4 @@
package pfn
package pmm
import (
"testing"
@ -35,7 +35,7 @@ func TestBootMemoryAllocator(t *testing.T) {
alloc BootMemAllocator
allocFrameCount uint64
)
for ; ; allocFrameCount++ {
for alloc.Init(); ; allocFrameCount++ {
frame, ok := alloc.AllocFrame(mem.PageOrder(0))
if !ok {
break

View File

@ -1,6 +1,5 @@
// Package pfn provides physical memory allocator implementations that allow
// allocations of physical memory frames.
package pfn
// Package pmm contains code that manages physical memory frame allocations.
package pmm
import (
"math"

View File

@ -1,4 +1,4 @@
package pfn
package pmm
import (
"testing"