os/boardsupport/emulator/emulatorbsp/inc/variant.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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 "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
// wins\inc\variant.h
sl@0
    15
// Wins Variant Header
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#ifndef __VA_STD_H__
sl@0
    20
#define __VA_STD_H__
sl@0
    21
sl@0
    22
#include <assp.h>
sl@0
    23
#include "vwins.h"
sl@0
    24
#include "nk_priv.h"
sl@0
    25
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
sl@0
    26
#include <mmsystem.h>
sl@0
    27
#pragma warning(default : 4201)
sl@0
    28
#include <kernel/kpower.h>
sl@0
    29
sl@0
    30
#ifdef _DEBUG
sl@0
    31
const TInt KDefaultDebugMask = 1<<KPANIC; //KPANIC, override this with "DebugMask 0" in EPOC.INI
sl@0
    32
#else
sl@0
    33
const TInt KDefaultDebugMask = 0;
sl@0
    34
#endif
sl@0
    35
sl@0
    36
typedef void (*TMediaChangeCallBack)(TAny*);
sl@0
    37
sl@0
    38
class WinsTimer
sl@0
    39
	{
sl@0
    40
public:
sl@0
    41
	enum
sl@0
    42
		{
sl@0
    43
		EDefaultPeriod = 5,		// milliseconds
sl@0
    44
		EMaxLag = 100,			// milliseconds
sl@0
    45
		};
sl@0
    46
public:
sl@0
    47
	WinsTimer();
sl@0
    48
	void Init(TUint aPeriod);
sl@0
    49
	void Enable();
sl@0
    50
	inline TUint Period() const
sl@0
    51
		{return iPeriod;}
sl@0
    52
	inline void SetIdleThread()
sl@0
    53
		{if (!iIdleThread) iIdleThread = NKern::CurrentThread();}
sl@0
    54
	inline void Nobble(TUint aNobbleFactor)
sl@0
    55
		{iNobbleNanos = aNobbleFactor * iPeriod;}
sl@0
    56
	TInt SystemTime() const;
sl@0
    57
	void SetSystemTime(TInt aTime);
sl@0
    58
	void Standby();
sl@0
    59
	void Wakeup();
sl@0
    60
private:
sl@0
    61
	void EventThread(NTimerQ& aTimerQ);
sl@0
    62
	static DWORD WINAPI Thread(LPVOID);
sl@0
    63
	static void CALLBACK Tick(UINT, UINT, DWORD, DWORD, DWORD);
sl@0
    64
private:
sl@0
    65
	TUint iPeriod;
sl@0
    66
	TUint iNobbleNanos;
sl@0
    67
	TInt iMaxLagTicks;
sl@0
    68
	HANDLE iSemaphore;
sl@0
    69
	UINT iTimer;
sl@0
    70
	TInt iSuspend;
sl@0
    71
	Int64 iTime;
sl@0
    72
	NThread* iIdleThread;
sl@0
    73
	TBool iStandby;
sl@0
    74
	};
sl@0
    75
sl@0
    76
class Properties
sl@0
    77
	{
sl@0
    78
	struct SEntry
sl@0
    79
		{
sl@0
    80
		char* iProperty;
sl@0
    81
		char* iValue;
sl@0
    82
		};
sl@0
    83
public:
sl@0
    84
	Properties();
sl@0
    85
	const char* Append(const char* aProperty, const char* aValue);
sl@0
    86
	const char* Replace(const char* aProperty, const char* aValue);
sl@0
    87
	TInt GetString(const char* aProperty, const char*& aValue) const;
sl@0
    88
	TInt GetInt(const char* aProperty, TInt& aValue) const;
sl@0
    89
	TInt GetBool(const char* aProperty, TBool& aValue, TBool aDefaultValue=EFalse) const;
sl@0
    90
	//
sl@0
    91
	void Dump() const;
sl@0
    92
private:
sl@0
    93
	TInt Find(const char* aProperty) const;
sl@0
    94
	const char* Insert(TInt aIndex, const char* aProperty, const char* aValue);
sl@0
    95
private:
sl@0
    96
	SEntry* iEntries;
sl@0
    97
	TInt iCount;
sl@0
    98
	TInt iSize;
sl@0
    99
	};
sl@0
   100
sl@0
   101
