1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License").␉You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | ␊ |
25 | /* ␊ |
26 | * Mach Operating System␊ |
27 | * Copyright (c) 1990 Carnegie-Mellon University␊ |
28 | * Copyright (c) 1989 Carnegie-Mellon University␊ |
29 | * All rights reserved.␉ The CMU software License Agreement specifies␊ |
30 | * the terms and conditions for use and redistribution.␊ |
31 | */␊ |
32 | ␊ |
33 | /*␊ |
34 | *␉␉␉INTEL CORPORATION PROPRIETARY INFORMATION␊ |
35 | *␊ |
36 | *␉This software is supplied under the terms of a license␉agreement or ␊ |
37 | *␉nondisclosure agreement with Intel Corporation and may not be copied ␊ |
38 | *␉nor disclosed except in accordance with the terms of that agreement.␊ |
39 | *␊ |
40 | *␉Copyright 1988, 1989 by Intel Corporation␊ |
41 | */␊ |
42 | ␊ |
43 | /*␊ |
44 | * Copyright 1993 NeXT Computer, Inc.␊ |
45 | * All rights reserved.␊ |
46 | */␊ |
47 | ␊ |
48 | /*␊ |
49 | * Completely reworked by Sam Streeper (sam_s@NeXT.com)␊ |
50 | * Reworked again by Curtis Galloway (galloway@NeXT.com)␊ |
51 | */␊ |
52 | ␊ |
53 | #include "boot.h"␊ |
54 | #include "bootstruct.h"␊ |
55 | #include "fake_efi.h"␊ |
56 | #include "sl.h"␊ |
57 | #include "libsa.h"␊ |
58 | #include "ramdisk.h"␊ |
59 | #include "gui.h"␊ |
60 | #include "platform.h"␊ |
61 | #include "modules.h"␊ |
62 | #include "device_tree.h"␊ |
63 | ␊ |
64 | #ifndef DEBUG_BOOT2␊ |
65 | #define DEBUG_BOOT2 0␊ |
66 | #endif␊ |
67 | ␊ |
68 | #if DEBUG_BOOT2␊ |
69 | #define DBG(x...)␉printf(x)␊ |
70 | #else␊ |
71 | #define DBG(x...)␉msglog(x)␊ |
72 | #endif␊ |
73 | ␊ |
74 | /*␊ |
75 | * How long to wait (in seconds) to load the␊ |
76 | * kernel after displaying the "boot:" prompt.␊ |
77 | */␊ |
78 | #define kBootErrorTimeout 5␊ |
79 | ␊ |
80 | bool␉␉gOverrideKernel, gEnableCDROMRescan, gScanSingleDrive, useGUI;␊ |
81 | static bool␉gUnloadPXEOnExit = false;␊ |
82 | ␊ |
83 | static char␉gCacheNameAdler[64 + 256];␊ |
84 | char␉␉*gPlatformName = gCacheNameAdler;␊ |
85 | ␊ |
86 | char␉␉gRootDevice[ROOT_DEVICE_SIZE];␊ |
87 | char␉␉gMKextName[512];␊ |
88 | char␉␉gMacOSVersion[8];␊ |
89 | int␉␉bvCount = 0, gDeviceCount = 0;␊ |
90 | //int␉␉menucount = 0;␊ |
91 | long␉␉gBootMode; /* defaults to 0 == kBootModeNormal */␊ |
92 | BVRef␉␉bvr, menuBVR, bvChain;␊ |
93 | ␊ |
94 | static unsigned long␉Adler32(unsigned char *buffer, long length);␊ |
95 | //static void␉␉␉selectBiosDevice(void);␊ |
96 | ␊ |
97 | /** options.c **/␊ |
98 | extern char* msgbuf;␊ |
99 | void showTextBuffer(char *buf, int size);␊ |
100 | ␊ |
101 | ␊ |
102 | //==========================================================================␊ |
103 | // Zero the BSS.␊ |
104 | ␊ |
105 | static void zeroBSS(void)␊ |
106 | {␊ |
107 | ␉extern char bss_start __asm("section$start$__DATA$__bss");␊ |
108 | ␉extern char bss_end __asm("section$end$__DATA$__bss");␊ |
109 | ␉extern char common_start __asm("section$start$__DATA$__common");␊ |
110 | ␉extern char common_end __asm("section$end$__DATA$__common");␊ |
111 | ␊ |
112 | ␉bzero(&bss_start, (&bss_end - &bss_start));␊ |
113 | ␉bzero(&common_start, (&common_end - &common_start));␊ |
114 | }␊ |
115 | ␊ |
116 | //==========================================================================␊ |
117 | // Malloc error function␊ |
118 | ␊ |
119 | static void malloc_error(char *addr, size_t size, const char *file, int line)␊ |
120 | {␊ |
121 | ␉stop("\nMemory allocation error! Addr: 0x%x, Size: 0x%x, File: %s, Line: %d\n",␊ |
122 | ␉␉␉␉␉␉␉␉␉ (unsigned)addr, (unsigned)size, file, line);␊ |
123 | }␊ |
124 | ␊ |
125 | //==========================================================================␊ |
126 | //Initializes the runtime. Right now this means zeroing the BSS and initializing malloc.␊ |
127 | //␊ |
128 | void initialize_runtime(void)␊ |
129 | {␊ |
130 | ␉zeroBSS();␊ |
131 | ␉malloc_init(0, 0, 0, malloc_error);␊ |
132 | }␊ |
133 | ␊ |
134 | //==========================================================================␊ |
135 | // execKernel - Load the kernel image (mach-o) and jump to its entry point.␊ |
136 | ␊ |
137 | static int ExecKernel(void *binary)␊ |
138 | {␊ |
139 | ␉int␉␉␉ret;␊ |
140 | ␉entry_t␉␉kernelEntry;␊ |
141 | ␊ |
142 | ␉bootArgs->kaddr = bootArgs->ksize = 0;␊ |
143 | ␉execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL);␊ |
144 | ␊ |
145 | ␉ret = DecodeKernel(binary,␊ |
146 | ␉␉␉␉␉ &kernelEntry,␊ |
147 | ␉␉␉␉␉ (char **) &bootArgs->kaddr,␊ |
148 | ␉␉␉␉␉ (int *)&bootArgs->ksize );␊ |
149 | ␊ |
150 | ␉if ( ret != 0 )␊ |
151 | ␉␉return ret;␊ |
152 | ␊ |
153 | ␉// Reserve space for boot args␊ |
154 | ␉reserveKernBootStruct();␊ |
155 | ␊ |
156 | ␉// Notify modules that the kernel has been decoded␊ |
157 | ␉execute_hook("DecodedKernel", (void*)binary, (void*)bootArgs->kaddr, (void*)bootArgs->ksize, NULL);␊ |
158 | ␊ |
159 | ␉setupFakeEfi();␊ |
160 | ␊ |
161 | ␉// Load boot drivers from the specifed root path.␊ |
162 | ␉//if (!gHaveKernelCache)␊ |
163 | ␉LoadDrivers("/");␊ |
164 | ␊ |
165 | ␉execute_hook("DriversLoaded", (void*)binary, NULL, NULL, NULL);␊ |
166 | ␊ |
167 | ␉clearActivityIndicator();␊ |
168 | ␊ |
169 | ␉if (gErrors)␊ |
170 | ␉{␊ |
171 | ␉␉printf("Errors encountered while starting up the computer.\n");␊ |
172 | ␉␉printf("Pausing %d seconds...\n", kBootErrorTimeout);␊ |
173 | ␉␉sleep(kBootErrorTimeout);␊ |
174 | ␉}␊ |
175 | ␊ |
176 | ␉md0Ramdisk();␊ |
177 | ␊ |
178 | ␉// Cleanup the PXE base code.␊ |
179 | ␊ |
180 | ␉if ( (gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit )␊ |
181 | ␉{␊ |
182 | ␉␉if ( (ret = nbpUnloadBaseCode()) != nbpStatusSuccess )␊ |
183 | ␉␉{␊ |
184 | ␉␉␉printf("nbpUnloadBaseCode error %d\n", (int) ret);␊ |
185 | ␉␉␉sleep(2);␊ |
186 | ␉␉}␊ |
187 | ␉}␊ |
188 | ␊ |
189 | ␉bool dummyVal;␊ |
190 | ␉if (getBoolForKey(kWaitForKeypressKey, &dummyVal, &bootInfo->chameleonConfig) && dummyVal)␊ |
191 | ␉{␊ |
192 | ␉␉showTextBuffer(msgbuf, strlen(msgbuf));␊ |
193 | ␉}␊ |
194 | ␊ |
195 | ␉usb_loop();␊ |
196 | ␊ |
197 | ␉// If we were in text mode, switch to graphics mode.␊ |
198 | ␉// This will draw the boot graphics unless we are in␊ |
199 | ␉// verbose mode.␊ |
200 | ␉if (gVerboseMode)␊ |
201 | ␉{␊ |
202 | ␉␉setVideoMode( GRAPHICS_MODE, 0 );␊ |
203 | ␉}␊ |
204 | ␉else␊ |
205 | ␉{␊ |
206 | ␉␉drawBootGraphics();␊ |
207 | ␉}␊ |
208 | ␊ |
209 | ␉DBG("Starting Darwin/%s [%s]\n",( archCpuType == CPU_TYPE_I386 ) ? "x86" : "x86_64", gDarwinBuildVerStr);␊ |
210 | ␉DBG("Boot Args: %s\n", bootArgs->CommandLine);␊ |
211 | ␊ |
212 | ␉setupBooterLog();␊ |
213 | ␊ |
214 | ␉finalizeBootStruct();␊ |
215 | ␊ |
216 | ␉// Jump to kernel's entry point. There's no going back now.␊ |
217 | ␉if (TIGER || LEOPARD || SNOW_LEOPARD)␊ |
218 | ␉{␊ |
219 | ␉␉// Notify modules that the kernel is about to be started␊ |
220 | ␉␉execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL);␊ |
221 | ␊ |
222 | ␉␉startprog( kernelEntry, bootArgsPreLion );␊ |
223 | ␊ |
224 | ␉}␊ |
225 | ␉else␊ |
226 | ␉{␊ |
227 | ␉␉// Notify modules that the kernel is about to be started␊ |
228 | ␉␉execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL);␊ |
229 | ␊ |
230 | ␉␉// Masking out so that Lion doesn't doublefault␊ |
231 | ␉␉outb(0x21, 0xff);␉/* Maskout all interrupts Pic1 */␊ |
232 | ␉␉outb(0xa1, 0xff);␉/* Maskout all interrupts Pic2 */␊ |
233 | ␊ |
234 | ␉␉startprog( kernelEntry, bootArgs );␊ |
235 | ␉}␊ |
236 | ␊ |
237 | ␉// Not reached␊ |
238 | ␉return 0;␊ |
239 | }␊ |
240 | ␊ |
241 | ␊ |
242 | //==========================================================================␊ |
243 | // LoadKernelCache - Try to load Kernel Cache.␊ |
244 | // return the length of the loaded cache file or -1 on error␊ |
245 | long LoadKernelCache(const char* cacheFile, void **binary)␊ |
246 | {␊ |
247 | ␉char␉␉kernelCacheFile[512];␊ |
248 | ␉char␉␉kernelCachePath[512];␊ |
249 | ␉long␉␉flags, time, cachetime, kerneltime, exttime, ret=-1;␊ |
250 | ␉unsigned long adler32;␊ |
251 | ␊ |
252 | ␉if((gBootMode & kBootModeSafe) != 0) {␊ |
253 | ␉␉DBG("Kernel Cache ignored.\n");␊ |
254 | ␉␉return -1;␊ |
255 | ␉}␊ |
256 | ␊ |
257 | ␉// Use specify kernel cache file if not empty␊ |
258 | ␉if (cacheFile[0] != 0)␊ |
259 | ␉{␊ |
260 | ␉␉strlcpy(kernelCacheFile, cacheFile, sizeof(kernelCacheFile));␊ |
261 | ␉␉verbose("Specified kernel cache file path = %s\n", cacheFile);␊ |
262 | ␉} else {␊ |
263 | ␉␉// Leopard prelink kernel cache file␊ |
264 | ␉␉if (TIGER || LEOPARD)␊ |
265 | ␉␉{␊ |
266 | ␉␉␉// Reset cache name.␊ |
267 | ␉␉␉bzero(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64);␊ |
268 | ␉␉␉snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile);␊ |
269 | ␉␉␉adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler));␊ |
270 | ␉␉␉snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32);␊ |
271 | ␉␉␉verbose("Reseted kernel cache file path = %s\n", kernelCacheFile);␊ |
272 | ␉␉}␊ |
273 | ␉␉// Snow Leopard prelink kernel cache file␊ |
274 | ␉␉else if ( SNOW_LEOPARD ) {␊ |
275 | ␉␉␉snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s",␊ |
276 | ␉␉␉␉(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");␊ |
277 | ␊ |
278 | ␉␉␉int␉lnam = strlen(kernelCacheFile) + 9; //with adler32␊ |
279 | ␉␉␉char␉*name;␊ |
280 | ␉␉␉long␉prev_time = 0;␊ |
281 | ␊ |
282 | ␉␉␉struct␉dirstuff* cacheDir = opendir(kDefaultCachePathSnow);␊ |
283 | ␊ |
284 | ␉␉␉/* TODO: handle error? */␊ |
285 | ␉␉␉if (cacheDir) {␊ |
286 | ␉␉␉␉while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0) {␊ |
287 | ␉␉␉␉␉if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time␊ |
288 | ␉␉␉␉␉␉&& strstr(name, kernelCacheFile) && (name[lnam] != '.')) {␊ |
289 | ␉␉␉␉␉␉snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name);␊ |
290 | ␉␉␉␉␉␉prev_time = time;␊ |
291 | ␉␉␉␉␉}␊ |
292 | ␉␉␉␉}␊ |
293 | ␉␉␉␉verbose("Snow Leopard kernel cache file path = %s\n", kernelCacheFile);␊ |
294 | ␉␉␉}␊ |
295 | ␉␉␉closedir(cacheDir);␊ |
296 | ␉␉} else {␊ |
297 | ␉␉␉// Lion, Mountain Lion, Mavericks, and Yosemite prelink kernel cache file␊ |
298 | ␉␉␉// for 10.7 10.8 10.9 10.10␊ |
299 | ␉␉␉snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow);␊ |
300 | ␉␉␉verbose("10.7, 10.8, 10.9 & 10.10 kernel cache file path = %s\n", kernelCacheFile);␊ |
301 | ␉␉}␊ |
302 | ␉}␊ |
303 | ␊ |
304 | ␉// Check if the kernel cache file exists␊ |
305 | ␉ret = -1;␊ |
306 | ␊ |
307 | ␉// If boot from a boot helper partition check the kernel cache file on it␊ |
308 | ␉if (gBootVolume->flags & kBVFlagBooter)␊ |
309 | ␉{␊ |
310 | ␉␉snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.P%s", kernelCacheFile);␊ |
311 | ␉␉ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);␊ |
312 | ␊ |
313 | ␉␉if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))␊ |
314 | ␉␉{␊ |
315 | ␉␉␉snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.R%s", kernelCacheFile);␊ |
316 | ␉␉␉ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);␊ |
317 | ␊ |
318 | ␉␉␉if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))␊ |
319 | ␉␉␉{␊ |
320 | ␉␉␉␉snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.S%s", kernelCacheFile);␊ |
321 | ␉␉␉␉ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);␊ |
322 | ␊ |
323 | ␉␉␉␉if ((flags & kFileTypeMask) != kFileTypeFlat)␊ |
324 | ␉␉␉␉{␊ |
325 | ␉␉␉␉␉ret = -1;␊ |
326 | ␉␉␉␉}␊ |
327 | ␉␉␉}␊ |
328 | ␉␉}␊ |
329 | ␉}␊ |
330 | ␊ |
331 | ␉// If not found, use the original kernel cache path.␊ |
332 | ␉if (ret == -1)␊ |
333 | ␉{␊ |
334 | ␉␉strlcpy(kernelCachePath, kernelCacheFile, sizeof(kernelCachePath));␊ |
335 | ␉␉ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);␊ |
336 | ␊ |
337 | ␉␉if ((flags & kFileTypeMask) != kFileTypeFlat)␊ |
338 | ␉␉{␊ |
339 | ␉␉␉ret = -1;␊ |
340 | ␉␉}␊ |
341 | ␉}␊ |
342 | ␊ |
343 | ␉// Exit if kernel cache file wasn't found␊ |
344 | ␉if (ret == -1)␊ |
345 | ␉{␊ |
346 | ␉␉DBG("No Kernel Cache File '%s' found\n", kernelCacheFile);␊ |
347 | ␉␉return -1;␊ |
348 | ␉}␊ |
349 | ␊ |
350 | ␉// Check if the kernel cache file is more recent (mtime)␊ |
351 | ␉// than the kernel file or the S/L/E directory␊ |
352 | ␉ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);␊ |
353 | ␊ |
354 | ␉// Check if the kernel file is more recent than the cache file␊ |
355 | ␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime))␊ |
356 | ␉{␊ |
357 | ␉␉DBG("Kernel file (%s) is more recent than Kernel Cache (%s)! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile);␊ |
358 | ␉␉return -1;␊ |
359 | ␉}␊ |
360 | ␊ |
361 | ␉ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);␊ |
362 | ␊ |
363 | ␉// Check if the S/L/E directory time is more recent than the cache file␊ |
364 | ␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime))␊ |
365 | ␉{␊ |
366 | ␉␉DBG("Folder: '/System/Library/Extensions' is more recent than Kernel Cache file (%s)! Ignoring Kernel Cache.\n", kernelCacheFile);␊ |
367 | ␉␉return -1;␊ |
368 | ␉}␊ |
369 | ␊ |
370 | ␉// Since the kernel cache file exists and is the most recent try to load it␊ |
371 | ␉DBG("Loading kernel cache: '%s'\n", kernelCachePath);␊ |
372 | ␊ |
373 | ␉ret = LoadThinFatFile(kernelCachePath, binary);␊ |
374 | ␉return ret; // ret contain the length of the binary␊ |
375 | }␊ |
376 | ␊ |
377 | //==========================================================================␊ |
378 | // This is the entrypoint from real-mode which functions exactly as it did␊ |
379 | // before. Multiboot does its own runtime initialization, does some of its␊ |
380 | // own things, and then calls common_boot.␊ |
381 | void boot(int biosdev)␊ |
382 | {␊ |
383 | ␉initialize_runtime();␊ |
384 | ␉// Enable A20 gate before accessing memory above 1Mb.␊ |
385 | ␉enableA20();␊ |
386 | ␉common_boot(biosdev);␊ |
387 | }␊ |
388 | ␊ |
389 | //==========================================================================␊ |
390 | // The 'main' function for the booter. Called by boot0 when booting␊ |
391 | // from a block device, or by the network booter.␊ |
392 | //␊ |
393 | // arguments:␊ |
394 | //␉ biosdev - Value passed from boot1/NBP to specify the device␊ |
395 | //␉␉␉ that the booter was loaded from.␊ |
396 | //␊ |
397 | // If biosdev is kBIOSDevNetwork, then this function will return if␊ |
398 | // booting was unsuccessful. This allows the PXE firmware to try the␊ |
399 | // next boot device on its list.␊ |
400 | void common_boot(int biosdev)␊ |
401 | {␊ |
402 | ␉bool␉ ␉␉quiet;␊ |
403 | ␉bool␉ ␉␉firstRun = true;␊ |
404 | ␉bool␉ ␉␉instantMenu;␊ |
405 | ␉bool␉ ␉␉rescanPrompt;␊ |
406 | ␉int␉␉␉␉status;␊ |
407 | ␉unsigned int␉allowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot;␊ |
408 | ␉unsigned int␉denyBVFlags = kBVFlagEFISystem;␊ |
409 | ␊ |
410 | ␉// Set reminder to unload the PXE base code. Neglect to unload␊ |
411 | ␉// the base code will result in a hang or kernel panic.␊ |
412 | ␉gUnloadPXEOnExit = true;␊ |
413 | ␊ |
414 | ␉// Record the device that the booter was loaded from.␊ |
415 | ␉gBIOSDev = biosdev & kBIOSDevMask;␊ |
416 | ␊ |
417 | ␉// Initialize boot-log␊ |
418 | ␉initBooterLog();␊ |
419 | ␊ |
420 | ␉// Initialize boot info structure.␊ |
421 | ␉initKernBootStruct();␊ |
422 | ␊ |
423 | ␉// Setup VGA text mode.␊ |
424 | ␉// Not sure if it is safe to call setVideoMode() before the␊ |
425 | ␉// config table has been loaded. Call video_mode() instead.␊ |
426 | #if DEBUG␊ |
427 | ␉printf("before video_mode\n");␊ |
428 | #endif␊ |
429 | ␉video_mode( 2 ); // 80x25 mono text mode.␊ |
430 | #if DEBUG␊ |
431 | ␉printf("after video_mode\n");␊ |
432 | #endif␊ |
433 | ␊ |
434 | ␉// Scan and record the system's hardware information.␊ |
435 | ␉scan_platform();␊ |
436 | ␊ |
437 | ␉// First get info for boot volume.␊ |
438 | ␉scanBootVolumes(gBIOSDev, 0);␊ |
439 | ␉bvChain = getBVChainForBIOSDev(gBIOSDev);␊ |
440 | ␉setBootGlobals(bvChain);␊ |
441 | ␊ |
442 | ␉// Load boot.plist config file␊ |
443 | ␉status = loadChameleonConfig(&bootInfo->chameleonConfig, bvChain);␊ |
444 | ␊ |
445 | ␉if (getBoolForKey(kQuietBootKey, &quiet, &bootInfo->chameleonConfig) && quiet)␊ |
446 | ␉{␊ |
447 | ␉␉gBootMode |= kBootModeQuiet;␊ |
448 | ␉}␊ |
449 | ␊ |
450 | ␉// Override firstRun to get to the boot menu instantly by setting "Instant Menu"=y in system config␊ |
451 | ␉if (getBoolForKey(kInstantMenuKey, &instantMenu, &bootInfo->chameleonConfig) && instantMenu)␊ |
452 | ␉{␊ |
453 | ␉␉firstRun = false;␊ |
454 | ␉}␊ |
455 | ␊ |
456 | ␉// Loading preboot ramdisk if exists.␊ |
457 | ␉loadPrebootRAMDisk();␊ |
458 | ␊ |
459 | ␉// Disable rescan option by default␊ |
460 | ␉gEnableCDROMRescan = false;␊ |
461 | ␊ |
462 | ␉// Enable it with Rescan=y in system config␊ |
463 | ␉if (getBoolForKey(kRescanKey, &gEnableCDROMRescan, &bootInfo->chameleonConfig)␉&& gEnableCDROMRescan)␊ |
464 | ␉{␊ |
465 | ␉␉gEnableCDROMRescan = true;␊ |
466 | ␉}␊ |
467 | ␊ |
468 | ␉// Ask the user for Rescan option by setting "Rescan Prompt"=y in system config.␊ |
469 | ␉rescanPrompt = false;␊ |
470 | ␉if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->chameleonConfig) && rescanPrompt && biosDevIsCDROM(gBIOSDev))␊ |
471 | ␉{␊ |
472 | ␉␉gEnableCDROMRescan = promptForRescanOption();␊ |
473 | ␉}␊ |
474 | ␊ |
475 | ␉// Enable touching a single BIOS device only if "Scan Single Drive"=y is set in system config.␊ |
476 | ␉if (getBoolForKey(kScanSingleDriveKey, &gScanSingleDrive, &bootInfo->chameleonConfig) && gScanSingleDrive)␊ |
477 | ␉{␊ |
478 | ␉␉gScanSingleDrive = true;␊ |
479 | ␉}␊ |
480 | ␊ |
481 | ␉// Create a list of partitions on device(s).␊ |
482 | ␉if (gScanSingleDrive)␊ |
483 | ␉{␊ |
484 | ␉␉scanBootVolumes(gBIOSDev, &bvCount);␊ |
485 | ␉}␊ |
486 | ␉else␊ |
487 | ␉{␊ |
488 | ␉␉scanDisks(gBIOSDev, &bvCount);␊ |
489 | ␉}␊ |
490 | ␊ |
491 | ␉// Create a separated bvr chain using the specified filters.␊ |
492 | ␉bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);␊ |
493 | ␊ |
494 | ␉gBootVolume = selectBootVolume(bvChain);␊ |
495 | ␊ |
496 | ␉// Intialize module system␊ |
497 | ␉init_module_system();␊ |
498 | ␊ |
499 | #if DEBUG␊ |
500 | ␉printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",␊ |
501 | ␉␉␉ gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags);␊ |
502 | ␉printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n",␊ |
503 | ␉␉␉ gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags);␊ |
504 | ␉getchar();␊ |
505 | #endif␊ |
506 | ␊ |
507 | ␉useGUI = true;␊ |
508 | ␉// Override useGUI default␊ |
509 | ␉getBoolForKey(kGUIKey, &useGUI, &bootInfo->chameleonConfig);␊ |
510 | ␉if (useGUI && initGUI())␊ |
511 | ␉{␊ |
512 | ␉␉// initGUI() returned with an error, disabling GUI.␊ |
513 | ␉␉useGUI = false;␊ |
514 | ␉}␊ |
515 | ␊ |
516 | ␉setBootGlobals(bvChain);␊ |
517 | ␊ |
518 | ␉// Parse args, load and start kernel.␊ |
519 | ␉while (1)␊ |
520 | ␉{␊ |
521 | ␉␉bool␉␉tryresume, tryresumedefault, forceresume;␊ |
522 | ␉␉bool␉␉useKernelCache = true; // by default try to use the prelinked kernel␊ |
523 | ␉␉const char␉*val;␊ |
524 | ␉␉int␉␉␉len, ret = -1;␊ |
525 | ␉␉long␉␉flags, sleeptime, time;␊ |
526 | ␉␉void␉␉*binary = (void *)kLoadAddr;␊ |
527 | ␊ |
528 | ␉␉char bootFile[sizeof(bootInfo->bootFile)];␊ |
529 | ␉␉char␉␉bootFilePath[512];␊ |
530 | ␉␉char␉␉kernelCacheFile[512];␊ |
531 | ␊ |
532 | ␉␉// Initialize globals.␊ |
533 | ␉␉sysConfigValid = false;␊ |
534 | ␉␉gErrors␉␉ = false;␊ |
535 | ␊ |
536 | ␉␉status = getBootOptions(firstRun);␊ |
537 | ␉␉firstRun = false;␊ |
538 | ␉␉if (status == -1) continue;␊ |
539 | ␊ |
540 | ␉␉status = processBootOptions();␊ |
541 | ␉␉// Status == 1 means to chainboot␊ |
542 | ␉␉if ( status ==␉1 ) break;␊ |
543 | ␉␉// Status == -1 means that the config file couldn't be loaded or that gBootVolume is NULL␊ |
544 | ␉␉if ( status == -1 )␊ |
545 | ␉␉{␊ |
546 | ␉␉␉// gBootVolume == NULL usually means the user hit escape.␊ |
547 | ␉␉␉if (gBootVolume == NULL)␊ |
548 | ␉␉␉{␊ |
549 | ␉␉␉␉freeFilteredBVChain(bvChain);␊ |
550 | ␊ |
551 | ␉␉␉␉if (gEnableCDROMRescan)␊ |
552 | ␉␉␉␉␉rescanBIOSDevice(gBIOSDev);␊ |
553 | ␊ |
554 | ␉␉␉␉bvChain = newFilteredBVChain(0x80, 0xFF, allowBVFlags, denyBVFlags, &gDeviceCount);␊ |
555 | ␉␉␉␉setBootGlobals(bvChain);␊ |
556 | ␉␉␉␉setupDeviceList(&bootInfo->themeConfig);␊ |
557 | ␉␉␉}␊ |
558 | ␉␉␉continue;␊ |
559 | ␉␉}␊ |
560 | ␊ |
561 | ␉␉// Other status (e.g. 0) means that we should proceed with boot.␊ |
562 | ␊ |
563 | ␉␉// Turn off any GUI elements␊ |
564 | ␉␉if ( bootArgs->Video.v_display == GRAPHICS_MODE )␊ |
565 | ␉␉{␊ |
566 | ␉␉␉gui.devicelist.draw = false;␊ |
567 | ␉␉␉gui.bootprompt.draw = false;␊ |
568 | ␉␉␉gui.menu.draw = false;␊ |
569 | ␉␉␉gui.infobox.draw = false;␊ |
570 | ␉␉␉gui.logo.draw = false;␊ |
571 | ␉␉␉drawBackground();␊ |
572 | ␉␉␉updateVRAM();␊ |
573 | ␉␉}␊ |
574 | ␊ |
575 | ␉␉if (platformCPUFeature(CPU_FEATURE_EM64T)) {␊ |
576 | ␉␉␉archCpuType = CPU_TYPE_X86_64;␊ |
577 | ␉␉} else {␊ |
578 | ␉␉␉archCpuType = CPU_TYPE_I386;␊ |
579 | ␉␉}␊ |
580 | ␊ |
581 | ␉␉if (getValueForKey(karch, &val, &len, &bootInfo->chameleonConfig)) {␊ |
582 | ␉␉␉if (strncmp(val, "i386", 4) == 0) {␊ |
583 | ␉␉␉␉archCpuType = CPU_TYPE_I386;␊ |
584 | ␉␉␉}␊ |
585 | ␉␉}␊ |
586 | ␊ |
587 | ␉␉if (getValueForKey(kKernelArchKey, &val, &len, &bootInfo->chameleonConfig)) {␊ |
588 | ␉␉␉if (strncmp(val, "i386", 4) == 0) {␊ |
589 | ␉␉␉␉archCpuType = CPU_TYPE_I386;␊ |
590 | ␉␉␉}␊ |
591 | ␉␉}␊ |
592 | ␊ |
593 | ␉␉// Notify modules that we are attempting to boot␊ |
594 | ␉␉execute_hook("PreBoot", NULL, NULL, NULL, NULL);␊ |
595 | ␊ |
596 | ␉␉if (!getBoolForKey (kWake, &tryresume, &bootInfo->chameleonConfig)) {␊ |
597 | ␉␉␉tryresume = true;␊ |
598 | ␉␉␉tryresumedefault = true;␊ |
599 | ␉␉} else {␊ |
600 | ␉␉␉tryresumedefault = false;␊ |
601 | ␉␉}␊ |
602 | ␊ |
603 | ␉␉if (!getBoolForKey (kForceWake, &forceresume, &bootInfo->chameleonConfig)) {␊ |
604 | ␉␉␉forceresume = false;␊ |
605 | ␉␉}␊ |
606 | ␊ |
607 | ␉␉if (forceresume) {␊ |
608 | ␉␉␉tryresume = true;␊ |
609 | ␉␉␉tryresumedefault = false;␊ |
610 | ␉␉}␊ |
611 | ␊ |
612 | ␉␉while (tryresume) {␊ |
613 | ␉␉␉const char *tmp;␊ |
614 | ␉␉␉BVRef bvr;␊ |
615 | ␉␉␉if (!getValueForKey(kWakeImage, &val, &len, &bootInfo->chameleonConfig))␊ |
616 | ␉␉␉␉val = "/private/var/vm/sleepimage";␊ |
617 | ␊ |
618 | ␉␉␉// Do this first to be sure that root volume is mounted␊ |
619 | ␉␉␉ret = GetFileInfo(0, val, &flags, &sleeptime);␊ |
620 | ␊ |
621 | ␉␉␉if ((bvr = getBootVolumeRef(val, &tmp)) == NULL)␊ |
622 | ␉␉␉␉break;␊ |
623 | ␊ |
624 | ␉␉␉// Can't check if it was hibernation Wake=y is required␊ |
625 | ␉␉␉if (bvr->modTime == 0 && tryresumedefault)␊ |
626 | ␉␉␉␉break;␊ |
627 | ␊ |
628 | ␉␉␉if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))␊ |
629 | ␉␉␉␉break;␊ |
630 | ␊ |
631 | ␉␉␉if (!forceresume && ((sleeptime+3)<bvr->modTime)) {␊ |
632 | #if DEBUG␊ |
633 | ␉␉␉␉printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",␊ |
634 | ␉␉␉␉␉␉bvr->modTime-sleeptime);␊ |
635 | #endif␊ |
636 | ␉␉␉␉break;␊ |
637 | ␉␉␉}␊ |
638 | ␊ |
639 | ␉␉␉HibernateBoot((char *)val);␊ |
640 | ␉␉␉break;␊ |
641 | ␉␉}␊ |
642 | ␊ |
643 | ␉␉getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);␊ |
644 | ␉␉if (useKernelCache) do {␊ |
645 | ␊ |
646 | ␉␉␉// Determine the name of the Kernel Cache␊ |
647 | ␉␉␉if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {␊ |
648 | ␉␉␉␉if (val[0] == '\\')␊ |
649 | ␉␉␉␉{␊ |
650 | ␉␉␉␉␉len--;␊ |
651 | ␉␉␉␉␉val++;␊ |
652 | ␉␉␉␉}␊ |
653 | ␉␉␉␉/* FIXME: check len vs sizeof(kernelCacheFile) */␊ |
654 | ␉␉␉␉strlcpy(kernelCacheFile, val, len + 1);␊ |
655 | ␉␉␉} else {␊ |
656 | ␉␉␉␉kernelCacheFile[0] = 0; // Use default kernel cache file␊ |
657 | ␉␉␉}␊ |
658 | ␊ |
659 | ␉␉␉if (gOverrideKernel && kernelCacheFile[0] == 0) {␊ |
660 | ␉␉␉␉DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile);␊ |
661 | ␉␉␉␉useKernelCache = false;␊ |
662 | ␉␉␉␉break;␊ |
663 | ␉␉␉}␊ |
664 | ␉␉␉if (gMKextName[0] != 0) {␊ |
665 | ␉␉␉␉DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n",␊ |
666 | ␉␉␉␉␉␉gMKextName);␊ |
667 | ␉␉␉␉useKernelCache = false;␊ |
668 | ␉␉␉␉break;␊ |
669 | ␉␉␉}␊ |
670 | ␉␉␉if (gBootFileType != kBlockDeviceType)␊ |
671 | ␉␉␉␉useKernelCache = false;␊ |
672 | ␊ |
673 | ␉␉} while(0);␊ |
674 | ␊ |
675 | ␉␉do {␊ |
676 | ␉␉␉if (useKernelCache) {␊ |
677 | ␉␉␉␉ret = LoadKernelCache(kernelCacheFile, &binary);␊ |
678 | ␉␉␉␉if (ret >= 0)␊ |
679 | ␉␉␉␉␉break;␊ |
680 | ␉␉␉}␊ |
681 | ␊ |
682 | ␉␉␉bool bootFileWithDevice = false;␊ |
683 | ␉␉␉// Check if bootFile start with a device ex: bt(0,0)/Extra/mach_kernel␊ |
684 | ␉␉␉if (strncmp(bootInfo->bootFile,"bt(",3) == 0 ||␊ |
685 | ␉␉␉␉strncmp(bootInfo->bootFile,"hd(",3) == 0 ||␊ |
686 | ␉␉␉␉strncmp(bootInfo->bootFile,"rd(",3) == 0)␊ |
687 | ␉␉␉␉bootFileWithDevice = true;␊ |
688 | ␊ |
689 | ␉␉␉// bootFile must start with a / if it not start with a device name␊ |
690 | ␉␉␉if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/')␊ |
691 | ␉␉␉{␊ |
692 | ␉␉␉␉if (!YOSEMITE)␊ |
693 | ␉␉␉␉{␊ |
694 | ␉␉␉␉␉//printf(HEADER " (%s).\n", bootInfo->bootFile);␊ |
695 | ␉␉␉␉␉snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading /␊ |
696 | ␉␉␉␉␉//sleep(1);␊ |
697 | ␉␉␉␉} else {␊ |
698 | ␊ |
699 | ␉␉␉␉␉//printf(HEADER " (%s).\n", bootInfo->bootFile);␊ |
700 | ␉␉␉␉␉snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos"%s", bootInfo->bootFile); // Yosemite␊ |
701 | ␉␉␉␉␉//sleep(1);␊ |
702 | ␉␉␉␉}␊ |
703 | ␉␉␉} else {␊ |
704 | ␉␉␉␉strlcpy(bootFile, bootInfo->bootFile, sizeof(bootFile));␊ |
705 | ␉␉␉}␊ |
706 | ␊ |
707 | ␉␉␉// Try to load kernel image from alternate locations on boot helper partitions.␊ |
708 | ␉␉␉ret = -1;␊ |
709 | ␉␉␉if ((gBootVolume->flags & kBVFlagBooter) && !bootFileWithDevice) {␊ |
710 | ␉␉␉␉snprintf(bootFilePath, sizeof(bootFilePath), "com.apple.boot.P%s", bootFile);␊ |
711 | ␉␉␉␉ret = GetFileInfo(NULL, bootFilePath, &flags, &time);␊ |
712 | ␉␉␉␉if (ret == -1)␊ |
713 | ␉␉␉␉{␊ |
714 | ␉␉␉␉␉snprintf(bootFilePath, sizeof(bootFilePath), "com.apple.boot.R%s", bootFile);␊ |
715 | ␉␉␉␉␉ret = GetFileInfo(NULL, bootFilePath, &flags, &time);␊ |
716 | ␉␉␉␉␉if (ret == -1)␊ |
717 | ␉␉␉␉␉{␊ |
718 | ␉␉␉␉␉␉snprintf(bootFilePath, sizeof(bootFilePath), "com.apple.boot.S%s", bootFile);␊ |
719 | ␉␉␉␉␉␉ret = GetFileInfo(NULL, bootFilePath, &flags, &time);␊ |
720 | ␉␉␉␉␉}␊ |
721 | ␉␉␉␉}␊ |
722 | ␉␉␉}␊ |
723 | ␉␉␉if (ret == -1) {␊ |
724 | ␉␉␉␉// No alternate location found, using the original kernel image path.␊ |
725 | ␉␉␉␉strlcpy(bootFilePath, bootFile, sizeof(bootFilePath));␊ |
726 | ␉␉␉}␊ |
727 | ␊ |
728 | ␉␉␉DBG("Loading kernel: '%s'\n", bootFilePath);␊ |
729 | ␉␉␉ret = LoadThinFatFile(bootFilePath, &binary);␊ |
730 | ␉␉␉if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)␊ |
731 | ␉␉␉{␊ |
732 | ␉␉␉␉archCpuType = CPU_TYPE_I386;␊ |
733 | ␉␉␉␉ret = LoadThinFatFile(bootFilePath, &binary);␊ |
734 | ␉␉␉}␊ |
735 | ␉␉} while (0);␊ |
736 | ␊ |
737 | ␉␉clearActivityIndicator();␊ |
738 | ␊ |
739 | #if DEBUG␊ |
740 | ␉␉printf("Pausing...");␊ |
741 | ␉␉sleep(8);␊ |
742 | #endif␊ |
743 | ␊ |
744 | ␉␉if (ret <= 0)␊ |
745 | ␉␉{␊ |
746 | ␉␉␉printf("Can't find %s\n", bootFile);␊ |
747 | ␉␉␉sleep(1);␊ |
748 | ␊ |
749 | ␉␉␉if (gBootFileType == kNetworkDeviceType)␊ |
750 | ␉␉␉{␊ |
751 | ␉␉␉␉// Return control back to PXE. Don't unload PXE base code.␊ |
752 | ␉␉␉␉gUnloadPXEOnExit = false;␊ |
753 | ␉␉␉␉break;␊ |
754 | ␉␉␉}␊ |
755 | ␉␉␉pause();␊ |
756 | ␊ |
757 | ␉␉} else {␊ |
758 | ␉␉␉/* Won't return if successful. */␊ |
759 | ␉␉␉ret = ExecKernel(binary);␊ |
760 | ␉␉}␊ |
761 | ␉}␊ |
762 | ␊ |
763 | ␉// chainboot␊ |
764 | ␉if (status == 1) {␊ |
765 | ␉␉// if we are already in graphics-mode,␊ |
766 | ␉␉if (getVideoMode() == GRAPHICS_MODE) {␊ |
767 | ␉␉␉setVideoMode(VGA_TEXT_MODE, 0); // switch back to text mode.␊ |
768 | ␉␉}␊ |
769 | ␉}␊ |
770 | ␊ |
771 | ␉if ((gBootFileType == kNetworkDeviceType) && gUnloadPXEOnExit) {␊ |
772 | ␉␉nbpUnloadBaseCode();␊ |
773 | ␉}␊ |
774 | }␊ |
775 | ␊ |
776 | /*!␊ |
777 | ␉Selects a new BIOS device, taking care to update the global state appropriately.␊ |
778 | */␊ |
779 | /*␊ |
780 | static void selectBiosDevice(void)␊ |
781 | {␊ |
782 | ␉struct DiskBVMap *oldMap = diskResetBootVolumes(gBIOSDev);␊ |
783 | ␉CacheReset();␊ |
784 | ␉diskFreeMap(oldMap);␊ |
785 | ␉oldMap = NULL;␊ |
786 | ␊ |
787 | ␉int dev = selectAlternateBootDevice(gBIOSDev);␊ |
788 | ␊ |
789 | ␉BVRef bvchain = scanBootVolumes(dev, 0);␊ |
790 | ␉BVRef bootVol = selectBootVolume(bvchain);␊ |
791 | ␉gBootVolume = bootVol;␊ |
792 | ␉setRootVolume(bootVol);␊ |
793 | ␉gBIOSDev = dev;␊ |
794 | }␊ |
795 | */␊ |
796 | ␊ |
797 | bool checkOSVersion(const char * version)␊ |
798 | {␊ |
799 | ␉if ( (sizeof(version) > 4) && (version[3] == '1') ) {␊ |
800 | ␉␉return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1])␊ |
801 | ␉␉&& (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3])␊ |
802 | ␉␉&& (gMacOSVersion[4] == version[4]));␊ |
803 | ␉} else {␊ |
804 | ␉␉return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1])␊ |
805 | ␉␉&& (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]));␊ |
806 | ␉}␊ |
807 | }␊ |
808 | ␊ |
809 | #define BASE 65521L /* largest prime smaller than 65536 */␊ |
810 | #define NMAX 5000␊ |
811 | // NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1␊ |
812 | ␊ |
813 | #define DO1(buf, i)␉{s1 += buf[i]; s2 += s1;}␊ |
814 | #define DO2(buf, i)␉DO1(buf, i); DO1(buf, i + 1);␊ |
815 | #define DO4(buf, i)␉DO2(buf, i); DO2(buf, i + 2);␊ |
816 | #define DO8(buf, i)␉DO4(buf, i); DO4(buf, i + 4);␊ |
817 | #define DO16(buf)␉DO8(buf, 0); DO8(buf, 8);␊ |
818 | ␊ |
819 | unsigned long Adler32(unsigned char *buf, long len)␊ |
820 | {␊ |
821 | ␉unsigned long s1 = 1; // adler & 0xffff;␊ |
822 | ␉unsigned long s2 = 0; // (adler >> 16) & 0xffff;␊ |
823 | ␉unsigned long result;␊ |
824 | ␉int k;␊ |
825 | ␊ |
826 | ␉while (len > 0) {␊ |
827 | ␉␉k = len < NMAX ? len : NMAX;␊ |
828 | ␉␉len -= k;␊ |
829 | ␉␉while (k >= 16) {␊ |
830 | ␉␉␉DO16(buf);␊ |
831 | ␉␉␉buf += 16;␊ |
832 | ␉␉␉k -= 16;␊ |
833 | ␉␉}␊ |
834 | ␉␉if (k != 0) do {␊ |
835 | ␉␉␉s1 += *buf++;␊ |
836 | ␉␉␉s2 += s1;␊ |
837 | ␉␉} while (--k);␊ |
838 | ␉␉s1 %= BASE;␊ |
839 | ␉␉s2 %= BASE;␊ |
840 | ␉}␊ |
841 | ␉result = (s2 << 16) | s1;␊ |
842 | ␉return OSSwapHostToBigInt32(result);␊ |
843 | }␊ |
844 | |