Index: trunk/i386/include/IOKit/IOLib.h =================================================================== --- trunk/i386/include/IOKit/IOLib.h (revision 915) +++ trunk/i386/include/IOKit/IOLib.h (revision 916) @@ -67,301 +67,8 @@ 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,
- kIOMapDefaultCache to inhibit the cache in I/O areas, kIOMapCopybackCache in general purpose RAM.
- kIOMapInhibitCache, kIOMapWriteThruCache, kIOMapCopybackCache to set the appropriate caching.
- @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(). */ @@ -371,28 +78,6 @@ #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 */ Index: trunk/i386/include/IOKit/storage/IOCDBlockStorageDriver.h =================================================================== --- trunk/i386/include/IOKit/storage/IOCDBlockStorageDriver.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOCDBlockStorageDriver.h (revision 916) @@ -48,212 +48,4 @@ #define kIOCDBlockStorageDriverClass "IOCDBlockStorageDriver" -class IOCDBlockStorageDriver : public IOBlockStorageDriver { - - OSDeclareDefaultStructors(IOCDBlockStorageDriver) - -public: - - static const UInt64 kBlockSizeCD = 2352; - static const UInt8 kBlockTypeCD = 0x01; - - /* Overrides of IORegistryEntry */ - - virtual bool init(OSDictionary * properties); - virtual void free(void); - - /* Overrides of IOBlockStorageDriver: */ - - virtual IOReturn ejectMedia(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 IOReturn recordMediaParameters(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 UInt32 getMediaType(void); - - /* -------------------------------------------------*/ - /* APIs implemented here, exported by IOCDMedia: */ - /* -------------------------------------------------*/ - - virtual CDTOC * getTOC(void); - virtual void readCD(IOService *client, - UInt64 byteStart, - IOMemoryDescriptor *buffer, - CDSectorArea sectorArea, - CDSectorType sectorType, -#ifdef __LP64__ - IOStorageAttributes *attributes, - IOStorageCompletion *completion); -#else /* !__LP64__ */ - IOStorageCompletion completion); -#endif /* !__LP64__ */ - virtual IOReturn readISRC(UInt8 track,CDISRC isrc); - virtual IOReturn readMCN(CDMCN mcn); - - /* end of IOCDMedia APIs */ - -#ifndef __LP64__ - /* --------------------------------------------------------*/ - /* APIs implemented here, exported by IOCDAudioControl: */ - /* --------------------------------------------------------*/ - - virtual IOReturn audioPause(bool pause) __attribute__ ((deprecated)); - virtual IOReturn audioPlay(CDMSF timeStart,CDMSF timeStop) __attribute__ ((deprecated)); - virtual IOReturn audioScan(CDMSF timeStart,bool reverse) __attribute__ ((deprecated)); - virtual IOReturn audioStop() __attribute__ ((deprecated)); - virtual IOReturn getAudioStatus(CDAudioStatus *status) __attribute__ ((deprecated)); - virtual IOReturn getAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume) __attribute__ ((deprecated)); - virtual IOReturn setAudioVolume(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 IOReturn acceptNewMedia(void); - virtual IOReturn decommissionMedia(bool forcible); - - /* End of IOBlockStorageDriver overrides. */ - - /* Internally used methods: */ - - using IOBlockStorageDriver::getMediaBlockSize; - - virtual IOReturn cacheTocInfo(void); - virtual UInt64 getMediaBlockSize(CDSectorArea area,CDSectorType type); - virtual void prepareRequest(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; - - /* ------- */ - - IOReturn reportDiscInfo(CDDiscInfo *discInfo); - IOReturn reportTrackInfo(UInt16 track,CDTrackInfo *trackInfo); - -public: - - virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */ - - virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ - - virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format, - UInt8 formatAsTime,UInt8 trackOrSessionNumber, - UInt16 *actualByteCount); /* 10.1.3 */ - - virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer, - UInt16 *actualByteCount); /* 10.1.3 */ - - virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address, - CDTrackInfoAddressType addressType, - UInt16 *actualByteCount); /* 10.1.3 */ - - virtual void writeCD(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 Index: trunk/i386/include/IOKit/storage/IOStorage.h =================================================================== --- trunk/i386/include/IOKit/storage/IOStorage.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOStorage.h (revision 916) @@ -212,351 +212,6 @@ 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 */ Index: trunk/i386/include/IOKit/storage/IOCDBlockStorageDevice.h =================================================================== --- trunk/i386/include/IOKit/storage/IOCDBlockStorageDevice.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOCDBlockStorageDevice.h (revision 916) @@ -54,128 +54,7 @@ /* Property used for matching, so the generic driver gets the nub it wants. */ #define kIOBlockStorageDeviceTypeCDROM "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 bool init(OSDictionary * properties); - - /*-----------------------------------------*/ - /* CD APIs */ - /*-----------------------------------------*/ - - virtual IOReturn doAsyncReadCD(IOMemoryDescriptor *buffer, - UInt32 block,UInt32 nblks, - CDSectorArea sectorArea, - CDSectorType sectorType, - IOStorageCompletion completion) = 0; - virtual UInt32 getMediaType(void) = 0; - virtual IOReturn readISRC(UInt8 track,CDISRC isrc) = 0; - virtual IOReturn readMCN(CDMCN mcn) = 0; - virtual IOReturn readTOC(IOMemoryDescriptor *buffer) = 0; - -#ifndef __LP64__ - /*-----------------------------------------*/ - /* APIs exported by IOCDAudioControl */ - /*-----------------------------------------*/ - - virtual IOReturn audioPause(bool pause) __attribute__ ((deprecated)); - virtual IOReturn audioPlay(CDMSF timeStart,CDMSF timeStop) __attribute__ ((deprecated)); - virtual IOReturn audioScan(CDMSF timeStart,bool reverse) __attribute__ ((deprecated)); - virtual IOReturn audioStop() __attribute__ ((deprecated)); - virtual IOReturn getAudioStatus(CDAudioStatus *status) __attribute__ ((deprecated)); - virtual IOReturn getAudioVolume(UInt8 *leftVolume,UInt8 *rightVolume) __attribute__ ((deprecated)); - virtual IOReturn setAudioVolume(UInt8 leftVolume,UInt8 rightVolume) __attribute__ ((deprecated)); -#endif /* !__LP64__ */ - - /*-----------------------------------------*/ - /* CD APIs */ - /*-----------------------------------------*/ - -#ifdef __LP64__ - virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond) = 0; - - virtual IOReturn setSpeed(UInt16 kilobytesPerSecond) = 0; - - virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format, - UInt8 msf,UInt8 trackSessionNumber, - UInt16 *actualByteCount) = 0; - - virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer, - UInt16 *actualByteCount) = 0; - - virtual IOReturn readTrackInfo(IOMemoryDescriptor *buffer,UInt32 address, - CDTrackInfoAddressType addressType, - UInt16 *actualByteCount) = 0; -#else /* !__LP64__ */ - virtual IOReturn getSpeed(UInt16 * kilobytesPerSecond); /* 10.1.0 */ - - virtual IOReturn setSpeed(UInt16 kilobytesPerSecond); /* 10.1.0 */ - - virtual IOReturn readTOC(IOMemoryDescriptor *buffer,CDTOCFormat format, - UInt8 msf,UInt8 trackSessionNumber, - UInt16 *actualByteCount); /* 10.1.3 */ - - virtual IOReturn readDiscInfo(IOMemoryDescriptor *buffer, - UInt16 *actualByteCount); /* 10.1.3 */ - - virtual IOReturn readTrackInfo(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 */ Index: trunk/i386/include/IOKit/storage/IOMediaBSDClient.h =================================================================== --- trunk/i386/include/IOKit/storage/IOMediaBSDClient.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOMediaBSDClient.h (revision 916) @@ -26,125 +26,4 @@ #include -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include -#include - -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 */ Index: trunk/i386/include/IOKit/storage/IOGUIDPartitionScheme.h =================================================================== --- trunk/i386/include/IOKit/storage/IOGUIDPartitionScheme.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOGUIDPartitionScheme.h (revision 916) @@ -87,148 +87,4 @@ #pragma pack(pop) /* (reset to default struct packing) */ -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include - -/* - * 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 */ Index: trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h =================================================================== --- trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 916) @@ -102,163 +102,4 @@ #pragma pack(pop) /* (reset to default struct packing) */ -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include - -/* - * 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 */ Index: trunk/i386/include/IOKit/storage/IOMedia.h =================================================================== --- trunk/i386/include/IOKit/storage/IOMedia.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOMedia.h (revision 916) @@ -228,441 +228,4 @@ typedef UInt32 IOMediaAttributeMask; -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include - -/*! - * @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 */ Index: trunk/i386/include/IOKit/storage/IOApplePartitionScheme.h =================================================================== --- trunk/i386/include/IOKit/storage/IOApplePartitionScheme.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOApplePartitionScheme.h (revision 916) @@ -119,147 +119,4 @@ #pragma pack(pop) /* (reset to default struct packing) */ -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include - -/* - * 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 */ Index: trunk/i386/include/IOKit/storage/IOBlockStorageDriver.h =================================================================== --- trunk/i386/include/IOKit/storage/IOBlockStorageDriver.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOBlockStorageDriver.h (revision 916) @@ -242,1330 +242,4 @@ typedef UInt32 IOMediaState; -#ifdef KERNEL -#ifdef __cplusplus - -/* - * Kernel - */ - -#include -#include -#include -#include - -/*! - * @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 IOReturn acceptNewMedia(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 UInt64 constrainByteCount(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 IOReturn decommissionMedia(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 IOReturn recordMediaParameters(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 void rejectMedia(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 bool validateNewMedia(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 IOReturn checkForMedia(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 void initMediaState(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 IOReturn mediaStateHasChanged(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 IOReturn requestIdle(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 */ Index: trunk/i386/include/IOKit/storage/IOBlockStorageDevice.h =================================================================== --- trunk/i386/include/IOKit/storage/IOBlockStorageDevice.h (revision 915) +++ trunk/i386/include/IOKit/storage/IOBlockStorageDevice.h (revision 916) @@ -61,29 +61,6 @@ #include #include -/*! - * @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 @@ -97,408 +74,7 @@ */ #define kIOBlockStorageDeviceTypeGeneric "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 bool init(OSDictionary * properties); - - virtual OSObject * getProperty(const OSSymbol * key) const; - - virtual IOReturn setProperties(OSObject * properties); - - /* --- A subclass must implement the the following methods: --- */ - -#ifndef __LP64__ - virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, - UInt32 block, UInt32 nblks, - IOStorageCompletion completion) __attribute__ ((deprecated)); - - virtual IOReturn doSyncReadWrite(IOMemoryDescriptor *buffer, - UInt32 block,UInt32 nblks) __attribute__ ((deprecated)); -#endif /* !__LP64__ */ - - /*! - * @function doEjectMedia - * @abstract - * Eject the media. - */ - virtual IOReturn doEjectMedia(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 IOReturn doFormatMedia(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 UInt32 doGetFormatCapacities(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 IOReturn doLockUnlockMedia(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 IOReturn doSynchronizeCache(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 IOReturn reportBlockSize(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 IOReturn reportEjectability(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 IOReturn reportLockability(bool *isLockable) = 0; - -#ifndef __LP64__ - virtual IOReturn reportMaxReadTransfer(UInt64 blockSize,UInt64 *max) __attribute__ ((deprecated)); - - virtual IOReturn reportMaxWriteTransfer(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 IOReturn reportMaxValidBlock(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 IOReturn reportMediaState(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 IOReturn reportPollRequirements(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 IOReturn reportRemovability(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 IOReturn reportWriteProtection(bool *isWriteProtected) = 0; - -#ifndef __LP64__ - virtual IOReturn doAsyncReadWrite(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 IOReturn getWriteCacheState(bool *enabled) = 0; -#else /* !__LP64__ */ - virtual IOReturn getWriteCacheState(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 IOReturn setWriteCacheState(bool enabled) = 0; -#else /* !__LP64__ */ - virtual IOReturn setWriteCacheState(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 IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, - UInt64 block, UInt64 nblks, - IOStorageAttributes *attributes, - IOStorageCompletion *completion) = 0; -#else /* !__LP64__ */ - virtual IOReturn doAsyncReadWrite(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 IOReturn requestIdle(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 */ Index: trunk/i386/include/architecture/byte_order.h =================================================================== --- trunk/i386/include/architecture/byte_order.h (revision 915) +++ trunk/i386/include/architecture/byte_order.h (revision 916) @@ -30,352 +30,7 @@ #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 -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 short x -) -{ - return (unsigned short)OSSwapBigToHostInt16((uint16_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned int -NXSwapBigIntToHost( - unsigned int x -) -{ - return (unsigned int)OSSwapBigToHostInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long -NXSwapBigLongToHost( - unsigned long x -) -{ - return (unsigned long)OSSwapBigToHostInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long long -NXSwapBigLongLongToHost( - unsigned long long x -) -{ - return (unsigned long long)OSSwapBigToHostInt64((uint64_t)x); -} - -static __inline__ __attribute__((deprecated)) -double -NXSwapBigDoubleToHost( - NXSwappedDouble x -) -{ - return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapBigToHostInt64((uint64_t)x)); -} - -static __inline__ __attribute__((deprecated)) -float -NXSwapBigFloatToHost( - NXSwappedFloat x -) -{ - return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapBigToHostInt32((uint32_t)x)); -} - -static __inline__ __attribute__((deprecated)) -unsigned short -NXSwapHostShortToBig( - unsigned short x -) -{ - return (unsigned short)OSSwapHostToBigInt16((uint16_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned int -NXSwapHostIntToBig( - unsigned int x -) -{ - return (unsigned int)OSSwapHostToBigInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long -NXSwapHostLongToBig( - unsigned long x -) -{ - return (unsigned long)OSSwapHostToBigInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long long -NXSwapHostLongLongToBig( - unsigned long long x -) -{ - return (unsigned long long)OSSwapHostToBigInt64((uint64_t)x); -} - -static __inline__ __attribute__((deprecated)) -NXSwappedDouble -NXSwapHostDoubleToBig( - double x -) -{ - return (NXSwappedDouble)OSSwapHostToBigInt64((uint64_t)NXConvertHostDoubleToSwapped(x)); -} - -static __inline__ __attribute__((deprecated)) -NXSwappedFloat -NXSwapHostFloatToBig( - float x -) -{ - return (NXSwappedFloat)OSSwapHostToBigInt32((uint32_t)NXConvertHostFloatToSwapped(x)); -} - -static __inline__ __attribute__((deprecated)) -unsigned short -NXSwapLittleShortToHost( - unsigned short x -) -{ - return (unsigned short)OSSwapLittleToHostInt16((uint16_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned int -NXSwapLittleIntToHost( - unsigned int x -) -{ - return (unsigned int)OSSwapLittleToHostInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long -NXSwapLittleLongToHost( - unsigned long x -) -{ - return (unsigned long)OSSwapLittleToHostInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long long -NXSwapLittleLongLongToHost( - unsigned long long x -) -{ - return (unsigned long long)OSSwapLittleToHostInt64((uint64_t)x); -} - -static __inline__ __attribute__((deprecated)) -double -NXSwapLittleDoubleToHost( - NXSwappedDouble x -) -{ - return NXConvertSwappedDoubleToHost((NXSwappedDouble)OSSwapLittleToHostInt64((uint64_t)x)); -} - -static __inline__ __attribute__((deprecated)) -float -NXSwapLittleFloatToHost( - NXSwappedFloat x -) -{ - return NXConvertSwappedFloatToHost((NXSwappedFloat)OSSwapLittleToHostInt32((uint32_t)x)); -} - -static __inline__ __attribute__((deprecated)) -unsigned short -NXSwapHostShortToLittle( - unsigned short x -) -{ - return (unsigned short)OSSwapHostToLittleInt16((uint16_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned int -NXSwapHostIntToLittle( - unsigned int x -) -{ - return (unsigned int)OSSwapHostToLittleInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long -NXSwapHostLongToLittle( - unsigned long x -) -{ - return (unsigned long)OSSwapHostToLittleInt32((uint32_t)x); -} - -static __inline__ __attribute__((deprecated)) -unsigned long long -NXSwapHostLongLongToLittle( - unsigned long long x -) -{ - return (unsigned long long)OSSwapHostToLittleInt64((uint64_t)x); -} - -static __inline__ __attribute__((deprecated)) -NXSwappedDouble -NXSwapHostDoubleToLittle( - double x -) -{ - return (NXSwappedDouble)OSSwapHostToLittleInt64((uint64_t)NXConvertHostDoubleToSwapped(x)); -} - -static __inline__ __attribute__((deprecated)) -NXSwappedFloat -NXSwapHostFloatToLittle( - float x -) -{ - return (NXSwappedFloat)OSSwapHostToLittleInt32((uint32_t)NXConvertHostFloatToSwapped(x)); -} - #endif /* _ARCHITECTURE_BYTE_ORDER_H_ */ Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 915) +++ trunk/i386/boot2/boot.c (revision 916) @@ -198,8 +198,8 @@ else { execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL); // Notify modules that the kernel is about to be started - } + // If we were in text mode, switch to graphics mode. // This will draw the boot graphics unless we are in // verbose mode.