1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     init_StartUp.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: 47285 $
14  *---------------------------------------------------------------------------*/
15 
16 //---------------------------------------------------------------------------
17 
18 #include <nn/config.h>
19 #include <nn/init.h>
20 #include <nn/os/os_Initialize.h>
21 #include <nn/ndm.h>
22 
23 #define NN_SYSTEM_DEFAULT_HEAP_SIZE     0x00800000
24 
25 extern "C" nninitStaticInitFunc Image$$STATIC_INIT$$RO$$Base[];
26 extern "C" nninitStaticInitFunc Image$$STATIC_INIT$$RO$$Limit[];
27 
28 #if NN_PLATFORM_HAS_MMU
29 #include <nn/os/os_ErrorHandlerSelect.h>
30 #include <nn/applet/CTR/applet_API.h>
31 namespace nn {
32 namespace applet {
33 namespace CTR {
34 namespace detail {
35     // If libnn_applet.a is not linked, this is used by the nninitSetup function
Initialize(AppletAttr appletAttr)36     __declspec(noinline) Result Initialize( AppletAttr appletAttr )
37     {
38         return ResultSuccess();
39     }
40 }}}}
41 #endif
42 
nninitSystem(void)43 extern "C" NN_WEAK_SYMBOL void nninitSystem(void)
44 {
45     // OS Library initialization
46     nn::os::Initialize();
47 }
48 
nninitStartUp(void)49 extern "C" NN_WEAK_SYMBOL void nninitStartUp(void)
50 {
51     nninitStartUpDefault();
52 }
53 
54 #if NN_PLATFORM_HAS_MMU
nninitSetupDaemons(void)55 extern "C" NN_WEAK_SYMBOL void nninitSetupDaemons(void)
56 {
57     // Performs default settings for daemon manager
58     nn::ndm::SetupDaemonsDefault();
59 }
60 #endif
61 
nninitCallStaticInitializers(void)62 extern "C" void nninitCallStaticInitializers(void)
63 {
64     for( nninitStaticInitFunc* f = Image$$STATIC_INIT$$RO$$Base;
65          f < Image$$STATIC_INIT$$RO$$Limit;
66          ++f )
67     {
68         (*f)();
69     }
70 }
71 
nninitSetup(void)72 extern "C" NN_WEAK_SYMBOL void nninitSetup(void)
73 {
74     nninitSetupDefault();
75 
76 #if NN_PLATFORM_HAS_MMU
77     nn::os::detail::SetInternalErrorHandlingMode(false);
78     nn::applet::CTR::detail::Initialize();
79     nninitSetupDaemons();
80 #endif
81 }
82 
83