navienginebsp/ne1_tb/rebootdrv/rebootdrv.cpp
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * bsp\hwip_nec_naviengine\ne1_tb\rebootdrv.cpp
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef NAVIREBOOT_H
       
    22 #define NAVIREBOOT_H
       
    23 #include <rebootdrv.h>
       
    24 #include <rebootdrv_ldd.h>
       
    25 #include <naviengine.h>
       
    26 #endif //NAVIREBBOT_H
       
    27 
       
    28 /**
       
    29  * Class Constructor
       
    30  */
       
    31 DLddDeviceReboot::DLddDeviceReboot()
       
    32 	{
       
    33 	iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
       
    34 	//No units, no info, no PDD
       
    35 	}
       
    36 
       
    37 /**
       
    38  * Implementatin of Create method of DLogicalDevice
       
    39  */
       
    40 TInt DLddDeviceReboot::Create(DLogicalChannelBase*& aChannel)
       
    41     {
       
    42 	aChannel=new DLddReboot;
       
    43 	return aChannel?KErrNone:KErrNoMemory;
       
    44     }
       
    45 
       
    46 /**
       
    47  * Implementatin of Install method of DLogicalDevice
       
    48  */
       
    49 TInt DLddDeviceReboot::Install()
       
    50 	{
       
    51 	return SetName(&KRebootLddName);
       
    52 	}
       
    53 
       
    54 /**
       
    55  * Implementatin of GetCaps method of DLogicalDevice
       
    56  */
       
    57 void DLddDeviceReboot::GetCaps(TDes8 &aDes) const
       
    58 	{
       
    59 	TCapsRebootV1 b;
       
    60 	b.version=iVersion;
       
    61 	aDes.FillZ(aDes.MaxLength());
       
    62 	aDes.Copy((TUint8 *)&b,Min(aDes.MaxLength(),sizeof(b)));
       
    63 	}
       
    64 
       
    65 /**
       
    66  * Class Constructor
       
    67  */
       
    68 DLddReboot::DLddReboot()
       
    69 	{
       
    70 	// we are in client's thread context, let's make sure that it knows about us
       
    71 	iClient=&Kern::CurrentThread();
       
    72 	((DObject*)iClient)->Open();
       
    73 	}
       
    74 
       
    75 /**
       
    76  * Class Destructor
       
    77  */
       
    78 DLddReboot::~DLddReboot()
       
    79 	{
       
    80 	Kern::SafeClose((DObject*&)iClient, NULL);
       
    81 	}
       
    82 
       
    83 /**
       
    84  * Implementation of GetCaps method of DLogicalChannelBase
       
    85  */
       
    86 
       
    87 TInt DLddReboot::Request(TInt aReqNo,TAny* a1,TAny* a2)
       
    88 	{
       
    89 	// we are in client's thread context, let's make sure we aren't
       
    90 	// killed or suspended
       
    91 	NKern::ThreadEnterCS();		
       
    92 	
       
    93 	switch (aReqNo)
       
    94 		{
       
    95 	case RReboot::EReboot:
       
    96 		{
       
    97 		TNandMediaInfo mediaInfo;
       
    98 		NKern::ThreadLeaveCS(); // leave CS as getting mediaInfo may kill us
       
    99 		kumemget(&mediaInfo,a1,sizeof(mediaInfo));
       
   100 		NKern::ThreadEnterCS();
       
   101 		(void)Reboot(mediaInfo);
       
   102 		}
       
   103 		break;
       
   104 	case RReboot::EGenericReboot:
       
   105 		{
       
   106 		(void)GenericReboot();
       
   107 		}
       
   108 	default:
       
   109 		break;
       
   110 		}
       
   111 	
       
   112 	NKern::ThreadLeaveCS();			// unnecessary we should be dead by now...
       
   113 	return KErrNone;
       
   114 	}
       
   115 
       
   116 TInt DLddReboot::Reboot(TNandMediaInfo& /*aNandMediaInfo*/)
       
   117 	{
       
   118 	// indicate to boot loader that NAND mini boot routine is required
       
   119 	Kern::Restart(TInt(KtRestartReasonNANDImage ));
       
   120 	return KErrNone;
       
   121 	}
       
   122 
       
   123 
       
   124 TInt DLddReboot::GenericReboot()
       
   125 	{
       
   126 	Kern::Restart(KtRestartReasonHardRestart);
       
   127 	return KErrNone;
       
   128 	}
       
   129 
       
   130 /*
       
   131  * LDD Entry point
       
   132  */
       
   133 DECLARE_STANDARD_LDD()
       
   134 	{
       
   135     return new DLddDeviceReboot;
       
   136     }
       
   137 
       
   138 // @}
       
   139