// E32HAL.H
//
// Copyright (c) 1995-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__E32HAL_H__)
#define __E32HAL_H__
#if !defined(__E32STD_H__)
#include <e32std.h>
#endif

const TInt KMaxRomDevices=8;

const TUint KLedMaskRed1=0x00000001;
const TUint KLedMaskGreen1=0x00000002;
const TUint KLedMaskYellow1=0x00000004;

const TUint KSupplyFlagSoundWarning=0x00000001;
const TUint KSupplyFlagBacklightWarning=0x00000002;
const TUint KSupplyFlagTimeChanged=0x80000000;

enum TDigitizerCalibrationType
    {
    EFactory,
    ESaved
    };

class TDigitizerCalibration
    {
public:
    TPoint iTl;
    TPoint iBl;
    TPoint iTr;
    TPoint iBr;
    };

enum TMachineStartupType
	{
	EStartupCold,EStartupColdReset,EStartupNewOs,
	EStartupPowerFail,EStartupWarmReset,EStartupKernelFault,
	EStartupSafeReset
	};

enum TBatteryType
	{
	EBatteryTypeNone,EBatteryTypeAlkaline,
	EBatteryTypeNicad,EBatteryTypeLeadAcid,
	EBatteryTypeLithium,EBatteryTypeLithiumIon,
	EBatteryTypeMetalHydride,
	EBatteryTypeUnknown=KMaxTInt
	};

enum TBacklightBehavior
	{
	EBacklightBehaviorTimed,EBacklightBehaviorUntimed
	};

enum TAutoSwitchOffBehavior
    {
    ESwitchOffDisabled,ESwitchOffEnabledOnBatteries,ESwitchOffEnabledAlways
    };

enum TAutoSwitchOffType
    {
    ESwitchOffHard,ESwitchOffEvent
    };

enum TSupplyStatus
    {
    EZero,EVeryLow,ELow,EGood
    };

class TSupplyInfoV1
    {
public:
    TTime iMainBatteryInsertionTime;
    TSupplyStatus iMainBatteryStatus;
    TTimeIntervalMicroSeconds iMainBatteryInUseMicroSeconds;
    TInt iCurrentConsumptionMilliAmps;
    TInt iMainBatteryConsumedMilliAmpSeconds;
    TInt iMainBatteryMilliVolts;
    TInt iMainBatteryMaxMilliVolts;
    TSupplyStatus iBackupBatteryStatus;
    TInt iBackupBatteryMilliVolts;
    TInt iBackupBatteryMaxMilliVolts;
    TBool iExternalPowerPresent;
    TTimeIntervalMicroSeconds iExternalPowerInUseMicroSeconds;
    TUint iFlags;
	};
typedef TPckgBuf<TSupplyInfoV1> TSupplyInfoV1Buf;

class TMachineInfoV1
	{
public:
	TVersion iRomVersion;
	TInfoName iMachineName;
	TInfoName iDisplayName;
	TInfoName iKeyboardName;
	TInfoName iXYInputName;
	TInfoName iPsuName;
	TBool iXYInputPresent;
	TBool iKeyboardPresent;
	TBool iBacklightPresent;
    TSize iDisplaySizeInPixels;
    TSize iXYInputSizeInPixels;
    TSize iPhysicalScreenSize;
	TPoint iOffsetToDisplayInPixels;
	TInt iKeyboardId;
	TInt iDisplayId;
	TInt64 iMachineUniqueId;
    TUint iLedCapabilities;
    TInfoName iProcessorName;
    TInt iProcessorClockInKHz;
    TInt iSpeedFactor;
    TInt iMaximumDisplayColors;
	};
typedef TPckgBuf<TMachineInfoV1> TMachineInfoV1Buf;

class TMachineInfoV2 : public TMachineInfoV1
	{
public:
	TInt iLanguageIndex;
    TInt iKeyboardIndex;
    };
