X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..3903760236c30e3b5ace7a4eefac3a269d68957c:/iokit/IOKit/IOHibernatePrivate.h diff --git a/iokit/IOKit/IOHibernatePrivate.h b/iokit/IOKit/IOHibernatePrivate.h index ab897a850..ee9139154 100644 --- a/iokit/IOKit/IOHibernatePrivate.h +++ b/iokit/IOKit/IOHibernatePrivate.h @@ -33,9 +33,13 @@ extern "C" { #endif #ifdef KERNEL -#include +#include +#include #endif +#ifndef __IOKIT_IOHIBERNATEPRIVATE_H +#define __IOKIT_IOHIBERNATEPRIVATE_H + struct IOPolledFileExtent { uint64_t start; @@ -48,7 +52,9 @@ struct IOHibernateImageHeader uint64_t imageSize; uint64_t image1Size; - uint32_t restore1CodePage; + uint32_t restore1CodePhysPage; + uint32_t reserved1; + uint64_t restore1CodeVirt; uint32_t restore1PageCount; uint32_t restore1CodeOffset; uint32_t restore1StackOffset; @@ -73,30 +79,63 @@ struct IOHibernateImageHeader uint32_t runtimePages; uint32_t runtimePageCount; + uint64_t runtimeVirtualPages __attribute__ ((packed)); - uint8_t reserved2[16]; + uint32_t performanceDataStart; + uint32_t performanceDataSize; - uint64_t encryptStart; - uint64_t machineSignature; + uint64_t encryptStart __attribute__ ((packed)); + uint64_t machineSignature __attribute__ ((packed)); uint32_t previewSize; uint32_t previewPageListSize; uint32_t diag[4]; - int32_t graphicsInfoOffset; - int32_t cryptVarsOffset; - int32_t memoryMapOffset; - uint32_t memoryMapSize; + uint32_t handoffPages; + uint32_t handoffPageCount; + uint32_t systemTableOffset; - uint32_t reserved[77]; // make sizeof == 512 + uint32_t debugFlags; + uint32_t options; + uint32_t sleepTime; + uint32_t compression; + + uint32_t reserved[58]; // make sizeof == 512 + uint32_t booterTime0; + uint32_t booterTime1; + uint32_t booterTime2; + + uint32_t booterStart; + uint32_t smcStart; + uint32_t connectDisplayTime; + uint32_t splashTime; + uint32_t booterTime; + uint32_t trampolineTime; + + uint64_t encryptEnd __attribute__ ((packed)); + uint64_t deviceBase __attribute__ ((packed)); + uint32_t deviceBlockSize; uint32_t fileExtentMapSize; IOPolledFileExtent fileExtentMap[2]; }; typedef struct IOHibernateImageHeader IOHibernateImageHeader; +enum +{ + kIOHibernateDebugRestoreLogs = 0x00000001 +}; + +// options & IOHibernateOptions property +enum +{ + kIOHibernateOptionSSD = 0x00000001, + kIOHibernateOptionColor = 0x00000002, + kIOHibernateOptionProgress = 0x00000004, + kIOHibernateOptionDarkWake = 0x00000008, +}; struct hibernate_bitmap_t { @@ -133,6 +172,25 @@ typedef struct hibernate_cryptvars_t hibernate_cryptvars_t; #endif /* defined(_AES_H) */ +enum +{ + kIOHibernateHandoffType = 0x686f0000, + kIOHibernateHandoffTypeEnd = kIOHibernateHandoffType + 0, + kIOHibernateHandoffTypeGraphicsInfo = kIOHibernateHandoffType + 1, + kIOHibernateHandoffTypeCryptVars = kIOHibernateHandoffType + 2, + kIOHibernateHandoffTypeMemoryMap = kIOHibernateHandoffType + 3, + kIOHibernateHandoffTypeDeviceTree = kIOHibernateHandoffType + 4, + kIOHibernateHandoffTypeDeviceProperties = kIOHibernateHandoffType + 5, + kIOHibernateHandoffTypeKeyStore = kIOHibernateHandoffType + 6, +}; + +struct IOHibernateHandoff +{ + uint32_t type; + uint32_t bytecount; + uint8_t data[]; +}; +typedef struct IOHibernateHandoff IOHibernateHandoff; enum { @@ -160,8 +218,8 @@ enum struct hibernate_graphics_t { - uint32_t physicalAddress; // Base address of video memory - uint32_t mode; // + uint64_t physicalAddress; // Base address of video memory + int32_t gfxStatus; // EFI config restore status uint32_t rowBytes; // Number of bytes per pixel row uint32_t width; // Width uint32_t height; // Height @@ -193,6 +251,51 @@ static const uint8_t gIOHibernateProgressAlpha \ { 0x00,0x66,0xdb,0xf3,0xdb,0x66,0x00 } \ }; +struct hibernate_preview_t +{ + uint32_t imageCount; // Number of images + uint32_t width; // Width + uint32_t height; // Height + uint32_t depth; // Pixel Depth + uint32_t lockTime; // Lock time + uint32_t reservedG[8]; // reserved + uint32_t reservedK[8]; // reserved +}; +typedef struct hibernate_preview_t hibernate_preview_t; + +struct hibernate_statistics_t +{ + uint64_t image1Size; + uint64_t imageSize; + uint32_t image1Pages; + uint32_t imagePages; + uint32_t booterStart; + uint32_t smcStart; + uint32_t booterDuration; + uint32_t booterConnectDisplayDuration; + uint32_t booterSplashDuration; + uint32_t booterDuration0; + uint32_t booterDuration1; + uint32_t booterDuration2; + uint32_t trampolineDuration; + uint32_t kernelImageReadDuration; + + uint32_t graphicsReadyTime; + uint32_t wakeNotificationTime; + uint32_t lockScreenReadyTime; + uint32_t hidReadyTime; + + uint32_t wakeCapability; + uint32_t resvA[15]; +}; +typedef struct hibernate_statistics_t hibernate_statistics_t; + +#define kIOSysctlHibernateStatistics "kern.hibernatestatistics" +#define kIOSysctlHibernateGraphicsReady "kern.hibernategraphicsready" +#define kIOSysctlHibernateWakeNotify "kern.hibernatewakenotification" +#define kIOSysctlHibernateScreenReady "kern.hibernatelockscreenready" +#define kIOSysctlHibernateHIDReady "kern.hibernatehidready" + #ifdef KERNEL #ifdef __cplusplus @@ -200,46 +303,60 @@ static const uint8_t gIOHibernateProgressAlpha \ void IOHibernateSystemInit(IOPMrootDomain * rootDomain); IOReturn IOHibernateSystemSleep(void); +void IOOpenDebugDataFile(const char *fname, uint64_t size); +void IOCloseDebugDataFile(); +IOReturn IOHibernateIOKitSleep(void); IOReturn IOHibernateSystemHasSlept(void); IOReturn IOHibernateSystemWake(void); IOReturn IOHibernateSystemPostWake(void); +bool IOHibernateWasScreenLocked(void); +void IOHibernateSetScreenLocked(uint32_t lockState); +void IOHibernateSetWakeCapabilities(uint32_t capability); +void IOHibernateSystemRestart(void); #endif /* __cplusplus */ -#ifdef _SYS_CONF_H_ -typedef void (*kern_get_file_extents_callback_t)(void * ref, uint64_t start, uint64_t size); - -struct kern_direct_file_io_ref_t * -kern_open_file_for_direct_io(const char * name, - kern_get_file_extents_callback_t callback, - void * callback_ref, - dev_t * device, - uint64_t * partitionbase_result, - uint64_t * maxiocount_result); void -kern_close_file_for_direct_io(struct kern_direct_file_io_ref_t * ref); -int -kern_write_file(struct kern_direct_file_io_ref_t * ref, off_t offset, caddr_t addr, vm_size_t len); -int get_kernel_symfile(struct proc *p, char const **symfile); -#endif /* _SYS_CONF_H_ */ +vm_compressor_do_warmup(void); + hibernate_page_list_t * -hibernate_page_list_allocate(void); +hibernate_page_list_allocate(boolean_t log); + +kern_return_t +hibernate_alloc_page_lists( + hibernate_page_list_t ** page_list_ret, + hibernate_page_list_t ** page_list_wired_ret, + hibernate_page_list_t ** page_list_pal_ret); kern_return_t hibernate_setup(IOHibernateImageHeader * header, - uint32_t free_page_ratio, - uint32_t free_page_time, - hibernate_page_list_t ** page_list_ret, - hibernate_page_list_t ** page_list_wired_ret, - boolean_t * encryptedswap); + boolean_t vmflush, + hibernate_page_list_t * page_list, + hibernate_page_list_t * page_list_wired, + hibernate_page_list_t * page_list_pal); + kern_return_t hibernate_teardown(hibernate_page_list_t * page_list, - hibernate_page_list_t * page_list_wired); + hibernate_page_list_t * page_list_wired, + hibernate_page_list_t * page_list_pal); + +kern_return_t +hibernate_pin_swap(boolean_t begin); kern_return_t hibernate_processor_setup(IOHibernateImageHeader * header); +void +hibernate_gobble_pages(uint32_t gobble_count, uint32_t free_page_time); +void +hibernate_free_gobble_pages(void); + +void +hibernate_vm_lock_queues(void); +void +hibernate_vm_unlock_queues(void); + void hibernate_vm_lock(void); void @@ -249,6 +366,9 @@ hibernate_vm_unlock(void); void hibernate_page_list_setall(hibernate_page_list_t * page_list, hibernate_page_list_t * page_list_wired, + hibernate_page_list_t * page_list_pal, + boolean_t preflight, + boolean_t discard_all, uint32_t * pagesOut); // mark pages to be saved, or pages not to be saved but available @@ -256,6 +376,7 @@ hibernate_page_list_setall(hibernate_page_list_t * page_list, void hibernate_page_list_setall_machine(hibernate_page_list_t * page_list, hibernate_page_list_t * page_list_wired, + boolean_t preflight, uint32_t * pagesOut); // mark pages not to be saved and not for scratch usage during restore @@ -267,6 +388,9 @@ hibernate_page_list_set_volatile( hibernate_page_list_t * page_list, void hibernate_page_list_discard(hibernate_page_list_t * page_list); +int +hibernate_should_abort(void); + void hibernate_set_page_state(hibernate_page_list_t * page_list, hibernate_page_list_t * page_list_wired, vm_offset_t ppnum, vm_offset_t count, uint32_t kind); @@ -283,7 +407,7 @@ hibernate_page_bitmap_pin(hibernate_page_list_t * list, uint32_t * page); uint32_t hibernate_page_bitmap_count(hibernate_bitmap_t * bitmap, uint32_t set, uint32_t page); -void +uintptr_t hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags); void @@ -293,9 +417,9 @@ uint32_t hibernate_write_image(void); long -hibernate_machine_entrypoint(IOHibernateImageHeader * header, void * p2, void * p3, void * p4); +hibernate_machine_entrypoint(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); long -hibernate_kernel_entrypoint(IOHibernateImageHeader * header, void * p2, void * p3, void * p4); +hibernate_kernel_entrypoint(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); void hibernate_newruntime_map(void * map, vm_size_t map_size, uint32_t system_table_offset); @@ -303,12 +427,12 @@ hibernate_newruntime_map(void * map, vm_size_t map_size, extern uint32_t gIOHibernateState; extern uint32_t gIOHibernateMode; +extern uint32_t gIOHibernateDebugFlags; extern uint32_t gIOHibernateFreeTime; // max time to spend freeing pages (ms) +extern boolean_t gIOHibernateStandbyDisabled; extern uint8_t gIOHibernateRestoreStack[]; extern uint8_t gIOHibernateRestoreStackEnd[]; extern IOHibernateImageHeader * gIOHibernateCurrentHeader; -extern hibernate_graphics_t * gIOHibernateGraphicsInfo; -extern hibernate_cryptwakevars_t * gIOHibernateCryptWakeVars; #define HIBLOG(fmt, args...) \ { kprintf(fmt, ## args); printf(fmt, ## args); } @@ -335,14 +459,18 @@ enum kIOHibernateModeDiscardCleanInactive = 0x00000008, kIOHibernateModeDiscardCleanActive = 0x00000010, kIOHibernateModeSwitch = 0x00000020, - kIOHibernateModeRestart = 0x00000040 + kIOHibernateModeRestart = 0x00000040, + kIOHibernateModeSSDInvert = 0x00000080, + kIOHibernateModeFileResize = 0x00000100, }; // IOHibernateImageHeader.signature enum { kIOHibernateHeaderSignature = 0x73696d65, - kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a + kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a, + kIOHibernateHeaderOpenSignature = 0xf1e0be9d, + kIOHibernateHeaderDebugDataSignature = 0xfcddfcdd }; // kind for hibernate_set_page_state() @@ -355,6 +483,8 @@ enum #define kIOHibernateModeKey "Hibernate Mode" #define kIOHibernateFileKey "Hibernate File" +#define kIOHibernateFileMinSizeKey "Hibernate File Min" +#define kIOHibernateFileMaxSizeKey "Hibernate File Max" #define kIOHibernateFreeRatioKey "Hibernate Free Ratio" #define kIOHibernateFreeTimeKey "Hibernate Free Time" @@ -362,12 +492,20 @@ enum #define kIOHibernateFeatureKey "Hibernation" #define kIOHibernatePreviewBufferKey "IOPreviewBuffer" +#ifndef kIOHibernatePreviewActiveKey #define kIOHibernatePreviewActiveKey "IOHibernatePreviewActive" // values for kIOHibernatePreviewActiveKey enum { kIOHibernatePreviewActive = 0x00000001, kIOHibernatePreviewUpdates = 0x00000002 }; +#endif + +#define kIOHibernateOptionsKey "IOHibernateOptions" +#define kIOHibernateGfxStatusKey "IOHibernateGfxStatus" +enum { + kIOHibernateGfxStatusUnknown = ((int32_t) 0xFFFFFFFF) +}; #define kIOHibernateBootImageKey "boot-image" #define kIOHibernateBootImageKeyKey "boot-image-key" @@ -378,9 +516,33 @@ enum { #define kIOHibernateMachineSignatureKey "machine-signature" #define kIOHibernateRTCVariablesKey "IOHibernateRTCVariables" +#define kIOHibernateSMCVariablesKey "IOHibernateSMCVariables" + +#define kIOHibernateBootSwitchVarsKey "boot-switch-vars" + +#define kIOHibernateBootNoteKey "boot-note" + + +#define kIOHibernateUseKernelInterpreter 0x80000000 + +enum +{ + kIOPreviewImageIndexDesktop = 0, + kIOPreviewImageIndexLockScreen = 1, + kIOPreviewImageCount = 2 +}; + +enum +{ + kIOScreenLockNoLock = 1, + kIOScreenLockUnlocked = 2, + kIOScreenLockLocked = 3, + kIOScreenLockFileVaultDialog = 4, +}; -#define kIOHibernateBootSwitchVarsKey "boot-switch-vars" +#define kIOScreenLockStateKey "IOScreenLockState" +#endif /* ! __IOKIT_IOHIBERNATEPRIVATE_H */ #ifdef __cplusplus }