From 26fee8c4964eeb4d01e5a1350b516c65a6d2907c Mon Sep 17 00:00:00 2001 From: yosiokat Date: Thu, 8 Nov 2007 04:46:29 +0000 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E4=BB=AE=E3=81=AE=E3=83=96=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82=EF=BC=88=E6=9C=AA=E6=95=B4=E7=90=86=EF=BC=89?= 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@115 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/libraries_sysmenu/boot/ARM7/Makefile | 51 ++ build/libraries_sysmenu/boot/ARM7/src/boot.c | 485 ++++++++++++++++++ .../libraries_sysmenu/boot/ARM7/src/bootAPI.c | 85 +++ build/libraries_sysmenu/boot/ARM9/Makefile | 51 ++ build/libraries_sysmenu/boot/ARM9/src/boot.c | 474 +++++++++++++++++ .../libraries_sysmenu/boot/ARM9/src/bootAPI.c | 104 ++++ build/libraries_sysmenu/boot/Makefile | 30 ++ 7 files changed, 1280 insertions(+) create mode 100644 build/libraries_sysmenu/boot/ARM7/Makefile create mode 100644 build/libraries_sysmenu/boot/ARM7/src/boot.c create mode 100644 build/libraries_sysmenu/boot/ARM7/src/bootAPI.c create mode 100644 build/libraries_sysmenu/boot/ARM9/Makefile create mode 100644 build/libraries_sysmenu/boot/ARM9/src/boot.c create mode 100644 build/libraries_sysmenu/boot/ARM9/src/bootAPI.c create mode 100644 build/libraries_sysmenu/boot/Makefile diff --git a/build/libraries_sysmenu/boot/ARM7/Makefile b/build/libraries_sysmenu/boot/ARM7/Makefile new file mode 100644 index 00000000..497866ca --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM7/Makefile @@ -0,0 +1,51 @@ +#! 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 = ARM7 + +#---------------------------------------------------------------------------- + +SRCDIR = ../common/src + +INCDIR = ../common/include + +SRCS = boot.c + +TARGET_LIB = libboot_sp$(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/boot/ARM7/src/boot.c b/build/libraries_sysmenu/boot/ARM7/src/boot.c new file mode 100644 index 00000000..3e4ef5c8 --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM7/src/boot.c @@ -0,0 +1,485 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot.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 "loader.h" +//#include "mb_child.h" + +// define data------------------------------------------------------- + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- +void BOOT_Core( void ); + +static void Venner_R1( void ); +static void ClearMemory( void ); +static void ClearBankregAndStack( void ); +static void CpuClear32Byte( void ); + +#ifdef ISDBG_MB_CHILD_ +// モニタAPI番号 +typedef enum { MONAPI_ONLOADCHILD = 0 } APITYPE; +static u32 _isdcallmon( APITYPE nIndex, void *pParam ); +static void _ISDbgLib_OnLoadChildBinary( void ); +#endif // ISDBG_MB_CHILD_ + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- + +#include + +//----------------------------------------------------------------------- +// メモリクリア +//----------------------------------------------------------------------- +static asm void ClearMemory( void ) +{ + mov r11, lr + +// ldr r0, = IPL2_ADDR_TOP // IPL2-ARM9 & ARM7プログラムのクリア +// ldr r1, = MB_BSSDESC_ADDRESS +// bl CpuClear32Byte + + ldr r0, = HW_WRAM // ARM7WRAMのクリア + ldr r1, = RETURN_FROM_MAIN_ARM7_FUNCP + bl CpuClear32Byte + + +@1 bx r11 +} + + +//----------------------------------------------------------------------- +// バンクレジスタ リセット & スタック領域 クリア +//----------------------------------------------------------------------- +static asm void ClearBankREG_Stack( void ) +{ + mov r12, lr + +#ifndef ISDBG_MB_CHILD_ + mov r0, #0xc0 | HW_PSR_SVC_MODE // SVCモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + ldr sp, =HW_PRV_WRAM_SVC_STACK_END // SP のセット + mov lr, #0 + msr spsr_csxf, lr + + mov r0, #0xc0 | HW_PSR_IRQ_MODE // IRQモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + ldr r2, =HW_PRV_WRAM_IRQ_STACK_END + mov sp, r2 // SP のセット + mov lr, #0 + msr spsr_cxsf, lr + + mov r0, #0xc0 | HW_PSR_SYS_MODE // システムモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + mov r1, #0x200 // SDK_IRQ_STACKSIZE (実際はリンカスクリプト内で定義している。) + sub r1, r2, r1 + mov sp, r1 // SP のセット + + ldr r2, = HW_PRV_WRAM_END + sub r0, r2, #0x600 + mov r1, r2 + bl CpuClear32Byte +#else // ISDBG_MB_CHILD_ + ldr r2, = HW_PRV_WRAM_END + sub r0, r2, #0x600 + sub r1, r2, #HW_PRV_WRAM_SYSRV_SIZE + bl CpuClear32Byte + add r0, r0, #0x20 + mov r1, r2 + bl CpuClear32Byte +#endif // ISDBG_MB_CHILD_ + + sub r0, r2, #( HW_PRV_WRAM_END - RETURN_FROM_MAIN_ARM7_FUNCP ) + ldr r1, = ClearMemory + bl CpuClear32Byte + + ldr r2, = 0x027ff000 + mov r0, r2 + add r1, r2, #0x800 + bl CpuClear32Byte + +#ifndef ISDBG_MB_CHILD_ + add r0, r2, #0xd80 // HW_BIOS_EXCP_STACK_MAIN (MAINPデバッガモニタ例外ハンドラ) + add r1, r0, #0x80 + bl CpuClear32Byte +#else // ISDBG_MB_CHILD_ + add r0, r2, #0xda0 // HW_ARENA_INFO_BUF (アリーナ情報構造体) ※mb_childビルド時には、デバッガモニタ用ハンドラはクリアしない。 + add r1, r0, #0x60 + bl CpuClear32Byte +#endif // ISDBG_MB_CHILD_ + + add r0, r2, #0xf80 + add r1, r0, #0x80 + bl CpuClear32Byte + + bx r12 +} + + +//----------------------------------------------------------------------- +// ブートコア +//----------------------------------------------------------------------- +asm void BOOT_Core( void ) +{ + //--------------------------------------- + // ARM9との同期をとる(subp_stateを2にしてから、mainp_stateが2になるのを待つ。) + //--------------------------------------- + ldr r1, =REG_MAINPINTF_ADDR + mov r0, #0x0200 + strh r0, [r1] // メインプロセッサインターフェースレジスタ +@0 ldrh r0, [r1] + and r0, r0, #0x000f + cmp r0, #0x0002 + bne @0 + + //--------------------------------------- + // メモリクリア + //--------------------------------------- + bl ClearMemory + + //--------------------------------------- + // 無線マルチブート用ローダー起動 + //--------------------------------------- +// ldr r1, =LOADER_Start +// bl Venner_R1 + + //--------------------------------------- + // デバッガ動作フラグ格納 + //--------------------------------------- +#ifdef __IS_DEBUGGER_BUILD + ldr r3, =HW_MAIN_MEM_EX_END + sub r0, r3, #0x400 + ldrh r11, [r0, #0x14] // r11 <- GetMovedInfoFromIPL1Addr()->isOnDebugger +#endif + //--------------------------------------- + // ARM9との同期をとる(subp_stateを1にしてから、mainp_stateが1になるのを待つ。) + //--------------------------------------- + ldr r1, =REG_MAINPINTF_ADDR + mov r0, #0x0100 + strh r0, [r1] // メインプロセッサインターフェースレジスタ +@1 ldrh r0, [r1] + and r0, r0, #0x000f + cmp r0, #0x0001 + bne @1 + + //--------------------------------------- + // ISデバッガでのDL子機プログラムのデバッグ情報設定 + //--------------------------------------- +#ifdef ISDBG_MB_CHILD_ + mov r0, #MONAPI_ONLOADCHILD + mov r1, #0 + bl _isdcallmon +#endif // ISDBG_MB_CHILD_ + + //--------------------------------------- + // バンクレジスタ&スタッククリア + //--------------------------------------- + bl ClearBankREG_Stack + + //--------------------------------------- + // ARM9との最終同期をとる(subp_stateを0にして、mainp_stateが0になるのを待つ。) + //--------------------------------------- + ldr r1, =REG_MAINPINTF_ADDR + mov r0, #0 + strh r0, [r1] // メインプロセッサインターフェースレジスタ +@2 ldrh r0, [r1] + cmp r0, #0x0001 + beq @2 + + //--------------------------------------- + // R11の値をもとにブートアドレス取得 + //--------------------------------------- + ldr r3, =HW_MAIN_MEM_EX_END // ゲーム・エントリポイント 獲得 + ldr r12, [r3, #-(0x200 - 0x34)] // rmhp->arm7->entryAddr + mov lr, r12 + +#ifdef __IS_DEBUGGER_BUILD + cmp r11, #1 // if (!GetMovedInfoFromIPL1Addr()->isOnDebugger) + ldreq r12, [r3, #-(0x200 - 0x16c)] // デバッガ動作なら、デバッガ・エントリポイント 獲得 +#endif + //--------------------------------------- + // 汎用レジスタクリア + //--------------------------------------- + mov r11, #HW_REG_BASE + ldmdb r11, {r0-r10} + mov r11, #0 + + //--------------------------------------- + // ゲームブート + //--------------------------------------- + bx r12 +} + +static asm void Venner_R1( void ) +{ + bx r1 +} + + +// 32byte単位のメモリクリア r0 = tgtp, r1 = lastAddr +static asm void CpuClear32Byte( void ) +{ + mov r3, #0 + mov r4, r3 + mov r5, r3 + mov r6, r3 + mov r7, r3 + mov r8, r3 + mov r9, r3 + mov r10, r3 +@0 cmp r0, r1 // クリア終了 + stmltia r0!, {r3-r10} + blt @0 + bx lr +} + + + + +#ifdef ISDBG_MB_CHILD_ +/////////////////////////////////////////////////////////////////////// +// Project: モニタの呼び出し - ISデバッグライブラリ内コード相当の実装 +// Copyright (C)2007 INTELIGENT SYSTEMS Co.,Ltd. +/////////////////////////////////////////////////////////////////////// + +#ifdef SDK_ARM9 +// ARM9の場合定義 +#define NITRO9 +#endif // SDK_ARM9 + +/////////////////////////////////////////////////////////////////////// + +#define MON_ENTRY_SIGNATURE_OFFSET 0x00010 +#define MON_INTAPI_FUNC_OFFSET 0x002A0 +#define MON_INTAPI_FUNC_SIGN 0x4346564f // OVFC +#define MON_INTAPI_OFFSET_VERSION 0x04 +#define MON_INTAPI_OFFSET_COMMONENTRY_A9 0x20 +#define MON_INTAPI_OFFSET_COMMONENTRY_A7 0x24 + +#define PERM_MASK 0x0F +#define PERM_SHIFT_REGION7 28 +#define PERM_SYS_RW_USER_RW 0x03 + +/////////////////////////////////////////////////////////////////////// + +// メモリ保護関連 +typedef struct tagMemoryProtection { + OSIntrMode modeIntr; +#ifdef NITRO9 + u32 nCP15R7State; + u32 nInstProtection; + u32 nDataProtection; +#endif // NITRO9 +} MemoryProtection; + +/////////////////////////////////////////////////////////////////////// + +static asm OSIntrMode OSm_DisableInterrupts_IrqAndFiq( void ) +{ + mrs r0, cpsr + orr r1, r0, #HW_PSR_IRQ_FIQ_DISABLE + msr cpsr_c, r1 + and r0, r0, #HW_PSR_IRQ_FIQ_DISABLE + + bx lr +} +static asm OSIntrMode OSm_RestoreInterrupts_IrqAndFiq( register OSIntrMode state ) +{ + mrs r1, cpsr + bic r2, r1, #HW_PSR_IRQ_FIQ_DISABLE + orr r2, r2, r0 + msr cpsr_c, r2 + and r0, r1, #HW_PSR_IRQ_FIQ_DISABLE + + bx lr +} +#ifdef NITRO9 +static asm u32 OSm_SetIPermissionsForProtectionRegionEx( u32 nVal ) +{ + mcr p15, 0, r0, c5, c0, 3 + bx lr +} + +static asm u32 OSm_SetDPermissionsForProtectionRegionEx( u32 nVal ) +{ + mcr p15, 0, r0, c5, c0, 2 + bx lr +} +static asm void OSm_SetProtectionRegion7( u32 param ) +{ + mcr p15, 0, r0, c6, c7, 0 + bx lr +} +static asm u32 OSm_GetIPermissionsForProtectionRegion( void ) +{ + mrc p15, 0, r0, c5, c0, 3 + bx lr +} +static asm u32 OSm_GetDPermissionsForProtectionRegion( void ) +{ + mrc p15, 0, r0, c5, c0, 2 + bx lr +} +static asm u32 OSm_GetProtectionRegion7( void ) +{ + mrc p15, 0, r0, c6, c7, 0 + bx lr +} +#endif // NITRO9 + +/////////////////////////////////////////////////////////////////////// +// プロテクトを解除します +/////////////////////////////////////////////////////////////////////// +#ifdef NITRO9 +static void _isdcallmon_unlockProtect( MemoryProtection *pParam, u32 dwRegion7 ) +{ + // 割り込みを強制的に止める処理 + pParam->modeIntr = OSm_DisableInterrupts_IrqAndFiq(); + + // プロテクションユニットのリージョン7の設定を保存 + pParam->nCP15R7State = OSm_GetProtectionRegion7(); + pParam->nInstProtection = OSm_GetIPermissionsForProtectionRegion(); + pParam->nDataProtection = OSm_GetDPermissionsForProtectionRegion(); + + // リージョン7にオーバーレイ転送情報領域からメインメモリ終了域のプロテクト設定を行う + if( dwRegion7 ) OSm_SetProtectionRegion7( dwRegion7 ) ; + + // ユーザー・システム下で書き込めるように修正 + OSm_SetIPermissionsForProtectionRegionEx( (pParam->nInstProtection & (~(PERM_MASK << PERM_SHIFT_REGION7))) | ( PERM_SYS_RW_USER_RW << PERM_SHIFT_REGION7) ); + OSm_SetDPermissionsForProtectionRegionEx( (pParam->nDataProtection & (~(PERM_MASK << PERM_SHIFT_REGION7))) | ( PERM_SYS_RW_USER_RW << PERM_SHIFT_REGION7) ); +} + // NITRO9 +#else + // NITRO7 +static void _isdcallmon_unlockProtect( MemoryProtection *pParam ) +{ + // 割り込みを強制的に止める処理 + pParam->modeIntr = OSm_DisableInterrupts_IrqAndFiq(); +} +#endif // NITRO7 + + +/////////////////////////////////////////////////////////////////////// +// プロテクト状態を元に戻します +/////////////////////////////////////////////////////////////////////// +static void _isdcallmon_restoreProtect( const MemoryProtection *pParam ) +{ +#ifdef NITRO9 + // ユーザー・システムの保護状態を設定 + OSm_SetDPermissionsForProtectionRegionEx( pParam->nDataProtection ); + OSm_SetIPermissionsForProtectionRegionEx( pParam->nInstProtection ); + + // プロテクションユニットのリージョン7の設定を元に戻す + OSm_SetProtectionRegion7( pParam->nCP15R7State ); +#endif // NITRO9 + + // 割り込みを戻す処理 + (void)OSm_RestoreInterrupts_IrqAndFiq( pParam->modeIntr ); +} + + +//////////////////////////////////////////////////////////////////////// +// モニタコールバック +// +// ・呼び出す前に_ISDbgLib_Initializeを行なっておく必要はありません。 +// ・子機バイナリダウンロード後に呼び出してください。 +// ・loadrun等のISNITRO.dllを用いたダウンロード実行環境や +// v1.75以前の古いデバッガ環境では何もせずに戻ります。 +// +//////////////////////////////////////////////////////////////////////// +static u32 _isdcallmon( APITYPE nIndex, void *pParam ) +{ + MemoryProtection prot; + u32 nMonitorEntry; + u32 nResult = (u32)-1; + + // モニタエントリのチェック + nMonitorEntry = *(vu32*)0x027FFF68; + if ((nMonitorEntry >= HW_MAIN_MEM) && (nMonitorEntry < (HW_MAIN_MEM+0x00800000))) { + +#ifdef NITRO9 + u32 dwRegion7; + + // Unlockする領域の切り分け + if( nMonitorEntry >= (HW_MAIN_MEM+0x00780000) ) { + dwRegion7 = 0x02780000 | HW_C6_PR_512KB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00700000) ) { + dwRegion7 = 0x02700000 | HW_C6_PR_1MB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00600000) ) { + dwRegion7 = 0x02600000 | HW_C6_PR_2MB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00400000) ) { + dwRegion7 = 0x02400000 | HW_C6_PR_4MB | HW_C6_PR_ENABLE; + } else { + dwRegion7 = 0x00000000; + } + + _isdcallmon_unlockProtect( &prot, dwRegion7 ); +#else + _isdcallmon_unlockProtect( &prot ); +#endif + + // シグネチャの確認とジャンプ + { + u32 nSignature = nMonitorEntry + MON_ENTRY_SIGNATURE_OFFSET; + u32 nOVFC = nMonitorEntry + MON_INTAPI_FUNC_OFFSET; + + if( *(u64 *)nSignature == (u64)0x47494c4c45544e49LL // INTELLIG + && *(u32 *)nOVFC == MON_INTAPI_FUNC_SIGN + && *(u32 *)(nOVFC + MON_INTAPI_OFFSET_VERSION) >= 2 + ){ + // 通知関数のアドレス診断 + u32 nAddr; +#ifdef NITRO9 + nAddr = *(u32 *)(nOVFC + MON_INTAPI_OFFSET_COMMONENTRY_A9); +#else + nAddr = *(u32 *)(nOVFC + MON_INTAPI_OFFSET_COMMONENTRY_A7); +#endif + if ((nAddr >= HW_MAIN_MEM) && (nAddr < (HW_MAIN_MEM+0x00800000))) { + // 通知関数へジャンプする + // (bx or blxでブランチしているか確認すること) + nResult = (*(u32(*)( u32, void*))nAddr)( nIndex, pParam ); + } + } + } + + // メモリ保護の復元 + _isdcallmon_restoreProtect( &prot ); + } + + return nResult; +} + +#if 0 +// 子機バイナリダウンロード後のコールバック処理 +static void _ISDbgLib_OnLoadChildBinary( void ) +{ + (void)_isdcallmon( MONAPI_ONLOADCHILD, NULL ); +} +#endif // 0 + +#endif // ISDBG_MB_CHILD_ + + +#include // ここまで。 + diff --git a/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c b/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c new file mode 100644 index 00000000..c7f9104c --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM7/src/bootAPI.c @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot.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 "loader.h" +//#include "mb_child.h" + +// define data------------------------------------------------------- +#define MAINP_SEND_IF 0x0200 + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- +void BOOT_Init( void ); +void BOOT_WaitStart( void ); + +static void BOOTi_ClearREG_RAM( void ); + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- + +void BOOT_Init( void ) +{ + reg_PXI_MAINPINTF = 0x0000; +} + + +BOOL BOOT_WaitStart( void ) +{ + if( (reg_PXI_MAINPINTF & 0x000f ) == 0x000f ) { + (void)OS_DisableIrq(); // ここで割り込み禁止にしないとダメ。 + (void)OS_SetIrqMask(0); // SDKバージョンのサーチに時間がかかると、ARM9がHALTにかかってしまい、ARM7のサウンドスレッドがARM9にFIFOでデータ送信しようとしてもFIFOが一杯で送信できない状態で無限ループに入ってしまう。 +/* +#ifdef ISDBG_MB_CHILD_ + if( ( GetIpl2WorkAddr()->ipl2_type != 0xff ) && ( GetIpl2WorkAddr()->ipl2_type & 0x28 ) ) +#endif // ISDBG_MB_CHILD_ // USG or NATなら無線パッチを当てる + { + InsertWLPatch(); + } +*/ + BOOi_ClearREG_RAM(); // ARM7側のメモリ&レジスタクリア。 + reg_PXI_MAINPINTF = MAINP_SEND_IF | 0x0100; // ARM9に対してブートするようIRQで要求+ARM7のステートを1にする。 + BOOT_Core(); // never return + } + return FALSE; +} + +static void BOOTi_ClearREG_RAM( void ) +{ + int i ; + +// SVC_CpuClearFast(0x0000, IPL2_PRV_WRAM_ARENA_LO, RETURN_FROM_MAIN_ARM7_FUNCP - IPL2_PRV_WRAM_ARENA_LO ); + // アリーナのクリア + for( i = 0; i <= MI_DMA_MAX_NUM; i++ ) { // DMAの停止 + MI_StopDma( i ); + } + // レジスタのクリア + SVC_CpuClearFast( 0x0000, (void*)(HW_REG_BASE + 0x0b0), (0x13c - 0x0b0) ); + // DMA0SAD 〜 RCNT1 + SVC_CpuClearFast( 0x0000, (void*)(HW_REG_BASE + 0x400), 0x104 ); // SG0CNT_L 〜 SGMCNT + SVC_CpuClearFast( 0x0000, (void*)(HW_REG_BASE + 0x508), 0x14 ); // SGRVCNT 〜 SGRV1CLEN + reg_GX_DISPSTAT = 0; + reg_SPI_SPICNT = 0; + reg_PXI_MAINP_FIFO_CNT = 0x4008; + // クリアしていないレジスタは、VCOUNT, JOY, PIFCNT, MC-, EXMEMCNT, IME, PAUSE, POWLCDCNT, 他セキュリティ系です。 + (void)OS_ResetRequestIrqMask(~0); +} +} \ No newline at end of file diff --git a/build/libraries_sysmenu/boot/ARM9/Makefile b/build/libraries_sysmenu/boot/ARM9/Makefile new file mode 100644 index 00000000..12566b85 --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM9/Makefile @@ -0,0 +1,51 @@ +#! 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 = ../common/src + +INCDIR = ../common/include + +SRCS = boot.c + +TARGET_LIB = libboot$(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/boot/ARM9/src/boot.c b/build/libraries_sysmenu/boot/ARM9/src/boot.c new file mode 100644 index 00000000..ec6c1573 --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM9/src/boot.c @@ -0,0 +1,474 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: boot.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 "IPL2_work.h" +//#include "define.h" + +// define data------------------------------------------------------- +#define C1_DTCM_ENABLE 0x00010000 // データTCM イネーブル +#define C1_EXCEPT_VEC_UPPER 0x00002000 // 例外ベクタ 上位アドレス(こちらに設定して下さい) +#define C1_SB1_BITSET 0x00000078 // レジスタ1用1固定ビット列(後期アボートモデル、DATA32構成シグナル制御、PROG32構成シグナル制御、ライトバッファイネーブル) +#define INITi_HW_DTCM SDK_AUTOLOAD_DTCM_START + + +// extern data------------------------------------------------------- +// from LCF +extern void SDK_IRQ_STACKSIZE( void ); + +// function's prototype---------------------------------------------- +void BOOT_Core( void ); + +static void ResetCP15( void ); +static void ClearBankregAndStack( void ); +static void CpuClear32Byte( void ); + +#ifdef ISDBG_MB_CHILD_ +// モニタAPI番号 +typedef enum { MONAPI_ONLOADCHILD = 0 } APITYPE; +static u32 _isdcallmon( APITYPE nIndex, void *pParam ); +static void _ISDbgLib_OnLoadChildBinary(void); +#endif // ISDBG_MB_CHILD_ + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- +#include // このソースはデフォルトではARMでコンパイルされる。 + +asm void BOOT_Core( void ) +{ + //--------------------------------------- + // データキャッシュを全て無効に。(DC_InvalidateAllを抜き出して実装) + //--------------------------------------- + mov r0, #0 + mcr p15, 0, r0, c7, c6, 0 + + //--------------------------------------- + // ARM7との同期をとる(subp_stateが2になるのを待って、mainp_stateを2にする。) + //--------------------------------------- + ldr r1, =REG_SUBPINTF_ADDR +@0 ldrh r0, [r1] + and r0, r0, #0x000f + cmp r0, #0x0002 + bne @0 + mov r0, #0x0200 + strh r0, [r1] + + //--------------------------------------- + // ISデバッガ動作フラグの格納 + //--------------------------------------- +#ifdef __IS_DEBUGGER_BUILD + ldr r3, =HW_MAIN_MEM_EX_END + sub r0, r3, #0x400 + ldrh r11, [r0, #0x14] // r11 = GetMovedInfoFromIPL1Addr()->isOnDebugger +#endif + //--------------------------------------- + // ARM7との同期をとる(subp_stateが1になるのを待って、mainp_stateを1にする。) + //--------------------------------------- + ldr r1, =REG_SUBPINTF_ADDR +@1 ldrh r0, [r1] + and r0, r0, #0x000f + cmp r0, #0x0001 + bne @1 + mov r0, #0x0100 + strh r0, [r1] + + //--------------------------------------- + // ISデバッガでのDL子機プログラムのデバッグ情報設定 + //--------------------------------------- +#ifdef ISDBG_MB_CHILD_ + mov r0, #MONAPI_ONLOADCHILD + mov r1, #0 + bl _isdcallmon +// bl _ISDbgLib_OnLoadChildBinary +#endif // ISDBG_MB_CHILD_ + + //--------------------------------------- + // バンクレジスタ&スタッククリア + //--------------------------------------- + bl ClearBankregAndStack + + //--------------------------------------- + // プロテクションユニットの解除 + //--------------------------------------- + bl ResetCP15 + + //--------------------------------------- + // ARM7との最終同期をとる(subp_stateが0になるのを待って、mainp_stateを0にする) + //--------------------------------------- + ldr r1, =REG_SUBPINTF_ADDR +@2 ldrh r0, [r1] + and r0, r0, #0x000f + cmp r0, #0x0001 + beq @2 + mov r0, #0 + strh r0, [r1] + + //--------------------------------------- + // R11の値をもとにブートアドレス取得 + //--------------------------------------- + ldr r3, =HW_MAIN_MEM_EX_END // ゲーム・エントリポイント 獲得 + ldr r12, [r3, #-(0x200 - 0x24)] // rmhp->arm9->entryAddr + mov lr, r12 + +#ifdef __IS_DEBUGGER_BUILD + cmp r11, #1 // if (!GetMovedInfoFromIPL1Addr()->isOnDebugger) + ldreq r12, [r3, #-(0x200 - 0x168)] // デバッガ・エントリポイント 獲得 +#endif + + //--------------------------------------- + // 汎用レジスタクリア + //--------------------------------------- + ldr r11, =INITi_HW_DTCM // クリアしたDTCMからデータを読み出して、汎用レジスタをクリアする。 + ldmia r11, {r0-r10} + mov r11, #0 + + //--------------------------------------- + // ゲームブート + //--------------------------------------- + bx r12 +} + + +//----------------------------------------------------------------------- +// システム制御コプロセッサ リセット +//----------------------------------------------------------------------- +asm static void ResetCP15( void ) +{ + // プロテクションユニット&キャッシュ&ITCM無効。DTCMは有効(スタックをクリアするため) + ldr r0, = C1_DTCM_ENABLE | C1_EXCEPT_VEC_UPPER | C1_SB1_BITSET + mcr p15, 0, r0, c1, c0, 0 + + // ITCMの割り当てを解除 + mov r0, #0 + mcr p15, 0, r0, c6, c5, 0 + + // DTCMの割り当てを解除 +// mov r0,#0 +// mcr p15, 0, r0, c9, c1, 0 + + // キャッシュ無効化 + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 // 命令キャッシュ + mcr p15, 0, r0, c7, c6, 0 // データキャッシュ + + // ライトバッファ エンプティ待ち + mcr p15, 0, r0, c7, c10, 4 + + bx lr +} + + +//----------------------------------------------------------------------- +// バンクレジスタ リセット & スタック領域 クリア +//----------------------------------------------------------------------- +asm static void ClearBankregAndStack( void ) +{ + mov r12, lr + +#ifndef ISDBG_MB_CHILD_ + mov r0, #0xc0 | HW_PSR_SVC_MODE // SVCモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + mov sp, r0 // SP のセット + mov lr, #0 + msr spsr_csxf, lr + + mov r0, #0xc0 | HW_PSR_IRQ_MODE // IRQモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + ldr r0, =INITi_HW_DTCM + add r0, r0, #0x3fc0 + sub r0, r0, #HW_SVC_STACK_SIZE + mov sp, r0 // SP のセット + mov lr, #0 + msr spsr_cxsf, lr + + ldr r1, =SDK_IRQ_STACKSIZE + sub r1, r0, r1 + mov r0, #0xc0 | HW_PSR_SYS_MODE // システムモードへ切り換え & IRQ/FIQ不許可 + msr cpsr_cxsf, r0 + sub sp, r1, #4 // SP のセット & 4byte for stack check code +#endif // ISDBG_MB_CHILD_ + + ldr r0, =HW_ITCM // ITCMのクリア + mov r1, #HW_ITCM_SIZE + bl CpuClear32Byte + + ldr r0, =INITi_HW_DTCM // スタックを含めたDTCMのクリア + mov r1, #HW_DTCM_SIZE + bl CpuClear32Byte + + bx r12 +} + + +// 32byte単位のメモリクリア r0 dstp,r1 byteSize +asm static void CpuClear32Byte( void ) +{ + add r2, r0, r1 // 終了アドレスの算出 + mov r1, r1, lsr #5 // サイズは32byte単位 + mov r3, #0 + mov r4, r3 + mov r5, r3 + mov r6, r3 + mov r7, r3 + mov r8, r3 + mov r9, r3 + mov r10, r3 +@0 cmp r0, r2 // クリア終了? + stmltia r0!, {r3-r10} + blt @0 + bx lr +} + + + + +#ifdef ISDBG_MB_CHILD_ +/////////////////////////////////////////////////////////////////////// +// Project: モニタの呼び出し - ISデバッグライブラリ内コード相当の実装 +// Copyright (C)2007 INTELIGENT SYSTEMS Co.,Ltd. +/////////////////////////////////////////////////////////////////////// + +#ifdef SDK_ARM9 +// ARM9の場合定義 +#define NITRO9 +#endif // SDK_ARM9 + +/////////////////////////////////////////////////////////////////////// + +#define MON_ENTRY_SIGNATURE_OFFSET 0x00010 +#define MON_INTAPI_FUNC_OFFSET 0x002A0 +#define MON_INTAPI_FUNC_SIGN 0x4346564f // OVFC +#define MON_INTAPI_OFFSET_VERSION 0x04 +#define MON_INTAPI_OFFSET_COMMONENTRY_A9 0x20 +#define MON_INTAPI_OFFSET_COMMONENTRY_A7 0x24 + +#define PERM_MASK 0x0F +#define PERM_SHIFT_REGION7 28 +#define PERM_SYS_RW_USER_RW 0x03 + +/////////////////////////////////////////////////////////////////////// + + +// メモリ保護関連 +typedef struct tagMemoryProtection { + OSIntrMode modeIntr; +#ifdef NITRO9 + u32 nCP15R7State; + u32 nInstProtection; + u32 nDataProtection; +#endif // NITRO9 +} MemoryProtection; + +/////////////////////////////////////////////////////////////////////// + +static asm OSIntrMode OSm_DisableInterrupts_IrqAndFiq( void ) +{ + mrs r0, cpsr + orr r1, r0, #HW_PSR_IRQ_FIQ_DISABLE + msr cpsr_c, r1 + and r0, r0, #HW_PSR_IRQ_FIQ_DISABLE + + bx lr +} +static asm OSIntrMode OSm_RestoreInterrupts_IrqAndFiq( register OSIntrMode state ) +{ + mrs r1, cpsr + bic r2, r1, #HW_PSR_IRQ_FIQ_DISABLE + orr r2, r2, r0 + msr cpsr_c, r2 + and r0, r1, #HW_PSR_IRQ_FIQ_DISABLE + + bx lr +} +#ifdef NITRO9 +static asm u32 OSm_SetIPermissionsForProtectionRegionEx( u32 nVal ) +{ + mcr p15, 0, r0, c5, c0, 3 + bx lr +} + +static asm u32 OSm_SetDPermissionsForProtectionRegionEx( u32 nVal ) +{ + mcr p15, 0, r0, c5, c0, 2 + bx lr +} +static asm void OSm_SetProtectionRegion7( u32 param ) +{ + mcr p15, 0, r0, c6, c7, 0 + bx lr +} +static asm u32 OSm_GetIPermissionsForProtectionRegion( void ) +{ + mrc p15, 0, r0, c5, c0, 3 + bx lr +} +static asm u32 OSm_GetDPermissionsForProtectionRegion( void ) +{ + mrc p15, 0, r0, c5, c0, 2 + bx lr +} +static asm u32 OSm_GetProtectionRegion7( void ) +{ + mrc p15, 0, r0, c6, c7, 0 + bx lr +} +#endif // NITRO9 + +/////////////////////////////////////////////////////////////////////// +// プロテクトを解除します +/////////////////////////////////////////////////////////////////////// +#ifdef NITRO9 +static void _isdcallmon_unlockProtect( MemoryProtection *pParam, u32 dwRegion7 ) +{ + // 割り込みを強制的に止める処理 + pParam->modeIntr = OSm_DisableInterrupts_IrqAndFiq(); + + // プロテクションユニットのリージョン7の設定を保存 + pParam->nCP15R7State = OSm_GetProtectionRegion7(); + pParam->nInstProtection = OSm_GetIPermissionsForProtectionRegion(); + pParam->nDataProtection = OSm_GetDPermissionsForProtectionRegion(); + + // リージョン7にオーバーレイ転送情報領域からメインメモリ終了域のプロテクト設定を行う + if( dwRegion7 ) OSm_SetProtectionRegion7( dwRegion7 ) ; + + // ユーザー・システム下で書き込めるように修正 + OSm_SetIPermissionsForProtectionRegionEx( (pParam->nInstProtection & (~(PERM_MASK << PERM_SHIFT_REGION7))) | ( PERM_SYS_RW_USER_RW << PERM_SHIFT_REGION7) ); + OSm_SetDPermissionsForProtectionRegionEx( (pParam->nDataProtection & (~(PERM_MASK << PERM_SHIFT_REGION7))) | ( PERM_SYS_RW_USER_RW << PERM_SHIFT_REGION7) ); +} + // NITRO9 +#else + // NITRO7 +static void _isdcallmon_unlockProtect( MemoryProtection *pParam ) +{ + // 割り込みを強制的に止める処理 + pParam->modeIntr = OSm_DisableInterrupts_IrqAndFiq(); +} +#endif // NITRO7 + + +/////////////////////////////////////////////////////////////////////// +// プロテクト状態を元に戻します +/////////////////////////////////////////////////////////////////////// +static void _isdcallmon_restoreProtect( const MemoryProtection *pParam ) +{ +#ifdef NITRO9 + // ユーザー・システムの保護状態を設定 + OSm_SetDPermissionsForProtectionRegionEx( pParam->nDataProtection ); + OSm_SetIPermissionsForProtectionRegionEx( pParam->nInstProtection ); + + // プロテクションユニットのリージョン7の設定を元に戻す + OSm_SetProtectionRegion7( pParam->nCP15R7State ); +#endif // NITRO9 + + // 割り込みを戻す処理 + (void)OSm_RestoreInterrupts_IrqAndFiq( pParam->modeIntr ); +} + + +//////////////////////////////////////////////////////////////////////// +// モニタコールバック +// +// ・呼び出す前に_ISDbgLib_Initializeを行なっておく必要はありません。 +// ・子機バイナリダウンロード後に呼び出してください。 +// ・loadrun等のISNITRO.dllを用いたダウンロード実行環境や +// v1.75以前の古いデバッガ環境では何もせずに戻ります。 +// +//////////////////////////////////////////////////////////////////////// +static u32 _isdcallmon( APITYPE nIndex, void *pParam ) +{ + MemoryProtection prot; + u32 nMonitorEntry; + u32 nResult = (u32)-1; + + // モニタエントリのチェック + nMonitorEntry = *(vu32*)0x027FFF68; + if ((nMonitorEntry >= HW_MAIN_MEM) && (nMonitorEntry < (HW_MAIN_MEM+0x00800000))) { + +#ifdef NITRO9 + u32 dwRegion7; + + // Unlockする領域の切り分け + if( nMonitorEntry >= (HW_MAIN_MEM+0x00780000) ) { + dwRegion7 = 0x02780000 | HW_C6_PR_512KB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00700000) ) { + dwRegion7 = 0x02700000 | HW_C6_PR_1MB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00600000) ) { + dwRegion7 = 0x02600000 | HW_C6_PR_2MB | HW_C6_PR_ENABLE; + } else + if( nMonitorEntry >= (HW_MAIN_MEM+0x00400000) ) { + dwRegion7 = 0x02400000 | HW_C6_PR_4MB | HW_C6_PR_ENABLE; + } else { + dwRegion7 = 0x00000000; + } + + _isdcallmon_unlockProtect( &prot, dwRegion7 ); +#else + _isdcallmon_unlockProtect( &prot ); +#endif + + // シグネチャの確認とジャンプ + { + u32 nSignature = nMonitorEntry + MON_ENTRY_SIGNATURE_OFFSET; + u32 nOVFC = nMonitorEntry + MON_INTAPI_FUNC_OFFSET; + + if( *(u64 *)nSignature == (u64)0x47494c4c45544e49LL // INTELLIG + && *(u32 *)nOVFC == MON_INTAPI_FUNC_SIGN + && *(u32 *)(nOVFC + MON_INTAPI_OFFSET_VERSION) >= 2 + ){ + // 通知関数のアドレス診断 + u32 nAddr; +#ifdef NITRO9 + nAddr = *(u32 *)(nOVFC + MON_INTAPI_OFFSET_COMMONENTRY_A9); +#else + nAddr = *(u32 *)(nOVFC + MON_INTAPI_OFFSET_COMMONENTRY_A7); +#endif + if ((nAddr >= HW_MAIN_MEM) && (nAddr < (HW_MAIN_MEM+0x00800000))) { + // 通知関数へジャンプする + // (bx or blxでブランチしているか確認すること) + nResult = (*(u32(*)( u32, void*))nAddr)( nIndex, pParam ); + } + } + } + + // メモリ保護の復元 + _isdcallmon_restoreProtect( &prot ); + } + + return nResult; +} + +#if 0 +// 子機バイナリダウンロード後のコールバック処理 +static void _ISDbgLib_OnLoadChildBinary(void) +{ + (void)_isdcallmon( MONAPI_ONLOADCHILD, NULL ); +} +#endif // 0 + +#endif // ISDBG_MB_CHILD_ + + +#include // ここまで。 + diff --git a/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c b/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c new file mode 100644 index 00000000..9733a1ac --- /dev/null +++ b/build/libraries_sysmenu/boot/ARM9/src/bootAPI.c @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------* + Project: TwlIPL + File: bootAPI.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 "IPL2_work.h" +//#include "define.h" + +// define data------------------------------------------------------- + +// extern data------------------------------------------------------- + +// function's prototype---------------------------------------------- +static void BOOTi_ClearREG_RAM( void ); +static void BOOTi_StartBOOT( void ); + +// global variables-------------------------------------------------- + +// static variables-------------------------------------------------- + +// const data-------------------------------------------------------- +void BOOT_Init( void ) +{ + reg_PXI_SUBPINTF = 0x0000; +} + + +// ブート準備をして、ARM7からの通知を待つ。 +void BOOT_Ready( void ) +{ + int i; + + // エントリアドレスの正当性をチェックし、無効な場合は無限ループに入る。 +// SYSMi_CheckEntryAddress(); + + for( i = 0; i <= MI_DMA_MAX_NUM; i++ ) { // DMAの停止 + MI_StopDma( i ); + } + +// FinalizeCardPulledOut(); // カード抜け検出終了処理 + BOOTi_ClearREG_RAM(); // レジスタ&RAMクリア + (void)GX_VBlankIntr( FALSE ); + (void)OS_SetIrqFunction( OS_IE_SUBP, NULL ); + (void)OS_SetIrqMask( OS_IE_SUBP ); // サブプロセッサ割り込みのみを許可。 + reg_PXI_SUBPINTF = SUBP_RECV_IF_ENABLE | 0x0f00; // ARM9ステートを "0x0f" に + // ※もうFIFOはクリア済みなので、使わない。 + + // ARM7からの通知待ち + OS_WaitIrq( 1, OS_IE_SUBP ); + + // 割り込みをクリアして最終ブートシーケンスへ。 + reg_PXI_SUBPINTF &= 0x0f00; // サブプロセッサ割り込み許可フラグをクリア + (void)OS_DisableIrq(); + (void)OS_SetIrqMask( 0 ); + (void)OS_ResetRequestIrqMask( ~0 ); + + BOOT_Core(); // never return +} + + +// 使用したレジスタ&メモリのクリア +static void BOOTi_ClearREG_RAM( void ) +{ + // 最後がサブプロセッサ割り込み待ちなので、IMEはクリアしない。 + (void)OS_SetIrqMask( 0 ); + (void)OS_ResetRequestIrqMask( ~0 ); + + // メモリクリア + GX_SetBankForLCDC( GX_VRAM_LCDC_ALL ); // VRAM クリア + MI_CpuClearFast( (void*)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE ); + (void)GX_DisableBankForLCDC(); +// MI_CpuClearFast( (void *)HW_ITCM, HW_ITCM_SIZE ); // ITCM クリア ※ITCMにはSDKのコードが入っているので、BOOT_Coreでクリアする。 +// MI_CpuClearFast( (void *)HW_DTCM, HW_DTCM_SIZE - 0x800 ); // DTCM クリア ※DTCMはスタック&SDK変数入りなので、最後にBOOT_Coreでクリアする。 + MI_CpuClearFast( (void *)HW_OAM, HW_OAM_SIZE ); // OAM クリア + MI_CpuClearFast( (void *)HW_PLTT, HW_PLTT_SIZE ); // パレット クリア + MI_CpuClearFast( (void *)HW_DB_OAM, HW_DB_OAM_SIZE ); // OAM クリア + MI_CpuClearFast( (void *)HW_DB_PLTT,HW_DB_PLTT_SIZE ); // パレット クリア + + // レジスタクリア + MI_CpuClearFast( (void*)( HW_REG_BASE + 0x8 ), 0x12c ); // BG0CNT 〜 KEYCNT + MI_CpuClearFast( (void*)( HW_REG_BASE + 0x280 ), 0x40 ); // DIVCNT 〜 SQRTD3 + MI_CpuClearFast( (void*)( HW_REG_BASE + 0x1000 ), 0x6e ); // DISP1CNT1 〜 DISPBRTCNT1 + CP_SetDiv32_32( 0, 1 ); + reg_PXI_SUBP_FIFO_CNT = 0x4008; + reg_GX_DISPCNT = 0; + reg_GX_DISPSTAT = 0; // ※ reg_GX_VCOUNTはベタクリアできないので、この先頭部分のクリアを分離する。 + + // クリアしていないレジスタは、VCOUNT, PIFCNT, MC-, EXMEMCNT, IME, RBKCNT1, PAUSE, POWLCDCNT, 全3D系。 +} + diff --git a/build/libraries_sysmenu/boot/Makefile b/build/libraries_sysmenu/boot/Makefile new file mode 100644 index 00000000..6024cf88 --- /dev/null +++ b/build/libraries_sysmenu/boot/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 = ARM7 ARM9 + +include $(TWLIPL_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLIPL_ROOT)/build/buildtools/modulerules + +#===== End of Makefile =====