1 | /*␊ |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@␊ |
5 | *␊ |
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.␊ |
14 | *␊ |
15 | * Please obtain a copy of the License at␊ |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.␊ |
17 | *␊ |
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.␊ |
25 | *␊ |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@␊ |
27 | */␊ |
28 | ␊ |
29 | #ifdef __cplusplus␊ |
30 | extern "C" {␊ |
31 | #endif␊ |
32 | ␊ |
33 | #ifdef KERNEL␊ |
34 | #include <crypto/aes.h>␊ |
35 | #endif␊ |
36 | ␊ |
37 | #ifndef __IOKIT_IOHIBERNATEPRIVATE_H␊ |
38 | #define __IOKIT_IOHIBERNATEPRIVATE_H␊ |
39 | ␊ |
40 | struct IOPolledFileExtent␊ |
41 | {␊ |
42 | ␉uint64_t␉start;␊ |
43 | ␉uint64_t␉length;␊ |
44 | };␊ |
45 | typedef struct IOPolledFileExtent IOPolledFileExtent;␊ |
46 | ␊ |
47 | struct IOHibernateImageHeader␊ |
48 | {␊ |
49 | ␉uint64_t␉imageSize; // 0␊ |
50 | ␉uint64_t␉image1Size; // 8␊ |
51 | ␊ |
52 | ␉uint32_t␉restore1CodePhysPage; // 10␊ |
53 | ␉uint32_t␉reserved1; // 14␊ |
54 | ␉uint64_t␉restore1CodeVirt; // 18␊ |
55 | ␉uint32_t␉restore1PageCount; // 20␊ |
56 | ␉uint32_t␉restore1CodeOffset;␊ |
57 | ␉uint32_t␉restore1StackOffset;␊ |
58 | ␊ |
59 | uint32_t␉pageCount;␊ |
60 | uint32_t␉bitmapSize;␊ |
61 | ␊ |
62 | uint32_t␉restore1Sum;␊ |
63 | uint32_t␉image1Sum;␊ |
64 | uint32_t␉image2Sum;␊ |
65 | ␊ |
66 | uint32_t␉actualRestore1Sum;␊ |
67 | uint32_t␉actualImage1Sum;␊ |
68 | uint32_t␉actualImage2Sum;␊ |
69 | ␊ |
70 | uint32_t␉actualUncompressedPages;␊ |
71 | uint32_t␉conflictCount;␊ |
72 | uint32_t␉nextFree;␊ |
73 | ␊ |
74 | uint32_t␉signature;␊ |
75 | uint32_t␉processorFlags;␊ |
76 | ␊ |
77 | uint32_t␉runtimePages;␊ |
78 | uint32_t␉runtimePageCount;␊ |
79 | ␉uint64_t␉runtimeVirtualPages __attribute__ ((packed));␊ |
80 | ␊ |
81 | ␉uint32_t␉performanceDataStart;␊ |
82 | ␉uint32_t␉performanceDataSize;␊ |
83 | ␊ |
84 | ␉uint64_t␉encryptStart __attribute__ ((packed));␊ |
85 | ␉uint64_t␉machineSignature __attribute__ ((packed));␊ |
86 | ␊ |
87 | ␉uint32_t␉previewSize;␊ |
88 | ␉uint32_t␉previewPageListSize;␊ |
89 | ␊ |
90 | ␉uint32_t␉diag[4];␊ |
91 | ␊ |
92 | ␉uint32_t␉handoffPages;␊ |
93 | ␉uint32_t␉handoffPageCount;␊ |
94 | ␊ |
95 | ␉uint32_t␉systemTableOffset;␊ |
96 | ␊ |
97 | ␉uint32_t␉debugFlags;␊ |
98 | ␉uint32_t␉options;␊ |
99 | ␉uint32_t␉sleepTime;␊ |
100 | ␉uint32_t␉compression;␊ |
101 | ␊ |
102 | ␉uint32_t␉reserved[58];␉␉// make sizeof == 512␊ |
103 | ␉uint32_t␉booterTime0;␊ |
104 | ␉uint32_t␉booterTime1;␊ |
105 | ␉uint32_t␉booterTime2;␊ |
106 | ␊ |
107 | ␉uint32_t␉booterStart;␊ |
108 | ␉uint32_t␉smcStart;␊ |
109 | ␉uint32_t␉connectDisplayTime;␊ |
110 | ␉uint32_t␉splashTime;␊ |
111 | ␉uint32_t␉booterTime;␊ |
112 | ␉uint32_t␉trampolineTime;␊ |
113 | ␊ |
114 | ␉uint64_t␉encryptEnd __attribute__ ((packed));␊ |
115 | ␉uint64_t␉deviceBase __attribute__ ((packed));␊ |
116 | ␉uint32_t␉deviceBlockSize;␊ |
117 | ␊ |
118 | ␉uint32_t␉␉fileExtentMapSize;␊ |
119 | ␉IOPolledFileExtent␉fileExtentMap[2];␊ |
120 | };␊ |
121 | typedef struct IOHibernateImageHeader IOHibernateImageHeader;␊ |
122 | ␊ |
123 | struct IOHibernateImageHeaderSnow␊ |
124 | {␊ |
125 | ␉uint64_t␉imageSize;␊ |
126 | ␉uint64_t␉image1Size;␊ |
127 | ␊ |
128 | ␉uint32_t␉restore1CodePhysPage;␊ |
129 | ␊ |
130 | ␉uint32_t␉restore1PageCount;␊ |
131 | ␉uint32_t␉restore1CodeOffset;␊ |
132 | ␉uint32_t␉restore1StackOffset;␊ |
133 | ␊ |
134 | ␉uint32_t␉pageCount;␊ |
135 | ␉uint32_t␉bitmapSize;␊ |
136 | ␊ |
137 | ␉uint32_t␉restore1Sum;␊ |
138 | ␉uint32_t␉image1Sum;␊ |
139 | ␉uint32_t␉image2Sum;␊ |
140 | ␊ |
141 | ␉uint32_t␉actualRestore1Sum;␊ |
142 | ␉uint32_t␉actualImage1Sum;␊ |
143 | ␉uint32_t␉actualImage2Sum;␊ |
144 | ␊ |
145 | ␉uint32_t␉actualUncompressedPages;␊ |
146 | ␉uint32_t␉conflictCount;␊ |
147 | ␉uint32_t␉nextFree;␊ |
148 | ␊ |
149 | ␉uint32_t␉signature;␊ |
150 | ␉uint32_t␉processorFlags;␊ |
151 | ␊ |
152 | ␉uint32_t␉runtimePages;␊ |
153 | ␉uint32_t␉runtimePageCount;␊ |
154 | ␊ |
155 | ␉uint8_t␉␉reserved2[16];␊ |
156 | ␊ |
157 | ␉uint64_t␉encryptStart;␊ |
158 | ␉uint64_t␉machineSignature;␊ |
159 | ␊ |
160 | ␉uint32_t␉previewSize;␊ |
161 | ␉uint32_t␉previewPageListSize;␊ |
162 | ␊ |
163 | ␉uint32_t␉diag[4];␊ |
164 | ␊ |
165 | ␉int32_t␉␉graphicsInfoOffset;␊ |
166 | ␉int32_t␉␉cryptVarsOffset;␊ |
167 | ␉int32_t␉␉memoryMapOffset;␊ |
168 | ␉uint32_t␉memoryMapSize;␊ |
169 | ␉uint32_t␉systemTableOffset;␊ |
170 | ␊ |
171 | ␉uint32_t␉reserved[77];␉␉// make sizeof == 512␊ |
172 | ␊ |
173 | ␉uint32_t␉␉fileExtentMapSize;␊ |
174 | ␉IOPolledFileExtent␉fileExtentMap[2];␊ |
175 | };␊ |
176 | typedef struct IOHibernateImageHeaderSnow IOHibernateImageHeaderSnow;␊ |
177 | ␊ |
178 | enum␊ |
179 | {␊ |
180 | ␉kIOHibernateDebugRestoreLogs = 0x00000001␊ |
181 | };␊ |
182 | ␊ |
183 | // options & IOHibernateOptions property␊ |
184 | enum␊ |
185 | {␊ |
186 | ␉kIOHibernateOptionSSD = 0x00000001,␊ |
187 | ␉kIOHibernateOptionColor = 0x00000002,␊ |
188 | ␉kIOHibernateOptionProgress = 0x00000004,␊ |
189 | ␉kIOHibernateOptionDarkWake = 0x00000008,␊ |
190 | };␊ |
191 | ␊ |
192 | struct hibernate_bitmap_t␊ |
193 | {␊ |
194 | ␉uint32_t␉first_page;␊ |
195 | ␉uint32_t␉last_page;␊ |
196 | ␉uint32_t␉bitmapwords;␊ |
197 | ␉uint32_t␉bitmap[0];␊ |
198 | };␊ |
199 | typedef struct hibernate_bitmap_t hibernate_bitmap_t;␊ |
200 | ␊ |
201 | struct hibernate_page_list_t␊ |
202 | {␊ |
203 | ␉uint32_t␉␉ list_size;␊ |
204 | ␉uint32_t␉␉ page_count;␊ |
205 | ␉uint32_t␉␉ bank_count;␊ |
206 | ␉hibernate_bitmap_t bank_bitmap[0];␊ |
207 | };␊ |
208 | typedef struct hibernate_page_list_t hibernate_page_list_t;␊ |
209 | ␊ |
210 | #if defined(_AES_H)␊ |
211 | ␊ |
212 | struct hibernate_cryptwakevars_t␊ |
213 | {␊ |
214 | ␉uint8_t aes_iv[AES_BLOCK_SIZE];␊ |
215 | };␊ |
216 | typedef struct hibernate_cryptwakevars_t hibernate_cryptwakevars_t;␊ |
217 | ␊ |
218 | struct hibernate_cryptvars_t␊ |
219 | {␊ |
220 | ␉uint8_t aes_iv[AES_BLOCK_SIZE];␊ |
221 | ␉aes_ctx ctx;␊ |
222 | };␊ |
223 | typedef struct hibernate_cryptvars_t hibernate_cryptvars_t;␊ |
224 | ␊ |
225 | #endif /* defined(_AES_H) */␊ |
226 | ␊ |
227 | enum␊ |
228 | {␊ |
229 | kIOHibernateHandoffType = 0x686f0000,␊ |
230 | kIOHibernateHandoffTypeEnd = kIOHibernateHandoffType + 0,␊ |
231 | kIOHibernateHandoffTypeGraphicsInfo = kIOHibernateHandoffType + 1,␊ |
232 | kIOHibernateHandoffTypeCryptVars = kIOHibernateHandoffType + 2,␊ |
233 | kIOHibernateHandoffTypeMemoryMap = kIOHibernateHandoffType + 3,␊ |
234 | kIOHibernateHandoffTypeDeviceTree = kIOHibernateHandoffType + 4,␊ |
235 | kIOHibernateHandoffTypeDeviceProperties = kIOHibernateHandoffType + 5,␊ |
236 | kIOHibernateHandoffTypeKeyStore = kIOHibernateHandoffType + 6,␊ |
237 | };␊ |
238 | ␊ |
239 | struct IOHibernateHandoff␊ |
240 | {␊ |
241 | uint32_t type;␊ |
242 | uint32_t bytecount;␊ |
243 | uint8_t data[];␊ |
244 | };␊ |
245 | typedef struct IOHibernateHandoff IOHibernateHandoff;␊ |
246 | ␊ |
247 | enum␊ |
248 | {␊ |
249 | ␉kIOHibernateProgressCount = 19,␊ |
250 | ␉kIOHibernateProgressWidth = 7,␊ |
251 | ␉kIOHibernateProgressHeight = 16,␊ |
252 | ␉kIOHibernateProgressSpacing = 3,␊ |
253 | ␉kIOHibernateProgressOriginY = 81,␊ |
254 | ␊ |
255 | ␉kIOHibernateProgressSaveUnderSize = 2*5+14*2,␊ |
256 | ␊ |
257 | ␉kIOHibernateProgressLightGray = 230,␊ |
258 | ␉kIOHibernateProgressMidGray = 174,␊ |
259 | ␉kIOHibernateProgressDarkGray = 92␊ |
260 | };␊ |
261 | ␊ |
262 | enum␊ |
263 | {␊ |
264 | ␉kIOHibernatePostWriteSleep = 0,␊ |
265 | ␉kIOHibernatePostWriteWake = 1,␊ |
266 | ␉kIOHibernatePostWriteHalt = 2,␊ |
267 | ␉kIOHibernatePostWriteRestart = 3␊ |
268 | };␊ |
269 | ␊ |
270 | ␊ |
271 | struct hibernate_graphics_t␊ |
272 | {␊ |
273 | ␉uint32_t physicalAddress;␉// Base address of video memory␊ |
274 | ␉int32_t gfxStatus;␉␉// EFI config restore status␊ |
275 | ␉uint32_t mode;␉␉␉// ␊ |
276 | ␉uint32_t rowBytes; ␉␉// Number of bytes per pixel row␊ |
277 | ␉uint32_t width; ␉␉// Width␊ |
278 | ␉uint32_t height; ␉␉// Height␊ |
279 | ␉uint32_t depth; ␉␉// Pixel Depth␊ |
280 | ␊ |
281 | ␉uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize];␊ |
282 | };␊ |
283 | typedef struct hibernate_graphics_t hibernate_graphics_t;␊ |
284 | ␊ |
285 | #define DECLARE_IOHIBERNATEPROGRESSALPHA␉␉␉␉\␊ |
286 | static const uint8_t gIOHibernateProgressAlpha␉␉␉\␊ |
287 | [kIOHibernateProgressHeight][kIOHibernateProgressWidth] = ␉\␊ |
288 | {␉␉␉␉␉␉␉␉\␊ |
289 | ␉{ 0x00,0x63,0xd8,0xf0,0xd8,0x63,0x00 },␉␉␉\␊ |
290 | ␉{ 0x51,0xff,0xff,0xff,0xff,0xff,0x51 },␉␉␉\␊ |
291 | ␉{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },␉␉␉\␊ |
292 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
293 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
294 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
295 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
296 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
297 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
298 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
299 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
300 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
301 | ␉{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },␉␉␉\␊ |
302 | ␉{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },␉␉␉\␊ |
303 | ␉{ 0x54,0xff,0xff,0xff,0xff,0xff,0x54 },␉␉␉\␊ |
304 | ␉{ 0x00,0x66,0xdb,0xf3,0xdb,0x66,0x00 }␉␉␉\␊ |
305 | };␊ |
306 | ␊ |
307 | struct hibernate_preview_t␊ |
308 | {␊ |
309 | ␉uint32_t imageCount;␉// Number of images␊ |
310 | ␉uint32_t width; ␉// Width␊ |
311 | ␉uint32_t height; ␉// Height␊ |
312 | ␉uint32_t depth; ␉// Pixel Depth␊ |
313 | ␉uint32_t lockTime; // Lock time␊ |
314 | ␉uint32_t reservedG[8]; // reserved␊ |
315 | ␉uint32_t reservedK[8]; // reserved␊ |
316 | };␊ |
317 | typedef struct hibernate_preview_t hibernate_preview_t;␊ |
318 | ␊ |
319 | struct hibernate_statistics_t␊ |
320 | {␊ |
321 | ␉uint64_t image1Size;␊ |
322 | ␉uint64_t imageSize;␊ |
323 | ␉uint32_t image1Pages;␊ |
324 | ␉uint32_t imagePages;␊ |
325 | ␉uint32_t booterStart;␊ |
326 | ␉uint32_t smcStart;␊ |
327 | ␉uint32_t booterDuration;␊ |
328 | ␉uint32_t booterConnectDisplayDuration;␊ |
329 | ␉uint32_t booterSplashDuration;␊ |
330 | ␉uint32_t booterDuration0;␊ |
331 | ␉uint32_t booterDuration1;␊ |
332 | ␉uint32_t booterDuration2;␊ |
333 | ␉uint32_t trampolineDuration;␊ |
334 | ␉uint32_t kernelImageReadDuration;␊ |
335 | ␊ |
336 | ␉uint32_t graphicsReadyTime;␊ |
337 | ␉uint32_t wakeNotificationTime;␊ |
338 | ␉uint32_t lockScreenReadyTime;␊ |
339 | ␉uint32_t hidReadyTime;␊ |
340 | ␊ |
341 | ␉uint32_t wakeCapability;␊ |
342 | ␉uint32_t resvA[15];␊ |
343 | };␊ |
344 | ␉typedef struct hibernate_statistics_t hibernate_statistics_t;␊ |
345 | ␊ |
346 | #define kIOSysctlHibernateStatistics␉"kern.hibernatestatistics"␊ |
347 | #define kIOSysctlHibernateGraphicsReady␉"kern.hibernategraphicsready"␊ |
348 | #define kIOSysctlHibernateWakeNotify␉"kern.hibernatewakenotification"␊ |
349 | #define kIOSysctlHibernateScreenReady␉"kern.hibernatelockscreenready"␊ |
350 | #define kIOSysctlHibernateHIDReady␉"kern.hibernatehidready"␊ |
351 | ␊ |
352 | #ifdef KERNEL␊ |
353 | ␊ |
354 | #ifdef __cplusplus␊ |
355 | ␊ |
356 | void IOHibernateSystemInit(IOPMrootDomain * rootDomain);␊ |
357 | ␊ |
358 | IOReturn IOHibernateSystemSleep(void);␊ |
359 | IOReturn IOHibernateIOKitSleep(void);␊ |
360 | IOReturn IOHibernateSystemHasSlept(void);␊ |
361 | IOReturn IOHibernateSystemWake(void);␊ |
362 | IOReturn IOHibernateSystemPostWake(void);␊ |
363 | bool IOHibernateWasScreenLocked(void);␊ |
364 | void IOHibernateSetScreenLocked(uint32_t lockState);␊ |
365 | void IOHibernateSetWakeCapabilities(uint32_t capability);␊ |
366 | void IOHibernateSystemRestart(void);␊ |
367 | ␊ |
368 | #endif /* __cplusplus */␊ |
369 | ␊ |
370 | #ifdef _SYS_CONF_H_␊ |
371 | typedef void (*kern_get_file_extents_callback_t)(void * ref, uint64_t start, uint64_t size);␊ |
372 | ␊ |
373 | struct kern_direct_file_io_ref_t *␊ |
374 | kern_open_file_for_direct_io(const char * name,␊ |
375 | ␉␉␉␉kern_get_file_extents_callback_t callback,␊ |
376 | ␉␉␉␉void * callback_ref,␊ |
377 | ␊ |
378 | ␉␉␉␉off_t set_file_size,␊ |
379 | ␊ |
380 | ␉␉␉␉off_t write_file_offset,␊ |
381 | ␉␉␉␉caddr_t write_file_addr,␊ |
382 | ␉␉␉␉vm_size_t write_file_len,␊ |
383 | ␊ |
384 | ␉␉␉␉dev_t * partition_device_result,␊ |
385 | ␉␉␉␉dev_t * image_device_result,␊ |
386 | ␉␉␉␉uint64_t * partitionbase_result,␊ |
387 | ␉␉␉␉uint64_t * maxiocount_result,␊ |
388 | ␉␉␉␉uint32_t * oflags);␊ |
389 | void␊ |
390 | kern_close_file_for_direct_io(struct kern_direct_file_io_ref_t * ref,␊ |
391 | off_t write_offset, caddr_t addr, vm_size_t write_length,␊ |
392 | off_t discard_offset, off_t discard_end);␊ |
393 | #endif /* _SYS_CONF_H_ */␊ |
394 | ␊ |
395 | hibernate_page_list_t *␊ |
396 | hibernate_page_list_allocate(boolean_t log);␊ |
397 | ␊ |
398 | kern_return_t␊ |
399 | hibernate_alloc_page_lists(␊ |
400 | hibernate_page_list_t ** page_list_ret,␊ |
401 | hibernate_page_list_t ** page_list_wired_ret,␊ |
402 | hibernate_page_list_t ** page_list_pal_ret);␊ |
403 | ␊ |
404 | kern_return_t␊ |
405 | hibernate_setup(IOHibernateImageHeader * header,␊ |
406 | ␉␉␉uint32_t free_page_ratio,␊ |
407 | ␉␉␉uint32_t free_page_time,␊ |
408 | ␉␉␉boolean_t vmflush,␊ |
409 | ␉␉␉hibernate_page_list_t * page_list,␊ |
410 | ␉␉␉hibernate_page_list_t * page_list_wired,␊ |
411 | ␉␉␉hibernate_page_list_t * page_list_pal);␊ |
412 | ␊ |
413 | kern_return_t␊ |
414 | hibernate_teardown(hibernate_page_list_t * page_list,␊ |
415 | ␉␉␉hibernate_page_list_t * page_list_wired,␊ |
416 | ␉␉␉hibernate_page_list_t * page_list_pal);␊ |
417 | ␊ |
418 | kern_return_t␊ |
419 | hibernate_processor_setup(IOHibernateImageHeader * header);␊ |
420 | ␊ |
421 | void␊ |
422 | hibernate_gobble_pages(uint32_t gobble_count, uint32_t free_page_time);␊ |
423 | void␊ |
424 | hibernate_free_gobble_pages(void);␊ |
425 | ␊ |
426 | void␊ |
427 | hibernate_vm_lock_queues(void);␊ |
428 | void␊ |
429 | hibernate_vm_unlock_queues(void);␊ |
430 | ␊ |
431 | void␊ |
432 | hibernate_vm_lock(void);␊ |
433 | void␊ |
434 | hibernate_vm_unlock(void);␊ |
435 | ␊ |
436 | // mark pages not to be saved, based on VM system accounting␊ |
437 | void␊ |
438 | hibernate_page_list_setall(hibernate_page_list_t * page_list,␊ |
439 | ␉␉␉ hibernate_page_list_t * page_list_wired,␊ |
440 | ␉␉␉ hibernate_page_list_t * page_list_pal,␊ |
441 | ␉␉␉ boolean_t preflight,␊ |
442 | ␉␉␉ boolean_t discard_all,␊ |
443 | ␉␉␉ uint32_t * pagesOut);␊ |
444 | ␊ |
445 | // mark pages to be saved, or pages not to be saved but available␊ |
446 | // for scratch usage during restore␊ |
447 | void␊ |
448 | hibernate_page_list_setall_machine(hibernate_page_list_t * page_list,␊ |
449 | hibernate_page_list_t * page_list_wired,␊ |
450 | boolean_t preflight,␊ |
451 | uint32_t * pagesOut);␊ |
452 | ␊ |
453 | // mark pages not to be saved and not for scratch usage during restore␊ |
454 | void␊ |
455 | hibernate_page_list_set_volatile( hibernate_page_list_t * page_list,␊ |
456 | ␉␉␉␉ hibernate_page_list_t * page_list_wired,␊ |
457 | ␉␉␉␉ uint32_t * pagesOut);␊ |
458 | ␊ |
459 | void␊ |
460 | hibernate_page_list_discard(hibernate_page_list_t * page_list);␊ |
461 | ␊ |
462 | int␊ |
463 | hibernate_should_abort(void);␊ |
464 | ␊ |
465 | void␊ |
466 | hibernate_set_page_state(hibernate_page_list_t * page_list, hibernate_page_list_t * page_list_wired,␊ |
467 | ␉␉␉␉vm_offset_t ppnum, vm_offset_t count, uint32_t kind);␊ |
468 | ␊ |
469 | void␊ |
470 | hibernate_page_bitset(hibernate_page_list_t * list, boolean_t set, uint32_t page);␊ |
471 | ␊ |
472 | boolean_t␊ |
473 | hibernate_page_bittst(hibernate_page_list_t * list, uint32_t page);␊ |
474 | ␊ |
475 | hibernate_bitmap_t *␊ |
476 | hibernate_page_bitmap_pin(hibernate_page_list_t * list, uint32_t * page);␊ |
477 | ␊ |
478 | uint32_t␊ |
479 | hibernate_page_bitmap_count(hibernate_bitmap_t * bitmap, uint32_t set, uint32_t page);␊ |
480 | ␊ |
481 | uintptr_t ␊ |
482 | hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags);␊ |
483 | ␊ |
484 | void␊ |
485 | hibernate_machine_init(void);␊ |
486 | ␊ |
487 | uint32_t␊ |
488 | hibernate_write_image(void);␊ |
489 | ␊ |
490 | long␊ |
491 | hibernate_machine_entrypoint(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4);␊ |
492 | long␊ |
493 | hibernate_kernel_entrypoint(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4);␊ |
494 | void␊ |
495 | hibernate_newruntime_map(void * map, vm_size_t map_size, ␊ |
496 | ␉␉␉ uint32_t system_table_offset);␊ |
497 | ␊ |
498 | ␊ |
499 | extern uint32_t gIOHibernateState;␊ |
500 | extern uint32_t gIOHibernateMode;␊ |
501 | extern uint32_t gIOHibernateDebugFlags;␊ |
502 | extern uint32_t gIOHibernateFreeTime;␉// max time to spend freeing pages (ms)␊ |
503 | extern uint8_t gIOHibernateRestoreStack[];␊ |
504 | extern uint8_t gIOHibernateRestoreStackEnd[];␊ |
505 | extern IOHibernateImageHeader * gIOHibernateCurrentHeader;␊ |
506 | extern hibernate_graphics_t * gIOHibernateGraphicsInfo;␊ |
507 | extern hibernate_cryptwakevars_t * gIOHibernateCryptWakeVars;␊ |
508 | ␊ |
509 | #define HIBLOG(fmt, args...)␉\␊ |
510 | ␉{ kprintf(fmt, ## args); printf(fmt, ## args); }␊ |
511 | ␊ |
512 | #define HIBPRINT(fmt, args...)␉\␊ |
513 | ␉{ kprintf(fmt, ## args); }␊ |
514 | ␊ |
515 | #endif /* KERNEL */␊ |
516 | ␊ |
517 | // gIOHibernateState, kIOHibernateStateKey␊ |
518 | enum␊ |
519 | {␊ |
520 | ␉kIOHibernateStateInactive = 0,␊ |
521 | ␉kIOHibernateStateHibernating ␉ = 1,␉/* writing image */␊ |
522 | ␉kIOHibernateStateWakingFromHibernate = 2␉/* booted and restored image */␊ |
523 | };␊ |
524 | ␊ |
525 | // gIOHibernateMode, kIOHibernateModeKey␊ |
526 | enum␊ |
527 | {␊ |
528 | ␉kIOHibernateModeOn␉␉␉= 0x00000001,␊ |
529 | ␉kIOHibernateModeSleep␉␉␉= 0x00000002,␊ |
530 | ␉kIOHibernateModeEncrypt␉␉␉= 0x00000004,␊ |
531 | ␉kIOHibernateModeDiscardCleanInactive␉= 0x00000008,␊ |
532 | ␉kIOHibernateModeDiscardCleanActive␉= 0x00000010,␊ |
533 | ␉kIOHibernateModeSwitch␉␉␉= 0x00000020,␊ |
534 | ␉kIOHibernateModeRestart␉␉␉= 0x00000040,␊ |
535 | ␉kIOHibernateModeSSDInvert␉␉= 0x00000080,␊ |
536 | ␉kIOHibernateModeFileResize␉␉= 0x00000100,␊ |
537 | };␊ |
538 | ␊ |
539 | // IOHibernateImageHeader.signature␊ |
540 | enum␊ |
541 | {␊ |
542 | ␉kIOHibernateHeaderSignature = 0x73696d65,␊ |
543 | ␉kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a␊ |
544 | };␊ |
545 | ␊ |
546 | // kind for hibernate_set_page_state()␊ |
547 | enum␊ |
548 | {␊ |
549 | ␉kIOHibernatePageStateFree = 0,␊ |
550 | ␉kIOHibernatePageStateWiredSave = 1,␊ |
551 | ␉kIOHibernatePageStateUnwiredSave = 2␊ |
552 | };␊ |
553 | ␊ |
554 | #define kIOHibernateModeKey␉␉"Hibernate Mode"␊ |
555 | #define kIOHibernateFileKey␉␉"Hibernate File"␊ |
556 | #define kIOHibernateFileMinSizeKey␉"Hibernate File Min"␊ |
557 | #define kIOHibernateFileMaxSizeKey␉"Hibernate File Max"␊ |
558 | #define kIOHibernateFreeRatioKey␉"Hibernate Free Ratio"␊ |
559 | #define kIOHibernateFreeTimeKey␉␉"Hibernate Free Time"␊ |
560 | ␊ |
561 | #define kIOHibernateStateKey␉␉"IOHibernateState"␊ |
562 | #define kIOHibernateFeatureKey␉␉"Hibernation"␊ |
563 | #define kIOHibernatePreviewBufferKey␉"IOPreviewBuffer"␊ |
564 | ␊ |
565 | #ifndef kIOHibernatePreviewActiveKey␊ |
566 | #define kIOHibernatePreviewActiveKey␉"IOHibernatePreviewActive"␊ |
567 | // values for kIOHibernatePreviewActiveKey␊ |
568 | enum {␊ |
569 | ␉kIOHibernatePreviewActive = 0x00000001,␊ |
570 | ␉kIOHibernatePreviewUpdates = 0x00000002␊ |
571 | };␊ |
572 | #endif␊ |
573 | ␊ |
574 | #define kIOHibernateOptionsKey "IOHibernateOptions"␊ |
575 | #define kIOHibernateGfxStatusKey "IOHibernateGfxStatus"␊ |
576 | enum {␊ |
577 | ␉kIOHibernateGfxStatusUnknown = ((int32_t) 0xFFFFFFFF)␊ |
578 | };␊ |
579 | ␊ |
580 | #define kIOHibernateBootImageKey␉"boot-image"␊ |
581 | #define kIOHibernateBootImageKeyKey␉"boot-image-key"␊ |
582 | #define kIOHibernateBootSignatureKey␉"boot-signature"␊ |
583 | ␊ |
584 | #define kIOHibernateMemorySignatureKey␉ "memory-signature"␊ |
585 | #define kIOHibernateMemorySignatureEnvKey "mem-sig"␊ |
586 | #define kIOHibernateMachineSignatureKey␉ "machine-signature"␊ |
587 | ␊ |
588 | #define kIOHibernateRTCVariablesKey␉"IOHibernateRTCVariables"␊ |
589 | #define kIOHibernateSMCVariablesKey␉"IOHibernateSMCVariables"␊ |
590 | ␊ |
591 | #define kIOHibernateBootSwitchVarsKey␉"boot-switch-vars"␊ |
592 | ␊ |
593 | #define kIOHibernateBootNoteKey␉␉"boot-note"␊ |
594 | ␊ |
595 | #define kIOHibernateUseKernelInterpreter 0x80000000␊ |
596 | ␊ |
597 | enum {␊ |
598 | ␉kIOPreviewImageIndexDesktop = 0, ␊ |
599 | ␉kIOPreviewImageIndexLockScreen = 1, ␊ |
600 | ␉kIOPreviewImageCount = 2␊ |
601 | };␊ |
602 | ␊ |
603 | enum {␊ |
604 | ␉kIOScreenLockNoLock = 1,␊ |
605 | ␉kIOScreenLockUnlocked = 2,␊ |
606 | ␉kIOScreenLockLocked = 3,␊ |
607 | ␉kIOScreenLockFileVaultDialog = 4,␊ |
608 | };␊ |
609 | ␊ |
610 | #define kIOScreenLockStateKey "IOScreenLockState"␊ |
611 | ␊ |
612 | #endif /* ! __IOKIT_IOHIBERNATEPRIVATE_H */␊ |
613 | ␊ |
614 | #ifdef __cplusplus␊ |
615 | }␊ |
616 | #endif␊ |
617 | |