]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/network/IONetworkController.h
e9ca383e6995483d2ea4a9c05ddb12611de330a6
[apple/xnu.git] / iokit / IOKit / network / IONetworkController.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24 *
25 * IONetworkController.h
26 *
27 * Network controller driver superclass.
28 *
29 * HISTORY
30 * 9-Dec-1998 Joe Liu (jliu) created.
31 *
32 */
33
34 #ifndef _IONETWORKCONTROLLER_H
35 #define _IONETWORKCONTROLLER_H
36
37 /*! @defined kIONetworkControllerClass
38 @abstract kIONetworkControllerClass is the name of the
39 IONetworkController class. */
40
41 #define kIONetworkControllerClass "IONetworkController"
42
43 /*! @defined kIOVendor
44 @abstract kIOVendor is a property of IONetworkController objects.
45 It has an OSString value.
46 @discussion The kIOVendor property is a string describing the
47 vendor of the network controller. */
48
49 #define kIOVendor "IOVendor"
50
51 /*! @defined kIOModel
52 @abstract kIOModel is a property of IONetworkController objects.
53 It has an OSString value.
54 @discussion The kIOModel property is a string describing the
55 model of the network controller. */
56
57 #define kIOModel "IOModel"
58
59 /*! @defined kIORevision
60 @abstract kIORevision is a property of IONetworkController objects.
61 It has an OSString value.
62 @discussion The kIORevision property is a string describing the
63 revision level of the network controller. */
64
65 #define kIORevision "IORevision"
66
67 /*! @defined kIOFeatures
68 @abstract kIOFeatures is a property of IONetworkController objects.
69 It has an OSNumber value.
70 @discussion The kIOFeatures property describes generic features
71 defined by IONetworkController that are supported by the
72 network controller. */
73
74 #define kIOFeatures "IOFeatures"
75
76 /*! @defined kIOMediumDictionary
77 @abstract kIOMediumDictionary is a property of IONetworkController
78 objects. It has an OSDictionary value.
79 @discussion The kIOMediumDictionary property is a container for the
80 collection of IONetworkMedium objects that represent the media
81 types supported by the network controller.
82 Each entry in the dictionary is a key/value pair consisting of
83 the medium name, and a dictionary value that contains the
84 properties for that medium entry. */
85
86 #define kIOMediumDictionary "IOMediumDictionary"
87
88 /*! @defined kIODefaultMedium
89 @abstract kIODefaultMedium is a property of IONetworkController
90 objects. It has an OSString value.
91 @discussion The kIODefaultMedium property describes the name of the
92 default medium. This definition may change or disappear in the
93 future. */
94
95 #define kIODefaultMedium "IODefaultMedium"
96
97 /*! @defined kIOSelectedMedium
98 @abstract kIOSelectedMedium is a property of IONetworkController
99 objects. It has an OSSymbol value.
100 @discussion The kIOSelectedMedium property describes the name of the
101 current selected medium. This name can be used as a key into the
102 medium dictionary to gather additional information about the
103 selected medium. */
104
105 #define kIOSelectedMedium "IOSelectedMedium"
106
107 /*! @defined kIOActiveMedium
108 @abstract kIOActiveMedium is a property of IONetworkController
109 objects. It has an OSSymbol value.
110 @discussion The kIOActiveMedium property describes the name of the
111 active medium. This is the name of the medium where an active
112 link has been established. This name can be used as a key into
113 the medium dictionary to gather additional information about the
114 active medium. */
115
116 #define kIOActiveMedium "IOActiveMedium"
117
118 /*! @defined kIOLinkSpeed
119 @abstract kIOLinkSpeed is a property of IONetworkController
120 objects. It has an OSNumber value.
121 @discussion The kIOLinkSpeed property describes the speed of the
122 link established over the active medium in bits per second. */
123
124 #define kIOLinkSpeed "IOLinkSpeed"
125
126 /*! @defined kIOLinkStatus
127 @abstract kIOLinkStatus is a property of IONetworkController
128 objects. It has an OSNumber value.
129 @discussion The kIOLinkStatus property describes the current network
130 link status. See IONetworkMedium for the definition of the link
131 status bits. */
132
133 #define kIOLinkStatus "IOLinkStatus"
134
135 /*! @defined kIOLinkData
136 @abstract kIOLinkData is a property of IONetworkController
137 objects. It has an OSData value.
138 @discussion The kIOLinkData property contains additional information,
139 that describes the active link that was established.
140 Its interpretation is not defined. */
141
142 #define kIOLinkData "IOLinkData"
143
144 /*! @defined kIOPacketFilters
145 @abstract kIOPacketFilters is a property of IONetworkController
146 objects. It has an OSDictionary value.
147 @discussion The kIOPacketFilters property describes the entire
148 set of packet filters supported by the controller. Each entry
149 in the dictionary is a key/value pair consisting of the filter
150 group name, and an OSNumber describing the set of supported
151 filters for that group. */
152
153 #define kIOPacketFilters "IOPacketFilters"
154
155 /*! @defined kIOMACAddress
156 @abstract kIOMACAddress is a property of IONetworkController
157 objects. It has an OSData value.
158 @discussion The kIOMACAddress property describes the hardware
159 MAC (media access controller) address, or station address,
160 of the network controller. */
161
162 #define kIOMACAddress "IOMACAddress"
163
164 /*! @defined kIOMaxPacketSize
165 @abstract kIOMaxPacketSize is a property of IONetworkController
166 objects. It has an OSNumber value.
167 @discussion The kIOMaxPacketSize property describes the maximum
168 packet size supported by the controller. */
169
170 #define kIOMaxPacketSize "IOMaxPacketSize"
171
172 /*! @defined kIOMinPacketSize
173 @abstract kIOMinPacketSize is a property of IONetworkController
174 objects. It has an OSNumber value.
175 @discussion The kIOMinPacketSize property describes the minimum
176 packet size supported by the controller. */
177
178 #define kIOMinPacketSize "IOMinPacketSize"
179
180 /*! @defined kIONetworkFilterGroup
181 @abstract kIONetworkFilterGroup describes the name assigned to the
182 standard network filter group. */
183
184 #define kIONetworkFilterGroup "IONetworkFilterGroup"
185
186 /*! @enum Enumeration of standard packet filters.
187 @discussion An enumeration of all standard packet filters. Each
188 filter will allow the reception of certain class of packets
189 depending on its destination MAC address.
190 @constant kIOPacketFilterUnicast Reception of unicast packets.
191 @constant kIOPacketFilterBroadcast Reception of broadcast packets.
192 @constant kIOPacketFilterMulticast Reception of multicast packets
193 addressed to a set of multicast addresses.
194 @constant kIOPacketFilterMulticastAll Reception of all multicast
195 packets.
196 @constant kIOPacketFilterPromiscuous Reception of all packets.
197 @constant kIOPacketFilterPromiscuousAll Reception of all packets,
198 including bad packets. */
199
200 enum {
201 kIOPacketFilterUnicast = 0x1,
202 kIOPacketFilterBroadcast = 0x2,
203 kIOPacketFilterMulticast = 0x10,
204 kIOPacketFilterMulticastAll = 0x20,
205 kIOPacketFilterPromiscuous = 0x100,
206 kIOPacketFilterPromiscuousAll = 0x200,
207 };
208
209 /*! @enum Feature flags returned by the getFeatures() method.
210 @constant kIONetworkFeatureNoBSDWait Set this bit in the value
211 returned by getFeatures() to disable the automatic wait for
212 "IOBSD" resource by the IONetworkController::start() method. */
213
214 enum {
215 kIONetworkFeatureNoBSDWait = 0x01,
216 };
217
218 /*
219 * Kernel
220 */
221 #if defined(KERNEL) && defined(__cplusplus)
222
223 #include <IOKit/IOService.h>
224 #include <IOKit/IOWorkLoop.h>
225 #include <IOKit/network/IONetworkInterface.h>
226 #include <IOKit/network/IOKernelDebugger.h>
227
228 struct mbuf; // forward declarations
229 class IOCommandGate;
230 class IOOutputQueue;
231 class IONetworkMedium;
232
233 /*! @typedef IOPacketBufferConstraints
234 @discussion Constraint parameters, specified by a driver,
235 for the data buffer in a packet mbuf. This is observed by
236 allocatePacket() to satisfy the stated requirements.
237 @field alignStart Starting address byte alignment.
238 @field alignLength Buffer length byte alignment. */
239
240 typedef struct {
241 UInt32 alignStart;
242 UInt32 alignLength;
243 UInt32 reserved[6];
244 } IOPacketBufferConstraints;
245
246 // Some frequently used alignment constants.
247 //
248 enum {
249 kIOPacketBufferAlign1 = 1,
250 kIOPacketBufferAlign2 = 2,
251 kIOPacketBufferAlign4 = 4,
252 kIOPacketBufferAlign8 = 8,
253 kIOPacketBufferAlign16 = 16,
254 kIOPacketBufferAlign32 = 32,
255 };
256
257 /*! @defined gIONetworkFilterGroup
258 @discussion gIONetworkFilterGroup is an OSSymbol object that contains
259 the name of the standard network filter group as defined by
260 kIONetworkFilterGroup. */
261
262 extern const OSSymbol * gIONetworkFilterGroup;
263
264 /*! @class IONetworkController : public IOService
265 @abstract IONetworkController implements the framework for a generic
266 network controller. A subclass of IONetworkController must provide
267 additional functionality specific for a particular networking type.
268 In addition, the driver must implement (override) a basic set of
269 hardware dependent methods to create a working driver.
270
271 IONetworkController attaches itself to the data link layer (DLIL) via
272 an IONetworkInterface object. A controller object without a companion
273 interface is not accessible to the networking system. The controller
274 interacts with DLIL by calling methods defined by the interface object.
275 And conversely, DLIL will issue commands and packets to the controller
276 through the interface object.
277
278 IONetworkController will create an IOCommandGate and attach this
279 event source to an IOWorkLoop object. All commands sent from the
280 interface object are handled through the IOCommandGate object,
281 which will serialize access to the controller. Outbound packets sent
282 from the interface to the controller have no implicit serialization.
283 Drivers must implement an output function that is thread safe, or use
284 an IOOutputQueue object which will provide a serialization model.
285 */
286
287 class IONetworkController : public IOService
288 {
289 OSDeclareAbstractStructors( IONetworkController )
290
291 private:
292
293 IOWorkLoop * _workLoop;
294 IOCommandGate * _cmdGate;
295 IOOutputQueue * _outputQueue;
296 OSSet * _clientSet;
297 OSCollectionIterator * _clientSetIter;
298 OSObject * _cmdClient;
299 UInt32 _alignStart;
300 UInt32 _alignLength;
301 UInt32 _alignPadding;
302 bool _propertiesPublished;
303 IOLock * _mediumLock;
304 IODebuggerLockState _debugLockState;
305 SInt32 _debugLockCount;
306 OSNumber * _linkStatus;
307 OSNumber * _linkSpeed;
308 const OSData * _lastLinkData;
309 const OSSymbol * _lastActiveMediumName;
310 const OSSymbol * _lastCurrentMediumName;
311 struct mbuf * _freeList;
312
313 struct ExpansionData { };
314 /*! @var reserved
315 Reserved for future use. (Internal use only) */
316 ExpansionData * _reserved;
317
318
319 bool _broadcastEvent(UInt32 type, void * data = 0);
320
321 static void debugRxHandler(IOService * handler,
322 void * buffer,
323 UInt32 * length,
324 UInt32 timeout);
325
326 static void debugTxHandler(IOService * handler,
327 void * buffer,
328 UInt32 length);
329
330 static IOReturn executeCommandAction(OSObject * owner,
331 void * arg0,
332 void * arg1,
333 void * arg2,
334 void * arg3);
335
336 static IOReturn handleCommand(void * target,
337 void * param0,
338 void * param1,
339 void * param2,
340 void * param3);
341
342 public:
343
344 /*! @function initialize
345 @abstract IONetworkController class initializer.
346 @discussion Create frequently used OSSymbol objects that are used as keys.
347 This method is called explicitly by a line in IOStartIOKit.cpp and not
348 by the OSDefineMetaClassAndInit() mechanism, to ensure that this method
349 is called after the OSSymbol class (pool) is initialized. */
350
351 static void initialize();
352
353 /*! @function init
354 @abstract Initialize the IONetworkController object.
355 @discussion Instance variables are initialized, then super::init()
356 is called.
357 @param properties A dictionary object containing a property table
358 associated with this instance.
359 @result true on success, false otherwise. */
360
361 virtual bool init(OSDictionary * properties);
362
363 /*! @function start
364 @abstract Start the network controller.
365 @discussion After the controller driver has successfully matched
366 to a provider, this method is called to start the network controller.
367 IONetworkController will allocate resources and gather controller
368 properties in its implementation. No I/O will be performed until
369 the subclass tries to attach a client object. A driver must override
370 this method, and call super::start() at the beginning of its own
371 implementation. Then check the return value to make sure that its
372 superclass was started successfully before proceeding. Tasks that
373 are usually performed by a driver's start method are; resource
374 allocation, hardware initialization, allocation of IOEventSources
375 and attaching them to a workloop, publishing a medium dictionary,
376 and finally, attaching an interface object when it is ready to
377 handle client requests.
378 @param provider The provider that the controller was matched
379 (and attached) to.
380 @result true on success, false otherwise. */
381
382 virtual bool start(IOService * provider);
383
384 /*! @function stop
385 @abstract Stop the network controller.
386 @discussion The counterpart of start(). The controller has been
387 instructed to stop running. The stop() method should release
388 resources and undo actions performed by the start() method.
389 Subclasses must override this method and call super::stop()
390 at the end of its implementation.
391 @param provider The provider that the controller was matched
392 (and attached) to. */
393
394 virtual void stop(IOService * provider);
395
396 /*! @typedef IONetworkController::Action
397 @discussion Definition of a C function that can be called
398 through executeCommand().
399 @param target The first argument passed to action.
400 @param param0 Action parameter 0.
401 @param param1 Action parameter 1.
402 @param param2 Action parameter 2.
403 @param param3 Action parameter 3. */
404
405 typedef IOReturn (*Action)(void * target, void * param0,
406 void * param1,
407 void * param2,
408 void * param3);
409
410 /*! @function executeCommand
411 @abstract Make a C function call through the command gate.
412 @discussion Make a call to a C function that will be synchronized
413 with the workloop thread, and any other threads that are called
414 with the workloop's gate closed.
415 @param client The client requesting the action. This parameter is not
416 passed to the function.
417 @param action Pointer to a C function to be executed.
418 @param target The first parameter in the action callout.
419 @param param0 Action parameter 0.
420 @param param1 Action parameter 1.
421 @param param2 Action parameter 2.
422 @param param3 Action parameter 3.
423 @result The value returned by the action. */
424
425 virtual IOReturn executeCommand(OSObject * client,
426 Action action,
427 void * target,
428 void * param0 = 0,
429 void * param1 = 0,
430 void * param2 = 0,
431 void * param3 = 0);
432
433 /*! @function outputPacket
434 @abstract Transmit an output packet.
435 @discussion If an IOOutputQueue was created by createOutputQueue(),
436 then this method will be called by the output queue object.
437 Otherwise, an interface object will call this method directly when
438 it receives an output packet from the data link layer.
439
440 There is no upper limit on the number of mbufs, hence the number of
441 memory fragments, in the mbuf chain provided. Drivers must be able to
442 handle cases when the mbuf count might exceed the limit supported by their
443 DMA engines, and perform coalescing to copy the various memory fragments
444 into a lesser number of fragments. This complexity can be hidden from
445 the driver when an IOMbufMemoryCursor is used, which is able to convert
446 a mbuf chain into a physical address scatter-gather list that will not
447 exceed a specified number of physically contiguous memory segments.
448 See IOMbufMemoryCursor.
449
450 The implementation in IONetworkController performs no useful action
451 and will drop all packets. A driver must override this method and
452 process the output packet provided. The implementation in the driver
453 must not block, since this may cause the network stack to be reentered
454 from an unsafe point.
455 @param packet A mbuf chain containing the output packet to be sent on
456 the network.
457 @param param A parameter provided by the caller.
458 @result A return code defined by the caller. */
459
460 virtual UInt32 outputPacket(struct mbuf * packet, void * param);
461
462 /*! @function getFeatures
463 @abstract Report generic features supported by the controller and/or
464 the driver.
465 @result This method will always return 0. Subclasses may override
466 this method and return a bit mask of all supported features. */
467
468 virtual UInt32 getFeatures() const;
469
470 /*! @function newVendorString
471 @result Return a string describing the vendor of the network controller.
472 The caller is responsible for releasing the string object returned. */
473
474 virtual const OSString * newVendorString() const;
475
476 /*! @function newModelString
477 @result Return a string describing the model of the network controller.
478 The caller is responsible for releasing the string object returned. */
479
480 virtual const OSString * newModelString() const;
481
482 /*! @function newRevisionString
483 @result Return a string describing the hardware revision of the
484 network controller. The caller is responsible for releasing the
485 string object returned. */
486
487 virtual const OSString * newRevisionString() const;
488
489 /*! @function getSelectedMedium
490 @abstract Get the current selected medium.
491 @discussion If the driver has previously called setSelectedMedium()
492 to indicate its current media selection, then this method will return
493 that medium object. Otherwise, the driver's property table is
494 consulted and a default medium property is examined, and the
495 corresponding entry in the medium dictionary is returned.
496 @result The current selected medium, the default medium, or 0. */
497
498 virtual const IONetworkMedium * getSelectedMedium() const;
499 inline const IONetworkMedium * getCurrentMedium() const;
500
501 /*! @function getMediumDictionary
502 @abstract Returns the medium dictionary published by the driver.
503 @discussion Returns the medium dictionary published by the driver
504 through publishMediumDictionary(). Use copyMediumDictionary() to
505 create and get a copy of the medium dictionary.
506 @result The published medium dictionary, or 0 if the driver has not
507 yet published a medium dictionary through publishMediumDictionary(). */
508
509 virtual const OSDictionary * getMediumDictionary() const;
510
511 /*! @function copyMediumDictionary
512 @abstract Returns a copy of the medium dictionary published by the
513 driver.
514 @discussion The caller is responsible for releasing the dictionary
515 object returned. Use getMediumDictionary() to get a reference to the
516 published medium dictionary instead of creating a copy.
517 @result A copy of the medium dictionary, or 0 if the driver has not
518 published a medium dictionary through publishMediumDictionary(). */
519
520 virtual OSDictionary * copyMediumDictionary() const;
521
522 /*! @function getOutputHandler
523 @abstract Get the address of the method designated to handle output
524 packets for the network controller.
525 @result A pointer to the outputPacket() method is returned. */
526
527 virtual IOOutputAction getOutputHandler() const;
528
529 /*! @function doEnable
530 @abstract Make a synchronized call to enable() through executeCommand().
531 @discussion Do not use this method, it may be removed in the future.
532 See enable(). */
533
534 virtual IOReturn doEnable(IOService * client);
535
536 /*! @function doDisable
537 @abstract Make a synchronized call to disable() through executeCommand().
538 @discussion Do not use this method, it may be removed in the future.
539 See disable(). */
540
541 virtual IOReturn doDisable(IOService * client);
542
543 /*! @function getCommandGate
544 @abstract Get the IOCommandGate object created by IONetworkController.
545 @discussion When IONetworkController is started, an IOCommandGate object
546 is instantiated and attached to the workloop returned by getWorkLoop().
547 This IOCommandGate object is used internally to synchronize client
548 commands handled through executeCommand(). Subclasses that need an
549 IOCommandGate should try to reuse the object returned by this method,
550 rather than creating a new instance. See IOCommandGate documentation.
551 @result The IOCommandGate object created by IONetworkController. */
552
553 virtual IOCommandGate * getCommandGate() const;
554
555 /*! @function getHardwareAddress
556 @abstract Get the network controller's permanent hardware/station
557 address. This method call is synchronized by the workloop's gate.
558 @param addr The buffer where the controller's hardware address should
559 be stored.
560 @param inOutAddrBytes The size of the address buffer provided by the
561 client, and replaced by this method with the actual size of
562 the hardware address in bytes.
563 @result kIOReturnSuccess on success, or an error otherwise. */
564
565 virtual IOReturn getHardwareAddress(void * addr,
566 UInt32 * inOutAddrBytes) = 0;
567
568 /*! @function setHardwareAddress
569 @abstract Set or change the station address used by the network
570 controller. This method call is synchronized by the workloop's gate.
571 @param buffer The buffer containing the hardware address provided by
572 the client.
573 @param addrBytes The size of the address buffer provided by the
574 client in bytes.
575 @result kIOReturnSuccess on success, or an error otherwise. */
576
577 virtual IOReturn setHardwareAddress(const void * addr,
578 UInt32 addrBytes) = 0;
579
580 /*! @function enable
581 @abstract An enable request from a client.
582 @discussion Handle an enable request from a client. A client will call
583 enable after it has opened the controller, and before it starts to use
584 the controller to send and to receive packets over the network. The
585 client object provided is typecasted using OSDynamicCast, and depending
586 on whether the client is an IOKernelDebugger or an IONetworkInterface,
587 then an overloaded enable method that takes a more specific argument
588 type is called. If the client matches neither type, then
589 kIOReturnBadArgument is returned. A driver has the option of overriding
590 this base enable method, or the overloaded form. This method call is
591 synchronized by the workloop's gate.
592 @param client The client object requesting the enable.
593 @result The return value from the overloaded enable() method, or
594 kIOReturnBadArgument if the client type is unknown. */
595
596 virtual IOReturn enable(IOService * client);
597
598 /*! @function disable
599 @abstract A disable request from a client.
600 @discussion Handle a disable request from a client. A client will call
601 disable if it has previously enabled the controller, and it no longer
602 needs to transport packets or perform I/O using the controller.
603 The client object is typecasted using OSDynamicCast, and depending on
604 whether the client is an IOKernelDebugger or an IONetworkInterface,
605 then an overloaded disable method that takes a more specific argument
606 type is called. If the client matches neither type, then
607 kIOReturnBadArgument is returned. A driver has the option of overriding
608 this base disable method, or the overloaded form. This method call is
609 synchronized by the workloop's gate.
610 @param client The client object requesting the disable.
611 @result The return from the overloaded disable() method, or
612 kIOReturnBadArgument if the client type is unknown. */
613
614 virtual IOReturn disable(IOService * client);
615
616 /*! @function setMaxPacketSize
617 @abstract A client request to change the maximum packet size.
618 @discussion This method call is synchronized by the workloop's gate.
619 @param maxSize The new maximum packet size.
620 @result kIOReturnUnsupported. Drivers may override this method
621 and return either kIOReturnSuccess to indicate that the new size
622 was accepted and is in effect, or an error code to indicate failure. */
623
624 virtual IOReturn setMaxPacketSize(UInt32 maxSize);
625
626 /*! @function getMaxPacketSize
627 @abstract Get the maximum packet size supported by the controller.
628 @param maxSize Pointer to the return value.
629 @result kIOReturnSuccess on success, or an error code otherwise. */
630
631 virtual IOReturn getMaxPacketSize(UInt32 * maxSize) const = 0;
632
633 /*! @function getMinPacketSize
634 @abstract Get the minimum packet size supported by the controller.
635 @param minSize Pointer to the return value.
636 @result kIOReturnSuccess on success, or an error code otherwise. */
637
638 virtual IOReturn getMinPacketSize(UInt32 * minSize) const = 0;
639
640 /*! @function selectMedium
641 @abstract A client request to change the medium selection.
642 @discussion This method is called when a client issues a command
643 for the controller to change its current medium selection.
644 The implementation must call setSelectedMedium() after the change
645 has occurred. This method call is synchronized by the workloop's
646 gate.
647 @param medium An entry from the published medium dictionary that
648 represents the selection chosen by the client.
649 @result kIOReturnUnsupported. Drivers may override this method and
650 return kIOReturnSuccess if the selection was successful,
651 or an error code otherwise. */
652
653 virtual IOReturn selectMedium(const IONetworkMedium * medium);
654
655 /*! @function selectMediumWithName
656 @abstract A client request to change the medium selection.
657 @discussion This method is called when a client issues a command
658 for the controller to change its current medium selection.
659 This implementation will look for an entry in the medium
660 dictionary published by the driver that is associated with the
661 key given. If a match is found, then selectMedium() is called to
662 perform the selection, otherwise an error is reported back to the
663 client. Subclasses should override selectMedium() and not this
664 method. This method call is synchronized by the workloop's gate.
665 @param mediumName An OSSymbol object that describes the name of the
666 new medium selected by the client.
667 @result The return from selectMedium() if a matching entry was found
668 from the medium dictionary. kIOReturnUnsupported if a medium
669 dictionary does not exist, or kIOReturnBadArgument if the name given
670 does not match any entry in the medium dictionary. */
671
672 virtual IOReturn selectMediumWithName(const OSSymbol * mediumName);
673
674 /*! @function getPacketFilters
675 @abstract Get the set of packet filters supported by the network
676 controller for the given filter group.
677 @discussion A subclass must implement this method and report the
678 set of filters that are supported for the given filter group.
679 This method call is synchronized by the workloop's gate.
680 @param group The name of the filter group.
681 @param filters Pointer to the mask of supported filters returned by
682 this method.
683 @result kIOReturnSuccess on success, or an error to indicate a
684 failure to discover the set of supported filters. */
685
686 virtual IOReturn getPacketFilters(const OSSymbol * group,
687 UInt32 * filters) const = 0;
688
689 /*! @function enablePacketFilter
690 @abstract Enable one of the supported packet filters from the
691 given filter group.
692 @discussion A client will call this method to enable a supported filter
693 from the filter group specified. If the client wishes to enable more
694 than one filter, it must call this method multiple times to enable the
695 desired set of filters. This method call is synchronized by the
696 workloop's gate.
697 @param group The name of the filter group containing the filter to be
698 enabled.
699 @param aFilter The filter to enable.
700 @param enabledFilters All filters currently enabled by the client.
701 @param options Optional flags for the enable request.
702 @result kIOReturnSuccess on success, or an error otherwise. */
703
704 virtual IOReturn enablePacketFilter(const OSSymbol * group,
705 UInt32 aFilter,
706 UInt32 enabledFilters,
707 IOOptionBits options = 0) = 0;
708
709 /*! @function disablePacketFilter
710 @abstract Disable a packet filter that is currently enabled from the
711 given filter group.
712 @discussion After a supported filter has been successfully enabled,
713 a client can call this method to disable that filter. This method call
714 is synchronized by the workloop's gate.
715 @param group The name of the filter group containing the filter to be
716 disabled.
717 @param aFilter The filter to disable.
718 @param enabledFilters All filters currently enabled by the client.
719 @param options Optional flags for the disable request.
720 @result kIOReturnSuccess on success, or an error otherwise. */
721
722 virtual IOReturn disablePacketFilter(const OSSymbol * group,
723 UInt32 aFilter,
724 UInt32 enabledFilters,
725 IOOptionBits options = 0) = 0;
726
727 /*! @function getOutputQueue
728 @abstract Get the IOOutputQueue object created by createOutputQueue().
729 @result Return a reference to the output queue object created by
730 createOutputQueue(). */
731
732 virtual IOOutputQueue * getOutputQueue() const;
733
734 /*! @function getPacketBufferConstraints
735 @abstract Get the controller's packet buffer constraints.
736 @discussion Called by start() to obtain the constraints on the
737 memory buffer for each mbuf packet allocated through allocatePacket().
738 Drivers can override this method to specify the buffer constraints
739 imposed by their bus master hardware. Note that outbound packets,
740 those that originate from the network stack, are not currently
741 subject to the constraints reported here.
742 @param constraints A pointer to an IOPacketBufferConstraints
743 structure that this method is expected to initialize.
744 See IOPacketBufferConstraints structure definition. */
745
746 virtual void getPacketBufferConstraints(
747 IOPacketBufferConstraints * constraints) const;
748
749 /*! @function allocatePacket
750 @abstract Allocate a packet with a data buffer that is larger than
751 or equal to the size specified.
752 @discussion This method will always return a single mbuf unless the
753 size requested (plus the alignment padding) is greater than MCLBYTES.
754 The data buffer for the mbuf (or a mbuf chain) returned is aligned
755 according to the constraints reported by getPacketBufferConstraints().
756 The length fields in each mbuf returned is set by this method, thus
757 allowing the mbuf to be passed directly to an IOMbufMemoryCursor object
758 in order to convert the mbuf to a physical address scatter-gather list.
759 @param size The minimum size of the data buffer for the mbuf
760 packet allocated.
761 @result A mbuf packet, or 0 if allocation failed. */
762
763 virtual struct mbuf * allocatePacket(UInt32 size);
764
765 /*! @function copyPacket
766 @abstract Allocate a new packet, containing data copied from an
767 existing source packet.
768 @discussion The source packet is not modified by this method.
769 @param m The source packet.
770 @param size The number of bytes to copy. If set to 0, then the
771 entire data buffer from the source packet is copied.
772 @result A new packet containing the same data as the source packet. */
773
774 virtual struct mbuf * copyPacket(const struct mbuf * m, UInt32 size = 0);
775
776 /*! @function replacePacket
777 @abstract Allocate a new packet to replace an existing packet, the
778 existing packet is then returned.
779 @param mp A handle to the existing packet.
780 @param size If size is 0, then the new packet shall have the same buffer
781 size as the original packet that is being replaced. Otherwise, the new
782 packet shall have the buffer size specified by this value.
783 @result If packet allocation was successful, then a replacement will
784 take place and the original packet will be returned. Otherwise, 0
785 is returned, and the original packet will be left untouched. */
786
787 virtual struct mbuf * replacePacket(struct mbuf ** mp, UInt32 size = 0);
788
789 /*! @function replaceOrCopyPacket
790 @abstract A helper method that combines the functionality of
791 copyPacket() and replacePacket() to process a packet containing
792 a received frame.
793 @discussion This method will either make a copy or replace the existing
794 packet, whichever is more time efficient. Packets containing small frames
795 are copied, otherwise they are replaced. If replaced, then the existing
796 packet is returned, and a new packet with the same buffer size is created
797 to take its place. If copied, the existing packet is left intact, while a
798 copy is returned that will hold a copy of the data from the source packet.
799 @param mp A handle to the existing packet that may be replaced.
800 @param length The number of bytes received held in the packet.
801 Must be greater than zero.
802 @param replaced Pointer to a return value that is set to true to indicate
803 that the existing packet was replaced, or false to indicate that the
804 existing packet was not replaced, and a copy was created.
805 @result A replacement or a copy of the existing packet, or 0 if packet
806 allocation failed. */
807
808 virtual struct mbuf * replaceOrCopyPacket(struct mbuf ** mp,
809 UInt32 length,
810 bool * replaced);
811
812 enum {
813 kDelayFree = 0x01
814 };
815
816 /*! @function freePacket
817 @abstract Release the packet given back to the free pool.
818 @param m The packet to be freed.
819 @param options When kDelayFree option is set, then the packet
820 provided to this function will be queued on the free packet queue.
821 A subsequent call to releaseFreePackets() will release all queued
822 packets by making a single BSD function call. Without the kDelayFree
823 option, the packet provided will be released immediately. */
824
825 virtual void freePacket(struct mbuf * m, IOOptionBits options = 0);
826
827 /*! @function releaseFreePackets
828 @abstract Release all packets held in the free packet queue.
829 @discussion The free packet queue is not protected by a lock. This
830 function must be called in a single threaded manner with respect to
831 all calls to freePacket() with the kDelayFree option set.
832 @result The number of packets queued and released. */
833
834 virtual UInt32 releaseFreePackets();
835
836 /*! @enum An enumeration of TCP/IP checksums that may be supported by the
837 hardware.
838 @constant kChecksumFamilyTCPIP A value that describes the collection
839 of TCP/IP checksums.
840 @constant kChecksumIP An IP header checksum.
841 @constant kChecksumTCP A TCP checksum that covers the TCP header and TCP
842 data.
843 @constant kChecksumUDP An UDP checksum that covers the UDP header and UDP
844 data.
845 @constant kChecksumTCPNoPseudoHeader A TCP checksum that covers the TCP
846 header and the TCP data, but the pseudo header is not included in the
847 checksum computation. A partial 16-bit checksum value must be provided
848 to allow the protocol stacks to calculate and verify the final checksum.
849 This type of checksum is not currently supported on the output path.
850 @constant kChecksumUDPNoPseudoHeader An UDP checksum that covers the UDP
851 header and the UDP data, but the pseudo header is not included in the
852 checksum computation. A partial 16-bit checksum value must be provided
853 to allow the protocol stacks to calculate and verify the final checksum.
854 This type of checksum is not currently supported on the output path.
855 @constant kChecksumTCPSum16 The hardware has a simple checksum engine
856 that can perform a TCP style ones complement sum of 16-bit words over
857 a certain range of bytes in a packet. The hardware does not have the
858 ability to scan for IP or TCP headers, and the driver must pass/get
859 additional parameter(s) to or from the protocol stack to coordinate
860 the checksumming effort. */
861
862 enum {
863 kChecksumFamilyTCPIP = 0x00000001,
864 kChecksumIP = 0x0001,
865 kChecksumTCP = 0x0002,
866 kChecksumUDP = 0x0004,
867 kChecksumTCPNoPseudoHeader = 0x0100,
868 kChecksumUDPNoPseudoHeader = 0x0200,
869 kChecksumTCPSum16 = 0x0400,
870 };
871
872 /*! @function getChecksumSupport
873 @abstract Get checksums that are supported by the network controller for
874 the given checksum family.
875 @discussion A network controller that is capable of inserting and verifying
876 checksums on output and input packets, should override this method and
877 advertise its capability in order to assist or offload the software checksum
878 calculations performed by the protocol stacks.
879 @param checksumMask A pointer to the mask of supported checksums returned
880 by this method.
881 @param checksumFamily A value that specifies the checksum family.
882 @param isOutput Set to true to query the support for checksum insertion on
883 output packets, or false to query the support for checksum verification
884 on input packets. Controllers that have symmetric hardware checksum support
885 can return a fixed checksum mask value, and ignore this argument.
886 @result Default return is kIOReturnUnsupported. Controllers that override
887 this method must return kIOReturnSuccess. Any other return value will be
888 interpretated as a lack of checksum support, regardless of the value
889 returned through the first argument. */
890
891 virtual IOReturn getChecksumSupport( UInt32 * checksumMask,
892 UInt32 checksumFamily,
893 bool isOutput );
894
895 /*! @function setChecksumResult
896 @abstract Encode a received packet with the checksum result reported
897 by the hardware.
898 @discussion A network controller that can verify the checksum(s) for a
899 received packet, should call this method to encode the result on the
900 packet, before passing it up towards the protocol stacks.
901 @param packet A mbuf containing a packet that has been checksummed by
902 the hardware.
903 @param checksumFamily A value that specifies the checksum family.
904 @param resultMask A mask of all checksums that were checked or computed.
905 Setting a bit implies that the driver is able to report the result of
906 the checksum computation, by asserting the validity of the checksum,
907 or by returning a partial checksum value.
908 @param validMask A mask of all checksums are were computed and verified
909 by the hardware as valid. Certain types of checksum performed by the
910 hardware are inheritely incomplete, and therefore should never be marked
911 as valid. A checksum cannot be marked valid unless it has also been
912 checked.
913 @param param0 Optional parameter 0, defaults to 0.
914 @param param1 Optional parameter 1, defaults to 0.
915 @result true if the checksum family is valid and the packet has been
916 encoded with the checksum result provided, false otherwise. */
917
918 virtual bool setChecksumResult( struct mbuf * packet,
919 UInt32 checksumFamily,
920 UInt32 resultMask,
921 UInt32 validMask,
922 UInt32 param0 = 0,
923 UInt32 param1 = 0 );
924
925 /*! @function getChecksumDemand
926 @abstract Fetch the demand for hardware checksum computation and insertion
927 for the given packet before it is transmitted on the network.
928 @discussion A network controller that can insert a checksum for output
929 packets must call this method to obtain the set of checksums that it must
930 compute, and insert into the appropriate fields in the given output packet.
931 @param packet A mbuf containing a packet that may be missing one or more
932 checksums in the specified checksum family.
933 @param checksumFamily A value which specifies the checksum family.
934 @param demandMask A mask of all checksums that the hardware must compute
935 and insert into the appropriate checksum fields in the packet.
936 @param param0 Optional parameter 0, defaults to 0.
937 @param param1 Optional parameter 1, defaults to 0. */
938
939 virtual void getChecksumDemand( const struct mbuf * packet,
940 UInt32 checksumFamily,
941 UInt32 * demandMask,
942 void * param0 = 0,
943 void * param1 = 0 );
944
945 /*! @function publishMediumDictionary
946 @abstract Publish a dictionary of IONetworkMedium objects to
947 advertise the media selection supported by the network controller.
948 @discussion Called by drivers to publish their medium dictionary.
949 Each entry in the dictionary is an IONetworkMedium object that
950 represents a single medium that is supported by the controller.
951 This method will make a copy of the dictionary provided, then add
952 the copy to the driver's property table. The dictionary provided
953 can be released by the caller upon returning from this method.
954 It is permissible to call this method multiple times, which may be
955 necessary if the hardware's media capability changes dynamically.
956 However, if the capability is static, which is often the case,
957 then drivers will typically call this method only once from
958 its start() method.
959
960 Several methods depend on the presence of a medium dictionary.
961 They should be called after the medium dictionary has been
962 published. Those methods are:
963 setSelectedMedium()
964 getSelectedMedium()
965 getMediumDictionary()
966 copyMediumDictionary()
967
968 @param mediumDict A dictionary of IONetworkMedium objects.
969 @result true if the dictionary is valid, and was successfully
970 exported to the property table, false otherwise. */
971
972 virtual bool publishMediumDictionary(const OSDictionary * mediumDict);
973
974 /*! @function setSelectedMedium
975 @abstract Designate an entry in the published medium dictionary as
976 the current selected medium.
977 @discussion After the driver has configured the hardware to select
978 one of its supported media types, it must call this method to inform
979 its parent about the change that has occurred. IONetworkController
980 will update a property in the registry to reflect the current selection.
981 @param medium A medium object representing the current selection.
982 @result true if the property table update was successful,
983 false if the update failed, or if the medium provided does not match
984 any entry from the published medium dictionary. */
985
986 virtual bool setSelectedMedium(const IONetworkMedium * medium);
987 inline bool setCurrentMedium(const IONetworkMedium * medium);
988
989 /*! @function setLinkStatus
990 @abstract Report the link status and the active medium.
991 @discussion Drivers must call this method when a link change is
992 detected. IONetworkController will update the link status properties
993 in the registry, and generate an event to inform the upper layers
994 about the change.
995 @param status Link status bits.
996 See IONetworkMedium for the definition of the link status bits.
997 @param activeMedium An object in the published medium dictionary
998 that represents the active medium. This may not be the same as
999 the selected medium. Set this to 0 if the link is inactive.
1000 @param speed Link speed in units of bits per second. If zero, then
1001 the link speed is taken from the medium object provided.
1002 @param data An OSData containing any additional link parameter that
1003 the driver wishes to publish to the registry.
1004 @result true if all link properties were successfully updated,
1005 false otherwise. */
1006
1007 virtual bool setLinkStatus(
1008 UInt32 status,
1009 const IONetworkMedium * activeMedium = 0,
1010 UInt64 speed = 0,
1011 OSData * data = 0);
1012
1013 protected:
1014
1015 /*! @function free
1016 @abstract Free the IONetworkController object.
1017 @discussion Free the IONetworkController object by releasing all
1018 allocated resources, followed by a call to super::free(). */
1019
1020 virtual void free();
1021
1022 /*! @function registerWithPolicyMaker
1023 @abstract Implemented by controller drivers to register with
1024 the power management policy-maker.
1025 @discussion Drivers that are able to power manage their hardware
1026 should override this method and register with the policy-maker
1027 provided by calling IOService::registerPowerDriver().
1028 IONetworkController will call this method before the initial
1029 attempt is made to attach a client.
1030 @param policyMaker The policy-maker chosen to manage power for
1031 this network controller.
1032 @result kIOReturnSuccess on success, kIOReturnUnsupported if the
1033 driver does not support power management, or an appropriate error
1034 return code. The default return is kIOReturnUnsupported. */
1035
1036 virtual IOReturn registerWithPolicyMaker(IOService * policyMaker);
1037
1038 /*! @function createWorkLoop
1039 @abstract Method called by IONetworkController prior to the initial
1040 getWorkLoop() call.
1041 @discussion Before IONetworkController calls getWorkLoop() in its
1042 start() method, it will call createWorkLoop() to make sure that a
1043 subclass that wants to create a workloop, will do so before its
1044 first use.
1045 @result True to indicate success, false otherwise. Returning false
1046 will fail IONetworkController::start(). */
1047
1048 virtual bool createWorkLoop();
1049
1050 /*! @function prepare
1051 @abstract Prepare the controller before an IOService is created and
1052 attached as a client.
1053 @discussion This method is called by attachInterface() or
1054 attachDebuggerClient() to prepare the controller before the new client
1055 object is attached. This method will call publishProperties() to publish
1056 controller capabilities and properties that may be used by client objects.
1057 However, publishProperties() will be called only once, even if prepare()
1058 is called multiple times. This method call is synchronized by the
1059 workloop's gate.
1060 @result kIOReturnSuccess on success, or an error code otherwise.
1061 Returning an error will fail the client attach. */
1062
1063 virtual IOReturn prepare();
1064
1065 /*! @function publishProperties
1066 @abstract Publish controller properties and capabilities.
1067 @discussion Called by IONetworkController to discover controller
1068 properties, and publish them to the property table in the I/O Kit
1069 registry. This method is called once by prepare().
1070 @result true if all properties were discovered and published
1071 successfully, false otherwise. Returning false will prevent client
1072 objects from attaching to the controller, since a property that
1073 a client relies upon may be missing. */
1074
1075 virtual bool publishProperties();
1076
1077 /*! @function getCommandClient
1078 @abstract Get the command client object.
1079 @discussion Methods called on the workloop context to service a
1080 client request can call this method to get the client object which
1081 initiated the command.
1082 @result The command client. If the caller is not running on the
1083 workloop thread, or if the thread does not have the workloop's gate
1084 closed, then 0 is returned. */
1085
1086 virtual OSObject * getCommandClient() const;
1087
1088 /*! @function handleOpen
1089 @abstract Handle a client open.
1090 @discussion Handle a client open on the controller object. IOService
1091 calls this method with the arbitration lock held. Subclasses
1092 should not override this method.
1093 @param client The client that is attempting to open the controller.
1094 @param options Not used. See IOService.
1095 @param argument Not used. See IOService.
1096 @result true to accept the client open, false to refuse it. */
1097
1098 virtual bool handleOpen(IOService * client,
1099 IOOptionBits options,
1100 void * argument);
1101
1102 /*! @function handleClose
1103 @abstract Handle a client close.
1104 @discussion Handle a close from one of the client objects. IOService
1105 calls this method with the arbitration lock held. Subclasses
1106 should not override this method.
1107 @param client The client that is closing the controller.
1108 @param options Not used. See IOService. */
1109
1110 virtual void handleClose(IOService * client, IOOptionBits options);
1111
1112 /*! @function handleIsOpen
1113 @abstract Query whether a client has an open on the controller.
1114 @discussion This method is always called by IOService with the
1115 arbitration lock held. Subclasses should not override this method.
1116 @result true if the specified client, or any client if none (0) is
1117 specified, presently has an open on this object. */
1118
1119 virtual bool handleIsOpen(const IOService * client) const;
1120
1121 /*! @function enable
1122 @abstract A request from an interface client to enable the controller.
1123 @discussion Called by an interface client to enable the controller.
1124 Upon receiving this command, the controller driver must bring up the
1125 hardware and become ready to transmit and receive packets. A driver
1126 should also delay the allocation of most runtime resources until this
1127 method is called in order to conserve system resources. This method call
1128 is synchronized by the workloop's gate.
1129 @param interface The interface client object that requested the enable.
1130 @result kIOReturnUnsupported. Drivers that override this method must
1131 return kIOReturnSuccess on success, or an error code otherwise. */
1132
1133 virtual IOReturn enable(IONetworkInterface * interface);
1134
1135 /*! @function disable
1136 @abstract A request from an interface client to disable the controller.
1137 @discussion Called by an interface client to disable the controller.
1138 This method should stop the hardware and disable hardware interrupt
1139 sources. Any resources allocated by enable() should also be deallocated.
1140 This method call is synchronized by the workloop's gate.
1141 @param interface The interface object that requested the disable.
1142 @result kIOReturnUnsupported. Drivers that override this method must
1143 return kIOReturnSuccess on success, or an error code otherwise. */
1144
1145 virtual IOReturn disable(IONetworkInterface * interface);
1146
1147 /*! @function attachInterface
1148 @abstract Attach a new interface client object.
1149 @discussion Create a new interface object and attach it to the
1150 controller. The createInterface() method is called to perform
1151 the interface allocation and initialization, followed by a call to
1152 configureInterface() to configure it. Subclasses can override those
1153 two methods to customize the interface client attached. Drivers will
1154 usually call this method from start(), after they are ready to process
1155 client requests. Since most drivers will have a single interface
1156 client, this method will likely be called only once.
1157 @param interface Upon success (return value is true), the
1158 interface object will be written to the handle provided.
1159 @param doRegister If true, then registerService() is called to register
1160 the interface, which will trigger the matching process, and will ultimately
1161 cause the interface to become registered with the data link layer.
1162 Drivers that wish to delay the registration can set doRegister to false,
1163 and call registerService() on the interface object when the controller
1164 becomes ready. This allows the driver to attach an interface without
1165 making its services available to the rest of the system.
1166 @result true on success, false otherwise. */
1167
1168 virtual bool attachInterface(IONetworkInterface ** interface,
1169 bool doRegister = true);
1170
1171 /*! @function detachInterface
1172 @abstract Detach an interface client object.
1173 @discussion This method will verify that the object provided is indeed
1174 an IONetworkInterface instance, and then call its terminate() method.
1175 Note that an interface object will close and detach from its
1176 controller after the data link layer has removed all references to
1177 all data structures exposed by the interface. The interface object
1178 should be released following this call.
1179 @param interface An interface object to be detached and terminated.
1180 @param sync If true, the interface is terminated synchronously.
1181 This may cause this method to block for an indeterminate
1182 amount of time. */
1183
1184 virtual void detachInterface(IONetworkInterface * interface,
1185 bool sync = false);
1186
1187 /*! @function createInterface
1188 @abstract Create a new network interface object.
1189 @discussion This method is called by attachInterface() to perform
1190 allocation and initialization of a new interface object. A subclass of
1191 IONetworkController must implement this method and return a matching
1192 interface object. For example, IOEthernetController's implementation
1193 will return an IOEthernetInterface object when createInterface() is
1194 called.
1195 @result A newly allocated and initialized interface object. */
1196
1197 virtual IONetworkInterface * createInterface() = 0;
1198
1199 /*! @function configureInterface
1200 @abstract Configure a newly created network interface object.
1201 @discussion Configure an interface object that was created by
1202 createInterface(). Subclasses can override this method to customize,
1203 and examine the interface object that will be attached to the
1204 controller as a client.
1205 @param interface The interface object to be configured.
1206 @result true if the operation was successful, false otherwise
1207 (this will cause attachInterface() to fail and return 0). */
1208
1209 virtual bool configureInterface(IONetworkInterface * interface);
1210
1211 /*! @function createOutputQueue
1212 @abstract Create an IOOutputQueue to handle output packet queueing,
1213 and also to resolve contention for the controller's transmitter from
1214 multiple client threads.
1215 @discussion Called by start() to create an IOOutputQueue object to
1216 handle output packet queueing. The default implementation will always
1217 return 0, hence no output queue will be created. A driver may override
1218 this method and return a subclass of IOOutputQueue. IONetworkController
1219 will keep a reference to the queue created, and will release this
1220 object when IONetworkController is freed. Also see getOutputQueue().
1221 @result A newly allocated and initialized IOOutputQueue object. */
1222
1223 virtual IOOutputQueue * createOutputQueue();
1224
1225 /*! @function enable
1226 @abstract An enable request from an IOKernelDebugger client.
1227 @discussion Drivers that provide debugging support may either override
1228 this method and setup the hardware to support the polled-mode send and
1229 receive methods; receivePacket() and sendPacket(). Or override the base
1230 enable() and disable() methods that take an IOService argument.
1231 @param debugger The IOKernelDebugger client requesting the enable.
1232 @result kIOReturnSuccess. Drivers must return kIOReturnSuccess
1233 on success, or an error otherwise. */
1234
1235 virtual IOReturn enable(IOKernelDebugger * debugger);
1236
1237 /*! @function disable
1238 @abstract A disable request from an IOKernelDebugger client.
1239 @discussion Drivers that provide debugging support may either override
1240 this method to disable support for the polled-mode send and receive
1241 methods. Or override the base enable() and disable() methods that
1242 take an IOService argument.
1243 @param debugger The IOKernelDebugger client requesting the disable.
1244 @result kIOReturnSuccess. Drivers must return kIOReturnSuccess
1245 on success, or an error otherwise. */
1246
1247 virtual IOReturn disable(IOKernelDebugger * debugger);
1248
1249 /*! @function attachDebuggerClient
1250 @abstract Attach a new IOKernelDebugger client object.
1251 @discussion Allocate an IOKernelDebugger object and attach it as
1252 a client. Having a debugger client implies that the controller
1253 supports kernel debugging, and therefore must implement the two
1254 polled-mode methods that are called by the debugger client. See
1255 sendPacket() and receivePacket(). Only a single debugger client
1256 should be attached to each controller.
1257 @param debuggerP A handle that will return the new
1258 IOKernelDebugger object created.
1259 @result true on success, false otherwise. */
1260
1261 virtual bool attachDebuggerClient(IOKernelDebugger ** debuggerP);
1262
1263 /*! @function detachDebuggerClient
1264 @abstract Detach an IOKernelDebugger client object.
1265 @discussion Detach and terminate the IOKernelDebugger client object
1266 provided. A synchronous termination is issued, and this method will
1267 return after the debugger client has been terminated. The debugger
1268 client should be released following this call.
1269 @param debugger The IOKernelDebugger object to be detached and
1270 terminated. If the argument provided is NULL or is not an
1271 IOKernelDebugger, this method will return immediately. */
1272
1273 virtual void detachDebuggerClient(IOKernelDebugger * debugger);
1274
1275 /*! @function reserveDebuggerLock
1276 @abstract Take the global debugger lock.
1277 @discussion This method should not be used. Instead, call the
1278 lock() method provided by IOKernelDebugger. */
1279
1280 void reserveDebuggerLock();
1281
1282 /*! @function releaseDebuggerLock
1283 @abstract Release the global debugger lock.
1284 @discussion This method should not be used. Instead, call the
1285 unlock() method provided by IOKernelDebugger. */
1286
1287 void releaseDebuggerLock();
1288
1289 /*! @function receivePacket
1290 @abstract Debugger polled-mode receive handler.
1291 @discussion This method must be implemented by a driver that supports
1292 kernel debugging. After a debugger client has been attached through
1293 attachDebuggerClient(), this method will be called by the debugger
1294 client to poll for a incoming packet when the kernel debugger is active.
1295 This method may be called from the primary interrupt context, and the
1296 implementation must avoid any memory allocation, and must never block.
1297 The receivePacket() method in IONetworkController is used as a placeholder,
1298 it performs no useful action, and should not be called. A driver that
1299 attaches a debugger client must override this method.
1300 @param pkt Address of a receive buffer where the received packet should
1301 be stored. This buffer has room for 1518 bytes.
1302 @param pktSize Address where the number of bytes received must be
1303 recorded. Set this to zero if no packets were received during
1304 the timeout interval.
1305 @param timeout The maximum amount of time in milliseconds to poll for
1306 a packet to arrive before this method must return. */
1307
1308 virtual void receivePacket(void * pkt, UInt32 * pktSize, UInt32 timeout);
1309
1310 /*! @function sendPacket
1311 @abstract Debugger polled-mode transmit handler.
1312 @discussion This method must be implemented by a driver that supports
1313 kernel debugging. After a debugger client has been attached through
1314 attachDebuggerClient(), this method will be called by the debugger
1315 to send an outbound packet only when the kernel debugger is active.
1316 This method may be called from the primary interrupt context, and the
1317 implementation must avoid any memory allocation, and must never block.
1318 The sendPacket() method in IONetworkController is used as a placeholder,
1319 it performs no useful action, and should not be called. A driver that
1320 attaches a debugger client must override this method.
1321 @param pkt Pointer to a transmit buffer containing the packet to be
1322 sent on the network.
1323 @param pktSize The size of the transmit buffer in bytes. */
1324
1325 virtual void sendPacket(void * pkt, UInt32 pktSize);
1326
1327 // Virtual function padding
1328 OSMetaClassDeclareReservedUnused( IONetworkController, 0);
1329 OSMetaClassDeclareReservedUnused( IONetworkController, 1);
1330 OSMetaClassDeclareReservedUnused( IONetworkController, 2);
1331 OSMetaClassDeclareReservedUnused( IONetworkController, 3);
1332 OSMetaClassDeclareReservedUnused( IONetworkController, 4);
1333 OSMetaClassDeclareReservedUnused( IONetworkController, 5);
1334 OSMetaClassDeclareReservedUnused( IONetworkController, 6);
1335 OSMetaClassDeclareReservedUnused( IONetworkController, 7);
1336 OSMetaClassDeclareReservedUnused( IONetworkController, 8);
1337 OSMetaClassDeclareReservedUnused( IONetworkController, 9);
1338 OSMetaClassDeclareReservedUnused( IONetworkController, 10);
1339 OSMetaClassDeclareReservedUnused( IONetworkController, 11);
1340 OSMetaClassDeclareReservedUnused( IONetworkController, 12);
1341 OSMetaClassDeclareReservedUnused( IONetworkController, 13);
1342 OSMetaClassDeclareReservedUnused( IONetworkController, 14);
1343 OSMetaClassDeclareReservedUnused( IONetworkController, 15);
1344 OSMetaClassDeclareReservedUnused( IONetworkController, 16);
1345 OSMetaClassDeclareReservedUnused( IONetworkController, 17);
1346 OSMetaClassDeclareReservedUnused( IONetworkController, 18);
1347 OSMetaClassDeclareReservedUnused( IONetworkController, 19);
1348 OSMetaClassDeclareReservedUnused( IONetworkController, 20);
1349 OSMetaClassDeclareReservedUnused( IONetworkController, 21);
1350 OSMetaClassDeclareReservedUnused( IONetworkController, 22);
1351 OSMetaClassDeclareReservedUnused( IONetworkController, 23);
1352 OSMetaClassDeclareReservedUnused( IONetworkController, 24);
1353 OSMetaClassDeclareReservedUnused( IONetworkController, 25);
1354 OSMetaClassDeclareReservedUnused( IONetworkController, 26);
1355 OSMetaClassDeclareReservedUnused( IONetworkController, 27);
1356 OSMetaClassDeclareReservedUnused( IONetworkController, 28);
1357 OSMetaClassDeclareReservedUnused( IONetworkController, 29);
1358 OSMetaClassDeclareReservedUnused( IONetworkController, 30);
1359 OSMetaClassDeclareReservedUnused( IONetworkController, 31);
1360 };
1361
1362 inline const IONetworkMedium * IONetworkController::getCurrentMedium() const
1363 {
1364 return getSelectedMedium();
1365 }
1366
1367 inline bool IONetworkController::setCurrentMedium(const IONetworkMedium * medium)
1368 {
1369 return setSelectedMedium(medium);
1370 }
1371
1372 #endif /* defined(KERNEL) && defined(__cplusplus) */
1373
1374 #endif /* !_IONETWORKCONTROLLER_H */
1375