/*---------------------------------------------------------------------------* Project: TwlFirm - nandfirm - nandrfirm-loader File: main.c Copyright 2007 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$ *---------------------------------------------------------------------------*/ #include //#define BOOT_SECURE_SRL // 本番SRLをブートするときにだけ定義する #ifndef BOOT_SECURE_SRL #define RSA_KEY_ADDR rsa_key static const u8 rsa_key[128] = { 0xdf, 0x56, 0x30, 0xc9, 0xae, 0x05, 0x55, 0xe8, 0xdf, 0xbe, 0xe6, 0xb9, 0x30, 0xb9, 0x76, 0x93, 0xb4, 0xc2, 0x20, 0xe7, 0xae, 0x4c, 0x3e, 0xc3, 0xed, 0x27, 0xcf, 0x5d, 0x4f, 0xb5, 0x7d, 0xde, 0x38, 0xbc, 0xfe, 0x25, 0x32, 0xd8, 0x23, 0x98, 0x52, 0xb5, 0xda, 0xf7, 0x39, 0xdc, 0xb3, 0x0a, 0x94, 0x7a, 0x2b, 0x79, 0xe6, 0xe0, 0x4c, 0xbc, 0x21, 0xbd, 0x59, 0xb2, 0xc7, 0xf1, 0xc0, 0xf1, 0xfb, 0x29, 0x75, 0xa1, 0x21, 0x93, 0x01, 0x29, 0x1c, 0x9a, 0xe1, 0x2d, 0x55, 0xfc, 0x7b, 0xb8, 0xcb, 0x07, 0x33, 0xc5, 0x91, 0x0d, 0xc8, 0x45, 0x59, 0xef, 0xbe, 0x58, 0xc7, 0xc1, 0x1d, 0xd5, 0xf2, 0xcf, 0x1f, 0xe0, 0x6d, 0x21, 0x00, 0xcd, 0x42, 0xd8, 0x84, 0x85, 0xe3, 0xb2, 0x02, 0x1a, 0xa5, 0x89, 0x02, 0xa1, 0x96, 0xc6, 0xf7, 0x61, 0x68, 0x66, 0xe6, 0x65, 0x12, 0xb7, 0xf1, 0x49 }; #else /* 鍵はどこへ? */ #define RSA_KEY_ADDR OSi_GetFromBromAddr()->rsa_pubkey[7] #endif #define RSA_HEAP_SIZE (4*1024) // RSA用ヒープサイズ (サイズ調整必要) static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32))); static int acPool[3]; /* Profile */ #ifndef SDK_FINALROM #define PRFILE_MAX 128 u32 profile[PRFILE_MAX]; u32 pf_cnt = 0; #endif /* PreInit FromBootの対応をまとめる&メインメモリの初期化 OS_Init前なので注意 */ static void PreInit(void) { /* FromBrom関連 */ #ifdef BOOT_SECURE_SRL /* 鍵はどこへ? */ #endif MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) ); // メインメモリ関連 // SHARED領域クリア (IS-TWL-DEBUGGERの更新待ち) #ifdef SDK_FINALROM MIi_CpuClearFast( 0, (void*)HW_MAIN_MEM_SHARED, HW_MAIN_MEM_SHARED_END-HW_MAIN_MEM_SHARED ); #endif } void TwlMain( void ) { PreInit(); #ifndef SDK_FINALROM // 0: before PXI profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); #endif OS_InitFIRM(); #ifndef SDK_FINALROM OS_InitTick(); // 1: after PXI profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); #endif SVC_InitSignHeap( acPool, acHeap, sizeof(acHeap) ); // load menu if ( MI_LoadHeader( acPool, RSA_KEY_ADDR ) && MI_LoadMenu() ) { #ifndef SDK_FINALROM // 127: before BootMenu pf_cnt = PRFILE_MAX-1; profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); #endif MI_BootMenu(); } OS_Terminate(); }