#include <IOKit/IOService.h>
#include <IOKit/OSMessageNotification.h>
+#if IOKITSTATS
+#include <IOKit/IOStatisticsPrivate.h>
+#endif
enum {
kIOUCTypeMask = 0x0000000f,
kIOUCScalarIScalarO = 0,
kIOUCScalarIStructO = 2,
kIOUCStructIStructO = 3,
- kIOUCScalarIStructI = 4
+ kIOUCScalarIStructI = 4,
+
+ kIOUCForegroundOnly = 0x00000010,
};
+/*! @enum
+ @abstract Constant to denote a variable length structure argument to IOUserClient.
+ @constant kIOUCVariableStructureSize Use in the structures IOExternalMethod, IOExternalAsyncMethod, IOExternalMethodDispatch to specify the size of the structure is variable.
+*/
+enum {
+ kIOUCVariableStructureSize = 0xffffffff
+};
+
+
typedef IOReturn (IOService::*IOMethod)(void * p1, void * p2, void * p3,
void * p4, void * p5, void * p6 );
// keys for clientHasPrivilege
#define kIOClientPrivilegeAdministrator "root"
#define kIOClientPrivilegeLocalUser "local"
+#define kIOClientPrivilegeForeground "foreground"
+
+/*! @enum
+ @abstract Constants to specify the maximum number of scalar arguments in the IOExternalMethodArguments structure. These constants are documentary since the scalarInputCount, scalarOutputCount fields reflect the actual number passed.
+ @constant kIOExternalMethodScalarInputCountMax The maximum number of scalars able to passed on input.
+ @constant kIOExternalMethodScalarOutputCountMax The maximum number of scalars able to passed on output.
+*/
+enum {
+ kIOExternalMethodScalarInputCountMax = 16,
+ kIOExternalMethodScalarOutputCountMax = 16,
+};
+
+
+struct IOExternalMethodArguments
+{
+ uint32_t version;
+
+ uint32_t selector;
+
+ mach_port_t asyncWakePort;
+ io_user_reference_t * asyncReference;
+ uint32_t asyncReferenceCount;
+
+ const uint64_t * scalarInput;
+ uint32_t scalarInputCount;
+
+ const void * structureInput;
+ uint32_t structureInputSize;
+
+ IOMemoryDescriptor * structureInputDescriptor;
+
+ uint64_t * scalarOutput;
+ uint32_t scalarOutputCount;
+
+ void * structureOutput;
+ uint32_t structureOutputSize;
+
+ IOMemoryDescriptor * structureOutputDescriptor;
+ uint32_t structureOutputDescriptorSize;
+
+ uint32_t __reservedA;
+
+ OSObject ** structureVariableOutputData;
+
+ uint32_t __reserved[30];
+};
+
+typedef IOReturn (*IOExternalMethodAction)(OSObject * target, void * reference,
+ IOExternalMethodArguments * arguments);
+struct IOExternalMethodDispatch
+{
+ IOExternalMethodAction function;
+ uint32_t checkScalarInputCount;
+ uint32_t checkStructureInputSize;
+ uint32_t checkScalarOutputCount;
+ uint32_t checkStructureOutputSize;
+};
+
+enum {
+#define IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION 2
+ kIOExternalMethodArgumentsCurrentVersion = IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION
+};
+
/*!
@class IOUserClient
class IOUserClient : public IOService
{
OSDeclareAbstractStructors(IOUserClient)
+#if IOKITSTATS
+ friend class IOStatistics;
+#endif
protected:
/*! @struct ExpansionData
@discussion This structure will be used to expand the capablilties of this class in the future.
*/
- struct ExpansionData { };
+ struct ExpansionData {
+#if IOKITSTATS
+ IOUserClientCounter *counter;
+#else
+ void *iokitstatsReserved;
+#endif
+ };
/*! @var reserved
Reserved for future use. (Internal use only)
*/
ExpansionData * reserved;
+ bool reserve();
+
+#ifdef XNU_KERNEL_PRIVATE
public:
+#else
+private:
+#endif
OSSet * mappings;
- void * __reserved[8];
+ UInt8 sharedInstance;
+ UInt8 __reservedA[3];
+ void * __reserved[7];
+
+public:
+ virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments,
+ IOExternalMethodDispatch * dispatch = 0, OSObject * target = 0, void * reference = 0 );
+
+ virtual IOReturn registerNotificationPort(
+ mach_port_t port, UInt32 type, io_user_reference_t refCon);
private:
+#if __LP64__
OSMetaClassDeclareReservedUnused(IOUserClient, 0);
OSMetaClassDeclareReservedUnused(IOUserClient, 1);
+#else
+ OSMetaClassDeclareReservedUsed(IOUserClient, 0);
+ OSMetaClassDeclareReservedUsed(IOUserClient, 1);
+#endif
OSMetaClassDeclareReservedUnused(IOUserClient, 2);
OSMetaClassDeclareReservedUnused(IOUserClient, 3);
OSMetaClassDeclareReservedUnused(IOUserClient, 4);
OSMetaClassDeclareReservedUnused(IOUserClient, 14);
OSMetaClassDeclareReservedUnused(IOUserClient, 15);
+#ifdef XNU_KERNEL_PRIVATE
+ /* Available within xnu source only */
+public:
+ static void initialize( void );
+ static void destroyUserReferences( OSObject * obj );
+ IOMemoryMap * mapClientMemory64( IOOptionBits type,
+ task_t task,
+ IOOptionBits mapFlags = kIOMapAnywhere,
+ mach_vm_address_t atAddress = 0 );
+#endif
+
protected:
static IOReturn sendAsyncResult(OSAsyncReference reference,
IOReturn result, void *args[], UInt32 numArgs);
static void setAsyncReference(OSAsyncReference asyncRef,
mach_port_t wakePort,
void *callback, void *refcon);
-public:
-
- static void initialize( void );
- static void destroyUserReferences( OSObject * obj );
+ static IOReturn sendAsyncResult64(OSAsyncReference64 reference,
+ IOReturn result, io_user_reference_t args[], UInt32 numArgs);
+ static void setAsyncReference64(OSAsyncReference64 asyncRef,
+ mach_port_t wakePort,
+ mach_vm_address_t callback, io_user_reference_t refcon);
+public:
static IOReturn clientHasPrivilege( void * securityToken,
const char * privilegeName );
+ /*!
+ @function releaseAsyncReference64
+ @abstract Release the mach_port_t reference held within the OSAsyncReference64 structure.
+ @discussion The OSAsyncReference64 structure passed to async methods holds a reference to the wakeup mach port, which should be released to balance each async method call. Behavior is undefined if these calls are not correctly balanced.
+ @param reference The reference passed to the subclass IOAsyncMethod, or externalMethod() in the IOExternalMethodArguments.asyncReference field.
+ @result A return code.
+ */
+ static IOReturn releaseAsyncReference64(OSAsyncReference64 reference);
+ /*!
+ @function releaseNotificationPort
+ @abstract Release the mach_port_t passed to registerNotificationPort().
+ @discussion The mach_port_t passed to the registerNotificationPort() methods should be released to balance each call to registerNotificationPort(). Behavior is undefined if these calls are not correctly balanced.
+ @param reference The mach_port_t argument previously passed to the subclass implementation of registerNotificationPort().
+ @result A return code.
+ */
+ static IOReturn releaseNotificationPort(mach_port_t port);
+
+ virtual bool init();
+ virtual bool init( OSDictionary * dictionary );
// Currently ignores the all args, just passes up to IOService::init()
virtual bool initWithTask(
task_t owningTask, void * securityToken, UInt32 type,
IOOptionBits * options,
IOMemoryDescriptor ** memory );
- virtual IOMemoryMap * mapClientMemory( IOOptionBits type,
+#if !__LP64__
+private:
+ APPLE_KEXT_COMPATIBILITY_VIRTUAL
+ IOMemoryMap * mapClientMemory( IOOptionBits type,
task_t task,
IOOptionBits mapFlags = kIOMapAnywhere,
- IOVirtualAddress atAddress = 0 );
+ IOVirtualAddress atAddress = 0 );
+#endif
+
+public:
/*!
@function removeMappingForDescriptor
// Old methods for accessing method vector backward compatiblility only
virtual IOExternalMethod *
- getExternalMethodForIndex( UInt32 index );
+ getExternalMethodForIndex( UInt32 index )
+ APPLE_KEXT_DEPRECATED;
virtual IOExternalAsyncMethod *
- getExternalAsyncMethodForIndex( UInt32 index );
+ getExternalAsyncMethodForIndex( UInt32 index )
+ APPLE_KEXT_DEPRECATED;
// Methods for accessing method vector.
virtual IOExternalMethod *
// Methods for accessing trap vector - old and new style
virtual IOExternalTrap *
- getExternalTrapForIndex( UInt32 index );
+ getExternalTrapForIndex( UInt32 index )
+ APPLE_KEXT_DEPRECATED;
+
virtual IOExternalTrap *
getTargetAndTrapForIndex( IOService **targetP, UInt32 index );
};