Root/
Source at commit 1084 created 13 years 1 month ago. By meklort, BiosDisk Read() function working. Write() complete but untested | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2009 Apple Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * This file contains Original Code and/or Modifications of Original Code␊ |
7 | * as defined in and that are subject to the Apple Public Source License␊ |
8 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
9 | * compliance with the License. Please obtain a copy of the License at␊ |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
11 | * file.␊ |
12 | * ␊ |
13 | * The Original Code and all software distributed under the License are␊ |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
18 | * Please see the License for the specific language governing rights and␊ |
19 | * limitations under the License.␊ |
20 | * ␊ |
21 | * @APPLE_LICENSE_HEADER_END@␊ |
22 | */␊ |
23 | ␊ |
24 | /*!␊ |
25 | * @header IOPartitionScheme␊ |
26 | * @abstract␊ |
27 | * This header contains the IOPartitionScheme class definition.␊ |
28 | */␊ |
29 | ␊ |
30 | #ifndef _IOPARTITIONSCHEME_H␊ |
31 | #define _IOPARTITIONSCHEME_H␊ |
32 | ␊ |
33 | /*!␊ |
34 | * @defined kIOPartitionSchemeClass␊ |
35 | * @abstract␊ |
36 | * The name of the IOPartitionScheme class.␊ |
37 | * @discussion␊ |
38 | * kIOPartitionSchemeClass is the name of the IOPartitionScheme class.␊ |
39 | */␊ |
40 | ␊ |
41 | #define kIOPartitionSchemeClass "IOPartitionScheme"␊ |
42 | ␊ |
43 | /*!␊ |
44 | * @defined kIOMediaLiveKey␊ |
45 | * @abstract␊ |
46 | * A property of IOMedia objects.␊ |
47 | * @discussion␊ |
48 | * The kIOMediaLiveKey property has an OSBoolean␊ |
49 | * value and is placed into an IOMedia instance␊ |
50 | * created via the partition scheme. It describes whether the␊ |
51 | * partition is live, that is, it is up-to-date with respect␊ |
52 | * to the on-disk partition table.␊ |
53 | */␊ |
54 | ␊ |
55 | #define kIOMediaLiveKey "Live"␊ |
56 | ␊ |
57 | /*!␊ |
58 | * @defined kIOMediaPartitionIDKey␊ |
59 | * @abstract␊ |
60 | * A property of IOMedia objects.␊ |
61 | * @discussion␊ |
62 | * The kIOMediaPartitionIDKey property has an OSNumber␊ |
63 | * value and is placed into an IOMedia instance␊ |
64 | * created via the partition scheme. It is an ID that differentiates one ␊ |
65 | * partition from the other (within a given scheme). It is typically an index␊ |
66 | * into the on-disk partition table.␊ |
67 | */␊ |
68 | ␊ |
69 | #define kIOMediaPartitionIDKey "Partition ID"␊ |
70 | ␊ |
71 | #ifdef KERNEL␊ |
72 | #ifdef __cplusplus␊ |
73 | ␊ |
74 | /*␊ |
75 | * Kernel␊ |
76 | */␊ |
77 | ␊ |
78 | #include <IOKit/storage/IOMedia.h>␊ |
79 | #include <IOKit/storage/IOStorage.h>␊ |
80 | ␊ |
81 | /*!␊ |
82 | * @class IOPartitionScheme␊ |
83 | * @abstract␊ |
84 | * The common base class for all partition scheme␊ |
85 | * objects.␊ |
86 | * @discussion␊ |
87 | * The IOPartitionScheme class is the common base class for all partition scheme␊ |
88 | * objects. It extends the IOStorage class by implementing the appropriate open␊ |
89 | * and close semantics for partition objects (standard semantics are to act as a␊ |
90 | * multiplexor for incoming opens, producing one outgoing open with the correct␊ |
91 | * access). It also implements the default read and write semantics, which pass␊ |
92 | * all reads and writes through to the provider media unprocessed. For simple␊ |
93 | * schemes, the default behavior is sufficient. More complex partition schemes␊ |
94 | * such as RAID will want to do extra processing for reads and writes.␊ |
95 | */␊ |
96 | ␊ |
97 | class IOPartitionScheme : public IOStorage␊ |
98 | {␊ |
99 | OSDeclareDefaultStructors(IOPartitionScheme);␊ |
100 | ␊ |
101 | protected:␊ |
102 | ␊ |
103 | struct ExpansionData { /* */ };␊ |
104 | ExpansionData * _expansionData;␊ |
105 | ␊ |
106 | IOStorageAccess _openLevel;␊ |
107 | OSSet * _openReaders;␊ |
108 | OSSet * _openReaderWriters;␊ |
109 | ␊ |
110 | /*␊ |
111 | * Free all of this object's outstanding resources.␊ |
112 | */␊ |
113 | ␊ |
114 | virtual void free();␊ |
115 | ␊ |
116 | /*!␊ |
117 | * @function handleOpen␊ |
118 | * @discussion␊ |
119 | * The handleOpen method grants or denies permission to access this object␊ |
120 | * to an interested client. The argument is an IOStorageAccess value that␊ |
121 | * specifies the level of access desired -- reader or reader-writer.␊ |
122 | *␊ |
123 | * This method can be invoked to upgrade or downgrade the access level for␊ |
124 | * an existing client as well. The previous access level will prevail for␊ |
125 | * upgrades that fail, of course. A downgrade should never fail. If the␊ |
126 | * new access level should be the same as the old for a given client, this␊ |
127 | * method will do nothing and return success. In all cases, one, singular␊ |
128 | * close-per-client is expected for all opens-per-client received.␊ |
129 | *␊ |
130 | * This implementation replaces the IOService definition of handleOpen().␊ |
131 | * @param client␊ |
132 | * Client requesting the open.␊ |
133 | * @param options␊ |
134 | * Options for the open. Set to zero.␊ |
135 | * @param access␊ |
136 | * Access level for the open. Set to kIOStorageAccessReader or␊ |
137 | * kIOStorageAccessReaderWriter.␊ |
138 | * @result␊ |
139 | * Returns true if the open was successful, false otherwise.␊ |
140 | */␊ |
141 | ␊ |
142 | virtual bool handleOpen(IOService * client,␊ |
143 | IOOptionBits options,␊ |
144 | void * access);␊ |
145 | ␊ |
146 | /*!␊ |
147 | * @function handleIsOpen␊ |
148 | * @discussion␊ |
149 | * The handleIsOpen method determines whether the specified client, or any␊ |
150 | * client if none is specified, presently has an open on this object.␊ |
151 | *␊ |
152 | * This implementation replaces the IOService definition of handleIsOpen().␊ |
153 | * @param client␊ |
154 | * Client to check the open state of. Set to zero to check the open state␊ |
155 | * of all clients.␊ |
156 | * @result␊ |
157 | * Returns true if the client was (or clients were) open, false otherwise.␊ |
158 | */␊ |
159 | ␊ |
160 | virtual bool handleIsOpen(const IOService * client) const;␊ |
161 | ␊ |
162 | /*!␊ |
163 | * @function handleClose␊ |
164 | * @discussion␊ |
165 | * The handleClose method closes the client's access to this object.␊ |
166 | *␊ |
167 | * This implementation replaces the IOService definition of handleClose().␊ |
168 | * @param client␊ |
169 | * Client requesting the close.␊ |
170 | * @param options␊ |
171 | * Options for the close. Set to zero.␊ |
172 | */␊ |
173 | ␊ |
174 | virtual void handleClose(IOService * client, IOOptionBits options);␊ |
175 | ␊ |
176 | /*␊ |
177 | * Attach the given media object to the device tree plane.␊ |
178 | */␊ |
179 | ␊ |
180 | #ifdef __LP64__␊ |
181 | virtual bool attachMediaObjectToDeviceTree(IOMedia * media);␊ |
182 | #else /* !__LP64__ */␊ |
183 | virtual bool attachMediaObjectToDeviceTree(IOMedia * media,␊ |
184 | IOOptionBits options = 0); /* 10.5.0 */␊ |
185 | #endif /* !__LP64__ */␊ |
186 | ␊ |
187 | /*␊ |
188 | * Detach the given media object from the device tree plane.␊ |
189 | */␊ |
190 | ␊ |
191 | #ifdef __LP64__␊ |
192 | virtual void detachMediaObjectFromDeviceTree(IOMedia * media);␊ |
193 | #else /* !__LP64__ */␊ |
194 | virtual void detachMediaObjectFromDeviceTree(IOMedia * media,␊ |
195 | IOOptionBits options = 0); /* 10.5.0 */␊ |
196 | #endif /* !__LP64__ */␊ |
197 | ␊ |
198 | /*␊ |
199 | * Updates a set of existing partitions, represented by partitionsOld,␊ |
200 | * with possible updates from a rescan of the disk, represented by␊ |
201 | * partitionsNew. It returns a new set of partitions with the results,␊ |
202 | * removing partitions from partitionsOld where applicable, adding␊ |
203 | * partitions from partitionsNew where applicable, and folding in property␊ |
204 | * changes to partitions from partitionsNew into partitionsOld where␊ |
205 | * applicable.␊ |
206 | */␊ |
207 | ␊ |
208 | virtual OSSet * juxtaposeMediaObjects(OSSet * partitionsOld,␊ |
209 | OSSet * partitionsNew); /* 10.5.0 */␊ |
210 | ␊ |
211 | public:␊ |
212 | ␊ |
213 | using IOStorage::read;␊ |
214 | using IOStorage::write;␊ |
215 | ␊ |
216 | /*␊ |
217 | * Initialize this object's minimal state.␊ |
218 | */␊ |
219 | ␊ |
220 | virtual bool init(OSDictionary * properties = 0);␊ |
221 | ␊ |
222 | /*!␊ |
223 | * @function read␊ |
224 | * @discussion␊ |
225 | * Read data from the storage object at the specified byte offset into the␊ |
226 | * specified buffer, asynchronously. When the read completes, the caller␊ |
227 | * will be notified via the specified completion action.␊ |
228 | *␊ |
229 | * The buffer will be retained for the duration of the read.␊ |
230 | *␊ |
231 | * For simple partition schemes, the default behavior is to simply pass the␊ |
232 | * read through to the provider media. More complex partition schemes such␊ |
233 | * as RAID will need to do extra processing here.␊ |
234 | * @param client␊ |
235 | * Client requesting the read.␊ |
236 | * @param byteStart␊ |
237 | * Starting byte offset for the data transfer.␊ |
238 | * @param buffer␊ |
239 | * Buffer for the data transfer. The size of the buffer implies the size of␊ |
240 | * the data transfer.␊ |
241 | * @param attributes␊ |
242 | * Attributes of the data transfer. See IOStorageAttributes. It is the␊ |
243 | * responsibility of the callee to maintain the information for the duration␊ |
244 | * of the data transfer, as necessary.␊ |
245 | * @param completion␊ |
246 | * Completion routine to call once the data transfer is complete. It is the␊ |
247 | * responsibility of the callee to maintain the information for the duration␊ |
248 | * of the data transfer, as necessary.␊ |
249 | */␊ |
250 | ␊ |
251 | virtual void read(IOService * client,␊ |
252 | UInt64 byteStart,␊ |
253 | IOMemoryDescriptor * buffer,␊ |
254 | IOStorageAttributes * attributes,␊ |
255 | IOStorageCompletion * completion);␊ |
256 | ␊ |
257 | /*!␊ |
258 | * @function write␊ |
259 | * @discussion␊ |
260 | * Write data into the storage object at the specified byte offset from the␊ |
261 | * specified buffer, asynchronously. When the write completes, the caller␊ |
262 | * will be notified via the specified completion action.␊ |
263 | *␊ |
264 | * The buffer will be retained for the duration of the write.␊ |
265 | *␊ |
266 | * For simple partition schemes, the default behavior is to simply pass the␊ |
267 | * write through to the provider media. More complex partition schemes such␊ |
268 | * as RAID will need to do extra processing here.␊ |
269 | * @param client␊ |
270 | * Client requesting the write.␊ |
271 | * @param byteStart␊ |
272 | * Starting byte offset for the data transfer.␊ |
273 | * @param buffer␊ |
274 | * Buffer for the data transfer. The size of the buffer implies the size of␊ |
275 | * the data transfer.␊ |
276 | * @param attributes␊ |
277 | * Attributes of the data transfer. See IOStorageAttributes. It is the␊ |
278 | * responsibility of the callee to maintain the information for the duration␊ |
279 | * of the data transfer, as necessary.␊ |
280 | * @param completion␊ |
281 | * Completion routine to call once the data transfer is complete. It is the␊ |
282 | * responsibility of the callee to maintain the information for the duration␊ |
283 | * of the data transfer, as necessary.␊ |
284 | */␊ |
285 | ␊ |
286 | virtual void write(IOService * client,␊ |
287 | UInt64 byteStart,␊ |
288 | IOMemoryDescriptor * buffer,␊ |
289 | IOStorageAttributes * attributes,␊ |
290 | IOStorageCompletion * completion);␊ |
291 | ␊ |
292 | /*!␊ |
293 | * @function synchronizeCache␊ |
294 | * @discussion␊ |
295 | * Flush the cached data in the storage object, if any, synchronously.␊ |
296 | * @param client␊ |
297 | * Client requesting the cache synchronization.␊ |
298 | * @result␊ |
299 | * Returns the status of the cache synchronization.␊ |
300 | */␊ |
301 | ␊ |
302 | virtual IOReturn synchronizeCache(IOService * client);␊ |
303 | ␊ |
304 | /*!␊ |
305 | * @function discard␊ |
306 | * @discussion␊ |
307 | * Delete unused data from the storage object at the specified byte offset,␊ |
308 | * synchronously.␊ |
309 | * @param client␊ |
310 | * Client requesting the operation.␊ |
311 | * @param byteStart␊ |
312 | * Starting byte offset for the operation.␊ |
313 | * @param byteCount␊ |
314 | * Size of the operation.␊ |
315 | * @result␊ |
316 | * Returns the status of the operation.␊ |
317 | */␊ |
318 | ␊ |
319 | virtual IOReturn discard(IOService * client,␊ |
320 | UInt64 byteStart,␊ |
321 | UInt64 byteCount);␊ |
322 | ␊ |
323 | /*␊ |
324 | * Obtain this object's provider. We override the superclass's method␊ |
325 | * to return a more specific subclass of OSObject -- an IOMedia. This␊ |
326 | * method serves simply as a convenience to subclass developers.␊ |
327 | */␊ |
328 | ␊ |
329 | virtual IOMedia * getProvider() const;␊ |
330 | ␊ |
331 | #ifdef __LP64__␊ |
332 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 0);␊ |
333 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 1);␊ |
334 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 2);␊ |
335 | #else /* !__LP64__ */␊ |
336 | OSMetaClassDeclareReservedUsed(IOPartitionScheme, 0);␊ |
337 | OSMetaClassDeclareReservedUsed(IOPartitionScheme, 1);␊ |
338 | OSMetaClassDeclareReservedUsed(IOPartitionScheme, 2);␊ |
339 | #endif /* !__LP64__ */␊ |
340 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 3);␊ |
341 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 4);␊ |
342 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 5);␊ |
343 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 6);␊ |
344 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 7);␊ |
345 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 8);␊ |
346 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 9);␊ |
347 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 10);␊ |
348 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 11);␊ |
349 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 12);␊ |
350 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 13);␊ |
351 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 14);␊ |
352 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 15);␊ |
353 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 16);␊ |
354 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 17);␊ |
355 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 18);␊ |
356 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 19);␊ |
357 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 20);␊ |
358 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 21);␊ |
359 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 22);␊ |
360 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 23);␊ |
361 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 24);␊ |
362 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 25);␊ |
363 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 26);␊ |
364 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 27);␊ |
365 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 28);␊ |
366 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 29);␊ |
367 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 30);␊ |
368 | OSMetaClassDeclareReservedUnused(IOPartitionScheme, 31);␊ |
369 | };␊ |
370 | ␊ |
371 | #endif /* __cplusplus */␊ |
372 | #endif /* KERNEL */␊ |
373 | #endif /* !_IOPARTITIONSCHEME_H */␊ |
374 |