1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00
Achilleas Anagnostopoulos e67e2644e2 mm: refactor package layout for the memory management code
Summary of changes:
- kernel/mem renamed to kernel/mm
- consolidated page/frame defs into one file which now lives in the
kernel/mm package and is referenced by both pmm and vmm pkgs
- consolidated parts of the vmm code (e.g. PDT+PTE)
- memcopy/memset helpers moved to the kernel package
- physical allocators moved to the kernel/mm/pmm package
- break vmm -> pmm pkg dependency by moving AllocFrame() into the mm
package.
2018-05-28 08:16:26 +01:00

40 lines
1007 B
Go

package pmm
import (
"gopheros/kernel"
"gopheros/kernel/mm"
)
var (
// bootMemAllocator is the page allocator used when the kernel boots.
// It is used to bootstrap the bitmap allocator which is used for all
// page allocations while the kernel runs.
bootMemAllocator BootMemAllocator
// bitmapAllocator is the standard allocator used by the kernel.
bitmapAllocator BitmapAllocator
)
// Init sets up the kernel physical memory allocation sub-system.
func Init(kernelStart, kernelEnd uintptr) *kernel.Error {
bootMemAllocator.init(kernelStart, kernelEnd)
bootMemAllocator.printMemoryMap()
mm.SetFrameAllocator(earlyAllocFrame)
// Using the bootMemAllocator bootstrap the bitmap allocator
if err := bitmapAllocator.init(); err != nil {
return err
}
mm.SetFrameAllocator(bitmapAllocFrame)
return nil
}
func earlyAllocFrame() (mm.Frame, *kernel.Error) {
return bootMemAllocator.AllocFrame()
}
func bitmapAllocFrame() (mm.Frame, *kernel.Error) {
return bitmapAllocator.AllocFrame()
}