|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\include\d32ethernet.h |
|
15 // User side class definition for using ethernet support |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file d32ethernet.h |
|
21 @publishedPartner |
|
22 @released |
|
23 */ |
|
24 |
|
25 #ifndef __D32ETHERNET_H__ |
|
26 #define __D32ETHERNET_H__ |
|
27 #include <e32cmn.h> |
|
28 #include <e32ver.h> |
|
29 |
|
30 |
|
31 /** @addtogroup enet Ethernet Drivers |
|
32 * Kernel Ethernet Support |
|
33 */ |
|
34 |
|
35 /** @addtogroup enet_external The External Intarface to the Ethernet support |
|
36 * @ingroup enet |
|
37 * @{ |
|
38 */ |
|
39 // Ethernet Specific Error Codes |
|
40 /** Transmit out of memory error */ |
|
41 const TInt KErrTxOutOfMemory = (-302); |
|
42 /** General Transmit Error */ |
|
43 const TInt KErrTxError = (-303); |
|
44 /** Trying to send a frame that is too big */ |
|
45 const TInt KErrTxFrameToBig = (-304); |
|
46 /** General Recieve Error */ |
|
47 const TInt KErrRxError = (-305); |
|
48 |
|
49 // Card configuration - speed settings. |
|
50 /** Ethernet speed unknown */ |
|
51 const TUint8 KEthSpeedUnknown=0x00; |
|
52 /** Ethernet speed autosensing */ |
|
53 const TUint8 KEthSpeedAuto=0x01; |
|
54 /** Ethernet speed 10Mbits */ |
|
55 const TUint8 KEthSpeed10BaseT=0x02; |
|
56 /** Ethernet speed 100Mbits */ |
|
57 const TUint8 KEthSpeed100BaseTX=0x03; |
|
58 |
|
59 // Card configuration - duplex settings. |
|
60 /** Ethernet duplex setting unknown */ |
|
61 const TUint8 KEthDuplexUnknown=0x00; |
|
62 /** Ethernet duplex setting automatic */ |
|
63 const TUint8 KEthDuplexAuto=0x01; |
|
64 /** Ethernet full duplex */ |
|
65 const TUint8 KEthDuplexFull=0x02; |
|
66 /** Ethernet helf duplex */ |
|
67 const TUint8 KEthDuplexHalf=0x03; |
|
68 |
|
69 // Default Ethernet Address |
|
70 const TUint8 KDefEtherAddByte0=0x30; // MSB |
|
71 const TUint8 KDefEtherAddByte1=0x32; |
|
72 const TUint8 KDefEtherAddByte2=0x33; |
|
73 const TUint8 KDefEtherAddByte3=0x34; |
|
74 const TUint8 KDefEtherAddByte4=0x35; |
|
75 const TUint8 KDefEtherAddByte5=0x36; // LSB |
|
76 |
|
77 /** Ethernet address length */ |
|
78 const TUint KEthernetAddressLength=6; |
|
79 |
|
80 /** |
|
81 * The ethernet configuration class |
|
82 */ |
|
83 class TEthernetConfigV01 |
|
84 { |
|
85 public: |
|
86 /** |
|
87 * The speed |
|
88 */ |
|
89 TUint8 iEthSpeed; |
|
90 /** |
|
91 * The duplex setting |
|
92 */ |
|
93 TUint8 iEthDuplex; |
|
94 /** |
|
95 * The MAC address |
|
96 */ |
|
97 TUint8 iEthAddress[KEthernetAddressLength]; |
|
98 }; |
|
99 typedef TPckgBuf<TEthernetConfigV01> TEthernetConfig; |
|
100 |
|
101 /** |
|
102 * The ethernet capibility class |
|
103 */ |
|
104 class TEthernetCapsV01 |
|
105 { |
|
106 public: |
|
107 |
|
108 }; |
|
109 typedef TPckgBuf<TEthernetCapsV01> TEthernetCaps; |
|
110 |
|
111 /** |
|
112 * The Ethernet device capibility class |
|
113 */ |
|
114 class TCapsDevEthernetV01 |
|
115 { |
|
116 public: |
|
117 /** |
|
118 * The device version |
|
119 */ |
|
120 TVersion version; |
|
121 }; |
|
122 |
|
123 |
|
124 #ifdef ETH_CHIP_IO_ENABLED |
|
125 enum TMemSpace |
|
126 { |
|
127 BGE_SPACE_CFG = 0, /* PCI config space */ |
|
128 BGE_SPACE_REG = 1, /* PCI memory space */ |
|
129 BGE_SPACE_NIC = 2, /* on-chip memory */ |
|
130 BGE_SPACE_MII = 3, /* PHY's MII registers */ |
|
131 BGE_SPACE_BGE = 4, /* driver's soft state */ |
|
132 BGE_SPACE_TXDESC = 5, /* TX descriptors */ |
|
133 BGE_SPACE_TXBUFF = 6, /* TX buffers */ |
|
134 BGE_SPACE_RXDESC = 7, /* RX descriptors */ |
|
135 BGE_SPACE_RXBUFF = 8, /* RX buffers */ |
|
136 BGE_SPACE_STATUS = 9, /* status block */ |
|
137 BGE_SPACE_STATISTICS = 10, /* statistics block */ |
|
138 BGE_SPACE_SEEPROM = 11, /* SEEPROM (if fitted) */ |
|
139 BGE_SPACE_FLASH = 12 /* FLASH (if fitted) */ |
|
140 }; |
|
141 |
|
142 struct TChipIOInfo |
|
143 { |
|
144 TUint32 iSize; /* in bytes: 1,2,4,8 */ |
|
145 TUint32 iSpace; /* See #defines below */ |
|
146 TUint32 iOffset; |
|
147 TUint32 iData; /* output for peek */ |
|
148 TUint32 iCnt; /* number of contigues items to be dumped*/ |
|
149 }; |
|
150 #endif |
|
151 |
|
152 |
|
153 /** |
|
154 @publishedPartner |
|
155 @released |
|
156 |
|
157 The externally visible interface |
|
158 */ |
|
159 class RBusDevEthernet : public RBusLogicalChannel |
|
160 { |
|
161 public: |
|
162 |
|
163 enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber}; |
|
164 |
|
165 /** |
|
166 * Asyncorus requests |
|
167 */ |
|
168 enum TRequest |
|
169 { |
|
170 ERequestRead=0x0, /**< Read request */ |
|
171 ERequestReadCancel=0x1, /**< Cancel read request */ |
|
172 ERequestWrite=0x1, /**< Write request */ |
|
173 ERequestWriteCancel=0x2 /**< Cancel write request */ |
|
174 #ifdef ETH_CHIP_IO_ENABLED |
|
175 ,EChipDiagIOCtrl=0x3 |
|
176 #endif |
|
177 }; |
|
178 |
|
179 /** |
|
180 * Control requests |
|
181 */ |
|
182 enum TControl |
|
183 { |
|
184 EControlConfig, /**< Get the current configuration */ |
|
185 EControlSetConfig, /**< Set the current configuration */ |
|
186 EControlSetMac, /**< Set the MAC address */ |
|
187 EControlCaps /**< Get ethernet capibilites */ |
|
188 }; |
|
189 |
|
190 public: |
|
191 #ifndef __KLIB_H__ |
|
192 /** |
|
193 * Open a channel |
|
194 * @param aUnit The channel number to open |
|
195 */ |
|
196 inline TInt Open(TInt aUnit); |
|
197 /** |
|
198 * Get the ethernet version |
|
199 * @return The version |
|
200 */ |
|
201 inline TVersion VersionRequired() const; |
|
202 /** |
|
203 * Read from the channel |
|
204 * @param aStatus The callback status |
|
205 * @param aDes Buffer to be filled in |
|
206 */ |
|
207 inline void Read(TRequestStatus &aStatus,TDes8 &aDes); |
|
208 /** |
|
209 * Read from the channel |
|
210 * @param aStatus The callback status |
|
211 * @param aDes Buffer to be filled in |
|
212 * @param aLength The maximun length frame to read |
|
213 */ |
|
214 inline void Read(TRequestStatus &aStatus,TDes8 &aDes,TInt aLength); |
|
215 /** |
|
216 * Cancel a pending read request |
|
217 */ |
|
218 inline void ReadCancel(); |
|
219 |
|
220 /** |
|
221 * Write to the channel |
|
222 * @param aStatus The callback status |
|
223 * @param aDes Buffer containing the frame to be sent |
|
224 */ |
|
225 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes); |
|
226 /** |
|
227 * Write to the channel |
|
228 * @param aStatus The callback status |
|
229 * @param aDes Buffer containing the frame to be sent |
|
230 * @param aLength The length of the frame to send |
|
231 */ |
|
232 inline void Write(TRequestStatus &aStatus,const TDesC8 &aDes,TInt aLength); |
|
233 /** |
|
234 * Cancel a pending write request |
|
235 */ |
|
236 inline void WriteCancel(); |
|
237 |
|
238 /** |
|
239 * Get the channels configuration |
|
240 * @param aConfig Buffer that will contain an configuration object |
|
241 */ |
|
242 inline void Config(TDes8 &aConfig); |
|
243 /** |
|
244 * Set the channels configuration |
|
245 * @param aConfig Buffer containing an configuration object |
|
246 */ |
|
247 inline TInt SetConfig(const TDesC8 &aConfig); |
|
248 /** |
|
249 * Set the channels MAC address |
|
250 * @param aConfig Buffer containing an configuration object with the MAC |
|
251 * address set |
|
252 */ |
|
253 inline TInt SetMAC(const TDesC8 &aConfig); |
|
254 |
|
255 /** |
|
256 * Request the channels capabilities |
|
257 * @param aCaps Buffer to contain the capibilites object |
|
258 */ |
|
259 inline void Caps(TDes8 &aCaps); |
|
260 |
|
261 #ifdef ETH_CHIP_IO_ENABLED |
|
262 inline void ChipIOCtrl(TRequestStatus &aStatus,TPckgBuf<TChipIOInfo> &aDes); |
|
263 #endif |
|
264 #endif |
|
265 }; |
|
266 |
|
267 /** @} */ // End of external interface |
|
268 #include <d32ethernet.inl> |
|
269 |
|
270 #endif |