From 188d996469b7b23ae18159f48a423d0c9b81ab7f Mon Sep 17 00:00:00 2001 From: yoshida_teruhisa Date: Thu, 29 Nov 2007 07:32:32 +0000 Subject: [PATCH] =?UTF-8?q?ResetParam=E3=81=AE=E8=A8=AD=E5=AE=9A=E5=8F=8A?= =?UTF-8?q?=E3=81=B3=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E9=80=81=E4=BF=A1=E9=83=A8=E5=88=86=E3=82=92=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E5=8C=96=20=E3=81=A8=E3=82=8A?= =?UTF-8?q?=E3=81=82=E3=81=88=E3=81=9AIPL=E3=81=AE=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=82=AB=E3=83=AB=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88?= 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@289 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/components/hyena.TWL/src/main.c | 10 --- build/libraries_sysmenu/Makefile | 2 +- .../reset_param/ARM9/Makefile | 49 +++++++++++ .../reset_param/ARM9/src/reset_param.c | 77 +++++++++++++++++ build/libraries_sysmenu/reset_param/Makefile | 30 +++++++ build/systemMenu_RED/Launcher/ARM9/Makefile | 1 + .../MachineSettings/ARM9/Makefile | 2 + .../MachineSettings/ARM9/src/MachineSetting.c | 22 +---- .../sysmenu/reset_param/ARM9/reset_param.h | 85 +++++++++++++++++++ .../sysmenu/sysmenu_lib/common/sysmenu_work.h | 48 +---------- 10 files changed, 248 insertions(+), 78 deletions(-) create mode 100644 build/libraries_sysmenu/reset_param/ARM9/Makefile create mode 100644 build/libraries_sysmenu/reset_param/ARM9/src/reset_param.c create mode 100644 build/libraries_sysmenu/reset_param/Makefile create mode 100644 include/sysmenu/reset_param/ARM9/reset_param.h diff --git a/build/components/hyena.TWL/src/main.c b/build/components/hyena.TWL/src/main.c index 8e19812c..ae1bebd5 100644 --- a/build/components/hyena.TWL/src/main.c +++ b/build/components/hyena.TWL/src/main.c @@ -195,16 +195,6 @@ static void ReadResetParameter( void ) { MCU_GetFreeRegisters( 0, (u8 *)HW_RESET_PARAMETER_BUF, 1 ); - /* - // ダイレクトブート用設定のテストコード - SYSMi_GetMCUFreeRegisterValue() = 1; // マイコンフリーレジスタ取得場所にホットスタートフラグをセット - SYSMi_GetResetParamAddr()->body.v1.bootTitleID = 0x000100015445534d; - SYSMi_GetResetParamAddr()->body.v1.flags = (BootFlags){TRUE, 0, TRUE, FALSE, FALSE, FALSE, 0}; - MI_CpuCopyFast( SYSM_RESET_PARAM_MAGIC_CODE, (char *)&SYSMi_GetResetParamAddr()->header.magicCode, SYSM_RESET_PARAM_MAGIC_CODE_LEN); - SYSMi_GetResetParamAddr()->header.bodyLength = sizeof(ResetParamBody); - SYSMi_GetResetParamAddr()->header.crc16 = SVC_GetCRC16( 65535, &SYSMi_GetResetParamAddr()->body, SYSMi_GetResetParamAddr()->header.bodyLength ); - */ - // Hot/Coldスタート判定 #ifdef SDK_FINALROM if( SYSMi_GetMCUFreeRegisterValue() == 0 ) // マイコンフリーレジスタ値が"0"ならColdスタート diff --git a/build/libraries_sysmenu/Makefile b/build/libraries_sysmenu/Makefile index c3c36134..ab047925 100644 --- a/build/libraries_sysmenu/Makefile +++ b/build/libraries_sysmenu/Makefile @@ -22,7 +22,7 @@ include $(TWLIPL_ROOT)/build/buildtools/commondefs #---------------------------------------------------------------------------- -SUBDIRS = sysmenu settings mb_loader acsign boot hotsw +SUBDIRS = sysmenu settings mb_loader acsign boot hotsw reset_param #---------------------------------------------------------------------------- diff --git a/build/libraries_sysmenu/reset_param/ARM9/Makefile b/build/libraries_sysmenu/reset_param/ARM9/Makefile new file mode 100644 index 00000000..a012c4f5 --- /dev/null +++ b/build/libraries_sysmenu/reset_param/ARM9/Makefile @@ -0,0 +1,49 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# 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:: 2007-09-27#$ +# $Rev: 1203 $ +# $Author: yada $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- +TARGET_FIRM = SYSTEMMENU +TARGET_PLATFORM = TWL +TWL_ARCHGEN = LIMITED +TWL_PROC = ARM9 + +#---------------------------------------------------------------------------- + +SRCDIR = ./src + +SRCS = reset_param.c + +TARGET_LIB = libreset_param$(TWL_LIBSUFFIX).a + + +include $(TWLIPL_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR) + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLIPL_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== + diff --git a/build/libraries_sysmenu/reset_param/ARM9/src/reset_param.c b/build/libraries_sysmenu/reset_param/ARM9/src/reset_param.c new file mode 100644 index 00000000..750dd4eb --- /dev/null +++ b/build/libraries_sysmenu/reset_param/ARM9/src/reset_param.c @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: reset_param.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:: 2007-11-26#$ + $Rev: 256 $ + $Author: yosiokat $ + *---------------------------------------------------------------------------*/ + +#include +#include + +// define data------------------------------------------------------- +#define RPi_RESET_PARAM_MAGIC_CODE "TRST" +#define RPi_RESET_PARAM_MAGIC_CODE_LEN 4 + +// リセットパラメータアドレスの取得(※ライブラリ向け) +#define RPi_GetResetParamAddr() ( (ResetParam *)0x02000100 ) + + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- +static void RPi_DoHardwareReset( void ); + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- + +// 安全のため、この関数はitcmに配置 +#include +#include +static void RPi_DoHardwareReset( void ) +{ + // リセット命令発行 + PM_ForceToResetHardware(); + OS_Terminate(); +} + +#include +#include + +// ResetParamを指定してリセット +void RP_Reset( u8 type, NAMTitleId id, BootFlags *flag ) +{ + // メーカーコードとゲームコードをコピー + u32 *maker_code_dest_addr = (u32 *)((u32)(RPi_GetResetParamAddr()) + HW_PARAM_DELIVER_ARG_MAKERCODE_OFS); + u32 *game_code_dest_addr = (u32 *)((u32)(RPi_GetResetParamAddr()) + HW_PARAM_DELIVER_ARG_GAMECODE_OFS); + u16 *maker_code_src_addr = (u16 *)(HW_TWL_ROM_HEADER_BUF + 0x10); + u32 *game_code_src_addr = (u32 *)(HW_TWL_ROM_HEADER_BUF + 0xc); + *maker_code_dest_addr = (u32)*maker_code_src_addr; + *game_code_dest_addr = *game_code_src_addr; + + // リセットパラメータの設定 + RPi_GetResetParamAddr()->body.v1.bootTitleID = id; + RPi_GetResetParamAddr()->body.v1.flags = *flag; + MI_CpuCopyFast( RPi_RESET_PARAM_MAGIC_CODE, (char *)&RPi_GetResetParamAddr()->header.magicCode, RPi_RESET_PARAM_MAGIC_CODE_LEN); + RPi_GetResetParamAddr()->header.bodyLength = sizeof(ResetParamBody); + RPi_GetResetParamAddr()->header.crc16 = SVC_GetCRC16( 65535, &RPi_GetResetParamAddr()->body, RPi_GetResetParamAddr()->header.bodyLength ); + RPi_GetResetParamAddr()->header.type = type; + + + DC_FlushRange(RPi_GetResetParamAddr(), 0x100 ); + DC_WaitWriteBufferEmpty(); + + RPi_DoHardwareReset(); +} diff --git a/build/libraries_sysmenu/reset_param/Makefile b/build/libraries_sysmenu/reset_param/Makefile new file mode 100644 index 00000000..95886bce --- /dev/null +++ b/build/libraries_sysmenu/reset_param/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL +# 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:: 2007-09-27#$ +# $Rev: 1203 $ +# $Author: yada $ +#---------------------------------------------------------------------------- + +TARGET_FIRM = SYSTEMMENU +SUBDIRS = ARM9 + +include $(TWLIPL_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLIPL_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/systemMenu_RED/Launcher/ARM9/Makefile b/build/systemMenu_RED/Launcher/ARM9/Makefile index af8d4d47..1692048f 100644 --- a/build/systemMenu_RED/Launcher/ARM9/Makefile +++ b/build/systemMenu_RED/Launcher/ARM9/Makefile @@ -20,6 +20,7 @@ SUBDIRS = \ ../../../libraries_sysmenu/sysmenu \ ../../../libraries_sysmenu/boot \ ../../../libraries_sysmenu/hotsw \ + ../../../libraries_sysmenu/reset_param \ ../../../components/hyena.TWL #---------------------------------------------------------------------------- diff --git a/build/systemMenu_RED/MachineSettings/ARM9/Makefile b/build/systemMenu_RED/MachineSettings/ARM9/Makefile index 8a73ebec..866a22aa 100644 --- a/build/systemMenu_RED/MachineSettings/ARM9/Makefile +++ b/build/systemMenu_RED/MachineSettings/ARM9/Makefile @@ -45,6 +45,8 @@ LINCLUDES = $(MISC_DIR)/include MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)' +LLIBRARIES += libreset_param$(TWL_LIBSUFFIX).a + include $(TWLIPL_ROOT)/build/buildtools/commondefs diff --git a/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c index d972786f..1e60c7f4 100644 --- a/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c +++ b/build/systemMenu_RED/MachineSettings/ARM9/src/MachineSetting.c @@ -18,7 +18,6 @@ #include #include "misc.h" #include "MachineSetting.h" -#include "spi.h" // define data------------------------------------------ // キャンセルボタンLCD領域 @@ -193,23 +192,6 @@ void MachineSettingInit( void ) g_pNowProcess = MachineSettingMain; } -static void ResetHardware( NAMTitleId id, BootFlags *flag) -{ - // リセットパラメータの設定 - SYSMi_GetResetParamAddr()->body.v1.bootTitleID = id; - SYSMi_GetResetParamAddr()->body.v1.flags = *flag; - MI_CpuCopyFast( SYSM_RESET_PARAM_MAGIC_CODE, (char *)&SYSMi_GetResetParamAddr()->header.magicCode, SYSM_RESET_PARAM_MAGIC_CODE_LEN); - SYSMi_GetResetParamAddr()->header.bodyLength = sizeof(ResetParamBody); - SYSMi_GetResetParamAddr()->header.crc16 = SVC_GetCRC16( 65535, &SYSMi_GetResetParamAddr()->body, SYSMi_GetResetParamAddr()->header.bodyLength ); - - DC_FlushRange(SYSMi_GetResetParamAddr(), sizeof(ResetParam) ); - DC_WaitWriteBufferEmpty(); - - // リセット命令発行 - PM_ForceToResetHardware(); - OS_Terminate(); -} - // メインメニュー int MachineSettingMain( void ) { @@ -236,7 +218,7 @@ int MachineSettingMain( void ) DrawMenu( s_csr, &s_settingParam ); if( pad.trg & PAD_BUTTON_START ) { - ResetHardware(NULL, &tempflag); + RP_Reset( 0, NULL, &tempflag ); } if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // メニュー項目への分岐 @@ -268,7 +250,7 @@ int MachineSettingMain( void ) break; case 6: //pictochat起動テスト - ResetHardware(0x0001000154484350, &tempflag); + RP_Reset( 0, 0x0001000154484350, &tempflag ); } } } diff --git a/include/sysmenu/reset_param/ARM9/reset_param.h b/include/sysmenu/reset_param/ARM9/reset_param.h new file mode 100644 index 00000000..7c9d45f8 --- /dev/null +++ b/include/sysmenu/reset_param/ARM9/reset_param.h @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: reset_param.h + + 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:: 2007-10-29#$ + $Rev: 72 $ + $Author: yosiokat $ + *---------------------------------------------------------------------------*/ + +#ifndef _RESET_PARAM_H_ +#define _RESET_PARAM_H_ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +// define data------------------------------------------- + +// BootFlagsで使用するmedia情報 +typedef enum TitleMedia { + TITLE_MEDIA_NAND = 0, + TITLE_MEDIA_CARD = 1, + TITLE_MEDIA_MAX = 2 +}TitleMedia; + + +// タイトル&リセットパラメータ フラグ +typedef struct BootFlags { + u16 isValid : 1; // TRUE:valid, FALSE:invalid + u16 media : 3; // 0:nand, 1:card, 2-7:rsv; + u16 isLogoSkip : 1; // ロゴデモスキップ要求 + u16 isInitialShortcutSkip : 1; // 初回起動シーケンススキップ要求 + u16 isAppLoadCompleted : 1; // アプリロード済みを示す + u16 isAppRelocate : 1; // アプリ再配置要求 + u16 rsv : 9; +}BootFlags; + + +// リセットパラメータ ヘッダ +typedef struct ResetParameterHeader { + u32 magicCode; // SYSM_RESET_PARAM_MAGIC_CODEが入る + u8 type; // タイプによってBodyを判別する。 + u8 bodyLength; // bodyの長さ + u16 crc16; // bodyのCRC16 +}ResetParamHeader; + + +// リセットパラメータ ボディ +typedef union ResetParamBody { + struct { // ※とりあえず最初はTitlePropertyとフォーマットを合わせておく + NAMTitleId bootTitleID; // リセット後にダイレクト起動するタイトルID + BootFlags flags; // リセット時のランチャー動作フラグ + u8 rsv[ 4 ]; // 予約 + }v1; +}ResetParamBody; + + +// リセットパラメータ +typedef struct ResetParam { + ResetParamHeader header; + ResetParamBody body; +}ResetParam; + +// function's prototype------------------------------------ + +void RP_Reset( u8 type, NAMTitleId id, BootFlags *flag ); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _RESET_PARAM_H_ diff --git a/include/sysmenu/sysmenu_lib/common/sysmenu_work.h b/include/sysmenu/sysmenu_lib/common/sysmenu_work.h index 82bf9ada..27a2af2e 100644 --- a/include/sysmenu/sysmenu_lib/common/sysmenu_work.h +++ b/include/sysmenu/sysmenu_lib/common/sysmenu_work.h @@ -22,6 +22,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -41,53 +42,6 @@ typedef struct TitleID_HiLo { u32 Hi; }TitleID_HiLo; - -// BootFlagsで使用するmedia情報 -typedef enum TitleMedia { - TITLE_MEDIA_NAND = 0, - TITLE_MEDIA_CARD = 1, - TITLE_MEDIA_MAX = 2 -}TitleMedia; - - -// タイトル&リセットパラメータ フラグ -typedef struct BootFlags { - u16 isValid : 1; // TRUE:valid, FALSE:invalid - u16 media : 3; // 0:nand, 1:card, 2-7:rsv; - u16 isLogoSkip : 1; // ロゴデモスキップ要求 - u16 isInitialShortcutSkip : 1; // 初回起動シーケンススキップ要求 - u16 isAppLoadCompleted : 1; // アプリロード済みを示す - u16 isAppRelocate : 1; // アプリ再配置要求 - u16 rsv : 9; -}BootFlags; - - -// リセットパラメータ ヘッダ -typedef struct ResetParameterHeader { - u32 magicCode; // SYSM_RESET_PARAM_MAGIC_CODEが入る - u8 type; // タイプによってBodyを判別する。 - u8 bodyLength; // bodyの長さ - u16 crc16; // bodyのCRC16 -}ResetParamHeader; - - -// リセットパラメータ ボディ -typedef union ResetParamBody { - struct { // ※とりあえず最初はTitlePropertyとフォーマットを合わせておく - NAMTitleId bootTitleID; // リセット後にダイレクト起動するタイトルID - BootFlags flags; // リセット時のランチャー動作フラグ - u8 rsv[ 4 ]; // 予約 - }v1; -}ResetParamBody; - - -// リセットパラメータ -typedef struct ResetParam { - ResetParamHeader header; - ResetParamBody body; -}ResetParam; - - //---------------------------------------------------------------------- // データ型定義 //----------------------------------------------------------------------