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,
42 #if defined(__cplusplus)
44 #include <libkern/c++/OSObject.h>
45 #include <IOKit/IOMemoryDescriptor.h>
47 #define kIOPolledInterfaceSupportKey "IOPolledInterface"
48 #define kIOPolledInterfaceActiveKey "IOPolledInterfaceActive"
49 #define kIOPolledInterfaceStackKey "IOPolledInterfaceStack"
57 typedef void (*IOPolledCompletionAction
)( void * target
,
60 uint64_t actualByteCount
);
61 struct IOPolledCompletion
64 IOPolledCompletionAction action
;
68 class IOPolledInterface
: public OSObject
70 OSDeclareAbstractStructors(IOPolledInterface
);
73 struct ExpansionData
{ };
74 ExpansionData
* reserved
;
77 virtual IOReturn
probe(IOService
* target
) = 0;
79 virtual IOReturn
open( IOOptionBits state
, IOMemoryDescriptor
* buffer
) = 0;
80 virtual IOReturn
close(IOOptionBits state
) = 0;
82 virtual IOReturn
startIO(uint32_t operation
,
83 uint32_t bufferOffset
,
84 uint64_t deviceOffset
,
86 IOPolledCompletion completion
) = 0;
88 virtual IOReturn
checkForWork(void) = 0;
90 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 0);
91 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 1);
92 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 2);
93 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 3);
94 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 4);
95 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 5);
96 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 6);
97 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 7);
98 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 8);
99 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 9);
100 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 10);
101 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 11);
102 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 12);
103 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 13);
104 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 14);
105 OSMetaClassDeclareReservedUnused(IOPolledInterface
, 15);
108 #endif /* defined(__cplusplus) */
110 #ifdef XNU_KERNEL_PRIVATE
112 #include <libkern/crypto/aes.h>
113 #include <IOKit/IOTypes.h>
114 #include <IOKit/IOHibernatePrivate.h>
118 kIOPolledFileSSD
= 0x00000001
121 #if !defined(__cplusplus)
122 typedef struct IORegistryEntry IORegistryEntry
;
123 typedef struct OSData OSData
;
124 typedef struct OSArray OSArray
;
125 typedef struct IOMemoryDescriptor IOMemoryDescriptor
;
126 typedef struct IOPolledFilePollers IOPolledFilePollers
;
128 class IOPolledFilePollers
;
131 struct IOPolledFileIOVars
133 IOPolledFilePollers
* pollers
;
134 struct kern_direct_file_io_ref_t
* fileRef
;
135 OSData
* fileExtents
;
137 IOByteCount blockSize
;
139 IOByteCount bufferLimit
;
141 IOByteCount bufferSize
;
142 IOByteCount bufferOffset
;
143 IOByteCount bufferHalf
;
144 IOByteCount extentRemaining
;
145 IOByteCount lastRead
;
150 uint64_t extentPosition
;
151 uint64_t encryptStart
;
154 AbsoluteTime cryptTime
;
155 IOPolledFileExtent
* extentMap
;
156 IOPolledFileExtent
* currentExtent
;
160 typedef struct IOPolledFileIOVars IOPolledFileIOVars
;
162 struct IOPolledFileCryptVars
164 uint8_t aes_iv
[AES_BLOCK_SIZE
];
167 typedef struct IOPolledFileCryptVars IOPolledFileCryptVars
;
169 #if defined(__cplusplus)
171 IOReturn
IOPolledFileOpen(const char * filename
,
172 uint64_t setFileSize
, uint64_t fsFreeSize
,
173 void * write_file_addr
, size_t write_file_len
,
174 IOPolledFileIOVars
** fileVars
,
176 uint8_t * volumeCryptKey
, size_t keySize
);
178 IOReturn
IOPolledFileClose(IOPolledFileIOVars
** pVars
,
179 off_t write_offset
, void * addr
, size_t write_length
,
180 off_t discard_offset
, off_t discard_end
);
182 IOReturn
IOPolledFilePollersSetup(IOPolledFileIOVars
* vars
, uint32_t openState
);
184 IOMemoryDescriptor
* IOPolledFileGetIOBuffer(IOPolledFileIOVars
* vars
);
186 #endif /* defined(__cplusplus) */
188 #if defined(__cplusplus)
194 extern __C IOReturn
IOPolledFileSeek(IOPolledFileIOVars
* vars
, uint64_t position
);
196 extern __C IOReturn
IOPolledFileWrite(IOPolledFileIOVars
* vars
,
197 const uint8_t * bytes
, IOByteCount size
,
198 IOPolledFileCryptVars
* cryptvars
);
199 extern __C IOReturn
IOPolledFileRead(IOPolledFileIOVars
* vars
,
200 uint8_t * bytes
, IOByteCount size
,
201 IOPolledFileCryptVars
* cryptvars
);
203 extern __C IOReturn
IOPolledFilePollersOpen(IOPolledFileIOVars
* vars
, uint32_t state
, bool abortable
);
205 extern __C IOReturn
IOPolledFilePollersClose(IOPolledFileIOVars
* vars
, uint32_t state
);
207 extern __C IOPolledFileIOVars
* gCoreFileVars
;
213 typedef void (*kern_get_file_extents_callback_t
)(void * ref
, uint64_t start
, uint64_t size
);
215 struct kern_direct_file_io_ref_t
*
216 kern_open_file_for_direct_io(const char * name
, boolean_t create_file
,
217 kern_get_file_extents_callback_t callback
,
221 off_t write_file_offset
,
222 void * write_file_addr
,
223 size_t write_file_len
,
224 dev_t
* partition_device_result
,
225 dev_t
* image_device_result
,
226 uint64_t * partitionbase_result
,
227 uint64_t * maxiocount_result
,
230 kern_close_file_for_direct_io(struct kern_direct_file_io_ref_t
* ref
,
231 off_t write_offset
, void * addr
, size_t write_length
,
232 off_t discard_offset
, off_t discard_end
);
234 kern_write_file(struct kern_direct_file_io_ref_t
* ref
, off_t offset
, void * addr
, size_t len
, int ioflag
);
236 kern_read_file(struct kern_direct_file_io_ref_t
* ref
, off_t offset
, void * addr
, size_t len
, int ioflag
);
239 kern_file_mount(struct kern_direct_file_io_ref_t
* ref
);
243 kIOPolledFileMountChangeMount
= 0x00000101,
244 kIOPolledFileMountChangeUnmount
= 0x00000102,
245 kIOPolledFileMountChangeWillResize
= 0x00000201,
246 kIOPolledFileMountChangeDidResize
= 0x00000202,
248 extern void IOPolledFileMountChange(struct mount
* mp
, uint32_t op
);
252 #endif /* _SYS_CONF_H_ */
254 #endif /* XNU_KERNEL_PRIVATE */
256 #endif /* _IOPOLLEDINTERFACE_H_ */