1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_Environment.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 #include <nn/os/os_EnvironmentSelect.h> 17 #include <nn/os/os_SharedInfo.h> 18 #include <nn/assert.h> 19 #include <nn/svc.h> 20 #include <nn/util.h> 21 22 namespace nn { namespace os { 23 GetAppMemorySize()24 size_t GetAppMemorySize() 25 { 26 return (GetReadOnlySharedInfo().kParamValues[0]); 27 } 28 GetUsingPrivateMemorySize()29 size_t GetUsingPrivateMemorySize() 30 { 31 s64 currentUse; 32 33 nn::svc::GetProcessInfo( 34 ¤tUse, 35 nn::PSEUDO_HANDLE_CURRENT_PROCESS, 36 PROCESS_INFO_TYPE_PRIVATE_PHYSICAL_MEMORY_SIZE ); 37 38 return static_cast<size_t>(currentUse); 39 } 40 GetMemoryQuotaSize()41 size_t GetMemoryQuotaSize() 42 { 43 Handle h; 44 s64 v[1]; 45 LimitableResource names[1] = { LIMITABLE_RESOURCE_MAX_COMMIT }; 46 47 svc::GetResourceLimit(&h, PSEUDO_HANDLE_CURRENT_PROCESS); 48 svc::GetResourceLimitLimitValues(v, h, names, sizeof(*util::NumOfElementsT(names)) ); 49 svc::CloseHandle(h); 50 51 return static_cast<size_t>(v[0]); 52 } 53 GetUsingMemorySize()54 size_t GetUsingMemorySize() 55 { 56 Handle h; 57 s64 v[1]; 58 LimitableResource names[1] = { LIMITABLE_RESOURCE_MAX_COMMIT }; 59 60 svc::GetResourceLimit(&h, PSEUDO_HANDLE_CURRENT_PROCESS); 61 svc::GetResourceLimitCurrentValues(v, h, names, sizeof(*util::NumOfElementsT(names)) ); 62 svc::CloseHandle(h); 63 64 return static_cast<size_t>(v[0]); 65 } 66 GetCreationTime()67 Tick GetCreationTime() 68 { 69 s64 tick; 70 71 svc::GetHandleInfo( 72 &tick, 73 PSEUDO_HANDLE_CURRENT_PROCESS, 74 HANDLE_INFO_TYPE_CREATION_TIME ); 75 76 return Tick(tick); 77 } 78 79 }} 80 81