mirror of
				https://github.com/taigrr/gopher-os
				synced 2025-01-18 04:43:13 -08:00 
			
		
		
		
	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.
		
			
				
	
	
		
			28 lines
		
	
	
		
			644 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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)
 | 
						|
}
 |