os/kernelhwsrv/kerneltest/e32test/nkernsa/init.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\nkernsa\init.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <nktest/nkutils.h>
sl@0
    19
sl@0
    20
extern "C" {
sl@0
    21
TLinAddr RomHeaderAddress;
sl@0
    22
TLinAddr SuperPageAddress;
sl@0
    23
TBool InitialThreadDefined;
sl@0
    24
}
sl@0
    25
sl@0
    26
NThread* InitialThread;
sl@0
    27
TDfcQue* TimerDfcQ;
sl@0
    28
TDfcQue* CleanupDfcQ;
sl@0
    29
NThread* MainThread;
sl@0
    30
sl@0
    31
#ifdef __SMP__
sl@0
    32
const char* NullNames[KMaxCpus] =
sl@0
    33
	{
sl@0
    34
	"Null0",
sl@0
    35
	"Null1",
sl@0
    36
	"Null2",
sl@0
    37
	"Null3",
sl@0
    38
	"Null4",
sl@0
    39
	"Null5",
sl@0
    40
	"Null6",
sl@0
    41
	"Null7"
sl@0
    42
	};
sl@0
    43
#endif
sl@0
    44
sl@0
    45
extern "C" void StartSystemTimer();
sl@0
    46
extern "C" void Hw_Init1();
sl@0
    47
extern "C" void Hw_InitAPs();
sl@0
    48
extern "C" void Hw_Init3();
sl@0
    49
extern "C" TLinAddr __initial_stack_base();
sl@0
    50
extern "C" TInt __initial_stack_size();
sl@0
    51
sl@0
    52
extern void Main(TAny*);
sl@0
    53
sl@0
    54
extern "C" void KernelMain()
sl@0
    55
	{
sl@0
    56
	KPrintf("KernelMain()");
sl@0
    57
	__CHECKPOINT();
sl@0
    58
sl@0
    59
	Hw_Init1();
sl@0
    60
	NTimerQ::Init1(__timer_period());
sl@0
    61
	SetupMemoryAllocator();
sl@0
    62
sl@0
    63
	InitialThread = new NThread;
sl@0
    64
	__KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", InitialThread));
sl@0
    65
	SNThreadCreateInfo info;
sl@0
    66
sl@0
    67
	info.iFunction = 0;
sl@0
    68
	info.iStackBase = (TAny*)__initial_stack_base();
sl@0
    69
	info.iStackSize = __initial_stack_size();
sl@0
    70
	info.iPriority = 0;
sl@0
    71
	info.iTimeslice = -1;
sl@0
    72
	info.iAttributes = 0;
sl@0
    73
	info.iHandlers = 0;
sl@0
    74
	info.iFastExecTable = 0;
sl@0
    75
	info.iSlowExecTable = 0;
sl@0
    76
	info.iParameterBlock = 0;
sl@0
    77
	info.iParameterBlockSize = 0;
sl@0
    78
#ifdef __SMP__
sl@0
    79
	info.iCpuAffinity = 0;
sl@0
    80
	info.iGroup = 0;
sl@0
    81
#endif
sl@0
    82
sl@0
    83
	NKern::Init(InitialThread, info);
sl@0
    84
#ifdef __SMP__
sl@0
    85
	InitialThread->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
sl@0
    86
#else
sl@0
    87
	InitialThread->iSpare8 = (TUint32)"Null";
sl@0
    88
#endif
sl@0
    89
	InitialThreadDefined = ETrue;
sl@0
    90
sl@0
    91
	KPrintf("NKern::CurrentThread() = %08x", NKern::CurrentThread());
sl@0
    92
	KPrintf("TR=%x",__cpu_id());
sl@0
    93
sl@0
    94
#ifdef __SMP__
sl@0
    95
	Hw_InitAPs();
sl@0
    96
#endif
sl@0
    97
sl@0
    98
	CleanupDfcQ = CreateDfcQ("Cleanup", 17, KCpuAffinityAny);
sl@0
    99
	TimerDfcQ = CreateDfcQ("Timer", 48);
sl@0
   100
	NTimerQ::Init3(TimerDfcQ);
sl@0
   101
	Hw_Init3();
sl@0
   102
sl@0
   103
	init_fast_counter();
sl@0
   104
sl@0
   105
	MainThread = CreateThread("Main", &Main, 16, 0, 0, ETrue, KTimeslice);
sl@0
   106
sl@0
   107
	KPrintf("spinning ...");
sl@0
   108
	FOREVER
sl@0
   109
		{
sl@0
   110
		NKern::Idle();
sl@0
   111
		}
sl@0
   112
	}
sl@0
   113
sl@0
   114
#ifdef __SMP__
sl@0
   115
extern "C" void ApMainGeneric(volatile SAPBootInfo* aInfo)
sl@0
   116
	{
sl@0
   117
	NThread* t = (NThread*)aInfo->iArgs[0];
sl@0
   118
	__KTRACE_OPT(KTHREAD,DEBUGPRINT("Initial thread at %08x", t));
sl@0
   119
	SNThreadCreateInfo info;
sl@0
   120
sl@0
   121
	info.iFunction = 0;
sl@0
   122
	info.iStackBase = (TAny*)aInfo->iInitStackBase;
sl@0
   123
	info.iStackSize = aInfo->iInitStackSize;
sl@0
   124
	info.iPriority = 0;
sl@0
   125
	info.iTimeslice = -1;
sl@0
   126
	info.iAttributes = 0;
sl@0
   127
	info.iHandlers = 0;
sl@0
   128
	info.iFastExecTable = 0;
sl@0
   129
	info.iSlowExecTable = 0;
sl@0
   130
	info.iParameterBlock = (const TUint32*)aInfo;
sl@0
   131
	info.iParameterBlockSize = 0;
sl@0
   132
	info.iCpuAffinity = 0;	// nanokernel substitutes with correct CPU number
sl@0
   133
	info.iGroup = 0;
sl@0
   134
sl@0
   135
	NKern::Init(t, info);
sl@0
   136
	t->iNThreadBaseSpare8 = (TUint32)NullNames[NKern::CurrentCpu()];
sl@0
   137
sl@0
   138
	KPrintf("NKern::CurrentThread() = %08x\n", NKern::CurrentThread());
sl@0
   139
sl@0
   140
	__e32_atomic_store_ord32(&aInfo->iArgs[1], 1);
sl@0
   141
sl@0
   142
	__KTRACE_OPT(KBOOT,DEBUGPRINT("AP status=%08x", __cpu_status_reg()));
sl@0
   143
	KPrintf("AP TR=%x",__cpu_id());
sl@0
   144
sl@0
   145
	FOREVER
sl@0
   146
		{
sl@0
   147
		NKern::Idle();
sl@0
   148
		}
sl@0
   149
	}
sl@0
   150
#endif
sl@0
   151
sl@0
   152
TBool BTrace::IsSupported(TUint aCategory)
sl@0
   153
	{
sl@0
   154
	if(aCategory>255)
sl@0
   155
		return EFalse;
sl@0
   156
	return ETrue;
sl@0
   157
	}
sl@0
   158