add loading WLAN-firmware.

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@632 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2008-02-12 08:00:30 +00:00
parent a6dda3dfa8
commit 7151ec854c
4 changed files with 138 additions and 1 deletions

View File

@ -47,7 +47,7 @@ MISC_DIR = ../../misc
BG_DIR = ../../data
SRCS_LOGO = logoDemo.c logoData.c
SRCS = main.c launcher.c sound.c bannerCounter.c \
SRCS = main.c launcher.c sound.c bannerCounter.c loadWlanFirm.c \
$(addprefix $(LOGO_DIR)/, $(SRCS_LOGO)) \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c \
$(BG_DIR)/BGData_Launcher.c

View File

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*
Project: TWL_RED_IPL -
File: loadWlanFirm.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 <twl/nam.h>
#include <twl/os/common/format_rom.h>
#include "loadWlanFirm.h"
static int isNwmActive;
static u32 nwmBuf[NWM_SYSTEM_BUF_SIZE/sizeof(u32)] ATTRIBUTE_ALIGN(32);
static u32 fwBuffer[256*1024/sizeof(u32)] ATTRIBUTE_ALIGN(32);
static void nwmcallback(void* arg)
{
NWMCallback *cb = (NWMCallback*)arg;
switch (cb->apiid)
{
case NWM_APIID_LOAD_DEVICE:
if (cb->retcode == NWM_RETCODE_SUCCESS) {
isNwmActive = 1;
/* osSendMessage */
OS_TPrintf("Wlan firm:Load Device success!\n");
} else {
OS_TPrintf("Wlan firm:Load Device Timeout Error!\n");
}
break;
case NWM_APIID_UNLOAD_DEVICE:
OS_TPrintf("Wlan firm:Unload Device success!\n");
break;
defalut:
OS_TPrintf("Wlan firm:Error(apiid=default)!\n");
break;
}
}
BOOL WirelessFirmwareDownloadStart(void)
{
char path[256];
FSFile file[1];
char *title = "WFW0";
u32 titleID_hi;
u32 titleID_lo;
u64 titleID = 0;
s32 flen = 0;
NWMRetCode err;
titleID_hi = (( 3 /* Nintendo */ << 16) | 4 /* */ | 1 /* */);
titleID_lo = ((u32)( *title++ ) & 0xff) << 24;
titleID_lo |= ((u32)( *title++ )& 0xff) << 16;
titleID_lo |= ((u32)( *title++ )& 0xff) << 8;
titleID_lo |= (u32)( *title++ ) & 0xff;
titleID = ((u64)(titleID_hi) << 32) | (u64)titleID_lo;
// OS_TPrintf( "titleID = 0x%08x%08x\n", titleID_hi, titleID_lo);
isNwmActive = 0;
if( NAM_OK == NAM_GetTitleBootContentPathFast(path, titleID) ) {
OS_TPrintf( "File = %s\n", path);
}
else {
OS_TPrintf( "Error: NAM_GetTitleBootContentPathFast titleID = 0x%08x0x%08x\n",titleID_hi, titleID_lo);
return FALSE;
}
if (!FS_OpenFileEx(file, path, FS_FILEMODE_R)) {
OS_TWarning("FS_OpenFileEx(%s) failed.\n", path);
return FALSE;
}
if( FALSE == FS_SeekFile(file, sizeof(ROM_Header), FS_SEEK_SET) ) {
OS_TWarning("FS_SeekFile failed.\n");
return FALSE;
}
flen = FS_ReadFile(file, fwBuffer, sizeof(fwBuffer));
if( flen == -1 ) {
OS_TWarning("FS_ReadFile failed.\n");
return FALSE;
}
(void)FS_CloseFile(file);
/*************************************************************/
NWM_Init(nwmBuf, sizeof(nwmBuf), 3); /* 3 -> DMA no. */
(void)NWMi_InstallFirmware(fwBuffer, (u32)flen);
err = NWM_LoadDevice(nwmcallback);
/* osRecvMessage */
return TRUE;
}

View File

@ -0,0 +1,2 @@
BOOL WirelessFirmwareDownloadStart(void);

View File

@ -24,6 +24,11 @@
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
#define WIRELESS_FIRM_LOADING 1
#if( WIRELESS_FIRM_LOADING == 1 )
#include "loadWlanFirm.h"
#endif
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
@ -117,6 +122,8 @@ void TwlMain( void )
// システムの初期化----------------
InitAllocator(); // ※SYSM_Init以外のSYSMライブラリ関数を呼ぶ前に
// Alloc, Freeで登録したメモリアロケータを初期化してください。
// 各種パラメータの取得------------
pBootTitle = SYSM_ReadParameters(); // 本体設定データ、リセットパラメータ、
// 初回起動シーケンス判定、
@ -177,6 +184,15 @@ void TwlMain( void )
THREAD_STACK_SIZE, STREAM_THREAD_PRIO);
OS_WakeupThreadDirect(&strmThread);
// 無線ファームウェアを無線モジュールにダウンロードする。
#if( WIRELESS_FIRM_LOADING == 1 )
if( FALSE == WirelessFirmwareDownloadStart() ) {
OS_TPrintf( "ERROR: Wireless firmware download failed!\n" );
}
#endif
// メインループ--------------------
while( 1 ) {
OS_WaitIrq(1, OS_IE_V_BLANK); // Vブランク割り込み待ち