Root/
Source at commit 1164 created 13 years 12 days ago. By azimutz, Add some pauses to nvidia.c and ati.c to help user feedback collection. | |
---|---|
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 _IONETWORKMEDIUM_H␊ |
24 | #define _IONETWORKMEDIUM_H␊ |
25 | ␊ |
26 | #ifdef __cplusplus␊ |
27 | extern "C" {␊ |
28 | #endif␊ |
29 | ␊ |
30 | #include <net/if_media.h>␊ |
31 | ␊ |
32 | /*! @typedef IOMediumType␊ |
33 | @discussion A 32-bit value divided into fields which describes␊ |
34 | a single medium type. */␊ |
35 | ␊ |
36 | typedef UInt32 IOMediumType;␊ |
37 | ␊ |
38 | /*! @defined kIOMediumType␊ |
39 | @abstract A property of IONetworkMedium objects.␊ |
40 | @discussion The kIOMediumType property is an OSNumber object that describes the type of␊ |
41 | medium that this object represents. ␊ |
42 | */␊ |
43 | ␊ |
44 | #define kIOMediumType "Type"␊ |
45 | ␊ |
46 | /*! @defined kIOMediumFlags␊ |
47 | @abstract A property of IONetworkMedium objects.␊ |
48 | @discussion The kIOMediumFlags property is an OSNumber object that describes a set of␊ |
49 | attributes assigned to the medium. ␊ |
50 | */␊ |
51 | ␊ |
52 | #define kIOMediumFlags "Flags"␊ |
53 | ␊ |
54 | /*! @defined kIOMediumSpeed␊ |
55 | @abstract A property of IONetworkMedium objects.␊ |
56 | @discussion The kIOMediumSpeed property is an OSNumber object that describes the maximum link␊ |
57 | speed supported by the medium in bits per second. ␊ |
58 | */␊ |
59 | ␊ |
60 | #define kIOMediumSpeed "Speed"␊ |
61 | ␊ |
62 | /*! @defined kIOMediumIndex␊ |
63 | @abstract A property of IONetworkMedium objects.␊ |
64 | @discussion The kIOMediumIndex property is an OSNumber object that describes an index assigned␊ |
65 | by the owner of the medium object. Its interpretation is driver␊ |
66 | specific.␊ |
67 | */␊ |
68 | ␊ |
69 | #define kIOMediumIndex "Index"␊ |
70 | ␊ |
71 | //===========================================================================␊ |
72 | // Medium Type (IOMediumType).␊ |
73 | //␊ |
74 | // The medium type is encoded by a 32-bit value. The definitions of␊ |
75 | // the fields and the encoding for each field is adapted from FreeBSD.␊ |
76 | //␊ |
77 | // Bits Definition␊ |
78 | // -------------------␊ |
79 | // 4-0 medium subtype␊ |
80 | // 7-5 network type␊ |
81 | // 15-8 network specific options␊ |
82 | // 19-16 reserved␊ |
83 | // 27-20 common options␊ |
84 | // 31-28 instance number␊ |
85 | ␊ |
86 | // Ethernet.␊ |
87 | //␊ |
88 | enum {␊ |
89 | kIOMediumEthernet = IFM_ETHER,␊ |
90 | kIOMediumEthernetAuto = ( IFM_AUTO | IFM_ETHER ),␊ |
91 | kIOMediumEthernetManual = ( IFM_MANUAL | IFM_ETHER ),␊ |
92 | kIOMediumEthernetNone = ( IFM_NONE | IFM_ETHER ),␊ |
93 | kIOMediumEthernet10BaseT = ( IFM_10_T | IFM_ETHER ),␊ |
94 | kIOMediumEthernet10Base2 = ( IFM_10_2 | IFM_ETHER ),␊ |
95 | kIOMediumEthernet10Base5 = ( IFM_10_5 | IFM_ETHER ),␊ |
96 | kIOMediumEthernet100BaseTX = ( IFM_100_TX | IFM_ETHER ),␊ |
97 | kIOMediumEthernet100BaseFX = ( IFM_100_FX | IFM_ETHER ),␊ |
98 | kIOMediumEthernet100BaseT4 = ( IFM_100_T4 | IFM_ETHER ),␊ |
99 | kIOMediumEthernet100BaseVG = ( IFM_100_VG | IFM_ETHER ),␊ |
100 | kIOMediumEthernet100BaseT2 = ( IFM_100_T2 | IFM_ETHER ),␊ |
101 | kIOMediumEthernet1000BaseSX = ( IFM_1000_SX | IFM_ETHER ),␊ |
102 | kIOMediumEthernet10BaseSTP = ( IFM_10_STP | IFM_ETHER ),␊ |
103 | kIOMediumEthernet10BaseFL = ( IFM_10_FL | IFM_ETHER ),␊ |
104 | kIOMediumEthernet1000BaseLX = ( IFM_1000_LX | IFM_ETHER ),␊ |
105 | kIOMediumEthernet1000BaseCX = ( IFM_1000_CX | IFM_ETHER ),␊ |
106 | kIOMediumEthernet1000BaseTX = ( IFM_1000_T | IFM_ETHER ), //deprecated- use kIOMediumEthernet1000BaseT instead␊ |
107 | kIOMediumEthernet1000BaseT = ( IFM_1000_T | IFM_ETHER ),␊ |
108 | kIOMediumEthernetHomePNA1 = ( IFM_HPNA_1 | IFM_ETHER ),␊ |
109 | ␉kIOMediumEthernet10GBaseSR = ( IFM_10G_SR | IFM_ETHER ),␊ |
110 | ␉kIOMediumEthernet10GBaseLR = ( IFM_10G_LR | IFM_ETHER ),␊ |
111 | kIOMediumEthernet10GBaseCX4 = ( IFM_10G_CX4 | IFM_ETHER ),␊ |
112 | kIOMediumEthernet10GBaseT = ( IFM_10G_T | IFM_ETHER )␊ |
113 | };␊ |
114 | ␊ |
115 | // IEEE 802.11 Wireless.␊ |
116 | //␊ |
117 | enum {␊ |
118 | kIOMediumIEEE80211 = IFM_IEEE80211,␊ |
119 | kIOMediumIEEE80211Auto = ( IFM_AUTO | IFM_IEEE80211 ),␊ |
120 | kIOMediumIEEE80211Manual = ( IFM_MANUAL | IFM_IEEE80211 ),␊ |
121 | kIOMediumIEEE80211None = ( IFM_NONE | IFM_IEEE80211 ),␊ |
122 | kIOMediumIEEE80211FH1 = ( IFM_IEEE80211_FH1 | IFM_IEEE80211 ),␊ |
123 | kIOMediumIEEE80211FH2 = ( IFM_IEEE80211_FH2 | IFM_IEEE80211 ),␊ |
124 | kIOMediumIEEE80211DS2 = ( IFM_IEEE80211_DS2 | IFM_IEEE80211 ),␊ |
125 | kIOMediumIEEE80211DS5 = ( IFM_IEEE80211_DS5 | IFM_IEEE80211 ),␊ |
126 | kIOMediumIEEE80211DS11 = ( IFM_IEEE80211_DS11 | IFM_IEEE80211 ),␊ |
127 | kIOMediumIEEE80211DS1 = ( IFM_IEEE80211_DS1 | IFM_IEEE80211 ),␊ |
128 | kIOMediumIEEE80211OptionAdhoc = IFM_IEEE80211_ADHOC␊ |
129 | };␊ |
130 | ␊ |
131 | // Common options.␊ |
132 | //␊ |
133 | enum {␊ |
134 | kIOMediumOptionFullDuplex = IFM_FDX,␊ |
135 | kIOMediumOptionHalfDuplex = IFM_HDX,␊ |
136 | kIOMediumOptionFlowControl = IFM_FLOW,␊ |
137 | kIOMediumOptionFlag0 = IFM_FLAG0,␊ |
138 | kIOMediumOptionFlag1 = IFM_FLAG1,␊ |
139 | kIOMediumOptionFlag2 = IFM_FLAG2,␊ |
140 | kIOMediumOptionLoopback = IFM_LOOP␊ |
141 | };␊ |
142 | ␊ |
143 | // Medium type masks.␊ |
144 | //␊ |
145 | #define kIOMediumSubTypeMask IFM_TMASK␊ |
146 | #define kIOMediumNetworkTypeMask IFM_NMASK␊ |
147 | #define kIOMediumOptionsMask IFM_OMASK␊ |
148 | #define kIOMediumCommonOptionsMask IFM_GMASK␊ |
149 | #define kIOMediumInstanceShift IFM_ISHIFT␊ |
150 | #define kIOMediumInstanceMask IFM_IMASK␊ |
151 | ␊ |
152 | // Medium type field accessors.␊ |
153 | //␊ |
154 | #define IOMediumGetSubType(x) ((x) & kIOMediumSubTypeMask)␊ |
155 | #define IOMediumGetNetworkType(x) ((x) & kIOMediumNetworkMask)␊ |
156 | #define IOMediumGetInstance(x) (((x) & kIOMediumInstanceMask) >> \␊ |
157 | kIOMediumInstanceShift)␊ |
158 | ␊ |
159 | //===========================================================================␊ |
160 | // Medium flags.␊ |
161 | ␊ |
162 | ␊ |
163 | //===========================================================================␊ |
164 | // Link status bits.␊ |
165 | //␊ |
166 | enum {␊ |
167 | kIONetworkLinkValid = IFM_AVALID, // link status is valid␊ |
168 | kIONetworkLinkActive = IFM_ACTIVE // link is up/active.␊ |
169 | };␊ |
170 | ␊ |
171 | #ifdef __cplusplus␊ |
172 | }␊ |
173 | #endif␊ |
174 | ␊ |
175 | //===========================================================================␊ |
176 | // IONetworkMedium class.␊ |
177 | ␊ |
178 | #ifdef KERNEL␊ |
179 | ␊ |
180 | #include <libkern/c++/OSObject.h>␊ |
181 | #include <libkern/c++/OSSymbol.h>␊ |
182 | ␊ |
183 | /*! @class IONetworkMedium␊ |
184 | @abstract An object that encapsulates information about a network␊ |
185 | medium (i.e. 10Base-T, or 100Base-T Full Duplex). ␊ |
186 | @discussion The main purpose of␊ |
187 | this object is for a network driver to advertise its media capability,␊ |
188 | through a collection of IONetworkMedium objects stored in a dictionary␊ |
189 | in its property table. IONetworkMedium supports serialization, and will␊ |
190 | encode its properties in the form of a dictionary to the serialization␊ |
191 | stream when instructed. This will allow a user-space application to␊ |
192 | browse the set of media types supported by the controller. ␊ |
193 | */␊ |
194 | ␊ |
195 | class IONetworkMedium : public OSObject␊ |
196 | {␊ |
197 | OSDeclareDefaultStructors( IONetworkMedium )␊ |
198 | ␊ |
199 | protected:␊ |
200 | IOMediumType _type;␊ |
201 | UInt32 _flags;␊ |
202 | UInt64 _speed;␊ |
203 | UInt32 _index;␊ |
204 | const OSSymbol * _name;␊ |
205 | ␊ |
206 | struct ExpansionData { };␊ |
207 | /*! @var reserved␊ |
208 | Reserved for future use. (Internal use only) */␊ |
209 | ExpansionData *_reserved;␊ |
210 | ␊ |
211 | ␊ |
212 | /*! @function free␊ |
213 | @abstract Frees the IONetworkMedium object. ␊ |
214 | */␊ |
215 | ␊ |
216 | virtual void free();␊ |
217 | ␊ |
218 | public:␊ |
219 | ␊ |
220 | /*! @function nameForType␊ |
221 | @abstract Creates a name that describes a medium type.␊ |
222 | @discussion Given a medium type, creates an OSymbol object that␊ |
223 | describes the medium type. There is a 1-to-1 mapping between the␊ |
224 | medium type, and the medium name created by this method. The caller␊ |
225 | is responsible for releasing the OSSymbol object returned.␊ |
226 | @param type A medium type. See IONetworkMedium.h for type encoding.␊ |
227 | @result Returns an OSSymbol object is created based on the type provided. ␊ |
228 | */␊ |
229 | ␊ |
230 | static const OSSymbol * nameForType(IOMediumType type);␊ |
231 | ␊ |
232 | /*! @function addMedium␊ |
233 | @abstract Adds an IONetworkMedium object to a dictionary.␊ |
234 | @discussion A helper function to add an IONetworkMedium object to a␊ |
235 | given dictionary. The name of the medium is used as the key for the␊ |
236 | new dictionary entry.␊ |
237 | @param dict An OSDictionary object where the medium object should be␊ |
238 | added as a new entry.␊ |
239 | @param medium The IONetworkMedium object to add to the dictionary.␊ |
240 | @result Returns true on success, false otherwise. ␊ |
241 | */␊ |
242 | ␊ |
243 | static bool addMedium(OSDictionary * dict,␊ |
244 | const IONetworkMedium * medium);␊ |
245 | ␊ |
246 | /*! @function removeMedium␊ |
247 | @abstract Removes an IONetworkMedium object from a dictionary.␊ |
248 | @discussion A helper function to remove an entry in a dictionary.␊ |
249 | @param dict The OSDictionary object where the medium object should be␊ |
250 | removed from.␊ |
251 | @param medium The name of this medium object is used as the key. ␊ |
252 | */␊ |
253 | ␊ |
254 | static void removeMedium(OSDictionary * dict,␊ |
255 | const IONetworkMedium * medium);␊ |
256 | ␊ |
257 | /*! @function getMediumWithType␊ |
258 | @abstract Finds a medium object from a dictionary with a given type.␊ |
259 | @discussion This method iterates through a dictionary and returns an IONetworkMedium␊ |
260 | entry with the given type. An optional mask supplies the don't care bits.␊ |
261 | @param dict The dictionary to look for a matching entry.␊ |
262 | @param type Search for an entry with this type.␊ |
263 | @param mask The don't care bits in IOMediumType. Defaults to 0, which␊ |
264 | implies that a perfect match is desired.␊ |
265 | @result Returns the first matching IONetworkMedium entry found,␊ |
266 | or 0 if no match was found. ␊ |
267 | */␊ |
268 | ␊ |
269 | static IONetworkMedium * getMediumWithType(const OSDictionary * dict,␊ |
270 | IOMediumType type,␊ |
271 | IOMediumType mask = 0);␊ |
272 | ␊ |
273 | /*! @function getMediumWithIndex␊ |
274 | @abstract Finds a medium object from a dictionary with a given index.␊ |
275 | @discussion This method iterates through a dictionary and returns an IONetworkMedium␊ |
276 | entry with the given index. An optional mask supplies the don't care bits.␊ |
277 | @param dict The dictionary to look for a matching entry.␊ |
278 | @param index Search for an entry with the given index.␊ |
279 | @param mask The don't care bits in index. Defaults to 0, which␊ |
280 | implies that a perfect match is desired.␊ |
281 | @result Returns the first matching IONetworkMedium entry found,␊ |
282 | or 0 if no match was found. ␊ |
283 | */␊ |
284 | ␊ |
285 | static IONetworkMedium * getMediumWithIndex(const OSDictionary * dict,␊ |
286 | UInt32 index,␊ |
287 | UInt32 mask = 0);␊ |
288 | ␊ |
289 | /*! @function init␊ |
290 | @abstract Initializes an IONetworkMedium object.␊ |
291 | @param type The medium type, this value is encoded with bits defined in␊ |
292 | IONetworkMedium.h.␊ |
293 | @param speed The maximum (or the only) link speed supported over this ␊ |
294 | medium in units of bits per second.␊ |
295 | @param flags An optional flag for the medium object.␊ |
296 | See IONetworkMedium.h for defined flags.␊ |
297 | @param index An optional index number assigned by the owner.␊ |
298 | Drivers can use this to store an index to a media table in␊ |
299 | the driver, or it may map to a driver-defined media type.␊ |
300 | @param name An optional name assigned to this medium object. If 0,␊ |
301 | then a name will be created based on the medium type by␊ |
302 | calling IONetworkMedium::nameForType(). Since the name of␊ |
303 | the medium is used as a key when inserted into a dictionary,␊ |
304 | the name chosen must be unique within the scope of the owner.␊ |
305 | @result Returns true on success, false otherwise. ␊ |
306 | */␊ |
307 | ␊ |
308 | virtual bool init(IOMediumType type,␊ |
309 | UInt64 speed,␊ |
310 | UInt32 flags = 0,␊ |
311 | UInt32 index = 0,␊ |
312 | const char * name = 0);␊ |
313 | ␊ |
314 | /*! @function medium␊ |
315 | @abstract Factory method that allocates and initializes an IONetworkMedium object.␊ |
316 | @param type The medium type, this value is encoded with bits defined in␊ |
317 | IONetworkMedium.h.␊ |
318 | @param speed The maximum (or the only) link speed supported over this ␊ |
319 | medium in units of bits per second.␊ |
320 | @param flags An optional flag for the medium object.␊ |
321 | See IONetworkMedium.h for defined flags.␊ |
322 | @param index An optional index number assigned by the owner.␊ |
323 | Drivers can use this to store an index to a media table in␊ |
324 | the driver, or it may map to a driver-defined media type.␊ |
325 | @param name An optional name assigned to this medium object. If 0,␊ |
326 | then a name will be created based on the medium type by␊ |
327 | calling IONetworkMedium::nameForType(). Since the name of␊ |
328 | the medium is used as a key when inserted into a dictionary,␊ |
329 | the name chosen must be unique within the scope of the owner.␊ |
330 | @result Returns an IONetworkMedium instance on success, or 0 otherwise. ␊ |
331 | */␊ |
332 | ␊ |
333 | static IONetworkMedium * medium(IOMediumType type,␊ |
334 | UInt64 speed,␊ |
335 | UInt32 flags = 0,␊ |
336 | UInt32 index = 0,␊ |
337 | const char * name = 0);␊ |
338 | ␊ |
339 | /*! @function getType␊ |
340 | @result Returns the medium type assigned to this medium object. ␊ |
341 | */␊ |
342 | ␊ |
343 | virtual IOMediumType getType() const;␊ |
344 | ␊ |
345 | /*! @function getSpeed␊ |
346 | @result Returns the maximum link speed supported by this medium. ␊ |
347 | */␊ |
348 | ␊ |
349 | virtual UInt64 getSpeed() const;␊ |
350 | ␊ |
351 | /*! @function getFlags␊ |
352 | @result Returns the medium flags. ␊ |
353 | */␊ |
354 | ␊ |
355 | virtual UInt32 getFlags() const;␊ |
356 | ␊ |
357 | /*! @function getIndex␊ |
358 | @result Returns the assigned medium index. ␊ |
359 | */␊ |
360 | ␊ |
361 | virtual UInt32 getIndex() const;␊ |
362 | ␊ |
363 | /*! @function getName␊ |
364 | @result Returns the name assigned to this medium object. ␊ |
365 | */␊ |
366 | ␊ |
367 | virtual const OSSymbol * getName() const;␊ |
368 | ␊ |
369 | /*! @function getKey␊ |
370 | @result Returns the key to use for this medium object. This key should be␊ |
371 | used when this object is added to a dictionary. Same as getName(). ␊ |
372 | */␊ |
373 | ␊ |
374 | virtual const OSSymbol * getKey() const;␊ |
375 | ␊ |
376 | /*! @function isEqualTo␊ |
377 | @abstract Tests for equality between two IONetworkMedium objects.␊ |
378 | @discussion Two IONetworkMedium objects are considered equal if␊ |
379 | they have similar properties assigned to them during initialization.␊ |
380 | @param medium An IONetworkMedium to test against the IONetworkMedium␊ |
381 | object being called.␊ |
382 | @result Returns true if equal, false otherwise. ␊ |
383 | */␊ |
384 | ␊ |
385 | virtual bool isEqualTo(const IONetworkMedium * medium) const;␊ |
386 | ␊ |
387 | /*! @function isEqualTo␊ |
388 | @abstract Tests for equality between a IONetworkMedium object and an␊ |
389 | OSObject.␊ |
390 | @discussion The OSObject is considered equal to the IONetworkMedium␊ |
391 | object if the OSObject is an IONetworkMedium, and they have␊ |
392 | similar properties assigned to them during initialization.␊ |
393 | @param obj An OSObject to test against an IONetworkMedium object.␊ |
394 | @result Returns true if equal, false otherwise. ␊ |
395 | */␊ |
396 | ␊ |
397 | virtual bool isEqualTo(const OSMetaClassBase * obj) const;␊ |
398 | ␊ |
399 | /*! @function serialize␊ |
400 | @abstract Serializes the IONetworkMedium object.␊ |
401 | @discussion A dictionary is created containing the properties␊ |
402 | assigned to this medium object, and this dictionary is then␊ |
403 | serialized using the OSSerialize object provided.␊ |
404 | @param s An OSSerialize object.␊ |
405 | @result Returns true on success, false otherwise. ␊ |
406 | */␊ |
407 | ␊ |
408 | virtual bool serialize(OSSerialize * s) const;␊ |
409 | ␊ |
410 | // Virtual function padding␊ |
411 | OSMetaClassDeclareReservedUnused( IONetworkMedium, 0);␊ |
412 | OSMetaClassDeclareReservedUnused( IONetworkMedium, 1);␊ |
413 | OSMetaClassDeclareReservedUnused( IONetworkMedium, 2);␊ |
414 | OSMetaClassDeclareReservedUnused( IONetworkMedium, 3);␊ |
415 | };␊ |
416 | ␊ |
417 | // Translate getKey() to getName().␊ |
418 | //␊ |
419 | inline const OSSymbol * IONetworkMedium::getKey() const␊ |
420 | {␊ |
421 | return getName();␊ |
422 | }␊ |
423 | ␊ |
424 | #endif /* KERNEL */␊ |
425 | ␊ |
426 | #endif /* !_IONETWORKMEDIUM_H */␊ |
427 |