ResetParamの設定及びリセット命令送信部分をライブラリ化

とりあえずIPLのローカルライブラリとしてコミット

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@289 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yoshida_teruhisa 2007-11-29 07:32:32 +00:00
parent 66b043a3f4
commit 188d996469
10 changed files with 248 additions and 78 deletions

View File

@ -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スタート

View File

@ -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
#----------------------------------------------------------------------------

View File

@ -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 =====

View File

@ -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 <twl.h>
#include <sysmenu/reset_param/ARM9/reset_param.h>
// 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 <nitro/code32.h>
#include <twl/itcm_begin.h>
static void RPi_DoHardwareReset( void )
{
// リセット命令発行
PM_ForceToResetHardware();
OS_Terminate();
}
#include <twl/itcm_end.h>
#include <nitro/codereset.h>
// 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();
}

View File

@ -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 =====

View File

@ -20,6 +20,7 @@ SUBDIRS = \
../../../libraries_sysmenu/sysmenu \
../../../libraries_sysmenu/boot \
../../../libraries_sysmenu/hotsw \
../../../libraries_sysmenu/reset_param \
../../../components/hyena.TWL
#----------------------------------------------------------------------------

View File

@ -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

View File

@ -18,7 +18,6 @@
#include <twl.h>
#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 );
}
}
}

View File

@ -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 <twl.h>
#include <twl/nam.h>
#include <spi.h>
#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_

View File

@ -22,6 +22,7 @@
#include <twl/nam.h>
#include <sysmenu/memorymap.h>
#include <sysmenu/reset_param/ARM9/reset_param.h>
#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;
//----------------------------------------------------------------------
// データ型定義
//----------------------------------------------------------------------