git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@36 7061adef-622a-194b-ae81-725974e89856

This commit is contained in:
miya 2008-10-30 10:20:58 +00:00
parent 74ed622476
commit 1365476d69
20 changed files with 959 additions and 343 deletions

View File

@ -0,0 +1,144 @@
#include <twl.h>
#include "miya_mcu.h"
static OSMessage MyMesgBuffer[1];
static OSMessageQueue MyMesgQueue;
static volatile u8 miya_mcu_free_register = 0x44;
static volatile u32 my_mcu_command = 0;
static volatile u8 my_mcu_volume = 0;
static volatile u8 my_mcu_brightness = 0;
static void miya_mcu_free_reg_pxi_callback(PXIFifoTag tag, u32 data, BOOL err)
{
#pragma unused(tag)
#pragma unused(err)
switch( my_mcu_command ) {
case MIYA_MCU_COMMAND_GET_FREE_REG:
miya_mcu_free_register = (u8)(0xff & data);
break;
case MIYA_MCU_COMMAND_GET_VOLUME:
my_mcu_volume = (u8)(0xff & data);
break;
case MIYA_MCU_COMMAND_GET_BRIGHTNESS:
my_mcu_brightness = (u8)(0xff & data);
break;
case MIYA_MCU_COMMAND_SET_VOLUME:
break;
case MIYA_MCU_COMMAND_SET_BRIGHTNESS:
break;
default:
miya_mcu_free_register = (u8)(0xff & data);
break;
}
(void)OS_SendMessage(&MyMesgQueue, (OSMessage)0, OS_MESSAGE_NOBLOCK);
}
void MIYA_MCU_Init(void)
{
OS_InitMessageQueue(&MyMesgQueue, &MyMesgBuffer[0], 1);
PXI_SetFifoRecvCallback(PXI_FIFO_TAG_USER_0, miya_mcu_free_reg_pxi_callback);
}
static void miya_mcu_send_pxi_data(u32 data)
{
my_mcu_command = 0x0f & data;
while (PXI_SendWordByFifo(PXI_FIFO_TAG_USER_0, data, FALSE) != PXI_FIFO_SUCCESS)
{
// do nothing
}
}
static void miya_mcu_get_free_reg(void)
{
miya_mcu_send_pxi_data(MIYA_MCU_COMMAND_GET_FREE_REG);
}
static void miya_mcu_get_volume(void)
{
miya_mcu_send_pxi_data(MIYA_MCU_COMMAND_GET_VOLUME);
}
static void miya_mcu_set_volume(u8 vol)
{
u32 data;
data = MIYA_MCU_COMMAND_SET_VOLUME;
data |= ((u32)vol << 4);
miya_mcu_send_pxi_data(data);
}
static void miya_mcu_get_brightness(void)
{
miya_mcu_send_pxi_data(MIYA_MCU_COMMAND_GET_BRIGHTNESS);
}
static void miya_mcu_set_brightness(u8 brightness)
{
u32 data;
data = MIYA_MCU_COMMAND_SET_BRIGHTNESS;
data |= ((u32)brightness << 4);
miya_mcu_send_pxi_data(data);
}
u8 MCU_GetFreeReg( void )
{
OSMessage message;
miya_mcu_get_free_reg();
if( TRUE == OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK) ) {
}
return miya_mcu_free_register;
}
u8 MCU_GetVolume( void )
{
OSMessage message;
miya_mcu_get_volume();
if( TRUE == OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK) ) {
}
return my_mcu_volume;
}
u8 MCU_GetBackLightBrightness( void )
{
OSMessage message;
miya_mcu_get_brightness();
if( TRUE == OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK) ) {
}
return my_mcu_brightness;
}
BOOL MCU_SetBackLightBrightness( u8 brightness )
{
OSMessage message;
miya_mcu_set_brightness(brightness);
if( TRUE == OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK) ) {
}
return TRUE;
}
BOOL MCU_SetVolume( u8 vol )
{
OSMessage message;
miya_mcu_set_volume( vol );
if( TRUE == OS_ReceiveMessage(&MyMesgQueue, &message, OS_MESSAGE_BLOCK) ) {
}
return TRUE;
}

View File

@ -0,0 +1,29 @@
#ifndef _MIYA_MCU_H_
#define _MIYA_MCU_H_
#define MIYA_MCU_COMMAND_GET_FREE_REG 1
#define MIYA_MCU_COMMAND_GET_VOLUME 2
#define MIYA_MCU_COMMAND_GET_BRIGHTNESS 3
#define MIYA_MCU_COMMAND_SET_VOLUME 4
#define MIYA_MCU_COMMAND_SET_BRIGHTNESS 5
#ifdef __cplusplus
extern "C" {
#endif
void MIYA_MCU_Init(void);
u8 MCU_GetFreeReg( void );
BOOL MCU_SetBackLightBrightness( u8 brightness );
BOOL MCU_SetVolume( u8 vol );
u8 MCU_GetBackLightBrightness( void );
u8 MCU_GetVolume( void );
#ifdef __cplusplus
}
#endif
#endif /* _MIYA_MCU_H_ */

View File

@ -289,7 +289,7 @@ static BOOL SaveFile(const char* path, void* pData, u32 size, FSFile *log_fd)
return TRUE;
}
static BOOL CopyFile(const char *dst_path, const char *src_path, FSFile *log_fd )
BOOL CopyFile(const char *dst_path, const char *src_path, FSFile *log_fd )
{
char *alloc_ptr = NULL;
int alloc_size = 0;
@ -1566,6 +1566,7 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
#endif
FS_InitFile(&f);
#if 0
STD_StrCpy(path, "nand:/sys/dev.kp");
bSuccess = FS_OpenFileEx(&f, path, (FS_FILEMODE_R));
if( ! bSuccess ) {
@ -1576,7 +1577,7 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
return FALSE;
}
(void)FS_CloseFile(&f);
#endif
#if 0
// CopyFile( dst <= src );
@ -2217,6 +2218,7 @@ int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_sr
return ret_value;
}
void write_debug_data(void)
{
// CopyFile( dst <= src );

View File

@ -49,6 +49,8 @@ void GetDirEntryList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size);
BOOL TitleIDSave(const char *path, u64 *pData, int count, FSFile *log_fd);
BOOL TitleIDLoad(const char *path, u64 **pBuffer, int *count, FSFile *log_fd);
BOOL CopyFile(const char *dst_path, const char *src_path, FSFile *log_fd );
#ifdef __cplusplus
}
#endif

View File

