Annotation of XNU/iokit/IOKit/storage/IOPartitionScheme.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: /*!
                     24:  * @header IOPartitionScheme
                     25:  * @abstract
                     26:  * This header contains the IOPartitionScheme class definition.
                     27:  */
                     28: 
                     29: #ifndef _IOPARTITIONSCHEME_H
                     30: #define _IOPARTITIONSCHEME_H
                     31: 
                     32: /*!
                     33:  * @defined kIOMediaPartitionID
                     34:  * @abstract
                     35:  * kIOMediaPartitionID is property of IOMedia objects.  It is an OSNumber.
                     36:  * @discussion
                     37:  * The kIOMediaPartitionID property is placed into each IOMedia instance created
                     38:  * via the partition scheme.  It is an ID that differentiates one partition from
                     39:  * the other (within a given scheme).  It is typically an index into the on-disk
                     40:  * partition table.
                     41:  */
                     42: 
                     43: #define kIOMediaPartitionID "Partition ID"
                     44: 
                     45: /*
                     46:  * Kernel
                     47:  */
                     48: 
                     49: #if defined(KERNEL) && defined(__cplusplus)
                     50: 
                     51: #include <IOKit/storage/IOMedia.h>
                     52: #include <IOKit/storage/IOStorage.h>
                     53: 
                     54: /*!
                     55:  * @class IOPartitionScheme
                     56:  * @abstract
                     57:  * The IOPartitionScheme class is the common base class for all partition scheme
                     58:  * objects.
                     59:  * @discussion
                     60:  * The IOPartitionScheme class is the common base class for all partition scheme
                     61:  * objects.  It extends the IOStorage class by implementing the appropriate open
                     62:  * and close semantics for partition objects (standard semantics are to act as a
                     63:  * multiplexor for incoming opens,  producing one outgoing open with the correct
                     64:  * access).  It also implements the default read and write semantics, which pass
                     65:  * all reads and writes through to the provider media unprocessed.    For simple
                     66:  * schemes, the default behavior is sufficient.   More complex partition schemes
                     67:  * such as RAID will want to do extra processing for reads and writes.
                     68:  */
                     69: 
                     70: class IOPartitionScheme : public IOStorage
                     71: {
                     72:     OSDeclareDefaultStructors(IOPartitionScheme);
                     73: 
                     74: protected:
                     75: 
                     76:     IOStorageAccess _openLevel;
                     77:     OSSet *         _openReaders;
                     78:     OSSet *         _openReaderWriters;
                     79: 
                     80:     /*
                     81:      * Free all of this object's outstanding resources.
                     82:      */
                     83: 
                     84:     virtual void free();
                     85: 
                     86:     /*!
                     87:      * @function handleOpen
                     88:      * @discussion
                     89:      * The handleOpen method grants or denies permission to access this object
                     90:      * to an interested client.  The argument is an IOStorageAccess value that
                     91:      * specifies the level of access desired -- reader or reader-writer.
                     92:      *
                     93:      * This method can be invoked to upgrade or downgrade the access level for
                     94:      * an existing client as well.  The previous access level will prevail for
                     95:      * upgrades that fail, of course.   A downgrade should never fail.  If the
                     96:      * new access level should be the same as the old for a given client, this
                     97:      * method will do nothing and return success.  In all cases, one, singular
                     98:      * close-per-client is expected for all opens-per-client received.
                     99:      *
                    100:      * This implementation replaces the IOService definition of handleOpen().
                    101:      * @param client
                    102:      * Client requesting the open.
                    103:      * @param options
                    104:      * Options for the open.  Set to zero.
                    105:      * @param access
                    106:      * Access level for the open.  Set to kAccessReader or kAccessReaderWriter.
                    107:      * @result
                    108:      * Returns true if the open was successful, false otherwise.
                    109:      */
                    110: 
                    111:     virtual bool handleOpen(IOService *  client,
                    112:                             IOOptionBits options,
                    113:                             void *       access);
                    114: 
                    115:     /*!
                    116:      * @function handleIsOpen
                    117:      * @discussion
                    118:      * The handleIsOpen method determines whether the specified client, or any
                    119:      * client if none is specificed, presently has an open on this object.
                    120:      *
                    121:      * This implementation replaces the IOService definition of handleIsOpen().
                    122:      * @param client
                    123:      * Client to check the open state of.  Set to zero to check the open state
                    124:      * of all clients.
                    125:      * @result
                    126:      * Returns true if the client was (or clients were) open, false otherwise.
                    127:      */
                    128: 
                    129:     virtual bool handleIsOpen(const IOService * client) const;
                    130: 
                    131:     /*!
                    132:      * @function handleClose
                    133:      * @discussion
                    134:      * The handleClose method closes the client's access to this object.
                    135:      *
                    136:      * This implementation replaces the IOService definition of handleClose().
                    137:      * @param client
                    138:      * Client requesting the close.
                    139:      * @param options
                    140:      * Options for the close.  Set to zero.
                    141:      */
                    142: 
                    143:     virtual void handleClose(IOService * client, IOOptionBits options);
                    144: 
                    145: public:
                    146: 
                    147: ///m:2333367:workaround:commented:start
                    148: //  IOStorage::open;
                    149: //  IOStorage::close;
                    150: //  IOStorage::read;
                    151: //  IOStorage::write;
                    152: ///m:2333367:workaround:commented:stop
                    153: 
                    154:     /*
                    155:      * Initialize this object's minimal state.
                    156:      */
                    157: 
                    158:     virtual bool init(OSDictionary * properties = 0);
                    159: 
                    160:     /*!
                    161:      * @function read
                    162:      * @discussion
                    163:      * Read data from the storage object at the specified byte offset into the
                    164:      * specified buffer, asynchronously.   When the read completes, the caller
                    165:      * will be notified via the specified completion action.
                    166:      *
                    167:      * The buffer will be retained for the duration of the read.
                    168:      *
                    169:      * For simple partition schemes, the default behavior is to simply pass the
                    170:      * read through to the provider media.  More complex partition schemes such
                    171:      * as RAID will need to do extra processing here.
                    172:      * @param client
                    173:      * Client requesting the read.
                    174:      * @param byteStart
                    175:      * Starting byte offset for the data transfer.
                    176:      * @param buffer
                    177:      * Buffer for the data transfer.  The size of the buffer implies the size of
                    178:      * the data transfer.
                    179:      * @param completion
                    180:      * Completion routine to call once the data transfer is complete.
                    181:      */
                    182: 
                    183:     virtual void read(IOService *          client,
                    184:                       UInt64               byteStart,
                    185:                       IOMemoryDescriptor * buffer,
                    186:                       IOStorageCompletion  completion);
                    187: 
                    188:     /*!
                    189:      * @function write
                    190:      * @discussion
                    191:      * Write data into the storage object at the specified byte offset from the
                    192:      * specified buffer, asynchronously.   When the write completes, the caller
                    193:      * will be notified via the specified completion action.
                    194:      *
                    195:      * The buffer will be retained for the duration of the write.
                    196:      *
                    197:      * For simple partition schemes, the default behavior is to simply pass the
                    198:      * write through to the provider media. More complex partition schemes such
                    199:      * as RAID will need to do extra processing here.
                    200:      * @param client
                    201:      * Client requesting the write.
                    202:      * @param byteStart
                    203:      * Starting byte offset for the data transfer.
                    204:      * @param buffer
                    205:      * Buffer for the data transfer.  The size of the buffer implies the size of
                    206:      * the data transfer.
                    207:      * @param completion
                    208:      * Completion routine to call once the data transfer is complete.
                    209:      */
                    210: 
                    211:     virtual void write(IOService *          client,
                    212:                        UInt64               byteStart,
                    213:                        IOMemoryDescriptor * buffer,
                    214:                        IOStorageCompletion  completion);
                    215: 
                    216:     /*
                    217:      * Obtain this object's provider.  We override the superclass's method
                    218:      * to return a more specific subclass of OSObject -- an IOMedia.  This
                    219:      * method serves simply as a convenience to subclass developers.
                    220:      */
                    221: 
                    222:     virtual IOMedia * getProvider() const
                    223:     {
                    224:         return (IOMedia *) IOStorage::getProvider();
                    225:     }
                    226: };
                    227: 
                    228: #endif /* defined(KERNEL) && defined(__cplusplus) */
                    229: 
                    230: #endif /* !_IOPARTITIONSCHEME_H */

unix.superglobalmegacorp.com

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