2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
24 * @header IOPartitionScheme
26 * This header contains the IOPartitionScheme class definition.
29 #ifndef _IOPARTITIONSCHEME_H
30 #define _IOPARTITIONSCHEME_H
33 * @defined kIOPartitionSchemeClass
35 * kIOPartitionSchemeClass is the name of the IOPartitionScheme class.
37 * kIOPartitionSchemeClass is the name of the IOPartitionScheme class.
40 #define kIOPartitionSchemeClass "IOPartitionScheme"
43 * @defined kIOMediaPartitionIDKey
45 * kIOMediaPartitionIDKey is property of IOMedia objects. It has an OSNumber
48 * The kIOMediaPartitionIDKey property is placed into each IOMedia instance
49 * created via the partition scheme. It is an ID that differentiates one
50 * partition from the other (within a given scheme). It is typically an index
51 * into the on-disk partition table.
54 #define kIOMediaPartitionIDKey "Partition ID"
55 #define kIOMediaPartitionID "Partition ID" ///d:deprecated
61 #if defined(KERNEL) && defined(__cplusplus)
63 #include <IOKit/storage/IOMedia.h>
64 #include <IOKit/storage/IOStorage.h>
67 * @class IOPartitionScheme
69 * The IOPartitionScheme class is the common base class for all partition scheme
72 * The IOPartitionScheme class is the common base class for all partition scheme
73 * objects. It extends the IOStorage class by implementing the appropriate open
74 * and close semantics for partition objects (standard semantics are to act as a
75 * multiplexor for incoming opens, producing one outgoing open with the correct
76 * access). It also implements the default read and write semantics, which pass
77 * all reads and writes through to the provider media unprocessed. For simple
78 * schemes, the default behavior is sufficient. More complex partition schemes
79 * such as RAID will want to do extra processing for reads and writes.
82 class IOPartitionScheme
: public IOStorage
84 OSDeclareDefaultStructors(IOPartitionScheme
);
88 struct ExpansionData
{ /* */ };
89 ExpansionData
* _expansionData
;
91 IOStorageAccess _openLevel
;
93 OSSet
* _openReaderWriters
;
96 * Free all of this object's outstanding resources.
102 * @function handleOpen
104 * The handleOpen method grants or denies permission to access this object
105 * to an interested client. The argument is an IOStorageAccess value that
106 * specifies the level of access desired -- reader or reader-writer.
108 * This method can be invoked to upgrade or downgrade the access level for
109 * an existing client as well. The previous access level will prevail for
110 * upgrades that fail, of course. A downgrade should never fail. If the
111 * new access level should be the same as the old for a given client, this
112 * method will do nothing and return success. In all cases, one, singular
113 * close-per-client is expected for all opens-per-client received.
115 * This implementation replaces the IOService definition of handleOpen().
117 * Client requesting the open.
119 * Options for the open. Set to zero.
121 * Access level for the open. Set to kIOStorageAccessReader or
122 * kIOStorageAccessReaderWriter.
124 * Returns true if the open was successful, false otherwise.
127 virtual bool handleOpen(IOService
* client
,
128 IOOptionBits options
,
132 * @function handleIsOpen
134 * The handleIsOpen method determines whether the specified client, or any
135 * client if none is specificed, presently has an open on this object.
137 * This implementation replaces the IOService definition of handleIsOpen().
139 * Client to check the open state of. Set to zero to check the open state
142 * Returns true if the client was (or clients were) open, false otherwise.
145 virtual bool handleIsOpen(const IOService
* client
) const;
148 * @function handleClose
150 * The handleClose method closes the client's access to this object.
152 * This implementation replaces the IOService definition of handleClose().
154 * Client requesting the close.
156 * Options for the close. Set to zero.
159 virtual void handleClose(IOService
* client
, IOOptionBits options
);
163 ///m:2333367:workaround:commented:start
166 ///m:2333367:workaround:commented:stop
169 * Initialize this object's minimal state.
172 virtual bool init(OSDictionary
* properties
= 0);
177 * Read data from the storage object at the specified byte offset into the
178 * specified buffer, asynchronously. When the read completes, the caller
179 * will be notified via the specified completion action.
181 * The buffer will be retained for the duration of the read.
183 * For simple partition schemes, the default behavior is to simply pass the
184 * read through to the provider media. More complex partition schemes such
185 * as RAID will need to do extra processing here.
187 * Client requesting the read.
189 * Starting byte offset for the data transfer.
191 * Buffer for the data transfer. The size of the buffer implies the size of
194 * Completion routine to call once the data transfer is complete.
197 virtual void read(IOService
* client
,
199 IOMemoryDescriptor
* buffer
,
200 IOStorageCompletion completion
);
205 * Write data into the storage object at the specified byte offset from the
206 * specified buffer, asynchronously. When the write completes, the caller
207 * will be notified via the specified completion action.
209 * The buffer will be retained for the duration of the write.
211 * For simple partition schemes, the default behavior is to simply pass the
212 * write through to the provider media. More complex partition schemes such
213 * as RAID will need to do extra processing here.
215 * Client requesting the write.
217 * Starting byte offset for the data transfer.
219 * Buffer for the data transfer. The size of the buffer implies the size of
222 * Completion routine to call once the data transfer is complete.
225 virtual void write(IOService
* client
,
227 IOMemoryDescriptor
* buffer
,
228 IOStorageCompletion completion
);
230 virtual IOReturn
synchronizeCache(IOService
* client
);
233 * Obtain this object's provider. We override the superclass's method
234 * to return a more specific subclass of OSObject -- an IOMedia. This
235 * method serves simply as a convenience to subclass developers.
238 virtual IOMedia
* getProvider() const;
240 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 0);
241 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 1);
242 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 2);
243 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 3);
244 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 4);
245 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 5);
246 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 6);
247 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 7);
248 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 8);
249 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 9);
250 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 10);
251 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 11);
252 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 12);
253 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 13);
254 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 14);
255 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 15);
256 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 16);
257 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 17);
258 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 18);
259 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 19);
260 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 20);
261 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 21);
262 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 22);
263 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 23);
264 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 24);
265 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 25);
266 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 26);
267 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 27);
268 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 28);
269 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 29);
270 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 30);
271 OSMetaClassDeclareReservedUnused(IOPartitionScheme
, 31);
274 #endif /* defined(KERNEL) && defined(__cplusplus) */
276 #endif /* !_IOPARTITIONSCHEME_H */