os/kernelhwsrv/kernel/eka/euser/epoc/win32/uc_epoc.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) 1998-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
// e32\euser\epoc\win32\uc_epoc.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/*
sl@0
    19
#include <e32std.h>
sl@0
    20
#include <e32std_private.h>
sl@0
    21
#include <e32wins.h>
sl@0
    22
*/
sl@0
    23
sl@0
    24
#ifdef __SYMC__
sl@0
    25
sl@0
    26
//That stuff comes mostly from estub and uc_stub.cpp
sl@0
    27
//We had to put it in there since we don't know how to do an MMP firstlib on Windows
sl@0
    28
sl@0
    29
/*
sl@0
    30
extern "C"
sl@0
    31
GLDEF_C TInt _E32Startup()
sl@0
    32
//
sl@0
    33
// Unused in the stub
sl@0
    34
//
sl@0
    35
	{
sl@0
    36
	return KErrNone;
sl@0
    37
	}
sl@0
    38
sl@0
    39
sl@0
    40
sl@0
    41
//
sl@0
    42
#include <windows.h>
sl@0
    43
sl@0
    44
sl@0
    45
int CALLBACK _E32Bootstrap(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
sl@0
    46
	{
sl@0
    47
	BootEpoc(EFalse);
sl@0
    48
	return 0;
sl@0
    49
	};
sl@0
    50
sl@0
    51
*/
sl@0
    52
sl@0
    53
#endif
sl@0
    54
sl@0
    55
sl@0
    56
sl@0
    57
sl@0
    58
sl@0
    59
sl@0
    60
sl@0
    61
