1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/nkernsa/init.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,158 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\nkernsa\init.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <nktest/nkutils.h>
1.22 +
1.23 +extern "C" {
1.24 +TLinAddr RomHeaderAddress;
1.25 +TLinAddr SuperPageAddress;
1.26 +TBool InitialThreadDefined;
1.27 +}
1.28 +
1.29 +NThread* InitialThread;
1.30 +TDfcQue* TimerDfcQ;
1.31 +TDfcQue* CleanupDfcQ;
1.32 +NThread* MainThread;
1.33 +
1.34 +#ifdef __SMP__
1.35 +const char* NullNames[KMaxCpus] =
1.36 + {
1.37 + "Null0",
1.38 + "Null1",
1.39 + "Null2",
1.40 + "Null3",
1.41 + "Null4",
1.42 + "Null5",
1.43 + "Null6",
1.44 + "Null7"
1.45 + };
1.46 +#endif
1.47 +
1.48 +extern "C" void StartSystemTimer();
1.49 +extern "C" void Hw_Init1();
1.50 +extern "C" void Hw_InitAPs();
1.51 +extern "C" void Hw_Init3();
1.52 +extern "C" TLinAddr __initial_stack_base();
1.53 +extern "C" TInt __initial_stack_size();
1.54 +
1.55 +extern void Main(TAny*);
1.56 +
1.57 +extern "C" void KernelMain()
1.58 + {
1.59 + KPrintf("KernelMain()");
1.60 + __CHECKPOINT();
1.61 +
1.62 + Hw_Init1();
1.63 + NTimerQ::Init1(__timer_period());
1.64 + SetupMemoryAllocator();
1.65 +
1.66 + InitialThread = new NThread;
1.67 + __KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", InitialThread));
1.68 + SNThreadCreateInfo info;
1.69 +
1.70 + info.iFunction = 0;
1.71 + info.iStackBase = (TAny*)__initial_stack_base();
1.72 + info.iStackSize = __initial_stack_size();
1.73 + info.iPriority = 0;
1.74 + info.iTimeslice = -1;
1.75 + info.iAttributes = 0;
1.76 + info.iHandlers = 0;
1.77 + info.iFastExecTable = 0;
1.78 + info.iSlowExecTable = 0;
1.79 + info.iParameterBlock = 0;
1.80 + info.iParameterBlockSize = 0;
1.81 +#ifdef __SMP__
1.82 + info.iCpuAffinity = 0;
1.83 + info.iGroup = 0;
1.84 +#endif
1.85 +
1.86 + NKern::Init(InitialThread, info);
1.87 +#ifdef __SMP__
1.88 + InitialThread->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
1.89 +#else
1.90 + InitialThread->iSpare8 = (TUint32)"Null";
1.91 +#endif
1.92 + InitialThreadDefined = ETrue;
1.93 +
1.94 + KPrintf("NKern::CurrentThread() = %08x", NKern::CurrentThread());
1.95 + KPrintf("TR=%x",__cpu_id());
1.96 +
1.97 +#ifdef __SMP__
1.98 + Hw_InitAPs();
1.99 +#endif
1.100 +
1.101 + CleanupDfcQ = CreateDfcQ("Cleanup", 17, KCpuAffinityAny);
1.102 + TimerDfcQ = CreateDfcQ("Timer", 48);
1.103 + NTimerQ::Init3(TimerDfcQ);
1.104 + Hw_Init3();
1.105 +
1.106 + init_fast_counter();
1.107 +
1.108 + MainThread = CreateThread("Main", &Main, 16, 0, 0, ETrue, KTimeslice);
1.109 +
1.110 + KPrintf("spinning ...");
1.111 + FOREVER
1.112 + {
1.113 + NKern::Idle();
1.114 + }
1.115 + }
1.116 +
1.117 +#ifdef __SMP__
1.118 +extern "C" void ApMainGeneric(volatile SAPBootInfo* aInfo)
1.119 + {
1.120 + NThread* t = (NThread*)aInfo->iArgs[0];
1.121 + __KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", t));
1.122 + SNThreadCreateInfo info;
1.123 +
1.124 + info.iFunction = 0;
1.125 + info.iStackBase = (TAny*)aInfo->iInitStackBase;
1.126 + info.iStackSize = aInfo->iInitStackSize;
1.127 + info.iPriority = 0;
1.128 + info.iTimeslice = -1;
1.129 + info.iAttributes = 0;
1.130 + info.iHandlers = 0;
1.131 + info.iFastExecTable = 0;
1.132 + info.iSlowExecTable = 0;
1.133 + info.iParameterBlock = (const TUint32*)aInfo;
1.134 + info.iParameterBlockSize = 0;
1.135 + info.iCpuAffinity = 0; // nanokernel substitutes with correct CPU number
1.136 + info.iGroup = 0;
1.137 +
1.138 + NKern::Init(t, info);
1.139 + t->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
1.140 +
1.141 + KPrintf("NKern::CurrentThread() = %08x\n", NKern::CurrentThread());
1.142 +
1.143 + __e32_atomic_store_ord32(&aInfo->iArgs[1], 1);
1.144 +
1.145 + __KTRACE_OPT(KBOOT,DEBUGPRINT("AP status=%08x", __cpu_status_reg()));
1.146 + KPrintf("AP TR=%x",__cpu_id());
1.147 +
1.148 + FOREVER
1.149 + {
1.150 + NKern::Idle();
1.151 + }
1.152 + }
1.153 +#endif
1.154 +
1.155 +TBool BTrace::IsSupported(TUint aCategory)
1.156 + {
1.157 + if(aCategory>255)
1.158 + return EFalse;
1.159 + return ETrue;
1.160 + }
1.161 +