mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@288 b871894f-2f95-9b40-918c-086798483c85
91 lines
2.9 KiB
C
91 lines
2.9 KiB
C
/*---------------------------------------------------------------------------*
|
|
Project: ctr_firmware - format
|
|
File: firm.h
|
|
|
|
Copyright 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_FIRM_H_
|
|
#define FORMAT_FIRM_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/*===========================================================================*
|
|
* FIRM FORMAT
|
|
*===========================================================================*/
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
* 基本パラメータ
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
#define FIRM_FORMAT_HASH_LENGTH 32 // SHA-256 or HMAC-SHA-256
|
|
#define FIRM_FORMAT_SIGN_LENGTH 256 // RSA-2048 with PKCS#1 v1.5
|
|
#define FIRM_FORMAT_MAX_MODULES 4
|
|
|
|
#define FIRM_FORMAT_MAGIC_NUMBER ( 'F'<<0 | 'I'<<8 | 'R'<<16 | 'M'<<24 )
|
|
#define FIRM_FORMAT_FIRST_VIRSION 0
|
|
|
|
/*
|
|
CTRファームは特定のパーティション1つに1つ含めることができる
|
|
どのパーティションか、いくつあるかについては別途メディアヘッダで定義する
|
|
(仮デフォルト: 0x1000以降に1つだけ)
|
|
*/
|
|
|
|
typedef struct FirmHash
|
|
{
|
|
u8 raw[FIRM_FORMAT_HASH_LENGTH];
|
|
}
|
|
FirmHash;
|
|
|
|
typedef struct FirmSign
|
|
{
|
|
u8 raw[FIRM_FORMAT_SIGN_LENGTH];
|
|
}
|
|
FirmSign;
|
|
|
|
typedef struct FirmModule
|
|
{
|
|
u32 sourceOffset; // FirmHeaderの先頭からのオフセット (512B境界に整列)
|
|
void* destinationAddress; // ARM9からみた転送先アドレス
|
|
u32 length; // 転送バイト数
|
|
BOOL isDMAC2; // 転送チェーンの最後にA9-DMAC1とA9-DMAC2のどちらを使うか
|
|
FirmHash hash; // データのハッシュ値 (ここはHMAC-SHA-256)
|
|
}
|
|
FirmModule;
|
|
|
|
typedef struct FirmHeaderCore
|
|
{
|
|
u32 magicNumber;
|
|
u32 versionNumber;
|
|
u32 entryAddressForMPCore; // modules対象番地以外はエラー (MPCoreにPIF経由で通知する)
|
|
u32 entryAddressForARM9; // A9-WRAM内、かつmodules対象番地以外はエラー
|
|
u8 padding[48]; // modulesに加えても良いが保険で空けておく
|
|
FirmModule modules[FIRM_FORMAT_MAX_MODULES]; // 何番目をどこにおいても自由 (A9-WRAMが最後?)
|
|
}
|
|
FirmHeaderCore;
|
|
|
|
typedef struct FirmHeder
|
|
{
|
|
FirmHeaderCore c; // ヘッダ本体
|
|
FirmSign sign; // FirmHeaderCoreの署名 (ここはSHA-256)
|
|
}
|
|
FirmHeader;
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif // FORMAT_FIRM_H_
|