1 | /*␊ |
2 | * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2004 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 | #include "boot.h"␊ |
26 | #include "bootstruct.h"␊ |
27 | #include "fdisk.h"␊ |
28 | #include "ramdisk.h"␊ |
29 | #include "gui.h"␊ |
30 | #include "term.h"␊ |
31 | #include "embedded.h"␊ |
32 | #include "pci.h"␊ |
33 | #include "modules.h"␊ |
34 | ␊ |
35 | #if DEBUG␊ |
36 | ␉#define DBG(x...)␉printf(x)␊ |
37 | #else␊ |
38 | ␉#define DBG(x...)␉msglog(x)␊ |
39 | #endif␊ |
40 | ␊ |
41 | char␉␉gMacOSVersion[OSVERSTRLEN];␊ |
42 | uint32_t␉MacOSVerCurrent = 0;␊ |
43 | bool␉␉showBootBanner = true; //Azi:showinfo␊ |
44 | static bool␉shouldboot = false;␊ |
45 | ␊ |
46 | extern int multiboot_timeout;␊ |
47 | extern int multiboot_timeout_set;␊ |
48 | ␊ |
49 | extern BVRef bvChain;␊ |
50 | //extern int␉␉menucount;␊ |
51 | ␊ |
52 | extern int␉␉gDeviceCount;␊ |
53 | ␊ |
54 | int␉␉␉selectIndex = 0;␊ |
55 | ␊ |
56 | MenuItem *menuItems = NULL;␊ |
57 | ␊ |
58 | enum {␊ |
59 | kMenuTopRow = 5,␊ |
60 | kMenuMaxItems = 10,␊ |
61 | kScreenLastRow = 24␊ |
62 | };␊ |
63 | ␊ |
64 | extern char *msgbuf;␊ |
65 | ␊ |
66 | void showTextBuffer(char *buf_orig, int size);␊ |
67 | ␊ |
68 | //==========================================================================␊ |
69 | ␊ |
70 | // MacOSVer2Int - converts OS ver. string to uint32 (e.g "10.9.5" -> 0x0A090500) for easy comparing␊ |
71 | uint32_t MacOSVer2Int(const char *osver)␊ |
72 | {␊ |
73 | ␉uint32_t result = 0;␊ |
74 | ␉uint8_t *resptr = (uint8_t *)&result;␊ |
75 | ␉uint8_t len = strlen(osver);␊ |
76 | ␉uint8_t i, j, m;␊ |
77 | #define CHR2UINT(c) ((uint8_t)(c - '0'))␊ |
78 | #define ISDIGIT(c) ((c >= '0') && (c <= '9'))␊ |
79 | #define ISDOT(c) (c == '.')␊ |
80 | ␊ |
81 | ␉if (!osver || (len < 4) || (len > OSVERSTRLEN - 1) || !ISDIGIT(osver[0]) || !ISDOT(osver[2]) || !ISDIGIT(osver[len - 1]))␊ |
82 | ␉{␊ |
83 | ␉␉verbose("ERROR: wrong Mac OS version string syntax: '%s'\n", osver);␊ |
84 | ␉␉return 0;␊ |
85 | ␉}␊ |
86 | ␊ |
87 | ␉for (i = 0, j = 3, m = 1; i < len; i++)␊ |
88 | ␉{␊ |
89 | ␉␉if (ISDIGIT(osver[i]))␊ |
90 | ␉␉{␊ |
91 | ␉␉␉resptr[j] = resptr[j] * m + CHR2UINT(osver[i]);␊ |
92 | ␉␉␉m = 10;␊ |
93 | ␉␉}␊ |
94 | ␉␉else if (ISDOT(osver[i]))␊ |
95 | ␉␉{␊ |
96 | ␉␉␉if (j > 0)␊ |
97 | ␉␉␉{␊ |
98 | ␉␉␉␉j--;␊ |
99 | ␉␉␉}␊ |
100 | ␉␉␉else␊ |
101 | ␉␉␉{␊ |
102 | ␉␉␉␉return 0;␊ |
103 | ␉␉␉}␊ |
104 | ␉␉␉m = 1;␊ |
105 | ␉␉}␊ |
106 | ␉␉else␊ |
107 | ␉␉{␊ |
108 | ␉␉␉return 0;␊ |
109 | ␉␉}␊ |
110 | ␉}␊ |
111 | ␊ |
112 | ␉return result;␊ |
113 | }␊ |
114 | ␊ |
115 | //==========================================================================␊ |
116 | ␊ |
117 | typedef struct {␊ |
118 | int x;␊ |
119 | int y;␊ |
120 | int type;␊ |
121 | } CursorState;␊ |
122 | ␊ |
123 | static void changeCursor( int col, int row, int type, CursorState * cs )␊ |
124 | {␊ |
125 | if (cs) getCursorPositionAndType( &cs->x, &cs->y, &cs->type );␊ |
126 | setCursorType( type );␊ |
127 | setCursorPosition( col, row, 0 );␊ |
128 | }␊ |
129 | ␊ |
130 | static void moveCursor( int col, int row )␊ |
131 | {␊ |
132 | setCursorPosition( col, row, 0 );␊ |
133 | }␊ |
134 | ␊ |
135 | static void restoreCursor( const CursorState * cs )␊ |
136 | {␊ |
137 | setCursorPosition( cs->x, cs->y, 0 );␊ |
138 | setCursorType( cs->type );␊ |
139 | }␊ |
140 | ␊ |
141 | //==========================================================================␊ |
142 | ␊ |
143 | /* Flush keyboard buffer; returns TRUE if any of the flushed␊ |
144 | * characters was F8.␊ |
145 | */␊ |
146 | ␊ |
147 | static bool flushKeyboardBuffer(void)␊ |
148 | {␊ |
149 | bool status = false;␊ |
150 | ␊ |
151 | while ( readKeyboardStatus() ) {␊ |
152 | if (bgetc() == 0x4200) status = true;␊ |
153 | }␊ |
154 | return status;␊ |
155 | }␊ |
156 | ␊ |
157 | //==========================================================================␊ |
158 | ␊ |
159 | static int countdown( const char * msg, int row, int timeout )␊ |
160 | {␊ |
161 | ␉unsigned long time;␊ |
162 | ␉int ch = 0;␊ |
163 | ␉int col = strlen(msg) + 1;␊ |
164 | ␊ |
165 | ␉flushKeyboardBuffer();␊ |
166 | ␊ |
167 | ␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
168 | ␉{␊ |
169 | ␉␉moveCursor( 0, row );␊ |
170 | ␉␉printf(msg);␊ |
171 | ␊ |
172 | ␉} else {␊ |
173 | ␊ |
174 | ␉␉position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) );␊ |
175 | ␊ |
176 | ␉␉char dummy[80];␊ |
177 | ␉␉getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true );␊ |
178 | ␉␉drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true );␊ |
179 | ␉␉drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos );␊ |
180 | ␊ |
181 | ␉␉// make this screen the new background␊ |
182 | ␉␉memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );␊ |
183 | ␊ |
184 | ␉}␊ |
185 | ␊ |
186 | ␉int multi_buff = 18 * (timeout);␊ |
187 | ␉int multi = ++multi_buff;␊ |
188 | ␊ |
189 | ␉int lasttime=0;␊ |
190 | ␊ |
191 | ␉for ( time = time18(), timeout++; timeout > 0; )␊ |
192 | ␉{␊ |
193 | ␉␉int currenttime;␊ |
194 | ␉␉if (lasttime)␊ |
195 | ␉␉{␊ |
196 | ␉␉␉currenttime = time18();␊ |
197 | ␉␉␉if( currenttime > lasttime)␊ |
198 | ␉␉␉{␊ |
199 | ␉␉␉␉multi -= (currenttime - lasttime);␊ |
200 | ␉␉␉␉if (multi < 0)␊ |
201 | ␉␉␉␉{␊ |
202 | ␉␉␉␉␉multi = 0;␊ |
203 | ␉␉␉␉}␊ |
204 | ␉␉␉␉lasttime=currenttime;␊ |
205 | ␉␉␉}␊ |
206 | ␉␉}␊ |
207 | ␉␉else␊ |
208 | ␉␉{␊ |
209 | ␉␉␉lasttime = currenttime = time;␊ |
210 | ␉␉}␊ |
211 | ␊ |
212 | ␉␉if ( (ch = readKeyboardStatus()) )␊ |
213 | ␉␉␉break;␊ |
214 | ␊ |
215 | ␉␉// Count can be interrupted by holding down shift,␊ |
216 | ␉␉// control or alt key␊ |
217 | ␉␉if ( ( readKeyboardShiftFlags() & 0x0F ) != 0 )␊ |
218 | ␉␉{␊ |
219 | ␉␉␉ch = 1;␊ |
220 | ␉␉␉break;␊ |
221 | ␉␉}␊ |
222 | ␊ |
223 | ␉␉if ( currenttime >= time )␊ |
224 | ␉␉{␊ |
225 | ␉␉␉time += 18;␊ |
226 | ␉␉␉timeout--;␊ |
227 | ␊ |
228 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
229 | ␉␉␉{␊ |
230 | ␉␉␉␉moveCursor( col, row );␊ |
231 | ␉␉␉␉printf("(%d) ", timeout);␊ |
232 | ␉␉␉}␊ |
233 | ␉␉}␊ |
234 | ␊ |
235 | ␉␉if( bootArgs->Video.v_display != VGA_TEXT_MODE )␊ |
236 | ␉␉{␊ |
237 | ␉␉␉drawProgressBar( gui.screen.pixmap, 100, gui.progressbar.pos , ( multi * 100 / multi_buff ) );␊ |
238 | ␉␉␉gui.redraw = true;␊ |
239 | ␉␉␉updateVRAM();␊ |
240 | ␉␉}␊ |
241 | ␊ |
242 | ␉}␊ |
243 | ␊ |
244 | ␉flushKeyboardBuffer();␊ |
245 | ␊ |
246 | ␉return ch;␊ |
247 | }␊ |
248 | ␊ |
249 | //==========================================================================␊ |
250 | ␊ |
251 | char␉␉gBootArgs[BOOT_STRING_LEN];␊ |
252 | static char␉*gBootArgsPtr = gBootArgs;␊ |
253 | static char␉*gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1;␊ |
254 | static char␉booterCommand[BOOT_STRING_LEN];␊ |
255 | static char␉booterParam[BOOT_STRING_LEN];␊ |
256 | ␊ |
257 | static void clearBootArgs(void)␊ |
258 | {␊ |
259 | ␉gBootArgsPtr = gBootArgs;␊ |
260 | ␉memset(gBootArgs, '\0', BOOT_STRING_LEN);␊ |
261 | ␊ |
262 | ␉if (bootArgs->Video.v_display != VGA_TEXT_MODE)␊ |
263 | ␉{␊ |
264 | ␉␉clearGraphicBootPrompt();␊ |
265 | ␉}␊ |
266 | ␉execute_hook("ClearArgs", NULL, NULL, NULL, NULL);␊ |
267 | }␊ |
268 | ␊ |
269 | void addBootArg(const char *argStr)␊ |
270 | {␊ |
271 | ␉if ( (gBootArgsPtr + strlen(argStr) + 1) < gBootArgsEnd)␊ |
272 | ␉{␊ |
273 | ␉␉if(gBootArgsPtr != gBootArgs) *gBootArgsPtr++ = ' ';␊ |
274 | ␉␉strlcat(gBootArgs, argStr, BOOT_STRING_LEN);␊ |
275 | ␉␉gBootArgsPtr += strlen(argStr);␊ |
276 | ␉}␊ |
277 | }␊ |
278 | ␊ |
279 | //==========================================================================␊ |
280 | ␊ |
281 | static void showBootPrompt(int row, bool visible)␊ |
282 | {␊ |
283 | ␉extern char bootPrompt[];␊ |
284 | ␉extern char bootRescanPrompt[];␊ |
285 | ␊ |
286 | ␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
287 | ␉{␊ |
288 | ␉␉changeCursor( 0, row, kCursorTypeUnderline, 0 );␊ |
289 | ␉␉clearScreenRows( row, kScreenLastRow );␊ |
290 | ␉}␊ |
291 | ␊ |
292 | ␉clearBootArgs();␊ |
293 | ␊ |
294 | ␉if (visible)␊ |
295 | ␉{␊ |
296 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
297 | ␉␉{␊ |
298 | ␉␉␉if (gEnableCDROMRescan)␊ |
299 | ␉␉␉{␊ |
300 | ␉␉␉␉printf( bootRescanPrompt );␊ |
301 | ␉␉␉}␊ |
302 | ␉␉␉else␊ |
303 | ␉␉␉{␊ |
304 | ␉␉␉␉printf( bootPrompt );␊ |
305 | ␉␉␉␉printf( gBootArgs );␊ |
306 | ␉␉␉}␊ |
307 | ␉␉}␊ |
308 | ␉}␊ |
309 | ␉else␊ |
310 | ␉{␊ |
311 | ␉␉if (bootArgs->Video.v_display != VGA_TEXT_MODE)␊ |
312 | ␉␉{␊ |
313 | ␉␉␉clearGraphicBootPrompt();␊ |
314 | ␉␉}␊ |
315 | ␉␉else␊ |
316 | ␉␉{␊ |
317 | ␉␉␉printf("Press Enter to start up the foreign OS. ");␊ |
318 | ␉␉}␊ |
319 | ␉}␊ |
320 | }␊ |
321 | ␊ |
322 | //==========================================================================␊ |
323 | ␊ |
324 | static void updateBootArgs( int key )␊ |
325 | {␊ |
326 | ␉key = ASCII_KEY(key);␊ |
327 | ␊ |
328 | ␉switch ( key )␊ |
329 | ␉{␊ |
330 | ␉␉case KEY_BKSP:␊ |
331 | ␉␉␉if ( gBootArgsPtr > gBootArgs )␊ |
332 | ␉␉␉{␊ |
333 | ␉␉␉␉*--gBootArgsPtr = '\0';␊ |
334 | ␊ |
335 | ␉␉␉␉int x, y, t;␊ |
336 | ␉␉␉␉getCursorPositionAndType( &x, &y, &t );␊ |
337 | ␉␉␉␉if ( x == 0 && y )␊ |
338 | ␉␉␉␉{␊ |
339 | ␉␉␉␉␉x = 80; y--;␊ |
340 | ␉␉␉␉}␊ |
341 | ␊ |
342 | ␉␉␉␉if (x)␊ |
343 | ␉␉␉␉{␊ |
344 | ␉␉␉␉␉x--;␊ |
345 | ␉␉␉␉}␊ |
346 | ␊ |
347 | ␉␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
348 | ␉␉␉␉{␊ |
349 | ␉␉␉␉␉setCursorPosition( x, y, 0 );␊ |
350 | ␉␉␉␉␉putca(' ', 0x07, 1);␊ |
351 | ␉␉␉␉}␊ |
352 | ␉␉␉␉else␊ |
353 | ␉␉␉␉{␊ |
354 | ␉␉␉␉␉updateGraphicBootPrompt();␊ |
355 | ␉␉␉␉}␊ |
356 | ␉␉␉}␊ |
357 | ␉␉␉break;␊ |
358 | ␊ |
359 | ␉default:␊ |
360 | ␉␉␉if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)␊ |
361 | ␉␉␉{␊ |
362 | ␉␉␉␉*gBootArgsPtr++ = key;␊ |
363 | ␊ |
364 | ␉␉␉␉if( bootArgs->Video.v_display != VGA_TEXT_MODE )␊ |
365 | ␉␉␉␉{␊ |
366 | ␉␉␉␉␉updateGraphicBootPrompt();␊ |
367 | ␉␉␉␉}␊ |
368 | ␉␉␉␉else if ( key >= ' ' && key < 0x7f)␊ |
369 | ␉␉␉␉{␊ |
370 | ␉␉␉␉␉putchar(key);␊ |
371 | ␉␉␉␉}␊ |
372 | ␉␉␉}␊ |
373 | ␊ |
374 | ␉␉␉break;␊ |
375 | ␉}␊ |
376 | }␊ |
377 | ␊ |
378 | //==========================================================================␊ |
379 | ␊ |
380 | static const MenuItem *gMenuItems = NULL;␊ |
381 | ␊ |
382 | static int gMenuItemCount;␊ |
383 | static int gMenuRow;␊ |
384 | static int gMenuHeight;␊ |
385 | static int gMenuTop;␊ |
386 | static int gMenuBottom;␊ |
387 | static int gMenuSelection;␊ |
388 | ␊ |
389 | static int␉ gMenuStart;␊ |
390 | static int␉ gMenuEnd;␊ |
391 | ␊ |
392 | static void printMenuItem( const MenuItem *item, int highlight )␊ |
393 | {␊ |
394 | ␉printf(" ");␊ |
395 | ␊ |
396 | ␉if ( highlight )␊ |
397 | ␉{␊ |
398 | ␉␉putca(' ', 0x70, strlen(item->name) + 4);␊ |
399 | ␉}␊ |
400 | ␉else␊ |
401 | ␉{␊ |
402 | ␉␉putca(' ', 0x07, 40);␊ |
403 | ␉}␊ |
404 | ␊ |
405 | ␉printf(" %40s\n", item->name);␊ |
406 | }␊ |
407 | ␊ |
408 | //==========================================================================␊ |
409 | ␊ |
410 | static void showMenu( const MenuItem * items, int count,␊ |
411 | int selection, int row, int height )␊ |
412 | {␊ |
413 | int i;␊ |
414 | CursorState cursorState;␊ |
415 | ␊ |
416 | if ( items == NULL || count == 0 ) ␊ |
417 | ␉␉return;␊ |
418 | ␊ |
419 | // head and tail points to the start and the end of the list.␊ |
420 | // top and bottom points to the first and last visible items␊ |
421 | // in the menu window.␊ |
422 | ␊ |
423 | gMenuItems␉␉= items;␊ |
424 | gMenuRow␉␉= row;␊ |
425 | gMenuHeight␉␉= height;␊ |
426 | gMenuItemCount␉= count;␊ |
427 | gMenuTop␉␉= 0;␊ |
428 | gMenuBottom␉␉= MIN( count, height ) - 1;␊ |
429 | gMenuSelection␉= selection;␊ |
430 | ␊ |
431 | gMenuStart␉␉= 0;␊ |
432 | gMenuEnd␉ = MIN( count, gui.maxdevices ) - 1;␊ |
433 | ␊ |
434 | ␉// If the selected item is not visible, shift the list down.␊ |
435 | ␊ |
436 | if ( gMenuSelection > gMenuBottom )␊ |
437 | {␊ |
438 | gMenuTop += ( gMenuSelection - gMenuBottom );␊ |
439 | gMenuBottom = gMenuSelection;␊ |
440 | }␊ |
441 | ␊ |
442 | ␉if ( gMenuSelection > gMenuEnd )␊ |
443 | {␊ |
444 | ␉␉gMenuStart += ( gMenuSelection - gMenuEnd );␊ |
445 | gMenuEnd = gMenuSelection;␊ |
446 | }␊ |
447 | ␉␊ |
448 | ␉// Draw the visible items.␊ |
449 | ␊ |
450 | ␉if( bootArgs->Video.v_display != VGA_TEXT_MODE )␊ |
451 | ␉{␊ |
452 | ␉␉drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection);␊ |
453 | ␉}␊ |
454 | ␉else␊ |
455 | ␉{␊ |
456 | ␉␉changeCursor( 0, row, kCursorTypeHidden, &cursorState );␊ |
457 | ␊ |
458 | ␉␉for ( i = gMenuTop; i <= gMenuBottom; i++ )␊ |
459 | ␉␉{␊ |
460 | ␉␉␉printMenuItem( &items[i], (i == gMenuSelection) );␊ |
461 | ␉␉}␊ |
462 | ␊ |
463 | ␉␉restoreCursor( &cursorState );␊ |
464 | ␉}␊ |
465 | }␊ |
466 | ␊ |
467 | //==========================================================================␊ |
468 | ␊ |
469 | static int updateMenu( int key, void ** paramPtr )␊ |
470 | {␊ |
471 | ␉int moved = 0;␊ |
472 | ␊ |
473 | ␉union {␊ |
474 | ␉␉struct {␊ |
475 | ␉␉␉unsigned int␊ |
476 | ␉␉␉selectionUp : 1,␊ |
477 | ␉␉␉selectionDown : 1,␊ |
478 | ␉␉␉scrollUp : 1,␊ |
479 | ␉␉␉scrollDown : 1;␊ |
480 | ␉␉} f;␊ |
481 | ␉␉unsigned int w;␊ |
482 | ␉} draw = {{0}};␊ |
483 | ␊ |
484 | ␉if ( gMenuItems == NULL )␊ |
485 | ␉␉return 0;␊ |
486 | ␊ |
487 | ␉if( bootArgs->Video.v_display != VGA_TEXT_MODE )␊ |
488 | ␉{␊ |
489 | ␉␉int res;␊ |
490 | ␊ |
491 | ␉␉// set navigation keys for horizontal layout as defaults␊ |
492 | ␉␉int previous␉= 0x4B00;␉␉// left arrow␊ |
493 | ␉␉int subsequent␉= 0x4D00;␉␉// right arrow␊ |
494 | ␉␉int menu␉= 0x5000;␉␉// down arrow␊ |
495 | ␊ |
496 | ␉␉if ( gui.layout == VerticalLayout )␊ |
497 | ␉␉{␊ |
498 | ␉␉␉// set navigation keys for vertical layout␊ |
499 | ␉␉␉previous␉= 0x4800;␉␉// up arrow␊ |
500 | ␉␉␉subsequent␉= 0x5000;␉␉// down arrow␊ |
501 | ␉␉␉menu␉␉= 0x4B00;␉␉// right arrow␊ |
502 | ␉␉}␊ |
503 | ␊ |
504 | ␉␉if ( key == previous )␊ |
505 | ␉␉{␊ |
506 | ␉␉␉if ( gMenuSelection > gMenuTop )␊ |
507 | ␉␉␉␉draw.f.selectionUp = 1;␊ |
508 | ␉␉␉else if ( gMenuTop > 0 )␊ |
509 | ␉␉␉␉draw.f.scrollDown = 1;␊ |
510 | ␊ |
511 | ␉␉}␊ |
512 | ␉␉␊ |
513 | ␉␉else if ( key == subsequent )␊ |
514 | ␉␉{␊ |
515 | ␉␉␉if ( gMenuSelection != gMenuBottom)␊ |
516 | ␉␉␉␉draw.f.selectionDown = 1;␊ |
517 | ␉␉␉else if ( gMenuBottom < ( gMenuItemCount - 1 ) )␊ |
518 | ␉␉␉␉draw.f.scrollUp = 1;␊ |
519 | ␉␉}␊ |
520 | ␉␉␊ |
521 | ␉␉else if ( key == menu )␊ |
522 | ␉␉{␊ |
523 | ␉␉␉if ( gui.menu.draw )␊ |
524 | ␉␉␉␉updateInfoMenu(key);␊ |
525 | ␉␉␉else␊ |
526 | ␉␉␉␉drawInfoMenu();␊ |
527 | ␉␉}␊ |
528 | ␊ |
529 | ␉␉else if ( gui.menu.draw )␊ |
530 | ␉␉{␊ |
531 | ␉␉␉res = updateInfoMenu(key);␊ |
532 | ␊ |
533 | ␉␉␉if ( res == CLOSE_INFO_MENU )␊ |
534 | ␉␉␉␉gui.menu.draw = false;␊ |
535 | ␉␉␉else␊ |
536 | ␉␉␉{␊ |
537 | ␉␉␉␉shouldboot = ( res != DO_NOT_BOOT );␊ |
538 | ␊ |
539 | ␉␉␉␉if ( shouldboot )␊ |
540 | ␉␉␉␉␉gui.menu.draw = false;␊ |
541 | ␊ |
542 | ␉␉␉␉switch (res)␊ |
543 | ␉␉␉␉{␊ |
544 | ␉␉␉␉␉case BOOT_NORMAL:␊ |
545 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
546 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
547 | ␉␉␉␉␉␉break;␊ |
548 | ␊ |
549 | ␉␉␉␉␉case BOOT_VERBOSE:␊ |
550 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
551 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
552 | ␉␉␉␉␉␉addBootArg(kVerboseModeFlag);␊ |
553 | ␉␉␉␉␉␉break;␊ |
554 | ␊ |
555 | ␉␉␉␉␉case BOOT_IGNORECACHE:␊ |
556 | ␉␉␉␉␉␉gVerboseMode = false;␊ |
557 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
558 | ␉␉␉␉␉␉addBootArg(kIgnoreCachesFlag);␊ |
559 | ␉␉␉␉␉␉break;␊ |
560 | ␊ |
561 | ␉␉␉␉␉case BOOT_SINGLEUSER:␊ |
562 | ␉␉␉␉␉␉gVerboseMode = true;␊ |
563 | ␉␉␉␉␉␉gBootMode = kBootModeNormal;␊ |
564 | ␉␉␉␉␉␉addBootArg(kSingleUserModeFlag);␊ |
565 | ␉␉␉␉␉␉break;␊ |
566 | ␉␉␉␉}␊ |
567 | ␊ |
568 | ␉␉␉}␊ |
569 | ␊ |
570 | ␉␉}␊ |
571 | ␊ |
572 | ␉}␊ |
573 | ␉else␊ |
574 | ␉{␊ |
575 | ␉␉switch ( key )␊ |
576 | ␉␉{␊ |
577 | ␉case 0x4800: // Up Arrow␊ |
578 | ␉␉␉␉if ( gMenuSelection != gMenuTop )␊ |
579 | ␉␉␉␉␉draw.f.selectionUp = 1;␊ |
580 | ␉␉␉␉else if ( gMenuTop > 0 )␊ |
581 | ␉␉␉␉␉draw.f.scrollDown = 1;␊ |
582 | ␉␉␉␉break;␊ |
583 | ␊ |
584 | ␉␉␉case 0x5000: // Down Arrow␊ |
585 | ␉␉␉␉if ( gMenuSelection != gMenuBottom )␊ |
586 | ␉␉␉␉␉draw.f.selectionDown = 1;␊ |
587 | ␉␉␉␉else if ( gMenuBottom < (gMenuItemCount - 1) ) ␊ |
588 | ␉␉␉␉␉draw.f.scrollUp = 1;␊ |
589 | ␉␉␉␉break;␊ |
590 | ␉␉}␊ |
591 | ␉}␊ |
592 | ␊ |
593 | ␉if ( draw.w )␊ |
594 | ␉{␊ |
595 | ␉␉if ( draw.f.scrollUp )␊ |
596 | ␉␉{␊ |
597 | ␉␉␉scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1);␊ |
598 | ␉␉␉gMenuTop++; gMenuBottom++;␊ |
599 | ␉␉␉gMenuStart++; gMenuEnd++;␊ |
600 | ␉␉␉draw.f.selectionDown = 1;␊ |
601 | ␉␉}␊ |
602 | ␊ |
603 | ␉␉if ( draw.f.scrollDown )␊ |
604 | ␉␉{␊ |
605 | ␉␉␉scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1);␊ |
606 | ␉␉␉gMenuTop--; gMenuBottom--;␊ |
607 | ␉␉␉gMenuStart--; gMenuEnd--;␊ |
608 | ␉␉␉draw.f.selectionUp = 1;␊ |
609 | ␉␉}␊ |
610 | ␊ |
611 | ␉␉if ( draw.f.selectionUp || draw.f.selectionDown )␊ |
612 | ␉␉{␊ |
613 | ␉␉␉CursorState cursorState;␊ |
614 | ␊ |
615 | ␉␉␉// Set cursor at current position, and clear inverse video.␊ |
616 | ␊ |
617 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
618 | ␉␉␉{␊ |
619 | ␉␉␉␉changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState );␊ |
620 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 0 );␊ |
621 | ␉␉␉}␊ |
622 | ␊ |
623 | ␉␉␉if ( draw.f.selectionUp )␊ |
624 | ␉␉␉{␊ |
625 | ␉␉␉␉gMenuSelection--;␊ |
626 | ␉␉␉␉if(( gMenuSelection - gMenuStart) == -1 )␊ |
627 | ␉␉␉␉{␊ |
628 | ␉␉␉␉␉gMenuStart--;␊ |
629 | ␉␉␉␉␉gMenuEnd--;␊ |
630 | ␉␉␉␉}␊ |
631 | ␊ |
632 | ␉␉␉}␊ |
633 | ␉␉␉else␊ |
634 | ␉␉␉{␊ |
635 | ␉␉␉␉gMenuSelection++;␊ |
636 | ␉␉␉␉if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 )␊ |
637 | ␉␉␉␉{␊ |
638 | ␉␉␉␉␉gMenuStart++;␊ |
639 | ␉␉␉␉␉gMenuEnd++;␊ |
640 | ␉␉␉␉}␊ |
641 | ␉␉␉}␊ |
642 | ␊ |
643 | ␉␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE )␊ |
644 | ␉␉␉{␊ |
645 | ␉␉␉␉moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop );␊ |
646 | ␉␉␉␉printMenuItem( &gMenuItems[gMenuSelection], 1 );␊ |
647 | ␉␉␉␉restoreCursor( &cursorState );␊ |
648 | ␊ |
649 | ␉␉␉}␊ |
650 | ␉␉␉else␊ |
651 | ␉␉␉{␊ |
652 | ␉␉␉␉drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection);␊ |
653 | ␉␉␉}␊ |
654 | ␉␉}␊ |
655 | ␊ |
656 | ␉␉*paramPtr = gMenuItems[gMenuSelection].param;␊ |
657 | ␉␉moved = 1;␊ |
658 | ␉}␊ |
659 | ␊ |
660 | ␉return moved;␊ |
661 | }␊ |
662 | ␊ |
663 | //==========================================================================␊ |
664 | ␊ |
665 | static void skipblanks( const char ** cpp ) ␊ |
666 | {␊ |
667 | ␉while (**(cpp) == ' ' || **(cpp) == '\t' ) ++(*cpp);␊ |
668 | }␊ |
669 | ␊ |
670 | //==========================================================================␊ |
671 | ␊ |
672 | static const char *extractKernelName( char ** cpp )␊ |
673 | {␊ |
674 | char * kn = *cpp;␊ |
675 | char * cp = *cpp;␊ |
676 | char c;␊ |
677 | ␊ |
678 | // Convert char to lower case.␊ |
679 | ␊ |
680 | c = *cp | 0x20;␊ |
681 | ␊ |
682 | // Must start with a letter or a '/'.␊ |
683 | ␊ |
684 | if ( (c < 'a' || c > 'z') && ( c != '/' ) )␊ |
685 | return 0;␊ |
686 | ␊ |
687 | // Keep consuming characters until we hit a separator.␊ |
688 | ␊ |
689 | while ( *cp && (*cp != '=') && (*cp != ' ') && (*cp != '\t') )␊ |
690 | cp++;␊ |
691 | ␊ |
692 | // Only SPACE or TAB separator is accepted.␊ |
693 | // Reject everything else.␊ |
694 | ␊ |
695 | if (*cp == '=')␊ |
696 | return 0;␊ |
697 | ␊ |
698 | // Overwrite the separator, and move the pointer past␊ |
699 | // the kernel name.␊ |
700 | ␊ |
701 | if (*cp != '\0') *cp++ = '\0';␊ |
702 | *cpp = cp;␊ |
703 | ␊ |
704 | return kn;␊ |
705 | }␊ |
706 | ␊ |
707 | //==========================================================================␊ |
708 | ␊ |
709 | static void printMemoryInfo(void)␊ |
710 | {␊ |
711 | int line;␊ |
712 | int i;␊ |
713 | MemoryRange *mp = bootInfo->memoryMap;␊ |
714 | ␊ |
715 | // Activate and clear page 1␊ |
716 | setActiveDisplayPage(1);␊ |
717 | clearScreenRows(0, 24);␊ |
718 | setCursorPosition( 0, 0, 1 );␊ |
719 | ␊ |
720 | printf("BIOS reported memory ranges:\n");␊ |
721 | line = 1;␊ |
722 | for (i=0; i<bootInfo->memoryMapCount; i++) {␊ |
723 | printf("Base 0x%08x%08x, ",␊ |
724 | (unsigned long)(mp->base >> 32),␊ |
725 | (unsigned long)(mp->base));␊ |
726 | printf("length 0x%08x%08x, type %d\n",␊ |
727 | (unsigned long)(mp->length >> 32),␊ |
728 | (unsigned long)(mp->length),␊ |
729 | mp->type);␊ |
730 | if (line++ > 20) {␊ |
731 | pause();␊ |
732 | line = 0;␊ |
733 | }␊ |
734 | mp++;␊ |
735 | }␊ |
736 | if (line > 0) {␊ |
737 | pause();␊ |
738 | }␊ |
739 | ␊ |
740 | setActiveDisplayPage(0);␊ |
741 | }␊ |
742 | ␊ |
743 | char *getMemoryInfoString()␊ |
744 | {␊ |
745 | ␉int i, bufflen;␊ |
746 | ␉MemoryRange *mp = bootInfo->memoryMap;␊ |
747 | ␉char *buff = malloc(sizeof(char)*1024);␊ |
748 | ␉if(!buff) {␊ |
749 | ␉␉return 0;␊ |
750 | ␉}␊ |
751 | ␊ |
752 | ␉static const char info[] = "BIOS reported memory ranges:\n";␊ |
753 | ␉bufflen = sprintf(buff, "%s", info);␊ |
754 | ␊ |
755 | ␉for (i = 0;␊ |
756 | ␉␉(i < bootInfo->memoryMapCount) && (bufflen < 1024); /* prevent buffer overflow */␊ |
757 | ␉␉i++) {␊ |
758 | ␉␉bufflen += snprintf(buff+bufflen, 1024-bufflen, "Base 0x%08x%08x, ",␊ |
759 | (unsigned)(mp->base >> 32),␊ |
760 | (unsigned)(mp->base));␊ |
761 | ␉␉bufflen += snprintf(buff+bufflen, 1024-bufflen, "length 0x%08x%08x, type %d\n",␊ |
762 | (unsigned)(mp->length >> 32),␊ |
763 | (unsigned)(mp->length),␊ |
764 | (int) mp->type);␊ |
765 | ␉␉mp++;␊ |
766 | ␉}␊ |
767 | ␉return buff;␊ |
768 | }␊ |
769 | ␊ |
770 | //==========================================================================␊ |
771 | ␊ |
772 | void lspci(void)␊ |
773 | {␊ |
774 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
775 | ␉{␊ |
776 | ␉␉setActiveDisplayPage(1);␊ |
777 | ␉␉clearScreenRows(0, 24);␊ |
778 | ␉␉setCursorPosition(0, 0, 1);␊ |
779 | ␉}␊ |
780 | ␊ |
781 | ␉dump_pci_dt(root_pci_dev->children);␊ |
782 | ␊ |
783 | ␉pause();␊ |
784 | ␊ |
785 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
786 | ␉{␊ |
787 | ␉␉setActiveDisplayPage(0);␊ |
788 | ␉}␊ |
789 | }␊ |
790 | ␊ |
791 | //==========================================================================␊ |
792 | ␊ |
793 | int getBootOptions(bool firstRun)␊ |
794 | {␊ |
795 | ␉int i;␊ |
796 | ␉int key;␊ |
797 | ␉int nextRow;␊ |
798 | ␉int timeout;␊ |
799 | ␉int bvCount;␊ |
800 | ␉BVRef bvr;␊ |
801 | ␉BVRef menuBVR;␊ |
802 | ␉bool showPrompt, newShowPrompt, isCDROM;␊ |
803 | ␊ |
804 | ␉// Initialize default menu selection entry.␊ |
805 | ␉gBootVolume = menuBVR = selectBootVolume(bvChain);␊ |
806 | ␊ |
807 | ␉if (biosDevIsCDROM(gBIOSDev)) {␊ |
808 | ␉␉isCDROM = true;␊ |
809 | ␉} else {␊ |
810 | ␉␉isCDROM = false;␊ |
811 | ␉}␊ |
812 | ␊ |
813 | ␉// ensure we're in graphics mode if gui is setup␊ |
814 | ␉if (firstRun && gui.initialised && bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
815 | ␉{␊ |
816 | ␉␉setVideoMode( GRAPHICS_MODE );␊ |
817 | ␉}␊ |
818 | ␊ |
819 | ␉// Clear command line boot arguments␊ |
820 | ␉clearBootArgs();␊ |
821 | ␊ |
822 | ␉// Allow user to override default timeout.␊ |
823 | ␉if (multiboot_timeout_set) {␊ |
824 | ␉␉timeout = multiboot_timeout;␊ |
825 | ␉} else if (!getIntForKey(kTimeoutKey, &timeout, &bootInfo->chameleonConfig)) {␊ |
826 | ␉␉/* If there is no timeout key in the file use the default timeout␊ |
827 | ␉␉ which is different for CDs vs. hard disks. However, if not booting␊ |
828 | ␉␉ a CD and no config file could be loaded set the timeout␊ |
829 | ␉␉ to zero which causes the menu to display immediately.␊ |
830 | ␉␉ This way, if no partitions can be found, that is the disk is unpartitioned␊ |
831 | ␉␉ or simply cannot be read) then an empty menu is displayed.␊ |
832 | ␉␉ If some partitions are found, for example a Windows partition, then␊ |
833 | ␉␉ these will be displayed in the menu as foreign partitions.␊ |
834 | ␉␉ */␊ |
835 | ␉␉if (isCDROM) {␊ |
836 | ␉␉␉timeout = kCDBootTimeout;␊ |
837 | ␉␉} else {␊ |
838 | ␉␉␉timeout = sysConfigValid ? kBootTimeout : 0;␊ |
839 | ␉␉}␊ |
840 | ␉}␊ |
841 | ␊ |
842 | ␉if (timeout < 0) {␊ |
843 | ␉␉gBootMode |= kBootModeQuiet;␊ |
844 | ␉}␊ |
845 | ␊ |
846 | ␉// If the user is holding down a modifier key, enter safe mode.␊ |
847 | ␉if ((readKeyboardShiftFlags() & 0x0F) != 0) {␊ |
848 | ␉␉gBootMode |= kBootModeSafe;␊ |
849 | ␉}␊ |
850 | ␊ |
851 | ␉// Checking user pressed keys␊ |
852 | ␉bool f8press = false, spress = false, vpress = false;␊ |
853 | ␉while (readKeyboardStatus()) {␊ |
854 | ␉␉key = bgetc ();␊ |
855 | ␉␉if (key == 0x4200) f8press = true;␊ |
856 | ␉␉if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;␊ |
857 | ␉␉if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;␊ |
858 | ␉}␊ |
859 | ␉// If user typed F8, abort quiet mode, and display the menu.␊ |
860 | ␉if (f8press) {␊ |
861 | ␉␉gBootMode &= ~kBootModeQuiet;␊ |
862 | ␉␉timeout = 0;␊ |
863 | ␉}␊ |
864 | ␉// If user typed 'v' or 'V', boot in verbose mode.␊ |
865 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && vpress) {␊ |
866 | ␉␉addBootArg(kVerboseModeFlag);␊ |
867 | ␉}␊ |
868 | ␉// If user typed 's' or 'S', boot in single user mode.␊ |
869 | ␉if ((gBootMode & kBootModeQuiet) && firstRun && spress) {␊ |
870 | ␉␉addBootArg(kSingleUserModeFlag);␊ |
871 | ␉}␊ |
872 | ␊ |
873 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE) {␊ |
874 | ␉␉setCursorPosition(0, 0, 0);␊ |
875 | ␉␉clearScreenRows(0, kScreenLastRow);␊ |
876 | ␉␉if (!(gBootMode & kBootModeQuiet)) {␊ |
877 | ␉␉␉// Display banner and show hardware info.␊ |
878 | ␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
879 | ␉␉␉printf(getVBEInfoString());␊ |
880 | ␉␉}␊ |
881 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
882 | ␉␉verbose("Scanning device %x...\n", gBIOSDev);␊ |
883 | ␉}␊ |
884 | ␊ |
885 | ␉// When booting from CD, default to hard drive boot when possible. ␊ |
886 | ␉if (isCDROM && firstRun) {␊ |
887 | ␉␉const char *val;␊ |
888 | ␉␉char *prompt = NULL;␊ |
889 | ␉␉char *name = NULL;␊ |
890 | ␉␉int cnt;␊ |
891 | ␉␉int optionKey;␊ |
892 | ␊ |
893 | ␉␉if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->chameleonConfig)) {␊ |
894 | ␉␉␉prompt = malloc(cnt + 1);␊ |
895 | ␉␉␉strncat(prompt, val, cnt);␊ |
896 | ␉␉} else {␊ |
897 | ␉␉␉name = malloc(80);␊ |
898 | ␉␉␉getBootVolumeDescription(gBootVolume, name, 79, false);␊ |
899 | ␉␉␉prompt = malloc(256);␊ |
900 | ␉␉␉sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);␊ |
901 | ␉␉␉free(name);␊ |
902 | ␉␉}␊ |
903 | ␊ |
904 | ␉␉if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->chameleonConfig )) {␊ |
905 | ␉␉␉// The key specified is a special key.␊ |
906 | ␉␉} else {␊ |
907 | ␉␉␉// Default to F8.␊ |
908 | ␉␉␉optionKey = 0x4200;␊ |
909 | ␉␉}␊ |
910 | ␊ |
911 | ␉␉// If the timeout is zero then it must have been set above due to the␊ |
912 | ␉␉// early catch of F8 which means the user wants to set boot options␊ |
913 | ␉␉// which we ought to interpret as meaning he wants to boot the CD.␊ |
914 | ␉␉if (timeout != 0) {␊ |
915 | ␉␉␉key = countdown(prompt, kMenuTopRow, timeout);␊ |
916 | ␉␉} else {␊ |
917 | ␉␉␉key = optionKey;␊ |
918 | ␉␉}␊ |
919 | ␊ |
920 | ␉␉if (prompt != NULL) {␊ |
921 | ␉␉␉free(prompt);␊ |
922 | ␉␉}␊ |
923 | ␊ |
924 | ␉␉clearScreenRows( kMenuTopRow, kMenuTopRow + 2 );␊ |
925 | ␊ |
926 | ␉␉// Hit the option key ?␊ |
927 | ␉␉if (key == optionKey) {␊ |
928 | ␉␉␉gBootMode &= ~kBootModeQuiet;␊ |
929 | ␉␉␉timeout = 0;␊ |
930 | ␉␉} else {␊ |
931 | ␉␉␉key = key & 0xFF;␊ |
932 | ␊ |
933 | ␉␉␉// Try booting hard disk if user pressed 'h'␊ |
934 | ␉␉␉if (biosDevIsCDROM(gBIOSDev) && key == 'h') {␊ |
935 | ␉␉␉␉BVRef bvr;␊ |
936 | ␊ |
937 | ␉␉␉␉// Look at partitions hosting OS X other than the CD-ROM␊ |
938 | ␉␉␉␉for (bvr = bvChain; bvr; bvr=bvr->next) {␊ |
939 | ␉␉␉␉␉if ((bvr->flags & kBVFlagSystemVolume) && bvr->biosdev != gBIOSDev) {␊ |
940 | ␉␉␉␉␉␉gBootVolume = bvr;␊ |
941 | ␉␉␉␉␉}␊ |
942 | ␉␉␉␉}␊ |
943 | ␉␉␉}␊ |
944 | ␉␉␉goto done;␊ |
945 | ␉␉}␊ |
946 | ␉}␊ |
947 | ␊ |
948 | ␉if (gBootMode & kBootModeQuiet) {␊ |
949 | ␉␉// No input allowed from user.␊ |
950 | ␉␉goto done;␊ |
951 | ␉}␊ |
952 | ␊ |
953 | ␉if (firstRun && timeout > 0 && countdown("Press any key to enter startup options.", kMenuTopRow, timeout) == 0) {␊ |
954 | ␉␉// If the user is holding down a modifier key,␊ |
955 | ␉␉// enter safe mode.␊ |
956 | ␉␉if ((readKeyboardShiftFlags() & 0x0F) != 0) {␊ |
957 | ␉␉␉gBootMode |= kBootModeSafe;␊ |
958 | ␉␉}␊ |
959 | ␉␉goto done;␊ |
960 | ␉}␊ |
961 | ␊ |
962 | ␉if (gDeviceCount > 0) {␊ |
963 | ␉␉// Allocate memory for an array of menu items.␊ |
964 | ␉␉menuItems = malloc(sizeof(MenuItem) * gDeviceCount);␊ |
965 | ␉␉if (menuItems == NULL) {␊ |
966 | ␉␉␉goto done;␊ |
967 | ␉␉}␊ |
968 | ␊ |
969 | ␉␉// Associate a menu item for each BVRef.␊ |
970 | ␉␉for (bvr=bvChain, i=gDeviceCount-1, selectIndex=-1; bvr; bvr=bvr->next) {␊ |
971 | ␉␉␉if (bvr->visible) {␊ |
972 | ␉␉␉␉getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true);␊ |
973 | ␉␉␉␉menuItems[i].param = (void *) bvr;␊ |
974 | ␉␉␉␉if (bvr == menuBVR) {␊ |
975 | ␉␉␉␉␉selectIndex = i;␊ |
976 | ␉␉␉␉}␊ |
977 | ␉␉␉␉i--;␊ |
978 | ␉␉␉}␊ |
979 | ␉␉}␊ |
980 | ␉␉// Jief : In case the default partition (returned by selectBootVolume) is not in the menu␊ |
981 | ␉␉if ( selectIndex == -1 )␊ |
982 | ␉␉{␊ |
983 | ␉␉␉selectIndex = 0;␊ |
984 | ␊ |
985 | ␉␉␉// gDeviceCount is actually > 0, so menuItems[selectIndex] exists␊ |
986 | ␉␉␉menuBVR = (BVRef)(menuItems[selectIndex].param);␊ |
987 | ␉␉␉// what happen if bvChain is empty ?␊ |
988 | ␉␉}␊ |
989 | ␉}␊ |
990 | ␊ |
991 | ␉if (bootArgs->Video.v_display != VGA_TEXT_MODE) {␊ |
992 | ␉␉// redraw the background buffer␊ |
993 | ␉␉gui.logo.draw = true;␊ |
994 | ␉␉drawBackground();␊ |
995 | ␉␉gui.devicelist.draw = true;␊ |
996 | ␉␉gui.redraw = true;␊ |
997 | ␉␉if (!(gBootMode & kBootModeQuiet)) {␊ |
998 | ␊ |
999 | ␉␉␉// Check if "Boot Banner"=N switch is present in config file.␊ |
1000 | ␉␉␉getBoolForKey(kBootBannerKey, &showBootBanner, &bootInfo->chameleonConfig); ␊ |
1001 | ␉␉␉if (showBootBanner) {␊ |
1002 | ␉␉␉␉// Display banner and show hardware info.␊ |
1003 | ␉␉␉␉gprintf(&gui.screen, bootBanner + 1, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
1004 | ␉␉␉}␊ |
1005 | ␊ |
1006 | ␉␉␉// redraw background␊ |
1007 | ␉␉␉memcpy(gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4);␊ |
1008 | ␉␉}␊ |
1009 | ␉} else {␊ |
1010 | ␉␉// Clear screen and hide the blinking cursor.␊ |
1011 | ␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
1012 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
1013 | ␉}␊ |
1014 | ␊ |
1015 | ␉nextRow = kMenuTopRow;␊ |
1016 | ␉showPrompt = true;␊ |
1017 | ␊ |
1018 | ␉if (gDeviceCount) {␊ |
1019 | ␉␉if( bootArgs->Video.v_display == VGA_TEXT_MODE ) {␊ |
1020 | ␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
1021 | ␉␉}␊ |
1022 | ␉␉showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );␊ |
1023 | ␉␉nextRow += MIN( gDeviceCount, kMenuMaxItems ) + 3;␊ |
1024 | ␉}␊ |
1025 | ␊ |
1026 | ␉// Show the boot prompt.␊ |
1027 | ␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
1028 | ␉showBootPrompt( nextRow, showPrompt );␊ |
1029 | ␉␊ |
1030 | ␉do {␊ |
1031 | ␉␉if (bootArgs->Video.v_display != VGA_TEXT_MODE) {␊ |
1032 | ␉␉␉// redraw background␊ |
1033 | ␉␉␉memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );␊ |
1034 | ␉␉␉// reset cursor co-ords␊ |
1035 | ␉␉␉gui.debug.cursor = pos( gui.screen.width - 160 , 10 );␊ |
1036 | ␉␉}␊ |
1037 | ␉␉key = getchar();␊ |
1038 | ␉␉updateMenu( key, (void **) &menuBVR );␊ |
1039 | ␉␉newShowPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
1040 | ␊ |
1041 | ␉␉if (newShowPrompt != showPrompt) {␊ |
1042 | ␉␉␉showPrompt = newShowPrompt;␊ |
1043 | ␉␉␉showBootPrompt( nextRow, showPrompt );␊ |
1044 | ␉␉}␊ |
1045 | ␊ |
1046 | ␉␉if (showPrompt) {␊ |
1047 | ␉␉␉updateBootArgs(key);␊ |
1048 | ␉␉}␊ |
1049 | ␊ |
1050 | ␉␉switch (key) {␊ |
1051 | ␉␉case KEY_ENTER:␊ |
1052 | ␉␉␉if (gui.menu.draw) { ␊ |
1053 | ␉␉␉␉key=0;␊ |
1054 | ␉␉␉␉break;␊ |
1055 | ␉␉␉}␊ |
1056 | ␉␉␉if (*gBootArgs == '?') {␊ |
1057 | ␉␉␉␉char * argPtr = gBootArgs;␊ |
1058 | ␊ |
1059 | ␉␉␉␉// Skip the leading "?" character.␊ |
1060 | ␉␉␉␉argPtr++;␊ |
1061 | ␉␉␉␉getNextArg(&argPtr, booterCommand);␊ |
1062 | ␉␉␉␉getNextArg(&argPtr, booterParam);␊ |
1063 | ␊ |
1064 | ␉␉␉␉/*␊ |
1065 | ␉␉␉␉* TODO: this needs to be refactored.␊ |
1066 | ␉␉␉␉*/␊ |
1067 | ␉␉␉␉if (strcmp( booterCommand, "video" ) == 0) {␊ |
1068 | ␉␉␉␉␉if (bootArgs->Video.v_display != VGA_TEXT_MODE) {␊ |
1069 | ␉␉␉␉␉␉showInfoBox(getVBEInfoString(), getVBEModeInfoString());␊ |
1070 | ␉␉␉␉␉} else {␊ |
1071 | ␉␉␉␉␉␉printVBEModeInfo();␊ |
1072 | ␉␉␉␉␉}␊ |
1073 | ␉␉␉␉} else if ( strcmp( booterCommand, "memory" ) == 0) {␊ |
1074 | ␉␉␉␉␉if (bootArgs->Video.v_display != VGA_TEXT_MODE ) {␊ |
1075 | ␉␉␉␉␉␉showInfoBox("Memory Map", getMemoryInfoString());␊ |
1076 | ␉␉␉␉␉} else {␊ |
1077 | ␉␉␉␉␉␉printMemoryInfo();␊ |
1078 | ␉␉␉␉␉}␊ |
1079 | ␉␉␉␉} else if (strcmp(booterCommand, "lspci") == 0) {␊ |
1080 | ␉␉␉␉␉lspci();␊ |
1081 | ␉␉␉␉} else if (strcmp(booterCommand, "log") == 0) {␊ |
1082 | ␉␉␉ showTextBuffer(msgbuf, strlen(msgbuf));␊ |
1083 | ␉␉␉␉} else if (strcmp(booterCommand, "more") == 0) {␊ |
1084 | ␉␉␉␉␉showTextFile(booterParam);␊ |
1085 | ␉␉␉␉} else if (strcmp(booterCommand, "rd") == 0) {␊ |
1086 | ␉␉␉␉␉processRAMDiskCommand(&argPtr, booterParam);␊ |
1087 | ␉␉␉␉} else if (strcmp(booterCommand, "norescan") == 0) {␊ |
1088 | ␉␉␉␉␉if (gEnableCDROMRescan) {␊ |
1089 | ␉␉␉␉␉␉gEnableCDROMRescan = false;␊ |
1090 | ␉␉␉␉␉␉break;␊ |
1091 | ␉␉␉␉␉}␊ |
1092 | ␉␉␉␉} else {␊ |
1093 | ␉␉␉␉␉showHelp();␊ |
1094 | ␉␉␉␉}␊ |
1095 | ␉␉␉␉key = 0;␊ |
1096 | ␉␉␉␉showBootPrompt(nextRow, showPrompt);␊ |
1097 | ␉␉␉␉break;␊ |
1098 | ␉␉␉}␊ |
1099 | ␉␉␉gBootVolume = menuBVR;␊ |
1100 | ␉␉␉setRootVolume(menuBVR);␊ |
1101 | ␉␉␉gBIOSDev = menuBVR->biosdev;␊ |
1102 | ␉␉␉break;␊ |
1103 | ␊ |
1104 | ␉␉case KEY_ESC:␊ |
1105 | ␉␉␉clearBootArgs();␊ |
1106 | ␉␉␉break;␊ |
1107 | ␊ |
1108 | ␉␉case KEY_F5:␊ |
1109 | ␉␉␉// New behavior:␊ |
1110 | ␉␉␉// Clear gBootVolume to restart the loop␊ |
1111 | ␉␉␉// if the user enabled rescanning the optical drive.␊ |
1112 | ␉␉␉// Otherwise boot the default boot volume.␊ |
1113 | ␉␉␉if (gEnableCDROMRescan) {␊ |
1114 | ␉␉␉␉gBootVolume = NULL;␊ |
1115 | ␉␉␉␉clearBootArgs();␊ |
1116 | ␉␉␉}␊ |
1117 | ␉␉␉break;␊ |
1118 | ␊ |
1119 | ␉␉case KEY_F10:␊ |
1120 | ␉␉␉gScanSingleDrive = false;␊ |
1121 | ␉␉␉scanDisks(gBIOSDev, &bvCount);␊ |
1122 | ␉␉␉gBootVolume = NULL;␊ |
1123 | ␉␉␉clearBootArgs();␊ |
1124 | ␉␉␉break;␊ |
1125 | ␊ |
1126 | ␉␉case KEY_TAB:␊ |
1127 | ␉␉␉// New behavior:␊ |
1128 | ␉␉␉// Switch between text & graphic interfaces␊ |
1129 | ␉␉␉// Only Permitted if started in graphics interface␊ |
1130 | ␉␉␉if (useGUI)␊ |
1131 | ␉␉␉{␊ |
1132 | ␉␉␉␉if (bootArgs->Video.v_display != VGA_TEXT_MODE)␊ |
1133 | ␉␉␉␉{␊ |
1134 | ␉␉␉␉␉setVideoMode( VGA_TEXT_MODE );␊ |
1135 | ␊ |
1136 | ␉␉␉␉␉setCursorPosition(0, 0, 0);␊ |
1137 | ␉␉␉␉␉clearScreenRows(0, kScreenLastRow);␊ |
1138 | ␊ |
1139 | ␉␉␉␉␉// Display banner and show hardware info.␊ |
1140 | ␉␉␉␉␉printf(bootBanner, (bootInfo->convmem + bootInfo->extmem) / 1024);␊ |
1141 | ␉␉␉␉␉printf(getVBEInfoString());␊ |
1142 | ␊ |
1143 | ␉␉␉␉␉clearScreenRows(kMenuTopRow, kMenuTopRow + 2);␊ |
1144 | ␉␉␉␉␉changeCursor(0, kMenuTopRow, kCursorTypeHidden, 0);␊ |
1145 | ␊ |
1146 | ␉␉␉␉␉nextRow = kMenuTopRow;␊ |
1147 | ␉␉␉␉␉showPrompt = true;␊ |
1148 | ␊ |
1149 | ␉␉␉␉␉if (gDeviceCount)␊ |
1150 | ␉␉␉␉␉{␊ |
1151 | ␉␉␉␉␉␉printf("Use \30\31 keys to select the startup volume.");␊ |
1152 | ␉␉␉␉␉␉showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);␊ |
1153 | ␉␉␉␉␉␉nextRow += MIN(gDeviceCount, kMenuMaxItems) + 3;␊ |
1154 | ␉␉␉␉␉}␊ |
1155 | ␊ |
1156 | ␉␉␉␉␉showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);␊ |
1157 | ␉␉␉␉␉showBootPrompt(nextRow, showPrompt);␊ |
1158 | ␉␉␉␉␉//changeCursor( 0, kMenuTopRow, kCursorTypeUnderline, 0 );␊ |
1159 | ␉␉␉␉}␊ |
1160 | ␉␉␉␉else␊ |
1161 | ␉␉␉␉{␊ |
1162 | ␉␉␉␉␉gui.redraw = true;␊ |
1163 | ␉␉␉␉␉setVideoMode( GRAPHICS_MODE );␊ |
1164 | ␉␉␉␉␉updateVRAM();␊ |
1165 | ␉␉␉updateGraphicBootPrompt();␊ |
1166 | ␉␉␉␉}␊ |
1167 | ␉␉␉}␊ |
1168 | ␉␉␉key = 0;␊ |
1169 | ␉␉␉break;␊ |
1170 | ␊ |
1171 | ␉␉default:␊ |
1172 | ␉␉␉key = 0;␊ |
1173 | ␉␉␉break;␊ |
1174 | ␉␉}␊ |
1175 | ␉} while (0 == key);␊ |
1176 | ␊ |
1177 | done:␊ |
1178 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
1179 | ␉{␊ |
1180 | ␉␉clearScreenRows(kMenuTopRow, kScreenLastRow);␊ |
1181 | ␉␉changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0);␊ |
1182 | ␉}␊ |
1183 | ␊ |
1184 | ␉shouldboot = false;␊ |
1185 | ␉gui.menu.draw = false;␊ |
1186 | ␉if (menuItems)␊ |
1187 | ␉{␊ |
1188 | ␉␉free(menuItems);␊ |
1189 | ␉␉menuItems = NULL;␊ |
1190 | ␉}␊ |
1191 | ␉execute_hook("BootOptions", gBootArgs, gBootArgsPtr, NULL, NULL);␊ |
1192 | ␉return 0;␊ |
1193 | }␊ |
1194 | ␊ |
1195 | //==========================================================================␊ |
1196 | ␊ |
1197 | char gBootUUIDString[32+4+1] = ""; // UUID of the boot volume e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292␊ |
1198 | extern unsigned char chainbootdev;␊ |
1199 | extern unsigned char chainbootflag;␊ |
1200 | ␊ |
1201 | bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP)␊ |
1202 | {␊ |
1203 | ␉int argLen = argName ? strlen(argName) : 0;␊ |
1204 | ␉int len = argLen + cnt + 1; // +1 to account for space␊ |
1205 | ␊ |
1206 | ␉if (len > *cntRemainingP)␊ |
1207 | ␉{␊ |
1208 | ␉␉error("Warning: boot arguments too long, truncating\n");␊ |
1209 | ␉␉return false;␊ |
1210 | ␉}␊ |
1211 | ␊ |
1212 | ␉if (argName)␊ |
1213 | ␉{␊ |
1214 | ␉␉strncpy(*argP, argName, argLen);␊ |
1215 | ␉␉*argP += argLen;␊ |
1216 | ␉␉*argP[0] = '=';␊ |
1217 | ␉␉(*argP)++;␊ |
1218 | ␉␉len++; // +1 to account for '='␊ |
1219 | ␉}␊ |
1220 | ␊ |
1221 | ␉strncpy(*argP, val, cnt);␊ |
1222 | ␉*argP += cnt;␊ |
1223 | ␉*argP[0] = ' ';␊ |
1224 | ␉(*argP)++;␊ |
1225 | ␊ |
1226 | ␉*cntRemainingP -= len;␊ |
1227 | ␊ |
1228 | ␉return true;␊ |
1229 | }␊ |
1230 | ␊ |
1231 | // ␊ |
1232 | // Returns TRUE if an argument was copied, FALSE otherwise␊ |
1233 | bool processBootArgument(␊ |
1234 | const char *argName, // The argument to search for␊ |
1235 | const char *userString, // Typed-in boot arguments␊ |
1236 | const char *kernelFlags, // Kernel flags from config table␊ |
1237 | const char *configTable,␊ |
1238 | char **argP, // Output value␊ |
1239 | int *cntRemainingP, // Output count␊ |
1240 | char *foundVal, // found value␊ |
1241 | int foundValSize // max found value size␊ |
1242 | )␊ |
1243 | {␊ |
1244 | ␉const char *val;␊ |
1245 | ␉int cnt;␊ |
1246 | ␉bool found = false;␊ |
1247 | ␊ |
1248 | ␉if (getValueForBootKey(userString, argName, &val, &cnt))␊ |
1249 | ␉{␊ |
1250 | ␉␉// Don't copy; these values will be copied at the end of argument processing.␊ |
1251 | ␉␉found = true;␊ |
1252 | ␉}␊ |
1253 | ␉else if (getValueForBootKey(kernelFlags, argName, &val, &cnt))␊ |
1254 | ␉{␊ |
1255 | ␉␉// Don't copy; these values will be copied at the end of argument processing.␊ |
1256 | ␉␉found = true;␊ |
1257 | ␉}␊ |
1258 | ␉else if (getValueForKey(argName, &val, &cnt, &bootInfo->chameleonConfig))␊ |
1259 | ␉{␊ |
1260 | ␉␉copyArgument(argName, val, cnt, argP, cntRemainingP);␊ |
1261 | ␉␉found = true;␊ |
1262 | ␉}␊ |
1263 | ␉if (found && foundVal)␊ |
1264 | ␉{␊ |
1265 | ␉␉strlcpy(foundVal, val, foundValSize);␊ |
1266 | ␉}␊ |
1267 | ␉return found;␊ |
1268 | }␊ |
1269 | ␊ |
1270 | // Maximum config table value size␊ |
1271 | #define VALUE_SIZE 2048␊ |
1272 | ␊ |
1273 | int processBootOptions()␊ |
1274 | {␊ |
1275 | ␉const char␉*cp = gBootArgs;␊ |
1276 | ␉const char␉*val = 0;␊ |
1277 | ␉const char␉*kernel;␊ |
1278 | ␉int␉␉cnt;␊ |
1279 | ␉int␉␉userCnt;␊ |
1280 | ␉int␉␉cntRemaining;␊ |
1281 | ␉char␉␉*argP;␊ |
1282 | ␉char␉␉*configKernelFlags;␊ |
1283 | ␉char␉␉*valueBuffer;␊ |
1284 | ␊ |
1285 | ␉valueBuffer = malloc(VALUE_SIZE);␊ |
1286 | ␊ |
1287 | ␉skipblanks( &cp );␊ |
1288 | ␊ |
1289 | ␉// Update the unit and partition number.␊ |
1290 | ␉if (gBootVolume)␊ |
1291 | ␉{␊ |
1292 | ␉␉if (!(gBootVolume->flags & kBVFlagNativeBoot))␊ |
1293 | ␉␉{␊ |
1294 | ␉␉␉readBootSector(gBootVolume->biosdev, gBootVolume->part_boff, (void *)0x7c00);␊ |
1295 | ␉␉␉//␊ |
1296 | ␉␉␉// Setup edx, and signal intention to chain load the␊ |
1297 | ␉␉␉// foreign booter.␊ |
1298 | ␉␉␉//␊ |
1299 | ␊ |
1300 | ␉␉␉chainbootdev = gBootVolume->biosdev;␊ |
1301 | ␉␉␉chainbootflag = 1;␊ |
1302 | ␊ |
1303 | ␉␉␉return 1;␊ |
1304 | ␉␉}␊ |
1305 | ␊ |
1306 | ␉␉setRootVolume(gBootVolume);␊ |
1307 | ␊ |
1308 | ␉}␊ |
1309 | ␉// If no boot volume fail immediately because we're just going to fail␊ |
1310 | ␉// trying to load the config file anyway.␊ |
1311 | ␉else␊ |
1312 | ␉{␊ |
1313 | ␉␉return -1;␊ |
1314 | ␉}␊ |
1315 | ␊ |
1316 | ␉// Save a version of mac os we're booting.␊ |
1317 | ␉MacOSVerCurrent = MacOSVer2Int(gBootVolume->OSFullVer);␊ |
1318 | ␉// so copy it and trim␊ |
1319 | ␉gMacOSVersion[0] = 0;␊ |
1320 | ␉if ( MacOSVerCurrent >= MacOSVer2Int("10.10") )␊ |
1321 | ␉{␊ |
1322 | ␉␉strncat(gMacOSVersion, gBootVolume->OSVersion, 5);␊ |
1323 | ␉}␊ |
1324 | ␉else␊ |
1325 | ␉{␊ |
1326 | ␉␉strncat(gMacOSVersion, gBootVolume->OSVersion, 4);␊ |
1327 | ␉}␊ |
1328 | ␊ |
1329 | ␉// Load config table specified by the user, or use the default.␊ |
1330 | ␊ |
1331 | ␉if (getValueForBootKey(cp, "config", &val, &cnt))␊ |
1332 | ␉{␊ |
1333 | ␉␉printf("Load config table specified by the user.\n");␊ |
1334 | ␉␉printf(val);␊ |
1335 | ␉␉printf("\n");␊ |
1336 | ␉␉pause();␊ |
1337 | ␉␉loadConfigFile(val,&bootInfo->chameleonConfig);␊ |
1338 | ␊ |
1339 | ␉␉loadSystemConfig(&bootInfo->bootConfig);␊ |
1340 | ␉}␊ |
1341 | ␉else␊ |
1342 | ␉{␊ |
1343 | ␉␉// Load org.chameleon.Boot.plist from the selected volume␊ |
1344 | ␉␉// and use its contents to override default bootConfig.␊ |
1345 | ␊ |
1346 | ␉␉loadSystemConfig(&bootInfo->bootConfig);␊ |
1347 | ␉␉loadChameleonConfig(&bootInfo->chameleonConfig, NULL);␊ |
1348 | ␉}␊ |
1349 | ␊ |
1350 | ␉// Use the kernel name specified by the user, or fetch the name␊ |
1351 | ␉// in the config table, or use the default if not specified.␊ |
1352 | ␉// Specifying a kernel name on the command line, or specifying␊ |
1353 | ␉// a non-default kernel name in the config file counts as␊ |
1354 | ␉// overriding the kernel, which causes the kernelcache not␊ |
1355 | ␉// to be used.␊ |
1356 | ␊ |
1357 | ␉gOverrideKernel = false;␊ |
1358 | ␉if (( kernel = extractKernelName((char **)&cp) ))␊ |
1359 | ␉{␊ |
1360 | ␉␉strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile) );␊ |
1361 | ␉}␊ |
1362 | ␉else␊ |
1363 | ␉{␊ |
1364 | ␉␉if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) )␊ |
1365 | ␉␉{␊ |
1366 | ␉␉␉strlcpy( bootInfo->bootFile, val, cnt+1 );␊ |
1367 | ␉␉}␊ |
1368 | ␉␉else␊ |
1369 | ␉␉{␊ |
1370 | ␉␉␉if ( MacOSVerCurrent >= MacOSVer2Int("10.10") ) // OS X is 10.10 or newer␊ |
1371 | ␉␉␉{␊ |
1372 | ␉␉␉␉strlcpy( bootInfo->bootFile, kOSXKernel, sizeof(bootInfo->bootFile) );␊ |
1373 | ␉␉␉}␊ |
1374 | ␉␉␉else␊ |
1375 | ␉␉␉{␊ |
1376 | ␉␉␉␉// or 10.9 and previous␊ |
1377 | ␉␉␉␉strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) );␊ |
1378 | ␉␉␉}␊ |
1379 | ␉␉}␊ |
1380 | ␉}␊ |
1381 | ␊ |
1382 | ␉if ((strcmp( bootInfo->bootFile, kDefaultKernel ) != 0) && (strcmp( bootInfo->bootFile, kOSXKernel ) != 0))␊ |
1383 | ␉{␊ |
1384 | ␉␉gOverrideKernel = true;␊ |
1385 | ␉}␊ |
1386 | ␊ |
1387 | ␉// ErmaC: Inject "kext-dev-mode=1" if OS X 10.10 is detected␊ |
1388 | ␉if ( (gMacOSVersion[3] == '1') && (gMacOSVersion[4] == '0') ) // OS X is 10.10␊ |
1389 | ␉{␊ |
1390 | ␉␉verbose("Added: kext-dev-mode=1\n");␊ |
1391 | ␉␉addBootArg("kext-dev-mode=1");␊ |
1392 | ␉}␊ |
1393 | ␊ |
1394 | ␉// Micky1979 (Recovery HD)␊ |
1395 | ␉if (gBootVolume->OSisRecovery)␊ |
1396 | ␉{␊ |
1397 | ␉␉const char␉*rval = 0;␊ |
1398 | ␉␉config_file_t ocBplist;␊ |
1399 | ␉␉char caBp[1024]; //too large ?. On El capitan is 365 bytes.. but we are testing␊ |
1400 | ␉␉snprintf(caBp, sizeof(caBp), "/com.apple.recovery.boot/com.apple.Boot.plist");␊ |
1401 | ␊ |
1402 | ␉␉loadConfigFile(caBp, &ocBplist);␊ |
1403 | ␉␉rval = getStringForKey(kKernelFlagsKey, &ocBplist);␊ |
1404 | ␊ |
1405 | ␉␉if (rval) {␊ |
1406 | ␉␉␉addBootArg(rval);␊ |
1407 | ␉␉}␊ |
1408 | ␉}␊ |
1409 | ␊ |
1410 | ␉// Micky1979 (Vanilla Installer)␊ |
1411 | ␉if (gBootVolume->OSisInstaller)␊ |
1412 | ␉{␊ |
1413 | ␉␉const char␉*rval = 0;␊ |
1414 | ␉␉config_file_t ocBplist;␊ |
1415 | ␊ |
1416 | ␉␉char caBp[2048];␊ |
1417 | ␊ |
1418 | ␉␉snprintf(caBp, sizeof(caBp), "/.IABootFiles/com.apple.Boot.plist");␊ |
1419 | ␊ |
1420 | ␉␉loadConfigFile(caBp, &ocBplist);␊ |
1421 | ␉␉rval = getStringForKey(kKernelFlagsKey, &ocBplist);␊ |
1422 | ␊ |
1423 | ␉␉if (rval) {␊ |
1424 | ␉␉␉addBootArg(rval);␊ |
1425 | ␉␉}␊ |
1426 | ␉}␊ |
1427 | ␊ |
1428 | ␉// Micky1979 (old Vanilla upgrade)␊ |
1429 | ␉if (gBootVolume->OSisMacOSXUpgrade)␊ |
1430 | ␉{␊ |
1431 | ␉␉const char␉*rval = 0;␊ |
1432 | ␉␉config_file_t ocBplist;␊ |
1433 | ␉␉char caBp[2048];␊ |
1434 | ␊ |
1435 | ␉␉snprintf(caBp, sizeof(caBp), "/Mac OS X Install Data/com.apple.Boot.plist");␊ |
1436 | ␊ |
1437 | ␉␉loadConfigFile(caBp, &ocBplist);␊ |
1438 | ␉␉rval = getStringForKey(kKernelFlagsKey, &ocBplist);␊ |
1439 | ␊ |
1440 | ␉␉if (rval) {␊ |
1441 | ␉␉␉addBootArg(rval);␊ |
1442 | ␉␉}␊ |
1443 | ␉}␊ |
1444 | ␊ |
1445 | ␉// Micky1979 (new Vanilla upgrade)␊ |
1446 | ␉if (gBootVolume->OSisOSXUpgrade)␊ |
1447 | ␉{␊ |
1448 | ␉␉const char␉*rval = 0;␊ |
1449 | ␉␉config_file_t ocBplist;␊ |
1450 | ␉␉char caBp[2048];␊ |
1451 | ␉␉bool found = false;␊ |
1452 | ␉␉snprintf(caBp, sizeof(caBp), "/macOS Install Data/Locked Files/Boot Files/com.apple.Boot.plist");␊ |
1453 | ␊ |
1454 | ␉␉if (!loadConfigFile(caBp, &ocBplist))␊ |
1455 | ␉␉{␊ |
1456 | ␉␉␉found = true;␊ |
1457 | ␉␉}␊ |
1458 | ␊ |
1459 | ␉␉if (!found) {␊ |
1460 | ␉␉␉snprintf(caBp, sizeof(caBp), "/OS X Install Data/com.apple.Boot.plist");␊ |
1461 | ␊ |
1462 | ␉␉␉if (!loadConfigFile(caBp, &ocBplist))␊ |
1463 | ␉␉␉{␊ |
1464 | ␉␉␉␉found = true;␊ |
1465 | ␉␉␉}␊ |
1466 | ␉␉}␊ |
1467 | ␊ |
1468 | ␉␉if (found) {␊ |
1469 | ␉␉␉rval = getStringForKey(kKernelFlagsKey, &ocBplist);␊ |
1470 | ␉␉␉if (rval) {␊ |
1471 | ␉␉␉␉addBootArg(rval);␊ |
1472 | ␉␉␉}␊ |
1473 | ␉␉}␊ |
1474 | ␉}␊ |
1475 | ␊ |
1476 | ␉cntRemaining = BOOT_STRING_LEN - 2; // save 1 for NULL, 1 for space␊ |
1477 | ␉argP = bootArgs->CommandLine;␊ |
1478 | ␊ |
1479 | ␉// Get config kernel flags, if not ignored.␊ |
1480 | ␉if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || !getValueForKey(kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig))␊ |
1481 | ␉{␊ |
1482 | ␉␉val = "";␊ |
1483 | ␉␉cnt = 0;␊ |
1484 | ␉}␊ |
1485 | ␉configKernelFlags = malloc(cnt + 1);␊ |
1486 | ␉strlcpy(configKernelFlags, val, cnt + 1);␊ |
1487 | ␊ |
1488 | ␉// boot-uuid can be set either on the command-line or in the config file␊ |
1489 | ␉if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config,␊ |
1490 | &argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString)))␊ |
1491 | ␉{␊ |
1492 | ␉␉//␊ |
1493 | ␉␉// Try an alternate method for getting the root UUID on boot helper partitions.␊ |
1494 | ␉␉//␊ |
1495 | ␉␉if (gBootVolume->flags & kBVFlagBooter)␊ |
1496 | ␉␉{␊ |
1497 | ␉␉␉// Load the configuration store in the boot helper partition␊ |
1498 | ␉␉␉if (loadHelperConfig(&bootInfo->helperConfig) == 0)␊ |
1499 | ␉␉␉{␊ |
1500 | ␉␉␉␉val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig);␊ |
1501 | ␉␉␉␉if (val != NULL)␊ |
1502 | ␉␉␉␉{␊ |
1503 | ␉␉␉␉␉strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString));␊ |
1504 | ␉␉␉␉}␊ |
1505 | ␉␉␉}␊ |
1506 | ␉␉}␊ |
1507 | /*␊ |
1508 | ␉␉// Try to get the volume uuid string␊ |
1509 | ␉␉if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)␊ |
1510 | ␉␉{␊ |
1511 | ␉␉␉gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);␊ |
1512 | ␉␉}␊ |
1513 | */␊ |
1514 | ␉␉// If we have the volume uuid add it to the commandline arguments␊ |
1515 | ␉␉if (strlen(gBootUUIDString))␊ |
1516 | ␉␉{␊ |
1517 | ␉␉␉copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);␊ |
1518 | ␉␉}␊ |
1519 | ␉␉// Try to get the volume uuid string␊ |
1520 | ␉␉if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)␊ |
1521 | ␉␉{␊ |
1522 | ␉␉␉gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);␊ |
1523 | ␉␉}␊ |
1524 | ␉}␊ |
1525 | ␉DBG("Boot UUID of '%s' %s (%s): %s\n", gBootVolume->label, gBootVolume->altlabel, gBootVolume->type_name, gBootUUIDString);␊ |
1526 | ␊ |
1527 | ␉if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,␊ |
1528 | &argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE))␊ |
1529 | ␉{␊ |
1530 | ␉␉cnt = 0;␊ |
1531 | ␉␉if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig))␊ |
1532 | ␉␉{␊ |
1533 | ␉␉␉valueBuffer[0] = '*';␊ |
1534 | ␉␉␉cnt++;␊ |
1535 | ␉␉␉strlcpy(valueBuffer + 1, val, cnt);␊ |
1536 | ␉␉␉val = valueBuffer;␊ |
1537 | ␉␉␉if (cnt > 0)␊ |
1538 | ␉␉␉{␊ |
1539 | ␉␉␉␉copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);␊ |
1540 | ␉␉␉}␊ |
1541 | ␉␉}␊ |
1542 | ␉␉else␊ |
1543 | ␉␉{␊ |
1544 | ␉␉␉if (strlen(gBootUUIDString))␊ |
1545 | ␉␉␉{␊ |
1546 | ␉␉␉␉val = "*uuid";␊ |
1547 | ␉␉␉␉cnt = 5;␊ |
1548 | ␉␉␉}␊ |
1549 | ␉␉␉else␊ |
1550 | ␉␉␉{␊ |
1551 | ␉␉␉␉// Don't set "rd=.." if there is no boot device key␊ |
1552 | ␉␉␉␉// and no UUID.␊ |
1553 | ␉␉␉␉val = "";␊ |
1554 | ␉␉␉␉cnt = 0;␊ |
1555 | ␉␉␉}␊ |
1556 | ␉␉}␊ |
1557 | /* Bungo␊ |
1558 | ␉␉if (cnt > 0)␊ |
1559 | ␉␉{␊ |
1560 | ␉␉␉copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining);␊ |
1561 | ␉␉}␊ |
1562 | */␊ |
1563 | ␉␉strlcpy(gRootDevice, val, (cnt + 1));␊ |
1564 | ␉}␊ |
1565 | ␊ |
1566 | ␉/*␊ |
1567 | ␉ * Removed. We don't need this anymore.␊ |
1568 | ␉ *␊ |
1569 | ␉if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config,␊ |
1570 | ␉␉␉␉␉␉␉ &argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler)))␊ |
1571 | ␉{␊ |
1572 | ␉␉getPlatformName(gPlatformName);␊ |
1573 | ␉␉copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);␊ |
1574 | ␉}␊ |
1575 | ␉*/␊ |
1576 | ␊ |
1577 | ␉if (!getValueForBootKey(cp, kSafeModeFlag, &val, &cnt) &&␊ |
1578 | !getValueForBootKey(configKernelFlags, kSafeModeFlag, &val, &cnt))␊ |
1579 | ␉{␊ |
1580 | ␉␉if (gBootMode & kBootModeSafe)␊ |
1581 | ␉␉{␊ |
1582 | ␉␉␉copyArgument(0, kSafeModeFlag, strlen(kSafeModeFlag), &argP, &cntRemaining);␊ |
1583 | ␉␉}␊ |
1584 | ␉}␊ |
1585 | ␊ |
1586 | ␉// Store the merged kernel flags and boot args.␊ |
1587 | ␊ |
1588 | ␉cnt = strlen(configKernelFlags);␊ |
1589 | ␉if (cnt)␊ |
1590 | ␉{␊ |
1591 | ␉␉if (cnt > cntRemaining)␊ |
1592 | ␉␉{␊ |
1593 | ␉␉␉error("Warning: boot arguments too long, truncating\n");␊ |
1594 | ␉␉␉cnt = cntRemaining;␊ |
1595 | ␉␉}␊ |
1596 | ␉␉strncpy(argP, configKernelFlags, cnt);␊ |
1597 | ␉␉argP[cnt++] = ' ';␊ |
1598 | ␉␉cntRemaining -= cnt;␊ |
1599 | ␉}␊ |
1600 | ␉userCnt = strlen(cp);␊ |
1601 | ␉if (userCnt > cntRemaining)␊ |
1602 | ␉{␊ |
1603 | ␉␉error("Warning: boot arguments too long, truncating\n");␊ |
1604 | ␉␉userCnt = cntRemaining;␊ |
1605 | ␉}␊ |
1606 | ␉strncpy(&argP[cnt], cp, userCnt);␊ |
1607 | ␉argP[cnt+userCnt] = '\0';␊ |
1608 | ␊ |
1609 | ␉if(!shouldboot)␊ |
1610 | ␉{␊ |
1611 | ␉␉gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, &bootInfo->chameleonConfig ) ||␊ |
1612 | ␉␉␉getValueForKey( kSingleUserModeFlag, &val, &cnt, &bootInfo->chameleonConfig );␊ |
1613 | ␉␉␊ |
1614 | ␉␉gBootMode = ( getValueForKey( kSafeModeFlag, &val, &cnt, &bootInfo->chameleonConfig ) ) ?␊ |
1615 | ␉␉␉kBootModeSafe : kBootModeNormal;␊ |
1616 | ␊ |
1617 | ␉␉if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->chameleonConfig ) )␊ |
1618 | ␉␉{␊ |
1619 | ␉␉␉gBootMode = kBootModeSafe;␊ |
1620 | ␉␉}␊ |
1621 | ␉}␊ |
1622 | ␊ |
1623 | ␉if ( getValueForKey( kMKextCacheKey, &val, &cnt, &bootInfo->bootConfig ) )␊ |
1624 | ␉{␊ |
1625 | ␉␉strlcpy(gMKextName, val, cnt + 1);␊ |
1626 | ␉}␊ |
1627 | ␉else␊ |
1628 | ␉{␊ |
1629 | ␉␉gMKextName[0]=0;␊ |
1630 | ␉}␊ |
1631 | ␊ |
1632 | ␉free(configKernelFlags);␊ |
1633 | ␉free(valueBuffer);␊ |
1634 | ␊ |
1635 | ␉return 0;␊ |
1636 | }␊ |
1637 | ␊ |
1638 | ␊ |
1639 | //==========================================================================␊ |
1640 | // Load the help file and display the file contents on the screen.␊ |
1641 | ␊ |
1642 | void showTextBuffer(char *buf_orig, int size)␊ |
1643 | {␊ |
1644 | ␉char␉*bp;␊ |
1645 | ␉char␉*buf;␊ |
1646 | ␉int␉line;␊ |
1647 | ␉int␉line_offset;␊ |
1648 | ␉int␉c;␊ |
1649 | ␊ |
1650 | ␉if (bootArgs->Video.v_display != VGA_TEXT_MODE) {␊ |
1651 | ␉␉showInfoBox( "Press q to continue, space for next page.\n",buf_orig );␊ |
1652 | ␉␉return;␊ |
1653 | ␉}␊ |
1654 | ␊ |
1655 | ␉// Create a copy so that we don't mangle the original␊ |
1656 | ␉buf = malloc(size + 1);␊ |
1657 | ␉memcpy(buf, buf_orig, size);␊ |
1658 | ␉␊ |
1659 | ␊ |
1660 | bp = buf;␊ |
1661 | while (size-- > 0) {␊ |
1662 | ␉␉if (*bp == '\n') {␊ |
1663 | ␉␉␉*bp = '\0';␊ |
1664 | ␉␉}␊ |
1665 | ␉␉bp++;␊ |
1666 | }␊ |
1667 | *bp = '\1';␊ |
1668 | line_offset = 0;␊ |
1669 | ␊ |
1670 | setActiveDisplayPage(1);␊ |
1671 | ␊ |
1672 | while (1) {␊ |
1673 | ␉␉clearScreenRows(0, 24);␊ |
1674 | ␉␉setCursorPosition(0, 0, 1);␊ |
1675 | ␉␉bp = buf;␊ |
1676 | ␉␉for (line = 0; *bp != '\1' && line < line_offset; line++) {␊ |
1677 | ␉␉␉while (*bp != '\0') {␊ |
1678 | ␉␉␉␉bp++;␊ |
1679 | ␉␉␉}␊ |
1680 | ␉␉␉bp++;␊ |
1681 | ␉␉}␊ |
1682 | ␉␉for (line = 0; *bp != '\1' && line < 23; line++) {␊ |
1683 | ␉␉␉setCursorPosition(0, line, 1);␊ |
1684 | ␉␉␉printf("%s\n", bp);␊ |
1685 | ␉␉␉while (*bp != '\0') {␊ |
1686 | ␉␉␉␉bp++;␊ |
1687 | ␉␉␉}␊ |
1688 | ␉␉␉bp++;␊ |
1689 | ␉␉}␊ |
1690 | ␊ |
1691 | ␉␉setCursorPosition(0, 23, 1);␊ |
1692 | ␉␉if (*bp == '\1') {␊ |
1693 | ␉␉␉printf("[Type %sq or space to quit viewer]", (line_offset > 0) ? "p for previous page, " : "");␊ |
1694 | ␉␉} else {␊ |
1695 | ␉␉␉printf("[Type %s%sq to quit viewer]", (line_offset > 0) ? "p for previous page, " : "", (*bp != '\1') ? "space for next page, " : "");␊ |
1696 | ␉␉}␊ |
1697 | ␊ |
1698 | ␉␉c = getchar();␊ |
1699 | ␉␉if (c == 'q' || c == 'Q') {␊ |
1700 | ␉␉␉break;␊ |
1701 | ␉␉}␊ |
1702 | ␉␉if ((c == 'p' || c == 'P') && line_offset > 0) {␊ |
1703 | ␉␉␉line_offset -= 23;␊ |
1704 | ␉␉}␊ |
1705 | ␉␉if (c == ' ') {␊ |
1706 | ␉␉␉if (*bp == '\1') {␊ |
1707 | ␉␉␉␉break;␊ |
1708 | ␉␉␉} else {␊ |
1709 | ␉␉␉␉line_offset += 23;␊ |
1710 | ␉␉␉}␊ |
1711 | ␉␉}␊ |
1712 | }␊ |
1713 | setActiveDisplayPage(0);␊ |
1714 | }␊ |
1715 | ␊ |
1716 | void showHelp(void)␊ |
1717 | {␊ |
1718 | ␉if (bootArgs->Video.v_display != VGA_TEXT_MODE)␊ |
1719 | ␉{␊ |
1720 | ␉␉showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt);␊ |
1721 | ␉}␊ |
1722 | ␉else␊ |
1723 | ␉{␊ |
1724 | ␉␉showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len);␊ |
1725 | ␉}␊ |
1726 | }␊ |
1727 | ␊ |
1728 | void showTextFile(const char * filename)␊ |
1729 | {␊ |
1730 | #define MAX_TEXT_FILE_SIZE 65536␊ |
1731 | ␉char␉*buf;␊ |
1732 | ␉int␉fd;␊ |
1733 | ␉int␉size;␊ |
1734 | ␊ |
1735 | ␉if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0)␊ |
1736 | ␉{␊ |
1737 | ␉␉printf("\nFile not found: %s\n", filename);␊ |
1738 | ␉␉sleep(2);␊ |
1739 | ␉␉return;␊ |
1740 | ␉}␊ |
1741 | ␊ |
1742 | size = file_size(fd);␊ |
1743 | if (size > MAX_TEXT_FILE_SIZE)␊ |
1744 | ␉{␊ |
1745 | ␉␉size = MAX_TEXT_FILE_SIZE;␊ |
1746 | ␉}␊ |
1747 | buf = malloc(size);␊ |
1748 | ␊ |
1749 | ␉if (!buf)␊ |
1750 | ␉{␊ |
1751 | ␉␉printf("Couldn't allocate memory for the buf in showTextFile\n");␊ |
1752 | ␉␉return;␊ |
1753 | ␉}␊ |
1754 | ␊ |
1755 | read(fd, buf, size);␊ |
1756 | close(fd);␊ |
1757 | ␉showTextBuffer(buf, size);␊ |
1758 | ␉free(buf);␊ |
1759 | }␊ |
1760 | ␊ |
1761 | // This is a very simplistic prompting scheme that just grabs two hex characters␊ |
1762 | // Eventually we need to do something more user-friendly like display a menu␊ |
1763 | // based off of the Multiboot device list␊ |
1764 | ␊ |
1765 | int selectAlternateBootDevice(int bootdevice)␊ |
1766 | {␊ |
1767 | ␉int key;␊ |
1768 | ␉int newbootdevice;␊ |
1769 | ␉int digitsI = 0;␊ |
1770 | ␉char *end;␊ |
1771 | ␉char digits[3] = {0,0,0};␊ |
1772 | ␊ |
1773 | ␉// We've already printed the current boot device so user knows what it is␊ |
1774 | ␉printf("Typical boot devices are 80 (First HD), 81 (Second HD)\n");␊ |
1775 | ␉printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice);␊ |
1776 | ␉do {␊ |
1777 | ␉␉key = getchar();␊ |
1778 | ␉␉switch (ASCII_KEY(key))␊ |
1779 | ␉␉{␊ |
1780 | ␉␉case KEY_BKSP:␊ |
1781 | ␉␉␉if (digitsI > 0)␊ |
1782 | ␉␉␉{␊ |
1783 | ␉␉␉␉int x, y, t;␊ |
1784 | ␉␉␉␉getCursorPositionAndType(&x, &y, &t);␊ |
1785 | ␉␉␉␉// Assume x is not 0;␊ |
1786 | ␉␉␉␉x--;␊ |
1787 | ␉␉␉␉setCursorPosition(x,y,0); // back up one char␊ |
1788 | ␉␉␉␉// Overwrite with space without moving cursor position␊ |
1789 | ␉␉␉␉putca(' ', 0x07, 1);␊ |
1790 | ␉␉␉␉digitsI--;␊ |
1791 | ␉␉␉}␊ |
1792 | ␉␉␉else␊ |
1793 | ␉␉␉{␊ |
1794 | ␉␉␉␉// TODO: Beep or something␊ |
1795 | ␉␉␉}␊ |
1796 | ␉␉␉break;␊ |
1797 | ␊ |
1798 | ␉␉case KEY_ENTER:␊ |
1799 | ␉␉␉digits[digitsI] = '\0';␊ |
1800 | ␉␉␉newbootdevice = strtol(digits, &end, 16);␊ |
1801 | ␉␉␉if (end == digits && *end == '\0')␊ |
1802 | ␉␉␉{␊ |
1803 | ␉␉␉␉// User entered empty string␊ |
1804 | ␉␉␉␉printf("\nUsing default boot device %x\n", bootdevice);␊ |
1805 | ␉␉␉␉key = 0;␊ |
1806 | ␉␉␉} else if(end != digits && *end == '\0') {␊ |
1807 | ␉␉␉␉bootdevice = newbootdevice;␊ |
1808 | ␉␉␉␉printf("\n");␊ |
1809 | ␉␉␉␉key = 0; // We gots da boot device␊ |
1810 | ␉␉␉} else {␊ |
1811 | ␉␉␉␉printf("\nCouldn't parse. try again: ");␊ |
1812 | ␉␉␉␉digitsI = 0;␊ |
1813 | ␉␉␉}␊ |
1814 | ␉␉␉break;␊ |
1815 | ␊ |
1816 | ␉␉default:␊ |
1817 | ␉␉␉if (isxdigit(ASCII_KEY(key)) && digitsI < 2)␊ |
1818 | ␉␉␉{␊ |
1819 | ␉␉␉␉putchar(ASCII_KEY(key));␊ |
1820 | ␉␉␉␉digits[digitsI++] = ASCII_KEY(key);␊ |
1821 | ␉␉␉}␊ |
1822 | ␉␉␉else␊ |
1823 | ␉␉␉{␊ |
1824 | ␉␉␉␉// TODO: Beep or something␊ |
1825 | ␉␉␉}␊ |
1826 | ␉␉␉break;␊ |
1827 | ␉␉};␊ |
1828 | ␉} while (key != 0);␊ |
1829 | ␊ |
1830 | ␉return bootdevice;␊ |
1831 | }␊ |
1832 | ␊ |
1833 | bool promptForRescanOption(void)␊ |
1834 | {␊ |
1835 | ␉printf("\nWould you like to enable media rescan option?\nPress ENTER to enable or any key to skip.\n");␊ |
1836 | ␉if (getchar() == KEY_ENTER)␊ |
1837 | ␉{␊ |
1838 | ␉␉return true;␊ |
1839 | ␉}␊ |
1840 | ␉else␊ |
1841 | ␉{␊ |
1842 | ␉␉return false;␊ |
1843 | ␉}␊ |
1844 | }␊ |
1845 | |