From f595dda844ff9df61b8c556f9135724e9edeeaea Mon Sep 17 00:00:00 2001 From: yutaka Date: Wed, 26 Dec 2007 11:23:30 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=83=BC=E3=83=89=E3=83=96=E3=83=BC?= =?UTF-8?q?=E3=83=88=E7=89=88SDMC-Launcher=E4=BD=9C=E6=88=90=20(sdmc:/menu?= =?UTF-8?q?.srl=E3=82=92=E8=B5=B7=E5=8B=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@406 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/gcdfirm/Makefile | 2 +- build/gcdfirm/sdmc-launcher/ARM7/Makefile | 49 ++++ build/gcdfirm/sdmc-launcher/ARM7/main.c | 260 ++++++++++++++++++ build/gcdfirm/sdmc-launcher/ARM9/Makefile | 51 ++++ build/gcdfirm/sdmc-launcher/ARM9/main.c | 206 ++++++++++++++ build/gcdfirm/sdmc-launcher/Makefile | 52 ++++ build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf | 21 ++ .../gcdfirm/sdmc-launcher/wram_regs/Makefile | 57 ++++ .../sdmc-launcher/wram_regs/wram_regs.c | 91 ++++++ 9 files changed, 788 insertions(+), 1 deletion(-) create mode 100644 build/gcdfirm/sdmc-launcher/ARM7/Makefile create mode 100644 build/gcdfirm/sdmc-launcher/ARM7/main.c create mode 100644 build/gcdfirm/sdmc-launcher/ARM9/Makefile create mode 100644 build/gcdfirm/sdmc-launcher/ARM9/main.c create mode 100644 build/gcdfirm/sdmc-launcher/Makefile create mode 100644 build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf create mode 100644 build/gcdfirm/sdmc-launcher/wram_regs/Makefile create mode 100644 build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c diff --git a/build/gcdfirm/Makefile b/build/gcdfirm/Makefile index 9d23e443..d6d1b53b 100644 --- a/build/gcdfirm/Makefile +++ b/build/gcdfirm/Makefile @@ -24,7 +24,7 @@ include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs SUBDIRS = \ gcdfirm-disp \ gcdfirm-print \ - + sdmc-launcher \ #---------------------------------------------------------------------------- diff --git a/build/gcdfirm/sdmc-launcher/ARM7/Makefile b/build/gcdfirm/sdmc-launcher/ARM7/Makefile new file mode 100644 index 00000000..2c85da75 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM7/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# 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:$ +#---------------------------------------------------------------------------- + +TWL_PROC = ARM7 + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher7.tef + +SRCS = main.c + +CRT0_O = crt0_firm.o + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000' + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/ARM7/main.c b/build/gcdfirm/sdmc-launcher/ARM7/main.c new file mode 100644 index 00000000..791b1329 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM7/main.c @@ -0,0 +1,260 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - sdmc-launcher + 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 +#include +#include + +#define FATFS_HEAP_SIZE (64*1024) // FATFS用ヒープ (サイズ調整必要) + +#define BOOT_DEVICE FATFS_MEDIA_TYPE_SD +#define PARTITION_NO 0 // 0固定 +#define MENU_FILE (char*)L"A:\\menu.srl" // 対象ファイル(DRIVE_LETTERと合わせること) +#define MENU_FILE_A (char*)L"A:\\menu_a.srl" // 対象ファイル(DRIVE_LETTERと合わせること) +#define MENU_FILE_B (char*)L"A:\\menu_b.srl" // 対象ファイル(DRIVE_LETTERと合わせること) +#define MENU_FILE_L (char*)L"A:\\menu_l.srl" // 対象ファイル(DRIVE_LETTERと合わせること) +#define MENU_FILE_R (char*)L"A:\\menu_r.srl" // 対象ファイル(DRIVE_LETTERと合わせること) + +#define DRIVE_LETTER 'A' // マウント先ドライブ名 +#define DRIVE_NO (DRIVE_LETTER - 'A') // マウント先ドライブ番号 + +static u8 fatfsHeap[FATFS_HEAP_SIZE] __attribute__ ((aligned (32))); + +#ifndef SDK_FINALROM +static u8 step = 0x80; +#endif + +/* + Profile +*/ +#ifndef SDK_FINALROM +#define PROFILE_MAX 0x100 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#endif + +/* + Production check +*/ +//#define PRODUCTION_CHECK() do { if (reg_SCFG_OP == 0) goto end; } while (0) +#define PRODUCTION_CHECK() ((void)0) + +/*************************************************************** + PreInit + + FromBootの対応&メインメモリの初期化 + OS_Init前なので注意 (ARM9によるメインメモリ初期化で消されないように注意) +***************************************************************/ +static void PreInit(void) +{ + /* + FromBrom関連 + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } + /* + リセットパラメータ(1バイト)を共有領域(4バイト)にコピー + */ +#define FIRM_AVAILABLE_BIT 0x80000000UL + *(u32*)HW_RESET_PARAMETER_BUF = (u32)MCUi_ReadRegister( MCU_REG_TEMP_ADDR ) | FIRM_AVAILABLE_BIT; +} + +/*************************************************************** + EraseAll + + 不正終了しました + いろいろ消してください + DSモードにして終わるのがよいか? +***************************************************************/ +static void EraseAll(void) +{ +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + OS_BootFromFIRM(); +#endif +} + +/*************************************************************** + Fatfs4sdmcInit + + FATFS周りの初期化 for SDカード +***************************************************************/ +static BOOL Fatfs4sdmcInit(void) +{ + BOOL result; + + /* FATFSライブラリ用にカレントヒープを設定 */ + /* WRAM上のfatfsHeapをメインメモリヒープとして登録している */ + OSHeapHandle hh; + u8 *lo = (u8*)fatfsHeap; + u8 *hi = (u8*)fatfsHeap + FATFS_HEAP_SIZE; + lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1); + OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo); + hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, OS_GetSubPrivArenaLo(), hi); + OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh); + + OS_SetDebugLED(++step); + + if ( !FATFS_InitFIRM( NULL ) ) + { + return FALSE; + } + +#ifndef SDK_FINALROM + // 3: after FATFS + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + OS_SetDebugLED(++step); + + PM_BackLightOn( FALSE ); + + if ( !FATFS_MountDriveFIRM( DRIVE_NO, BOOT_DEVICE, PARTITION_NO ) ) + { + return FALSE; + } + +#ifndef SDK_FINALROM + // 4: after Mount + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + OS_SetDebugLED(++step); + + PM_BackLightOn( FALSE ); + +#if 0 + switch ( PAD_Read() & PAD_KEYPORT_MASK ) + { + case 0: +#endif + result = FATFS_OpenSpecifiedSrl( MENU_FILE ) && FATFS_SaveSrlFilename( BOOT_DEVICE, MENU_FILE ); +#if 0 + break; + case PAD_BUTTON_A: + result = FATFS_OpenSpecifiedSrl( MENU_FILE_A ) && FATFS_SaveSrlFilename( BOOT_DEVICE, MENU_FILE_A ); + break; + case PAD_BUTTON_B: + result = FATFS_OpenSpecifiedSrl( MENU_FILE_B ) && FATFS_SaveSrlFilename( BOOT_DEVICE, MENU_FILE_B ); + break; + case PAD_BUTTON_L: + result = FATFS_OpenSpecifiedSrl( MENU_FILE_L ) && FATFS_SaveSrlFilename( BOOT_DEVICE, MENU_FILE_L ); + break; + case PAD_BUTTON_R: + result = FATFS_OpenSpecifiedSrl( MENU_FILE_R ) && FATFS_SaveSrlFilename( BOOT_DEVICE, MENU_FILE_R ); + break; + default: + OS_SetDebugLED( (u8)(PAD_Read() & PAD_KEYPORT_MASK) ); + result = FALSE; + break; + } +#endif + return result; +} + +void TwlSpMain( void ) +{ + // OS_InitDebugLED and OS_SetDebugLED are able to call after OS_Init +#ifndef SDK_FINALROM + I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00); + I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, ++step); +#endif + + PreInit(); + +#ifndef SDK_FINALROM + I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, ++step); + + // 0: before PXI + profile[pf_cnt++] = (u32)OS_TicksToMicroSecondsBROM(OS_GetTick()); +#endif + + OS_InitFIRM(); + PRODUCTION_CHECK(); + OS_EnableIrq(); + +#ifndef SDK_FINALROM + //OS_EnableIrq(); + // 1: after PXI + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + + OS_SetDebugLED(++step); + + PM_InitFIRM(); + PM_BackLightOn( FALSE ); + +#ifndef SDK_FINALROM + // 2: after PM + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + OS_SetDebugLED(++step); + PRODUCTION_CHECK(); + + if ( !Fatfs4sdmcInit() ) + { + goto end; + } + +#ifndef SDK_FINALROM + // 5: after Open + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + OS_SetDebugLED(++step); + + PM_BackLightOn( FALSE ); + + if ( !FATFS_LoadHeader() || !FATFS_LoadStatic() ) + { + goto end; + } + +#ifndef SDK_FINALROM + // 127: before Boot + pf_cnt = PROFILE_MAX-1; + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); + { + int i; + PXI_RecvID(); + OS_TPrintf("\n[ARM7] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { + OS_TPrintf("0x%08X\n", profile[i]); + } + OS_TPrintf("\n[ARM7] End\n"); + } +#endif + OS_SetDebugLED(0); + PRODUCTION_CHECK(); + + PM_BackLightOn( TRUE ); // last chance + PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, 22, PMIC_BL_BRT_A_MASK ); // brighter + PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 22, PMIC_BL_BRT_B_MASK ); // brighter + + OS_BootFromFIRM(); + +end: + OS_SetDebugLED( (u8)(0xF0 | step)); + + EraseAll(); + + // failed + while (1) + { + PXI_NotifyID( FIRM_PXI_ID_NULL ); + } +} + diff --git a/build/gcdfirm/sdmc-launcher/ARM9/Makefile b/build/gcdfirm/sdmc-launcher/ARM9/Makefile new file mode 100644 index 00000000..1c0bbd29 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM9/Makefile @@ -0,0 +1,51 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - sdmc-launcher +# File: Makefile +# +# 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:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = sdmc_launcher9.srl + +SRCS = main.c + +CRT0_O = crt0_firm.o + +MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7)) + +#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/ARM9/main.c b/build/gcdfirm/sdmc-launcher/ARM9/main.c new file mode 100644 index 00000000..0138a814 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/ARM9/main.c @@ -0,0 +1,206 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - nandfirm - sdmc-launcher + 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 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 +}; + +#define RSA_HEAP_SIZE (4*1024) // RSA用ヒープサイズ (サイズ調整必要) + +static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32))); +static SVCSignHeapContext acPool; + +/* + Profile +*/ +#ifndef SDK_FINALROM +#define PROFILE_MAX 0x100 +u32 profile[PROFILE_MAX]; +u32 pf_cnt = 0; +#endif + +/*************************************************************** + PreInit + + FromBootの対応&OS_Init前に必要なメインメモリの初期化 +***************************************************************/ +static void PreInit(void) +{ + static const OSMountInfo firmSettings[] = + { + { 'A', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" }, + { 0 } + }; + /* + メインメモリ関連 + */ + // SHARED領域クリア + MI_CpuClearFast((void *)HW_WRAM_EX_LOCK_BUF, (HW_WRAM_EX_LOCK_BUF_END - HW_WRAM_EX_LOCK_BUF)); + MI_CpuClearFast((void *)HW_BIOS_EXCP_STACK_MAIN, (HW_REAL_TIME_CLOCK_BUF - HW_BIOS_EXCP_STACK_MAIN)); + MI_CpuClearFast((void *)HW_PXI_SIGNAL_PARAM_ARM9, (HW_MMEMCHECKER_MAIN - HW_PXI_SIGNAL_PARAM_ARM9)); + MI_CpuClearFast((void*)HW_ROM_HEADER_BUF, (HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF)); + + // FS_MOUNT領域の初期化 + MI_CpuCopy8(firmSettings, (char*)HW_TWL_FS_MOUNT_INFO_BUF, sizeof(firmSettings)); + + /* + FromBrom関連 + */ + if ( !OSi_FromBromToMenu() ) + { + OS_Terminate(); + } +} + +/*************************************************************** + PostInit + + MI_LoadHeader前にかなり(数100msec)時間があるので、可能なら + OS_Init後にいろいろ処理したい! + メインメモリの初期化 +***************************************************************/ +static void PostInit(void) +{ + /* + メインメモリ関連 + */ + // ARM9領域を全クリア + if ( OS_GetResetParameter() ) + { + MI_CpuClearFast( (void*)HW_FIRM_RESET_BUF_END, HW_TWL_MAIN_MEM_MAIN_END-HW_FIRM_RESET_BUF_END ); + } + else + { + MI_CpuClearFast( (void*)HW_MAIN_MEM_MAIN, HW_MAIN_MEM_MAIN_SIZE ); + } + + DC_FlushAll(); +} + +/*************************************************************** + CheckHeader + + ヘッダの内容がTWLアプリとして問題ないかチェック +***************************************************************/ +static BOOL CheckHeader(void) +{ + static ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF; + // TODO + // イニシャルコード + OS_TPrintf("Initial Code : %08X\n", *(u32*)rhs->game_code); + // エントリポイント + OS_TPrintf("ARM9 Entry point : %08X\n", rhs->main_entry_address); + OS_TPrintf("ARM7 Entry point : %08X\n", rhs->sub_entry_address); + // ロード範囲 + OS_TPrintf("ARM9 ROM address : %08X\n", rhs->main_rom_offset); + OS_TPrintf("ARM9 RAM address : %08X\n", rhs->main_ram_address); + OS_TPrintf("ARM9 size : %08X\n", rhs->main_size); + OS_TPrintf("ARM7 ROM address : %08X\n", rhs->sub_rom_offset); + OS_TPrintf("ARM7 RAM address : %08X\n", rhs->sub_ram_address); + OS_TPrintf("ARM7 size : %08X\n", rhs->sub_size); + OS_TPrintf("ARM9 LTD ROM address: %08X\n", rhs->main_ltd_rom_offset); + OS_TPrintf("ARM9 LTD RAM address: %08X\n", rhs->main_ltd_ram_address); + OS_TPrintf("ARM9 LTD size : %08X\n", rhs->main_ltd_size); + OS_TPrintf("ARM7 LTD ROM address: %08X\n", rhs->sub_ltd_rom_offset); + OS_TPrintf("ARM7 LTD RAM address: %08X\n", rhs->sub_ltd_ram_address); + OS_TPrintf("ARM7 LTD size : %08X\n", rhs->sub_ltd_size); + return TRUE; +} + +/*************************************************************** + EraseAll + + 不正終了しました + いろいろ消してください + DSモードにして終わるのがよいか? +***************************************************************/ +static void EraseAll(void) +{ +#ifdef SDK_FINALROM + MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE ); + OS_BootFromFIRM(); +#endif +} + +void TwlMain( void ) +{ + PreInit(); + +#ifndef SDK_FINALROM + // 0: before PXI + profile[pf_cnt++] = (u32)OS_TicksToMicroSecondsBROM(OS_GetTick()); +#endif + + OS_InitFIRM(); + OS_EnableIrq(); +#ifndef SDK_FINALROM + OS_InitTick(); + // 1: after PXI + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + + SVC_InitSignHeap( &acPool, acHeap, sizeof(acHeap) ); + + PostInit(); + +#ifndef SDK_FINALROM + // 2: after PostInit + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); +#endif + + // load menu + if ( MI_LoadHeader( &acPool, RSA_KEY_ADDR ) && CheckHeader() && MI_LoadStatic() ) + { +#ifndef SDK_FINALROM + // 127: before Boot + pf_cnt = PROFILE_MAX-1; + profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()); + { + int i; + OS_TPrintf("\n[ARM9] Begin\n"); + for (i = 0; i < PROFILE_MAX; i++) + { + OS_TPrintf("0x%08X\n", profile[i]); + } + OS_TPrintf("\n[ARM9] End\n"); + PXI_NotifyID( FIRM_PXI_ID_NULL ); + } +#endif + + OS_BootFromFIRM(); + } + + EraseAll(); + + // failed + while (1) + { + PXI_NotifyID( FIRM_PXI_ID_NULL ); + } +} + diff --git a/build/gcdfirm/sdmc-launcher/Makefile b/build/gcdfirm/sdmc-launcher/Makefile new file mode 100644 index 00000000..008df31e --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/Makefile @@ -0,0 +1,52 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - gcdfirm-disp +# File: Makefile +# +# 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:$ +#---------------------------------------------------------------------------- + + +# if you have valid keys, set environment value like below +#export TWL_KEYSDIR='$(TWL_IPL_RED_ROOT)/../twl_firmware/bootrom/build/keys' + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + wram_regs \ + ARM7 \ + ARM9 \ + +TARGET_FIRM_BIN = sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher9.tef +MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +MAKEFIRM_FLAGS += -p +FIRM_SPEC = gcdfirm.gcdsf + +LDIRT_CLEAN += $(TARGETS) \ + rsa_public.sbin \ + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf b/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf new file mode 100644 index 00000000..b5a9fa74 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/gcdfirm.gcdsf @@ -0,0 +1,21 @@ +#GCDSF --- Gcdfirm Spec File + +VERSION : 0x0 # GENERATE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN : ./wram_regs/wram_regs.rbin + +ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin +ARM9_ELF : $(MAKEFIRM_ARM9).tef + +ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin +ARM7_ELF : $(MAKEFIRM_ARM7).tef + +ARM9_X2 : TRUE # TRUE or FALSE + +#NORFIRM : $(NORFIRM_BIN) +#NANDFIRM : $(NANDFIRM_BIN) diff --git a/build/gcdfirm/sdmc-launcher/wram_regs/Makefile b/build/gcdfirm/sdmc-launcher/wram_regs/Makefile new file mode 100644 index 00000000..66504d9a --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/wram_regs/Makefile @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - nandfirm - menu-launcher +# File: Makefile +# +# 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:$ +#---------------------------------------------------------------------------- + +override TARGET_PLATFORM := TWL +override TARGET_CODEGEN := ARM +override TWL_ARCHGEN := LIMITED + +override TARGET_FINALROM := TRUE +override TARGET_RELEASE := +override TARGET_DEBUG := + +SUBDIRS = + +LINCLUDES = ../include + + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c b/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c new file mode 100644 index 00000000..2454b302 --- /dev/null +++ b/build/gcdfirm/sdmc-launcher/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - nandfirm + File: wram_regs.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 +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ), + }, + { + REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + { + REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ), + MI_WRAM_IMAGE_256KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; +