Annotation of XNU/iokit/IOKit/IOCatalogue.h, revision 1.1.1.1

1.1       root        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) 1998 Apple Computer, Inc.  All rights reserved. 
                     24:  *
                     25:  * HISTORY
                     26:  *
                     27:  */
                     28: 
                     29: 
                     30: #ifndef _IOKIT_IOCATALOGUE_H
                     31: #define _IOKIT_IOCATALOGUE_H
                     32: 
                     33: #include <libkern/c++/OSObject.h>
                     34: #include <libkern/c++/OSCollectionIterator.h>
                     35: #include <libkern/c++/OSArray.h>
                     36: #include <libkern/c++/OSDictionary.h>
                     37: #include <IOKit/IOLocks.h>
                     38: #include <sys/cdefs.h>
                     39: 
                     40: #include <IOKit/IOKitServer.h>
                     41: 
                     42: class IOService;
                     43: 
                     44: /*!
                     45:     @class IOCatalogue
                     46:     @abstract In-kernel database for IOKit driver personalities.
                     47:     @discussion The IOCatalogue is a database which contains all IOKit driver personalities.  IOService uses this resource when matching devices to their associated drivers.
                     48: */
                     49: class IOCatalogue : public OSObject
                     50: {
                     51:     OSDeclareDefaultStructors(IOCatalogue)
                     52:     
                     53: private:
                     54:     OSCollectionIterator   * kernelTables;
                     55:     OSArray                * array;
                     56:     IOLock *                 lock;
                     57:     SInt32                   generation;
                     58:     
                     59: public:
                     60:     /*!
                     61:         @function initialize
                     62:         @abstract Creates and initializes the database object and poputates it with in-kernel driver personalities.
                     63:     */
                     64:     static void initialize( void );
                     65:     
                     66:     /*!
                     67:         @function init
                     68:         @abstract Initializes the database object.
                     69:         @param initArray  The initial array of driver personalities to populate the database.
                     70:     */
                     71:     bool init( OSArray * initArray );
                     72:     
                     73:     /*!
                     74:         @function free
                     75:         @abstract Cleans up the database and deallocates memory allocated at initialization.  This is never called in normal operation of the system.
                     76:     */
                     77:     void free( void );
                     78:     
                     79:     /*!
                     80:         @function findDrivers
                     81:         @abstract This is the primary entry point for IOService.
                     82:         @param service
                     83:         @param generationCount  Returns a reference to the generation count of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
                     84:         @result Returns an ordered set of driver personalities ranked on probe-scores.  The ordered set must be released by the receiver.
                     85:     */
                     86:     OSOrderedSet * findDrivers( IOService * service, SInt32 * generationCount );
                     87:     
                     88:     /*!
                     89:         @function findDrivers
                     90:         @abstract A more general purpose interface which allows one to retreive driver personalities based the intersection of the 'matching' dictionary and the personality's own property list.
                     91:         @param matching  A dictionary containing only keys and values which are to be used for matching. For example, a matching dictionary containing 'IOProviderClass'='IOPCIDevice' will return all personalities with an IOProviderClass key and a value of IOPCIDevice.
                     92:         @param generationCount  Returns a reference to the current generation of the database. The generation count increases only when personalities are added to the database *and* IOService matching has been initiated.
                     93:         @result Returns an ordered set of driver personalities ranked on probe-scores. The ordered set must be released by the receiver.
                     94:     */
                     95:     OSOrderedSet * findDrivers( OSDictionary * matching, SInt32 * generationCount );
                     96:     
                     97:     /*!
                     98:         @function addDrivers
                     99:         @abstract Adds an array of driver personalities to the database.
                    100:         @param array Array of driver personalities to be added to the database.
                    101:         @param doNubMatchng Start matching process after personalities have been added.
                    102:         @result Returns true if driver personality was added to the database successfully. Failure is due to a memory allocation failure.
                    103:     */
                    104:     bool addDrivers( OSArray * array, bool doNubMatching = true );
                    105:     
                    106:     /*!
                    107:         @function removeDrivers
                    108:         @abstract Remove driver personalities from the database based on matching information provided.
                    109:         @param matching  A dictionary whose keys and values are used for matching personalities in the database.  For example, a matching dictionary containing a 'IOProviderClass' key with the value 'IOPCIDevice' will remove all personalities which have the key 'IOProviderClass' equal to 'IOPCIDevice'.
                    110:         @param doNubMatchng Start matching process after personalities have been removed.  Matching criteria is based on IOProviderClass of those personalities which were removed.  This is to allow drivers which haven't been matched to match against NUB's which were blocked by the previous personalities. 
                    111:         @result Returns true if personality was removed successfully. Failure is due to a memory allocation failure.
                    112:     */
                    113:     bool removeDrivers( OSDictionary * matching, bool doNubMatching = true );
                    114:     
                    115:     /*!
                    116:         @function getGenerationCount
                    117:         @abstract Get the current generation count of the database.
                    118:     */
                    119:     SInt32 getGenerationCount( void ) const;
                    120: 
                    121:     /*!
                    122:         @function isModuleLoaded
                    123:         @abstract Reports if a kernel module has been loaded.
                    124:         @param moduleName  Name of the module.
                    125:         @result Returns true if the associated kernel module has been loaded into the kernel.
                    126:     */
                    127:     bool isModuleLoaded( OSString * moduleName ) const;
                    128: 
                    129:     /*!
                    130:         @function isModuleLoaded
                    131:         @abstract Reports if a kernel module has been loaded.
                    132:         @param moduleName  Name of the module.
                    133:         @result Returns true if the associated kernel module has been loaded into the kernel.
                    134:     */
                    135:     bool isModuleLoaded( const char * moduleName ) const;
                    136:     
                    137:     /*!
                    138:         @function isModuleLoaded
                    139:         @abstract Reports if a kernel module has been loaded for a particular personality.
                    140:         @param driver  A driver personality's property list.
                    141:         @result Returns true if the associated kernel module has been loaded into the kernel for a particular driver personality on which it depends.
                    142:     */
                    143:     bool isModuleLoaded( OSDictionary * driver ) const;
                    144:     
                    145:     /*!
                    146:         @function moduleHasLoaded
                    147:         @abstract Callback function called after a IOKit dependent kernel module is loaded.
                    148:         @param name  Name of the kernel module.
                    149:     */
                    150:     void moduleHasLoaded( OSString * name );
                    151:     
                    152:     /*!
                    153:         @function moduleHasLoaded
                    154:         @abstract Callback function called after a IOKit dependent kernel module is loaded.
                    155:         @param name  Name of the kernel module.
                    156:     */
                    157:     void moduleHasLoaded( const char * name );
                    158: 
                    159:     /*!
                    160:         @function terminateDrivers
                    161:         @abstract Terminates all instances of a driver which match the contents of the matching dictionary. Does not unload module.
                    162:         @param matching Dictionary containing the matching criteria.
                    163:      */
                    164:     IOReturn terminateDrivers( OSDictionary * matching );
                    165: 
                    166:     /*!
                    167:         @function terminateDriversForModule
                    168:         @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
                    169:         @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
                    170:         @param unload Flag to cause the actual unloading of the module.
                    171:      */
                    172:     IOReturn terminateDriversForModule( OSString * moduleName, bool unload = true);
                    173: 
                    174:     /*!
                    175:         @function terminateDriversForModule
                    176:         @abstract Terminates all instances of a driver which depends on a particular module and unloads the module.
                    177:         @param moduleName Name of the module which is used to determine which driver instances to terminate and unload.
                    178:         @param unload Flag to cause the actual unloading of the module.
                    179:      */
                    180:     IOReturn terminateDriversForModule( const char * moduleName, bool unload = true);
                    181: 
                    182:     /*!
                    183:         @function startMatching
                    184:         @abstract Starts an IOService matching thread where matching keys and values are provided by the matching dictionary.
                    185:         @param matching A dictionary containing keys and values to match against.
                    186:      */
                    187:     bool startMatching( OSDictionary * matching );
                    188: 
                    189:     /*!
                    190:         @function reset
                    191:         @abstract Return the Catalogue to its initial state.
                    192:     */
                    193:     void reset(void);
                    194: 
                    195:     /*!
                    196:         @function serialize
                    197:         @abstract Serializes the catalog for transport to the user.
                    198:         @param s The serializer object.
                    199:         @result Returns false if unable to serialize database, most likely due to memory shortage.
                    200:      */
                    201:     virtual bool serialize(OSSerialize * s) const;
                    202: 
                    203: private:
                    204: 
                    205:     /*!
                    206:         @function unloadModule
                    207:         @abstract Unloads the reqested module if no driver instances are currently depending on it.
                    208:         @param moduleName An OSString containing the name of the module to unload.
                    209:      */
                    210:     IOReturn unloadModule( OSString * moduleName ) const;
                    211: 
                    212: 
                    213: };
                    214: 
                    215: __BEGIN_DECLS
                    216: /*!
                    217:     @function IOKitRelocStart
                    218:     @abstract Deprecated API.
                    219: */
                    220: kmod_start_func_t IOKitRelocStart;
                    221: /*!
                    222:     @function IOKitRelocStop
                    223:     @abstract Deprecated API.
                    224: */
                    225: kmod_stop_func_t IOKitRelocStop;
                    226: __END_DECLS
                    227: 
                    228: extern const OSSymbol *                gIOClassKey;
                    229: extern const OSSymbol *                gIOProbeScoreKey;
                    230: extern IOCatalogue *            gIOCatalogue;
                    231: 
                    232: #endif /* ! _IOKIT_IOCATALOGUE_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.