typedef TPckgBuf<TMachineInfoV2> TMachineInfoV2Buf;

class TMemoryInfoV1
    {
public:
    TInt iTotalRamInBytes;
    TInt iTotalRomInBytes;
    TInt iMaxFreeRamInBytes;
    TInt iFreeRamInBytes;
    TInt iInternalDiskRamInBytes;
    TInt iRegistryRamInBytes;
    TBool iRomIsReprogrammable;
    };
typedef TPckgBuf<TMemoryInfoV1> TMemoryInfoV1Buf;

class TRomInfoEntryV1
	{
public:
    enum TRomTypeV1
    	{
    	ERomTypeRom=0,
    	ERomTypeFlash=1
    	};
	TInt iSize;		    // size of ROM in bytes, 0=no ROM present
	TInt iWidth;		// bus width in bits
	TInt iSpeed;		// number of wait states
	TRomTypeV1 iType;	// 0=ROM, 1=FLASH
	};

class TRomInfoV1
	{
public:
	TRomInfoEntryV1	iEntry[KMaxRomDevices];
	};
typedef TPckgBuf<TRomInfoV1> TRomInfoV1Buf;

class TSoundInfoV1
    {
public:
	TBool iKeyClickEnabled;
	TBool iKeyClickLoud;
	TBool iKeyClickOverridden;
	TBool iPointerClickEnabled;
	TBool iPointerClickLoud;
	TBool iBeepEnabled;
	TBool iBeepLoud;
	TBool iSoundDriverEnabled;
	TBool iSoundDriverLoud;
	TBool iSoundEnabled;
    };
typedef TPckgBuf<TSoundInfoV1> TSoundInfoV1Buf;

class TDriveInfoV1
    {
public:
	TInt iTotalSupportedDrives;
	TInfoName iDriveName[KMaxLocalDrives];
	TInt iTotalSockets;
	TInfoName iSocketName[KMaxPBusSockets];
	};
typedef TPckgBuf<TDriveInfoV1> TDriveInfoV1Buf;

class TOnOffInfoV1
    {
public:
	TAutoSwitchOffBehavior iAutoSwitchOffBehavior;
    TTimeIntervalSeconds iAutoSwitchOffTime;
    TBacklightBehavior iBacklightBehavior;
    TTimeIntervalSeconds iBacklightOnTime;
    TBool iPointerSwitchesOn;
    TBool iCaseOpenSwitchesOn;
    TBool iCaseCloseSwitchesOff;
    };
typedef TPckgBuf<TOnOffInfoV1> TOnOffInfoV1Buf;

class TExcInfo
	{
public:
	TAny *iCodeAddress;
	TAny *iDataAddress;
	TInt iExtraData;
	};

