diff options
| author | 2019-11-03 18:54:03 -0500 | |
|---|---|---|
| committer | 2019-11-03 22:22:41 -0500 | |
| commit | 1bdae0fe29f87daa81d2aba052a10a709b87485a (patch) | |
| tree | 16d0f4aa4c4a11222c6950b3ad60e7d1d9905036 /src/core/file_sys | |
| parent | Merge pull request #3059 from FearlessTobi/stub-am-commands (diff) | |
| download | yuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.tar.gz yuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.tar.xz yuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.zip | |
common_func: Use std::array for INSERT_PADDING_* macros.
- Zero initialization here is useful for determinism.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/content_archive.cpp | 39 | ||||
| -rw-r--r-- | src/core/file_sys/romfs.h | 19 |
2 files changed, 28 insertions, 30 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index ea5c92f61..b8bbdd1ef 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -32,11 +32,28 @@ enum class NCASectionFilesystemType : u8 { | |||
| 32 | ROMFS = 0x3, | 32 | ROMFS = 0x3, |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | struct IVFCLevel { | ||
| 36 | u64_le offset; | ||
| 37 | u64_le size; | ||
| 38 | u32_le block_size; | ||
| 39 | u32_le reserved; | ||
| 40 | }; | ||
| 41 | static_assert(sizeof(IVFCLevel) == 0x18, "IVFCLevel has incorrect size."); | ||
| 42 | |||
| 43 | struct IVFCHeader { | ||
| 44 | u32_le magic; | ||
| 45 | u32_le magic_number; | ||
| 46 | INSERT_UNION_PADDING_BYTES(8); | ||
| 47 | std::array<IVFCLevel, 6> levels; | ||
| 48 | INSERT_UNION_PADDING_BYTES(64); | ||
| 49 | }; | ||
| 50 | static_assert(sizeof(IVFCHeader) == 0xE0, "IVFCHeader has incorrect size."); | ||
| 51 | |||
| 35 | struct NCASectionHeaderBlock { | 52 | struct NCASectionHeaderBlock { |
| 36 | INSERT_PADDING_BYTES(3); | 53 | INSERT_UNION_PADDING_BYTES(3); |
| 37 | NCASectionFilesystemType filesystem_type; | 54 | NCASectionFilesystemType filesystem_type; |
| 38 | NCASectionCryptoType crypto_type; | 55 | NCASectionCryptoType crypto_type; |
| 39 | INSERT_PADDING_BYTES(3); | 56 | INSERT_UNION_PADDING_BYTES(3); |
| 40 | }; | 57 | }; |
| 41 | static_assert(sizeof(NCASectionHeaderBlock) == 0x8, "NCASectionHeaderBlock has incorrect size."); | 58 | static_assert(sizeof(NCASectionHeaderBlock) == 0x8, "NCASectionHeaderBlock has incorrect size."); |
| 42 | 59 | ||
| @@ -44,7 +61,7 @@ struct NCASectionRaw { | |||
| 44 | NCASectionHeaderBlock header; | 61 | NCASectionHeaderBlock header; |
| 45 | std::array<u8, 0x138> block_data; | 62 | std::array<u8, 0x138> block_data; |
| 46 | std::array<u8, 0x8> section_ctr; | 63 | std::array<u8, 0x8> section_ctr; |
| 47 | INSERT_PADDING_BYTES(0xB8); | 64 | INSERT_UNION_PADDING_BYTES(0xB8); |
| 48 | }; | 65 | }; |
| 49 | static_assert(sizeof(NCASectionRaw) == 0x200, "NCASectionRaw has incorrect size."); | 66 | static_assert(sizeof(NCASectionRaw) == 0x200, "NCASectionRaw has incorrect size."); |
| 50 | 67 | ||
| @@ -52,19 +69,19 @@ struct PFS0Superblock { | |||
| 52 | NCASectionHeaderBlock header_block; | 69 | NCASectionHeaderBlock header_block; |
| 53 | std::array<u8, 0x20> hash; | 70 | std::array<u8, 0x20> hash; |
| 54 | u32_le size; | 71 | u32_le size; |
| 55 | INSERT_PADDING_BYTES(4); | 72 | INSERT_UNION_PADDING_BYTES(4); |
| 56 | u64_le hash_table_offset; | 73 | u64_le hash_table_offset; |
| 57 | u64_le hash_table_size; | 74 | u64_le hash_table_size; |
| 58 | u64_le pfs0_header_offset; | 75 | u64_le pfs0_header_offset; |
| 59 | u64_le pfs0_size; | 76 | u64_le pfs0_size; |
| 60 | INSERT_PADDING_BYTES(0x1B0); | 77 | INSERT_UNION_PADDING_BYTES(0x1B0); |
| 61 | }; | 78 | }; |
| 62 | static_assert(sizeof(PFS0Superblock) == 0x200, "PFS0Superblock has incorrect size."); | 79 | static_assert(sizeof(PFS0Superblock) == 0x200, "PFS0Superblock has incorrect size."); |
| 63 | 80 | ||
| 64 | struct RomFSSuperblock { | 81 | struct RomFSSuperblock { |
| 65 | NCASectionHeaderBlock header_block; | 82 | NCASectionHeaderBlock header_block; |
| 66 | IVFCHeader ivfc; | 83 | IVFCHeader ivfc; |
| 67 | INSERT_PADDING_BYTES(0x118); | 84 | INSERT_UNION_PADDING_BYTES(0x118); |
| 68 | }; | 85 | }; |
| 69 | static_assert(sizeof(RomFSSuperblock) == 0x200, "RomFSSuperblock has incorrect size."); | 86 | static_assert(sizeof(RomFSSuperblock) == 0x200, "RomFSSuperblock has incorrect size."); |
| 70 | 87 | ||
| @@ -72,24 +89,24 @@ struct BKTRHeader { | |||
| 72 | u64_le offset; | 89 | u64_le offset; |
| 73 | u64_le size; | 90 | u64_le size; |
| 74 | u32_le magic; | 91 | u32_le magic; |
| 75 | INSERT_PADDING_BYTES(0x4); | 92 | INSERT_UNION_PADDING_BYTES(0x4); |
| 76 | u32_le number_entries; | 93 | u32_le number_entries; |
| 77 | INSERT_PADDING_BYTES(0x4); | 94 | INSERT_UNION_PADDING_BYTES(0x4); |
| 78 | }; | 95 | }; |
| 79 | static_assert(sizeof(BKTRHeader) == 0x20, "BKTRHeader has incorrect size."); | 96 | static_assert(sizeof(BKTRHeader) == 0x20, "BKTRHeader has incorrect size."); |
| 80 | 97 | ||
| 81 | struct BKTRSuperblock { | 98 | struct BKTRSuperblock { |
| 82 | NCASectionHeaderBlock header_block; | 99 | NCASectionHeaderBlock header_block; |
| 83 | IVFCHeader ivfc; | 100 | IVFCHeader ivfc; |
| 84 | INSERT_PADDING_BYTES(0x18); | 101 | INSERT_UNION_PADDING_BYTES(0x18); |
| 85 | BKTRHeader relocation; | 102 | BKTRHeader relocation; |
| 86 | BKTRHeader subsection; | 103 | BKTRHeader subsection; |
| 87 | INSERT_PADDING_BYTES(0xC0); | 104 | INSERT_UNION_PADDING_BYTES(0xC0); |
| 88 | }; | 105 | }; |
| 89 | static_assert(sizeof(BKTRSuperblock) == 0x200, "BKTRSuperblock has incorrect size."); | 106 | static_assert(sizeof(BKTRSuperblock) == 0x200, "BKTRSuperblock has incorrect size."); |
| 90 | 107 | ||
| 91 | union NCASectionHeader { | 108 | union NCASectionHeader { |
| 92 | NCASectionRaw raw; | 109 | NCASectionRaw raw{}; |
| 93 | PFS0Superblock pfs0; | 110 | PFS0Superblock pfs0; |
| 94 | RomFSSuperblock romfs; | 111 | RomFSSuperblock romfs; |
| 95 | BKTRSuperblock bktr; | 112 | BKTRSuperblock bktr; |
diff --git a/src/core/file_sys/romfs.h b/src/core/file_sys/romfs.h index 0f35639bc..1c89be8a4 100644 --- a/src/core/file_sys/romfs.h +++ b/src/core/file_sys/romfs.h | |||
| @@ -13,25 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | namespace FileSys { | 14 | namespace FileSys { |
| 15 | 15 | ||
| 16 | struct RomFSHeader; | ||
| 17 | |||
| 18 | struct IVFCLevel { | ||
| 19 | u64_le offset; | ||
| 20 | u64_le size; | ||
| 21 | u32_le block_size; | ||
| 22 | u32_le reserved; | ||
| 23 | }; | ||
| 24 | static_assert(sizeof(IVFCLevel) == 0x18, "IVFCLevel has incorrect size."); | ||
| 25 | |||
| 26 | struct IVFCHeader { | ||
| 27 | u32_le magic; | ||
| 28 | u32_le magic_number; | ||
| 29 | INSERT_PADDING_BYTES(8); | ||
| 30 | std::array<IVFCLevel, 6> levels; | ||
| 31 | INSERT_PADDING_BYTES(64); | ||
| 32 | }; | ||
| 33 | static_assert(sizeof(IVFCHeader) == 0xE0, "IVFCHeader has incorrect size."); | ||
| 34 | |||
| 35 | enum class RomFSExtractionType { | 16 | enum class RomFSExtractionType { |
| 36 | Full, // Includes data directory | 17 | Full, // Includes data directory |
| 37 | Truncated, // Traverses into data directory | 18 | Truncated, // Traverses into data directory |