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