TwlIPL/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/main.c
kamikawa d3fee837c3 本体初期化時にshared2以下を消去しないようにしました。
本体初期化時に本体ボリュームとバックライト輝度を初期化するようにしました。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1859 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-07-11 08:04:21 +00:00

220 lines
6.1 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
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 <sysmenu/namut.h>
#include "kami_font.h"
#include "process_format.h"
#include "process_topmenu.h"
#include "graphics.h"
#include "keypad.h"
#include "kami_pxi.h"
#include "sd_event.h"
#include "process_fade.h"
#include "hwi.h"
extern void HWInfoWriterInit( void );
/*---------------------------------------------------------------------------*
“à•”•Ï<E280A2>è`
*---------------------------------------------------------------------------*/
static Process sProcess;
static FSEventHook sSDHook;
/*---------------------------------------------------------------------------*
“à•”ŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
static void VBlankIntr(void);
static void InitAllocation(void);
/*---------------------------------------------------------------------------*
Name: TwlMain
Description: main
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void
TwlMain()
{
OS_Init();
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);
#ifdef MARIOCLUB_VERSION
// ƒ{ƒ“ƒfƒBƒ“ƒOƒIƒvƒVƒ‡ƒ“ª<E2809A>»•iÈçâŽ~
if (SCFG_ReadBondingOption() == SCFG_OP_PRODUCT)
{
OS_Panic("Bonding Option == PRODUCT\n");
}
#endif // MARIOCLUB_VERSION
// initialize file-system
FS_Init(FS_DMA_NOT_USE);
// 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 = TopmenuProcess0;
kamiFontPrintfConsole( CONSOLE_ORANGE, "How to \n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "l A Button : Select Menu l\n");
kamiFontPrintfConsole( CONSOLE_ORANGE, "l Up/Down Key : Change Menu l\n");
#ifndef NAND_INITIALIZER_LIMITED_MODE
kamiFontPrintfConsole( CONSOLE_ORANGE, "l L&R Button : Auto Init l\n");
#endif
kamiFontPrintfConsole( CONSOLE_ORANGE, "+---------------------------+\n");
#ifdef AUTO_FORMAT_MODE
// ŒŸ<C592>¸<EFBFBD>HöÅÍNANDª<E2809A>‰Šú‰»³êĢȢª»Ì<E2809A>óÔÅFATɃAƒNƒZƒX·éÆ
// â誠é½ß­<E280B9>§“IɃtƒH<C692>[ƒ}ƒbƒgð<E2809A>s¤
ExeFormat(FORMAT_MODE_QUICK);
#endif
// NAMƒ‰ƒCƒuƒ‰ƒŠ<C692>‰Šú‰»
NAM_Init( OS_AllocFromMain, OS_FreeToMain);
NAMUT_Init( OS_AllocFromMain, OS_FreeToMain);
// HWInfoŠÖ˜AÌO<E28098>€”õ
switch (HWI_Init( OS_AllocFromMain, OS_FreeToMain ))
{
case HWI_INIT_FAILURE:
kamiFontPrintfConsoleEx(CONSOLE_RED, "HWI_INIT() Failure!\n" );
break;
case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE:
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[PRO Signature MODE]\n" );
break;
case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE:
kamiFontPrintfConsoleEx(CONSOLE_ORANGE, "[DEV Signature MODE]\n" );
break;
case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE:
kamiFontPrintfConsoleEx(CONSOLE_RED, "[No Signature MODE]\n" );
break;
}
while (1)
{
kamiPadRead();
// ƒRƒ}ƒ“ƒhƒtƒ‰ƒbƒVƒ…
// (void)SND_FlushCommand(SND_COMMAND_NOBLOCK);
// Vƒuƒ‰ƒ“ƒNÒ¿
OS_WaitVBlankIntr();
// `qlVƒ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);
}