1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: init_Default.cpp 4 5 Copyright (C)2009 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: 36718 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn/config.h> 17 #include <nn/init.h> 18 #include <nn/os.h> 19 #include <nn/srv.h> 20 21 namespace 22 { 23 class ExitHandler : public nn::srv::NotificationHandler 24 { 25 public: HandleNotification(bit32 message)26 virtual void HandleNotification(bit32 message) 27 { 28 NN_UNUSED_VAR(message); 29 30 nn::svc::ExitProcess(); 31 } 32 }; 33 34 35 36 ExitHandler s_ExitHandler; 37 } 38 nninitStartUpDefault(void)39extern "C" void nninitStartUpDefault(void) 40 { 41 #if NN_PLATFORM_HAS_MMU 42 #pragma push 43 #pragma diag_suppress 1361 44 45 const size_t assingment = nn::os::GetAppMemorySize(); 46 const size_t currentUsing = nn::os::GetUsingMemorySize(); 47 48 const size_t available = assingment - currentUsing; 49 const size_t heapSize = available - nn::os::DEVICE_MEMORY_SIZE; 50 51 nn::os::SetupHeapForMemoryBlock(heapSize); 52 nn::os::InitializeDeviceMemory(); 53 54 nn::init::InitializeAllocator( 8 * 1024 * 1024 ); 55 #pragma pop 56 #endif // if NN_PLATFORM_HAS_MMU 57 } 58 nninitSetupDefault(void)59extern "C" void nninitSetupDefault(void) 60 { 61 #if NN_PLATFORM_HAS_MMU 62 nn::srv::Initialize(); 63 nn::srv::StartNotification(); 64 65 nn::os::detail::SaveThreadLocalRegionAddress(); 66 #endif // if NN_PLATFORM_HAS_MMU 67 } 68 nninitSetupDefaultWithSettingExitHandler(void)69extern "C" void nninitSetupDefaultWithSettingExitHandler(void) 70 { 71 #if NN_PLATFORM_HAS_MMU 72 nn::srv::Initialize(); 73 nn::srv::StartNotification(); 74 75 nn::srv::RegisterNotificationHandler(&s_ExitHandler, nn::srv::NOTIFICATION_EXIT); 76 77 nn::os::detail::SaveThreadLocalRegionAddress(); 78 #endif // if NN_PLATFORM_HAS_MMU 79 } 80 81