NetBurner 3.5.0
PDF Version
 
netDevice.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef _NETDEVICE_H_
6#define _NETDEVICE_H_
7#include <nettypes.h>
8#include <buffers.h>
9#include <stdio.h>
10#include <device.h>
11/*
12 ******************************************************************************
13 *
14 * Include Files
15 *
16 ******************************************************************************
17 */
18
19/*
20 ******************************************************************************
21 *
22 * Debugging
23 *
24 ******************************************************************************
25 */
26/* Library debugging switch */
27#define NETDEVICE_DEVICE_DEBUG (1)
28
29/*
30 ******************************************************************************
31 *
32 * Constants
33 *
34 ******************************************************************************
35 */
36/* Maximum Network Devices */
37#define NETDEVICE_DEVICE_MAXIMUM (5)
38
39/*
40 NetworkAddInterface Returns
41
42 NETDEVICE_REQUEST_FAILED - Was not added by the system
43 NETDEVICE_MODULE_NOT_FOUND - Module not detected
44 NETDEVICE_ALREADY_EXISTS - Already exists
45 NETDEVICE_SUPPORT_TASK_FAILED - Driver task not created
46
47*/
48
49#define NETDEVICE_REQUEST_FAILED (0)
50#define NETDEVICE_MODULE_NOT_FOUND (-1)
51#define NETDEVICE_ALREADY_EXISTS (-2)
52#define NETDEVICE_SUPPORT_TASK_FAILED (-3)
53#define NETDEVICE_MODULE_NOT_SUPPORTED (-4)
54
55/* List requests */
56#define NETDEVICE_SITE_COUNT (1)
57#define NETDEVICE_SITE_LIST (2)
58
59/*
60 Security supplicant actions
61
62 NETDEVICE_INITIALIZE - Initialize
63 NETDEVICE_UPDATE_KEY - Update key
64
65*/
66#define NETDEVICE_INITIALIZE (0)
67#define NETDEVICE_UPDATE_PASSPHRASE (1)
68#define NETDEVICE_GET_TEMPORAL_KEY (2)
69
70/*
71 ******************************************************************************
72 *
73 * Enumerations
74 *
75 ******************************************************************************
76 */
77/*
78 Network interface controller (NIC)
79
80 ControllerNone - No controller
81 ControllerPointToPoint - Point-to-Point data link protocol
82 ControllerRealtekRtl8711 - Realtek IEEE 802.11g
83
84 */
85typedef enum _NetDeviceController
86{
87 ControllerNone,
88 ControllerPointToPoint,
89 ControllerRealtekRtl8711
90
91} NetDeviceController;
92
93/*
94 Network interface controller (NIC) bus type used
95
96 BusTypeNone - No bus
97 BusTypeMemoryMapped - External data bus access
98 BusTypeSdioBusType - Secure Digital Input Output (SDIO)
99 BusTypeSdioBusSpiMode - SDIO using SPI mode
100 BusTypeSpiBus - Serial Peripheral Interface (SPI)
101
102 */
103typedef enum _NetDeviceBusType
104{
105 BusTypeNone,
106 BusTypeMemoryMapped,
107 BusTypeSdioBusType,
108 BusTypeSdioBusSpiMode,
109 BusTypeSpiBus
110
111} NetDeviceBusType;
112
113/*
114 Select details (chip select)
115
116 Chip select are either managed (asserted/deasserted by the processor
117 module (e.g. (Q)SPI module) or unmanaged and handled by the driver.
118
119 The (Q)SPI module supports connecting additional hardware that using
120 the (Q)SPI chip selects can select several devices (multiplex) up to 15.
121
122 SelectDetailNone - No chip select
123 SelectDetailSpiUnmanaged - Single signal unmanaged chip select
124 SelectDetailSpiUnmanagedMultiplex - Multiplexed unmanaged chip select
125 SelectDetailSpiManaged - Single signal managed chip select
126 SelectDetailSpiManagedMultiplex - Multiplexed managed chip select
127 SelectDetailGpioUnmanaged - Single signal unmanaged chip select
128
129 Changing the ordering of these parameters require complete system and platform
130 rebuilds.
131
132*/
133
134typedef enum _NetDeviceSelectDetail
135{
136 SelectDetailNone,
137 SelectDetailSpiUnmanaged,
138 SelectDetailSpiUnmanagedMultiplex,
139 SelectDetailSpiManaged,
140 SelectDetailSpiManagedMultiplex,
141 SelectDetailGpioUnmanaged,
142
143} NetDeviceSelectDetail;
144
145/*
146 ******************************************************************************
147 *
148 * C++ definitions
149 *
150 ******************************************************************************
151 */
152
153/*
154 ******************************************************************************
155 *
156 * Routine Prototypes
157 *
158 ******************************************************************************
159 */
160/* Device management */
161typedef void(NetDeviceProgressFn)(int activity, int progress, const char *detail);
162typedef NetDeviceProgressFn *NetDeviceProgressFnPtr;
163
164/* Security supplicant */
165typedef BOOL(NetDeviceSupplicantFn)(int action, void *buffer);
166typedef NetDeviceSupplicantFn *NetDeviceSupplicantFnPtr;
167
168/*
169 ******************************************************************************
170 *
171 * Classes
172 *
173 ******************************************************************************
174 */
175/*
176 ******************************************************************************
177 * Network Device Base Class
178 ******************************************************************************
179 */
180class NetDevice
181{
182 public:
183 /*** Constructor ***/
184 NetDevice(int irq, NetDeviceController controller, NetDeviceBusType busType, int select, NetDeviceSelectDetail selectDetails);
185
186 /*** Destructor ***/
187 virtual ~NetDevice();
188
189 /*** Copy Constructor ***/
190 /* Default */
191
192 /*** Static Methods ***/
193 /* Verify platform support, create controller object */
194 static int add(int irq, NetDeviceController controller, NetDeviceBusType busType, int select, NetDeviceSelectDetail selectDetails);
195
196 /* Get network device */
197 static NetDevice *getNetDevice(int deviceIndex);
198
199 /*** Methods ***/
200 /* Setup bus for controller */
201 virtual BOOL setupBus(void);
202
203 /* Setup ISR */
204 virtual BOOL setupIsr(DeviceIsrFnPtr isrFunction, int irq);
205
206 /* Determine existence of controller on bus */
207 virtual BOOL probe(void);
208
209 /* Initialize controller in idle state, add to network stack */
210 virtual BOOL open(void);
211
212 /* Reset controller to quiescent idle state */
213 virtual BOOL close(void);
214
215 /* Remove controller from network stack */
216 virtual BOOL remove(void);
217
218 /* Configure and retrieve settings */
219 virtual BOOL configure(int request, ssize_t parameterSize, void *parameterPtr);
220 virtual BOOL retrieveSetting(int setting, ssize_t settingSize, void *settingPtr);
221
222 /* List */
223 virtual BOOL list(int request, ssize_t &listSize, void *listPtr);
224
225 /* Network name */
226 virtual void getNetworkName(char *name, ssize_t maximumBytes);
227
228 /* Survey network */
229 virtual BOOL surveyNetwork(char *site);
230
231 /* Connect */
232 virtual BOOL connect(const char *identifier = NULL, const char *securityKey = NULL, int securityDetail = 0, int mode = 0);
233
234 /* Disconnect */
235 virtual BOOL disconnect(void);
236
237 /*** Network stack routines ***/
238 /* Transmit packet */
239 virtual BOOL transmitPacket(PoolPtr poolPtr);
240
241 /* Set/Reset multicast */
242 virtual void resetMulticast(MACADDRESS_48 macAddress, BOOL addAddress);
243
244 /*** Accessors ***/
245 /* Access stack interface number */
246 void setInterfaceNumber(int interfaceNumber);
247 int getInterfaceNumber(void) const;
248
249 /* Get number */
250 int getNumber(void) const;
251
252 /* Get name */
253 char *getName(void);
254
255 /* Get unit */
256 int getUnit(void) const;
257
258 /* Get controller */
259 NetDeviceController getController(void) const;
260
261 /* Get bus type */
262 NetDeviceBusType getBusType(void) const;
263
264 /* Get select */
265 int getSelect(void) const;
266
267 /* Get select */
268 NetDeviceSelectDetail getSelectDetail(void) const;
269
270 /* Get MAC address */
271 virtual BOOL getMacAddress(MACADDRESS_48 &macAddress);
272
273 /* Connected? */
274 virtual BOOL isConnected(void);
275
276 /* Progress routine */
277 virtual void setProgressRoutine(NetDeviceProgressFnPtr routinePtr);
278
279 /* Security supplicant routine */
280 virtual void setSupplicant(NetDeviceSupplicantFnPtr routinePtr);
281
282 /* Set/Get ticks per second */
283 void setTicksPerSecond(unsigned short ticksPerSecond);
284 unsigned int getTicksPerSecond(void) const;
285
286 /* Signal interrupt */
287 virtual void signalInterrupt(void);
288
289 /* Valid? */
290 BOOL isValid(void) const;
291
292 protected:
293 /* Set name */
294 void setName(const char *namePtr);
295
296 /* Set unit */
297 void setUnit(int unit);
298
299 /* Set valid */
300 void setValid(BOOL valid) const;
301
302 private:
303 /*** Methods ***/
304 /* None */
305
306 /*** Data Members ***/
307 /* Index in __device */
308 int __index;
309
310 /* Name */
311 char *__namePtr;
312
313 /* Unit */
314 int __unit;
315
316 /* IRQ */
317 int __irq;
318
319 /* Controller */
320 NetDeviceController __controller;
321
322 /* Bus */
323 NetDeviceBusType __busType;
324
325 /* Select */
326 int __select;
327
328 /* Select */
329 NetDeviceSelectDetail __selectDetail;
330
331 /* Interface number */
332 int __interfaceNumber;
333
334 /* Ticks per second (Can be modified by developer) */
335 unsigned short __ticksPerSecond;
336
337 /* Valid */
338 BOOL __valid;
339
340 /*** Static Data Members ***/
341 /* One time initialization */
342 static BOOL __isInitialized;
343
344 /* Critical section for mutex */
345 static OS_CRIT __criticalSection;
346
347 /* Interface objects */
348 static NetDevice *__device[NETDEVICE_DEVICE_MAXIMUM];
349};
350
351/*
352 ******************************************************************************
353
354 Verify availability and support for device.
355
356
357 Parameters:
358 irq - Fixed level interrupt source
359 controller - IEEE 802.11g controller
360 busType - Bus used by the controller
361
362
363 Return:
364 TRUE - Support and available on module, FALSE option not supported
365
366 Note:
367 Does not verify controller is attached and operational.
368
369 ******************************************************************************
370 */
371BOOL NetDeviceIsValid(int irq, NetDeviceController controller, NetDeviceBusType busType);
372
373/*
374 ******************************************************************************
375
376 Get device handle
377
378
379 Parameters:
380 irq - Fixed level interrupt source
381 controller - IEEE 802.11g controller
382 busType - Bus used by the controller
383 select - Chip select is bus specific
384 SDIO using SPI mode (BusTypeSdioBusSpiMode)
385 0 - 3 (Q)SPI chip select lines QSPI_CS[0:3]
386
387 Return:
388 Handle - Supported and available on module,
389 NULL interface not supported
390
391 Note:
392 Verify parameters and platform support for device.
393 Does not verify controller is attached and operational.
394
395 ******************************************************************************
396 */
397NetDevice *NetDeviceGetDevice(int irq,
398 NetDeviceController controller,
399 NetDeviceBusType busType,
400 int select,
401 NetDeviceSelectDetail selectDetails);
402
403/* Device Realtek RTL8711 Controller on SDIO bus in SPI mode */
404NetDevice *NetDeviceGetDeviceRtl8711SdioSpi(int irq, int select, NetDeviceSelectDetail selectDetails);
405
406#endif /* _NETDEVICE_H_ */
NetBurner Buffers API.
NetBurner Device Interrupts.
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, unsigned long timeout)
Wait for events to occur on one or more I/O resources associated with a set of file descriptors (fds)...
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition nbrtos.h:1084