1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_WaitableCounter.cpp 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. 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 $Rev: 46347 $ 14 *---------------------------------------------------------------------------*/ 15 16 17 #include <nn/os/os_WaitableCounter.h> 18 #include <nn/assert.h> 19 20 21 namespace nn { namespace os { 22 23 // When explicitly initializing with INVALID_HANDLE_VALUE, 24 // relies on bss clear because it is initialized with static_initializer 25 nnHandle WaitableCounter::s_Handle = {0}; 26 Initialize()27 void WaitableCounter::Initialize() 28 { 29 if( s_Handle.value == INVALID_HANDLE_VALUE.value ) 30 { 31 Handle h; 32 Result ret = nn::svc::CreateAddressArbiter(&h); 33 NN_TASSERT_( ret.IsSuccess() ); 34 35 if( ret.IsSuccess() ) 36 { 37 s_Handle = h; 38 } 39 } 40 } 41 Finalize()42 void WaitableCounter::Finalize() 43 { 44 if( s_Handle.value != INVALID_HANDLE_VALUE.value ) 45 { 46 Result ret = nn::svc::CloseHandle(s_Handle); 47 NN_TASSERT_( ret.IsSuccess() ); 48 49 if( ret.IsSuccess() ) 50 { 51 s_Handle.value = INVALID_HANDLE_VALUE.value; 52 } 53 } 54 } 55 56 }} 57 58 namespace nn { namespace svc { ArbitrateAddress(Handle arbiter,uptr addr,nn::os::ArbitrationType type,s32 value)59 Result ArbitrateAddress( Handle arbiter, uptr addr, nn::os::ArbitrationType type, s32 value ) 60 { 61 return svc::ArbitrateAddress(arbiter, addr, type, value, 0); 62 } 63 }} 64