os/kernelhwsrv/kernel/eka/include/d32ethernet.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/d32ethernet.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,270 @@
     1.4 +// Copyright (c) 1995-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 +// e32\include\d32ethernet.h
    1.18 +// User side class definition for using ethernet support
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file d32ethernet.h
    1.24 + @publishedPartner
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +#ifndef __D32ETHERNET_H__
    1.29 +#define __D32ETHERNET_H__
    1.30 +#include <e32cmn.h>
    1.31 +#include <e32ver.h>
    1.32 +
    1.33 +
    1.34 +/** @addtogroup enet Ethernet Drivers
    1.35 + *  Kernel Ethernet Support
    1.36 + */
    1.37 +
    1.38 +/** @addtogroup enet_external The External Intarface to the Ethernet support
    1.39 + * @ingroup enet
    1.40 + * @{
    1.41 + */
    1.42 +// Ethernet Specific Error Codes
    1.43 +/** Transmit out of memory error */
    1.44 +const TInt KErrTxOutOfMemory = (-302);
    1.45 +/** General Transmit Error */
    1.46 +const TInt KErrTxError       = (-303);
    1.47 +/** Trying to send a frame that is too big */
    1.48 +const TInt KErrTxFrameToBig  = (-304);
    1.49 +/** General Recieve Error */
    1.50 +const TInt KErrRxError       = (-305);
    1.51 +
    1.52 +// Card configuration - speed settings.
    1.53 +/** Ethernet speed unknown */
    1.54 +const TUint8 KEthSpeedUnknown=0x00;
    1.55 +/** Ethernet speed autosensing */
    1.56 +const TUint8 KEthSpeedAuto=0x01;
    1.57 +/** Ethernet speed 10Mbits */
    1.58 +const TUint8 KEthSpeed10BaseT=0x02;
    1.59 +/** Ethernet speed 100Mbits */
    1.60 +const TUint8 KEthSpeed100BaseTX=0x03;
    1.61 +
    1.62 +// Card configuration - duplex settings.
    1.63 +/** Ethernet duplex setting unknown */
    1.64 +const TUint8 KEthDuplexUnknown=0x00;
    1.65 +/** Ethernet duplex setting automatic */
    1.66 +const TUint8 KEthDuplexAuto=0x01;
    1.67 +/** Ethernet full duplex */
    1.68 +const TUint8 KEthDuplexFull=0x02;
    1.69 +/** Ethernet helf duplex */
    1.70 +const TUint8 KEthDuplexHalf=0x03;
    1.71 +
    1.72 +// Default Ethernet Address
    1.73 +const TUint8 KDefEtherAddByte0=0x30; // MSB
    1.74 +const TUint8 KDefEtherAddByte1=0x32;
    1.75 +const TUint8 KDefEtherAddByte2=0x33;
    1.76 +const TUint8 KDefEtherAddByte3=0x34;
    1.77 +const TUint8 KDefEtherAddByte4=0x35;
    1.78 +const TUint8 KDefEtherAddByte5=0x36; // LSB
    1.79 +
    1.80 +/** Ethernet address length */
    1.81 +const TUint KEthernetAddressLength=6;
    1.82 +
    1.83 +/**
    1.84 + * The ethernet configuration class
    1.85 + */
    1.86 +class TEthernetConfigV01
    1.87 +    {
    1.88 +    public:
    1.89 +    /**
    1.90 +     * The speed 
    1.91 +     */
    1.92 +    TUint8 iEthSpeed;
    1.93 +    /**
    1.94 +     * The duplex setting
    1.95 +     */
    1.96 +    TUint8 iEthDuplex;
    1.97 +    /** 
    1.98 +     * The MAC address
    1.99 +     */
   1.100 +    TUint8 iEthAddress[KEthernetAddressLength];
   1.101 +    };
   1.102 +typedef TPckgBuf<TEthernetConfigV01> TEthernetConfig;
   1.103 +
   1.104 +/**
   1.105 + * The ethernet capibility class
   1.106 + */
   1.107 +class TEthernetCapsV01
   1.108 +    {
   1.109 +    public:
   1.110 +
   1.111 +    };
   1.112 +typedef TPckgBuf<TEthernetCapsV01> TEthernetCaps;
   1.113 +
   1.114 +/**
   1.115 + * The Ethernet device capibility class
   1.116 + */
   1.117 +class TCapsDevEthernetV01
   1.118 +    {
   1.119 +    public:
   1.120 +    /**
   1.121 +     * The device version
   1.122 +     */
   1.123 +    TVersion version;
   1.124 +    };
   1.125 +
   1.126 +    
   1.127 +#ifdef ETH_CHIP_IO_ENABLED
   1.128 +enum TMemSpace 
   1.129 +    {
   1.130 +    BGE_SPACE_CFG =  0,       /* PCI config space */
   1.131 +    BGE_SPACE_REG = 1,       /* PCI memory space */
   1.132 +    BGE_SPACE_NIC =  2,       /* on-chip memory   */
   1.133 +    BGE_SPACE_MII =  3,       /* PHY's MII registers  */
   1.134 +    BGE_SPACE_BGE =  4,       /* driver's soft state  */
   1.135 +    BGE_SPACE_TXDESC = 5,       /* TX descriptors   */
   1.136 +    BGE_SPACE_TXBUFF = 6,       /* TX buffers       */
   1.137 +    BGE_SPACE_RXDESC = 7,       /* RX descriptors   */
   1.138 +    BGE_SPACE_RXBUFF = 8,       /* RX buffers       */
   1.139 +    BGE_SPACE_STATUS = 9,       /* status block     */
   1.140 +    BGE_SPACE_STATISTICS = 10,      /* statistics block */
   1.141 +    BGE_SPACE_SEEPROM =  11,      /* SEEPROM (if fitted)  */
   1.142 +    BGE_SPACE_FLASH = 12      /* FLASH (if fitted)    */
   1.143 +    };
   1.144 +
   1.145 +struct TChipIOInfo
   1.146 +    {
   1.147 +    TUint32 iSize; /* in bytes: 1,2,4,8    */
   1.148 +    TUint32 iSpace; /* See #defines below   */
   1.149 +    TUint32 iOffset;
   1.150 +    TUint32 iData; /* output for peek  */
   1.151 +    TUint32 iCnt; /* number of contigues items to be dumped*/
   1.152 +    };   
   1.153 +#endif 
   1.154 +
   1.155 +
   1.156 +/**
   1.157 +@publishedPartner
   1.158 +@released
   1.159 +
   1.160 +The externally visible interface
   1.161 +*/
   1.162 +class RBusDevEthernet : public RBusLogicalChannel 
   1.163 +    {
   1.164 +    public:
   1.165 +	
   1.166 +	enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
   1.167 +
   1.168 +    /**
   1.169 +     * Asyncorus requests
   1.170 +     */
   1.171 +    enum TRequest
   1.172 +	{
   1.173 +	ERequestRead=0x0,         /**< Read request */
   1.174 +        ERequestReadCancel=0x1,   /**< Cancel read request */
   1.175 +	ERequestWrite=0x1,        /**< Write request */
   1.176 +        ERequestWriteCancel=0x2   /**< Cancel write request */
   1.177 +#ifdef ETH_CHIP_IO_ENABLED
   1.178 +    ,EChipDiagIOCtrl=0x3
   1.179 +#endif
   1.180 +	};
   1.181 +
   1.182 +    /**
   1.183 +     * Control requests
   1.184 +     */
   1.185 +    enum TControl
   1.186 +	{
   1.187 +	EControlConfig,    /**< Get the current configuration */
   1.188 +        EControlSetConfig, /**< Set the current configuration */
   1.189 +        EControlSetMac,    /**< Set the MAC address */
   1.190 +        EControlCaps       /**< Get ethernet capibilites */
   1.191 +	};
   1.192 +
   1.193 +    public:
   1.194 +#ifndef __KLIB_H__
   1.195 +    /**
   1.196 +     * Open a channel
   1.197 +     * @param aUnit The channel number to open
   1.198 +     */
   1.199 +    inline TInt Open(TInt aUnit);
   1.200 +    /**
   1.201 +     * Get the ethernet version
   1.202 +     * @return The version
   1.203 +     */
   1.204 +    inline TVersion VersionRequired() const;
   1.205 +    /**
   1.206 +     * Read from the channel
   1.207 +     * @param aStatus The callback status 
   1.208 +     * @param aDes Buffer to be filled in
   1.209 +     */
   1.210 +    inline void Read(TRequestStatus &aStatus,TDes8 &aDes);
   1.211 +    /**
   1.212 +     * Read from the channel
   1.213 +     * @param aStatus The callback status 
   1.214 +     * @param aDes Buffer to be filled in
   1.215 +     * @param aLength The maximun length frame to read
   1.216 +     */
   1.217 +    inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength);
   1.218 +    /**
   1.219 +     * Cancel a pending read request
   1.220 +     */
   1.221 +    inline void ReadCancel();
   1.222 +
   1.223 +    /**
   1.224 +     * Write to the channel
   1.225 +     * @param aStatus The callback status 
   1.226 +     * @param aDes Buffer containing the frame to be sent
   1.227 +     */
   1.228 +    inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes);
   1.229 +    /**
   1.230 +     * Write to the channel
   1.231 +     * @param aStatus The callback status 
   1.232 +     * @param aDes Buffer containing the frame to be sent
   1.233 +     * @param aLength The length of the frame to send
   1.234 +     */
   1.235 +    inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength);
   1.236 +    /**
   1.237 +     * Cancel a pending write request
   1.238 +     */
   1.239 +    inline void WriteCancel();
   1.240 +
   1.241 +    /**
   1.242 +     * Get the channels configuration
   1.243 +     * @param aConfig Buffer that will contain an configuration object
   1.244 +     */
   1.245 +    inline void Config(TDes8 &aConfig);
   1.246 +    /**
   1.247 +     * Set the channels configuration
   1.248 +     * @param aConfig Buffer containing an configuration object
   1.249 +     */
   1.250 +    inline TInt SetConfig(const TDesC8 &aConfig);
   1.251 +    /**
   1.252 +     * Set the channels MAC address
   1.253 +     * @param aConfig Buffer containing an configuration object with the MAC 
   1.254 +     * address set
   1.255 +     */
   1.256 +    inline TInt SetMAC(const TDesC8 &aConfig);
   1.257 +
   1.258 +    /**
   1.259 +     * Request the channels capabilities
   1.260 +     * @param aCaps Buffer to contain the capibilites object
   1.261 +     */
   1.262 +    inline void Caps(TDes8 &aCaps);
   1.263 +    
   1.264 +#ifdef ETH_CHIP_IO_ENABLED    
   1.265 +    inline void ChipIOCtrl(TRequestStatus &aStatus,TPckgBuf<TChipIOInfo> &aDes);
   1.266 +#endif
   1.267 +    #endif
   1.268 +    };
   1.269 +
   1.270 +/** @} */ // End of external interface
   1.271 +#include <d32ethernet.inl>
   1.272 +
   1.273 +#endif