C# 클래스 SharpOS.Kernel.Memory.PageAllocator

The PageAllocator class handles physical memory page allocation and provides the OS an interface for memory paging/mapping. The PageAllocator class is portable, making use of the SharpOS.ADC.Pager class to implement platform- specific paging mechanisms.
파일 보기 프로젝트 열기: sharpos/SharpOS 1 사용 예제들

공개 메소드들

메소드 설명
Alloc ( ) : void*

Allocates a page of memory. This function returns null when out of memory.

Dealloc ( void page ) : void

Deallocates the memory page pointed to by page.

Dump ( int count ) : void
DumpInfo ( ) : void
DumpStack ( uint stack, uint stackptr, int count ) : void
GetPageAttributes ( void page, uint granularity, PageAllocator ret_err ) : PageAttributes
IsPageFree ( void page ) : bool

Checks if a given page is allocated. If the page is allocated, the method returns true. This function starts from the current stack pointer and goes backward.

IsPageReserved ( void page ) : bool

Returns true if the given page is reserved (that is, not available for allocation).

MapPage ( void page, void physPage, uint granularity, PageAttributes attr ) : PageAllocator.Errors

Modifies the virtual memory mapping of the given super-page to point to the given physical super page. Both pointers must be aligned along the platform's native super-page boundaries.

This function is only available on platforms which can provide super-page mapping. The Intel 386 and later processors support this using the 'page directory', which maps large 4MB sections of memory at a time (via redirection to page tables which contain 4KB blocks).

ReservePage ( void page ) : bool

Reserves a memory page so that it cannot be allocated using M:Alloc() or M:RangeAlloc(uint count).

ReservePageRange ( void firstPage, uint pages, string name ) : bool

Reserves a range of memory pages so that they cannot be allocated using M:Alloc() or M:RangeAlloc(uint count).

SetPageAttributes ( void page, uint granularity, PageAttributes attr ) : Errors
Setup ( byte kernelOffset, uint _kernelSize, uint totalKbMem ) : void

Initializes page management and paging. Using Alloc and related management functions before calling this function results in a kernel panic. After this function is called, the ReservePage and ReservePageRange functions can be used to reserve memory that should not be allocated. You should ensure that no memory allocations have happened between calling this function and reserving memory.

비공개 메소드들

메소드 설명
DumpReservedStack ( ReservedPages pageStack, uint stackPtr, int count ) : void
GetReservedPage ( ) : ReservedPages*
PopFreePage ( ) : void*

Pops the free page from the free page stack

PrintError ( Errors error ) : void
PtrToPage ( void ptr ) : void*

Gets the page address of a given pointer.

PushFreePage ( void page ) : void

Pushes the free page to the free page stack

메소드 상세

Alloc() 공개 정적인 메소드

Allocates a page of memory. This function returns null when out of memory.
public static Alloc ( ) : void*
리턴 void*

Dealloc() 공개 정적인 메소드

Deallocates the memory page pointed to by page.
public static Dealloc ( void page ) : void
page void /// A pointer which is aligned along the platform's native page boundaries. ///
리턴 void

Dump() 공개 정적인 메소드

public static Dump ( int count ) : void
count int
리턴 void

DumpInfo() 공개 정적인 메소드

public static DumpInfo ( ) : void
리턴 void

DumpStack() 공개 정적인 메소드

public static DumpStack ( uint stack, uint stackptr, int count ) : void
stack uint
stackptr uint
count int
리턴 void

GetPageAttributes() 공개 정적인 메소드

public static GetPageAttributes ( void page, uint granularity, PageAllocator ret_err ) : PageAttributes
page void
granularity uint
ret_err PageAllocator
리턴 PageAttributes

IsPageFree() 공개 정적인 메소드

Checks if a given page is allocated. If the page is allocated, the method returns true. This function starts from the current stack pointer and goes backward.
public static IsPageFree ( void page ) : bool
page void
리턴 bool

IsPageReserved() 공개 정적인 메소드

Returns true if the given page is reserved (that is, not available for allocation).
public static IsPageReserved ( void page ) : bool
page void
리턴 bool

MapPage() 공개 정적인 메소드

Modifies the virtual memory mapping of the given super-page to point to the given physical super page. Both pointers must be aligned along the platform's native super-page boundaries.
This function is only available on platforms which can provide super-page mapping. The Intel 386 and later processors support this using the 'page directory', which maps large 4MB sections of memory at a time (via redirection to page tables which contain 4KB blocks).
public static MapPage ( void page, void physPage, uint granularity, PageAttributes attr ) : PageAllocator.Errors
page void
physPage void
granularity uint
attr PageAttributes /// The attributes to apply to the paging table entry for this super-page. If /// one or more flags given in this parameter are not supported by the current /// platform, the call will fail, returning false. ///
리턴 PageAllocator.Errors

ReservePage() 공개 정적인 메소드

Reserves a memory page so that it cannot be allocated using M:Alloc() or M:RangeAlloc(uint count).
public static ReservePage ( void page ) : bool
page void /// A pointer which is aligned along the platform's native page boundaries. ///
리턴 bool

ReservePageRange() 공개 정적인 메소드

Reserves a range of memory pages so that they cannot be allocated using M:Alloc() or M:RangeAlloc(uint count).
public static ReservePageRange ( void firstPage, uint pages, string name ) : bool
firstPage void
pages uint /// The amount of pages to reserve. ///
name string
리턴 bool

SetPageAttributes() 공개 정적인 메소드

public static SetPageAttributes ( void page, uint granularity, PageAttributes attr ) : Errors
page void
granularity uint
attr PageAttributes
리턴 Errors

Setup() 공개 정적인 메소드

Initializes page management and paging. Using Alloc and related management functions before calling this function results in a kernel panic. After this function is called, the ReservePage and ReservePageRange functions can be used to reserve memory that should not be allocated. You should ensure that no memory allocations have happened between calling this function and reserving memory.
public static Setup ( byte kernelOffset, uint _kernelSize, uint totalKbMem ) : void
kernelOffset byte
_kernelSize uint
totalKbMem uint
리턴 void