Line 420:
Line 420:
| 0x2A || 0x2A || IOSError || FreeAndClear || IOSHeapId id, void *ptr
| 0x2A || 0x2A || IOSError || FreeAndClear || IOSHeapId id, void *ptr
|-
|-
−
| 0x2B || 0x2B || IOSError || Expand || IOSHeapId id, void *ptr, u32 size
+
| 0x2B || 0x2B || IOSError || ReAlloc || IOSHeapId id, void *ptr, u32 size
|-
|-
| 0x2C || 0x2C || IOSError || IOS_RegisterResourceManager || const char* path, IOSMessageQueueId id
| 0x2C || 0x2C || IOSError || IOS_RegisterResourceManager || const char* path, IOSMessageQueueId id
Line 572:
Line 572:
| 0x76 || 0x6A || IOSError || IOS_GetSemaphoreUtilization ||
| 0x76 || 0x6A || IOSError || IOS_GetSemaphoreUtilization ||
|-
|-
−
| 0x77 || 0x6B || IOSError || GetHeapProfile ||
+
| 0x77 || 0x6B || IOSError || GetHeapProfile || IOSHeapId id, [[#IOSHeapProfile|IOSHeapProfile]] *profile
|-
|-
| 0x78 || 0x6C || IOSError || EnableIopClockMultiplier || bool enable
| 0x78 || 0x6C || IOSError || EnableIopClockMultiplier || bool enable
Line 924:
Line 924:
| 0x0 || 0x4 || Base
| 0x0 || 0x4 || Base
|-
|-
−
| 0x4 || 0x4 || Pid
+
| 0x4 || 0x4 || Owner
|-
|-
| 0x8 || 0x4 || Size
| 0x8 || 0x4 || Size
|-
|-
−
| 0xC || 0x4 || FirstFree
+
| 0xC || 0x4 || [[#IOSChunk|FreeList]]
|-
|-
−
| 0x10 || 0x4 || ErrorCountOutOfMemory
+
| 0x10 || 0x4 || AllocErrors
|-
|-
−
| 0x14 || 0x4 || ErrorCountFreeBlockNotInHeap
+
| 0x14 || 0x4 || FreeErrors
|-
|-
−
| 0x18 || 0x4 || ErrorCountExpandInvalidBlock
+
| 0x18 || 0x4 || ReAllocErrors
|-
|-
−
| 0x1C || 0x4 || ErrorCountCorruptedBlock
+
| 0x1C || 0x4 || InvalidChunks
|-
|-
| 0x20 || 0x4 || Flags
| 0x20 || 0x4 || Flags
Line 944:
Line 944:
| 0x28 || 0x4 || LargestAllocatedSize
| 0x28 || 0x4 || LargestAllocatedSize
|-
|-
−
| 0x2C || 0x4 || TotalAllocationCount
+
| 0x2C || 0x4 || AllocatedChunks
|-
|-
−
| 0x30 || 0x4 || TotalFreedCount
+
| 0x30 || 0x4 || FreeChunks
|-
|-
−
| 0x34 || 0x4 || ErrorCountFreeUnallocatedBlock
+
| 0x34 || 0x4 || FreeUnusedChunkErrors
|-
|-
−
| 0x38 || 0x4 || ErrorCountAllocInvalidHeap
+
| 0x38 || 0x4 || AllocInvalidHeapErrors
|-
|-
−
| 0x3C || 0x4 || Id
+
| 0x3C || 0x4 || AllocInvalidHeapId
|}
|}
Line 958:
Line 958:
{| class="wikitable"
{| class="wikitable"
|-
|-
−
! Heap ID
+
! Value
−
! Purpose
+
! Description
|-
|-
| 0x0001
| 0x0001
Line 984:
Line 984:
0x2: Cross process heap
0x2: Cross process heap
−
Each heap is created from memory of the shared heap. It is initialized as one big seperate memory chunk. Memory chunks have the following structure:
+
Each heap is created from memory of the shared heap. It is initialized as one big seperate memory chunk.
−
// Heap chunk header
+
When memory is allocated to a heap, the linked list (terminated using nullptr's) is traversed to find a large enough chunk, chunks are split and back and forward pointers are cleared for the allocated chunk. When a chunk is allocated aligned, a chunk bigger than the needed one may be allocated. Inside this chunk, a second heap chunk is set up in a fashion that the beginning of the memory block described by this "inner" chunk is aligned according to the specified alignment. It's magic is set to 0xBABE0002 and the back pointer is set to the chunk containing it. These inner chunks can not be expanded.
−
struct
−
{
−
0x00: magic
−
0x04: size
−
0x08: back
−
0x0C: next
−
} heap_chunk_header_t; // sizeof() = 0x10
−
There are 3 valid magic values:
+
== IOSChunk ==
+
{| class="wikitable" border="1"
+
|-
+
! Offset || Size || Description
+
|-
+
| 0x0 || 0x4 || [[#Status|Status]]
+
|-
+
| 0x4 || 0x4 || Size
+
|-
+
| 0x8 || 0x4 || [[#IOSChunk|PrevFree]]
+
|-
+
| 0xC || 0x4 || [[#IOSChunk|NextFree]]
+
|}
+
=== Status ===
{| class="wikitable"
{| class="wikitable"
|-
|-
−
! Magic
+
! Value
−
! Meaning
+
! Description
|-
|-
| 0xBABE0000
| 0xBABE0000
Line 1,012:
Line 1,018:
|}
|}
−
When memory is allocated to a heap, the linked list (terminated using nullptr's) is traversed to find a large enough chunk, chunks are split and back and forward pointers are cleared for the allocated chunk. When a chunk is allocated aligned, a chunk bigger than the needed one may be allocated. Inside this chunk, a second heap chunk is set up in a fashion that the beginning of the memory block described by this "inner" chunk is aligned according to the specified alignment. It's magic is set to 0xBABE0002 and the back pointer is set to the chunk containing it. These inner chunks can not be expanded.
+
== IOSHeapProfile ==
+
{| class="wikitable" border="1"
+
|-
+
! Offset || Size || Description
+
|-
+
| 0x0 || 0x4 || Owner
+
|-
+
| 0x4 || 0x4 || Base
+
|-
+
| 0x8 || 0x4 || Size
+
|-
+
| 0xC || 0x4 || FreeChunks
+
|-
+
| 0x10 || 0x4 || LargestChunkSize
+
|-
+
| 0x14 || 0x4 || SmallestChunkSize
+
|-
+
| 0x18 || 0x4 || TotalFreeSize
+
|-
+
| 0x1C || 0x4 || AllocErrors
+
|-
+
| 0x20 || 0x4 || FreeErrors
+
|-
+
| 0x24 || 0x4 || ReAllocErrors
+
|-
+
| 0x28 || 0x4 || CorruptChunks
+
|-
+
| 0x2C || 0x4 || InvalidChunks
+
|-
+
| 0x30 || 0x4 || Flags
+
|}
== IOSTimeStruct ==
== IOSTimeStruct ==