Chameleon

Chameleon Commit Details

Date:2014-02-01 00:35:05 (5 years 4 months ago)
Author:ErmaC
Commit:2364
Parents: 2363
Message:Update header and apply Vladimir Zidar's patch http://forge.voodooprojects.org/p/chameleon/issues/133/
Changes:
M/branches/ErmaC/Enoch/i386/boot2/IOHibernatePrivate.h
M/branches/ErmaC/Enoch/i386/boot2/resume.c
M/branches/ErmaC/Enoch/i386/boot2/boot.h

File differences

branches/ErmaC/Enoch/i386/boot2/resume.c
3737
3838
3939
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
4097
4198
4299
......
51108
52109
53110
54
111
55112
56113
57
58114
115
116
59117
60118
61119
......
107165
108166
109167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
110287
111288
112289
......
135312
136313
137314
138
315
139316
140317
141318
......
144321
145322
146323
147
148
324
325
149326
150
327
151328
152329
153330
154331
155332
156333
157
334
158335
159336
160337
161338
162339
163340
164
341
165342
166343
167344
......
176353
177354
178355
179
356
180357
181358
182359
......
208385
209386
210387
211
388
212389
return 0x10000000;
}
static void WakeKernelSnow(IOHibernateImageHeaderSnow * header)
{
uint32_t proc;
unsigned long cnt, newSP;
unsigned long *src, *dst;
unsigned int count;
unsigned int page;
unsigned int compressedSize;
int32_t byteCnt;
u_int32_t lowHalf, highHalf;
u_int32_t sum;
printf("\nWake Kernel!\n");
dst = (unsigned long *) (header->restore1CodePhysPage << 12);
count = header->restore1PageCount;
proc = (header->restore1CodeOffset + ((uint32_t) dst));
newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12);
src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0])
+ header->fileExtentMapSize);
sum = 0;
for (page = 0; page < count; page++)
{
compressedSize = 4096;
lowHalf = 1;
highHalf = 0;
for (cnt = 0; cnt < compressedSize; cnt += 0x20) {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
dst[3] = src[3];
dst[4] = src[4];
dst[5] = src[5];
dst[6] = src[6];
dst[7] = src[7];
for (byteCnt = 0; byteCnt < 0x20; byteCnt++) {
lowHalf += ((u_int8_t *) dst)[byteCnt];
highHalf += lowHalf;
}
src += 8;
dst += 8;
}
lowHalf %= 65521L;
highHalf %= 65521L;
sum += (highHalf << 16) | lowHalf;
}
header->actualRestore1Sum = sum;
startprog (proc, header);
return;
}
static void WakeKernel(IOHibernateImageHeader * header)
{
uint32_t proc;
printf("\nWake Kernel!\n");
dst = (unsigned long *) (header->restore1CodePage << 12);
dst = (unsigned long *) (header->restore1CodePhysPage << 12);
count = header->restore1PageCount;
proc = (header->restore1CodeOffset + ((uint32_t) dst));
newSP = header->restore1StackOffset + (header->restore1CodePage << 12);
newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12);
src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0])
+ header->fileExtentMapSize);
sum = 0;
imageSize = header->image1Size;
codeSize = header->restore1PageCount << 12;
if (kIOHibernateHeaderSignature != header->signature)
{
printf ("Incorrect image signature, expected version 10.7\n");
getchar();
return;
}
if (header->encryptStart)
{
printf ("Resuming from Encrypted image is unsupported.\n"
"Uncheck \"Use secure virtual memory\" in \"Security\" pane on system preferences.\n"
"Press any key to proceed with normal boot.\n");
getchar();
return;
}
// depends on NVRAM
#if 0
{
uint32_t machineSignature;
size = GetProp(gChosenPH, kIOHibernateMachineSignatureKey,
(char *)&machineSignature, sizeof(machineSignature));
if (size != sizeof(machineSignature)) machineSignature = 0;
if (machineSignature != header->machineSignature)
break;
}
#endif
allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095);
mem_base = (long)(getmemorylimit() - allocSize);//TODO: lower this
printf("mem_base %x\n", mem_base);
bcopy(header, (void *) mem_base, sizeof(IOHibernateImageHeader));
header = (IOHibernateImageHeader *) mem_base;
imageSize -= sizeof(IOHibernateImageHeader);
buffer = (long)(header + 1);
if (header->previewSize)
{
uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize;
uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize];
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), preview_offset+header->previewSize);
drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0]));
previewTotalSectors = (int)(imageSize-(preview_offset+header->previewSize))/512;
previewLoadedSectors = 0;
previewSaveunder = &(progressSaveUnder[0][0]);
if (preview_offset+header->previewSize<imageSize)
ReadFileAtOffset (image_filename, (char *)(long)(buffer+preview_offset+header->previewSize),
sizeof(IOHibernateImageHeader)+preview_offset+header->previewSize,
imageSize-(preview_offset+header->previewSize));
previewTotalSectors = 0;
previewLoadedSectors = 0;
previewSaveunder = 0;
#if 0
/* AsereBLN:
check_vga_nvidia() didn't work as expected (recursion level > 0 & return value).
Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only
and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will
remove it completely */
setVideoMode( VGA_TEXT_MODE, 0 );
#endif
}
else
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), imageSize);
// Depends on NVRAM
#if 0
if (header->encryptStart) {
// decryption data
static const unsigned char first_iv[AES_BLOCK_SIZE]
= { 0xa3, 0x63, 0x65, 0xa9, 0x0b, 0x71, 0x7b, 0x1c,
0xdf, 0x9e, 0x5f, 0x32, 0xd7, 0x61, 0x63, 0xda };
hibernate_cryptvars_t _cryptvars;
hibernate_cryptvars_t * cryptvars = &_cryptvars;
aes_decrypt_key(&decryptkey,
decryptkeysize,
&cryptvars->ctx.decrypt);
// set the vector for the following decryptions
bcopy(((uint8_t *) header) + header->image1Size - AES_BLOCK_SIZE,
&cryptvars->aes_iv[0], AES_BLOCK_SIZE);
// decrypt the buffer
uint32_t len = (uint32_t)(header->image1Size - header->encryptStart);
aes_decrypt_cbc(((uint8_t *) header) + header->encryptStart,
&first_iv[0],
len >> 4,
((uint8_t *) header) + header->encryptStart,
&cryptvars->ctx.decrypt);
bzero(&cryptvars->aes_iv[0], sizeof(cryptvars));
bzero(&decryptkey, sizeof(decryptkey));
}
#endif
WakeKernel(header);
}
void HibernateBootSnow(char *image_filename)
{
long long size, imageSize, codeSize, allocSize;
long mem_base;
IOHibernateImageHeaderSnow _header;
IOHibernateImageHeaderSnow * header = &_header;
long buffer;
if(gMacOSVersion[3] >= '7') // TODO: unlocked, but please check the compatibility with the 10.8
{
HibernateBoot(image_filename);
return;
}
size = ReadFileAtOffset (image_filename, header, 0, sizeof(IOHibernateImageHeaderSnow));
printf("header read size %x\n", size);
imageSize = header->image1Size;
codeSize = header->restore1PageCount << 12;
if (kIOHibernateHeaderSignature != header->signature) {
printf ("Incorrect image signature\n");
return;
allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095);
mem_base = getmemorylimit() - allocSize;//TODO: lower this
mem_base = (long)(getmemorylimit() - allocSize);//TODO: lower this
printf("mem_base %x\n", mem_base);
if (((long long)mem_base + allocSize) < (1024 * bootInfo->extmem + 0x100000)) {
return;
}
bcopy(header, (void *) mem_base, sizeof(IOHibernateImageHeader));
header = (IOHibernateImageHeader *) mem_base;
bcopy(header, (void *) mem_base, sizeof(IOHibernateImageHeaderSnow));
header = (IOHibernateImageHeaderSnow *) mem_base;
imageSize -= sizeof(IOHibernateImageHeader);
imageSize -= sizeof(IOHibernateImageHeaderSnow);
buffer = (long)(header + 1);
if (header->previewSize) {
uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize;
uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize];
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), preview_offset+header->previewSize);
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeaderSnow), preview_offset+header->previewSize);
drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0]));
previewTotalSectors = (imageSize-(preview_offset+header->previewSize))/512;
previewLoadedSectors = 0;
previewSaveunder = &(progressSaveUnder[0][0]);
if (preview_offset+header->previewSize<imageSize) {
ReadFileAtOffset (image_filename, (char *)(long)(buffer+preview_offset+header->previewSize),
sizeof(IOHibernateImageHeader)+preview_offset+header->previewSize,
sizeof(IOHibernateImageHeaderSnow)+preview_offset+header->previewSize,
imageSize-(preview_offset+header->previewSize));
}
previewTotalSectors = 0;
//setVideoMode( VGA_TEXT_MODE, 0 );
#endif
} else {
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), imageSize);
ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeaderSnow), imageSize);
}
// Depends on NVRAM
#if 0
}
#endif
WakeKernel(header);
WakeKernelSnow(header);
}
branches/ErmaC/Enoch/i386/boot2/boot.h
328328
329329
330330
331
331332
332333
333334
/* resume.c */
void HibernateBoot(char *boot_device);
void HibernateBootSnow(char *boot_device);
/* bmdecompress.c */
void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);
branches/ErmaC/Enoch/i386/boot2/IOHibernatePrivate.h
22
33
44
5
5
66
77
88
......
3434
3535
3636
37
38
39
3740
3841
3942
......
4346
4447
4548
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
46125
47126
48127
49
128
50129
51130
52131
......
94173
95174
96175
97
176
98177
178
179
180
181
99182
183
184
185
186
187
188
189
190
191
100192
101193
102194
......
132224
133225
134226
227
228
229
230
231
232
233
234
235
236
237
135238
136
239
137240
241
242
243
244
245
246
247
248
138249
139250
140251
......
159270
160271
161272
162
273
274
163275
164276
165277
......
192304
193305
194306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
195352
196353
197354
......
199356
200357
201358
359
202360
203361
204362
363
364
365
366
205367
206368
207369
......
209371
210372
211373
212
213
214
215
216
217
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
218389
219
220
221
222
390
391
392
223393
224394
225395
226
396
227397
228
398
399
400
401
402
403
404
229405
230
231
232
233
234
235
406
407
408
409
410
411
412
413
236414
237
415
416
238417
239
418
240419
241420
242421
422
423
424
425
426
427
428
429
430
431
243432
244433
245434
......
248437
249438
250439
440
441
442
251443
252444
253
445
254446
255447
256448
257449
450
258451
259452
260453
......
266459
267460
268461
462
463
464
269465
270466
271467
......
282478
283479
284480
285
481
286482
287483
288484
......
292488
293489
294490
295
491
296492
297
493
298494
299495
300496
......
302498
303499
304500
501
305502
306503
307504
......
310507
311508
312509
313
510
314511
315512
316
513
317514
318515
319516
320517
321518
322519
323
324
325
520
521
522
326523
327524
328525
329526
330527
331
332
333
334
335
336
337
528
529
530
531
532
533
534
535
536
338537
339538
340539
341540
342541
343
344
542
543
345544
346545
347546
348547
349548
350
351
352
549
550
551
353552
354553
355554
356555
556
557
357558
358559
359560
......
361562
362563
363564
565
364566
365567
366568
367
368
569
570
369571
572
370573
574
575
576
577
578
579
371580
372581
373582
......
377586
378587
379588
589
380590
381
591
382592
593
383594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
384614
385615
386616
* 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
#include <crypto/aes.h>
#endif
#ifndef __IOKIT_IOHIBERNATEPRIVATE_H
#define __IOKIT_IOHIBERNATEPRIVATE_H
struct IOPolledFileExtent
{
uint64_tstart;
struct IOHibernateImageHeader
{
uint64_timageSize; // 0
uint64_timage1Size; // 8
uint32_trestore1CodePhysPage; // 10
uint32_treserved1; // 14
uint64_trestore1CodeVirt; // 18
uint32_trestore1PageCount; // 20
uint32_trestore1CodeOffset;
uint32_trestore1StackOffset;
uint32_tpageCount;
uint32_tbitmapSize;
uint32_trestore1Sum;
uint32_timage1Sum;
uint32_timage2Sum;
uint32_tactualRestore1Sum;
uint32_tactualImage1Sum;
uint32_tactualImage2Sum;
uint32_tactualUncompressedPages;
uint32_tconflictCount;
uint32_tnextFree;
uint32_tsignature;
uint32_tprocessorFlags;
uint32_truntimePages;
uint32_truntimePageCount;
uint64_truntimeVirtualPages __attribute__ ((packed));
uint32_tperformanceDataStart;
uint32_tperformanceDataSize;
uint64_tencryptStart __attribute__ ((packed));
uint64_tmachineSignature __attribute__ ((packed));
uint32_tpreviewSize;
uint32_tpreviewPageListSize;
uint32_tdiag[4];
uint32_thandoffPages;
uint32_thandoffPageCount;
uint32_tsystemTableOffset;
uint32_tdebugFlags;
uint32_toptions;
uint32_tsleepTime;
uint32_tcompression;
uint32_treserved[58];// make sizeof == 512
uint32_tbooterTime0;
uint32_tbooterTime1;
uint32_tbooterTime2;
uint32_tbooterStart;
uint32_tsmcStart;
uint32_tconnectDisplayTime;
uint32_tsplashTime;
uint32_tbooterTime;
uint32_ttrampolineTime;
uint64_tencryptEnd __attribute__ ((packed));
uint64_tdeviceBase __attribute__ ((packed));
uint32_tdeviceBlockSize;
uint32_tfileExtentMapSize;
IOPolledFileExtentfileExtentMap[2];
};
typedef struct IOHibernateImageHeader IOHibernateImageHeader;
struct IOHibernateImageHeaderSnow
{
uint64_timageSize;
uint64_timage1Size;
uint32_trestore1CodePage;
uint32_trestore1CodePhysPage;
uint32_trestore1PageCount;
uint32_trestore1CodeOffset;
uint32_tfileExtentMapSize;
IOPolledFileExtentfileExtentMap[2];
};
typedef struct IOHibernateImageHeader IOHibernateImageHeader;
typedef struct IOHibernateImageHeaderSnow IOHibernateImageHeaderSnow;
enum
{
kIOHibernateDebugRestoreLogs = 0x00000001
};
// options & IOHibernateOptions property
enum
{
kIOHibernateOptionSSD = 0x00000001,
kIOHibernateOptionColor = 0x00000002,
kIOHibernateOptionProgress = 0x00000004,
kIOHibernateOptionDarkWake = 0x00000008,
};
struct hibernate_bitmap_t
{
uint32_tfirst_page;
#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,
};
enum
struct IOHibernateHandoff
{
uint32_t type;
uint32_t bytecount;
uint8_t data[];
};
typedef struct IOHibernateHandoff IOHibernateHandoff;
enum
{
kIOHibernateProgressCount = 19,
kIOHibernateProgressWidth = 7,
kIOHibernateProgressHeight = 16,
struct hibernate_graphics_t
{
uint32_t physicalAddress;// Base address of video memory
uint32_t physicalAddress;// Base address of video memory
int32_t gfxStatus;// EFI config restore status
uint32_t mode;//
uint32_t rowBytes; // Number of bytes per pixel row
uint32_t width; // Width
{ 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
void IOHibernateSystemInit(IOPMrootDomain * rootDomain);
IOReturn IOHibernateSystemSleep(void);
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 */
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);
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);
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);
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_ */
hibernate_page_list_t *
hibernate_page_list_allocate(void);
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,
hibernate_page_list_t ** page_list_ret,
hibernate_page_list_t ** page_list_wired_ret,
boolean_t * encryptedswap);
kern_return_t
uint32_t free_page_ratio,
uint32_t free_page_time,
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
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
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
// 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,
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
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);
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
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);
extern uint32_t gIOHibernateState;
extern uint32_t gIOHibernateMode;
extern uint32_t gIOHibernateDebugFlags;
extern uint32_t gIOHibernateFreeTime;// max time to spend freeing pages (ms)
extern uint8_t gIOHibernateRestoreStack[];
extern uint8_t gIOHibernateRestoreStackEnd[];
extern hibernate_cryptwakevars_t * gIOHibernateCryptWakeVars;
#define HIBLOG(fmt, args...)\
{ kprintf(fmt, ## args); printf(fmt, ## args); }
{ kprintf(fmt, ## args); printf(fmt, ## args); }
#define HIBPRINT(fmt, args...)\
{ kprintf(fmt, ## args); }
{ kprintf(fmt, ## args); }
#endif /* KERNEL */
// gIOHibernateState, kIOHibernateStateKey
enum
{
kIOHibernateStateInactive = 0,
kIOHibernateStateHibernating = 1,/* writing image */
kIOHibernateStateWakingFromHibernate = 2/* booted and restored image */
kIOHibernateStateInactive = 0,
kIOHibernateStateHibernating = 1,/* writing image */
kIOHibernateStateWakingFromHibernate = 2/* booted and restored image */
};
// gIOHibernateMode, kIOHibernateModeKey
enum
{
kIOHibernateModeOn = 0x00000001,
kIOHibernateModeSleep = 0x00000002,
kIOHibernateModeEncrypt = 0x00000004,
kIOHibernateModeDiscardCleanInactive = 0x00000008,
kIOHibernateModeDiscardCleanActive = 0x00000010,
kIOHibernateModeSwitch= 0x00000020,
kIOHibernateModeRestart= 0x00000040
kIOHibernateModeOn= 0x00000001,
kIOHibernateModeSleep= 0x00000002,
kIOHibernateModeEncrypt= 0x00000004,
kIOHibernateModeDiscardCleanInactive= 0x00000008,
kIOHibernateModeDiscardCleanActive= 0x00000010,
kIOHibernateModeSwitch= 0x00000020,
kIOHibernateModeRestart= 0x00000040,
kIOHibernateModeSSDInvert= 0x00000080,
kIOHibernateModeFileResize= 0x00000100,
};
// IOHibernateImageHeader.signature
enum
{
kIOHibernateHeaderSignature = 0x73696d65,
kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a
kIOHibernateHeaderSignature = 0x73696d65,
kIOHibernateHeaderInvalidSignature = 0x7a7a7a7a
};
// kind for hibernate_set_page_state()
enum
{
kIOHibernatePageStateFree = 0,
kIOHibernatePageStateWiredSave = 1,
kIOHibernatePageStateUnwiredSave = 2
kIOHibernatePageStateFree = 0,
kIOHibernatePageStateWiredSave = 1,
kIOHibernatePageStateUnwiredSave = 2
};
#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"
#define kIOHibernateFeatureKey"Hibernation"
#define kIOHibernatePreviewBufferKey"IOPreviewBuffer"
#ifndef kIOHibernatePreviewActiveKey
#define kIOHibernatePreviewActiveKey"IOHibernatePreviewActive"
// values for kIOHibernatePreviewActiveKey
enum {
kIOHibernatePreviewActive = 0x00000001,
kIOHibernatePreviewUpdates = 0x00000002
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"
#define kIOHibernateBootSignatureKey"boot-signature"
#define kIOHibernateMachineSignatureKey "machine-signature"
#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"
#endif /* ! __IOKIT_IOHIBERNATEPRIVATE_H */
#ifdef __cplusplus
}
#endif

Archive Download the corresponding diff file

Revision: 2364