]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOUserClient.h
xnu-1228.tar.gz
[apple/xnu.git] / iokit / IOKit / IOUserClient.h
index 17378e7bd9e09efb9ca09b3980c6ea1bfdff2a72..1a2782e50d9e84c538bdc19fc353a82a4687e70d 100644 (file)
@@ -46,6 +46,15 @@ enum {
     kIOUCScalarIStructI = 4
 };
 
+/*! @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 );
 
@@ -85,6 +94,64 @@ enum {
 #define kIOClientPrivilegeAdministrator        "root"
 #define kIOClientPrivilegeLocalUser    "local"
 
+/*! @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           __reserved[32];
+};
+
+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   1
+    kIOExternalMethodArgumentsCurrentVersion = IO_EXTERNAL_METHOD_ARGUMENTS_CURRENT_VERSION
+};
+
+
 /*!
     @class IOUserClient
     @abstract   Provides a basis for communication between client applications and I/O Kit objects.
@@ -108,10 +175,16 @@ protected:
 
 public:
     OSSet * mappings;
-    void  * __reserved[8];
+    UInt8   sharedInstance;
+    UInt8   __reservedA[3];
+    void  * __reserved[7];
+
+    virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments,
+                                       IOExternalMethodDispatch * dispatch = 0, OSObject * target = 0, void * reference = 0 );
+    OSMetaClassDeclareReservedUsed(IOUserClient, 0);
 
 private:
-    OSMetaClassDeclareReservedUnused(IOUserClient, 0);
+
     OSMetaClassDeclareReservedUnused(IOUserClient, 1);
     OSMetaClassDeclareReservedUnused(IOUserClient, 2);
     OSMetaClassDeclareReservedUnused(IOUserClient, 3);
@@ -134,6 +207,12 @@ protected:
     static void setAsyncReference(OSAsyncReference asyncRef,
                                   mach_port_t wakePort,
                                   void *callback, void *refcon);
+
+    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 void initialize( void );
@@ -143,6 +222,8 @@ public:
     static IOReturn clientHasPrivilege( void * securityToken,
                                         const char * privilegeName );
 
+    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,
@@ -176,6 +257,11 @@ public:
                                     IOOptionBits mapFlags = kIOMapAnywhere,
                                    IOVirtualAddress atAddress = 0 );
 
+    IOMemoryMap * mapClientMemory64( IOOptionBits type,
+                                    task_t task,
+                                    IOOptionBits mapFlags = kIOMapAnywhere,
+                                   mach_vm_address_t atAddress = 0 );
+
     /*!
         @function removeMappingForDescriptor
         Remove the first mapping created from the memory descriptor returned by clientMemoryForType() from IOUserClient's list of mappings. If such a mapping exists, it is retained and the reference currently held by IOUserClient is returned to the caller.