|
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 * ne1_tb\ethernet\shared_ethernet.h |
|
16 * Ethernet driver common header |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __SHARED_ETHERNET_H__ |
|
24 #define __SHARED_ETHERNET_H__ |
|
25 |
|
26 #include <e32def.h> |
|
27 #include <kernel/kernel.h> |
|
28 #include <kernel/kern_priv.h> |
|
29 #include <ethernet.h> |
|
30 #include <nkern.h> |
|
31 |
|
32 // |
|
33 // Driver Constants |
|
34 // |
|
35 |
|
36 class DEthernetPdd; |
|
37 |
|
38 /******Ethernet POWER HANDLER CLASS*****/ |
|
39 class DEthernetPowerHandler : public DPowerHandler |
|
40 { |
|
41 public: |
|
42 DEthernetPowerHandler(); |
|
43 TInt SetEthernetPdd(DEthernetPdd* aEthernetPdd); |
|
44 void PowerDown(TPowerState aState); |
|
45 void PowerUp(); |
|
46 void RequestPower(); |
|
47 void RelinquishPower(); |
|
48 private: |
|
49 TBool iCurPoweredUp; |
|
50 TPowerState iCurPowerState; |
|
51 DEthernetPdd* iEthernetPdd; |
|
52 }; |
|
53 |
|
54 |
|
55 class DEthernetPdd : public DEthernet |
|
56 /** |
|
57 Ethernet PDD class. |
|
58 */ |
|
59 { |
|
60 public: |
|
61 DEthernetPdd(); |
|
62 ~DEthernetPdd(); |
|
63 |
|
64 /** |
|
65 * Start receiving frames |
|
66 * @return KErrNone if driver started |
|
67 */ |
|
68 virtual TInt Start() ; |
|
69 /** |
|
70 * Stop receiving frames |
|
71 * @param aMode The stop mode |
|
72 */ |
|
73 virtual void Stop(TStopMode aMode) = 0; |
|
74 |
|
75 /** |
|
76 * Validate a new config |
|
77 * Validates a new configuration should be called before Configure |
|
78 * @param aConfig is the configuration to be validated |
|
79 * @return ETrue or EFalse if the Configuration is allowed |
|
80 * @see Configure() |
|
81 */ |
|
82 virtual TInt ValidateConfig(const TEthernetConfigV01 &aConfig) const; |
|
83 /** |
|
84 * Configure the device |
|
85 * Reconfigure the device using the new configuration supplied. |
|
86 * This should not change the MAC address. |
|
87 * @param aConfig The new configuration |
|
88 * @see ValidateConfig() |
|
89 * @see MacConfigure() |
|
90 */ |
|
91 virtual TInt Configure(TEthernetConfigV01 &aConfig) = 0; |
|
92 /** |
|
93 * Change the MAC address |
|
94 * Attempt to change the MAC address of the device |
|
95 * @param aConfig A Configuration containing the new MAC |
|
96 * @see Configure() |
|
97 */ |
|
98 virtual void MacConfigure(TEthernetConfigV01 &aConfig) = 0; |
|
99 /** |
|
100 * Get the current config from the chip |
|
101 * This returns the current configuration of the chip with the following fields |
|
102 * The Transmit Speed |
|
103 * The Duplex Setting |
|
104 * The MAC address |
|
105 * @param aConfig is a TEthernetConfigV01 reference that will be filled in |
|
106 */ |
|
107 virtual void GetConfig(TEthernetConfigV01 &aConfig) const; |
|
108 /** |
|
109 * Check a configuration |
|
110 * @param aConfig a reference to the structure TEthernetConfigV01 with configuration to check |
|
111 */ |
|
112 virtual void CheckConfig(TEthernetConfigV01& aConfig); |
|
113 |
|
114 /** |
|
115 * Query the device's capabilities |
|
116 * @param aCaps To be filled in with the capabilites |
|
117 */ |
|
118 virtual void Caps(TDes8 &aCaps) const; |
|
119 |
|
120 /** |
|
121 * Transmit data |
|
122 * @param aBuffer reference to the data to be sent |
|
123 * @return KErrNone if the data has been sent |
|
124 */ |
|
125 virtual TInt Send(TBuf8<KMaxEthernetPacket+32> &aBuffer) = 0; |
|
126 /** |
|
127 * Retrieve data from the device |
|
128 * Pull the received data out of the device and into the supplied buffer. |
|
129 * Need to be told if the buffer is OK to use as if it not we could dump |
|
130 * the waiting frame in order to clear the interrupt if necessory. |
|
131 * @param aBuffer Reference to the buffer to be used to store the data in |
|
132 * @param okToUse Bool to indicate if the buffer is usable |
|
133 * @return KErrNone if the buffer has been filled. |
|
134 */ |
|
135 virtual TInt ReceiveFrame(TBuf8<KMaxEthernetPacket+32> &aBuffer, |
|
136 TBool okToUse) = 0; |
|
137 |
|
138 /** |
|
139 * Disables all IRQ's |
|
140 * @return The IRQ level before it was changed |
|
141 * @see RestoreIrqs() |
|
142 */ |
|
143 virtual TInt DisableIrqs(); |
|
144 /** |
|
145 * Restore the IRQ's to the supplied level |
|
146 * @param aIrq The level to set the irqs to. |
|
147 * @see DisableIrqs() |
|
148 */ |
|
149 virtual void RestoreIrqs(TInt aIrq); |
|
150 |
|
151 /** |
|
152 * Return the DFC Queue that this device should use |
|
153 * @param aUnit The Channel number |
|
154 * @return Then DFC Queue to use |
|
155 */ |
|
156 virtual TDfcQue* DfcQ(TInt aUnit); |
|
157 |
|
158 virtual TInt DoCreate() = 0; |
|
159 |
|
160 /** |
|
161 * Put the card to sleep |
|
162 */ |
|
163 |
|
164 virtual void Sleep() = 0; |
|
165 /** |
|
166 * Wake the card up |
|
167 */ |
|
168 virtual TInt Wakeup() = 0; |
|
169 |
|
170 protected: |
|
171 static void ServiceRxDfc(TAny *aPtr); |
|
172 |
|
173 /** |
|
174 * Does the soft reset of the lan card |
|
175 */ |
|
176 TInt CardSoftReset(); |
|
177 |
|
178 protected: |
|
179 /** |
|
180 * Contains the default/current configuration of the chip |
|
181 */ |
|
182 TEthernetConfigV01 iDefaultConfig; |
|
183 /** |
|
184 * Is ETrue if the chip has been fully configured. |
|
185 */ |
|
186 TBool iReady; |
|
187 /** |
|
188 * Is ETrue if the pdd has been created |
|
189 */ |
|
190 TBool iCreated; |
|
191 DEthernetPowerHandler iPowerHandler; |
|
192 TDynamicDfcQue* iDfcQ; |
|
193 TInt32 iInterruptId; |
|
194 }; |
|
195 |
|
196 |
|
197 #endif //__SHARED_ETHERNET_H__ |