]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/IOHibernatePrivate.h
xnu-4570.71.2.tar.gz
[apple/xnu.git] / iokit / IOKit / IOHibernatePrivate.h
index da180376c113f5ec9f81a759beb9d70146303f03..b6f3b7f62a39822b2d17d7431bdc8b332c97c6b3 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- * 
+ *
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
  * unlawful or unlicensed copies of an Apple operating system, or to
  * circumvent, violate, or enable the circumvention or violation of, any
  * terms of an Apple operating system software license agreement.
- * 
+ *
  * Please obtain a copy of the License at
  * http://www.opensource.apple.com/apsl/ and read it before using this file.
- * 
+ *
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
@@ -22,7 +22,7 @@
  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  * Please see the License for the specific language governing rights and
  * limitations under the License.
- * 
+ *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 
@@ -35,6 +35,9 @@ extern "C" {
 #ifdef KERNEL
 #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
@@ -51,14 +54,14 @@ struct IOHibernateImageHeader
 {
     uint64_t   imageSize;
     uint64_t   image1Size;
-    
+
     uint32_t   restore1CodePhysPage;
     uint32_t    reserved1;
     uint64_t   restore1CodeVirt;
     uint32_t   restore1PageCount;
     uint32_t   restore1CodeOffset;
     uint32_t   restore1StackOffset;
-    
+
     uint32_t   pageCount;
     uint32_t   bitmapSize;
 
@@ -83,7 +86,7 @@ struct IOHibernateImageHeader
 
     uint32_t    performanceDataStart;
     uint32_t    performanceDataSize;
-    
+
     uint64_t   encryptStart __attribute__ ((packed));
     uint64_t   machineSignature __attribute__ ((packed));
 
@@ -102,10 +105,23 @@ struct IOHibernateImageHeader
     uint32_t   sleepTime;
     uint32_t    compression;
 
-    uint32_t   reserved[68];           // make sizeof == 512
+    uint8_t     bridgeBootSessionUUID[16];
+
+    uint32_t   reserved[54];           // 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];
@@ -124,6 +140,7 @@ enum
     kIOHibernateOptionColor         = 0x00000002,
     kIOHibernateOptionProgress      = 0x00000004,
     kIOHibernateOptionDarkWake      = 0x00000008,
+    kIOHibernateOptionHWEncrypt     = 0x00000010,
 };
 
 struct hibernate_bitmap_t
@@ -161,7 +178,7 @@ typedef struct hibernate_cryptvars_t hibernate_cryptvars_t;
 
 #endif /* defined(_AES_H) */
 
-enum 
+enum
 {
     kIOHibernateHandoffType                 = 0x686f0000,
     kIOHibernateHandoffTypeEnd              = kIOHibernateHandoffType + 0,
@@ -171,6 +188,7 @@ enum
     kIOHibernateHandoffTypeDeviceTree       = kIOHibernateHandoffType + 4,
     kIOHibernateHandoffTypeDeviceProperties = kIOHibernateHandoffType + 5,
     kIOHibernateHandoffTypeKeyStore         = kIOHibernateHandoffType + 6,
+    kIOHibernateHandoffTypeVolumeCryptKey   = kIOHibernateHandoffType + 7,
 };
 
 struct IOHibernateHandoff
@@ -181,7 +199,7 @@ struct IOHibernateHandoff
 };
 typedef struct IOHibernateHandoff IOHibernateHandoff;
 
-enum 
+enum
 {
     kIOHibernateProgressCount         = 19,
     kIOHibernateProgressWidth         = 7,
@@ -207,7 +225,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
@@ -252,6 +270,39 @@ struct hibernate_preview_t
 };
 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
@@ -259,58 +310,48 @@ typedef struct hibernate_preview_t hibernate_preview_t;
 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);
+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,
-
-                             off_t set_file_size,
-
-                             off_t write_file_offset,
-                             caddr_t write_file_addr,
-                             vm_size_t write_file_len,
-
-                            dev_t * partition_device_result,
-                            dev_t * image_device_result,
-                             uint64_t * partitionbase_result,
-                             uint64_t * maxiocount_result,
-                             uint32_t * oflags);
 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(boolean_t log);
 
-kern_return_t 
+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);
-kern_return_t 
+                       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_pal);
 
-kern_return_t 
+kern_return_t
+hibernate_pin_swap(boolean_t begin);
+
+kern_return_t
 hibernate_processor_setup(IOHibernateImageHeader * header);
 
 void
@@ -327,6 +368,10 @@ 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
@@ -334,9 +379,10 @@ 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 
+// mark pages to be saved, or pages not to be saved but available
 // for scratch usage during restore
 void
 hibernate_page_list_setall_machine(hibernate_page_list_t * page_list,
@@ -360,10 +406,10 @@ 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);
 
-void 
+void
 hibernate_page_bitset(hibernate_page_list_t * list, boolean_t set, uint32_t page);
 
-boolean_t 
+boolean_t
 hibernate_page_bittst(hibernate_page_list_t * list, uint32_t page);
 
 hibernate_bitmap_t *
@@ -372,7 +418,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);
 
-uintptr_t 
+uintptr_t
 hibernate_restore_phys_page(uint64_t src, uint64_t dst, uint32_t len, uint32_t procFlags);
 
 void
@@ -386,7 +432,7 @@ hibernate_machine_entrypoint(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4)
 long
 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, 
+hibernate_newruntime_map(void * map, vm_size_t map_size,
                            uint32_t system_table_offset);
 
 
@@ -394,15 +440,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 */
 
@@ -432,7 +483,9 @@ enum
 enum
 {
     kIOHibernateHeaderSignature        = 0x73696d65,
-    kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a
+    kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a,
+    kIOHibernateHeaderOpenSignature    = 0xf1e0be9d,
+    kIOHibernateHeaderDebugDataSignature = 0xfcddfcdd
 };
 
 // kind for hibernate_set_page_state()
@@ -489,8 +542,8 @@ enum {
 
 enum
 {
-       kIOPreviewImageIndexDesktop = 0, 
-       kIOPreviewImageIndexLockScreen = 1, 
+       kIOPreviewImageIndexDesktop = 0,
+       kIOPreviewImageIndexLockScreen = 1,
        kIOPreviewImageCount = 2
 };
 
@@ -500,9 +553,10 @@ enum
        kIOScreenLockUnlocked        = 2,
        kIOScreenLockLocked          = 3,
        kIOScreenLockFileVaultDialog = 4,
-};     
+};
 
-#define kIOScreenLockStateKey      "IOScreenLockState"
+#define kIOScreenLockStateKey       "IOScreenLockState"
+#define kIOBooterScreenLockStateKey "IOBooterScreenLockState"
 
 #endif /* ! __IOKIT_IOHIBERNATEPRIVATE_H */