@ -3,11 +3,13 @@
#define MY_DATA_VERSION_MAJOR 0
#define MY_DATA_VERSION_MINOR 1
#define MY_DATA_VERSION_MINOR 2
typedef struct {
u8 version_major;
u8 version_minor;
BOOL rtc_date_flag;
BOOL rtc_time_flag;
RTCDate rtc_date;
RTCTime rtc_time;
BOOL shop_record_flag;
@ -15,11 +17,14 @@ typedef struct {
int num_of_app_save_data;
int num_of_photo_files;
int num_of_shared2_files;
BOOL uniqueid_flag;
u8 movableUniqueID[ LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN ]; // 移行可能なユニークID 16byte
u32 deviceId;
u8 region;
u64 fuseId;
char bmsDeviceId[32];
s32 volume;
s32 backlight_brightness;
u32 reserve[256];
} MyData;

View File

@ -15,6 +15,28 @@ void MyFile_AddPathBase(const char *str)
STD_StrCat( path_base , str );
}
char *MyFile_GetProductLogFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_PRODUCT_LOG );
return path;
}
char *MyFile_GetSystemMenuLogFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_SHOP_LOG );
return path;
}
char *MyFile_GetShopLogFileName(void)
{
STD_StrCpy( path , path_base );
STD_StrCat( path , MY_FILE_NAME_SYSMENU_LOG );
return path;
}
char *MyFile_GetUniqueIDFileName(void)
{
STD_StrCpy( path , path_base );

View File

@ -32,6 +32,11 @@
#define MY_FILE_NAME_ORG_RESTORE_LOG ("personal_rst.txt")
#define MY_FILE_NAME_PRODUCT_LOG "product.log"
#define MY_FILE_NAME_SHOP_LOG "sysmenu.log"
#define MY_FILE_NAME_SYSMENU_LOG "shop.log"
#ifdef __cplusplus
extern "C" {
#endif
@ -39,6 +44,11 @@ extern "C" {
void MyFile_SetPathBase(const char *str);
void MyFile_AddPathBase(const char *str);
char *MyFile_GetProductLogFileName(void);
char *MyFile_GetSystemMenuLogFileName(void);
char *MyFile_GetShopLogFileName(void);
char *MyFile_GetUniqueIDFileName(void);
char *MyFile_GetWifiParamFileName(void);
char *MyFile_GetUserSettingsFileName(void);

View File

@ -7,14 +7,74 @@
#include "mywlan.h"
/*
IP addr = 192.168. 11. 6
NetMask = 255.255.255. 0
GW addr = 192.168. 11. 1
DNS[0] = 192.168. 11. 1
DNS[1] = 0. 0. 0. 0
*/
static char SSID_STR[256];
static int SSID_LEN = 0;
static int key_mode = 0; /* 0->str 1->bin */
static char KEY_STR[256];
static u8 KEY_BIN[256];
static u8 KEY_BIN[MAX_KEY_BIN_BUF];
static int KEY_STR_LEN = 0;
static int KEY_BIN_LEN = 0;
static int MODE = 0;
static int DHCP_MODE = 0;
static u32 IPADDR = 0;
static u32 NETMASK = 0;
static u32 GATEWAY = 0;
static u32 DNS1 = 0;
static u32 DNS2 = 0;
BOOL GetKeyModeStr(void)
{
if( key_mode ) {
return FALSE;
}
return TRUE;
}
u32 GetGateway(void)
{
return GATEWAY;
}
u32 GetNetmask(void)
{
return NETMASK;
}
u32 GetIPAddr(void)
{
return IPADDR;
}
BOOL GetDhcpMODE(void)
{
if( DHCP_MODE ) {
return TRUE;
}
return FALSE;
}
u32 GetDNS1(void)
{
return DNS1;
}
u32 GetDNS2(void)
{
return DNS2;
}
char *GetWlanSSID(void)
{
return SSID_STR;
@ -22,7 +82,10 @@ char *GetWlanSSID(void)
char *GetWlanKEYSTR(void)
{
return KEY_STR;
if( KEY_STR_LEN ) {
return KEY_STR;
}
return NULL;
}
int GetWlanKEYBIN(u8 *buf)
@ -82,6 +145,95 @@ static int ReadLine(FSFile *f, char *buf, int buf_size)
}
static BOOL Addr_scan(char *buf, int size, int cnt, u32 *ret_addr)
{
char c;
int keta;
int area;
u32 num[3];
u32 addr;
int readSize;
int count;
int count2;
char *line_buf;
line_buf = buf;
readSize = size;
count = cnt;
if( line_buf[count] == '\"' /* PŒÂÚ */) {
count++;
count2 = count;
addr = 0;
keta = 0;
area = 0;
num[0] = 0;
num[1] = 0;
num[2] = 0;
while( readSize > count ) {
c = line_buf[count];
if( c == '\"' /* QŒÂÚ */) {
if( area == 3 ) {
if( keta == 1 ) {
addr |= ( ( num[0] ) << (8*(3 - area)) );
}
else if( keta == 2 ) {
addr |= ( (num[0] * 10 + num[1]) << (8*(3 - area)) );
}
else if( keta == 3 ) {
addr |= ( (num[0] * 100 + num[1] * 10 + num[2]) << (8*( 3 - area)) );
}
else {
OS_TPrintf("Error: %s %d\n",__FUNCTION__,__LINE__);
}
*ret_addr = addr;
return TRUE;
}
else {
OS_TPrintf("Error: %s %d\n",__FUNCTION__,__LINE__);
return FALSE;
}
}
if( ('0' <= c) && (c <= '9') ) {
if( keta > 3 ) {
/* error */
OS_TPrintf("Error: %s %d\n",__FUNCTION__,__LINE__);
return FALSE;
}
num[keta] = (u32)( c - '0' );
keta++;
}
else if( c == '.' ){
if( keta == 1 ) {
addr |= ( ( num[0] ) << (8*(3 - area)) );
}
else if( keta == 2 ) {
addr |= ( (num[0] * 10 + num[1]) << (8*(3 - area)) );
}
else if( keta == 3 ) {
addr |= ( (num[0] * 100 + num[1] * 10 + num[2]) << (8*( 3 - area)) );
}
else {
return FALSE;
OS_TPrintf("Error: %s %d\n",__FUNCTION__,__LINE__);
}
keta = 0;
area++;
}
else {
OS_TPrintf("Error: %s %d\n",__FUNCTION__,__LINE__);
return FALSE;
}
count++;
}
}
return FALSE;
}
BOOL LoadWlanConfigFile(char *path)
{
FSFile f;
@ -90,16 +242,22 @@ BOOL LoadWlanConfigFile(char *path)
BOOL bSuccess;
int count = 0;
int count2;
int count3;
BOOL ssid_flag;
BOOL key_str_flag;
BOOL key_bin_flag;
BOOL key_flag;
BOOL mode_flag;
BOOL dhcp_flag;
BOOL ip_addr_flag;
BOOL net_mask_flag;
BOOL gw_flag;
BOOL dns1_flag;
BOOL dns2_flag;
BOOL ret_flag = FALSE;
int lo_hi;
u8 hex;
char c;
#define LINE_BUF_SIZE 256
char line_buf[LINE_BUF_SIZE];
@ -112,9 +270,14 @@ BOOL LoadWlanConfigFile(char *path)
ssid_flag = FALSE;
key_str_flag = FALSE;
key_bin_flag = FALSE;
key_flag = FALSE;
mode_flag = FALSE;
dhcp_flag = FALSE;
ip_addr_flag = FALSE;
net_mask_flag = FALSE;
gw_flag = FALSE;
dns1_flag = FALSE;
dns2_flag = FALSE;
while( 1 ) {
@ -124,9 +287,70 @@ BOOL LoadWlanConfigFile(char *path)
break;
}
if( readSize > 5 ) {
if( !ssid_flag && !STD_StrNCmp( line_buf, "SSID:" , STD_StrLen("SSID:")) ) {
if( !dhcp_flag && !STD_StrNCmp( line_buf, "DHCP:" , STD_StrLen("DHCP:")) ) {
count = STD_StrLen("DHCP:");
if( line_buf[count] == '\"' /* PŒÂÚ */) {
count++;
count2 = count;
if( !STD_StrNCmp( &(line_buf[count2]), "OFF" , STD_StrLen("OFF")) ) {
if( line_buf[ count2 + STD_StrLen("OFF") ] == '\"' /* QŒÂÚ */) {
dhcp_flag = TRUE;
DHCP_MODE = 0;
OS_TPrintf("DHCP OFF %s %d\n",__FUNCTION__,__LINE__);
}
}
else if( !STD_StrNCmp( &(line_buf[count2]), "ON" , STD_StrLen("ON")) ) {
if( line_buf[ count2 + STD_StrLen("ON") ] == '\"' /* QŒÂÚ */) {
dhcp_flag = TRUE;
DHCP_MODE = 1;
OS_TPrintf("DHCP ON %s %d\n",__FUNCTION__,__LINE__);
}
}
}
}
else if( !ip_addr_flag && !STD_StrNCmp( line_buf, "IPADDR:" , STD_StrLen("IPADDR:")) ) {
count = STD_StrLen("IPADDR:");
if( TRUE == Addr_scan(line_buf, readSize, count, &IPADDR) ) {
OS_TPrintf("IPADDR %d.%d.%d.%d\n", (u32)((IPADDR >> 24) & 0xff),(u32)((IPADDR >> 16) & 0xff),
(u32)((IPADDR >> 8) & 0xff),(u32)(IPADDR & 0xff) );
ip_addr_flag = TRUE;
}
}
else if( !net_mask_flag && !STD_StrNCmp( line_buf, "NETMASK:" , STD_StrLen("NETMASK:")) ) {
count = STD_StrLen("NETMASK:");
if( TRUE == Addr_scan(line_buf, readSize, count, &NETMASK) ) {
OS_TPrintf("NETMASK %d.%d.%d.%d\n", (u32)((NETMASK >> 24) & 0xff),(u32)((NETMASK >> 16) & 0xff),
(u32)((NETMASK >> 8) & 0xff),(u32)(NETMASK & 0xff) );
net_mask_flag = TRUE;
}
}
else if( !gw_flag && !STD_StrNCmp( line_buf, "GATEWAY:" , STD_StrLen("GATEWAY:")) ) {
count = STD_StrLen("GATEWAY:");
if( TRUE == Addr_scan(line_buf, readSize, count, &GATEWAY) ) {
OS_TPrintf("GATEWAY %d.%d.%d.%d\n", (u32)((GATEWAY >> 24) & 0xff),(u32)((GATEWAY >> 16) & 0xff),
(u32)((GATEWAY >> 8) & 0xff),(u32)(GATEWAY & 0xff) );
gw_flag = TRUE;
}
}
else if( !dns1_flag && !STD_StrNCmp( line_buf, "DNS1:" , STD_StrLen("DNS1:")) ) {
count = STD_StrLen("DNS1:");
if( TRUE == Addr_scan(line_buf, readSize, count, &DNS1) ) {
OS_TPrintf("DNS1 %d.%d.%d.%d\n", (u32)((DNS1 >> 24) & 0xff),(u32)((DNS1 >> 16) & 0xff),
(u32)((DNS1 >> 8) & 0xff),(u32)(DNS1 & 0xff) );
dns1_flag = TRUE;
}
}
else if( !dns2_flag && !STD_StrNCmp( line_buf, "DNS2:" , STD_StrLen("DNS2:")) ) {
count = STD_StrLen("DNS2:");
if( TRUE == Addr_scan(line_buf, readSize, count, &DNS2) ) {
OS_TPrintf("DNS2 %d.%d.%d.%d\n", (u32)((DNS2 >> 24) & 0xff),(u32)((DNS2 >> 16) & 0xff),
(u32)((DNS2 >> 8) & 0xff),(u32)(DNS2 & 0xff) );
dns2_flag = TRUE;
}
}
else if( !ssid_flag && !STD_StrNCmp( line_buf, "SSID:" , STD_StrLen("SSID:")) ) {
count = STD_StrLen("SSID:");
if( line_buf[count] == '\"' /* 1個目 */) {
count++;
@ -151,30 +375,34 @@ BOOL LoadWlanConfigFile(char *path)
if( !STD_StrNCmp( &(line_buf[count2]), "NONE" , STD_StrLen("NONE")) ) {
// ;MODE:"NONE"
if( line_buf[ count2 + STD_StrLen("NONE") ] == '\"' /* 2個目 */) {
/* 0 */
MODE = WCM_WEPMODE_NONE;
mode_flag = TRUE;
}
}
else if( !STD_StrNCmp( &(line_buf[count2]), "WEP40" , STD_StrLen("WEP40")) ) {
/* 1 */
if( line_buf[ count2 + STD_StrLen("WEP40") ] == '\"' /* 2個目 */) {
MODE = WCM_WEPMODE_40;
mode_flag = TRUE;
}
}
else if( !STD_StrNCmp( &(line_buf[count2]), "WEP104" , STD_StrLen("WEP104")) ) {
/* 2 */
if( line_buf[ count2 + STD_StrLen("WEP104") ] == '\"' /* 2個目 */) {
MODE = WCM_WEPMODE_104;
mode_flag = TRUE;
}
}
else if( !STD_StrNCmp( &(line_buf[count2]), "WEP128" , STD_StrLen("WEP128")) ) {
/* 3 */
if( line_buf[ count2 + STD_StrLen("WEP128") ] == '\"' /* 2個目 */) {
MODE = WCM_WEPMODE_128;
mode_flag = TRUE;
}
}
else if( !STD_StrNCmp( &(line_buf[count2]), "WPA-TKIP", STD_StrLen("WPA-TKIP")) ) {
/* 4 */
if( line_buf[ count2 + STD_StrLen("WPA-TKIP") ] == '\"' /* 2個目 */) {
MODE = WCM_WEPMODE_WPA_TKIP;
mode_flag = TRUE;
@ -199,9 +427,8 @@ BOOL LoadWlanConfigFile(char *path)
}
}
}
}
else if( !key_str_flag && !STD_StrNCmp( line_buf, "KEY-STR:" , STD_StrLen("KEY-STR:")) ) {
} /* MODE */
else if( !key_flag && !STD_StrNCmp( line_buf, "KEY-STR:" , STD_StrLen("KEY-STR:")) ) {
count = STD_StrLen("KEY-STR:");
if( line_buf[count] == '\"' /* 1個目 */) {
count++;
@ -213,7 +440,8 @@ BOOL LoadWlanConfigFile(char *path)
/* このときwep128ならcountは文字なので */
// 0123456789012345678901
// KEY-STR:"0123456789red"
key_str_flag = TRUE;
key_mode = 0; /* 0->str 1->bin */
key_flag = TRUE;
break;
}
KEY_STR[count - count2] = line_buf[count];
@ -221,70 +449,53 @@ BOOL LoadWlanConfigFile(char *path)
}
}
}
else if( !key_bin_flag && !STD_StrNCmp( line_buf, "KEY-BIN:" , STD_StrLen("KEY-BIN:")) ) {
else if( !key_flag && !STD_StrNCmp( line_buf, "KEY-BIN:" , STD_StrLen("KEY-BIN:")) ) {
count = STD_StrLen("KEY-BIN:");
lo_hi = 0;
hex = 0;
if( line_buf[count] == '\"' /* 1個目 */) {
count++;
count2 = count;
count3 = 0;
count2 = 0;
while( readSize > count ) {
if( line_buf[count] == '\"' /* 2個目 */) {
if( lo_hi == 0 ) {
KEY_BIN_LEN = count3;
key_bin_flag = TRUE;
}
KEY_BIN_LEN = (count2+1)/2;
key_mode = 1; /* 0->str 1->bin */
key_flag = TRUE;
break;
}
c = line_buf[count];
OS_PutChar( c );
if( ('a' <= c) && (c <= 'f') ) {
if( lo_hi == 0 ) {
hex = (u8)(( c - 'a' + 10 ) * 16);
}
else {
hex += (u8)( c - 'a' + 10 );
}
hex = (u8)( c - 'a' + 10 );
}
else if( ('A' <= c) && (c <= 'F') ) {
if( lo_hi == 0 ) {
hex = (u8)(( c - 'A' + 10 ) * 16);
}
else {
hex += (u8)( c - 'a' + 10 );
}
hex = (u8)( c - 'a' + 10 );
}
else if( ('0' <= c) && (c <= '9') ) {
if( lo_hi == 0 ) {
hex = (u8)( (c - '0' ) * 16 );
}
else {
hex += (u8)(c - '0');
}
hex = (u8)(c - '0');
}
else {
OS_TPrintf("Error keybin: %s %d\n",__FUNCTION__,__LINE__);
/* error! */
break;
}
if( lo_hi == 1 ) {
KEY_BIN[count3] = hex;
count3++;
if( (count2 & 1) == 0 ) {
KEY_BIN[count2/2] = (u8)(hex << 4);
}
else {
KEY_BIN[count2/2] |= hex;
}
count2++;
if( count2 >= (MAX_KEY_BIN_BUF*2) ) {
OS_TPrintf("Error keybin: buffer overflow %s %d\n",__FUNCTION__,__LINE__);
break;
}
lo_hi ^= 1;
count++;
}
}
}
}
if( ssid_flag == TRUE && (key_str_flag == TRUE || key_bin_flag == TRUE) && mode_flag == TRUE ) {
ret_flag = TRUE;
break;
}
/*123456789012345678
SSID:"001D731A8202"
MODE:"WEP128"
;MODE:"NONE"
@ -298,6 +509,23 @@ BOOL LoadWlanConfigFile(char *path)
}
if( ssid_flag == TRUE && (key_flag == TRUE) && mode_flag == TRUE && (dhcp_flag == TRUE) ) {
if( DHCP_MODE == 0 ) {
if( (ip_addr_flag == TRUE) && (net_mask_flag == TRUE) && (gw_flag == TRUE) && (dns1_flag == TRUE) ) {
// dns2_flag = FALSE;
ret_flag = TRUE;
}
else {
ret_flag = FALSE;
}
}
else {
ret_flag = TRUE;
}
}
if( FS_CloseFile(&f) == FALSE) {
res = FS_GetArchiveResultCode(path);

View File

@ -6,6 +6,8 @@
extern "C" {
#endif
#define MAX_KEY_BIN_BUF 80
BOOL LoadWlanConfigFile(char *path);
@ -14,6 +16,15 @@ int GetWlanKEYBIN(u8 *buf);
char *GetWlanKEYSTR(void);
int GetWlanMode(void);
u32 GetGateway(void);
u32 GetNetmask(void);
u32 GetIPAddr(void);
BOOL GetDhcpMODE(void);
u32 GetDNS1(void);
u32 GetDNS2(void);
BOOL GetKeyModeStr(void);
#ifdef __cplusplus
}
#endif

View File

@ -64,7 +64,35 @@ void NcGlobalInit()
(void)OS_EnableInterrupts();
}
#ifndef SDK_WIFI_INET
#if 0
typedef struct
{
BOOL use_dhcp; // if TRUE, use dhcp
struct
{
SOCLInAddr my_ip;
SOCLInAddr net_mask;
SOCLInAddr gateway_ip;
SOCLInAddr dns_ip[2];
} host_ip;
void* (*alloc) (u32);
void (*free) (void*);
u32 cmd_packet_max; // コマンドパケットの最大数
u32 lan_buffer_size; // 0 なら *alloc で自力確保
void* lan_buffer; // 0 なら default(16384)設定
// CPS スレッドの優先度
// 0 なら SOCL_CPS_SOCKET_THREAD_PRIORITY
s32 cps_thread_prio;
// 通信バッファサイズ
s32 mtu; //default 1500
s32 rwin;
} SOCLConfig;
#endif
static void ncStartWiFi(void)
{
int result;
@ -81,6 +109,8 @@ static void ncStartWiFi(void)
if (OS_IsRunOnTwl())
{
static SOCLConfig socl_config;
MI_CpuClear8(&socl_config, sizeof(socl_config));
socl_config.alloc = myAlloc_SOCL;
@ -90,6 +120,17 @@ static void ncStartWiFi(void)
socl_config.lan_buffer_size = SOCL_LAN_BUFFER_SIZE_DEFAULT * 8;
socl_config.mtu = 1400;
socl_config.rwin = 65535;
socl_config.use_dhcp = GetDhcpMODE();
socl_config.host_ip.gateway_ip = GetGateway();
socl_config.host_ip.net_mask = GetNetmask();
socl_config.host_ip.my_ip = GetIPAddr();
socl_config.host_ip.dns_ip[0] = GetDNS1();
socl_config.host_ip.dns_ip[1] = GetDNS2();
OS_TPrintf("SOCL_Startup....\n");
result = SOCL_Startup(&socl_config);
@ -109,7 +150,9 @@ static void ncStartWiFi(void)
}
if (result < 0)
{
OS_Panic("SOC_Startup failed (%d)", result);
OS_TPrintf("SOC_Startup failed (%d)", result);
mprintf("SOC_Startup failed (%d)", result);
return;
}
g_started = TRUE;
OS_TPrintf("DHCP....\n");
@ -136,116 +179,7 @@ static void ncFinishWiFi(void)
}
}
#else // SDK_WIFI_INET
static void ncStartInet(void)
{
int result;
SOConfig soConfig =
{
SO_VENDOR_NINTENDO, // vendor
SO_VERSION, // version
NcAlloc, // alloc
NcFree, // free
SO_FLAG_DHCP, // flag
SO_HtoNl(SO_INADDR_ANY),// addr
SO_HtoNl(SO_INADDR_ANY),// netmask
SO_HtoNl(SO_INADDR_ANY),// router
SO_HtoNl(SO_INADDR_ANY),// dns1
SO_HtoNl(SO_INADDR_ANY),// dns1
4096, // timeWaitBuffer
4096, // reassemblyBuffer
0, // maximum transmission unit size
// TCP
16384, // default TCP receive window size (default 2 x MSS)
0, // default TCP total retransmit timeout value (default 100 sec)
// PPP PPP関連機能は未実装
NULL,
NULL,
// PPPoE PPP関連機能は未実装
NULL,
// DHCP
"NINTENDO-DS", // DHCP host name
4, // TCP total retransmit times (default 4)
// UDP
0, // default UDP send buffer size (default 1472)
0 // defualt UDP receive buffer size (default 4416)
};
#ifdef SDK_TWL
if (OS_IsRunOnTwl())
{
soConfig.rwin = 65535;
}
#endif // SDK_TWL
OS_TPrintf("SO_Startup....\n");
result = SO_Startup(&soConfig);
if (result < 0)
{
OS_Panic("SO_Startup failed (%d)", result);
}
g_started = TRUE;
OS_TPrintf("DHCP....\n");
while (SO_GetHostID() == 0 && IP_GetConfigError(NULL) == 0)
{
OS_Sleep(100);
}
if (SO_GetHostID() != 0)
{
int retry = 0;
u8 ip[ IP_ALEN ];
IP_GetAddr( NULL, ip );
OS_Printf("IP addr = %3d.%3d.%3d.%3d\n", ip[0], ip[1], ip[2], ip[3] );
IP_GetNetmask ( NULL, ip );
OS_Printf("NetMask = %3d.%3d.%3d.%3d\n", ip[0], ip[1], ip[2], ip[3] );
IP_GetGateway ( NULL, ip );
OS_Printf("GW addr = %3d.%3d.%3d.%3d\n", ip[0], ip[1], ip[2], ip[3] );
}
else
{
OS_TPrintf("NO DHCP SERVER or NO LINK....\n");
switch (IP_GetConfigError(NULL))
{
case IP_ERR_DHCP_TIMEOUT:
OS_Panic("IP_ERR_DHCP_TIMEOUT\n");
break;
case IP_ERR_LINK_DOWN:
OS_Panic("IP_ERR_LINK_DOWN\n");
break;
default:
OS_Panic("Default???\n");
break;
}
}
}
static void ncFinishInet(void)
{
previousAddr = SO_GetHostID();
if (g_started)
{
(void)SO_Cleanup();
g_started = FALSE;
}
}
#endif // SDK_WIFI_INET
/*---------------------------------------------------------------------------*
Name : NcStart
@ -257,25 +191,38 @@ void NcStart(const char* apClass)
{
int counter = 0;
s32 wcm_phase;
int len;
u8 key_bin_buf[MAX_KEY_BIN_BUF];
SiteDefs_Init();
if( FALSE == ENV_SetBinary("WiFi.LAN.1.AP.1.WEP.KEY", (void *)GetWlanKEYSTR()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
if( TRUE == GetKeyModeStr() ) {
if( FALSE == ENV_SetBinary("WiFi.LAN.1.AP.1.WEP.KEY", (void *)GetWlanKEYSTR()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
}
else {
STD_MemSet((void *)key_bin_buf, 0, MAX_KEY_BIN_BUF );
len = GetWlanKEYBIN(key_bin_buf);
if( len ) {
if( FALSE == ENV_SetBinary2("WiFi.LAN.1.AP.1.WEP.KEY", (void *)key_bin_buf, (u32)len) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
}
}
if( FALSE == ENV_SetString("WiFi.LAN.1.AP.1.ESSID", GetWlanSSID()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
if( FALSE == ENV_SetU8("WiFi.LAN.1.AP.1.WEP.MODE", (u8)GetWlanMode() ) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
if (!InitWcmApInfo(&apInfo, apClass))
if( FALSE == ENV_SetString("WiFi.LAN.1.AP.1.ESSID", GetWlanSSID()) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
if( FALSE == ENV_SetU8("WiFi.LAN.1.AP.1.WEP.MODE", (u8)GetWlanMode() ) ) {
OS_TPrintf("Error %s %d\n", __FUNCTION__,__LINE__);
}
if (!InitWcmApInfo(&apInfo, apClass))
{
OS_Panic("Invalid AP Class....");
mprintf("Invalid AP Class....");
OS_TPrintf("Invalid AP Class....");
}
while (1) {
@ -352,21 +299,14 @@ void NcStart(const char* apClass)
OS_TPrintf("connected\n");
mprintf(" connected\n");
#ifndef SDK_WIFI_INET
ncStartWiFi();
#else // SDK_WIFI_INET
ncStartInet();
#endif // SDK_WIFI_INET
}
void NcFinish()
{
#ifndef SDK_WIFI_INET
ncFinishWiFi();
#else // SDK_WIFI_INET
ncFinishInet();
#endif // SDK_WIFI_INET
}
void NcSetDevice(u8 deviceId)

View File

@ -24,6 +24,40 @@
c:/twlsdk/include/nitro/env/env_system.h
*/
BOOL ENV_SetBinary2(const char *name, void *ptr, u32 length)
{
ENVResource *resSetPtr;
ENVResource *p = ENVi_Search(name, &resSetPtr);
u16 len = 1;
if (!p) {
return FALSE;
}
if (p->type != ENV_RESTYPE_BINARY) {
return FALSE;
}
len = (u16)(p->len - ((p->type == ENV_RESTYPE_STRING) ? 1 : 0));
OS_TPrintf("env bin len = %d\n", len);
if (p->type & ENV_RESTYPE_OFFSET_MASK)
{
// return (void *)((u32)resSetPtr + (u32)(p->ptr));
// (char *)((u32)resSetPtr + (u32)(p->ptr)) = val;
STD_CopyMemory( (void *)((u32)resSetPtr + (u32)(p->ptr)) , ptr, length );
}
else
{
// return p->ptr;
// (char *)p->ptr = val;
// STD_CopyMemory( (void *)(p->ptr) , ptr , (u32)len );
STD_CopyMemory( (void *)(p->ptr) , ptr , length );
}
return TRUE;
}
BOOL ENV_SetBinary(const char *name, void *ptr)
{
ENVResource *resSetPtr;
@ -58,6 +92,7 @@ BOOL ENV_SetBinary(const char *name, void *ptr)
return TRUE;
}
BOOL ENV_SetString(const char *name, char *str)
{
ENVResource *resSetPtr;

View File

@ -26,6 +26,7 @@ extern "C" {
#define SITEDEFS_DEFAULTCLASS_FOR_TEST "WiFi.LAN.1.AP.1"
void SiteDefs_Init(void);
BOOL ENV_SetBinary(const char *name, void *ptr);
BOOL ENV_SetBinary2(const char *name, void *ptr, u32 length);
BOOL ENV_SetString(const char *name, char *str);
BOOL ENV_SetU8(const char *name, u8 val);

View File

@ -1,5 +1,9 @@
#include <twl.h>
#include "stream.h"
#include "font.h"
#include "text.h"
#include "mprintf.h"
#define MIYA_MEM_FILE 1
@ -334,7 +338,9 @@ static void PlayStream(StreamInfo * strm, const char *filename)
}
if ( ! MY_FS_OpenFile(&strm->file, filename) ) {
OS_Panic("Error: failed to open file %s\n", filename);
OS_TPrintf("Error: failed to open file %s\n", filename);
mprintf("Error: failed to open file %s\n", filename);
return;
}
#else
// ƒtƒ@ƒCƒ<E28098>¸
@ -342,12 +348,16 @@ static void PlayStream(StreamInfo * strm, const char *filename)
(void)FS_CloseFile(&strm->file);
}
if ( ! FS_OpenFile(&strm->file, filename) ) {
OS_Panic("Error: failed to open file %s\n", filename);
OS_TPrintf("Error: failed to open file %s\n", filename);
mprintf("Error: failed to open file %s\n", filename);
return;
}
#endif
if (!ReadWaveFormat(strm))
{
OS_Panic("Error: failed to read wavefile\n");
OS_TPrintf("Error: failed to read wavefile\n");
mprintf("Error: failed to read wavefile\n");
return;
}
strm->isPlay = TRUE;
@ -495,8 +505,11 @@ static void ReadStrmData(StreamInfo * strm)
(strm->dataSize <
STRM_BUF_PAGESIZE) ? strm->dataSize : STRM_BUF_PAGESIZE);
#endif
if (readSize == -1)
OS_Panic("read file end\n");
if (readSize == -1) {
OS_TPrintf("read file end\n");
mprintf("read file end\n");
return;
}
if (strm->format.bitPerSample == 16)
{
@ -538,8 +551,11 @@ static void ReadStrmData(StreamInfo * strm)
(strm->dataSize <
STRM_BUF_PAGESIZE * 2) ? strm->dataSize : STRM_BUF_PAGESIZE * 2);
#endif
if (readSize == -1)
OS_Panic("read file end\n");
if (readSize == -1) {
OS_TPrintf("read file end\n");
mprintf("read file end\n");
return;
}
if (strm->format.bitPerSample == 16)
{

View File

@ -21,6 +21,11 @@
#include "ap_info.h"
#include "sitedefs.h"
#include "netconnect.h"
#include "mywlan.h"
#include "font.h"
#include "text.h"
#include "mprintf.h"
/*---------------------------------------------------------------------------*
@ -703,8 +708,9 @@ static s32 CallFunction(s16 notifyId)
* WCM 使 WVR 使 ARM7
*
*/
OS_Panic("ARM7 WM library is not ready.\n");
OS_TPrintf("ARM7 WM library is not ready.\n");
mprintf("ARM7 WM library is not ready.\n");
return WCM_RESULT_FATAL_ERROR;
case WCM_RESULT_NOT_ENOUGH_MEM: // 非同期関数にこの返り値が返されることは無い
case WCM_RESULT_FATAL_ERROR:
default:
@ -883,14 +889,16 @@ BOOL InitWcmApInfo(WcmControlApInfo* apinfo, const char* apclass)
if(apinfo->wepDesc.mode > WCM_WEPMODE_128 ) /* WPA */
{
u8 psk[WCM_WPA_PSK_SIZE];
if (WCM_GetWPAPSK(apinfo->wepDesc.key, apinfo->essId, (u8)STD_GetStringLength((const char*)apinfo->essId), psk) == FALSE)
{
OS_TWarning("PreSharedKey Calculation Error.\n");
return FALSE;
}
MI_CpuClear8(apinfo->wepDesc.key, sizeof(apinfo->wepDesc.key));
MI_CpuCopy8(psk, apinfo->wepDesc.key, WCM_WPA_PSK_SIZE);
if( TRUE == GetKeyModeStr() ) {
if (WCM_GetWPAPSK(apinfo->wepDesc.key, apinfo->essId,
(u8)STD_GetStringLength((const char*)apinfo->essId), psk) == FALSE)
{
OS_TWarning("PreSharedKey Calculation Error.\n");
return FALSE;
}
MI_CpuClear8(apinfo->wepDesc.key, sizeof(apinfo->wepDesc.key));
MI_CpuCopy8(psk, apinfo->wepDesc.key, WCM_WPA_PSK_SIZE);
}
apinfo->wepDesc.keyId = 32;
}
#endif

View File

@ -24,7 +24,7 @@ SRCDIR = ../common/src ./src
SRCS = main.c mfiler.c key.c font.c text.c mprintf.c logprintf.c \
gfx.c hwi.c mynvram.c my_fs_util.c \
hatamotolib.cpp \
hatamotolib.cpp miya_mcu.c \
sitedefs.c wcm_control.c netconnect.c mywlan.c \
mynuc.c nuc_error_msg.c stream.c myfilename.c menu_version.c

View File

@ -39,6 +39,7 @@
#include "wcm_control.h"
#include "nuc.h"
#include "mynuc.h"
#include "miya_mcu.h"
#include "myfilename.h"
#include "mfiler.h"
@ -47,8 +48,11 @@
//================================================================================
#define MIYA_MCU 1
// #define MIYA_MCU 1
static BOOL no_reboot_flag = FALSE;
static BOOL only_wifi_config_data_trans_flag = FALSE;
static BOOL user_and_wifi_config_data_trans_flag = FALSE;
static BOOL completed_flag = FALSE;
static FSEventHook sSDHook;
static BOOL sd_card_flag = FALSE;
@ -159,47 +163,57 @@ static BOOL RestoreFromSDCard1(void)
MyData mydata
*/
// static BOOL SDBackupToSDCard8(void)
mprintf("RTC data restore ");
if( RTC_RESULT_SUCCESS != RTC_SetDate( &(mydata.rtc_date) ) ) {
flag = FALSE;
}
if( RTC_RESULT_SUCCESS != RTC_SetTime( &(mydata.rtc_time) ) ) {
flag = FALSE;
}
if( flag == TRUE ) {
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
mprintf("OK.\n");
if( (mydata.rtc_date_flag == TRUE) && (mydata.rtc_time_flag == TRUE) ) {
mprintf("RTC data restore ");
if( RTC_RESULT_SUCCESS != RTC_SetDate( &(mydata.rtc_date) ) ) {
flag = FALSE;
}
if( RTC_RESULT_SUCCESS != RTC_SetTime( &(mydata.rtc_time) ) ) {
flag = FALSE;
}
if( flag == TRUE ) {
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
mprintf("OK.\n");
}
else {
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
mprintf("NG.\n");
}
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
}
else {
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
mprintf("NG.\n");
// mprintf("RTC data restore ");
mprintf("No original RTC data\n");
flag = TRUE;
}
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return flag;
}
static BOOL RestoreFromSDCard2(void)
{
mprintf("Unique ID restore ");
/* すでにブート時に一度 hwn_info はリードしている。 */
STD_CopyMemory( (void *)hwn_info.movableUniqueID, (void *)(mydata.movableUniqueID),
LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
if ( LCFGi_THW_WriteNormalInfoDirect( &hwn_info )) {
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
mprintf("OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
}
else {
// error
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
if( mydata.uniqueid_flag == TRUE ) {
mprintf("Unique ID restore ");
/* すでにブート時に一度 hwn_info はリードしている。 */
STD_CopyMemory( (void *)hwn_info.movableUniqueID, (void *)(mydata.movableUniqueID),
LCFG_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN );
if ( LCFGi_THW_WriteNormalInfoDirect( &hwn_info )) {
m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */
mprintf("OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
}
else {
// error
m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return FALSE;
}
return TRUE;
}
mprintf("No original Unique ID\n");
return TRUE;
}
@ -315,27 +329,35 @@ static BOOL LoadWlanConfig(void)
mfprintf(tc[3],"MODE = ");
switch( GetWlanMode() ) {
case 1:
case WCM_WEPMODE_NONE:
OS_TPrintf("NONE\n");
mfprintf(tc[3],"NONE\n");
break;
case 2:
case WM_WEPMODE_40BIT:
OS_TPrintf("WEP128\n");
mfprintf(tc[3],"WEP128\n");
break;
case 3:
case WM_WEPMODE_104BIT:
OS_TPrintf("WEP128\n");
mfprintf(tc[3],"WEP128\n");
break;
case WM_WEPMODE_128BIT:
OS_TPrintf("WEP128\n");
mfprintf(tc[3],"WEP128\n");
break;
case WCM_WEPMODE_WPA_TKIP:
OS_TPrintf("WPA-TKIP\n");
mfprintf(tc[3],"WPA-TKIP\n");
break;
case 4:
case WCM_WEPMODE_WPA2_TKIP:
OS_TPrintf("WPA2-TKIP\n");
mfprintf(tc[3],"WPA2-TKIP\n");
break;
case 5:
case WCM_WEPMODE_WPA_AES:
OS_TPrintf("WPA-AES\n");
mfprintf(tc[3],"WPA-AES\n");
break;
case 6:
case WCM_WEPMODE_WPA2_AES :
OS_TPrintf("WPA2-AES\n");
mfprintf(tc[3],"WPA2-AES\n");
break;
@ -344,20 +366,54 @@ static BOOL LoadWlanConfig(void)
mfprintf(tc[3],"Unknow mode..\n");
break;
}
OS_TPrintf("KEY STR = %s\n", GetWlanKEYSTR());
mfprintf(tc[3],"KEY STR = %s\n", GetWlanKEYSTR());
len = GetWlanKEYBIN(buf);
if( len ) {
OS_TPrintf("KEY BIN = 0x");
mfprintf(tc[3],"KEY BIN = 0x");
for( i = 0 ; i < len ; i++ ) {
OS_TPrintf("%02X",buf[i]);
mfprintf(tc[3],"%02X",buf[i]);
}
OS_TPrintf("\n");
mfprintf(tc[3],"\n");
if( TRUE == GetKeyModeStr() ) {
OS_TPrintf("KEY STR = %s\n", GetWlanKEYSTR());
mfprintf(tc[3],"KEY STR = %s\n", GetWlanKEYSTR());
}
else {
len = GetWlanKEYBIN(buf);
if( len ) {
OS_TPrintf("KEY BIN = 0x");
mfprintf(tc[3],"KEY BIN = 0x");
for( i = 0 ; i < len ; i++ ) {
OS_TPrintf("%02X",buf[i]);
mfprintf(tc[3],"%02X",buf[i]);
}
OS_TPrintf("\n");
mfprintf(tc[3],"\n");
}
}
mfprintf(tc[3],"\n");
if( TRUE == GetDhcpMODE() ) {
mfprintf(tc[3],"DHCP client\n");
}
else {
u32 addr_temp;
addr_temp = GetIPAddr();
mfprintf(tc[3],"IP addr %d.%d.%d.%d\n", (u32)((addr_temp >> 24) & 0xff),(u32)((addr_temp >> 16) & 0xff),
(u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) );
addr_temp = GetNetmask();
mfprintf(tc[3],"netmask %d.%d.%d.%d\n", (u32)((addr_temp >> 24) & 0xff),(u32)((addr_temp >> 16) & 0xff),
(u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) );
addr_temp = GetGateway();
mfprintf(tc[3],"gateway %d.%d.%d.%d\n", (u32)((addr_temp >> 24) & 0xff),(u32)((addr_temp >> 16) & 0xff),
(u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) );
addr_temp = GetDNS1();
mfprintf(tc[3],"DNS1 %d.%d.%d.%d\n", (u32)((addr_temp >> 24) & 0xff),(u32)((addr_temp >> 16) & 0xff),
(u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) );
addr_temp = GetDNS2();
mfprintf(tc[3],"DNS2 %d.%d.%d.%d\n", (u32)((addr_temp >> 24) & 0xff),(u32)((addr_temp >> 16) & 0xff),
(u32)((addr_temp >> 8) & 0xff),(u32)(addr_temp & 0xff) );
}
mfprintf(tc[3],"\n");
}
else {
OS_TPrintf("Invalid wlan cfg file\n");
@ -606,6 +662,12 @@ static void MyThreadProc(void *arg)
stream_play1(); /* ok.aiff */
}
Gfx_Set_BG1_Color((u16)M_TEXT_COLOR_DARKGREEN);
OS_Sleep(2000);
(void)MCU_SetVolume((u8)(mydata.volume));
(void)MCU_SetBackLightBrightness((u8)(mydata.backlight_brightness));
OS_TPrintf("vol = %d\n",mydata.volume );
OS_TPrintf("bright = %d\n", mydata.backlight_brightness);
OS_Sleep(200000);
break;
}
@ -656,16 +718,27 @@ static void MyThreadProcNuc(void *arg)
stream_play0(); /* cursor.aiff */
}
/* ハードウェアリセットを行い、自分自身を起動します。 */
mprintf("\n");
text_blink_current_line(tc[0]);
mprintf("press A button to start RESTORE\n\n");
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & PAD_BUTTON_A ) {
OS_RebootSystem();
if( no_reboot_flag == FALSE ) {
mprintf("\n");
text_blink_current_line(tc[0]);
mprintf("press A button to start RESTORE\n\n");
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & PAD_BUTTON_A ) {
OS_RebootSystem();
}
OS_Sleep(20);
}
}
else {
mprintf("\n");
// text_blink_current_line(tc[0]);
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & PAD_BUTTON_A ) {
}
OS_Sleep(20);
}
OS_Sleep(20);
}
}
else {
@ -709,26 +782,6 @@ static BOOL myTWLCardCallback( void )
return FALSE; // means that not terminate.
}
#ifdef MIYA_MCU
static volatile u8 miya_mcu_free_register = 0x44;
static void miya_mcu_free_reg_pxi_callback(PXIFifoTag tag, u32 data, BOOL err)
{
#pragma unused(tag)
#pragma unused(err)
miya_mcu_free_register = (u8)(0xff & data);
}
static void miya_mcu_free_reg_send_pxi_data(u32 data)
{
while (PXI_SendWordByFifo(PXI_FIFO_TAG_USER_0, data, FALSE) != PXI_FIFO_SUCCESS)
{
// do nothing
}
}
#endif
void TwlMain(void)
{
@ -800,21 +853,32 @@ void TwlMain(void)
/* OS_IsRebootedなんかおかしい・・ */
#ifdef MIYA_MCU
PXI_SetFifoRecvCallback(PXI_FIFO_TAG_USER_0, miya_mcu_free_reg_pxi_callback);
miya_mcu_free_reg_send_pxi_data( 0 );
MIYA_MCU_Init();
if( miya_mcu_free_register == 0x55 ) {
OS_TPrintf("MCU Free Reg. 0x%02x\n", MCU_GetFreeReg());
if( MCU_GetFreeReg() == 0x55 ) {
reboot_flag = TRUE;
}
else {
reboot_flag = FALSE;
}
#endif
/* デバッグのために今だけ強制的にオン(UPDATE mode) */
/* miya */
// reboot_flag = TRUE;
#if 0
/*
static inline u8 MCU_GetVolume( void )
static inline BOOL MCU_SetVolume( u8 volume )
static inline u8 MCU_GetBackLightBrightness( void )
static inline BOOL MCU_SetBackLightBrightness( u8 brightness )
*/
#endif
MCU_SetVolume( (u8)31 );
MCU_SetBackLightBrightness( (u8)4 );
if( FALSE == SDCardValidation() ) {
sd_card_flag = FALSE;
@ -881,10 +945,9 @@ void TwlMain(void)
}
// mprintf("mcu reg 0x%02X\n", miya_mcu_free_register );
#ifdef MIYA_MCU
if( miya_mcu_free_register == 0x55 ) {
#if 0
OS_TPrintf("MCU Free Reg. 0x%02x\n",MCU_GetFreeReg());
if( MCU_GetFreeReg() == 0x55 ) {
reboot_flag = TRUE;
}
else {
@ -898,6 +961,20 @@ void TwlMain(void)
if ( keyData & PAD_BUTTON_X ) {
reboot_flag = TRUE;
}
else if( keyData & PAD_BUTTON_Y ) {
no_reboot_flag = TRUE;
mprintf("no_reboot_flag ON\n");
}
else if( keyData & PAD_BUTTON_B ) {
reboot_flag = TRUE;
only_wifi_config_data_trans_flag = TRUE;
mprintf("only_wifi_config_data_trans ON\n");
}
else if( keyData & (PAD_BUTTON_START | PAD_BUTTON_SELECT) ) {
reboot_flag = TRUE;
user_and_wifi_config_data_trans_flag = TRUE;
mprintf("user_and_wifi_config_data ON\n");
}
#endif
if( FALSE == reboot_flag ) {
@ -1012,48 +1089,65 @@ void TwlMain(void)
MyFile_AddPathBase((const char *)MFILER_GetCursorEntryPath( &mfiler_list_head ) );
MyFile_AddPathBase("/");
mprintf("Personal data. restore ");
MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(),
&mydata, sizeof(MyData), NULL);
if(TRUE == MydataLoadDecrypt_success_flag ) {
if( mydata.version_major != MY_DATA_VERSION_MAJOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else if( mydata.version_minor != MY_DATA_VERSION_MINOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
m_set_palette(tc[0], 0xF); /* white */
vram_num_sub = 0;
MydataLoadDecrypt_message_flag = TRUE;
MydataLoadDecrypt_dir_flag = TRUE;
MydataLoadDecrypt_success_flag = TRUE;
start_my_thread();
}
if( only_wifi_config_data_trans_flag == TRUE ) {
/* 無線設定のみリストアする */
vram_num_sub = 0;
MydataLoadDecrypt_message_flag = TRUE;
MydataLoadDecrypt_dir_flag = TRUE;
MydataLoadDecrypt_success_flag = TRUE;
(void)RestoreFromSDCard3();
}
else {
m_set_palette(tc[0], 0x1); /* red */
mprintf("NG.\n");
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
else if( user_and_wifi_config_data_trans_flag == TRUE ) {
vram_num_sub = 0;
MydataLoadDecrypt_message_flag = TRUE;
MydataLoadDecrypt_dir_flag = TRUE;
MydataLoadDecrypt_success_flag = TRUE;
(void)RestoreFromSDCard4();
(void)RestoreFromSDCard3();
}
else {
mprintf("Personal data. restore ");
MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(),
&mydata, sizeof(MyData), NULL);
if(TRUE == MydataLoadDecrypt_success_flag ) {
if( mydata.version_major != MY_DATA_VERSION_MAJOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else if( mydata.version_minor != MY_DATA_VERSION_MINOR ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal format version.\n");
mprintf(" %s\n version %d.%d\n",MyFile_GetGlobalInformationFileName(),
mydata.version_major,mydata.version_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
m_set_palette(tc[0], 0xF); /* white */
vram_num_sub = 0;
MydataLoadDecrypt_message_flag = TRUE;
MydataLoadDecrypt_dir_flag = TRUE;
MydataLoadDecrypt_success_flag = TRUE;
start_my_thread();
}
}
else {
m_set_palette(tc[0], 0x1); /* red */
mprintf("NG.\n");
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
}
}
else {
@ -1062,7 +1156,6 @@ void TwlMain(void)
stream_play2(); /* ng.aiff */
}
MydataLoadDecrypt_message_flag = FALSE;
}
}
}

View File

@ -127,6 +127,7 @@ NucStatus ProgressNupCheck(void)
{
// NUC_GetProgress() failed in checking, error code=34303
OS_TPrintf("NUC_GetProgress() failed in checking, error code=%d\n", NUC_GetLastError());
mprintf("NUC_GetProgress() failed in checking\n error code=%d\n", NUC_GetLastError());
}
if (TestState.count++ % STRING_ANIM_CNT == 0)
{

View File

@ -23,7 +23,7 @@ TWL_ARCHGEN := LIMITED
SRCDIR = ../common/src ./src
SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \
gfx.c hwi.c mynvram.c my_fs_util.c \
gfx.c hwi.c mynvram.c my_fs_util.c miya_mcu.c \
sitedefs.c wcm_control.c netconnect.c mywlan.c \
stream.c myfilename.c menu_version.c

View File

@ -32,6 +32,7 @@
#include "mywlan.h"
#include "mydata.h"
#include "nuc.h"
#include "miya_mcu.h"
#include "myfilename.h"
#include "menu_version.h"
@ -337,12 +338,21 @@ static BOOL SDBackupToSDCard8(void)
RTCDate rtc_date;
RTCTime rtc_time;
/* オリジナルのデータのバックアップ */
if( RTC_RESULT_SUCCESS != RTC_GetDate( &rtc_date ) ) {
mprintf("rtc read date error.\n");
mydata.rtc_date_flag = FALSE;
}
else {
mydata.rtc_date_flag = TRUE;
}
if( RTC_RESULT_SUCCESS != RTC_GetTime( &rtc_time ) ) {
mprintf("rtc read time error.\n");
mydata.rtc_time_flag = FALSE;
}
else {
mydata.rtc_time_flag = TRUE;
}
STD_CopyMemory( (void *)&(mydata.rtc_date), (void *)&rtc_date, sizeof(RTCDate) );
@ -399,6 +409,12 @@ static void MyThreadProc(void *arg)
MyFile_SetPathBase("sdmc:/");
MyFile_AddPathBase((const char *)hws_info.serialNo );
MyFile_AddPathBase("/");
(void)CopyFile(MyFile_GetProductLogFileName(), "nand:/sys/log/"MY_FILE_NAME_PRODUCT_LOG , NULL);
(void)CopyFile(MyFile_GetSystemMenuLogFileName(), "nand:/sys/log/"MY_FILE_NAME_SYSMENU_LOG , NULL);
(void)CopyFile(MyFile_GetShopLogFileName(), "nand:/sys/log/"MY_FILE_NAME_SHOP_LOG , NULL);
for( function_counter = 0 ; function_counter < function_table_max ; function_counter++ ) {
if( FALSE == (function_table[function_counter])() ) {
flag = FALSE;
@ -524,6 +540,9 @@ void TwlMain(void)
// 必須SEA の初期化
SEA_Init();
MIYA_MCU_Init();
OS_TPrintf("MCU Free Reg. 0x%02x\n",MCU_GetFreeReg());
if( FALSE == Read_SystemMenuVersion(&s_major, &s_minor, &s_timestamp) ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
@ -542,10 +561,14 @@ void TwlMain(void)
ES_InitLib();
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
mydata.uniqueid_flag = FALSE;
m_set_palette(tc[0], 0x1); /* red */
mprintf("HW Normal Info. read error.\n");
m_set_palette(tc[0], 0xF);
}
else {
mydata.uniqueid_flag = TRUE;
}
// mprintf("HW Secure Info. read ");
if( FALSE == MiyaReadHWSecureInfo( &hws_info ) ) {
@ -611,18 +634,20 @@ void TwlMain(void)
*/
mydata.shop_record_flag = FALSE;
es_error_code = ES_GetDeviceId(&mydata.deviceId);
if( es_error_code == ES_ERR_OK ) {
mydata.shop_record_flag = TRUE;
if( TRUE == CheckShopRecord( hws_info.region, NULL ) ) {
mydata.shop_record_flag = TRUE;
}
else {
mprintf("no ec.cfg file\n");
}
}
else {
OS_TPrintf("es_error_code = %d\n", es_error_code );
mydata.shop_record_flag = FALSE;
}
// (void)CheckShopRecord( hws_info.region, NULL );
if( TRUE == mydata.shop_record_flag ) {
snprintf(mydata.bmsDeviceId, sizeof(mydata.bmsDeviceId), "%lld", ((0x3ull << 32) | mydata.deviceId));
// OS_TPrintf("DeviceID: %08X %u\n", mydata.deviceId, mydata.deviceId);
@ -631,6 +656,19 @@ void TwlMain(void)
mprintf("\n");
mydata.volume = (s32)MCU_GetVolume();
mydata.backlight_brightness = (s32)MCU_GetBackLightBrightness();
OS_TPrintf("vol = %d\n",mydata.volume );
OS_TPrintf("bright = %d\n", mydata.backlight_brightness);
MCU_SetVolume( (u8)31 );
MCU_SetBackLightBrightness( (u8)4 );
// static inline BOOL MCU_SetVolume( u8 volume )
// static inline BOOL MCU_SetBackLightBrightness( u8 brightness )
if( FALSE == SDCardValidation() ) {
sd_card_flag = FALSE;
m_set_palette(tc[0], 0x1); /* red */

View File

@ -93,12 +93,43 @@ static void miya_mcu_free_reg_send_pxi_data(u32 data)
}
}
#define MIYA_MCU_COMMAND_GET_FREE_REG 1
#define MIYA_MCU_COMMAND_GET_VOLUME 2
#define MIYA_MCU_COMMAND_GET_BRIGHTNESS 3
#define MIYA_MCU_COMMAND_SET_VOLUME 4
#define MIYA_MCU_COMMAND_SET_BRIGHTNESS 5
static void miya_mcu_free_reg_pxi_callback(PXIFifoTag tag, u32 data, BOOL err)
{
#pragma unused(tag)
#pragma unused(err)
miya_mcu_free_reg_send_pxi_data( (u32)miya_mcu_free_register );
switch( (data & 0xf) ) {
case MIYA_MCU_COMMAND_GET_FREE_REG:
miya_mcu_free_reg_send_pxi_data( (u32)miya_mcu_free_register );
break;
case MIYA_MCU_COMMAND_GET_VOLUME:
miya_mcu_free_reg_send_pxi_data( (u32)MCU_GetVolume() );
break;
case MIYA_MCU_COMMAND_GET_BRIGHTNESS:
miya_mcu_free_reg_send_pxi_data( (u32)MCU_GetBackLightBrightness() );
break;
case MIYA_MCU_COMMAND_SET_VOLUME:
miya_mcu_free_reg_send_pxi_data( (u32)MCU_SetVolume( (u8)((data >> 4) & 0xf)) );
break;
case MIYA_MCU_COMMAND_SET_BRIGHTNESS:
miya_mcu_free_reg_send_pxi_data( (u32)MCU_SetBackLightBrightness( (u8)((data >> 4) & 0xf) ));
break;
default:
miya_mcu_free_reg_send_pxi_data( (u32)miya_mcu_free_register );
break;
}
}
/*---------------------------------------------------------------------------*