2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _IOPOLLEDINTERFACE_H_
30 #define _IOPOLLEDINTERFACE_H_
34 kIOPolledPreflightState
= 1,
35 kIOPolledBeforeSleepState
= 2,
36 kIOPolledAfterSleepState
= 3,
37 kIOPolledPostflightState
= 4,
39 kIOPolledPreflightCoreDumpState
= 5,
40 kIOPolledPostflightCoreDumpState
= 6,
42 kIOPolledBeforeSleepStateAborted
= 7,
45 #if defined(__cplusplus)
47 #include <libkern/c++/OSObject.h>
48 #include <IOKit/IOMemoryDescriptor.h>
50 #define kIOPolledInterfaceSupportKey "IOPolledInterface"
51 #define kIOPolledInterfaceActiveKey "IOPolledInterfaceActive"
52 #define kIOPolledInterfaceStackKey "IOPolledInterfaceStack"
60 typedef void (*IOPolledCompletionAction
)( void * target
,
63 uint64_t actualByteCount
);
64 struct IOPolledCompletion
67 IOPolledCompletionAction action
;
71 class IOPolledInterface
: public OSObject
73 OSDeclareAbstractStructors(IOPolledInterface
);
76 struct ExpansionData
{ };
77 ExpansionData
* reserved
;
80 virtual IOReturn
probe(IOService
* target
) = 0;
82 virtual IOReturn
open( IOOptionBits state
, IOMemoryDescriptor
* buffer
) = 0;
83 virtual IOReturn
close(IOOptionBits state
) = 0;
85 virtual IOReturn
startIO(uint32_t operation
,
86 uint32_t bufferOffset
,
87 uint64_t deviceOffset
,
89 IOPolledCompletion completion
) = 0;
91 virtual IOReturn
checkForWork(void) = 0;
93 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 0);
94 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 1);
95 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 2);
96 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 3);
97 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 4);
98 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 5);
99 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 6);
100 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 7);
101 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 8);
102 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 9);
103 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 10);
104 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 11);
105 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 12);
106 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 13);
107 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 14);
108 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 15);
111 #endif /* defined(__cplusplus) */
113 #ifdef XNU_KERNEL_PRIVATE
115 #include <libkern/crypto/aes.h>
116 #include <IOKit/IOTypes.h>
117 #include <IOKit/IOHibernatePrivate.h>
121 kIOPolledFileSSD
= 0x00000001
124 #if !defined(__cplusplus)
125 typedef struct IORegistryEntry IORegistryEntry
;
126 typedef struct OSData OSData
;
127 typedef struct OSArray OSArray
;
128 typedef struct IOMemoryDescriptor IOMemoryDescriptor
;
129 typedef struct IOPolledFilePollers IOPolledFilePollers
;
131 class IOPolledFilePollers
;
134 struct IOPolledFileIOVars
136 IOPolledFilePollers
* pollers
;
137 struct kern_direct_file_io_ref_t
* fileRef
;
138 OSData
* fileExtents
;
140 IOByteCount blockSize
;
142 IOByteCount bufferLimit
;
144 IOByteCount bufferSize
;
145 IOByteCount bufferOffset
;
146 IOByteCount bufferHalf
;
147 IOByteCount extentRemaining
;
148 IOByteCount lastRead
;
153 uint64_t extentPosition
;
154 uint64_t encryptStart
;
157 AbsoluteTime cryptTime
;
158 IOPolledFileExtent
* extentMap
;
159 IOPolledFileExtent
* currentExtent
;
163 typedef struct IOPolledFileIOVars IOPolledFileIOVars
;
165 struct IOPolledFileCryptVars
167 uint8_t aes_iv
[AES_BLOCK_SIZE
];
170 typedef struct IOPolledFileCryptVars IOPolledFileCryptVars
;
172 #if defined(__cplusplus)
174 IOReturn
IOPolledFileOpen(const char * filename
,
175 uint64_t setFileSize
, uint64_t fsFreeSize
,
176 void * write_file_addr
, size_t write_file_len
,
177 IOPolledFileIOVars
** fileVars
,
179 uint8_t * volumeCryptKey
, size_t keySize
);
181 IOReturn
IOPolledFileClose(IOPolledFileIOVars
** pVars
,
182 off_t write_offset
, void * addr
, size_t write_length
,
183 off_t discard_offset
, off_t discard_end
);
185 IOReturn
IOPolledFilePollersSetup(IOPolledFileIOVars
* vars
, uint32_t openState
);
187 IOMemoryDescriptor
* IOPolledFileGetIOBuffer(IOPolledFileIOVars
* vars
);
189 #endif /* defined(__cplusplus) */
191 #if defined(__cplusplus)
197 extern __C IOReturn
IOPolledFileSeek(IOPolledFileIOVars
* vars
, uint64_t position
);
199 extern __C IOReturn
IOPolledFileWrite(IOPolledFileIOVars
* vars
,
200 const uint8_t * bytes
, IOByteCount size
,
201 IOPolledFileCryptVars
* cryptvars
);
202 extern __C IOReturn
IOPolledFileRead(IOPolledFileIOVars
* vars
,
203 uint8_t * bytes
, IOByteCount size
,
204 IOPolledFileCryptVars
* cryptvars
);
206 extern __C IOReturn
IOPolledFilePollersOpen(IOPolledFileIOVars
* vars
, uint32_t state
, bool abortable
);
208 extern __C IOReturn
IOPolledFilePollersClose(IOPolledFileIOVars
* vars
, uint32_t state
);
210 extern __C IOPolledFileIOVars
* gCoreFileVars
;
216 typedef void (*kern_get_file_extents_callback_t
)(void * ref
, uint64_t start
, uint64_t size
);
218 struct kern_direct_file_io_ref_t
*
219 kern_open_file_for_direct_io(const char * name
, boolean_t create_file
,
220 kern_get_file_extents_callback_t callback
,
224 off_t write_file_offset
,
225 void * write_file_addr
,
226 size_t write_file_len
,
227 dev_t
* partition_device_result
,
228 dev_t
* image_device_result
,
229 uint64_t * partitionbase_result
,
230 uint64_t * maxiocount_result
,
233 kern_close_file_for_direct_io(struct kern_direct_file_io_ref_t
* ref
,
234 off_t write_offset
, void * addr
, size_t write_length
,
235 off_t discard_offset
, off_t discard_end
);
237 kern_write_file(struct kern_direct_file_io_ref_t
* ref
, off_t offset
, void * addr
, size_t len
, int ioflag
);
239 kern_read_file(struct kern_direct_file_io_ref_t
* ref
, off_t offset
, void * addr
, size_t len
, int ioflag
);
242 kern_file_mount(struct kern_direct_file_io_ref_t
* ref
);
246 kIOPolledFileMountChangeMount
= 0x00000101,
247 kIOPolledFileMountChangeUnmount
= 0x00000102,
248 kIOPolledFileMountChangeWillResize
= 0x00000201,
249 kIOPolledFileMountChangeDidResize
= 0x00000202,
251 extern void IOPolledFileMountChange(struct mount
* mp
, uint32_t op
);
255 #endif /* _SYS_CONF_H_ */
257 #endif /* XNU_KERNEL_PRIVATE */
259 #endif /* _IOPOLLEDINTERFACE_H_ */