baseport/src/cedar/generic/base/syborg/ethernet/pdd/ethernet.cpp
changeset 0 ffa851df0825
equal deleted inserted replaced
-1:000000000000 0:ffa851df0825
       
     1 /*
       
     2 * Copyright (c) 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 the License "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 *
       
    16 */
       
    17 
       
    18 #include <ethernet.h>
       
    19 #include <e32hal.h>
       
    20 #include <system.h>
       
    21 #include "ethernet_device.h"
       
    22 
       
    23 #pragma diag_suppress 1441
       
    24 
       
    25 _LIT(KEthPddName, "Ethernet.Syborg");
       
    26 
       
    27 // needs ldd version..
       
    28 const TInt KMinimumLddMajorVersion	= 1;
       
    29 const TInt KMinimumLddMinorVersion	= 0;
       
    30 const TInt KMinimumLddBuild			= 122;
       
    31 
       
    32 //
       
    33 // Class to identify the driver as PDD
       
    34 //
       
    35 class DDriverEthernet : public DPhysicalDevice
       
    36 {
       
    37 public:
       
    38 	DDriverEthernet();
       
    39 	
       
    40 	//
       
    41 	// Functions that we must implement as we are inheriting from abstract base class
       
    42 	//
       
    43 	virtual TInt Install();
       
    44 	virtual void GetCaps(TDes8 &aDes) const;
       
    45 	virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
       
    46 	virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
       
    47 };
       
    48 
       
    49 //////////////////////////////////////////
       
    50 // Implementation of DDriverEthernet class
       
    51 //////////////////////////////////////////
       
    52 
       
    53 DDriverEthernet::DDriverEthernet()
       
    54 {
       
    55 	DP("** (PDD) DDriverEthernet::DDriverEthernet()");
       
    56 	__KTRACE_OPT(KHARDWARE, Kern::Printf("DDriverEthernet::DDriverEthernet()"));
       
    57 	
       
    58 	iUnitsMask=0x1;	
       
    59 	iVersion=TVersion(KEthernetMajorVersionNumber,
       
    60 					  KEthernetMinorVersionNumber,
       
    61 					  KEthernetBuildVersionNumber);
       
    62 }
       
    63 
       
    64 TInt DDriverEthernet::Install()
       
    65 {
       
    66 	DP("** (PDD) DDriverEthernet::Install()");
       
    67 	__KTRACE_OPT(KHARDWARE, Kern::Printf("DDriverEthernet::Install()"));
       
    68 	
       
    69 	return SetName(&KEthPddName);
       
    70 }
       
    71 
       
    72 void DDriverEthernet::GetCaps(TDes8 &aDes) const
       
    73 {
       
    74 	DP("** (PDD) DDriverEthernet::GetCaps");
       
    75 	__KTRACE_OPT(KHARDWARE, Kern::Printf("DDriverEthernet::GetCaps"));
       
    76 	
       
    77 	TEthernetCaps capsBuf;
       
    78 
       
    79 	aDes.FillZ(aDes.MaxLength());
       
    80 	aDes=capsBuf.Left(Min(capsBuf.Length(),aDes.MaxLength()));
       
    81 }
       
    82 
       
    83 TInt DDriverEthernet::Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer)
       
    84 {
       
    85 	DP("** (PDD) DDriverEthernet::Create");
       
    86 	__KTRACE_OPT(KHARDWARE, Kern::Printf("DDriverEthernet::Create"));
       
    87 	
       
    88     TInt r = KErrNoMemory;
       
    89 
       
    90 	EthernetDevice	*VirtioEthernet = new EthernetDevice;
       
    91 	if(VirtioEthernet)
       
    92 		{
       
    93 		DP("** (PDD) DDriverEthernet:: EthernetDevice created successfully");
       
    94 		r = VirtioEthernet->DoCreate(aUnit, anInfo);
       
    95 		}
       
    96 	aChannel = VirtioEthernet;
       
    97        return r;
       
    98 }
       
    99 
       
   100 TInt DDriverEthernet::Validate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer)
       
   101 {
       
   102 	DP("** (PDD) DDriverEthernet::Validate");
       
   103 	__KTRACE_OPT(KHARDWARE, Kern::Printf("DDriverEthernet::Validate"));
       
   104 	
       
   105 	if((!Kern::QueryVersionSupported(iVersion,aVer)) || 
       
   106 		(!Kern::QueryVersionSupported(aVer,TVersion(KMinimumLddMajorVersion,
       
   107 													KMinimumLddMinorVersion,
       
   108 													KMinimumLddBuild))))
       
   109 	{
       
   110 		return KErrNotSupported;
       
   111 	}
       
   112 	if(aUnit != 0)
       
   113 	{
       
   114 		return KErrNotSupported;
       
   115 	}
       
   116 	return KErrNone;
       
   117 }
       
   118 
       
   119 DECLARE_STANDARD_PDD()
       
   120 {
       
   121 	DP("** (DPhysicalDevice) Ethernet PDD Factory created");
       
   122 	return new DDriverEthernet;
       
   123 }