class UserHal
	{
public:
	IMPORT_C static TInt MachineInfo(TDes8& anInfo);
	IMPORT_C static TInt SupplyInfo(TDes8& anInfo);
	IMPORT_C static TInt MemoryInfo(TDes8& anInfo);
	IMPORT_C static TInt SoundInfo(TDes8& anInfo);
	IMPORT_C static TInt DriveInfo(TDes8& anInfo);
	IMPORT_C static TInt OnOffInfo(TDes8& anInfo);
	IMPORT_C static TInt RomInfo(TDes8& anInfo);
    IMPORT_C static TInt SetKeyClickOverridden(TBool aState);
	IMPORT_C static TInt SetKeyClickEnabled(TBool aState);
	IMPORT_C static TInt SetKeyClickLoud(TBool aState);
	IMPORT_C static TInt SetPointerClickLoud(TBool aState);
	IMPORT_C static TInt SetPointerClickEnabled(TBool aState);
	IMPORT_C static TInt SetBeepEnabled(TBool aState);
	IMPORT_C static TInt SetBeepLoud(TBool aState);
	IMPORT_C static TInt SetSoundDriverEnabled(TBool aState);
	IMPORT_C static TInt SetSoundDriverLoud(TBool aState);
	IMPORT_C static TInt SetSoundEnabled(TBool aState);
    IMPORT_C static TInt KeyClickOverridden(TBool& aState);
    IMPORT_C static TInt KeyClickEnabled(TBool& aState);
    IMPORT_C static TInt KeyClickLoud(TBool& aState);
    IMPORT_C static TInt PointerClickEnabled(TBool& aState);
    IMPORT_C static TInt PointerClickLoud(TBool& aState);
    IMPORT_C static TInt KeyClick();
    IMPORT_C static TInt PointerClick();
	IMPORT_C static TInt StartupReason(TMachineStartupType& aReason);
	IMPORT_C static TInt FaultReason(TInt &aReason);
	IMPORT_C static TInt ExceptionId(TInt &anId);
	IMPORT_C static TInt ExceptionInfo(TExcInfo &aInfo);
    IMPORT_C static TInt CpuInfo(TDes8& aInfo);
	IMPORT_C static TInt PageSizeInBytes(TInt& aSize);
	IMPORT_C static TInt MaxDisplayContrast(TInt& aContrast);
	IMPORT_C static TInt SetDisplayContrast(TInt aContrast);
	IMPORT_C static TInt DisplayContrast(TInt& aContrast);
	IMPORT_C static TInt SetAutoSwitchOffBehavior(TAutoSwitchOffBehavior aBehaviour);
	IMPORT_C static TInt AutoSwitchOffBehavior(TAutoSwitchOffBehavior& aBehaviour);
	IMPORT_C static TInt SetAutoSwitchOffTime(TTimeIntervalSeconds aInterval);
	IMPORT_C static TInt AutoSwitchOffTime(TTimeIntervalSeconds& aInterval);
	IMPORT_C static TInt ResetAutoSwitchOffTimer();
   	IMPORT_C static TInt SwitchOff();
	IMPORT_C static TInt SetBacklightBehavior(TBacklightBehavior aBehaviour);
	IMPORT_C static TInt BacklightBehavior(TBacklightBehavior& aBehaviour);
	IMPORT_C static TInt SetBacklightOnTime(TTimeIntervalSeconds aInterval);
	IMPORT_C static TInt BacklightOnTime(TTimeIntervalSeconds& aInterval);
	IMPORT_C static TInt SetBacklightOn(TBool aState);
	IMPORT_C static TInt BacklightOn(TBool& aState);
   	IMPORT_C static TInt SetPointerSwitchesOn(TBool aState);
   	IMPORT_C static TInt PointerSwitchesOn(TBool& aState);
   	IMPORT_C static TInt SetCaseOpenSwitchesOn(TBool aState);
   	IMPORT_C static TInt CaseOpenSwitchesOn(TBool& aState);
   	IMPORT_C static TInt SetCaseCloseSwitchesOff(TBool aState);
   	IMPORT_C static TInt CaseCloseSwitchesOff(TBool& aState);
	IMPORT_C static TInt SetBatteryType(TBatteryType aType);
	IMPORT_C static TInt BatteryType(TBatteryType& aType);
	IMPORT_C static TInt SetBatteryCapacity(TInt aCapacity);
	IMPORT_C static TInt BatteryCapacity(TInt& aCapacity);
   	IMPORT_C static TInt ModifyLedMask(TUint aClearMask,TUint aSetMask);
	IMPORT_C static TInt SetXYInputCalibration(const TDigitizerCalibration& aCalibration);
	IMPORT_C static TInt CalibrationPoints(TDigitizerCalibration& aCalibration);
	IMPORT_C static TInt TickPeriod(TTimeIntervalMicroSeconds32& aPeriod);
	IMPORT_C static TInt SaveXYInputCalibration();
	IMPORT_C static TInt RestoreXYInputCalibration(TDigitizerCalibrationType aType);
	};
#endif

