os/kernelhwsrv/kerneltest/e32test/system/t_reason.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/system/t_reason.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,72 @@
     1.4 +// Copyright (c) 1997-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\system\t_reason.cpp
    1.18 +// Debugging aid which prints the ESHELL startup banner down the serial port, as an
    1.19 +// aid to debugging repeated bleep-bleep-bleep restarting. 
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#include "e32std.h"
    1.24 +#include "e32std_private.h"
    1.25 +#include "e32svr.h"
    1.26 +#include "e32hal.h"
    1.27 +
    1.28 +TUint j;
    1.29 +
    1.30 +TInt E32Main()
    1.31 +	{
    1.32 +
    1.33 +	FOREVER
    1.34 +		{
    1.35 +		TMachineStartupType reason;
    1.36 +		UserHal::StartupReason(reason);
    1.37 +		switch (reason)
    1.38 +			{
    1.39 +			case EStartupCold:		RDebug::Print(_L("Cold Start    ")); break;
    1.40 +			case EStartupColdReset: 	RDebug::Print(_L("Cold Reset    ")); break;
    1.41 +			case EStartupNewOs: 		RDebug::Print(_L("New OS        ")); break;
    1.42 +			case EStartupPowerFail:		RDebug::Print(_L("Power failed  ")); break;
    1.43 +			case EStartupWarmReset:		RDebug::Print(_L("Warm Reset    ")); break;
    1.44 +			case EStartupKernelFault:	
    1.45 +				TInt faultno;
    1.46 +				UserHal::FaultReason(faultno);
    1.47 +				if (faultno == 0x10000000)
    1.48 +					RDebug::Print(_L("Kernel Exception  "));
    1.49 +				else
    1.50 +				if (faultno >= 0x10000)
    1.51 +					RDebug::Print(_L("Kernel PANIC: %d  "), faultno-0x10000);
    1.52 +				else
    1.53 +					RDebug::Print(_L("Kernel FAULT: %d  "), faultno);
    1.54 +				break;
    1.55 +			case EStartupSafeReset:		RDebug::Print(_L("Safe Reset    ")); break;
    1.56 +			default:
    1.57 +				RDebug::Print(_L("<?reason=%d>  "), reason);
    1.58 +				break;
    1.59 +			}
    1.60 +
    1.61 +		if (reason==EStartupWarmReset || reason==EStartupPowerFail || reason==EStartupKernelFault)
    1.62 +			{
    1.63 +			TInt exceptno;
    1.64 +			TExcInfo exceptInfo;
    1.65 +			UserHal::ExceptionId(exceptno);
    1.66 +			UserHal::ExceptionInfo(exceptInfo);
    1.67 +			RDebug::Print(_L("(last exception %d: code %08x data %08x) "), exceptno, exceptInfo.iCodeAddress,exceptInfo.iDataAddress);
    1.68 +			}
    1.69 +
    1.70 +		RDebug::Print(_L("\r\n\nCopyright (C) 1997-1999 Symbian Ltd\r\n\n"));
    1.71 +
    1.72 +		for (TInt i=0; i<1000000; i++)
    1.73 +			j=i%17;	// waste some time
    1.74 +		}
    1.75 +	}