TwlToolsRED/build/tools/TamperDetectorForSrl/twl_format_rom.h
n1481 47983519a2 TWL-ROMフォーマットの主要部分に対応
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@566 7061adef-622a-194b-ae81-725974e89856
2011-07-01 07:48:13 +00:00

646 lines
25 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
Project: TwlSDK - tools - makerom.TWL
File: format_rom.h
Copyright 2007-2009 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef FORMAT_ROM_H_
#define FORMAT_ROM_H_
#include "twl_format_rom_certificate.h"
#define FILE_NAME_LENGTH 128
#define ROMHEADER_CORP_ID "NINTENDO "
#define TITLE_NAME_MAX 12
#define GAME_CODE_MAX 4
#define MAKER_CODE_MAX 2
#define DIGEST_SIZE_SHA1 20
#define AES_BLOCK_SIZE 16
#define SECURE_AREA_START 0x00004000
#define SECURE_AREA_END 0x00008000
#define SECURE_AREA_SIZE (SECURE_AREA_END - SECURE_AREA_START)
// for out_romheader.c size check
#define BOOTABLE_SIZE_ARM9 0x0027c000 // 2.5M - 16K (0x02004000 to 0x02280000)
#define BOOTABLE_SIZE_ARM7 0x00040000 // 256K (0x02380000 to 0x023c0000) // NITRO-IPL ̃<C38C><C692>[ƒhƒTƒCƒY<C692>§ŒÀ
#define BOOTABLE_SIZE_ARM9_LTD 0x00280000 // 2.5M (0x02400000 to 0x02680000)
#define BOOTABLE_SIZE_ARM7_LTD 0x000fc000 // 1M - 16K (0x02e80000 to 0x02f80000 or 0x02f00000 to 0x02ffc000)
#define SIZE_OF_SIGN 136
#define NITROCODE_LE 0x2106c0de
#define NITROCODE_BE 0xdec00621
#define TWLCODE_LE 0x6314c0de
#define TWLCODE_BE 0xdec01463
#define NINTENDO_LOGO_DATA_LENGTH 0x9c
// use PlatformCode
#define PLATFORM_CODE_FLAG_NTR 0x00 // <20>¦ŠùÌNTR-ROMƒwƒbƒ_Ìplatform_codelª"0"Å é½ß<E2809A>Aê“÷Ì<E2809A>ôÅ<E2809A>B
#define PLATFORM_CODE_FLAG_NOT_NTR 0x01
#define PLATFORM_CODE_FLAG_TWL 0x02
#define PLATFORM_CODE_FLAG_NTR_MASK 0x01
#define PLATFORM_CODE_NTR ( PLATFORM_CODE_FLAG_NTR )
#define PLATFORM_CODE_TWL_HYBLID ( PLATFORM_CODE_FLAG_NTR | PLATFORM_CODE_FLAG_TWL )
#define PLATFORM_CODE_TWL_LIMITED ( PLATFORM_CODE_FLAG_NOT_NTR | PLATFORM_CODE_FLAG_TWL )
// use TitleID_Hi
#define TITLE_ID_HI_APP_TYPE_SHIFT 0
#define TITLE_ID_HI_NOT_LAUNCH_FLAG_SHIFT 1
#define TITLE_ID_HI_MEDIA_CODE_SHIFT 2
#define TITLE_ID_HI_DATA_ONLY_FLAG_SHIFT 3
#define TITLE_ID_HI_SECURE_FLAG_SHIFT 4
#define TITLE_ID_HI_PUBLISHER_CODE_SHIFT 16
#define TITLE_ID_HI_APP_TYPE_MASK ( 0x0001 << TITLE_ID_HI_APP_TYPE_SHIFT )
#define TITLE_ID_HI_NOT_LAUNCH_FLAG_MASK ( 0x0001 << TITLE_ID_HI_NOT_LAUNCH_FLAG_SHIFT )
#define TITLE_ID_HI_MEDIA_MASK ( 0x0001 << TITLE_ID_HI_MEDIA_CODE_SHIFT )
#define TITLE_ID_HI_DATA_ONLY_FLAG_MASK ( 0x0001 << TITLE_ID_HI_DATA_ONLY_FLAG_SHIFT )
#define TITLE_ID_HI_SECURE_FLAG_MASK ( 0x0001 << TITLE_ID_HI_SECURE_FLAG_SHIFT )
#define TITLE_ID_HI_PUBLISHER_CODE_MASK ( 0xffff << TITLE_ID_HI_PUBLISHER_CODE_SHIFT )
// use TitleID
#define TITLE_ID_HI_SHIFT_OFFSET 32
#define TITLE_ID_APP_TYPE_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_APP_TYPE_SHIFT )
#define TITLE_ID_NOT_LAUNCH_FLAG_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_NOT_LAUNCH_FLAG_SHIFT )
#define TITLE_ID_MEDIA_CODE_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_MEDIA_CODE_SHIFT )
#define TITLE_ID_DATA_ONLY_FLAG_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_DATA_ONLY_FLAG_SHIFT )
#define TITLE_ID_SECURE_FLAG_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_SECURE_FLAG_SHIFT )
#define TITLE_ID_PUBLISHER_CODE_SHIFT ( TITLE_ID_HI_SHIFT_OFFSET + TITLE_ID_HI_PUBLISHER_CODE_SHIFT )
#define TITLE_ID_APP_TYPE_MASK ( 0x0001ULL << TITLE_ID_APP_TYPE_SHIFT )
#define TITLE_ID_NOT_LAUNCH_FLAG_MASK ( 0x0001ULL << TITLE_ID_NOT_LAUNCH_FLAG_SHIFT )
#define TITLE_ID_MEDIA_MASK ( 0x0001ULL << TITLE_ID_MEDIA_CODE_SHIFT )
#define TITLE_ID_DATA_ONLY_FLAG_MASK ( 0x0001ULL << TITLE_ID_DATA_ONLY_FLAG_SHIFT )
#define TITLE_ID_SECURE_FLAG_MASK ( 0x0001ULL << TITLE_ID_SECURE_FLAG_SHIFT )
#define TITLE_ID_PUBLISHER_CODE_MASK ( 0xffffULL << TITLE_ID_PUBLISHER_CODE_SHIFT )
#define PARENTAL_CONTROL_INFO_SIZE 0x10
/*---------------------------------------------------------------------------*
<20>퓃ƒWƒ…<C692>—pƒpƒ‰ƒ<E280B0>ƒ^
*---------------------------------------------------------------------------*/
typedef struct {
u8* rom_address; // “]‘—Œ³ ROM ƒAƒhƒŒƒX
u8* entry_address; // ŽÀ<C5BD>sŠJŽn<C5BD>iƒGƒ“ƒgƒŠ<C692>jƒAƒhƒŒƒX
u8* ram_address; // “]<E28098>æ RAM ƒAƒhƒŒƒX
s32 rom_size; // “]‘— ROM ƒTƒCƒY
} ROM_ResidentModuleParam; // <20>íÌ ... resident
// ROMƒwƒbƒ_<C692>Eƒu<C692>[ƒgƒpƒ‰ƒ<E280B0><C692>[ƒ^<5E>\‘¢‘Ì (ƒIƒŠƒWƒiƒÌè`)
typedef struct {
u8 *romAddr; // ROMƒAƒhƒŒƒX
u8 *entryAddr; // ƒGƒ“ƒgƒŠƒAƒhƒŒƒX
u8 *ramAddr; // RAMƒAƒhƒŒƒX
s32 romSize; // ROMƒTƒCƒY
} BootUsrParam;
/*===========================================================================*
* ROM FORMAT
*===========================================================================*/
// ROM access control info
typedef struct RomAccessControl {
u32 common_client_key :1; // launcher deliver common client Key
u32 hw_aes_slot_B :1; // launcher deliver HW AES slot B setting for ES
u32 hw_aes_slot_C :1; // launcher deliver HW AES slot C setting for NAM
u32 sd_card_access :1; // sd card access control
u32 nand_access :1; // NAND access control
u32 game_card_on :1; // NANDƒAƒvƒŠÅƒQ<C692>[ƒ€ƒJ<C692>[ƒh“dŒ¹ON<4F>iƒm<C692>[ƒ}ƒƒ<C692>[ƒh<C692>j
u32 shared2_file :1; // shared file in "nand:/shared2"
u32 hw_aes_slot_B_SignJPEGForLauncher :1; // launcher deliver HW AES slot B setting for Sign JPEG for Launcher
u32 game_card_nitro_mode :1; // NANDƒAƒvƒŠÅƒQ<C692>[ƒ€ƒJ<C692>[ƒhNTRŒÝŠ·—̈æÖƒAƒNƒZƒX
u32 hw_aes_slot_A_SSLClientCert :1; // launcher deliver HW AES slot A setting for SSL Client Certificate
u32 hw_aes_slot_B_SignJPEGForUser :1; // launcher deliver HW AES slot B setting for Sign JPEG for User
u32 photo_access_read :1; // "photo:" archive read-access control
u32 photo_access_write :1; // "photo:" archive write-access control
u32 sdmc_access_read :1; // "sdmc:" archive read-access control
u32 sdmc_access_write :1; // "sdmc:" archive write-access control
u32 backup_access_read :1; // CARD-backup read-access control
u32 backup_access_write :1; // CARD-backup write-access control
u32: 14;
u32 common_client_key_for_debugger_sysmenu :1; // launcher deliver common client Key
}RomAccessControl;
// ROM expansion flags
typedef struct RomExpansionFlags {
u8 codec_mode:1; // 0:NTR mode, 1:TWL mode // undeveloped
u8 agree_EULA:1; // 1: necessary agree EULA
u8 availableSubBannerFile:1; // 1: Available SubBannerFile
u8 WiFiConnectionIcon :1; // 1: WiFiConnectionðƒ‰ƒ“ƒ`ƒƒ<C692>[‚Å•\ަ
u8 DSWirelessIcon :1; // 1: DSWirelessIconðƒ‰ƒ“ƒ`ƒƒ<C692>[‚Å•\ަ
u8 rsv_d5:1;
u8 enable_nitro_whitelist_signature :1; // 1: NITROƒzƒ<7A>ƒCƒgƒŠƒXƒg<C692><67>¼—LŒøƒtƒ‰ƒO
u8 developer_encrypt:1; // 1: ŠJ”­—pƒZƒLƒ…ƒŠƒeƒBª©©ÁÄ¢é<E2809A>ê<EFBFBD>É"1"<22>B<EFBFBD>»•i”ÅÅÍ"0" (<28>¦TwlSDK UIG_branch/RC2ˆÈ<CB86>~ͱ¿çª—LŒø<C592>j
}RomExpansionFlags;
//---------------------------------------------------------------------------
// Section A ROM HEADER
//---------------------------------------------------------------------------
typedef struct ROM_Header_Short
{
//==========================================================
//
// NTR/TWL common
//
//==========================================================
//
// 0x000 System Reserved
//
char title_name[TITLE_NAME_MAX]; // Soft title name
char game_code[GAME_CODE_MAX]; // Game code
char maker_code[MAKER_CODE_MAX]; // Maker code
char platform_code; // Platform code bit0: not support NTR, bit1: support TWL ( NTR_only=0x00, NTR/TWL=0x03, TWL_only=0x02 )
u8 rom_type; // Rom type
u8 rom_size; // Rom size (2Ìrom_size<7A>æ Mbit: ex. 128MbitÌÆ«rom_size = 7)
u8 reserved_A[7]; // System Reserved A ( Set ALL 0 )
u8 enable_signature:1; // enable ROM Header signature
u8 enable_aes:1; // enable AES encryption
u8 developer_encrypt_old:1; // ŠJ”­—pƒZƒLƒ…ƒŠƒeƒBª©©ÁÄ¢é<E2809A>ê<EFBFBD>É"1"<22>B<EFBFBD>»•i”ÅÅÍ"0" (<28>¦TwlSDK RC plusÜÅͱ¿çª—LŒø<C592>j
u8 disable_debug:1; // ƒfƒoƒbƒOÖŽ~ƒtƒ‰ƒO
u8: 4;
u8 permit_landing_normal_jump:1; // ƒAƒvƒŠƒWƒƒƒ“ƒṽm<C692>[ƒ}ƒƒWƒƒƒ“ƒvÅŒÄÑ<E2809A>o³ê鱯ð‰Â·é( for TWL Application Jump )
u8 permit_landing_tmp_jump:1; // ƒAƒvƒŠƒWƒƒƒ“ƒvÌTMPƒWƒƒƒ“ƒvÅŒÄÑ<E2809A>o³ê鱯ð‰Â·é( for TWL Application Jump )
// <20>¦NTRÌŒ±”ŃAƒvƒŠÍDSƒ_ƒEƒ“ƒ<E2809C><C692>[ƒhƒvƒŒƒCÌ<E2809A><C38C>¼µ©Â¢Ä¢È¢ÌÅ<E2809A>A±Ìƒtƒ‰ƒOÍNTR-ROMƒwƒbƒ_Ì0x160bytes“à̗̈æÉŠi”[·é•K—vª é<E2809A>B
u8: 4;
u8 for_korea:1; // For Korea
u8 for_china:1; // For China
u8 rom_version; // Rom version
u8 comp_arm9_boot_area:1; // Compress arm9 boot area
u8 comp_arm7_boot_area:1; // Compress arm7 boot area
u8 inspect_card:1; // Show inspect card
u8 disable_clear_memory_pad:1; // for Debugger
u8 enable_twl_rom_cache_read:1; // Enable TWL ROM cacheRead command
u8 :1; // reserved.
u8 warning_no_spec_rom_speed:1;// Warning not to specify rom speed
u8 disable_detect_pull_out:1; //
//
// 0x020 for Static modules (Section:B)
//
// ARM9
union {
BootUsrParam arm9;
struct {
u32 main_rom_offset; // ROM offset
void *main_entry_address; // Entry point
void *main_ram_address; // RAM address
u32 main_size; // Module size
};
};
// ARM7
union {
BootUsrParam arm7;
struct {
u32 sub_rom_offset; // ROM offset
void *sub_entry_address; // Entry point
void *sub_ram_address; // RAM address
u32 sub_size; // Module size
};
};
//
// 0x040 for File Name Table[FNT] (Section:C)
//
struct ROM_FNT *fnt_offset; // ROM offset
u32 fnt_size; // Table size
//
// 0x048 for File Allocation Table[FAT] (Section:E)
//
struct ROM_FAT *fat_offset; // ROM offset
u32 fat_size; // Table size
//
// 0x050 for Overlay Tables[OVT] (Section:D)
//
// ARM9
struct ROM_OVT *main_ovt_offset; // ROM offset
u32 main_ovt_size; // Table size
// ARM7
struct ROM_OVT *sub_ovt_offset; // ROM offset
u32 sub_ovt_size; // Table size
// 0x060 for ROM control parameter (Section:F)
u32 game_cmd_param; // Game command parameter
u32 secure_cmd_param; // Secure command parameter
u32 banner_offset; // Banner ROM offset
u16 secure_area_crc16; // Secure area CRC-16
u16 secure_cmd_latency; // Secure command latency ((param+2)*256 system cycles)
// since NITRO-SDK 2.0PR4
void *main_autoload_done; // ARM9 autoload done callback address (debug purpose)
void *sub_autoload_done; // ARM7 autoload done callback address (debug purpose)
u8 ctrl_reserved_B[8]; // Ctrl Reserved B (Set 0)
// since NITRO-SDK 2.0PR6
u32 rom_valid_size; // ROM Original Size
u32 rom_header_size; // ROM Header size
u32 main_module_param_offset; // Offset for table of ARM9 module parameters
u32 sub_module_param_offset; // Offset for table of ARM7 module parameters
// 0x090 - 0x0C0 System Reserved
u16 twl_card_normal_area_rom_offset; // undeveloped
u16 twl_card_keytable_area_rom_offset; // undeveloped
u16 nand_card_dl_area_rom_offset; // undeveloped
u16 nand_card_bk_area_rom_offset; // undeveloped
u8 nand_card_flag; // undeveloped
u8 reserved_B[39];
// 0x0C0 for NINTENDO logo data
u8 nintendo_logo[ NINTENDO_LOGO_DATA_LENGTH ]; // NINTENDO logo data
u16 nintendo_logo_crc16; // CRC-16
// 0x15E ROM header CRC-16
u16 header_crc16; // ROM header CRC-16
// 0x160 - 0x180 Debugger Reserved
u8 reserved_C[32]; // Debugger Reserved (Set ALL 0)
//==========================================================
//
// TWL only
//
//==========================================================
// 0x180 - 0x190 TWL-WRAM A/B/C ARM9 configuration data
u32 main_wram_config_data[8]; // developing...
// 0x1A0 - 0x1B0 TWL-WRAM A/B/C ARM7 configuration data
u32 sub_wram_config_data[4]; // developing...
// 0x1B0 - Card Region bitmap
u32 card_region_bitmap;
// 0x1B4 - AccessControl
RomAccessControl access_control;
/* <>ˆÓ<CB86>F fatfs_command.c “à‚Å 0x01b4 ̃AƒhƒŒƒXð
ƒn<C692>[ƒhƒR<C692>[ƒfƒBƒ“ƒOµÄ¢Ü·<E2809A>B ±Ìƒ<C38C>ƒ“ƒõIƒtƒZƒbƒgð•Ï<E280A2>XµÈ¢Å‰º³¢<E2809A>B */
// 0x1B8 - ARM7-SCFG
u32 arm7_scfg_ext; // SCFG-EXT
// padding(3byte)
u8 reserved_ltd_A2[ 3 ];
// 0x1BF - TWL expansion flags
RomExpansionFlags exFlags;
// 0x1C0 for EX Static modules
//
// ARM9
union {
BootUsrParam ltd_arm9;
struct {
u32 main_ltd_rom_offset; // ROM offset // undeveloped
u8 reserved_ltd_B[ 4 ];
void *main_ltd_ram_address; // RAM address // undeveloped //
u32 main_ltd_size; // Module size // undeveloped //
};
};
// ARM7
union {
BootUsrParam ltd_arm7;
struct {
u32 sub_ltd_rom_offset; // ROM offset // undeveloped
void *sub_mount_info_ram_address; // ARM7 MountInfo RAM address.
void *sub_ltd_ram_address; // RAM address // undeveloped //
u32 sub_ltd_size; // Module size // undeveloped //
/* <>ˆÓ<CB86>F os_reset.c / crt0.HYB.c / crt0.LTD.c “à‚Å 0x01c0 <20>` 0x01e0 ̃AƒhƒŒƒXð
ƒn<C692>[ƒhƒR<C692>[ƒfƒBƒ“ƒOµÄ¢Ü·<E2809A>B ±êçWẪ<C38C>ƒ“ƒõIƒtƒZƒbƒgð•Ï<E280A2>XµÈ¢Å‰º³¢<E2809A>B */
};
};
// 0x01E0 - 0x01E8 for NITRO digest area offset & size
u32 nitro_digest_area_rom_offset;
u32 nitro_digest_area_size;
// 0x01E8 - 0x01F0 for TWL digest area offset & size
u32 twl_digest_area_rom_offset;
u32 twl_digest_area_size;
// 0x01F0 - 0x01F8 for FS digest table1 offset & size
u32 digest1_table_offset;
u32 digest1_table_size;
// 0x01F8 - 0x0200 for FS digest table2 offset & size
u32 digest2_table_offset;
u32 digest2_table_size;
// 0x0200 - 0x0208 for FS digest config parameters
u32 digest1_block_size;
u32 digest2_covered_digest1_num;
// 0x0208 - 0x020C for TWL banner size.
u32 banner_size;
// 0x020C - 0x020E for shared2 files size
u8 shared2_file0_size; // shared2 file [0]
u8 shared2_file1_size; // shared2 file [1]
/* <>ˆÓ<CB86>F fatfs_command.c “à‚Å 0x020C-0x020D ̃AƒhƒŒƒXð
ƒn<C692>[ƒhƒR<C692>[ƒfƒBƒ“ƒOµÄ¢Ü·<E2809A>B ±Ìƒ<C38C>ƒ“ƒõIƒtƒZƒbƒgð•Ï<E280A2>XµÈ¢Å‰º³¢<E2809A>B */
// 0x020E for Agree EULA version
u8 agree_EULA_version;
// 0x020F TWL Administration flags
u8 unnecessary_rating_display:1; // ƒŒ<C692>[ƒeƒBƒ“ƒO•\Lª¢çÈ¢ROMÌÆ«É—§Äé(ŠÇ—<C387>—p:ƒ‰ƒ“ƒ`ƒƒ<C692>[ÅÍ•sŽg—p)
u8: 7;
// 0x0210 - 0x0214 for TWL rom valid size
u32 twl_rom_valid_size; // ROM Original Size
// 0x0214 - 0x0218 for shared2 files size
u8 shared2_file2_size; // shared2 file [2]
u8 shared2_file3_size; // shared2 file [3]
u8 shared2_file4_size; // shared2 file [4]
u8 shared2_file5_size; // shared2 file [5]
/* <>ˆÓ<CB86>F fatfs_command.c “à‚Å 0x0214 - 0x0217 ̃AƒhƒŒƒXð
ƒn<C692>[ƒhƒR<C692>[ƒfƒBƒ“ƒOµÄ¢Ü·<E2809A>B ±Ìƒ<C38C>ƒ“ƒõIƒtƒZƒbƒgð•Ï<E280A2>XµÈ¢Å‰º³¢<E2809A>B */
// 0x0218 - 0x0220 for TWL ltd module param offset
u32 main_ltd_module_param_offset; // Offset for table of ARM9 ltd module parameters
u32 sub_ltd_module_param_offset; // Offset for table of ARM7 ltd module parameters
// 0x0220 - 0x0230 for AES target offset & size
u32 aes_target_rom_offset;
u32 aes_target_size;
u32 aes_target2_rom_offset; // —\–ñ
u32 aes_target2_size; // —\–ñ
// 0x0230 - 0x0238 for TitleID
union {
u64 titleID;
struct {
u8 titleID_Lo[ 4 ];
u32 titleID_Hi;
};
};
/* <>ˆÓ<CB86>F os_reset.c / crt0.HYB.c / crt0.LTD.c / fatfs_command.c “à‚Å 0x0234 ðƒn<C692>[ƒhƒR<C692>[ƒfƒBƒ“ƒOµÄ¢Ü·<E2809A>B
titleID_Hi ̃IƒtƒZƒbƒgð•Ï<E280A2>XµÈ¢Å‰º³¢<E2809A>B */
// 0x0238 - 0x0240 for Public & Private Save Data Size
u32 public_save_data_size;
u32 private_save_data_size;
// 0x0240 - 0x02f0 reserved.
u8 reserved_ltd_F[ 0x2f0 - 0x240 ];
// 0x02f0 - 0x0300 Parental Controls Rating Info
u8 parental_control_rating_info[ PARENTAL_CONTROL_INFO_SIZE ];
// 0x0300 - 0x03b4 Rom Segment Digest
u8 main_static_digest[ DIGEST_SIZE_SHA1 ];
u8 sub_static_digest[ DIGEST_SIZE_SHA1 ];
u8 digest2_table_digest[ DIGEST_SIZE_SHA1 ];
u8 banner_digest[ DIGEST_SIZE_SHA1 ];
u8 main_ltd_static_digest[ DIGEST_SIZE_SHA1 ];
u8 sub_ltd_static_digest[ DIGEST_SIZE_SHA1 ];
u8 nitro_whitelist_phase1_digest[ DIGEST_SIZE_SHA1 ];
u8 nitro_whitelist_phase2_diegst[ DIGEST_SIZE_SHA1 ];
u8 main_static_without_secure_digest[ DIGEST_SIZE_SHA1 ];
}
ROM_Header_Short;
typedef ROM_Header_Short RomHeader;
typedef struct
{
struct ROM_Header_Short s;
////
//// EXTRA SYSTEM REGION
////
//
// 0x0378 - 0x0e00 System Reserved
//
u8 reserved_D[4 * 1024 - sizeof(ROM_Header_Short) - sizeof(RomCertificate) - RSA_KEY_LENGTH ]; // Reserved D
//
// 0x0e00 - 0x0f80 ROM Certificate
//
RomCertificate certificate;
//
// 0x0f80 - 0x1000 ROM Header Signature
//
u8 signature[ RSA_KEY_LENGTH ]; // PKCS#1_v1.5‚ÌŒ`Ž®ÅƒtƒH<C692>[ƒ}ƒbƒg³ê½SignatureDataª<E2809A>ARSAˆÃ<CB86>†‰»³ê½<E2809A>óÔ
//
// 0x01000 - 0x04000 System Reserved
//
u8 reserved_E[12 * 1024]; // Reserved E
}
ROM_Header; // 16KB
// <20><>¼(ROM_Header.signature)“à̃f<C692>[ƒ^
typedef struct SignatureData
{
u8 digest[ DIGEST_SIZE_SHA1 ];
}SignatureData;
//---------------------------------------------------------------------------
// Section C FNT: FILE NAME TABLE
// - DIRECTORY TABLE
// - ENTRY TABLE
//---------------------------------------------------------------------------
typedef struct ROM_FNTDir
{
u32 entry_start; // offset for entry
u16 entry_file_id; // file id for 1st file
u16 parent_id; // parent directory id
}
ROM_FNTDir;
/* P-SEUDO CODE for YOUR INFO.
typedef struct ROM_FNTStrFile
{
u8 entry_type :1; // 0 if file entry
u8 entry_name_length:7; // length of filename (0-127)
char entry_name[length]; // file name (surpress '\0')
} ROM_FNTStrFile;
typedef struct ROM_FNTStrDir
{
u8 entry_type :1; // 1 if directory entry
u8 entry_name_length:7; // length of directory name (0-127)
char entry_name[length]; // directory name (surpress '\0')
u8 dir_id_L; // low byte of directory id
u8 dir_id_H; // high byte of directory id
} ROM_FNTStrDir;
*/
//---------------------------------------------------------------------------
// Section D OVT: OVERLAY TABLE
//---------------------------------------------------------------------------
typedef struct ROM_OVT
{
void *id; // Overlay ID
void *ram_address; // ram address
u32 ram_size; // ram size
u32 bss_size; // bss size
void *sinit_init; // static initializer start
void *sinit_init_end; // static initializer end
u32 file_id; // file id in FAT
u32 compressed:24; // ƒI<C692>[ƒo<C692>[ƒŒƒCˆ³<CB86>kŒã̃TƒCƒY
u32 flag:8; // ƒI<C692>[ƒo<C692>[ƒŒƒC<C692>î•ñƒtƒ‰ƒO
}
ROM_OVT;
//---------------------------------------------------------------------------
// Section E FAT: FILE ALLOCATION TABLE
//---------------------------------------------------------------------------
/*
typedef struct ROM_FilePtr
{
u32 offset; // offset
}
ROM_FilePtr;
*/
typedef struct ROM_FAT
{
void* top; // file region start
void* bottom; // end
}
ROM_FAT;
//---------------------------------------------------------------------------
// Section F LT: ROM LATENCY
//---------------------------------------------------------------------------
typedef enum
{
ONETROM = 0,
MROM
}
tRomSpeedType;
typedef struct ROM_LT
{
u32 game_latency;
u32 secure_hw_latency;
u16 secure_sw_latency;
u16 padding;
}
ROM_LT;
//---------------------------------------------------------------------------
// Section X ONT: OVERLAY NAME TABLE (not include in ROM) generated by LD
// - OverlayDefs
//---------------------------------------------------------------------------
typedef struct ROM_ONTHeader
{
void *static_ram_address; // static module ram_address
void *static_entry_address; // entry address
u32 static_size; // size
void *static_autoload_done; // autoload done callback address
}
ROM_ONTHeader;
typedef struct ROM_ONT
{
ROM_ONTHeader header;
char file_list[1];
char padding[3];
}
ROM_ONT;
//---------------------------------------------------------------------------
// Section Y MDP: Module params
//---------------------------------------------------------------------------
typedef struct tModuleParam
{
void *autoload_list;
void *autoload_list_end;
void *autoload_start;
void *static_bss_start;
void *static_bss_end;
void *compressed_static_end; // tCompFooter ‚Ì 1—vf•ª<E280A2>æðŽw·
u32 version;
u32 nitro_magic_be;
u32 nitro_magic_le;
}
tModuleParam;
typedef struct tLtdModuleParam
{
void *autoload_list;
void *autoload_list_end;
void *autoload_start;
void *compressed_static_end; // tCompFooter ‚Ì 1—vf•ª<E280A2>æðŽw·
u32 twl_magic_be;
u32 twl_magic_le;
}
tLtdModuleParam;
typedef struct
{
u32 bufferTop:24;
u32 compressBottom:8;
u32 originalBottom;
}
tCompFooter;
typedef struct // compstatic/component.hæè”²<E2809D>ˆ
{
u32 magicNumber; // ”FޝŽq ==MAGICNUMBER_FOOTER
int staticParamsOffset; // StaticParams Ö̃IƒtƒZƒbƒg
int digestParamsOffset; // SDK_DIGEST_TABLE Ö̃IƒtƒZƒbƒg
int ltdStaticParamsOffset; // LtdStaticParams Ö̃IƒtƒZƒbƒg
}
StaticFooter;
#endif //FORMAT_ROM_H_