/*---------------------------------------------------------------------------* Project: TwlIPL File: pxi.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 #include #include "internal_api.h" #ifdef SDK_ARM7 #include #endif // SDK_ARM7 #ifdef DHT_TEST #include #ifdef SDK_ARM9 #define DS_HASH_TABLE_SIZE (256*1024) static u8 dht_buffer[DS_HASH_TABLE_SIZE] ATTRIBUTE_ALIGN(256); static DHTFile *const dht = (DHTFile*)dht_buffer; #else extern DHTFile* dht; #endif #endif // define data----------------------------------------------------------------- #define SYSM_PXI_COMM_STAT_REQ 0 #define SYSM_PXI_COMM_STAT_ACK 1 // PXIコマンド typedef union SYSMPXIPacket { struct { u16 data; u8 cmd; // PXI_FIFOMESSAGE_BITSZ_DATA = 26 u8 stat : 2; }; u32 raw; }SYSMPXIPacket; // extern data----------------------------------------------------------------- // function's prototype------------------------------------------------------- // global variable------------------------------------------------------------- // static variable------------------------------------------------------------- static volatile BOOL s_sending[SYSM_PXI_COMM_NUM]; // const data------------------------------------------------------------------ // PXI初期化 #ifdef SDK_ARM9 void SYSM_InitPXI( void ) #else // SDK_ARM7 void SYSM_InitPXI( u32 mcu_prio ) #endif // SDK_ARM7 { static BOOL isInitialized; int i; if (isInitialized) { return; } isInitialized = TRUE; // マイコンPXI初期化とマイコンバージョン取得 #ifdef SDK_ARM9 SYSM_InitMcuPxi(); #else // SDK_ARM7 SYSM_InitMcuPxi( mcu_prio ); #endif // SDK_ARM7 for (i=0; i> 8) ); } #endif #endif // PXIコマンド送信 BOOL SYSMi_TrySendPXICommand( SYSMPXICommand cmd, u16 data ) { SYSMPXIPacket packet; OSIntrMode saved = OS_DisableInterrupts(); if( s_sending[cmd] ) { OS_RestoreInterrupts( saved ); return FALSE; } s_sending[cmd] = TRUE; OS_RestoreInterrupts( saved ); packet.stat = SYSM_PXI_COMM_STAT_REQ; packet.cmd = cmd; packet.data = data; while( PXI_SendWordByFifo( SYSMENU_PXI_FIFO_TAG, packet.raw, FALSE) != PXI_FIFO_SUCCESS ) { SVC_WaitByLoop(1); } return TRUE; } BOOL SYSMi_SendPXICommand( SYSMPXICommand cmd, u16 data ) { while( ! SYSMi_TrySendPXICommand( cmd, data ) ) { OS_WaitAnyIrq(); } while( s_sending[cmd] ) { OS_WaitAnyIrq(); } return TRUE; } void SYSMi_PXIFifoRecvCallback( PXIFifoTag tag, u32 data, BOOL err ) { #pragma unused( tag, err ) SYSMPXIPacket packet; u8 cmd; packet.raw = data; cmd = packet.cmd; if( packet.stat == SYSM_PXI_COMM_STAT_ACK ) { s_sending[cmd] = FALSE; } if( packet.stat == SYSM_PXI_COMM_STAT_REQ ) { packet.stat = SYSM_PXI_COMM_STAT_ACK; } #ifdef SDK_ARM7 switch( cmd ) { #ifdef DHT_TEST case SYSM_PXI_COMM_DS_HASH_TABLE: dht = (void*)(0x2000000 + (packet.data << 8)); OS_TPrintf("[ARM7] dht address: %08X\n", dht); break; #endif default: #ifndef SDK_FINALROM OS_Panic( "illegal SYSM pxi command." ); #else OS_Panic(""); #endif break; } // PXI応答返信 PXI_SendWordByFifo( SYSMENU_PXI_FIFO_TAG, packet.raw, FALSE ); #endif // SDK_ARM7 }