]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOHibernatePrivate.h
xnu-4570.31.3.tar.gz
[apple/xnu.git] / iokit / IOKit / IOHibernatePrivate.h
index 0cc86a55ca0f86701ec9e2b23f6947044c9ddfc2..cf8aa46df175e0b1484bed6a87a3265c91bacb76 100644 (file)
@@ -33,10 +33,16 @@ extern "C" {
 #endif
 
 #ifdef KERNEL
-#include <crypto/aes.h>
+#include <libkern/crypto/aes.h>
 #include <uuid/uuid.h>
+#include <kern/debug.h>
+
+extern int kdb_printf(const char *format, ...) __printflike(1,2);
 #endif
 
+#ifndef __IOKIT_IOHIBERNATEPRIVATE_H
+#define __IOKIT_IOHIBERNATEPRIVATE_H
+
 struct IOPolledFileExtent
 {
     uint64_t   start;
@@ -96,11 +102,24 @@ struct IOHibernateImageHeader
 
     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   reserved[70];           // make sizeof == 512
+    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];
@@ -202,7 +221,7 @@ enum
 
 struct hibernate_graphics_t
 {
-    uint32_t physicalAddress;  // Base address of video memory
+    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
@@ -235,6 +254,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
@@ -242,48 +306,46 @@ 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);
+IOReturn IOHibernateSystemPostWake(bool now);
+uint32_t 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 * partition_device_result,
-                            dev_t * image_device_result,
-                             uint64_t * partitionbase_result,
-                             uint64_t * maxiocount_result,
-                             uint32_t * oflags,
-                             off_t offset,
-                             caddr_t addr,
-                             vm_size_t len);
 void
-kern_close_file_for_direct_io(struct kern_direct_file_io_ref_t * ref,
-                             off_t write_offset, caddr_t addr, vm_size_t write_length,
-                             off_t discard_offset, off_t discard_end);
-#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,
                         boolean_t vmflush,
-                       hibernate_page_list_t ** page_list_ret,
-                       hibernate_page_list_t ** page_list_wired_ret,
-                       hibernate_page_list_t ** page_list_pal_ret,
-                        boolean_t * encryptedswap);
+                       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);
@@ -293,16 +355,27 @@ 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
 hibernate_vm_unlock(void);
+void
+hibernate_vm_lock_end(void);
+boolean_t
+hibernate_vm_locks_are_safe(void);
 
 // mark pages not to be saved, based on VM system accounting
 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 
@@ -310,6 +383,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
@@ -362,15 +436,20 @@ 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;
 
+#define HIBLOGFROMPANIC(fmt, args...) \
+    { if (kernel_debugger_entry_count) { kdb_printf(fmt, ## args); } }
+
 #define HIBLOG(fmt, args...)   \
-    { kprintf(fmt, ## args); printf(fmt, ## args); }
+    { if (kernel_debugger_entry_count) { kdb_printf(fmt, ## args); } else { kprintf(fmt, ## args); printf(fmt, ## args); } }
 
 #define HIBPRINT(fmt, args...) \
-    { kprintf(fmt, ## args); }
+    { if (kernel_debugger_entry_count) { kdb_printf(fmt, ## args); } else { kprintf(fmt, ## args); } }
+
 
 #endif /* KERNEL */
 
@@ -393,13 +472,16 @@ enum
     kIOHibernateModeSwitch     = 0x00000020,
     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()
@@ -412,6 +494,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"
 
@@ -419,12 +503,14 @@ 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"
@@ -443,10 +529,33 @@ enum {
 #define kIOHibernateRTCVariablesKey    "IOHibernateRTCVariables"
 #define kIOHibernateSMCVariablesKey    "IOHibernateSMCVariables"
 
-#define kIOHibernateBootSwitchVarsKey                  "boot-switch-vars"
+#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 kIOScreenLockStateKey       "IOScreenLockState"
+#define kIOBooterScreenLockStateKey "IOBooterScreenLockState"
+
+#endif /* ! __IOKIT_IOHIBERNATEPRIVATE_H */
+
 #ifdef __cplusplus
 }
 #endif