]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOHibernateInternal.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOHibernateInternal.h
CommitLineData
3a60a9f5
A
1/*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
3a60a9f5
A
27 */
28
29#include <stdint.h>
f427ee49 30#include <IOKit/IOHibernatePrivate.h>
3a60a9f5
A
31
32#ifdef __cplusplus
33
f427ee49
A
34
35enum { kIOHibernateAESKeySize = 16 }; /* bytes */
36
f427ee49
A
37// srcBuffer has to be big enough for a source page, the WKDM
38// compressed output, and a scratch page needed by WKDM
39#define HIBERNATION_SRC_BUFFER_SIZE (2 * page_size + WKdm_SCRATCH_BUF_SIZE_INTERNAL)
3a60a9f5 40
0a7de745
A
41struct IOHibernateVars {
42 hibernate_page_list_t * page_list;
43 hibernate_page_list_t * page_list_wired;
44 hibernate_page_list_t * page_list_pal;
45 class IOBufferMemoryDescriptor * ioBuffer;
46 class IOBufferMemoryDescriptor * srcBuffer;
47 class IOBufferMemoryDescriptor * handoffBuffer;
48 class IOMemoryDescriptor * previewBuffer;
49 OSData * previewData;
50 OSObject * saveBootDevice;
3a60a9f5 51
0a7de745
A
52 struct IOPolledFileIOVars * fileVars;
53 uint64_t fileMinSize;
54 uint64_t fileMaxSize;
55 vm_offset_t videoMapping;
56 vm_size_t videoAllocSize;
57 vm_size_t videoMapSize;
58 uint8_t * consoleMapping;
59 uint8_t haveFastBoot;
60 uint8_t saveBootAudioVolume;
61 uint8_t hwEncrypt;
f427ee49
A
62 uint8_t wiredCryptKey[kIOHibernateAESKeySize];
63 uint8_t cryptKey[kIOHibernateAESKeySize];
0a7de745
A
64 size_t volumeCryptKeySize;
65 uint8_t volumeCryptKey[64];
3a60a9f5
A
66};
67typedef struct IOHibernateVars IOHibernateVars;
68
0a7de745 69#endif /* __cplusplus */
3a60a9f5 70
0a7de745
A
71enum{
72 kIOHibernateTagSignature = 0x53000000,
f427ee49 73 kIOHibernateTagLength = 0x00007fff,
3a60a9f5
A
74};
75
76#ifdef __cplusplus
77extern "C"
0a7de745 78#endif /* __cplusplus */
3a60a9f5 79uint32_t
0b4c1975 80hibernate_sum_page(uint8_t *buf, uint32_t ppnum);
3a60a9f5 81
f427ee49 82#if defined(__i386__) || defined(__x86_64__)
316670eb
A
83extern vm_offset_t segHIBB;
84extern unsigned long segSizeHIB;
f427ee49
A
85#elif defined(__arm64__)
86extern vm_offset_t sectHIBTEXTB;
87extern unsigned long sectSizeHIBTEXT;
88#endif
3a60a9f5 89
6d2010ae 90extern ppnum_t gIOHibernateHandoffPages[];
f427ee49
A
91extern const uint32_t gIOHibernateHandoffPageCount;
92
93// max address that can fit in a ppnum_t
94#define IO_MAX_PAGE_ADDR (((uint64_t) UINT_MAX) << PAGE_SHIFT)
95// atop() returning ppnum_t
96#define atop_64_ppnum(x) ((ppnum_t)((uint64_t)(x) >> PAGE_SHIFT))