Class RAT
RAT (RAM Allocation Table) class.
Inheritance
Inherited Members
Namespace: Cosmos.Core.Memory
Assembly: Cosmos.Core.dll
Syntax
public static class RAT
Fields
| Improve this Doc View SourceFreePageCount
Number of pages which are currently not in use
Declaration
public static uint FreePageCount
Field Value
Type | Description |
---|---|
System.UInt32 |
GCTriggered
Number of the times the GC has been triggered automatically
Declaration
public static uint GCTriggered
Field Value
Type | Description |
---|---|
System.UInt32 |
HeapEnd
Pointer to end of the heap
Declaration
public static byte *HeapEnd
Field Value
Type | Description |
---|---|
System.Byte* |
MinFreePages
If number of free pages drops below this number, we trigger the GC.Collect automatically If set to -1 it is disabled
Declaration
public static int MinFreePages
Field Value
Type | Description |
---|---|
System.Int32 |
mRAT
Pointer to the RAT.
Declaration
public static byte *mRAT
Field Value
Type | Description |
---|---|
System.Byte* |
Remarks
Covers Data area only.
PageSize
Native Intel page size.
Declaration
public const uint PageSize = 4096U
Field Value
Type | Description |
---|---|
System.UInt32 |
Remarks
- x86 Page Size: 4k, 2m (PAE only), 4m.
- x64 Page Size: 4k, 2m
RamSize
Size of heap.
Declaration
public static uint RamSize
Field Value
Type | Description |
---|---|
System.UInt32 |
RamStart
Start of area usable for heap, and also start of heap.
Declaration
public static byte *RamStart
Field Value
Type | Description |
---|---|
System.Byte* |
TotalPageCount
Number of pages in the heap.
Declaration
public static uint TotalPageCount
Field Value
Type | Description |
---|---|
System.UInt32 |
Remarks
Calculated from mSize.
Methods
| Improve this Doc View SourceAllocPages(RAT.PageType, UInt32)
Alloc a given number of pages, all of the same type.
Declaration
public static void *AllocPages(RAT.PageType aType, uint aPageCount = 1U)
Parameters
Type | Name | Description |
---|---|---|
RAT.PageType | aType | A type of pages to alloc. |
System.UInt32 | aPageCount | Number of pages to alloc. (default = 1) |
Returns
Type | Description |
---|---|
System.Void* | A pointer to the first page on success, null on failure. |
Free(UInt32)
Free page.
Declaration
public static void Free(uint aPageIdx)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aPageIdx | A index to the page to be freed. |
Free(Void*)
Free the page this pointer points to
Declaration
public static void Free(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr |
GetFirstRATIndex(Void*)
Get the first RAT address.
Declaration
public static uint GetFirstRATIndex(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr | A pointer to the block. |
Returns
Type | Description |
---|---|
System.UInt32 | The index in RAT to which this pointer belongs |
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown if page type is not found. |
GetPageCount(Byte)
Get page count.
Declaration
public static uint GetPageCount(byte aType = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | aType | A page type to count. |
Returns
Type | Description |
---|---|
System.UInt32 | Number of pages of this type including extension pages |
GetPagePtr(Void*)
Get the pointer to the start of the page containing the pointer's address
Declaration
public static byte *GetPagePtr(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr |
Returns
Type | Description |
---|---|
System.Byte* |
GetPageType(Void*)
Get the page type pointed by a pointer to the RAT entry.
Declaration
public static RAT.PageType GetPageType(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr | A pointer to the page to get the type of. |
Returns
Type | Description |
---|---|
RAT.PageType | byte value. |
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown if page type is not found. |
Init(Byte*, UInt32)
Init RAT.
Declaration
public static void Init(byte *aStartPtr, uint aSize)
Parameters
Type | Name | Description |
---|---|---|
System.Byte* | aStartPtr | A pointer to the start of the heap. |
System.UInt32 | aSize | A heap size, in bytes. |
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown if:
|