Chameleon

Chameleon Commit Details

Date:2014-01-29 20:28:21 (5 years 5 months ago)
Author:ErmaC
Commit:2362
Parents: 2361
Message:Min typos.
Changes:
M/trunk/i386/libsaio/acpi_patcher.c
M/trunk/i386/boot2/resume.c
M/trunk/i386/boot2/IOHibernatePrivate.h

File differences

trunk/i386/libsaio/acpi_patcher.c
793793
794794
795795
796
797
796798
797799
798800
......
989991
990992
991993
992
994
993995
994996
995997
addConfigurationTable(&gEfiAcpiTableGuid, &acpi10_p, "ACPI");
if(acpi20_p) {
addConfigurationTable(&gEfiAcpi20TableGuid, &acpi20_p, "ACPI_20");
} else {
verbose("No ACPI 2.\n");
}
return 1;
}
DBG("New checksum %d at %x\n", rsdt_mod->Checksum,rsdt_mod);
} else {
rsdp_mod->RsdtAddress=0;
printf("RSDT not found or incorrect\n");
printf("RSDT not found or RSDT incorrect\n");
}
if (version) {
trunk/i386/boot2/resume.c
5151
5252
5353
54
54
5555
5656
57
57
5858
5959
6060
......
104104
105105
106106
107
107
108108
109109
110110
......
132132
133133
134134
135
135
136136
137
137
138138
139
139
140140
141141
142142
......
146146
147147
148148
149
149
150150
151151
152152
153153
154154
155155
156
156
157157
158158
159159
......
168168
169169
170170
171
172
173
174
175
176
171
172
173
174
175
176
177177
178178
179179
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);
size = ReadFileAtOffset (image_filename, header, 0, sizeof(IOHibernateImageHeader));
printf("header read size %x\n", size);
imageSize = header->image1Size;
codeSize = header->restore1PageCount << 12;
if (kIOHibernateHeaderSignature != header->signature) {
}
}
#endif
allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095);
mem_base = getmemorylimit() - allocSize;//TODO: lower this
printf("mem_base %x\n", mem_base);
if (((long long)mem_base + allocSize) < (1024 * bootInfo->extmem + 0x100000)) {
printf ("Not enough space to restore image. Press any key to proceed with normal boot.\n");
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 = (imageSize-(preview_offset+header->previewSize))/512;
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 );
//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);
trunk/i386/boot2/IOHibernatePrivate.h
22
33
44
5
5
66
77
88
......
1111
1212
1313
14
14
1515
1616
17
17
1818
1919
2020
......
2222
2323
2424
25
25
2626
2727
2828
......
3636
3737
3838
39
40
39
40
4141
4242
4343
4444
4545
46
47
48
49
50
51
52
53
54
55
46
47
5648
57
58
59
49
50
51
52
53
54
6055
61
62
63
56
57
6458
65
66
67
59
60
61
6862
69
70
63
64
65
7166
72
73
67
68
69
7470
75
76
77
78
71
72
7973
80
81
74
75
8276
83
77
8478
85
86
87
88
89
79
80
9081
91
82
83
9284
93
94
85
86
87
88
89
90
91
92
93
94
95
96
9597
9698
9799
98100
99101
100102
101
102
103
104
103
104
105
106
105107
106108
107109
108110
109111
110
111
112
113
112
113
114
115
114116
115117
116118
......
118120
119121
120122
121
123
122124
123125
124126
125127
126128
127
128
129
130
129131
130132
131133
......
134136
135137
136138
137
138
139
140
141
139
140
141
142
143
142144
143
145
144146
145
146
147
147
148
149
148150
149151
150
151
152
153
154
155
152
153
154
155
156
156157
157158
158159
159160
160161
161
162
163
164
165
166
162
163
164
165
166
167
167168
168
169
169170
170171
171172
......
173174
174175
175176
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
192193
193194
194195
......
208209
209210
210211
211
212
212
213
213214
214215
215216
......
224225
225226
226227
227
228
228229
229230
230231
231232
232233
233234
234
235
235236
236237
237238
238
239
239240
240241
241242
......
249250
250251
251252
252
253
253254
254255
255256
......
269270
270271
271272
272
273
273274
274275
275
276
276277
277278
278279
......
309310
310311
311312
312
313
313314
314315
315
316
316317
317318
318319
319320
320321
321322
322
323
324
323
324
325
325326
326327
327328
328329
329330
330
331
332
333
334
335
336
331
332
333
334
335
336
337
337338
338339
339340
340341
341342
342
343
343
344
344345
345346
346347
347348
348349
349
350
351
350
351
352
352353
353354
354355
......
363364
364365
365366
366
367
367
368
368369
369370
370371
* 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,
* 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@
*/
struct IOPolledFileExtent
{
uint64_tstart;
uint64_tlength;
uint64_tstart;
uint64_tlength;
};
typedef struct IOPolledFileExtent IOPolledFileExtent;
struct IOHibernateImageHeader
{
uint64_timageSize;
uint64_timage1Size;
uint32_trestore1CodePage;
uint32_trestore1PageCount;
uint32_trestore1CodeOffset;
uint32_trestore1StackOffset;
uint32_tpageCount;
uint32_tbitmapSize;
uint64_timageSize;
uint64_timage1Size;
uint32_trestore1Sum;
uint32_timage1Sum;
uint32_timage2Sum;
uint32_trestore1CodePhysPage;
uint32_treserved1;
uint64_trestore1CodeVirt;
uint32_trestore1PageCount;
uint32_trestore1CodeOffset;
uint32_trestore1StackOffset;
uint32_tactualRestore1Sum;
uint32_tactualImage1Sum;
uint32_tactualImage2Sum;
uint32_tpageCount;
uint32_tbitmapSize;
uint32_tactualUncompressedPages;
uint32_tconflictCount;
uint32_tnextFree;
uint32_trestore1Sum;
uint32_timage1Sum;
uint32_timage2Sum;
uint32_tsignature;
uint32_tprocessorFlags;
uint32_tactualRestore1Sum;
uint32_tactualImage1Sum;
uint32_tactualImage2Sum;
uint32_t runtimePages;
uint32_t runtimePageCount;
uint32_tactualUncompressedPages;
uint32_tconflictCount;
uint32_tnextFree;
uint8_treserved2[16];
uint64_tencryptStart;
uint64_tmachineSignature;
uint32_tsignature;
uint32_tprocessorFlags;
uint32_t previewSize;
uint32_t previewPageListSize;
uint32_truntimePages;
uint32_truntimePageCount;
uint32_tdiag[4];
uint8_treserved2[16];
int32_tgraphicsInfoOffset;
int32_tcryptVarsOffset;
int32_tmemoryMapOffset;
uint32_t memoryMapSize;
uint32_t systemTableOffset;
uint64_tencryptStart;
uint64_tmachineSignature;
uint32_treserved[77];// make sizeof == 512
uint32_tpreviewSize;
uint32_tpreviewPageListSize;
uint32_tfileExtentMapSize;
IOPolledFileExtentfileExtentMap[2];
uint32_tdiag[4];
int32_tgraphicsInfoOffset;
int32_tcryptVarsOffset;
int32_tmemoryMapOffset;
uint32_tmemoryMapSize;
uint32_tsystemTableOffset;
uint32_treserved[77];// make sizeof == 512
uint32_tfileExtentMapSize;
IOPolledFileExtentfileExtentMap[2];
};
typedef struct IOHibernateImageHeader IOHibernateImageHeader;
struct hibernate_bitmap_t
{
uint32_tfirst_page;
uint32_tlast_page;
uint32_tbitmapwords;
uint32_tbitmap[0];
uint32_tfirst_page;
uint32_tlast_page;
uint32_tbitmapwords;
uint32_tbitmap[0];
};
typedef struct hibernate_bitmap_t hibernate_bitmap_t;
struct hibernate_page_list_t
{
uint32_t list_size;
uint32_t page_count;
uint32_t bank_count;
hibernate_bitmap_t bank_bitmap[0];
uint32_t list_size;
uint32_t page_count;
uint32_t bank_count;
hibernate_bitmap_t bank_bitmap[0];
};
typedef struct hibernate_page_list_t hibernate_page_list_t;
struct hibernate_cryptwakevars_t
{
uint8_t aes_iv[AES_BLOCK_SIZE];
uint8_t aes_iv[AES_BLOCK_SIZE];
};
typedef struct hibernate_cryptwakevars_t hibernate_cryptwakevars_t;
struct hibernate_cryptvars_t
{
uint8_t aes_iv[AES_BLOCK_SIZE];
aes_ctx ctx;
uint8_t aes_iv[AES_BLOCK_SIZE];
aes_ctx ctx;
};
typedef struct hibernate_cryptvars_t hibernate_cryptvars_t;
enum
{
kIOHibernateProgressCount = 19,
kIOHibernateProgressWidth = 7,
kIOHibernateProgressHeight = 16,
kIOHibernateProgressSpacing = 3,
kIOHibernateProgressOriginY = 81,
kIOHibernateProgressCount = 19,
kIOHibernateProgressWidth = 7,
kIOHibernateProgressHeight = 16,
kIOHibernateProgressSpacing = 3,
kIOHibernateProgressOriginY = 81,
kIOHibernateProgressSaveUnderSize = 2*5+14*2,
kIOHibernateProgressSaveUnderSize = 2*5+14*2,
kIOHibernateProgressLightGray = 230,
kIOHibernateProgressMidGray = 174,
kIOHibernateProgressDarkGray = 92
kIOHibernateProgressLightGray = 230,
kIOHibernateProgressMidGray = 174,
kIOHibernateProgressDarkGray = 92
};
enum
{
kIOHibernatePostWriteSleep = 0,
kIOHibernatePostWriteWake = 1,
kIOHibernatePostWriteHalt = 2,
kIOHibernatePostWriteRestart = 3
enum {
kIOHibernatePostWriteSleep = 0,
kIOHibernatePostWriteWake = 1,
kIOHibernatePostWriteHalt = 2,
kIOHibernatePostWriteRestart = 3
};
struct hibernate_graphics_t
{
uint32_t physicalAddress;// Base address of video memory
uint32_t mode;//
uint32_t rowBytes; // Number of bytes per pixel row
uint32_t width; // Width
uint32_t height; // Height
uint32_t depth; // Pixel Depth
uint32_t physicalAddress;// Base address of video memory
uint32_t mode;//
uint32_t rowBytes; // Number of bytes per pixel row
uint32_t width; // Width
uint32_t height; // Height
uint32_t depth; // Pixel Depth
uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize];
uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize];
};
typedef struct hibernate_graphics_t hibernate_graphics_t;
static const uint8_t gIOHibernateProgressAlpha\
[kIOHibernateProgressHeight][kIOHibernateProgressWidth] = \
{\
{ 0x00,0x63,0xd8,0xf0,0xd8,0x63,0x00 },\
{ 0x51,0xff,0xff,0xff,0xff,0xff,0x51 },\
{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },\
{ 0x54,0xff,0xff,0xff,0xff,0xff,0x54 },\
{ 0x00,0x66,0xdb,0xf3,0xdb,0x66,0x00 }\
{ 0x00,0x63,0xd8,0xf0,0xd8,0x63,0x00 },\
{ 0x51,0xff,0xff,0xff,0xff,0xff,0x51 },\
{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xc3,0xff,0xff,0xff,0xff,0xff,0xc3 },\
{ 0xae,0xff,0xff,0xff,0xff,0xff,0xae },\
{ 0x54,0xff,0xff,0xff,0xff,0xff,0x54 },\
{ 0x00,0x66,0xdb,0xf3,0xdb,0x66,0x00 }\
};
#ifdef KERNEL
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,
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,
hibernate_page_list_t *
hibernate_page_list_allocate(void);
kern_return_t
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
kern_return_t
hibernate_teardown(hibernate_page_list_t * page_list,
hibernate_page_list_t * page_list_wired);
kern_return_t
kern_return_t
hibernate_processor_setup(IOHibernateImageHeader * header);
void
hibernate_page_list_t * page_list_wired,
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_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 *
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
};
// 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 kIOHibernatePreviewActiveKey"IOHibernatePreviewActive"
// values for kIOHibernatePreviewActiveKey
enum {
kIOHibernatePreviewActive = 0x00000001,
kIOHibernatePreviewUpdates = 0x00000002
kIOHibernatePreviewActive = 0x00000001,
kIOHibernatePreviewUpdates = 0x00000002
};
#define kIOHibernateBootImageKey"boot-image"

Archive Download the corresponding diff file

Revision: 2362