1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - NWM - libraries 3 File: nwm_end.c 4 5 Copyright 2007-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-09-17#$ 14 $Rev: 8556 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 18 #include <twl.h> 19 #include "nwm_common_private.h" 20 #include "nwm_arm9_private.h" 21 22 23 /*---------------------------------------------------------------------------* 24 Name: NWM_End 25 26 Description: 27 28 29 Arguments: callback: Callback function that is called when the asynchronous process completes 30 31 Returns: NWMRetCode: Returns the processing result. 32 Returns NWM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback. 33 34 *---------------------------------------------------------------------------*/ 35 NWM_End(void)36NWMRetCode NWM_End(void) 37 { 38 NWMRetCode result; 39 OSIntrMode e; 40 extern NWMArm9Buf *nwm9buf; 41 extern u8 nwmInitialized; 42 43 SDK_NULL_ASSERT(nwm9buf); 44 45 // This can only run in the INITIALIZED state 46 result = NWMi_CheckState(1, NWM_STATE_INITIALIZED); 47 NWM_CHECK_RESULT(result); 48 49 e = OS_DisableInterrupts(); 50 51 nwm9buf->status->state = NWM_STATE_NONE; // As an exception, set the initial state here alone (this was originally done by the ARM7) 52 53 // Clears the FIFO buffer writable flag 54 NWMi_ClearFifoRecvFlag(); 55 56 PXI_SetFifoRecvCallback(PXI_FIFO_TAG_WMW, NULL); 57 nwm9buf = 0; 58 59 // Normal end 60 nwmInitialized = 0; 61 (void)OS_RestoreInterrupts(e); 62 return NWM_RETCODE_SUCCESS; 63 } 64