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