mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
TestComponentのソースを含めるよう変更。
TestComponent の不要なコードを削減。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2780 b08762b0-b915-fc4b-9d8c-17b2551a87ff
231 lines
6.3 KiB
C
231 lines
6.3 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: TwlSDK - NandInitializer
|
||
File: main.c
|
||
|
||
Copyright 2008 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 <twl.h>
|
||
#include <nitro/snd.h>
|
||
#include <twl/fatfs.h>
|
||
#include <nitro/card.h>
|
||
#include <twl/nam.h>
|
||
#include <twl/os/common/format_rom.h>
|
||
#include <sysmenu/namut.h>
|
||
#include "kami_font.h"
|
||
#include "graphics.h"
|
||
#include "keypad.h"
|
||
#include "kami_pxi.h"
|
||
|
||
#define SCRAMBLE_MASK 0x00406000
|
||
|
||
extern void HWInfoWriterInit( void );
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Œ^’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
typedef void* (*Process)(void);
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”•Ï<E280A2>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
static Process sProcess;
|
||
static FSEventHook sSDHook;
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”ŠÖ<C5A0>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
static void VBlankIntr(void);
|
||
static void InitAllocation(void);
|
||
|
||
static void* DummyProcess0(void)
|
||
{
|
||
return DummyProcess0;
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: TwlMain
|
||
|
||
Description: main
|
||
|
||
Arguments: None
|
||
|
||
Returns: None
|
||
*---------------------------------------------------------------------------*/
|
||
void
|
||
TwlMain()
|
||
{
|
||
// <20>»•iƒrƒ‹ƒhƒ‰ƒ“ƒ`ƒƒ<C692>[<5B>•ƒfƒoƒbƒK<C692>ã‚ł̋N“®‘Ήž
|
||
if ( OS_GetRunningConsoleType() & OS_CONSOLE_TWLDEBUGGER )
|
||
{
|
||
ROM_Header *dh = (void *)HW_ROM_HEADER_BUF;
|
||
dh->s.game_cmd_param &= ~SCRAMBLE_MASK;
|
||
}
|
||
|
||
OS_Init();
|
||
OS_InitTick();
|
||
OS_InitArena();
|
||
PXI_Init();
|
||
OS_InitLock();
|
||
OS_InitArenaEx();
|
||
OS_InitIrqTable();
|
||
OS_SetIrqStackChecker();
|
||
MI_Init();
|
||
OS_InitVAlarm();
|
||
OSi_InitVramExclusive();
|
||
OS_InitThread();
|
||
OS_InitReset();
|
||
GX_Init();
|
||
FX_Init();
|
||
SND_Init();
|
||
SNDEX_Init();
|
||
TP_Init();
|
||
RTC_Init();
|
||
|
||
#ifndef NAND_INITIALIZER_LIMITED_MODE
|
||
KamiPxiInit(); /* “ÆŽ©PXI<58>‰Šú‰» */
|
||
#endif
|
||
|
||
// Vƒuƒ‰ƒ“ƒNŠ„‚è<E2809A>ž‚Ý<E2809A>Ý’è
|
||
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
|
||
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||
(void)OS_EnableIrqMask(OS_IE_FIFO_RECV);
|
||
(void)OS_EnableIrq();
|
||
(void)GX_VBlankIntr(TRUE);
|
||
|
||
// initialize file-system
|
||
FS_Init(FS_DMA_NOT_USE);
|
||
|
||
// FATƒhƒ‰ƒCƒo‚ð<E2809A>‰Šú‰»‚µ‚Ü‚·<E2809A>B
|
||
// NAND‚ɃAƒNƒZƒX‚·‚邽‚߂ɕK—v‚Å‚·<E2809A>B
|
||
// ‚±‚ÌŠÖ<C5A0>”‚ÍTwlSDK_branchUIG‚ɂ͊܂܂ê‚Ä‚¢‚Ü‚¹‚ñ<E2809A>B
|
||
FS_InitFatDriver();
|
||
|
||
// SDƒJ<C692>[ƒh‚Ì‘}”²ƒCƒxƒ“ƒgŠÄŽ‹ƒR<C692>[ƒ‹ƒoƒbƒN<C692>Ý’è
|
||
// FS_RegisterEventHook("sdmc", &sSDHook, SDEvents, NULL);
|
||
|
||
// FS_Init‚ÌŒã‚Ì•û‚ª—Ç‚¢–Í—l
|
||
InitAllocation();
|
||
|
||
// •\ަŠÖ˜A<CB9C>‰Šú‰»
|
||
InitGraphics();
|
||
kamiFontInit();
|
||
|
||
/* always preload FS table for faster directory access. */
|
||
{
|
||
u32 need_size = FS_GetTableSize();
|
||
void *p_table = OS_Alloc(need_size);
|
||
SDK_ASSERT(p_table != NULL);
|
||
(void)FS_LoadTable(p_table, need_size);
|
||
}
|
||
|
||
// <20>‰ŠúƒV<C692>[ƒPƒ“ƒX<C692>Ý’è
|
||
sProcess = DummyProcess0;
|
||
|
||
kamiFontPrintfConsole( CONSOLE_ORANGE, "This is Test Component\n");
|
||
|
||
#ifdef TWL_CAPTURE_VERSION
|
||
// memory-launcherŒo—R‚Å—§‚¿<E2809A>オ‚éTWLCaptureSystemWriter‚Å‚Í
|
||
// RED_LAUNCHER_VER‚ª0‚ŃtƒH<C692>[ƒ}ƒbƒg‚ÉŽ¸”s‚·‚é‚̂ŋ<E280B9>§“I‚É<E2809A>‘‚«Š·‚¦‚é
|
||
MI_StoreLE8((void*)HW_TWL_RED_LAUNCHER_VER, 1);
|
||
#endif
|
||
|
||
#ifdef AUTO_FORMAT_MODE
|
||
// ŒŸ<C592>¸<EFBFBD>H’ö‚Å‚ÍNAND‚ª<E2809A>‰Šú‰»‚³‚ê‚Ä‚¢‚È‚¢‚ª‚»‚Ì<E2809A>ó‘Ô‚ÅFAT‚ɃAƒNƒZƒX‚·‚邯
|
||
// –â‘肪‚ ‚邽‚ß‹<E280B9>§“I‚ɃtƒH<C692>[ƒ}ƒbƒg‚ð<E2809A>s‚¤ 2008/06/18
|
||
// ExeFormat(FORMAT_MODE_QUICK);
|
||
//
|
||
// Secure<72>î•ñ‚ð“Ç‚Ý<E2809A>ž‚Þ‘O‚ɃtƒH<C692>[ƒ}ƒbƒg‚µ‚Ä‚µ‚Ü‚¤‚ÆSecure<72>î•ñ‚ª<E2809A>Á‚¦‚Ä‚µ‚Ü‚¤<E2809A>B
|
||
// ‚»‚¤‚·‚邯ƒVƒŠƒAƒ‹No‚ª<E2809A>‘‚«Š·‚í‚Á‚Ä‚µ‚Ü‚¤‚̂ł±‚Ì<E2809A>ˆ—<CB86>‚͂Ȃ‚·<E2809A>B
|
||
// ŒŸ<C592>¸<EFBFBD>H’ö‚ƈقȂèNandInitializer‚ªŽÀ<C5BD>s‚³‚ê‚é’iŠK‚ł̓tƒH<C692>[ƒ}ƒbƒg<C692>ς݂Ȃ͂¸<E2809A>B
|
||
// ‰¼‚É–¢ƒtƒH<C692>[ƒ}ƒbƒg‚Å‚ ‚Á‚½‚Æ‚µ‚Ä‚àBadFormatˆµ‚¢‚ƂȂé<E2809A>B2009/03/05
|
||
#endif
|
||
|
||
// NAMƒ‰ƒCƒuƒ‰ƒŠ<C692>‰Šú‰»
|
||
NAM_Init( OS_AllocFromMain, OS_FreeToMain);
|
||
NAMUT_Init( OS_AllocFromMain, OS_FreeToMain);
|
||
|
||
/*
|
||
{
|
||
u8 temp;
|
||
kamiCodecRead( 1, 31, &temp);
|
||
OS_Printf("temp = %x\n", temp);
|
||
kamiCodecWrite( 1, 31, (temp & 0x7f));
|
||
kamiCodecRead( 1, 31, &temp);
|
||
OS_Printf("temp = %x\n", temp);
|
||
|
||
}
|
||
*/
|
||
|
||
while (1)
|
||
{
|
||
kamiPadRead();
|
||
|
||
// ƒRƒ}ƒ“ƒhƒtƒ‰ƒbƒVƒ…
|
||
// (void)SND_FlushCommand(SND_COMMAND_NOBLOCK);
|
||
|
||
// Vƒuƒ‰ƒ“ƒN‘Ò‚¿
|
||
OS_WaitVBlankIntr();
|
||
|
||
// ‚`‚q‚l‚VƒRƒ}ƒ“ƒh‰ž“šŽó<C5BD>M
|
||
// while (SND_RecvCommandReply(SND_COMMAND_NOBLOCK) != NULL)
|
||
// {
|
||
// }
|
||
|
||
// ƒtƒHƒ“ƒgƒXƒNƒŠ<C692>[ƒ“ƒf<C692>[ƒ^ƒ<><C692>[ƒh
|
||
kamiFontLoadScreenData();
|
||
|
||
sProcess = sProcess();
|
||
}
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: VBlankIntr
|
||
|
||
Description: VBlankŠ„‚è<E2809A>ž‚Ý<E2809A>ˆ—<CB86>
|
||
|
||
Arguments: None.
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
static void
|
||
VBlankIntr(void)
|
||
{
|
||
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: InitAllocation
|
||
|
||
Description: ƒq<C692>[ƒv‚Ì<E2809A>‰Šú‰».
|
||
|
||
Arguments: None.
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
static void InitAllocation(void)
|
||
{
|
||
void *tmp;
|
||
OSHeapHandle hh;
|
||
|
||
/* ƒAƒŠ<C692>[ƒi‚Ì<E2809A>‰Šú‰» */
|
||
tmp = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1);
|
||
OS_SetArenaLo(OS_ARENA_MAIN, tmp);
|
||
hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi());
|
||
if (hh < 0)
|
||
OS_Panic("ARM9: Fail to create heap...\n");
|
||
hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh);
|
||
}
|
||
|