Chameleon

Chameleon Commit Details

Date:2011-06-24 12:09:58 (8 years 23 days ago)
Author:Azimutz
Commit:1049
Parents: 1048
Message:Matching trunk on these files.
Changes:
M/branches/azimutz/Chazi/i386/config/Makefile
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOBlockStorageDevice.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOFDiskPartitionScheme.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOMedia.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOApplePartitionScheme.h
M/branches/azimutz/Chazi/i386/include/IOKit/IOLib.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOCDBlockStorageDriver.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOStorage.h
M/branches/azimutz/Chazi/i386/include/architecture/byte_order.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOCDBlockStorageDevice.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOGUIDPartitionScheme.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOMediaBSDClient.h
M/branches/azimutz/Chazi/i386/include/IOKit/storage/IOBlockStorageDriver.h

File differences

branches/azimutz/Chazi/i386/include/IOKit/IOLib.h
6767
6868
6969
70
71
72
7370
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
14471
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
36572
36673
36774
......
37178
37279
37380
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
39681
39782
39883
typedef thread_t IOThread;
typedef void (*IOThreadFunc)(void *argument);
/*
* Memory allocation functions.
*/
/*! @function IOMalloc
@abstract Allocates general purpose, wired memory in the kernel map.
@discussion This is a general purpose utility to allocate memory in the kernel. There are no alignment guarantees given on the returned memory, and alignment may vary depending on the kernel configuration. This function may block and so should not be called from interrupt level or while a simple lock is held.
@param size Size of the memory requested.
@result Pointer to the allocated memory, or zero on failure. */
void * IOMalloc(vm_size_t size);
/*! @function IOFree
@abstract Frees memory allocated with IOMalloc.
@discussion This function frees memory allocated with IOMalloc, it may block and so should not be called from interrupt level or while a simple lock is held.
@param address Pointer to the allocated memory.
@param size Size of the memory allocated. */
void IOFree(void * address, vm_size_t size);
/*! @function IOMallocAligned
@abstract Allocates wired memory in the kernel map, with an alignment restriction.
@discussion This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count. This function may block and so should not be called from interrupt level or while a simple lock is held.
@param size Size of the memory requested.
@param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bit 0-7 zero.
@result Pointer to the allocated memory, or zero on failure. */
void * IOMallocAligned(vm_size_t size, vm_offset_t alignment);
/*! @function IOFreeAligned
@abstract Frees memory allocated with IOMallocAligned.
@discussion This function frees memory allocated with IOMallocAligned, it may block and so should not be called from interrupt level or while a simple lock is held.
@param address Pointer to the allocated memory.
@param size Size of the memory allocated. */
void IOFreeAligned(void * address, vm_size_t size);
/*! @function IOMallocContiguous
@abstract Deprecated - use IOBufferMemoryDescriptor. Allocates wired memory in the kernel map, with an alignment restriction and physically contiguous.
@discussion This is a utility to allocate memory in the kernel, with an alignment restriction which is specified as a byte count, and will allocate only physically contiguous memory. The request may fail if memory is fragmented, and may cause large amounts of paging activity. This function may block and so should not be called from interrupt level or while a simple lock is held.
@param size Size of the memory requested.
@param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
@param physicalAddress IOMallocContiguous returns the physical address of the allocated memory here, if physicalAddress is a non-zero pointer. The physicalAddress argument is deprecated and should be passed as NULL. To obtain the physical address for a memory buffer, use the IODMACommand class in conjunction with the IOMemoryDescriptor or IOBufferMemoryDescriptor classes.
@result Virtual address of the allocated memory, or zero on failure. */
void * IOMallocContiguous(vm_size_t size, vm_size_t alignment,
IOPhysicalAddress * physicalAddress) __attribute__((deprecated));
/*! @function IOFreeContiguous
@abstract Deprecated - use IOBufferMemoryDescriptor. Frees memory allocated with IOMallocContiguous.
@discussion This function frees memory allocated with IOMallocContiguous, it may block and so should not be called from interrupt level or while a simple lock is held.
@param address Virtual address of the allocated memory.
@param size Size of the memory allocated. */
void IOFreeContiguous(void * address, vm_size_t size) __attribute__((deprecated));
/*! @function IOMallocPageable
@abstract Allocates pageable memory in the kernel map.
@discussion This is a utility to allocate pageable memory in the kernel. This function may block and so should not be called from interrupt level or while a simple lock is held.
@param size Size of the memory requested.
@param alignment Byte count of the alignment for the memory. For example, pass 256 to get memory allocated at an address with bits 0-7 zero.
@result Pointer to the allocated memory, or zero on failure. */
void * IOMallocPageable(vm_size_t size, vm_size_t alignment);
/*! @function IOFreePageable
@abstract Frees memory allocated with IOMallocPageable.
@discussion This function frees memory allocated with IOMallocPageable, it may block and so should not be called from interrupt level or while a simple lock is held.
@param address Virtual address of the allocated memory.
@param size Size of the memory allocated. */
void IOFreePageable(void * address, vm_size_t size);
/*
* Typed memory allocation macros. Both may block.
*/
#define IONew(type,number) (type*)IOMalloc(sizeof(type) * (number) )
#define IODelete(ptr,type,number) IOFree( (ptr) , sizeof(type) * (number) )
/////////////////////////////////////////////////////////////////////////////
//
//
//These functions are now implemented in IOMapper.cpp
//
//
/////////////////////////////////////////////////////////////////////////////
/*! @function IOMappedRead8
@abstract Read one byte from the desired "Physical" IOSpace address.
@discussion Read one byte from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@result Data contained at that location */
UInt8 IOMappedRead8(IOPhysicalAddress address);
/*! @function IOMappedRead16
@abstract Read two bytes from the desired "Physical" IOSpace address.
@discussion Read two bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@result Data contained at that location */
UInt16 IOMappedRead16(IOPhysicalAddress address);
/*! @function IOMappedRead32
@abstract Read four bytes from the desired "Physical" IOSpace address.
@discussion Read four bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@result Data contained at that location */
UInt32 IOMappedRead32(IOPhysicalAddress address);
/*! @function IOMappedRead64
@abstract Read eight bytes from the desired "Physical" IOSpace address.
@discussion Read eight bytes from the desired "Physical" IOSpace address. This function allows the developer to read an address returned from any memory descriptor's getPhysicalSegment routine. It can then be used by segmenting a physical page slightly to tag the physical page with its kernel space virtual address.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@result Data contained at that location */
UInt64 IOMappedRead64(IOPhysicalAddress address);
/*! @function IOMappedWrite8
@abstract Write one byte to the desired "Physical" IOSpace address.
@discussion Write one byte to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@param value Data to be writen to the desired location */
void IOMappedWrite8(IOPhysicalAddress address, UInt8 value);
/*! @function IOMappedWrite16
@abstract Write two bytes to the desired "Physical" IOSpace address.
@discussion Write two bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@param value Data to be writen to the desired location */
void IOMappedWrite16(IOPhysicalAddress address, UInt16 value);
/*! @function IOMappedWrite32
@abstract Write four bytes to the desired "Physical" IOSpace address.
@discussion Write four bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@param value Data to be writen to the desired location */
void IOMappedWrite32(IOPhysicalAddress address, UInt32 value);
/*! @function IOMappedWrite64
@abstract Write eight bytes to the desired "Physical" IOSpace address.
@discussion Write eight bytes to the desired "Physical" IOSpace address. This function allows the developer to write to an address returned from any memory descriptor's getPhysicalSegment routine.
@param address The desired address, as returned by IOMemoryDescriptor::getPhysicalSegment.
@param value Data to be writen to the desired location */
void IOMappedWrite64(IOPhysicalAddress address, UInt64 value);
/*! @function IOSetProcessorCacheMode
@abstract Sets the processor cache mode for mapped memory.
@discussion This function sets the cache mode of an already mapped & wired memory range. Note this may not be supported on I/O mappings or shared memory - it is far preferable to set the cache mode as mappings are created with the IOMemoryDescriptor::map method.
@param task Task the memory is mapped into.
@param address Virtual address of the memory.
@param length Length of the range to set.
@param cacheMode A constant from IOTypes.h, <br>
kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.<br>
kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.<br>
@result An IOReturn code.*/
IOReturn IOSetProcessorCacheMode( task_t task, IOVirtualAddress address,
IOByteCount length, IOOptionBits cacheMode );
/*! @function IOFlushProcessorCache
@abstract Flushes the processor cache for mapped memory.
@discussion This function flushes the processor cache of an already mapped memory range. Note in most cases it is preferable to use IOMemoryDescriptor::prepare and complete to manage cache coherency since they are aware of the architecture's requirements. Flushing the processor cache is not required for coherency in most situations.
@param task Task the memory is mapped into.
@param address Virtual address of the memory.
@param length Length of the range to set.
@result An IOReturn code. */
IOReturn IOFlushProcessorCache( task_t task, IOVirtualAddress address,
IOByteCount length );
/*! @function IOThreadSelf
@abstract Returns the osfmk identifier for the currently running thread.
@discussion This function returns the current thread (a pointer to the currently active osfmk thread_shuttle). */
#define IOThreadSelf() (current_thread())
/*! @function IOCreateThread
@abstract Deprecated function - use kernel_thread_start(). Create a kernel thread.
@discussion This function creates a kernel thread, and passes the caller supplied argument to the new thread. Warning: the value returned by this function is not 100% reliable. There is a race condition where it is possible that the new thread has already terminated before this call returns. Under that circumstance the IOThread returned will be invalid. In general there is little that can be done with this value except compare it against 0. The thread itself can call IOThreadSelf() 100% reliably and that is the prefered mechanism to manipulate the IOThreads state.
@param function A C-function pointer where the thread will begin execution.
@param argument Caller specified data to be passed to the new thread.
@result An IOThread identifier for the new thread, equivalent to an osfmk thread_t. */
IOThread IOCreateThread(IOThreadFunc function, void *argument) __attribute__((deprecated));
/*! @function IOExitThread
@abstract Deprecated function - use thread_terminate(). Terminate execution of current thread.
@discussion This function destroys the currently running thread, and does not return. */
void IOExitThread(void) __attribute__((deprecated));
/*! @function IOSleep
@abstract Sleep the calling thread for a number of milliseconds.
@discussion This function blocks the calling thread for at least the number of specified milliseconds, giving time to other processes.
@param milliseconds The integer number of milliseconds to wait. */
void IOSleep(unsigned milliseconds);
/*! @function IODelay
@abstract Spin delay for a number of microseconds.
@discussion This function spins to delay for at least the number of specified microseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods. Also, the AbsoluteTime based APIs of kern/clock.h provide finer grained and lower cost delays.
@param microseconds The integer number of microseconds to spin wait. */
void IODelay(unsigned microseconds);
/*! @function IOPause
@abstract Spin delay for a number of nanoseconds.
@discussion This function spins to delay for at least the number of specified nanoseconds. Since the CPU is busy spinning no time is made available to other processes; this method of delay should be used only for short periods.
@param microseconds The integer number of nanoseconds to spin wait. */
void IOPause(unsigned nanoseconds);
/*! @function IOLog
@abstract Log a message to console in text mode, and /var/log/system.log.
@discussion This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLog should not be called from interrupt context.
@param format A printf() style format string (see printf(3) documentation).
@param other arguments described by the format string. */
void IOLog(const char *format, ...)
__attribute__((format(printf, 1, 2)));
/*! @function IOLogv
@abstract Log a message to console in text mode, and /var/log/system.log.
@discussion This function allows a driver to log diagnostic information to the screen during verbose boots, and to a log file found at /var/log/system.log. IOLogv should not be called from interrupt context.
@param format A printf() style format string (see printf(3) documentation).
@param ap stdarg(3) style variable arguments. */
void IOLogv(const char *format, va_list ap);
#ifndef _FN_KPRINTF
#define_FN_KPRINTF
void kprintf(const char *format, ...);
#endif
#ifndef _FN_KPRINTF_DECLARED
#define_FN_KPRINTF_DECLARED
#endif
/*
* Convert a integer constant (typically a #define or enum) to a string
* via an array of IONamedValue.
*/
const char *IOFindNameForValue(int value,
const IONamedValue *namedValueArray);
/*
* Convert a string to an int via an array of IONamedValue. Returns
* kIOReturnSuccess of string found, else returns kIOReturnBadArgument.
*/
IOReturn IOFindValueForName(const char *string,
const IONamedValue *regValueArray,
int *value);/* RETURNED */
/*! @function Debugger
@abstract Enter the kernel debugger.
@discussion This function freezes the kernel and enters the builtin debugger. It may not be possible to exit the debugger without a second machine.
@param reason A C-string to describe why the debugger is being entered. */
void Debugger(const char * reason);
#if __LP64__
#define IOPanic(reason) panic("%s", reason)
#else
void IOPanic(const char *reason) __attribute__((deprecated));
#endif
struct OSDictionary * IOBSDNameMatching( const char * name );
struct OSDictionary * IOOFPathMatching( const char * path, char * buf, int maxLen );
/*
* Convert between size and a power-of-two alignment.
*/
IOAlignment IOSizeToAlignment(unsigned int size);
unsigned int IOAlignmentToSize(IOAlignment align);
/*
* Multiply and divide routines for IOFixed datatype.
*/
static inline IOFixed IOFixedMultiply(IOFixed a, IOFixed b)
{
return (IOFixed)((((SInt64) a) * ((SInt64) b)) >> 16);
}
static inline IOFixed IOFixedDivide(IOFixed a, IOFixed b)
{
return (IOFixed)((((SInt64) a) << 16) / ((SInt64) b));
}
/*
* IORound and IOTrunc convenience functions, in the spirit
* of vm's round_page() and trunc_page().
*/
#define IOTrunc(value,multiple) \
(((value) / (multiple)) * (multiple));
#if defined(__APPLE_API_OBSOLETE)
/* The following API is deprecated */
/* The API exported by kern/clock.h
should be used for high resolution timing. */
void IOGetTime( mach_timespec_t * clock_time) __attribute__((deprecated));
#if !defined(__LP64__)
#undef eieio
#define eieio() \
OSSynchronizeIO()
extern mach_timespec_t IOZeroTvalspec;
#endif /* !defined(__LP64__) */
#endif /* __APPLE_API_OBSOLETE */
__END_DECLS
#endif /* !__IOKIT_IOLIB_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOCDBlockStorageDriver.h
4848
4949
5050
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
25951
#define kIOCDBlockStorageDriverClass "IOCDBlockStorageDriver"
class IOCDBlockStorageDriver : public IOBlockStorageDriver {
OSDeclareDefaultStructors(IOCDBlockStorageDriver)
public:
static const UInt64 kBlockSizeCD = 2352;
static const UInt8 kBlockTypeCD = 0x01;
/* Overrides of IORegistryEntry */
virtual boolinit(OSDictionary * properties);
virtual voidfree(void);
/* Overrides of IOBlockStorageDriver: */
virtual IOReturnejectMedia(void);
virtual void executeRequest(UInt64 byteStart,
IOMemoryDescriptor *buffer,
#ifdef __LP64__
IOStorageAttributes *attributes,
IOStorageCompletion *completion,
#else /* !__LP64__ */
IOStorageCompletion completion,
#endif /* !__LP64__ */
Context *context);
virtual const char * getDeviceTypeName(void);
virtual IOMedia *instantiateDesiredMediaObject(void);
virtual IOMedia *instantiateMediaObject(UInt64 base,UInt64 byteSize,
UInt32 blockSize,char *mediaName);
virtual IOReturnrecordMediaParameters(void);
/* End of IOBlockStorageDriver overrides. */
/*
* @function getMediaType
* @abstract
* Get the current type of media inserted in the CD drive.
* @discussion
* Certain I/O operations may not be allowed depending on the type of
* media currently inserted. For example, one cannot issue write operations
* if CD-ROM media is inserted.
* @result
* See the kCDMediaType constants in IOCDTypes.h.
*/
virtual UInt32getMediaType(void);
/* -------------------------------------------------*/
/* APIs implemented here, exported by IOCDMedia: */
/* -------------------------------------------------*/
virtual CDTOC *getTOC(void);
virtual voidreadCD(IOService *client,
UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
#ifdef __LP64__
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
#else /* !__LP64__ */
IOStorageCompletion completion);
#endif /* !__LP64__ */
virtual IOReturnreadISRC(UInt8 track,CDISRC isrc);
virtual IOReturnreadMCN(CDMCN mcn);
/* end of IOCDMedia APIs */
#ifndef __LP64__
/* --------------------------------------------------------*/
/* APIs implemented here, exported by IOCDAudioControl: */
/* --------------------------------------------------------*/
virtual IOReturnaudioPause(bool pause)__attribute__ ((deprecated));
virtual IOReturnaudioPlay(CDMSF timeStart,CDMSF timeStop)__attribute__ ((deprecated));
virtual IOReturnaudioScan(CDMSF timeStart,bool reverse)__attribute__ ((deprecated));
virtual IOReturnaudioStop()__attribute__ ((deprecated));
virtual IOReturngetAudioStatus(CDAudioStatus *status)__attribute__ ((deprecated));
virtual IOReturngetAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume)__attribute__ ((deprecated));
virtual IOReturnsetAudioVolume(UInt8 leftVolume,UInt8 rightVolume)__attribute__ ((deprecated));
/* end of IOCDAudioControl APIs */
#endif /* !__LP64__ */
/*
* Obtain this object's provider. We override the superclass's method to
* return a more specific subclass of IOService -- IOCDBlockStorageDevice.
* This method serves simply as a convenience to subclass developers.
*/
virtual IOCDBlockStorageDevice * getProvider() const;
protected:
/* Overrides of IOBlockStorageDriver behavior. */
/* When CD media is inserted, we want to create multiple nubs for the data and
* audio tracks, for sessions, and the entire media. We override the methods
* that manage nubs.
*/
virtual IOReturnacceptNewMedia(void);
virtual IOReturndecommissionMedia(bool forcible);
/* End of IOBlockStorageDriver overrides. */
/* Internally used methods: */
usingIOBlockStorageDriver::getMediaBlockSize;
virtual IOReturncacheTocInfo(void);
virtual UInt64getMediaBlockSize(CDSectorArea area,CDSectorType type);
virtual voidprepareRequest(UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
#ifdef __LP64__
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
#else /* !__LP64__ */
IOStorageCompletion completion);
#endif /* !__LP64__ */
/* ------- */
struct ExpansionData
{
UInt32 minBlockNumberAudio;
UInt32 maxBlockNumberAudio;
};
ExpansionData * _expansionData;
#define _minBlockNumberAudio \
IOCDBlockStorageDriver::_expansionData->minBlockNumberAudio
#define _maxBlockNumberAudio \
IOCDBlockStorageDriver::_expansionData->maxBlockNumberAudio
UInt32_reserved0032;
/* We keep the TOC here because we'll always need it, so what the heck.
*
* There are possible "point" track entries for 0xa0..a2, 0xb0..b4, and 0xc0..0xc1.
* Tracks need not start at 1, as long as they're between 1 and 99, and have contiguous
* numbers.
*/
CDTOC *_toc;
UInt32_tocSize;
/* ------- */
IOReturnreportDiscInfo(CDDiscInfo *discInfo);
IOReturnreportTrackInfo(UInt16 track,CDTrackInfo *trackInfo);
public:
virtual IOReturngetSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */
virtual IOReturnsetSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */
virtual IOReturnreadTOC(IOMemoryDescriptor *buffer,CDTOCFormat format,
UInt8 formatAsTime,UInt8 trackOrSessionNumber,
UInt16 *actualByteCount); /* 10.1.3 */
virtual IOReturnreadDiscInfo(IOMemoryDescriptor *buffer,
UInt16 *actualByteCount); /* 10.1.3 */
virtual IOReturnreadTrackInfo(IOMemoryDescriptor *buffer,UInt32 address,
CDTrackInfoAddressType addressType,
UInt16 *actualByteCount); /* 10.1.3 */
virtual voidwriteCD(IOService *client,
UInt64 byteStart,
IOMemoryDescriptor *buffer,
CDSectorArea sectorArea,
CDSectorType sectorType,
#ifdef __LP64__
IOStorageAttributes *attributes,
IOStorageCompletion *completion);
#else /* !__LP64__ */
IOStorageCompletion completion); /* 10.2.0 */
#endif /* !__LP64__ */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 0);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 1);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 2);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 3);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 4);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 5);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 0);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 1);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 2);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 3);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 4);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDriver, 5);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 6);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 7);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 8);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 9);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 10);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 11);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 12);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 13);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 14);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver, 15);
};
#endif
branches/azimutz/Chazi/i386/include/IOKit/storage/IOStorage.h
212212
213213
214214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560215
561216
562217
void * parameter;
};
/*!
* @class IOStorage
* @abstract
* The common base class for mass storage objects.
* @discussion
* The IOStorage class is the common base class for mass storage objects. It is
* an abstract class that defines the open/close/read/write APIs that need to be
* implemented in a given subclass. Synchronous versions of the read/write APIs
* are provided here -- they are coded in such a way as to wrap the asynchronous
* versions implemented in the subclass.
*/
class IOStorage : public IOService
{
OSDeclareAbstractStructors(IOStorage);
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
/*!
* @function handleOpen
* @discussion
* The handleOpen method grants or denies permission to access this object
* to an interested client. The argument is an IOStorageAccess value that
* specifies the level of access desired -- reader or reader-writer.
*
* This method can be invoked to upgrade or downgrade the access level for
* an existing client as well. The previous access level will prevail for
* upgrades that fail, of course. A downgrade should never fail. If the
* new access level should be the same as the old for a given client, this
* method will do nothing and return success. In all cases, one, singular
* close-per-client is expected for all opens-per-client received.
* @param client
* Client requesting the open.
* @param options
* Options for the open. Set to zero.
* @param access
* Access level for the open. Set to kIOStorageAccessReader or
* kIOStorageAccessReaderWriter.
* @result
* Returns true if the open was successful, false otherwise.
*/
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * access) = 0;
/*!
* @function handleIsOpen
* @discussion
* The handleIsOpen method determines whether the specified client, or any
* client if none is specified, presently has an open on this object.
* @param client
* Client to check the open state of. Set to zero to check the open state
* of all clients.
* @result
* Returns true if the client was (or clients were) open, false otherwise.
*/
virtual bool handleIsOpen(const IOService * client) const = 0;
/*!
* @function handleClose
* @discussion
* The handleClose method closes the client's access to this object.
* @param client
* Client requesting the close.
* @param options
* Options for the close. Set to zero.
*/
virtual void handleClose(IOService * client, IOOptionBits options) = 0;
public:
#ifndef __LP64__
/*
* Initialize this object's minimal state.
*/
virtual bool init(OSDictionary * properties = 0);
#endif /* !__LP64__ */
/*!
* @function complete
* @discussion
* Invokes the specified completion action of the read/write request. If
* the completion action is unspecified, no action is taken. This method
* serves simply as a convenience to storage subclass developers.
* @param completion
* Completion information for the data transfer.
* @param status
* Status of the data transfer.
* @param actualByteCount
* Actual number of bytes transferred in the data transfer.
*/
static void complete(IOStorageCompletion * completion,
IOReturn status,
UInt64 actualByteCount = 0);
#ifndef __LP64__
static void complete(IOStorageCompletion completion,
IOReturn status,
UInt64 actualByteCount = 0); /* DEPRECATED */
#endif /* !__LP64__ */
/*!
* @function open
* @discussion
* Ask the storage object for permission to access its contents; the method
* is equivalent to IOService::open(), but with the correct parameter types.
*
* This method may also be invoked to upgrade or downgrade the access of an
* existing open (if it fails, the existing open prevails).
* @param client
* Client requesting the open.
* @param options
* Options for the open. Set to zero.
* @param access
* Access level for the open. Set to kIOStorageAccessReader or
* kIOStorageAccessReaderWriter.
* @result
* Returns true if the open was successful, false otherwise.
*/
virtual bool open(IOService * client,
IOOptionBits options,
IOStorageAccess access);
#ifndef __LP64__
virtual void read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion) __attribute__ ((deprecated));
virtual void write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*!
* @function read
* @discussion
* Read data from the storage object at the specified byte offset into the
* specified buffer, synchronously. When the read completes, this method
* will return to the caller. The actual byte count field is optional.
* @param client
* Client requesting the read.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes.
* @param actualByteCount
* Returns the actual number of bytes transferred in the data transfer.
* @result
* Returns the status of the data transfer.
*/
#ifdef __LP64__
virtual IOReturn read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes = 0,
UInt64 * actualByteCount = 0);
#else /* !__LP64__ */
virtual IOReturn read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
UInt64 * actualByteCount = 0);
#endif /* !__LP64__ */
/*!
* @function write
* @discussion
* Write data into the storage object at the specified byte offset from the
* specified buffer, synchronously. When the write completes, this method
* will return to the caller. The actual byte count field is optional.
* @param client
* Client requesting the write.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes.
* @param actualByteCount
* Returns the actual number of bytes transferred in the data transfer.
* @result
* Returns the status of the data transfer.
*/
#ifdef __LP64__
virtual IOReturn write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes = 0,
UInt64 * actualByteCount = 0);
#else /* !__LP64__ */
virtual IOReturn write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
UInt64 * actualByteCount = 0);
#endif /* !__LP64__ */
/*!
* @function synchronizeCache
* @discussion
* Flush the cached data in the storage object, if any, synchronously.
* @param client
* Client requesting the cache synchronization.
* @result
* Returns the status of the cache synchronization.
*/
virtual IOReturn synchronizeCache(IOService * client) = 0;
/*!
* @function read
* @discussion
* Read data from the storage object at the specified byte offset into the
* specified buffer, asynchronously. When the read completes, the caller
* will be notified via the specified completion action.
*
* The buffer will be retained for the duration of the read.
* @param client
* Client requesting the read.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
#ifdef __LP64__
virtual void read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion) = 0;
#else /* !__LP64__ */
virtual void read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion); /* 10.5.0 */
#endif /* !__LP64__ */
/*!
* @function write
* @discussion
* Write data into the storage object at the specified byte offset from the
* specified buffer, asynchronously. When the write completes, the caller
* will be notified via the specified completion action.
*
* The buffer will be retained for the duration of the write.
* @param client
* Client requesting the write.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
#ifdef __LP64__
virtual void write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion) = 0;
#else /* !__LP64__ */
virtual void write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion); /* 10.5.0 */
#endif /* !__LP64__ */
/*!
* @function discard
* @discussion
* Delete unused data from the storage object at the specified byte offset,
* synchronously.
* @param client
* Client requesting the operation.
* @param byteStart
* Starting byte offset for the operation.
* @param byteCount
* Size of the operation.
* @result
* Returns the status of the operation.
*/
virtual IOReturn discard(IOService * client,
UInt64 byteStart,
UInt64 byteCount); /* 10.6.0 */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOStorage, 0);
OSMetaClassDeclareReservedUnused(IOStorage, 1);
OSMetaClassDeclareReservedUnused(IOStorage, 2);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOStorage, 0);
OSMetaClassDeclareReservedUsed(IOStorage, 1);
OSMetaClassDeclareReservedUsed(IOStorage, 2);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOStorage, 3);
OSMetaClassDeclareReservedUnused(IOStorage, 4);
OSMetaClassDeclareReservedUnused(IOStorage, 5);
OSMetaClassDeclareReservedUnused(IOStorage, 6);
OSMetaClassDeclareReservedUnused(IOStorage, 7);
OSMetaClassDeclareReservedUnused(IOStorage, 8);
OSMetaClassDeclareReservedUnused(IOStorage, 9);
OSMetaClassDeclareReservedUnused(IOStorage, 10);
OSMetaClassDeclareReservedUnused(IOStorage, 11);
OSMetaClassDeclareReservedUnused(IOStorage, 12);
OSMetaClassDeclareReservedUnused(IOStorage, 13);
OSMetaClassDeclareReservedUnused(IOStorage, 14);
OSMetaClassDeclareReservedUnused(IOStorage, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOSTORAGE_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOCDBlockStorageDevice.h
5454
5555
5656
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
7357
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
17958
18059
18160
/* Property used for matching, so the generic driver gets the nub it wants. */
#definekIOBlockStorageDeviceTypeCDROM"CDROM"
/*!
* @class
* IOCDBlockStorageDevice : public IOBlockStorageDevice
* @abstract
* The IOCDBlockStorageDevice class is a generic CD block storage device
* abstraction.
* @discussion
* This class is the protocol for generic CD functionality, independent of
* the physical connection protocol (e.g. SCSI, ATA, USB).
*
* The APIs are the union of CD (block storage) data APIs and all
* necessary low-level CD APIs.
*
* A subclass implements relay methods that translate our requests into
* calls to a protocol- and device-specific provider.
*/
class IOCDBlockStorageDevice : public IOBlockStorageDevice {
OSDeclareAbstractStructors(IOCDBlockStorageDevice)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
public:
/* Overrides from IORegistryEntry */
virtual boolinit(OSDictionary * properties);
/*-----------------------------------------*/
/* CD APIs */
/*-----------------------------------------*/
virtual IOReturndoAsyncReadCD(IOMemoryDescriptor *buffer,
UInt32 block,UInt32 nblks,
CDSectorArea sectorArea,
CDSectorType sectorType,
IOStorageCompletion completion) = 0;
virtual UInt32getMediaType(void)= 0;
virtual IOReturnreadISRC(UInt8 track,CDISRC isrc)= 0;
virtual IOReturnreadMCN(CDMCN mcn)= 0;
virtual IOReturnreadTOC(IOMemoryDescriptor *buffer) = 0;
#ifndef __LP64__
/*-----------------------------------------*/
/* APIs exported by IOCDAudioControl */
/*-----------------------------------------*/
virtual IOReturnaudioPause(bool pause)__attribute__ ((deprecated));
virtual IOReturnaudioPlay(CDMSF timeStart,CDMSF timeStop)__attribute__ ((deprecated));
virtual IOReturnaudioScan(CDMSF timeStart,bool reverse)__attribute__ ((deprecated));
virtual IOReturnaudioStop()__attribute__ ((deprecated));
virtual IOReturngetAudioStatus(CDAudioStatus *status)__attribute__ ((deprecated));
virtual IOReturngetAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume)__attribute__ ((deprecated));
virtual IOReturnsetAudioVolume(UInt8 leftVolume,UInt8 rightVolume)__attribute__ ((deprecated));
#endif /* !__LP64__ */
/*-----------------------------------------*/
/* CD APIs */
/*-----------------------------------------*/
#ifdef __LP64__
virtual IOReturngetSpeed(UInt16 * kilobytesPerSecond)= 0;
virtual IOReturnsetSpeed(UInt16 kilobytesPerSecond)= 0;
virtual IOReturnreadTOC(IOMemoryDescriptor *buffer,CDTOCFormat format,
UInt8 msf,UInt8 trackSessionNumber,
UInt16 *actualByteCount)= 0;
virtual IOReturnreadDiscInfo(IOMemoryDescriptor *buffer,
UInt16 *actualByteCount)= 0;
virtual IOReturnreadTrackInfo(IOMemoryDescriptor *buffer,UInt32 address,
CDTrackInfoAddressType addressType,
UInt16 *actualByteCount)= 0;
#else /* !__LP64__ */
virtual IOReturngetSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */
virtual IOReturnsetSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */
virtual IOReturnreadTOC(IOMemoryDescriptor *buffer,CDTOCFormat format,
UInt8 msf,UInt8 trackSessionNumber,
UInt16 *actualByteCount); /* 10.1.3 */
virtual IOReturnreadDiscInfo(IOMemoryDescriptor *buffer,
UInt16 *actualByteCount); /* 10.1.3 */
virtual IOReturnreadTrackInfo(IOMemoryDescriptor *buffer,UInt32 address,
CDTrackInfoAddressType addressType,
UInt16 *actualByteCount); /* 10.1.3 */
#endif /* !__LP64__ */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 0);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 1);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 2);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 3);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 4);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 0);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 1);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 2);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 3);
OSMetaClassDeclareReservedUsed(IOCDBlockStorageDevice, 4);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 5);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 6);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 7);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 8);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 9);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 10);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 11);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 12);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 13);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 14);
OSMetaClassDeclareReservedUnused(IOCDBlockStorageDevice, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOCDBLOCKSTORAGEDEVICE_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOMediaBSDClient.h
2626
2727
2828
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
15029
#include <sys/disk.h>
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <sys/conf.h>
#include <IOKit/storage/IOMedia.h>
class AnchorTable;
class MinorTable;
struct MinorSlot;
/*
* Class
*/
class IOMediaBSDClient : public IOService
{
OSDeclareDefaultStructors(IOMediaBSDClient)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
private:
AnchorTable * _anchors; /* (table of anchors) */
UInt32 _reserved0064; /* (reserved, do not use) */
UInt32 _reserved0096; /* (reserved, do not use) */
MinorTable * _minors; /* (table of minors) */
UInt32 _reserved0160; /* (reserved, do not use) */
protected:
/*
* Find the whole media that roots the given media tree.
*/
virtual IOMedia * getWholeMedia( IOMedia * media,
UInt32 * slicePathSize = 0,
char * slicePath = 0 );
/*
* Create bdevsw and cdevsw nodes for the given media object.
*/
virtual bool createNodes(IOMedia * media);
/*
* Free all of this object's outstanding resources.
*/
virtual void free();
public:
/*
* Obtain this object's provider. We override the superclass's method to
* return a more specific subclass of IOService -- IOMedia. This method
* method serves simply as a convenience to subclass developers.
*/
virtual IOMedia * getProvider() const;
/*
* Initialize this object's minimal state.
*/
virtual bool init(OSDictionary * properties = 0);
/*
* This method is called once we have been attached to the provider object.
*/
virtual bool start(IOService * provider);
/*
* This method is called when we are to terminate from the provider object.
*/
virtual bool terminate(IOOptionBits options);
#ifndef __LP64__
virtual AnchorTable * getAnchors() __attribute__ ((deprecated));
virtual MinorTable * getMinors() __attribute__ ((deprecated));
virtual MinorSlot * getMinor(UInt32 minorID) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*
* Process a foreign ioctl.
*/
virtual int ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, proc_t proc);
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 0);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOMediaBSDClient, 0);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 1);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 2);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 3);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 4);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 5);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 6);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 7);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 8);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 9);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 10);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 11);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 12);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 13);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 14);
OSMetaClassDeclareReservedUnused(IOMediaBSDClient, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOMEDIABSDCLIENT_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOGUIDPartitionScheme.h
8787
8888
8989
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
23490
#pragma pack(pop) /* (reset to default struct packing) */
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOPartitionScheme.h>
/*
* Class
*/
class IOGUIDPartitionScheme : public IOPartitionScheme
{
OSDeclareDefaultStructors(IOGUIDPartitionScheme);
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
OSSet * _partitions; /* (set of media objects representing partitions) */
/*
* Free all of this object's outstanding resources.
*/
virtual void free(void);
/*
* Scan the provider media for a GUID partition map. Returns the set
* of media objects representing each of the partitions (the retain for
* the set is passed to the caller), or null should no partition map be
* found. The default probe score can be adjusted up or down, based on
* the confidence of the scan.
*/
virtual OSSet * scan(SInt32 * score);
/*
* Ask whether the given partition is used.
*/
virtual bool isPartitionUsed(gpt_ent * partition);
/*
* Ask whether the given partition appears to be corrupt. A partition that
* is corrupt will cause the failure of the GUID partition map recognition
* altogether.
*/
virtual bool isPartitionCorrupt( gpt_ent * partition,
UInt32 partitionID );
/*
* Ask whether the given partition appears to be invalid. A partition that
* is invalid will cause it to be skipped in the scan, but will not cause a
* failure of the GUID partition map recognition.
*/
virtual bool isPartitionInvalid( gpt_ent * partition,
UInt32 partitionID );
/*
* Instantiate a new media object to represent the given partition.
*/
virtual IOMedia * instantiateMediaObject( gpt_ent * partition,
UInt32 partitionID );
/*
* Allocate a new media object (called from instantiateMediaObject).
*/
virtual IOMedia * instantiateDesiredMediaObject( gpt_ent * partition,
UInt32 partitionID );
#ifndef __LP64__
/*
* Attach the given media object to the device tree plane.
*/
virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated));
/*
* Detach the given media object from the device tree plane.
*/
virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated));
#endif /* !__LP64__ */
public:
/*
* Initialize this object's minimal state.
*/
virtual bool init(OSDictionary * properties = 0);
/*
* Determine whether the provider media contains a GUID partition map.
*/
virtual IOService * probe(IOService * provider, SInt32 * score);
/*
* Publish the new media objects which represent our partitions.
*/
virtual bool start(IOService * provider);
/*
* Clean up after the media objects we published before terminating.
*/
virtual void stop(IOService * provider);
/*
* Request that the provider media be re-scanned for partitions.
*/
virtual IOReturn requestProbe(IOOptionBits options);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 0);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 1);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 2);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 3);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 4);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 5);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 6);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 7);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 8);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 9);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 10);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 11);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 12);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 13);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 14);
OSMetaClassDeclareReservedUnused(IOGUIDPartitionScheme, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOGUIDPARTITIONSCHEME_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOFDiskPartitionScheme.h
102102
103103
104104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264105
#pragma pack(pop) /* (reset to default struct packing) */
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOPartitionScheme.h>
/*
* Class
*/
class IOFDiskPartitionScheme : public IOPartitionScheme
{
OSDeclareDefaultStructors(IOFDiskPartitionScheme);
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
OSSet * _partitions; /* (set of media objects representing partitions) */
/*
* Free all of this object's outstanding resources.
*/
virtual void free(void);
/*
* Scan the provider media for an FDisk partition map. Returns the set
* of media objects representing each of the partitions (the retain for
* the set is passed to the caller), or null should no partition map be
* found. The default probe score can be adjusted up or down, based on
* the confidence of the scan.
*/
virtual OSSet * scan(SInt32 * score);
/*
* Ask whether the given partition is extended.
*/
virtual bool isPartitionExtended(fdisk_part * partition);
/*
* Ask whether the given partition is used.
*/
virtual bool isPartitionUsed(fdisk_part * partition);
/*
* Ask whether the given partition appears to be corrupt. A partition that
* is corrupt will cause the failure of the FDisk partition map recognition
* altogether.
*/
virtual bool isPartitionCorrupt( fdisk_part * partition,
UInt32 partitionID,
UInt32 fdiskBlock );
/*
* Ask whether the given partition appears to be invalid. A partition that
* is invalid will cause it to be skipped in the scan, but will not cause a
* failure of the FDisk partition map recognition.
*/
virtual bool isPartitionInvalid( fdisk_part * partition,
UInt32 partitionID,
UInt32 fdiskBlock );
/*
* Instantiate a new media object to represent the given partition.
*/
virtual IOMedia * instantiateMediaObject( fdisk_part * partition,
UInt32 partitionID,
UInt32 fdiskBlock );
/*
* Allocate a new media object (called from instantiateMediaObject).
*/
virtual IOMedia * instantiateDesiredMediaObject( fdisk_part * partition,
UInt32 partitionID,
UInt32 fdiskBlock );
#ifndef __LP64__
/*
* Attach the given media object to the device tree plane.
*/
virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated));
/*
* Detach the given media object from the device tree plane.
*/
virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated));
#endif /* !__LP64__ */
public:
/*
* Initialize this object's minimal state.
*/
virtual bool init(OSDictionary * properties = 0);
/*
* Determine whether the provider media contains an FDisk partition map.
*/
virtual IOService * probe(IOService * provider, SInt32 * score);
/*
* Publish the new media objects which represent our partitions.
*/
virtual bool start(IOService * provider);
/*
* Clean up after the media objects we published before terminating.
*/
virtual void stop(IOService * provider);
/*
* Request that the provider media be re-scanned for partitions.
*/
virtual IOReturn requestProbe(IOOptionBits options);
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 0);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 1);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOFDiskPartitionScheme, 0);
OSMetaClassDeclareReservedUsed(IOFDiskPartitionScheme, 1);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 2);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 3);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 4);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 5);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 6);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 7);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 8);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 9);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 10);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 11);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 12);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 13);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 14);
OSMetaClassDeclareReservedUnused(IOFDiskPartitionScheme, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOFDISKPARTITIONSCHEME_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOMedia.h
228228
229229
230230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668231
typedef UInt32 IOMediaAttributeMask;
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOStorage.h>
/*!
* @class IOMedia
* @abstract
* A random-access disk device abstraction.
* @discussion
* The IOMedia class is a random-access disk device abstraction. It provides a
* consistent interface for both real and virtual disk devices, for subdivisions
* of disks such as partitions, for supersets of disks such as RAID volumes, and
* so on. It extends the IOStorage class by implementing the appropriate open,
* close, read, write, and matching semantics for media objects. The properties
* it has reflect the properties of real disk devices, such as ejectability and
* writability.
*
* The read and write interfaces support byte-level access to the storage space,
* with the appropriate deblocking handled by the block storage driver, however,
* a typical client will want to get the natural block size in order to optimize
* access to the real disk device. A read or write is accepted so long as the
* client's access is valid, the media is formatted and the transfer is within
* the bounds of the media. An optional non-zero base (offset) is then applied
* before the read or write is passed to provider object.
*/
class IOMedia : public IOStorage
{
OSDeclareDefaultStructors(IOMedia)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
UInt32 _attributes;
bool _isWhole;
bool _isWritable;
UInt64 _mediaBase; /* (relative to the storage object below us) */
UInt64 _mediaSize;
IOStorageAccess _openLevel;
OSDictionary * _openClients;
UInt32 _reserved0320;
UInt64 _preferredBlockSize;
/*
* Free all of this object's outstanding resources.
*/
virtual void free();
/*!
* @function handleOpen
* @discussion
* The handleOpen method grants or denies permission to access this object
* to an interested client. The argument is an IOStorageAccess value that
* specifies the level of access desired -- reader or reader-writer.
*
* This method can be invoked to upgrade or downgrade the access level for
* an existing client as well. The previous access level will prevail for
* upgrades that fail, of course. A downgrade should never fail. If the
* new access level should be the same as the old for a given client, this
* method will do nothing and return success. In all cases, one, singular
* close-per-client is expected for all opens-per-client received.
*
* This implementation replaces the IOService definition of handleOpen().
* @param client
* Client requesting the open.
* @param options
* Options for the open. Set to zero.
* @param access
* Access level for the open. Set to kIOStorageAccessReader or
* kIOStorageAccessReaderWriter.
* @result
* Returns true if the open was successful, false otherwise.
*/
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * access);
/*!
* @function handleIsOpen
* @discussion
* The handleIsOpen method determines whether the specified client, or any
* client if none is specified, presently has an open on this object.
*
* This implementation replaces the IOService definition of handleIsOpen().
* @param client
* Client to check the open state of. Set to zero to check the open state
* of all clients.
* @result
* Returns true if the client was (or clients were) open, false otherwise.
*/
virtual bool handleIsOpen(const IOService * client) const;
/*!
* @function handleClose
* @discussion
* The handleClose method closes the client's access to this object.
*
* This implementation replaces the IOService definition of handleClose().
* @param client
* Client requesting the close.
* @param options
* Options for the close. Set to zero.
*/
virtual void handleClose(IOService * client, IOOptionBits options);
public:
using IOStorage::read;
using IOStorage::write;
#ifndef __LP64__
virtual bool init(UInt64 base,
UInt64 size,
UInt64 preferredBlockSize,
bool isEjectable,
bool isWhole,
bool isWritable,
const char * contentHint = 0,
OSDictionary * properties = 0) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*
* This method is called for each client interested in the services we
* provide. The superclass links us as a parent to this client in the
* I/O Kit registry on success.
*/
virtual bool attachToChild(IORegistryEntry * client,
const IORegistryPlane * plane);
/*
* This method is called for each client that loses interest in the
* services we provide. The superclass unlinks us from this client
* in the I/O Kit registry on success.
*/
virtual void detachFromChild(IORegistryEntry * client,
const IORegistryPlane * plane);
/*
* Obtain this object's provider. We override the superclass's method to
* return a more specific subclass of OSObject -- IOStorage. This method
* serves simply as a convenience to subclass developers.
*/
virtual IOStorage * getProvider() const;
/*
* Compare the properties in the supplied table to this object's properties.
*/
virtual bool matchPropertyTable(OSDictionary * table, SInt32 * score);
/*!
* @function read
* @discussion
* Read data from the storage object at the specified byte offset into the
* specified buffer, asynchronously. When the read completes, the caller
* will be notified via the specified completion action.
*
* The buffer will be retained for the duration of the read.
* @param client
* Client requesting the read.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
virtual void read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion);
/*!
* @function write
* @discussion
* Write data into the storage object at the specified byte offset from the
* specified buffer, asynchronously. When the write completes, the caller
* will be notified via the specified completion action.
*
* The buffer will be retained for the duration of the write.
* @param client
* Client requesting the write.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
virtual void write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion);
/*!
* @function synchronizeCache
* @discussion
* Flush the cached data in the storage object, if any, synchronously.
* @param client
* Client requesting the cache synchronization.
* @result
* Returns the status of the cache synchronization.
*/
virtual IOReturn synchronizeCache(IOService * client);
/*!
* @function discard
* @discussion
* Delete unused data from the storage object at the specified byte offset,
* synchronously.
* @param client
* Client requesting the operation.
* @param byteStart
* Starting byte offset for the operation.
* @param byteCount
* Size of the operation.
* @result
* Returns the status of the operation.
*/
virtual IOReturn discard(IOService * client,
UInt64 byteStart,
UInt64 byteCount);
/*!
* @function getPreferredBlockSize
* @discussion
* Ask the media object for its natural block size. This information
* is useful to clients that want to optimize access to the media.
* @result
* Natural block size, in bytes.
*/
virtual UInt64 getPreferredBlockSize() const;
/*!
* @function getSize
* @discussion
* Ask the media object for its total length in bytes.
* @result
* Media size, in bytes.
*/
virtual UInt64 getSize() const;
/*!
* @function getBase
* @discussion
* Ask the media object for its byte offset relative to its provider media
* object below it in the storage hierarchy.
* Media offset, in bytes.
*/
virtual UInt64 getBase() const;
/*!
* @function isEjectable
* @discussion
* Ask the media object whether it is ejectable.
* @result
* Returns true if the media is ejectable, false otherwise.
*/
virtual bool isEjectable() const;
/*!
* @function isFormatted
* @discussion
* Ask the media object whether it is formatted.
* @result
* Returns true if the media is formatted, false otherwise.
*/
virtual bool isFormatted() const;
/*!
* @function isWhole
* @discussion
* Ask the media object whether it represents the whole disk.
* @result
* Returns true if the media represents the whole disk, false otherwise.
*/
virtual bool isWhole() const;
/*!
* @function isWritable
* @discussion
* Ask the media object whether it is writable.
* @result
* Returns true if the media is writable, false otherwise.
*/
virtual bool isWritable() const;
/*!
* @function getContent
* @discussion
* Ask the media object for a description of its contents. The description
* is the same as the hint at the time of the object's creation, but it is
* possible that the description has been overridden by a client (which has probed
* the media and identified the content correctly) of the media object. It
* is more accurate than the hint for this reason. The string is formed in
* the likeness of Apple's "Apple_HFS" strings or in the likeness of a UUID.
*
* The content description can be overridden by any client that matches onto
* this media object with a match category of kIOStorageCategory. The media
* object checks for a kIOMediaContentMaskKey property in the client, and if
* it finds one, it copies it into kIOMediaContentKey property.
* @result
* Description of media's contents.
*/
virtual const char * getContent() const;
/*!
* @function getContentHint
* @discussion
* Ask the media object for a hint of its contents. The hint is set at the
* time of the object's creation, should the creator have a clue as to what
* it may contain. The hint string does not change for the lifetime of the
* object and is also formed in the likeness of Apple's "Apple_HFS" strings
* or in the likeness of a UUID.
* @result
* Hint of media's contents.
*/
virtual const char * getContentHint() const;
/*!
* @function init
* @discussion
* Initialize this object's minimal state.
* @param base
* Media offset, in bytes.
* @param size
* Media size, in bytes.
* @param preferredBlockSize
* Natural block size, in bytes.
* @param attributes
* Media attributes, such as ejectability and removability. See
* IOMediaAttributeMask.
* @param isWhole
* Indicates whether the media represents the whole disk.
* @param isWritable
* Indicates whether the media is writable.
* @param contentHint
* Hint of media's contents (optional). See getContentHint().
* @param properties
* Substitute property table for this object (optional).
* @result
* Returns true on success, false otherwise.
*/
virtual bool init(UInt64 base,
UInt64 size,
UInt64 preferredBlockSize,
IOMediaAttributeMask attributes,
bool isWhole,
bool isWritable,
const char * contentHint = 0,
OSDictionary * properties = 0); /* 10.2.0 */
/*!
* @function getAttributes
* @discussion
* Ask the media object for its attributes.
* @result
* Media attributes, such as ejectability and removability. See
* IOMediaAttributeMask.
*/
virtual IOMediaAttributeMask getAttributes() const; /* 10.2.0 */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOMedia, 0);
OSMetaClassDeclareReservedUnused(IOMedia, 1);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOMedia, 0);
OSMetaClassDeclareReservedUsed(IOMedia, 1);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOMedia, 2);
OSMetaClassDeclareReservedUnused(IOMedia, 3);
OSMetaClassDeclareReservedUnused(IOMedia, 4);
OSMetaClassDeclareReservedUnused(IOMedia, 5);
OSMetaClassDeclareReservedUnused(IOMedia, 6);
OSMetaClassDeclareReservedUnused(IOMedia, 7);
OSMetaClassDeclareReservedUnused(IOMedia, 8);
OSMetaClassDeclareReservedUnused(IOMedia, 9);
OSMetaClassDeclareReservedUnused(IOMedia, 10);
OSMetaClassDeclareReservedUnused(IOMedia, 11);
OSMetaClassDeclareReservedUnused(IOMedia, 12);
OSMetaClassDeclareReservedUnused(IOMedia, 13);
OSMetaClassDeclareReservedUnused(IOMedia, 14);
OSMetaClassDeclareReservedUnused(IOMedia, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOMEDIA_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOApplePartitionScheme.h
119119
120120
121121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265122
#pragma pack(pop) /* (reset to default struct packing) */
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOPartitionScheme.h>
/*
* Class
*/
class IOApplePartitionScheme : public IOPartitionScheme
{
OSDeclareDefaultStructors(IOApplePartitionScheme);
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
OSSet * _partitions; /* (set of media objects representing partitions) */
/*
* Free all of this object's outstanding resources.
*/
virtual void free(void);
/*
* Scan the provider media for an Apple partition map. Returns the set
* of media objects representing each of the partitions (the retain for
* the set is passed to the caller), or null should no partition map be
* found. The default probe score can be adjusted up or down, based on
* the confidence of the scan.
*/
virtual OSSet * scan(SInt32 * score);
/*
* Ask whether the given partition appears to be corrupt. A partition that
* is corrupt will cause the failure of the Apple partition map recognition
* altogether.
*/
virtual bool isPartitionCorrupt( dpme * partition,
UInt32 partitionID,
UInt32 partitionBlockSize );
/*
* Ask whether the given partition appears to be invalid. A partition that
* is invalid will cause it to be skipped in the scan, but will not cause a
* failure of the Apple partition map recognition.
*/
virtual bool isPartitionInvalid( dpme * partition,
UInt32 partitionID,
UInt32 partitionBlockSize );
/*
* Instantiate a new media object to represent the given partition.
*/
virtual IOMedia * instantiateMediaObject( dpme * partition,
UInt32 partitionID,
UInt32 partitionBlockSize );
/*
* Allocate a new media object (called from instantiateMediaObject).
*/
virtual IOMedia * instantiateDesiredMediaObject(
dpme * partition,
UInt32 partitionID,
UInt32 partitionBlockSize );
#ifndef __LP64__
/*
* Attach the given media object to the device tree plane.
*/
virtual bool attachMediaObjectToDeviceTree(IOMedia * media) __attribute__ ((deprecated));
/*
* Detach the given media object from the device tree plane.
*/
virtual void detachMediaObjectFromDeviceTree(IOMedia * media) __attribute__ ((deprecated));
#endif /* !__LP64__ */
public:
/*
* Initialize this object's minimal state.
*/
virtual bool init(OSDictionary * properties = 0);
/*
* Determine whether the provider media contains an Apple partition map.
*/
virtual IOService * probe(IOService * provider, SInt32 * score);
/*
* Publish the new media objects which represent our partitions.
*/
virtual bool start(IOService * provider);
/*
* Clean up after the media objects we published before terminating.
*/
virtual void stop(IOService * provider);
/*
* Request that the provider media be re-scanned for partitions.
*/
virtual IOReturn requestProbe(IOOptionBits options);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 0);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 1);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 2);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 3);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 4);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 5);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 6);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 7);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 8);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 9);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 10);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 11);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 12);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 13);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 14);
OSMetaClassDeclareReservedUnused(IOApplePartitionScheme, 15);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOAPPLEPARTITIONSCHEME_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOBlockStorageDriver.h
242242
243243
244244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571245
typedef UInt32 IOMediaState;
#ifdef KERNEL
#ifdef __cplusplus
/*
* Kernel
*/
#include <IOKit/storage/IOBlockStorageDevice.h>
#include <IOKit/storage/IOMedia.h>
#include <IOKit/storage/IOStorage.h>
#include <kern/thread_call.h>
/*!
* @class IOBlockStorageDriver
* @abstract
* The common base class for generic block storage drivers.
* @discussion
* The IOBlockStorageDriver class is the common base class for generic block
* storage drivers. It matches and communicates via an IOBlockStorageDevice
* interface, and connects to the remainder of the storage framework via the
* IOStorage protocol. It extends the IOStorage protocol by implementing the
* appropriate open and close semantics, deblocking for unaligned transfers,
* polling for ejectable media, locking and ejection policies, media object
* creation and tear-down, and statistics gathering and reporting.
*
* Block storage drivers are split into two parts: the generic driver handles
* all generic device issues, independent of the lower-level transport
* mechanism (e.g. SCSI, ATA, USB, FireWire). All storage operations
* at the generic driver level are translated into a series of generic
* device operations. These operations are passed via the IOBlockStorageDevice
* nub to a transport driver, which implements the appropriate
* transport-dependent protocol to execute these operations.
*
* To determine the write-protect state of a device (or media), for
* example, the generic driver would issue a call to the
* Transport Driver's reportWriteProtection method. If this were a SCSI
* device, its transport driver would issue a Mode Sense command to
* extract the write-protection status bit. The transport driver then
* reports true or false to the generic driver.
*
* The generic driver therefore has no knowledge of, or involvement
* with, the actual commands and mechanisms used to communicate with
* the device. It is expected that the generic driver will rarely, if
* ever, need to be subclassed to handle device idiosyncrasies; rather,
* the transport driver should be changed via overrides.
*
* A generic driver could be subclassed to create a different type of
* generic device. The generic driver IOCDBlockStorageDriver class is
* a subclass of IOBlockStorageDriver, adding CD functions.
*/
class IOBlockStorageDriver : public IOStorage
{
OSDeclareDefaultStructors(IOBlockStorageDriver);
public:
/*!
* @enum Statistics
* @abstract
* Indices for the different statistics that getStatistics() can report.
* @constant kStatisticsReads Number of read operations thus far.
* @constant kStatisticsBytesRead Number of bytes read thus far.
* @constant kStatisticsTotalReadTime Nanoseconds spent performing reads thus far.
* @constant kStatisticsLatentReadTime Nanoseconds of latency during reads thus far.
* @constant kStatisticsReadRetries Number of read retries thus far.
* @constant kStatisticsReadErrors Number of read errors thus far.
* @constant kStatisticsWrites Number of write operations thus far.
* @constant kStatisticsSingleBlockWrites Number of write operations for a single block thus far.
* @constant kStatisticsBytesWritten Number of bytes written thus far.
* @constant kStatisticsTotalWriteTime Nanoseconds spent performing writes thus far.
* @constant kStatisticsLatentWriteTime Nanoseconds of latency during writes thus far.
* @constant kStatisticsWriteRetries Number of write retries thus far.
* @constant kStatisticsWriteErrors Number of write errors thus far.
*/
enum Statistics
{
kStatisticsReads,
kStatisticsBytesRead,
kStatisticsTotalReadTime,
kStatisticsLatentReadTime,
kStatisticsReadRetries,
kStatisticsReadErrors,
kStatisticsWrites,
kStatisticsSingleBlockWrites,
kStatisticsBytesWritten,
kStatisticsTotalWriteTime,
kStatisticsLatentWriteTime,
kStatisticsWriteRetries,
kStatisticsWriteErrors
};
static const UInt32 kStatisticsCount = kStatisticsWriteErrors + 1;
protected:
struct Context;
struct ExpansionData
{
bool mediaDirtied;
UInt64 maxReadBlockTransfer;
UInt64 maxWriteBlockTransfer;
IONotifier * powerEventNotifier;
UInt32 deblockRequestWriteLockCount;
UInt64 maxReadSegmentTransfer;
UInt64 maxWriteSegmentTransfer;
UInt64 maxReadSegmentByteTransfer;
UInt64 maxWriteSegmentByteTransfer;
UInt64 minSegmentAlignmentByteTransfer;
UInt64 maxSegmentWidthByteTransfer;
Context * contexts;
IOSimpleLock * contextsLock;
UInt32 contextsCount;
UInt32 contextsMaxCount;
};
ExpansionData * _expansionData;
#define _mediaDirtied \
IOBlockStorageDriver::_expansionData->mediaDirtied
#define _maxReadBlockTransfer \
IOBlockStorageDriver::_expansionData->maxReadBlockTransfer
#define _maxWriteBlockTransfer \
IOBlockStorageDriver::_expansionData->maxWriteBlockTransfer
#define _powerEventNotifier \
IOBlockStorageDriver::_expansionData->powerEventNotifier
#define _deblockRequestWriteLockCount \
IOBlockStorageDriver::_expansionData->deblockRequestWriteLockCount
#define _maxReadSegmentTransfer \
IOBlockStorageDriver::_expansionData->maxReadSegmentTransfer
#define _maxWriteSegmentTransfer \
IOBlockStorageDriver::_expansionData->maxWriteSegmentTransfer
#define _maxReadSegmentByteTransfer \
IOBlockStorageDriver::_expansionData->maxReadSegmentByteTransfer
#define _maxWriteSegmentByteTransfer \
IOBlockStorageDriver::_expansionData->maxWriteSegmentByteTransfer
#define _minSegmentAlignmentByteTransfer \
IOBlockStorageDriver::_expansionData->minSegmentAlignmentByteTransfer
#define _maxSegmentWidthByteTransfer \
IOBlockStorageDriver::_expansionData->maxSegmentWidthByteTransfer
#define _contexts \
IOBlockStorageDriver::_expansionData->contexts
#define _contextsLock \
IOBlockStorageDriver::_expansionData->contextsLock
#define _contextsCount \
IOBlockStorageDriver::_expansionData->contextsCount
#define _contextsMaxCount \
IOBlockStorageDriver::_expansionData->contextsMaxCount
OSSet * _openClients;
OSNumber * _statistics[kStatisticsCount];
/*
* @struct Context
* @discussion
* Context structure for a read/write operation. It describes the block size,
* and where applicable, a block type and block sub-type, for a data transfer,
* as well as the completion information for the original request. Note that
* the block type field is unused in the IOBlockStorageDriver class.
* @field block.size
* Block size for the operation.
* @field block.type
* Block type for the operation. Unused in IOBlockStorageDriver. The default
* value for this field is IOBlockStorageDriver::kBlockTypeStandard.
* @field block.typeSub
* Block sub-type for the operation. It's definition depends on block.type.
* Unused in IOBlockStorageDriver.
* @field request.byteStart
* Starting byte offset for the data transfer.
* @param request.buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param request.attributes
* Attributes of the data transfer. See IOStorageAttributes.
* @param request.completion
* Completion routine to call once the data transfer is complete.
*/
struct Context
{
#ifdef __LP64__
struct
{
UInt64 byteStart;
IOMemoryDescriptor * buffer;
IOStorageAttributes attributes;
IOStorageCompletion completion;
} request;
struct
{
UInt32 size;
UInt8 type;
UInt8 typeSub[3];
} block;
AbsoluteTime timeStart;
UInt64 reserved0704;
UInt64 reserved0768;
UInt64 reserved0832;
UInt64 reserved0896;
#else /* !__LP64__ */
struct
{
UInt32 size;
UInt8 type;
UInt8 typeSub[3];
} block;
struct
{
UInt64 byteStart;
IOMemoryDescriptor * buffer;
IOStorageCompletion completion;
} original;
AbsoluteTime timeStart;
struct
{
IOStorageAttributes attributes;
} request;
UInt32 reserved0448;
#endif /* !__LP64__ */
Context * next;
};
static const UInt8 kBlockTypeStandard = 0x00;
/*
* Free all of this object's outstanding resources.
*
* This method's implementation is not typically overridden.
*/
void free();
/*!
* @function handleOpen
* @discussion
* The handleOpen method grants or denies permission to access this object
* to an interested client. The argument is an IOStorageAccess value that
* specifies the level of access desired -- reader or reader-writer.
*
* This method can be invoked to upgrade or downgrade the access level for
* an existing client as well. The previous access level will prevail for
* upgrades that fail, of course. A downgrade should never fail. If the
* new access level should be the same as the old for a given client, this
* method will do nothing and return success. In all cases, one, singular
* close-per-client is expected for all opens-per-client received.
*
* This implementation replaces the IOService definition of handleIsOpen().
* @param client
* Client requesting the open.
* @param options
* Options for the open. Set to zero.
* @param access
* Access level for the open. Set to kIOStorageAccessReader or
* kIOStorageAccessReaderWriter.
* @result
* Returns true if the open was successful, false otherwise.
*/
virtual bool handleOpen(IOService * client,
IOOptionBits options,
void * access);
/*!
* @function handleIsOpen
* @discussion
* The handleIsOpen method determines whether the specified client, or any
* client if none is specified, presently has an open on this object.
*
* This implementation replaces the IOService definition of handleIsOpen().
* @param client
* Client to check the open state of. Set to zero to check the open state
* of all clients.
* @result
* Returns true if the client was (or clients were) open, false otherwise.
*/
virtual bool handleIsOpen(const IOService * client) const;
/*!
* @function handleClose
* @discussion
* The handleClose method closes the client's access to this object.
*
* This implementation replaces the IOService definition of handleIsOpen().
* @param client
* Client requesting the close.
* @param options
* Options for the close. Set to zero.
*/
virtual void handleClose(IOService * client, IOOptionBits options);
/*!
* @function addToBytesTransferred
* @discussion
* Update the total number of bytes transferred, the total transfer time,
* and the total latency time -- used for statistics.
*
* This method's implementation is not typically overridden.
* @param bytesTransferred
* Number of bytes transferred in this operation.
* @param totalTime
* Nanoseconds spent performing this operation.
* @param latentTime
* Nanoseconds of latency during this operation.
* @param isWrite
* Indicates whether this operation was a write, otherwise is was a read.
*/
virtual void addToBytesTransferred(UInt64 bytesTransferred,
UInt64 totalTime,
UInt64 latentTime,
bool isWrite);
/*!
* @function incrementErrors
* @discussion
* Update the total error count -- used for statistics.
*
* This method's implementation is not typically overridden.
* @param isWrite
* Indicates whether this operation was a write, otherwise is was a read.
*/
virtual void incrementErrors(bool isWrite);
/*!
* @function incrementRetries
* @discussion
* Update the total retry count -- used for statistics.
*
* This method's implementation is not typically overridden.
* @param isWrite
* Indicates whether this operation was a write, otherwise is was a read.
*/
virtual void incrementRetries(bool isWrite);
/*!
* @function allocateContext
* @discussion
* Allocate a context structure for a read/write operation.
* @result
* Context structure.
*/
virtual Context * allocateContext();
/*!
* @function deleteContext
* @discussion
* Delete a context structure from a read/write operation.
* @param context
* Context structure to be deleted.
*/
virtual void deleteContext(Context * context);
#ifndef __LP64__
virtual void prepareRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*!
* @function deblockRequest
* @discussion
* The deblockRequest method checks to see if the incoming request rests
* on the media's block boundaries, and if not, deblocks it. Deblocking
* involves rounding out the request to the nearest block boundaries and
* transferring the excess bytes into a scratch buffer.
*
* This method is part of a sequence of methods invoked for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
*
* This method's implementation is not typically overridden.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param context
* Additional context information for the data transfer (e.g. block size).
*/
#ifdef __LP64__
virtual void deblockRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion,
Context * context);
#else /* !__LP64__ */
virtual void deblockRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion,
Context * context);
#endif /* !__LP64__ */
/*!
* @function executeRequest
* @discussion
* Execute an asynchronous storage request. The request is guaranteed to be
* block-aligned.
*
* This method is part of a sequence of methods invoked for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param context
* Additional context information for the data transfer (e.g. block size).
*/
#ifdef __LP64__
virtual void executeRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion,
Context * context);
#else /* !__LP64__ */
virtual void executeRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion,
Context * context);
#endif /* !__LP64__ */
/*!
* @function handleStart
* @discussion
* Prepare the block storage driver for operation.
*
* This is where a media object needs to be created for fixed media, and
* optionally for removable media.
*
* Note that this method is called from within the start() routine;
* if this method returns successfully, it should be prepared to accept
* any of IOBlockStorageDriver's APIs.
* @param provider
* This object's provider.
* @result
* Returns true on success, false otherwise.
*/
virtual bool handleStart(IOService * provider);
/*!
* @function handleYield
* @discussion
* Stop the block storage driver.
*
* This method is called as a result of a kIOMessageServiceIsRequestingClose
* provider message. The argument is passed in as-is from the message. The
* options are unused.
*
* This is where the driver should clean up its state in preparation for
* removal from the system.
*
* Note that this method is called from within the yield() routine.
*
* This method is called with the arbitration lock held.
* @param provider
* This object's provider.
*/
virtual bool handleYield(IOService * provider,
IOOptionBits options = 0,
void * argument = 0);
/*!
* @function getMediaBlockSize
* @discussion
* Ask the driver about the media's natural block size.
* @result
* Natural block size, in bytes.
*/
virtual UInt64 getMediaBlockSize() const;
public:
using IOStorage::read;
using IOStorage::write;
/*
* Initialize this object's minimal state.
*
* This method's implementation is not typically overridden.
*/
virtual bool init(OSDictionary * properties = 0);
/*
* This method is called once we have been attached to the provider object.
*
* This method's implementation is not typically overridden.
*/
virtual bool start(IOService * provider);
/*
* This method is called before we are detached from the provider object.
*
* This method's implementation is not typically overridden.
*/
virtual void stop(IOService * provider);
/*
* This method is called as a result of a kIOMessageServiceIsRequestingClose
* provider message. The argument is passed in as-is from the message. The
* options are unused.
*
* This method's implementation is not typically overridden.
*/
virtual bool yield(IOService * provider,
IOOptionBits options = 0,
void * argument = 0);
/*!
* @function read
* @discussion
* The read method is the receiving end for all read requests from the
* storage framework (through the media object created by this driver).
*
* This method initiates a sequence of methods (stages) for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
*
* This method's implementation is not typically overridden.
* @param client
* Client requesting the read.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
virtual void read(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion);
/*!
* @function write
* @discussion
* The write method is the receiving end for all write requests from the
* storage framework (through the media object created by this driver).
*
* This method initiates a sequence of methods (stages) for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
*
* This method's implementation is not typically overridden.
* @param client
* Client requesting the write.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
virtual void write(IOService * client,
UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion);
/*!
* @function synchronizeCache
* @discussion
* Flush the cached data in the storage object, if any, synchronously.
* @param client
* Client requesting the cache synchronization.
* @result
* Returns the status of the cache synchronization.
*/
virtual IOReturn synchronizeCache(IOService * client);
/*!
* @function discard
* @discussion
* Delete unused data from the storage object at the specified byte offset,
* synchronously.
* @param client
* Client requesting the operation.
* @param byteStart
* Starting byte offset for the operation.
* @param byteCount
* Size of the operation.
* @result
* Returns the status of the operation.
*/
virtual IOReturn discard(IOService * client,
UInt64 byteStart,
UInt64 byteCount);
/*!
* @function ejectMedia
* @discussion
* Eject the media from the device. The driver is responsible for tearing
* down the media object it created before proceeding with the eject. If
* the tear-down fails, an error should be returned.
* @result
* An IOReturn code.
*/
virtual IOReturn ejectMedia();
/*!
* @function formatMedia
* @discussion
* Format the media with the specified byte capacity. The driver is
* responsible for tearing down the media object and recreating it.
* @param byteCapacity
* Number of bytes to format media to.
* @result
* An IOReturn code.
*/
virtual IOReturn formatMedia(UInt64 byteCapacity);
/*!
* @function lockMedia
* @discussion
* Lock or unlock the ejectable media in the device, that is, prevent
* it from manual ejection or allow its manual ejection.
* @param lock
* Pass true to lock the media, otherwise pass false to unlock the media.
* @result
* An IOReturn code.
*/
virtual IOReturn lockMedia(bool lock);
/*!
* @function pollMedia
* @discussion
* Poll for the presence of media in the device. The driver is responsible
* for tearing down the media object it created should the media have been
* removed since the last poll, and vice-versa, creating the media object
* should new media have arrived since the last poll.
* @result
* An IOReturn code.
*/
virtual IOReturn pollMedia();
/*!
* @function isMediaEjectable
* @discussion
* Ask the driver whether the media is ejectable.
* @result
* Returns true if the media is ejectable, false otherwise.
*/
virtual bool isMediaEjectable() const;
#ifdef __LP64__
/*!
* @function isMediaRemovable
* @discussion
* Ask the driver whether the media is ejectable.
* @result
* Returns true if the media is ejectable, false otherwise.
*/
virtual bool isMediaRemovable() const;
#endif /* __LP64__ */
/*!
* @function isMediaPollExpensive
* @discussion
* Ask the driver whether a pollMedia() would be an expensive operation,
* that is, one that requires the device to spin up or delay for a while.
* @result
* Returns true if polling the media is expensive, false otherwise.
*/
virtual bool isMediaPollExpensive() const;
/*!
* @function isMediaPollRequired
* @discussion
* Ask the driver whether the block storage device requires polling, which is
* typically required for devices without the ability to asynchronously detect
* the arrival or departure of the media.
* @result
* Returns true if polling the media is required, false otherwise.
*/
virtual bool isMediaPollRequired() const;
virtual bool isMediaWritable() const;
/*!
* @function getMediaState
* @discussion
* Ask the driver about the media's current state.
* @result
* An IOMediaState value.
*/
virtual IOMediaState getMediaState() const;
/*!
* @function getFormatCapacities
* @discussion
* Ask the driver to report the feasible formatting capacities for the
* inserted media (in bytes). This routine fills the caller's buffer,
* up to the maximum count specified if the real number of capacities
* would overflow the buffer. The return value indicates the actual
* number of capacities copied to the buffer.
*
* If the capacities buffer is not supplied or if the maximum count is
* zero, the routine returns the proposed count of capacities instead.
* @param capacities
* Buffer that will receive the UInt64 capacity values.
* @param capacitiesMaxCount
* Maximum number of capacity values that can be held in the buffer.
* @result
* Actual number of capacity values copied to the buffer, or if no buffer
* is given, the total number of capacity values available.
*/
virtual UInt32 getFormatCapacities(UInt64 * capacities,
UInt32 capacitiesMaxCount) const;
/*!
* @function getStatistics
* @discussion
* Ask the driver to report its operating statistics.
*
* The statistics are each indexed by IOBlockStorageDriver::Statistics
* indices. This routine fills the caller's buffer, up to the maximum
* count specified if the real number of statistics would overflow the
* buffer. The return value indicates the actual number of statistics
* copied to the buffer.
*
* If the statistics buffer is not supplied or if the maximum count is
* zero, the routine returns the proposed count of statistics instead.
* @param statistics
* Buffer that will receive the UInt64 statistic values.
* @param statisticsMaxCount
* Maximum number of statistic values that can be held in the buffer.
* @result
* Actual number of statistic values copied to the buffer, or if no buffer
* is given, the total number of statistic values available.
*/
virtual UInt32 getStatistics(UInt64 * statistics,
UInt32 statisticsMaxCount) const;
/*!
* @function getStatistic
* @discussion
* Ask the driver to report one of its operating statistics.
* @param statistic
* Statistic index (an IOBlockStorageDriver::Statistics index).
* @result
* Statistic value.
*/
virtual UInt64 getStatistic(Statistics statistic) const;
/*
* Generic entry point for calls from the provider. A return value of
* kIOReturnSuccess indicates that the message was received, and where
* applicable, that it was successful.
*/
virtual IOReturn message(UInt32 type, IOService * provider, void * argument);
/*
* Obtain this object's provider. We override the superclass's method to
* return a more specific subclass of IOService -- IOBlockStorageDevice.
* This method serves simply as a convenience to subclass developers.
*/
virtual IOBlockStorageDevice * getProvider() const;
protected:
IOLock * _deblockRequestWriteLock;
thread_call_t _pollerCall;
/*
* This is the completion routine for the broken up breaker sub-requests.
* It verifies the success of the just-completed stage, transitions to
* the next stage, then builds and issues a transfer for the next stage.
*/
static void breakUpRequestCompletion(void * target,
void * parameter,
IOReturn status,
UInt64 actualByteCount);
/*
* This is the completion routine for the aligned deblocker sub-requests.
* It verifies the success of the just-completed stage, transitions to
* the next stage, then builds and issues a transfer for the next stage.
*/
static void deblockRequestCompletion(void * target,
void * parameter,
IOReturn status,
UInt64 actualByteCount);
/*
* This is the completion routine for the prepared request. It updates
* the driver's statistics, performs some clean up work, then calls the
* original request's completion routine.
*/
static void prepareRequestCompletion(void * target,
void * parameter,
IOReturn status,
UInt64 actualByteCount);
/*
* Schedule the poller mechanism.
*/
virtual void schedulePoller();
/*
* Unschedule the poller mechanism.
*/
virtual void unschedulePoller();
/*
* This method is the timeout handler for the poller mechanism. It polls
* for media and reschedules another timeout if there are still no opens.
*/
static void poller(void *, void *);
/*
* This method is the power event handler for restarts and shutdowns.
*/
static IOReturn handlePowerEvent(void * target,
void * parameter,
UInt32 messageType,
IOService * provider,
void * messageArgument,
vm_size_t messageArgumentSize);
protected:
/* Device info: */
/*!
* @var _removable
* True if the media is removable; False if it is fixed (not removable).
*/
bool_removable;
/*!
* @var _ejectable
* True if the media is ejectable under software control.
*/
bool_ejectable;/* software-ejectable */
/*!
* @var _lockable
* True if the media can be locked in the device under software control.
*/
bool_lockable;/* software lockable in device */
/*!
* @var _pollIsRequired
* True if we must poll to detect media insertion or removal.
*/
bool_pollIsRequired;
/*!
* @var _pollIsExpensive
* True if polling is expensive; False if not.
*/
bool_pollIsExpensive;
/* Media info and states: */
/*!
* @var _mediaObject
* A pointer to the media object we have instantiated (if any).
*/
IOMedia *_mediaObject;
/*!
* @var _mediaType
* Type of the media (can be used to differentiate between the
* different types of CD media, DVD media, etc).
*/
UInt32_mediaType;
/*!
* @var _mediaPresent
* True if media is present in the device; False if not.
*/
bool_mediaPresent;/* media is present and ready */
/*!
* @var _writeProtected
* True if the media is write-protected; False if not.
*/
bool_writeProtected;
private:
/*!
* @var _mediaStateLock
* A lock used to protect during media checks.
*/
IOLock *_mediaStateLock;
protected:
/*!
* @var _mediaBlockSize
* The block size of the media, in bytes.
*/
UInt64_mediaBlockSize;
/*!
* @var _maxBlockNumber
* The maximum allowable block number for the media, zero-based.
*/
UInt64_maxBlockNumber;
/*!
* @var _maxReadByteTransfer
* The maximum byte transfer allowed for read operations.
*/
UInt64_maxReadByteTransfer;
/*!
* @var _maxWriteByteTransfer
* The maximum byte transfer allowed for write operations.
*/
UInt64_maxWriteByteTransfer;
/*!
* @function acceptNewMedia
* @abstract
* React to new media insertion.
* @discussion
* This method logs the media block size and block count, then calls
* instantiateMediaObject to get a media object instantiated. The
* media object is then attached above us and registered.
*
* This method can be overridden to control what happens when new media
* is inserted. The default implementation deals with one IOMedia object.
*/
virtual IOReturnacceptNewMedia(void);
/*!
* @function constrainByteCount
* @abstract
* Constrain the byte count for this IO to device limits.
* @discussion
* This function should be called prior to each read or write operation, so that
* the driver can constrain the requested byte count, as necessary, to meet
* current device limits. Such limits could be imposed by the device depending
* on operating modes, media types, or transport protocol (e.g. ATA, SCSI).
*
* At present, this method is not used.
* @param requestedCount
* The requested byte count for the next read or write operation.
* @param isWrite
* True if the operation will be a write; False if the operation will be a read.
*/
virtual UInt64constrainByteCount(UInt64 requestedCount,bool isWrite);
/*!
* @function decommissionMedia
* @abstract
* Decommission an existing piece of media that has gone away.
* @discussion
* This method wraps a call to terminate, to tear down the stack and
* the IOMedia object for the media. If "forcible" is true, the media
* object will be forgotten, and initMediaState will be called. A
* forcible decommission would occur when an unrecoverable error
* happens during tear-down (e.g. perhaps a client is still open), but
* we must still forget about the media.
* @param forcible
* True to force forgetting of the media object even if terminate reports
* that there was an active client.
*/
virtual IOReturndecommissionMedia(bool forcible);
/*!
* @function instantiateDesiredMediaObject
* @abstract
* Create an IOMedia object for media.
* @discussion
* This method creates the exact type of IOMedia object desired. It is called by
* instantiateMediaObject. A subclass may override this one-line method to change
* the type of media object actually instantiated.
*/
virtual IOMedia *instantiateDesiredMediaObject(void);
/*!
* @function instantiateMediaObject
* @abstract
* Create an IOMedia object for media.
* @discussion
* This method creates an IOMedia object from the supplied parameters. It is a
* convenience method to wrap the handful of steps to do the job.
* @param base
* Byte number of beginning of active data area of the media. Usually zero.
* @param byteSize
* Size of the data area of the media, in bytes.
* @param blockSize
* Block size of the media, in bytes.
* @param mediaName
* Name of the IOMedia object.
* @result
* A pointer to the created IOMedia object, or a null on error.
*/
virtual IOMedia *instantiateMediaObject(UInt64 base,UInt64 byteSize,
UInt32 blockSize,char *mediaName);
/*!
* @function recordMediaParameters
* @abstract
* Obtain media-related parameters on media insertion.
* @discussion
* This method obtains media-related parameters via calls to the
* Transport Driver's reportBlockSize, reportMaxValidBlock,
* and reportWriteProtection methods.
*/
virtual IOReturnrecordMediaParameters(void);
/*!
* @function rejectMedia
* @abstract
* Reject new media.
* @discussion
* This method will be called if validateNewMedia returns False (thus rejecting
* the new media. A vendor may choose to override this method to control behavior
* when media is rejected.
*
* The default implementation simply calls ejectMedia.
*/
virtual voidrejectMedia(void);/* default ejects */
/*!
* @function validateNewMedia
* @abstract
* Verify that new media is acceptable.
* @discussion
* This method will be called whenever new media is detected. Return true to accept
* the media, or false to reject it (and call rejectMedia). Vendors might override
* this method to handle password-protection for new media.
*
* The default implementation always returns True, indicating media is accepted.
*/
virtual boolvalidateNewMedia(void);
/* --- Internally used methods. --- */
/*
* @group
* Internally Used Methods
* @discussion
* These methods are used internally, and will not generally be modified.
*/
/*!
* @function checkForMedia
* @abstract
* Check if media has newly arrived or disappeared.
* @discussion
* This method does most of the work in polling for media, first
* calling the block storage device's reportMediaState method. If
* reportMediaState reports no change in the media state, kIOReturnSuccess
* is returned. If the media state has indeed changed, a call is made to
* mediaStateHasChanged to act on the event.
*/
virtual IOReturncheckForMedia(void);
/*!
* @function getDeviceTypeName
* @abstract
* Return the desired device name.
* @discussion
* This method returns a string, used to compare the
* kIOBlockStorageDeviceTypeKey of our provider. This method is called from
* probe.
*
* The default implementation of this method returns
* kIOBlockStorageDeviceTypeGeneric.
*/
virtual const char * getDeviceTypeName(void);
/*!
* @function initMediaState
* @abstract
* Initialize media-related instance variables.
* @discussion
* Called when media is not present, this method marks the device state
* as not having media present, not spun up, and write-enabled.
*/
virtual voidinitMediaState(void);
/*!
* @function mediaStateHasChanged
* @abstract
* React to a new media insertion or a media removal.
* @discussion
* This method is called on a media state change, that is, an arrival
* or removal. If media has just become available, calls are made to
* recordMediaParameters and acceptNewMedia. If media has just gone
* away, a call is made to decommissionMedia, with the forcible
* parameter set to true. The forcible tear-down is needed to enforce
* the disappearance of media, regardless of interested clients.
*/
virtual IOReturnmediaStateHasChanged(IOMediaState state);
/*
* @endgroup
*/
protected:
/*!
* @function breakUpRequest
* @discussion
* The breakUpRequest method checks to see if the incoming request exceeds
* our transfer constraints, and if so, breaks up the request into smaller
* sub-requests.
*
* This method is part of a sequence of methods invoked for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
*
* This method's implementation is not typically overridden.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param context
* Additional context information for the data transfer (e.g. block size).
*/
#ifdef __LP64__
virtual void breakUpRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion,
Context * context);
#else /* !__LP64__ */
virtual void breakUpRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageCompletion completion,
Context * context); /* 10.1.2 */
#endif /* !__LP64__ */
/*!
* @function prepareRequest
* @discussion
* The prepareRequest method allocates and prepares state for the transfer.
*
* This method is part of a sequence of methods invoked for each read/write
* request. The first is prepareRequest, which allocates and prepares some
* context for the transfer; the second is deblockRequest, which aligns the
* transfer at the media's block boundaries; third is breakUpRequest, which
* breaks up the transfer into multiple sub-transfers when certain hardware
* constraints are exceeded; fourth is executeRequest, which implements the
* actual transfer from the block storage device.
*
* This method's implementation is not typically overridden.
* @param byteStart
* Starting byte offset for the data transfer.
* @param buffer
* Buffer for the data transfer. The size of the buffer implies the size of
* the data transfer.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
* @param completion
* Completion routine to call once the data transfer is complete. It is the
* responsibility of the callee to maintain the information for the duration
* of the data transfer, as necessary.
*/
virtual void prepareRequest(UInt64 byteStart,
IOMemoryDescriptor * buffer,
IOStorageAttributes * attributes,
IOStorageCompletion * completion); /* 10.5.0 */
public:
/*!
* @function requestIdle
* @abstract
* Request that the device enter an idle state.
* @discussion
* Request that the device enter an idle state. The device will exit this state on the
* next read or write request, or as it sees necessary. One example is for a DVD drive
* to spin down when it enters such an idle state, and spin up on the next read request
* from the system.
*/
virtual IOReturnrequestIdle(void); /* 10.6.0 */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 0);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 1);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 2);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 0);
OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 1);
OSMetaClassDeclareReservedUsed(IOBlockStorageDriver, 2);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 3);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 4);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 5);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 6);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 7);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 8);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 9);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 10);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 11);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 12);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 13);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 14);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 15);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 16);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 17);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 18);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 19);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 20);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 21);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 22);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 23);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 24);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 25);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 26);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 27);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 28);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 29);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 30);
OSMetaClassDeclareReservedUnused(IOBlockStorageDriver, 31);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOBLOCKSTORAGEDRIVER_H */
branches/azimutz/Chazi/i386/include/IOKit/storage/IOBlockStorageDevice.h
6161
6262
6363
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
8764
8865
8966
......
9774
9875
9976
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
12377
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
50278
50379
50480
#include <IOKit/IOService.h>
#include <IOKit/storage/IOMedia.h>
/*!
* @defined kIOMessageMediaParametersHaveChanged
* @abstract
* The message ID which indicates that the media parameters, such as the highest valid block
* for the device, have changed.
* @discussion
* The message is passed to all clients of the IOBlockStorageDevice via the message() method.
*/
#define kIOMessageMediaParametersHaveChanged iokit_family_msg(sub_iokit_block_storage, 2)
/*!
* @defined kIOMessageMediaStateHasChanged
* @abstract
* The message ID which indicates that the media state has changed.
* @discussion
* The message is passed to all clients of the IOBlockStorageDevice via the message() method.
* The argument that is passed along with this message is an IOMediaState value.
*
* Devices that aren't capable of detecting media state changes indicate this in
* the reportPollRequirements() method.
*/
#define kIOMessageMediaStateHasChanged iokit_family_msg(sub_iokit_block_storage, 1)
/* Property used for matching, so the generic driver gets the nub it wants. */
/*!
* @defined kIOBlockStorageDeviceTypeKey
*/
#definekIOBlockStorageDeviceTypeGeneric"Generic"
/*!
* @class
* IOBlockStorageDevice
* @abstract
* A generic block storage device abstraction.
* @discussion
* The IOBlockStorageDevice class exports the generic block storage protocol,
* independent of the physical connection protocol (e.g. SCSI, ATA, USB),
* forwarding all requests to its provider (the Transport Driver).
* Though the nub does no actual processing of requests, it is necessary
* in a C++ environment. The Transport Driver can be of any type, as
* long as it inherits from IOService. Because Transport Drivers needn't
* derive from a type known to IOBlockStorageDriver, it isn't possible for
* IOBlockStorageDriver to include the appropriate header file to allow direct
* communication with the Transport Driver. Thus we achieve polymorphism by
* having the Transport Driver instantiate a subclass of IOBlockStorageDevice.
* A typical implementation for a concrete subclass of IOBlockStorageDevice
* simply relays all methods to its provider (the Transport Driver), which
* implements the protocol- and device-specific behavior.
*
* All pure-virtual functions must be implemented by the Transport Driver, which
* is responsible for instantiating the Nub.
*/
class IOBlockStorageDevice : public IOService {
OSDeclareAbstractStructors(IOBlockStorageDevice)
protected:
struct ExpansionData { /* */ };
ExpansionData * _expansionData;
public:
/* Overrides from IORegistryEntry */
using IORegistryEntry::getProperty;
/*!
* @function init
* @discussion
* This function is overridden so that IOBlockStorageDevice can set a
* property, used by IOBlockStorageDriver for matching. Since the concrete
* subclass of IOBlockStorageDevice can be of any class type, the property
* is used for matching.
*
* This function is usually not overridden by developers.
*/
virtual boolinit(OSDictionary * properties);
virtual OSObject *getProperty(const OSSymbol * key) const;
virtual IOReturnsetProperties(OSObject * properties);
/* --- A subclass must implement the the following methods: --- */
#ifndef __LP64__
virtual IOReturndoAsyncReadWrite(IOMemoryDescriptor *buffer,
UInt32 block, UInt32 nblks,
IOStorageCompletion completion) __attribute__ ((deprecated));
virtual IOReturndoSyncReadWrite(IOMemoryDescriptor *buffer,
UInt32 block,UInt32 nblks) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*!
* @function doEjectMedia
* @abstract
* Eject the media.
*/
virtual IOReturndoEjectMedia(void)= 0;
/*!
* @function doFormatMedia
* @abstract
* Format the media to the specified byte capacity.
* @discussion
* The specified byte capacity must be one supported by the device.
* Supported capacities can be obtained by calling doGetFormatCapacities.
* @param byteCapacity
* The byte capacity to which the device is to be formatted, if possible.
*/
virtual IOReturndoFormatMedia(UInt64 byteCapacity)= 0;
/*!
* @function doGetFormatCapacities
* @abstract
* Return the allowable formatting byte capacities.
* @discussion
* This function returns the supported byte capacities for the device.
* @param capacities
* Pointer for returning the list of capacities.
* @param capacitiesMaxCount
* The number of capacity values returned in "capacities," or if no buffer
* is given, the total number of capacity values available.
*/
virtual UInt32doGetFormatCapacities(UInt64 * capacities,
UInt32 capacitiesMaxCount) const= 0;
/*!
* @function doLockUnlockMedia
* @abstract
* Lock or unlock the (removable) media in the drive.
* @discussion
* This method should only be called if the media is known to be removable.
* @param doLock
* True to lock the media, False to unlock.
*/
virtual IOReturndoLockUnlockMedia(bool doLock)= 0;
/*!
* @function doSynchronizeCache
* @abstract
* Force data blocks in the hardware's buffer to be flushed to the media.
* @discussion
* This method should only be called if the media is writable.
*/
virtual IOReturndoSynchronizeCache(void)= 0;
/*!
* @function getVendorString
* @abstract
* Return Vendor Name string for the device.
* @result
* A pointer to a static character string.
*/
virtual char *getVendorString(void)= 0;
/*!
* @function getProductString
* @abstract
* Return Product Name string for the device.
* @result
* A pointer to a static character string.
*/
virtual char *getProductString(void)= 0;
/*!
* @function getRevisionString
* @abstract
* Return Product Revision string for the device.
* @result
* A pointer to a static character string.
*/
virtual char *getRevisionString(void)= 0;
/*!
* @function getAdditionalDeviceInfoString
* @abstract
* Return additional informational string for the device.
* @result
* A pointer to a static character string.
*/
virtual char *getAdditionalDeviceInfoString(void)= 0;
/*!
* @function reportBlockSize
* @abstract
* Report the block size for the device, in bytes.
* @param blockSize
* Pointer to returned block size value.
*/
virtual IOReturnreportBlockSize(UInt64 *blockSize)= 0;
/*!
* @function reportEjectability
* @abstract
* Report if the media is ejectable under software control.
* @discussion
* This method should only be called if the media is known to be removable.
* @param isEjectable
* Pointer to returned result. True indicates the media is ejectable, False indicates
* the media cannot be ejected under software control.
*/
virtual IOReturnreportEjectability(bool *isEjectable)= 0;
/*!
* @function reportLockability
* @abstract
* Report if the media is lockable under software control.
* @discussion
* This method should only be called if the media is known to be removable.
* @param isLockable
* Pointer to returned result. True indicates the media can be locked in place; False
* indicates the media cannot be locked by software.
*/
virtual IOReturnreportLockability(bool *isLockable)= 0;
#ifndef __LP64__
virtual IOReturnreportMaxReadTransfer(UInt64 blockSize,UInt64 *max) __attribute__ ((deprecated));
virtual IOReturnreportMaxWriteTransfer(UInt64 blockSize,UInt64 *max) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*!
* @function reportMaxValidBlock
* @abstract
* Report the highest valid block for the device.
* @param maxBlock
* Pointer to returned result
*/
virtual IOReturnreportMaxValidBlock(UInt64 *maxBlock)= 0;
/*!
* @function reportMediaState
* @abstract
* Report the device's media state.
* @discussion
* This method reports whether we have media in the drive or not, and
* whether the state has changed from the previously reported state.
*
* A result of kIOReturnSuccess is always returned if the test for media is successful,
* regardless of media presence. The mediaPresent result should be used to determine
* whether media is present or not. A return other than kIOReturnSuccess indicates that
* the Transport Driver was unable to interrogate the device. In this error case, the
* outputs mediaState and changedState will *not* be stored.
* @param mediaPresent Pointer to returned media state. True indicates media is present
* in the device; False indicates no media is present.
* @param changedState Pointer to returned result. True indicates a change of state since
* prior calls, False indicates that the state has not changed.
*/
virtual IOReturnreportMediaState(bool *mediaPresent,bool *changedState)= 0;
/*!
* @function reportPollRequirements
* @abstract
* Report if it's necessary to poll for media insertion, and if polling is expensive.
* @discussion
* This method reports whether the device must be polled to detect media
* insertion, and whether a poll is expensive to perform.
*
* The term "expensive" typically implies a device that must be spun-up to detect media,
* as on a PC floppy. Most devices can detect media inexpensively.
* @param pollRequired
* Pointer to returned result. True indicates that polling is required; False indicates
* that polling is not required to detect media.
* @param pollIsExpensive
* Pointer to returned result. True indicates that the polling operation is expensive;
* False indicates that the polling operation is cheap.
*/
virtual IOReturnreportPollRequirements(bool *pollRequired,
bool *pollIsExpensive)= 0;
/*!
* @function reportRemovability
* @abstract
* Report whether the media is removable or not.
* @discussion
* This method reports whether the media is removable, but it does not
* provide detailed information regarding software eject or lock/unlock capability.
* @param isRemovable
* Pointer to returned result. True indicates that the media is removable; False
* indicates the media is not removable.
*/
virtual IOReturnreportRemovability(bool *isRemovable) = 0;
/*!
* @function reportWriteProtection
* @abstract
* Report whether the media is write-protected or not.
* @param isWriteProtected
* Pointer to returned result. True indicates that the media is write-protected (it
* cannot be written); False indicates that the media is not write-protected (it
* is permissible to write).
*/
virtual IOReturnreportWriteProtection(bool *isWriteProtected)= 0;
#ifndef __LP64__
virtual IOReturndoAsyncReadWrite(IOMemoryDescriptor *buffer,
UInt64 block, UInt64 nblks,
IOStorageCompletion completion) __attribute__ ((deprecated));
#endif /* !__LP64__ */
/*!
* @function getWriteCacheState
* @abstract
* Reports the current write cache state of the device.
* @discussion
* Reports the current write cache state of the device. The write cache
* state is not guaranteed to persist across reboots and detaches.
* @param enabled
* Pointer to returned result. True indicates the write cache is enabled;
* False indicates the write cache is disabled.
*/
#ifdef __LP64__
virtual IOReturngetWriteCacheState(bool *enabled)= 0;
#else /* !__LP64__ */
virtual IOReturngetWriteCacheState(bool *enabled); /* 10.3.0 */
#endif /* !__LP64__ */
/*!
* @function setWriteCacheState
* @abstract
* Sets the write cache state of the device.
* @discussion
* Sets the write cache state of the device. The write cache state
* is not guaranteed to persist across reboots and detaches.
* @param enabled
* True to enable the write cache; False to disable the write cache.
*/
#ifdef __LP64__
virtual IOReturnsetWriteCacheState(bool enabled)= 0;
#else /* !__LP64__ */
virtual IOReturnsetWriteCacheState(bool enabled); /* 10.3.0 */
#endif /* !__LP64__ */
/*!
* @function doAsyncReadWrite
* @abstract
* Start an asynchronous read or write operation.
* @param buffer
* An IOMemoryDescriptor describing the data-transfer buffer. The data direction
* is contained in the IOMemoryDescriptor. Responsibility for releasing the descriptor
* rests with the caller.
* @param block
* The starting block number of the data transfer.
* @param nblks
* The integral number of blocks to be transferred.
* @param attributes
* Attributes of the data transfer. See IOStorageAttributes.
* @param completion
* The completion routine to call once the data transfer is complete.
*/
#ifdef __LP64__
virtual IOReturndoAsyncReadWrite(IOMemoryDescriptor *buffer,
UInt64 block, UInt64 nblks,
IOStorageAttributes *attributes,
IOStorageCompletion *completion)= 0;
#else /* !__LP64__ */
virtual IOReturndoAsyncReadWrite(IOMemoryDescriptor *buffer,
UInt64 block, UInt64 nblks,
IOStorageAttributes *attributes,
IOStorageCompletion *completion); /* 10.5.0 */
#endif /* !__LP64__ */
/*!
* @function requestIdle
* @abstract
* Request that the device enter an idle state.
* @discussion
* Request that the device enter an idle state. The device will exit this state on the
* next read or write request, or as it sees necessary. One example is for a DVD drive
* to spin down when it enters such an idle state, and spin up on the next read request
* from the system.
*/
virtual IOReturnrequestIdle(void); /* 10.6.0 */
/*!
* @function doDiscard
* @abstract
* Delete unused data blocks from the media.
* @param block
* The starting block number of the operation.
* @param nblks
* The integral number of blocks to be deleted.
*/
virtual IOReturn doDiscard(UInt64 block, UInt64 nblks); /* 10.6.0 */
#ifdef __LP64__
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 0);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 1);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 2);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 3);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 4);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 5);
#else /* !__LP64__ */
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 0);
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 1);
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 2);
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 3);
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 4);
OSMetaClassDeclareReservedUsed(IOBlockStorageDevice, 5);
#endif /* !__LP64__ */
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 6);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 7);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 8);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 9);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 10);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 11);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 12);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 13);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 14);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 15);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 16);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 17);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 18);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 19);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 20);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 21);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 22);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 23);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 24);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 25);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 26);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 27);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 28);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 29);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 30);
OSMetaClassDeclareReservedUnused(IOBlockStorageDevice, 31);
};
#endif /* __cplusplus */
#endif /* KERNEL */
#endif /* !_IOBLOCKSTORAGEDEVICE_H */
branches/azimutz/Chazi/i386/include/architecture/byte_order.h
3030
3131
3232
33
34
35
36
37
3833
3934
40
41
4235
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
38136
#ifndef_ARCHITECTURE_BYTE_ORDER_H_
#define _ARCHITECTURE_BYTE_ORDER_H_
/*
* Please note that the byte ordering functions in this file are deprecated.
* A replacement API exists in libkern/OSByteOrder.h
*/
#include <libkern/OSByteOrder.h>
typedef unsigned long NXSwappedFloat;
typedef unsigned long long NXSwappedDouble;
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapShort(
unsigned short inv
)
{
return (unsigned short)OSSwapInt16((uint16_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapInt(
unsigned int inv
)
{
return (unsigned int)OSSwapInt32((uint32_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapLong(
unsigned long inv
)
{
return (unsigned long)OSSwapInt32((uint32_t)inv);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapLongLong(
unsigned long long inv
)
{
return (unsigned long long)OSSwapInt64((uint64_t)inv);
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXConvertHostFloatToSwapped(float x)
{
union fconv {
float number;
NXSwappedFloat sf;
} u;
u.number = x;
return u.sf;
}
static __inline__ __attribute__((deprecated))
float
NXConvertSwappedFloatToHost(NXSwappedFloat x)
{
union fconv {
float number;
NXSwappedFloat sf;
} u;
u.sf = x;
return u.number;
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXConvertHostDoubleToSwapped(double x)
{
union dconv {
double number;
NXSwappedDouble sd;
} u;
u.number = x;
return u.sd;
}
static __inline__ __attribute__((deprecated))
double
NXConvertSwappedDoubleToHost(NXSwappedDouble x)
{
union dconv {
double number;
NXSwappedDouble sd;
} u;
u.sd = x;
return u.number;
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapFloat(NXSwappedFloat x)
{
return (NXSwappedFloat)OSSwapInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapDouble(NXSwappedDouble x)
{
return (NXSwappedDouble)OSSwapInt64((uint64_t)x);
}
/*
* Identify the byte order
* of the current host.
*/
enum NXByteOrder {
NX_UnknownByteOrder,
NX_LittleEndian,
NX_BigEndian
};
static __inline__
enum NXByteOrder
NXHostByteOrder(void)
{
#if defined(__LITTLE_ENDIAN__)
return NX_LittleEndian;
#elif defined(__BIG_ENDIAN__)
return NX_BigEndian;
#else
return NX_UnknownByteOrder;
#endif
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapBigShortToHost(
unsigned shortx
)
{
return (unsigned short)OSSwapBigToHostInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapBigIntToHost(
unsigned intx
)
{
return (unsigned int)OSSwapBigToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapBigLongToHost(
unsigned longx
)
{
return (unsigned long)OSSwapBigToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapBigLongLongToHost(
unsigned long longx
)
{
return (unsigned long long)OSSwapBigToHostInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
double
NXSwapBigDoubleToHost(
NXSwappedDoublex
)
{
return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapBigToHostInt64((uint64_t)x));
}
static __inline__ __attribute__((deprecated))
float
NXSwapBigFloatToHost(
NXSwappedFloatx
)
{
return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapBigToHostInt32((uint32_t)x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapHostShortToBig(
unsigned shortx
)
{
return (unsigned short)OSSwapHostToBigInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapHostIntToBig(
unsigned intx
)
{
return (unsigned int)OSSwapHostToBigInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapHostLongToBig(
unsigned longx
)
{
return (unsigned long)OSSwapHostToBigInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapHostLongLongToBig(
unsigned long longx
)
{
return (unsigned long long)OSSwapHostToBigInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapHostDoubleToBig(
doublex
)
{
return (NXSwappedDouble)OSSwapHostToBigInt64((uint64_t)NXConvertHostDoubleToSwapped(x));
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapHostFloatToBig(
floatx
)
{
return (NXSwappedFloat)OSSwapHostToBigInt32((uint32_t)NXConvertHostFloatToSwapped(x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapLittleShortToHost(
unsigned shortx
)
{
return (unsigned short)OSSwapLittleToHostInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapLittleIntToHost(
unsigned intx
)
{
return (unsigned int)OSSwapLittleToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapLittleLongToHost(
unsigned longx
)
{
return (unsigned long)OSSwapLittleToHostInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapLittleLongLongToHost(
unsigned long longx
)
{
return (unsigned long long)OSSwapLittleToHostInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
double
NXSwapLittleDoubleToHost(
NXSwappedDoublex
)
{
return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapLittleToHostInt64((uint64_t)x));
}
static __inline__ __attribute__((deprecated))
float
NXSwapLittleFloatToHost(
NXSwappedFloatx
)
{
return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapLittleToHostInt32((uint32_t)x));
}
static __inline__ __attribute__((deprecated))
unsigned short
NXSwapHostShortToLittle(
unsigned shortx
)
{
return (unsigned short)OSSwapHostToLittleInt16((uint16_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned int
NXSwapHostIntToLittle(
unsigned intx
)
{
return (unsigned int)OSSwapHostToLittleInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long
NXSwapHostLongToLittle(
unsigned longx
)
{
return (unsigned long)OSSwapHostToLittleInt32((uint32_t)x);
}
static __inline__ __attribute__((deprecated))
unsigned long long
NXSwapHostLongLongToLittle(
unsigned long longx
)
{
return (unsigned long long)OSSwapHostToLittleInt64((uint64_t)x);
}
static __inline__ __attribute__((deprecated))
NXSwappedDouble
NXSwapHostDoubleToLittle(
doublex
)
{
return (NXSwappedDouble)OSSwapHostToLittleInt64((uint64_t)NXConvertHostDoubleToSwapped(x));
}
static __inline__ __attribute__((deprecated))
NXSwappedFloat
NXSwapHostFloatToLittle(
floatx
)
{
return (NXSwappedFloat)OSSwapHostToLittleInt32((uint32_t)NXConvertHostFloatToSwapped(x));
}
#endif/* _ARCHITECTURE_BYTE_ORDER_H_ */
branches/azimutz/Chazi/i386/config/Makefile
1515
1616
1717
18
19
20
1821
19
20
21
2222
2323
2424
25
2625
2726
28
29
3027
3128
3229
3330
3431
3532
36
37
38
3933
4034
4135
......
4741
4842
4943
50
44
5145
5246
5347
DIR = util
include ${SRCROOT}/Make.rules
OBJECTS = cconfig.o32 cconfig.o64 zconf.tab.o32 zconf.tab.o64 \
yesno.o32 yesno.o64 textbox.o32 textbox.o64 menubox.o32 \
menubox.o64 checklist.o32 checklist.o64 inputbox.o32 inputbox.o64
OBJECTS = cconfig.o32 cconfig.o64 zconf.tab.o32 zconf.tab.o64 yesno.o32 yesno.o64 textbox.o32 textbox.o64 menubox.o32 menubox.o64 checklist.o32 checklist.o64 inputbox.o32 inputbox.o64
DEFINES = -DKBUILD_NO_NLS -DCURSES_LOC=\<ncurses.h\> -DPATH_MAX=256 -DPACKAGE=\"chameleon\"
LDFLAGS = -lncurses -lmenu
PROGRAMS = cconfig
SYMPROG = $(addprefix $(SYMROOT)/, $(PROGRAMS))
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
all: $(DIRS_NEEDED) $(SYMPROG)
$(SYMPROG): $(addprefix $(OBJROOT)/, $(OBJECTS))
@echo "\t[LD32] $(@F)_32"
@$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -arch i386 -o $(SYMROOT)/$(@F)_32 $(OBJROOT)/*.o32
config: $(DIRS_NEEDED) $(SYMPROG)
@cd ${SRCROOT} && $(SYMPROG) $(SRCROOT)/Cconfig
rebuild_config: $(DIRS_NEEDED) $(SYMPROG)
@cd ${SRCROOT} && $(SYMPROG) $(SRCROOT)/Cconfig rebuild

Archive Download the corresponding diff file

Revision: 1049