class Wins : public Asic
sl@0
   102
	{
sl@0
   103
public:
sl@0
   104
	Wins();
sl@0
   105
	//
sl@0
   106
	TInt Init(TBool aRunExe);
sl@0
   107
	inline void InstallUi(DWinsUiBase& aUi);
sl@0
   108
	TInt EmulatorHal(TInt aFunction, TAny* a1, TAny* a2);
sl@0
   109
private:
sl@0
   110
	// initialisation
sl@0
   111
	void Init1();
sl@0
   112
	void Init3();
sl@0
   113
	void AddressInfo(SAddressInfo& anInfo);
sl@0
   114
sl@0
   115
	// power management
sl@0
   116
	void Idle();
sl@0
   117
sl@0
   118
	// timing
sl@0
   119
	TInt MsTickPeriod();
sl@0
   120
	TInt SystemTimeInSecondsFrom2000(TInt& aTime);
sl@0
   121
	TInt SetSystemTimeInSecondsFrom2000(TInt aTime);
sl@0
   122
sl@0
   123
	// HAL
sl@0
   124
	TInt VariantHal(TInt aFunction, TAny* a1, TAny* a2);
sl@0
   125
sl@0
   126
	// Machine configuration
sl@0
   127
	TPtr8 MachineConfiguration();
sl@0
   128
	const char* EmulatorMediaPath();
sl@0
   129
sl@0
   130
	// Debug trace
sl@0
   131
	void DebugPrint(const TDesC8& aDes);
sl@0
   132
	TBool ErrorDialog(TError aType, const TDesC8& aPanic, TInt aVal);
sl@0
   133
	void EarlyLogging(const char* aMessage1,const char* aMessage2);
sl@0
   134
private:
sl@0
   135
	TInt InitProperties(TBool aRunExe);
sl@0
   136
	TInt DebugMask();
sl@0
   137
	TUint32 KernelConfigFlags();
sl@0
   138
	TInt ParseCapabilitiesArg(SCapabilitySet& aCapabilities, const char *aText);
sl@0
   139
	void DisabledCapabilities(SCapabilitySet& aCapabilities);
sl@0
   140
	void CalibrateCpuSpeed();
sl@0
   141
	TInt SetCpuSpeed(TUint aSpeed);
sl@0
   142
	TInt AddProperty(char* aProperty, const char* aEol);
sl@0
   143
	TInt ProcessCommandLine(TBool aRunExe, char* aCDrive);
sl@0
   144
	TInt LoadProperties();
sl@0
   145
	TInt ReadProperties(char* aData);
sl@0
   146
	TInt ReadIniFile(const char* aFileName, char*& aContents);
sl@0
   147
	TInt SetupPaths();
sl@0
   148
	TInt SetupMediaPath();
sl@0
   149
	TInt SetupDrive(int aDrive, const char* aPath);
sl@0
   150
	TInt MapFilename(const TDesC& aFilename, TDes& aBuffer) const;
sl@0
   151
	TInt MapDrive(int aDrive, TDes& aBuffer) const;
sl@0
   152
	HANDLE DebugOutput();
sl@0
   153
	void PurgeImages();
sl@0
   154
	TBool ConfigSpecificProperty(const char * aProperty);
sl@0
   155
	TInt LoadConfigSpecificProperties(const char * pFile);
sl@0
   156
	TBool ScreenSpecificProperty(const char * aProperty);
sl@0
   157
sl@0
   158
private:
sl@0
   159
	friend class DWinsPowerController;
sl@0
   160
	DWinsUiBase* iUi;
sl@0
   161
	WinsTimer iTimer;
sl@0
   162
	Properties iProperties;
sl@0
   163
	TUint iRealCpuSpeed;
sl@0
   164
	TUint iCpuSpeed;
sl@0
   165
	HANDLE iDebugOutput;
sl@0
   166
	TBool iLogTimeStamp;
sl@0
   167
	TBool iPurgedImages;
sl@0
   168
	TBool iLogToDebugger;
sl@0
   169
	TBool iLogToFile;
sl@0
   170
	TBool iConfigPropertySet;
sl@0
   171
	TInt iConfigId;
sl@0
   172
sl@0
   173
	class DWinsPowerController* iPowerController;
sl@0
   174
	// For MMC emulation
sl@0
   175
	static TBool MediaDoorOpen;
sl@0
   176
	static TInt CurrentPBusDevice;
sl@0
   177
	static TAny* MediaChangeCallbackParam;
sl@0
   178
	static TMediaChangeCallBack MediaChangeCallBackPtr;
sl@0
   179
public:
sl@0
   180
	static Wins* Self()
sl@0
   181
		{ return (Wins*) Arch::TheAsic();}
sl@0
   182
	IMPORT_C void AssertWakeupSignal();
sl@0
   183
	IMPORT_C void WakeupEvent();
sl@0
   184
	IMPORT_C static TBool* MediaDoorOpenPtr();
sl@0
   185
	IMPORT_C static TInt* CurrentPBusDevicePtr();
sl@0
   186
	IMPORT_C static void SetMediaChangeCallBackPtr(TMediaChangeCallBack aPtr, TAny* aParam);
sl@0
   187
	IMPORT_C static void MediaChangeCallBack();
sl@0
   188
	};
sl@0
   189
sl@0
   190
GLREF_D Wins TheVariant;
sl@0
   191
sl@0
   192
#endif