/*
sl@0
    62
#if defined __SYMC__
sl@0
    63
sl@0
    64
//#include <e32cmn.h>
sl@0
    65
#include <nwdl.h>
sl@0
    66
sl@0
    67
sl@0
    68
//#include <e32hashtab.h>
sl@0
    69
sl@0
    70
//SL: Empty on FCL ?
sl@0
    71
//For now we use this for basic testing on our SYMC implementation
sl@0
    72
sl@0
    73
sl@0
    74
TInt IdleCallBack(TAny* aParam)
sl@0
    75
   {
sl@0
    76
   static TInt count=0;
sl@0
    77
sl@0
    78
   count++;
sl@0
    79
sl@0
    80
   if (count>5)
sl@0
    81
      {
sl@0
    82
      //Stop it there
sl@0
    83
      CActiveScheduler::Stop();
sl@0
    84
      return EFalse;
sl@0
    85
      }
sl@0
    86
sl@0
    87
   //Keep playing
sl@0
    88
   return ETrue;		
sl@0
    89
   }
sl@0
    90
sl@0
    91
sl@0
    92
sl@0
    93
class CBaseTest: public CBase
sl@0
    94
	{
sl@0
    95
sl@0
    96
	};
sl@0
    97
sl@0
    98
sl@0
    99
GLDEF_C void MainL()
sl@0
   100
	{
sl@0
   101
sl@0
   102
   //Testing CBase object
sl@0
   103
	CBase* other=new(ELeave) CBase();
sl@0
   104
	CleanupStack::PushL(other);
sl@0
   105
	CBase* base=new(ELeave) CBase();
sl@0
   106
	CleanupStack::PushL(base);
sl@0
   107
	CleanupStack::PopAndDestroy(2,other);
sl@0
   108
	//delete base;
sl@0
   109
	
sl@0
   110
	//Testing cleanup stack
sl@0
   111
	TRAPD(err,
sl@0
   112
	base=new(ELeave) CBase();
sl@0
   113
	CleanupStack::PushL(base);
sl@0
   114
	User::Leave(KErrCancel);
sl@0
   115
	);
sl@0
   116
sl@0
   117
	ASSERT(err==KErrCancel);
sl@0
   118
sl@0
   119
	//Testing alloc failure
sl@0
   120
   //See TProcess
sl@0
   121
	TRAP(err,
sl@0
   122
	TUint8* shouldFail=new(ELeave) TUint8[1024*1024*10];
sl@0
   123
	delete[] shouldFail;
sl@0
   124
	);
sl@0
   125
sl@0
   126
   //
sl@0
   127
	ASSERT(err==KErrNoMemory);
sl@0
   128
sl@0
   129
   //Testing alloc failure without leave
sl@0
   130
   TUint8* tooLarge=new TUint8[1024*1024*10];
sl@0
   131
   ASSERT(tooLarge==NULL);
sl@0
   132
   delete[] tooLarge;
sl@0
   133
sl@0
   134
   //Testing simple alloc of T class
sl@0
   135
   TUint8* tinyAlloc=new TUint8;
sl@0
   136
   ASSERT(tinyAlloc!=NULL);
sl@0
   137
   delete tinyAlloc;
sl@0
   138
sl@0
   139
   //TODO:
sl@0
   140
   //RHashSet<TUint32> hash;
sl@0
   141
	
sl@0
   142
   //Testing AOs
sl@0
   143
   //Install an active scheduler
sl@0
   144
   CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler;
sl@0
   145
   CActiveScheduler::Install(activeScheduler);
sl@0
   146
   CleanupStack::PushL(activeScheduler);
sl@0
   147
sl@0
   148
   CIdle* idle = CIdle::NewL(CActive::EPriorityIdle);	
sl@0
   149
   CleanupStack::PushL(idle);
sl@0
   150
sl@0
   151
   idle->Start(TCallBack(IdleCallBack,NULL));
sl@0
   152
sl@0
   153
   CActiveScheduler::Start();
sl@0
   154
sl@0
   155
   CleanupStack::PopAndDestroy(idle);
sl@0
   156
   CActiveScheduler::Install(NULL);
sl@0
   157
   CleanupStack::PopAndDestroy(activeScheduler);
sl@0
   158
sl@0
   159
sl@0
   160
	//Testing unbalanced cleanup stack
sl@0
   161
	//base=new(ELeave) CBase();
sl@0
   162
	//CleanupStack::PushL(base);
sl@0
   163
	}
sl@0
   164
sl@0
   165
sl@0
   166
GLDEF_C TInt E32Main()
sl@0
   167
	{
sl@0
   168
	//What do we do then
sl@0
   169
	//SetReturnedHandle
sl@0
   170
	
sl@0
   171
	__UHEAP_MARK;
sl@0
   172
sl@0
   173
	//CBase* base=new(ELeave) CBase();
sl@0
   174
	CBase* base=new CBase();
sl@0
   175
	delete base;
sl@0
   176
sl@0
   177
	CBaseTest* baseTest=new CBaseTest();
sl@0
   178
	delete baseTest;
sl@0
   179
sl@0
   180
	HBufC* buf=HBufC::New(10);
sl@0
   181
	delete buf;
sl@0
   182
sl@0
   183
	CArrayFix<TInt>* active=new CArrayFixFlat<TInt>(10);
sl@0
   184
	delete active;
sl@0
   185
sl@0
   186
	TUint8* test=new TUint8[1024*9];
sl@0
   187
	delete[] test;
sl@0
   188
sl@0
   189
	CTrapCleanup* cleanupStack = CTrapCleanup::New();
sl@0
   190
	if (!cleanupStack)
sl@0
   191
		{
sl@0
   192
		return KErrNoMemory;
sl@0
   193
		}
sl@0
   194
sl@0
   195
sl@0
   196
sl@0
   197
sl@0
   198
sl@0
   199
	TInt err=KErrNone;
sl@0
   200
	TRAP(err,MainL());
sl@0
   201
	
sl@0
   202
	delete cleanupStack;
sl@0
   203
sl@0
   204
	__UHEAP_MARKEND;
sl@0
   205
sl@0
   206
	return err;
sl@0
   207
	}
sl@0
   208
sl@0
   209
sl@0
   210
sl@0
   211
#include <windows.h>
sl@0
   212
sl@0
   213
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,	int nCmdShow)
sl@0
   214
	{
sl@0
   215
	//User::InitProcess();
sl@0
   216
	//E32Main();
sl@0
   217
	//User::Exit(0);
sl@0
   218
sl@0
   219
	BootEpoc(ETrue);
sl@0
   220
sl@0
   221
	return 0;
sl@0
   222
	}
sl@0
   223
sl@0
   224
#endif
sl@0
   225
*/