Line 67:
Line 67:
== AES CMAC header ==
== AES CMAC header ==
+
+
This is internally referred to as MasterHeaderMac.
+
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 432:
Line 435:
| 0x00
| 0x00
| 0x40
| 0x40
β
| [[Filesystem_services#Save_Struct|Save Struct]]
+
| [[Filesystem_services#SaveDataAttribute|SaveDataAttribute]]
|-
|-
| 0x40
| 0x40
Line 658:
Line 661:
== File allocation table ==
== File allocation table ==
β
The savedata FS uses a fairly basic allocation table to keep track of block allocation. The FAT contains doubly-linked lists of the blocks allocated to each file. Each entry in the FAT is 8 bytes in size.
+
The savedata FS uses an allocation table to keep track of block allocation. This FAT contains doubly-linked lists of the blocks allocated to each file. Each entry in the FAT is 8 bytes in size.
FAT entry 0 is reserved for the list of free blocks. Because of this, the FAT entry for block n is found at FAT index n+1. The indexes stored in FAT entries refer the index of the next/previous FAT entry in the chain, not the index of the next/previous block.
FAT entry 0 is reserved for the list of free blocks. Because of this, the FAT entry for block n is found at FAT index n+1. The indexes stored in FAT entries refer the index of the next/previous FAT entry in the chain, not the index of the next/previous block.
+
+
The FAT header is internally called AllocationTableControlArea. The FAT itself is called AllocationTableMeta. The actual save FS data is called AllocationTableData.
=== File allocation table header ===
=== File allocation table header ===
Line 705:
Line 710:
| 4
| 4
| File table block index
| File table block index
+
|-
+
|}
+
+
=== File allocation table entry ===
+
+
{| class="wikitable"
+
|-
+
! Start
+
! Length
+
! Description
+
|-
+
| 0
+
| 4 (High bit)
+
| Set if entry is the first entry in the list.
+
|-
+
| 0
+
| 4 (Lower 31 bits)
+
| Previous entry index. First entry in list if 0.
+
|-
+
| 4
+
| 4 (High bit)
+
| Set if the allocation segment has multiple blocks.
+
|-
+
| 4
+
| 4 (Lower 31 bits)
+
| Next entry index. Last entry in list if 0.
+
|-
+
|}
+
+
If the allocation segment has multiple blocks, the first entry will be followed by a range descriptor entry. The last entry in the segment will contain a duplicate of this entry.
+
+
{| class="wikitable"
+
|-
+
! Start
+
! Length
+
! Description
+
|-
+
| 0
+
| 4 (High bit)
+
| Always set.
+
|-
+
| 0
+
| 4 (Lower 31 bits)
+
| First entry in this segment.
+
|-
+
| 4
+
| 4 (High bit)
+
| Never set.
+
|-
+
| 4
+
| 4 (Lower 31 bits)
+
| Last entry in this segment.
|-
|-
|}
|}