1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00
gopher-os/kernel/mem/pmm/frame.go
Achilleas Anagnostopoulos d7eb2547dd Change the Frame type to uintptr and remove Size/Order methods
To keep the implementation portable, the Frame type had to be changed
from uint64 to uintptr. Using uintptr ensures that the frame will always
match the pointer size of the platform.
2017-05-31 15:07:09 +01:00

28 lines
644 B
Go

// Package pmm contains code that manages physical memory frame allocations.
package pmm
import (
"math"
"github.com/achilleasa/gopher-os/kernel/mem"
)
// Frame describes a physical memory page index.
type Frame uintptr
const (
// InvalidFrame is returned by page allocators when
// they fail to reserve the requested frame.
InvalidFrame = Frame(math.MaxUint64)
)
// IsValid returns true if this is a valid frame.
func (f Frame) IsValid() bool {
return f != InvalidFrame
}
// Address returns a pointer to the physical memory address pointed to by this Frame.
func (f Frame) Address() uintptr {
return uintptr(f << mem.PageShift)
}