Root/
Source at commit 1446 created 12 years 11 months ago. By jrcs, Fix multiboot | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2008 Apple 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 | #ifndef _IOETHERNETINTERFACE_H␊ |
24 | #define _IOETHERNETINTERFACE_H␊ |
25 | ␊ |
26 | /*! @defined kIOEthernetInterfaceClass␊ |
27 | @abstract The name of the␊ |
28 | IOEthernetInterface class. ␊ |
29 | */␊ |
30 | ␊ |
31 | #define kIOEthernetInterfaceClass "IOEthernetInterface"␊ |
32 | ␊ |
33 | /*! @defined kIOActivePacketFilters␊ |
34 | @abstract A property of IOEthernetInterface objects.␊ |
35 | @discussion The kIOActivePacketFilters property has an OSDictionary value that describes the current␊ |
36 | set of packet filters that have been successfully activated. Each␊ |
37 | entry in the dictionary is a key/value pair consisting of the filter␊ |
38 | group name, and an OSNumber describing the set of active filters for␊ |
39 | that group. Entries in this dictionary will mirror those in␊ |
40 | kIORequiredPacketFilters if the controller has reported success for␊ |
41 | all filter change requests from the IOEthernetInterface object. ␊ |
42 | */␊ |
43 | ␊ |
44 | #define kIOActivePacketFilters "IOActivePacketFilters"␊ |
45 | ␊ |
46 | /*! @defined kIORequiredPacketFilters␊ |
47 | @abstract A property of IOEthernetInterface objects.␊ |
48 | @discussion The kIORequiredPacketFilters property has an OSDictionary value that describes the current␊ |
49 | set of required packet filters. Each entry in the dictionary is a␊ |
50 | key/value pair consisting of the filter group name, and an OSNumber␊ |
51 | describing the set of required filters for that group. ␊ |
52 | */␊ |
53 | ␊ |
54 | #define kIORequiredPacketFilters "IORequiredPacketFilters"␊ |
55 | ␊ |
56 | /*! @defined kIOMulticastAddressList␊ |
57 | @abstract A property of IOEthernetInterface objects.␊ |
58 | @discussion The kIOMulticastAddressList property is an OSData object that describes the␊ |
59 | list of multicast addresses that are being used by the␊ |
60 | controller to match against the destination address of an␊ |
61 | incoming frame. ␊ |
62 | */␊ |
63 | ␊ |
64 | #define kIOMulticastAddressList "IOMulticastAddressList"␊ |
65 | #define kIOMulticastFilterData kIOMulticastAddressList ␊ |
66 | ␊ |
67 | /*␊ |
68 | * Kernel␊ |
69 | */␊ |
70 | #if defined(KERNEL) && defined(__cplusplus)␊ |
71 | ␊ |
72 | #include <IOKit/network/IONetworkInterface.h>␊ |
73 | #include <IOKit/network/IOEthernetController.h>␊ |
74 | #include <IOKit/network/IOEthernetStats.h>␊ |
75 | ␊ |
76 | /*! @class IOEthernetInterface␊ |
77 | @abstract The Ethernet interface object. ␊ |
78 | @discussion An Ethernet controller driver,␊ |
79 | that is a subclass of IOEthernetController, will instantiate an object␊ |
80 | of this class when the driver calls the attachInterface() method.␊ |
81 | This interface object will then vend an Ethernet interface to DLIL,␊ |
82 | and manage the connection between the controller driver and the upper␊ |
83 | networking layers. Drivers will seldom need to subclass␊ |
84 | IOEthernetInterface. ␊ |
85 | */␊ |
86 | ␊ |
87 | class IOEthernetInterface : public IONetworkInterface␊ |
88 | {␊ |
89 | OSDeclareDefaultStructors( IOEthernetInterface )␊ |
90 | ␊ |
91 | private:␊ |
92 | thread_call_t _inputEventThreadCall; // inputEvent() thread call␊ |
93 | UInt32 _mcAddrCount; // # of multicast addresses␊ |
94 | bool _ctrEnabled; // Is controller enabled?␊ |
95 | OSDictionary * _supportedFilters; // Controller's supported filters␊ |
96 | OSDictionary * _requiredFilters; // The required filters␊ |
97 | OSDictionary * _activeFilters; // Currently active filters ␊ |
98 | bool _controllerLostPower; // true if controller is unusable␊ |
99 | ␊ |
100 | struct ExpansionData { ␊ |
101 | ␉␉UInt32 altMTU; // track the physical mtu of controller␊ |
102 | ␉␉UInt32 publishedFeatureID; // id for published wake packet␊ |
103 | uint32_t supportedWakeFilters; // bitmask of supported wake filters␊ |
104 | OSNumber * disabledWakeFilters; // OSNumber of disabled wake filters␊ |
105 | ␉};␊ |
106 | /*! @var reserved␊ |
107 | Reserved for future use. (Internal use only) */␊ |
108 | ExpansionData * _reserved;␊ |
109 | ␊ |
110 | ␊ |
111 | IOReturn enableController(IONetworkController * ctr);␊ |
112 | IOReturn setupMulticastFilter(IONetworkController * ctr);␊ |
113 | ␊ |
114 | UInt32 getFilters(const OSDictionary * dict,␊ |
115 | const OSSymbol * group);␊ |
116 | ␊ |
117 | bool setFilters(OSDictionary * dict,␊ |
118 | const OSSymbol * group,␊ |
119 | UInt32 filters);␊ |
120 | ␊ |
121 | IOReturn disableFilter(IONetworkController * ctr,␊ |
122 | const OSSymbol * group,␊ |
123 | UInt32 filter,␊ |
124 | IOOptionBits options = 0);␊ |
125 | ␊ |
126 | IOReturn enableFilter(IONetworkController * ctr,␊ |
127 | const OSSymbol * group,␊ |
128 | UInt32 filter,␊ |
129 | IOOptionBits options = 0);␊ |
130 | ␊ |
131 | int syncSIOCSIFFLAGS(IONetworkController * ctr);␊ |
132 | int syncSIOCSIFADDR(IONetworkController * ctr);␊ |
133 | int syncSIOCADDMULTI(IONetworkController * ctr);␊ |
134 | int syncSIOCDELMULTI(IONetworkController * ctr);␊ |
135 | int syncSIOCSIFMTU(IONetworkController * ctr, struct ifreq * ifr, bool);␊ |
136 | int syncSIOCGIFDEVMTU(IONetworkController * ctr, struct ifreq * ifr);␊ |
137 | int syncSIOCSIFLLADDR(IONetworkController * ctr, const char * lladdr, int len);␊ |
138 | ␉void _fixupVlanPacket(mbuf_t, u_int16_t, int);␊ |
139 | void reportInterfaceWakeFlags(void);␊ |
140 | ␊ |
141 | static void handleEthernetInputEvent(thread_call_param_t param0, thread_call_param_t param1);␊ |
142 | static int performGatedCommand(void *, void *, void *, void *, void *);␊ |
143 | ␉static IOReturn enableFilter_Wrapper(␊ |
144 | IOEthernetInterface *, IONetworkController *, const OSSymbol *, UInt32 , IOOptionBits);␊ |
145 | ␊ |
146 | public:␊ |
147 | ␊ |
148 | /*! @function init␊ |
149 | @abstract Initializes an IOEthernetInterface instance.␊ |
150 | @discussion Instance variables are initialized, and an arpcom␊ |
151 | structure is allocated.␊ |
152 | @param controller A network controller object that will service␊ |
153 | the interface object being initialized.␊ |
154 | @result Returns true on success, false otherwise. ␊ |
155 | */␊ |
156 | ␊ |
157 | virtual bool init( IONetworkController * controller );␊ |
158 | ␊ |
159 | /*! @function getNamePrefix␊ |
160 | @abstract Returns a string containing the prefix to use when␊ |
161 | creating a BSD name for this interface.␊ |
162 | @discussion The BSD name for each interface object is created by␊ |
163 | concatenating a string returned by this method, with an unique␊ |
164 | unit number assigned by IONetworkStack.␊ |
165 | @result Returns a pointer to a constant C string "en". Therefore, Ethernet␊ |
166 | interfaces will be registered with BSD as en0, en1, etc. ␊ |
167 | */␊ |
168 | ␊ |
169 | virtual const char * getNamePrefix() const;␊ |
170 | ␊ |
171 | /*! @function setProperties␊ |
172 | @abstract Handles a request to set Ethernet interface properties from␊ |
173 | kernel or non-kernel clients. ␊ |
174 | @discussion For non-kernel clients, the preferred␊ |
175 | access mechanism is through a user client connection.␊ |
176 | @param properties An OSDictionary containing a collection of␊ |
177 | properties.␊ |
178 | @result Returns kIOReturnUnsupported if the interface did not␊ |
179 | recognize any of the properties provided. Otherwise, the return␊ |
180 | code will be kIOReturnSuccess to indicate no errors, or an␊ |
181 | IOReturn error code to indicate that an error occurred while␊ |
182 | handling one of the properties. ␊ |
183 | */␊ |
184 | ␊ |
185 | virtual IOReturn setProperties( OSObject * properties );␊ |
186 | ␊ |
187 | protected:␊ |
188 | ␊ |
189 | /*! @function free␊ |
190 | @abstract Frees the IOEthernetInterface instance.␊ |
191 | @discussion The memory allocated for the arpcom structure is released,␊ |
192 | followed by a call to super::free(). ␊ |
193 | */␊ |
194 | ␊ |
195 | virtual void free();␊ |
196 | ␊ |
197 | /*! @function performCommand␊ |
198 | @abstract Handles an ioctl command sent to the Ethernet interface.␊ |
199 | @discussion This method handles socket ioctl commands sent to the Ethernet␊ |
200 | interface from DLIL. Commands recognized and processed by this method are␊ |
201 | SIOCSIFADDR, SIOCSIFFLAGS, SIOCADDMULTI, and SIOCDELMULTI. Other commands␊ |
202 | are passed to the superclass.␊ |
203 | @param controller The controller object.␊ |
204 | @param cmd The ioctl command code.␊ |
205 | @param arg0 Command argument 0. Generally a pointer to an ifnet structure␊ |
206 | associated with the interface.␊ |
207 | @param arg1 Command argument 1.␊ |
208 | @result Returns a BSD return value defined in bsd/sys/errno.h. ␊ |
209 | */␊ |
210 | ␊ |
211 | virtual SInt32 performCommand(IONetworkController * controller,␊ |
212 | unsigned long cmd,␊ |
213 | void * arg0,␊ |
214 | void * arg1);␊ |
215 | ␊ |
216 | /*! @function controllerDidOpen␊ |
217 | @abstract A notification that the interface has opened the network␊ |
218 | controller.␊ |
219 | @discussion This method will be called by IONetworkInterface after a␊ |
220 | network controller has accepted an open from this interface object.␊ |
221 | IOEthernetInterface will first call the implementation in its␊ |
222 | superclass, then inspect the controller through properties published␊ |
223 | in the registry. This method is called with the arbitration lock held.␊ |
224 | @param controller The controller object that was opened.␊ |
225 | @result Returns true on success, false otherwise. Returning false will␊ |
226 | cause the controller to be closed, and any pending client opens to be␊ |
227 | rejected. ␊ |
228 | */␊ |
229 | ␊ |
230 | virtual bool controllerDidOpen(IONetworkController * controller);␊ |
231 | ␊ |
232 | /*! @function controllerWillClose␊ |
233 | @abstract A notification that the interface will close the network␊ |
234 | controller.␊ |
235 | @discussion This method will simply call super to propagate the method␊ |
236 | call. This method is called with the arbitration lock held.␊ |
237 | @param controller The controller that is about to be closed. ␊ |
238 | */␊ |
239 | ␊ |
240 | virtual void controllerWillClose(IONetworkController * controller);␊ |
241 | ␊ |
242 | ␊ |
243 | /*! @function controllerWillChangePowerState␊ |
244 | @abstract Handles a notification that the network controller ␊ |
245 | servicing this interface object is about to transition to a new power state.␊ |
246 | @discussion If the controller is about to transition to an unusable state,␊ |
247 | and it is currently enabled, then the disable() method on the controller is␊ |
248 | called.␊ |
249 | @param controller The network controller object.␊ |
250 | @param flags Flags that describe the capability of the controller in the new␊ |
251 | power state.␊ |
252 | @param stateNumber An index to a state in the network controller's␊ |
253 | power state array that the controller is switching to.␊ |
254 | @param policyMaker A reference to the network controller's policy-maker,␊ |
255 | and is also the originator of this notification.␊ |
256 | @result Always returns kIOReturnSuccess. ␊ |
257 | */␊ |
258 | ␊ |
259 | virtual IOReturn controllerWillChangePowerState(␊ |
260 | IONetworkController * controller,␊ |
261 | IOPMPowerFlags flags,␊ |
262 | UInt32 stateNumber,␊ |
263 | IOService * policyMaker);␊ |
264 | ␊ |
265 | /*! @function controllerDidChangePowerState␊ |
266 | @abstract Handles a notification that the network controller servicing␊ |
267 | this interface object has transitioned to a new power state.␊ |
268 | @discussion If the controller did transition to a usable state, and it was␊ |
269 | previously disabled due to a previous power change, then it is re-enabled.␊ |
270 | @param controller The network controller object.␊ |
271 | @param flags Flags that describe the capability of the controller in the new␊ |
272 | power state.␊ |
273 | @param stateNumber An index to a state in the network controller's␊ |
274 | power state array that the controller has switched to.␊ |
275 | @param policyMaker A reference to the network controller's policy-maker,␊ |
276 | and is also the originator of this notification.␊ |
277 | @result Always returns kIOReturnSuccess. ␊ |
278 | */␊ |
279 | ␊ |
280 | virtual IOReturn controllerDidChangePowerState( ␊ |
281 | IONetworkController * controller,␊ |
282 | IOPMPowerFlags flags,␊ |
283 | UInt32 stateNumber,␊ |
284 | IOService * policyMaker);␊ |
285 | ␊ |
286 | public:␊ |
287 | /* Override IONetworkInterface::willTerminate() */␊ |
288 | ␊ |
289 | virtual bool willTerminate( IOService * provider,␊ |
290 | IOOptionBits options );␊ |
291 | ␊ |
292 | /* Override IONetworkInterface::attachToDataLinkLayer() */␊ |
293 | ␊ |
294 | virtual IOReturn attachToDataLinkLayer( IOOptionBits options,␊ |
295 | void * parameter );␊ |
296 | ␊ |
297 | /* Override IONetworkInterface::inputEvent() */␊ |
298 | ␊ |
299 | virtual bool inputEvent( UInt32 type, void * data );␊ |
300 | ␊ |
301 | protected:␊ |
302 | ␉virtual void feedPacketInputTap(mbuf_t);␊ |
303 | ␉virtual void feedPacketOutputTap(mbuf_t);␊ |
304 | ␉virtual bool initIfnetParams(struct ifnet_init_params *params);␊ |
305 | ␊ |
306 | public:␊ |
307 | // Virtual function padding␊ |
308 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 0);␊ |
309 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 1);␊ |
310 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 2);␊ |
311 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 3);␊ |
312 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 4);␊ |
313 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 5);␊ |
314 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 6);␊ |
315 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 7);␊ |
316 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 8);␊ |
317 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 9);␊ |
318 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 10);␊ |
319 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 11);␊ |
320 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 12);␊ |
321 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 13);␊ |
322 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 14);␊ |
323 | OSMetaClassDeclareReservedUnused( IOEthernetInterface, 15);␊ |
324 | };␊ |
325 | ␊ |
326 | #endif /* defined(KERNEL) && defined(__cplusplus) */␊ |
327 | ␊ |
328 | #endif /* !_IOETHERNETINTERFACE_H */␊ |
329 |