Contents of /trunk/grub/patches/grub-0.97-splash.patch
Parent Directory | Revision Log
Revision 144 -
(show annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 63567 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 63567 byte(s)
-import
1 | diff -Naur grub-0.95-orig/configure.ac grub-0.95/configure.ac |
2 | --- grub-0.95-orig/configure.ac 2003-10-19 19:25:30.000000000 +0200 |
3 | +++ grub-0.95/configure.ac 2004-02-15 11:20:57.681027504 +0100 |
4 | @@ -595,6 +595,11 @@ |
5 | [ --enable-diskless enable diskless support]) |
6 | AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes) |
7 | |
8 | +dnl Graphical splashscreen support |
9 | +AC_ARG_ENABLE(graphics, |
10 | + [ --disable-graphics disable graphics terminal support]) |
11 | +AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno) |
12 | + |
13 | dnl Hercules terminal |
14 | AC_ARG_ENABLE(hercules, |
15 | [ --disable-hercules disable hercules terminal support]) |
16 | diff -Naur grub-0.95-orig/stage2/asm.S grub-0.95/stage2/asm.S |
17 | --- grub-0.95-orig/stage2/asm.S 2004-01-11 10:39:22.000000000 +0100 |
18 | +++ grub-0.95/stage2/asm.S 2004-02-15 11:20:57.706023704 +0100 |
19 | @@ -2216,6 +2216,156 @@ |
20 | pop %ebx |
21 | pop %ebp |
22 | ret |
23 | + |
24 | +/* graphics mode functions */ |
25 | +#ifdef SUPPORT_GRAPHICS |
26 | +VARIABLE(cursorX) |
27 | +.word 0 |
28 | +VARIABLE(cursorY) |
29 | +.word 0 |
30 | +VARIABLE(cursorCount) |
31 | +.word 0 |
32 | +VARIABLE(cursorBuf) |
33 | +.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
34 | + |
35 | + |
36 | +/* |
37 | + * int set_videomode(mode) |
38 | + * BIOS call "INT 10H Function 0h" to set video mode |
39 | + * Call with %ah = 0x0 |
40 | + * %al = video mode |
41 | + * Returns old videomode. |
42 | + */ |
43 | +ENTRY(set_videomode) |
44 | + push %ebp |
45 | + push %ebx |
46 | + push %ecx |
47 | + |
48 | + movb 0x10(%esp), %cl |
49 | + |
50 | + call EXT_C(prot_to_real) |
51 | + .code16 |
52 | + |
53 | + xorw %bx, %bx |
54 | + movb $0xf, %ah |
55 | + int $0x10 /* Get Current Video mode */ |
56 | + movb %al, %ch |
57 | + xorb %ah, %ah |
58 | + movb %cl, %al |
59 | + int $0x10 /* Set Video mode */ |
60 | + |
61 | + DATA32 call EXT_C(real_to_prot) |
62 | + .code32 |
63 | + |
64 | + xorb %ah, %ah |
65 | + movb %ch, %al |
66 | + |
67 | + pop %ecx |
68 | + pop %ebx |
69 | + pop %ebp |
70 | + ret |
71 | + |
72 | + |
73 | +/* |
74 | + * unsigned char * graphics_get_font() |
75 | + * BIOS call "INT 10H Function 11h" to set font |
76 | + * Call with %ah = 0x11 |
77 | + */ |
78 | +ENTRY(graphics_get_font) |
79 | + push %ebp |
80 | + push %ebx |
81 | + push %ecx |
82 | + push %edx |
83 | + |
84 | + call EXT_C(prot_to_real) |
85 | + .code16 |
86 | + |
87 | + movw $0x1130, %ax |
88 | + movb $6, %bh /* font 8x16 */ |
89 | + int $0x10 |
90 | + movw %bp, %dx |
91 | + movw %es, %cx |
92 | + |
93 | + DATA32 call EXT_C(real_to_prot) |
94 | + .code32 |
95 | + |
96 | + xorl %eax, %eax |
97 | + movw %cx, %ax |
98 | + shll $4, %eax |
99 | + movw %dx, %ax |
100 | + |
101 | + pop %edx |
102 | + pop %ecx |
103 | + pop %ebx |
104 | + pop %ebp |
105 | + ret |
106 | + |
107 | + |
108 | + |
109 | +/* |
110 | + * graphics_set_palette(index, red, green, blue) |
111 | + * BIOS call "INT 10H Function 10h" to set individual dac register |
112 | + * Call with %ah = 0x10 |
113 | + * %bx = register number |
114 | + * %ch = new value for green (0-63) |
115 | + * %cl = new value for blue (0-63) |
116 | + * %dh = new value for red (0-63) |
117 | + */ |
118 | + |
119 | +ENTRY(graphics_set_palette) |
120 | + push %ebp |
121 | + push %eax |
122 | + push %ebx |
123 | + push %ecx |
124 | + push %edx |
125 | + |
126 | + movw $0x3c8, %bx /* address write mode register */ |
127 | + |
128 | + /* wait vertical retrace */ |
129 | + |
130 | + movw $0x3da, %dx |
131 | +l1b: inb %dx, %al /* wait vertical active display */ |
132 | + test $8, %al |
133 | + jnz l1b |
134 | + |
135 | +l2b: inb %dx, %al /* wait vertical retrace */ |
136 | + test $8, %al |
137 | + jnz l2b |
138 | + |
139 | + mov %bx, %dx |
140 | + movb 0x18(%esp), %al /* index */ |
141 | + outb %al, %dx |
142 | + inc %dx |
143 | + |
144 | + movb 0x1c(%esp), %al /* red */ |
145 | + outb %al, %dx |
146 | + |
147 | + movb 0x20(%esp), %al /* green */ |
148 | + outb %al, %dx |
149 | + |
150 | + movb 0x24(%esp), %al /* blue */ |
151 | + outb %al, %dx |
152 | + |
153 | + movw 0x18(%esp), %bx |
154 | + |
155 | + call EXT_C(prot_to_real) |
156 | + .code16 |
157 | + |
158 | + movb %bl, %bh |
159 | + movw $0x1000, %ax |
160 | + int $0x10 |
161 | + |
162 | + DATA32 call EXT_C(real_to_prot) |
163 | + .code32 |
164 | + |
165 | + pop %edx |
166 | + pop %ecx |
167 | + pop %ebx |
168 | + pop %eax |
169 | + pop %ebp |
170 | + ret |
171 | + |
172 | +#endif /* SUPPORT_GRAPHICS */ |
173 | |
174 | /* |
175 | * getrtsecs() |
176 | diff -Naur grub-0.95-orig/stage2/builtins.c grub-0.95/stage2/builtins.c |
177 | --- grub-0.95-orig/stage2/builtins.c 2004-01-11 10:39:22.000000000 +0100 |
178 | +++ grub-0.95/stage2/builtins.c 2004-02-15 11:20:57.736019144 +0100 |
179 | @@ -848,6 +848,138 @@ |
180 | }; |
181 | #endif /* SUPPORT_NETBOOT */ |
182 | |
183 | +static int terminal_func (char *arg, int flags); |
184 | + |
185 | +#ifdef SUPPORT_GRAPHICS |
186 | + |
187 | +static int splashimage_func(char *arg, int flags) { |
188 | + char splashimage[64]; |
189 | + int i; |
190 | + |
191 | + /* filename can only be 64 characters due to our buffer size */ |
192 | + if (strlen(arg) > 63) |
193 | + return 1; |
194 | + if (flags == BUILTIN_CMDLINE) { |
195 | + if (!grub_open(arg)) |
196 | + return 1; |
197 | + grub_close(); |
198 | + } |
199 | + |
200 | + strcpy(splashimage, arg); |
201 | + |
202 | + /* get rid of TERM_NEED_INIT from the graphics terminal. */ |
203 | + for (i = 0; term_table[i].name; i++) { |
204 | + if (grub_strcmp (term_table[i].name, "graphics") == 0) { |
205 | + term_table[i].flags &= ~TERM_NEED_INIT; |
206 | + break; |
207 | + } |
208 | + } |
209 | + |
210 | + graphics_set_splash(splashimage); |
211 | + |
212 | + if (flags == BUILTIN_CMDLINE && graphics_inited) { |
213 | + graphics_end(); |
214 | + graphics_init(); |
215 | + graphics_cls(); |
216 | + } |
217 | + |
218 | + /* FIXME: should we be explicitly switching the terminal as a |
219 | + * side effect here? */ |
220 | + terminal_func("graphics", flags); |
221 | + |
222 | + return 0; |
223 | +} |
224 | + |
225 | +static struct builtin builtin_splashimage = |
226 | +{ |
227 | + "splashimage", |
228 | + splashimage_func, |
229 | + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, |
230 | + "splashimage FILE", |
231 | + "Load FILE as the background image when in graphics mode." |
232 | +}; |
233 | + |
234 | + |
235 | +/* foreground */ |
236 | +static int |
237 | +foreground_func(char *arg, int flags) |
238 | +{ |
239 | + if (grub_strlen(arg) == 6) { |
240 | + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2; |
241 | + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2; |
242 | + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2; |
243 | + |
244 | + foreground = (r << 16) | (g << 8) | b; |
245 | + if (graphics_inited) |
246 | + graphics_set_palette(15, r, g, b); |
247 | + |
248 | + return (0); |
249 | + } |
250 | + |
251 | + return (1); |
252 | +} |
253 | + |
254 | +static struct builtin builtin_foreground = |
255 | +{ |
256 | + "foreground", |
257 | + foreground_func, |
258 | + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, |
259 | + "foreground RRGGBB", |
260 | + "Sets the foreground color when in graphics mode." |
261 | + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal." |
262 | +}; |
263 | + |
264 | + |
265 | +/* background */ |
266 | +static int |
267 | +background_func(char *arg, int flags) |
268 | +{ |
269 | + if (grub_strlen(arg) == 6) { |
270 | + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2; |
271 | + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2; |
272 | + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2; |
273 | + |
274 | + background = (r << 16) | (g << 8) | b; |
275 | + if (graphics_inited) |
276 | + graphics_set_palette(0, r, g, b); |
277 | + return (0); |
278 | + } |
279 | + |
280 | + return (1); |
281 | +} |
282 | + |
283 | +static struct builtin builtin_background = |
284 | +{ |
285 | + "background", |
286 | + background_func, |
287 | + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, |
288 | + "background RRGGBB", |
289 | + "Sets the background color when in graphics mode." |
290 | + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal." |
291 | +}; |
292 | + |
293 | +#endif /* SUPPORT_GRAPHICS */ |
294 | + |
295 | + |
296 | +/* clear */ |
297 | +static int |
298 | +clear_func() |
299 | +{ |
300 | + if (current_term->cls) |
301 | + current_term->cls(); |
302 | + |
303 | + return 0; |
304 | +} |
305 | + |
306 | +static struct builtin builtin_clear = |
307 | +{ |
308 | + "clear", |
309 | + clear_func, |
310 | + BUILTIN_CMDLINE | BUILTIN_HELP_LIST, |
311 | + "clear", |
312 | + "Clear the screen" |
313 | +}; |
314 | + |
315 | |
316 | /* displayapm */ |
317 | static int |
318 | @@ -4073,7 +4205,7 @@ |
319 | }; |
320 | |
321 | |
322 | -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) |
323 | +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS) |
324 | /* terminal */ |
325 | static int |
326 | terminal_func (char *arg, int flags) |
327 | @@ -4232,17 +4364,21 @@ |
328 | end: |
329 | current_term = term_table + default_term; |
330 | current_term->flags = term_flags; |
331 | - |
332 | + |
333 | if (lines) |
334 | max_lines = lines; |
335 | else |
336 | - /* 24 would be a good default value. */ |
337 | - max_lines = 24; |
338 | - |
339 | + max_lines = current_term->max_lines; |
340 | + |
341 | /* If the interface is currently the command-line, |
342 | restart it to repaint the screen. */ |
343 | - if (current_term != prev_term && (flags & BUILTIN_CMDLINE)) |
344 | + if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){ |
345 | + if (prev_term->shutdown) |
346 | + prev_term->shutdown(); |
347 | + if (current_term->startup) |
348 | + current_term->startup(); |
349 | grub_longjmp (restart_cmdline_env, 0); |
350 | + } |
351 | |
352 | return 0; |
353 | } |
354 | @@ -4252,7 +4388,7 @@ |
355 | "terminal", |
356 | terminal_func, |
357 | BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST, |
358 | - "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]", |
359 | + "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]", |
360 | "Select a terminal. When multiple terminals are specified, wait until" |
361 | " you push any key to continue. If both console and serial are specified," |
362 | " the terminal to which you input a key first will be selected. If no" |
363 | @@ -4264,7 +4400,7 @@ |
364 | " seconds. The option --lines specifies the maximum number of lines." |
365 | " The option --silent is used to suppress messages." |
366 | }; |
367 | -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */ |
368 | +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */ |
369 | |
370 | |
371 | #ifdef SUPPORT_SERIAL |
372 | @@ -4783,6 +4919,9 @@ |
373 | /* The table of builtin commands. Sorted in dictionary order. */ |
374 | struct builtin *builtin_table[] = |
375 | { |
376 | +#ifdef SUPPORT_GRAPHICS |
377 | + &builtin_background, |
378 | +#endif |
379 | &builtin_blocklist, |
380 | &builtin_boot, |
381 | #ifdef SUPPORT_NETBOOT |
382 | @@ -4790,6 +4929,7 @@ |
383 | #endif /* SUPPORT_NETBOOT */ |
384 | &builtin_cat, |
385 | &builtin_chainloader, |
386 | + &builtin_clear, |
387 | &builtin_cmp, |
388 | &builtin_color, |
389 | &builtin_configfile, |
390 | @@ -4809,6 +4949,9 @@ |
391 | &builtin_embed, |
392 | &builtin_fallback, |
393 | &builtin_find, |
394 | +#ifdef SUPPORT_GRAPHICS |
395 | + &builtin_foreground, |
396 | +#endif |
397 | &builtin_fstest, |
398 | &builtin_geometry, |
399 | &builtin_halt, |
400 | @@ -4852,9 +4995,12 @@ |
401 | #endif /* SUPPORT_SERIAL */ |
402 | &builtin_setkey, |
403 | &builtin_setup, |
404 | -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) |
405 | +#ifdef SUPPORT_GRAPHICS |
406 | + &builtin_splashimage, |
407 | +#endif /* SUPPORT_GRAPHICS */ |
408 | +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS) |
409 | &builtin_terminal, |
410 | -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */ |
411 | +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */ |
412 | #ifdef SUPPORT_SERIAL |
413 | &builtin_terminfo, |
414 | #endif /* SUPPORT_SERIAL */ |
415 | |
416 | diff -Naur grub-0.95-orig/stage2/char_io.c grub-0.95/stage2/char_io.c |
417 | --- grub-0.95-orig/stage2/char_io.c 2003-07-09 13:45:52.000000000 +0200 |
418 | +++ grub-0.95/stage2/char_io.c 2004-02-15 11:20:57.742018232 +0100 |
419 | @@ -35,6 +35,7 @@ |
420 | { |
421 | "console", |
422 | 0, |
423 | + 24, |
424 | console_putchar, |
425 | console_checkkey, |
426 | console_getkey, |
427 | @@ -43,13 +44,16 @@ |
428 | console_cls, |
429 | console_setcolorstate, |
430 | console_setcolor, |
431 | - console_setcursor |
432 | + console_setcursor, |
433 | + 0, |
434 | + 0 |
435 | }, |
436 | #ifdef SUPPORT_SERIAL |
437 | { |
438 | "serial", |
439 | /* A serial device must be initialized. */ |
440 | TERM_NEED_INIT, |
441 | + 24, |
442 | serial_putchar, |
443 | serial_checkkey, |
444 | serial_getkey, |
445 | @@ -58,6 +62,8 @@ |
446 | serial_cls, |
447 | serial_setcolorstate, |
448 | 0, |
449 | + 0, |
450 | + 0, |
451 | 0 |
452 | }, |
453 | #endif /* SUPPORT_SERIAL */ |
454 | @@ -65,6 +71,7 @@ |
455 | { |
456 | "hercules", |
457 | 0, |
458 | + 24, |
459 | hercules_putchar, |
460 | console_checkkey, |
461 | console_getkey, |
462 | @@ -73,9 +80,28 @@ |
463 | hercules_cls, |
464 | hercules_setcolorstate, |
465 | hercules_setcolor, |
466 | - hercules_setcursor |
467 | + hercules_setcursor, |
468 | + 0, |
469 | + 0 |
470 | }, |
471 | #endif /* SUPPORT_HERCULES */ |
472 | +#ifdef SUPPORT_GRAPHICS |
473 | + { "graphics", |
474 | + TERM_NEED_INIT, /* flags */ |
475 | + 30, /* number of lines */ |
476 | + graphics_putchar, /* putchar */ |
477 | + console_checkkey, /* checkkey */ |
478 | + console_getkey, /* getkey */ |
479 | + graphics_getxy, /* getxy */ |
480 | + graphics_gotoxy, /* gotoxy */ |
481 | + graphics_cls, /* cls */ |
482 | + graphics_setcolorstate, /* setcolorstate */ |
483 | + graphics_setcolor, /* setcolor */ |
484 | + graphics_setcursor, /* nocursor */ |
485 | + graphics_init, /* initialize */ |
486 | + graphics_end /* shutdown */ |
487 | + }, |
488 | +#endif /* SUPPORT_GRAPHICS */ |
489 | /* This must be the last entry. */ |
490 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } |
491 | }; |
492 | @@ -1046,13 +1072,15 @@ |
493 | the following grub_printf call will print newlines. */ |
494 | count_lines = -1; |
495 | |
496 | + grub_printf("\n"); |
497 | if (current_term->setcolorstate) |
498 | current_term->setcolorstate (COLOR_STATE_HIGHLIGHT); |
499 | |
500 | - grub_printf ("\n[Hit return to continue]"); |
501 | + grub_printf ("[Hit return to continue]"); |
502 | |
503 | if (current_term->setcolorstate) |
504 | current_term->setcolorstate (COLOR_STATE_NORMAL); |
505 | + |
506 | |
507 | do |
508 | { |
509 | @@ -1090,7 +1118,7 @@ |
510 | cls (void) |
511 | { |
512 | /* If the terminal is dumb, there is no way to clean the terminal. */ |
513 | - if (current_term->flags & TERM_DUMB) |
514 | + if (current_term->flags & TERM_DUMB) |
515 | grub_putchar ('\n'); |
516 | else |
517 | current_term->cls (); |
518 | @@ -1214,6 +1242,16 @@ |
519 | return ! errnum; |
520 | } |
521 | |
522 | +void |
523 | +grub_memcpy(void *dest, const void *src, int len) |
524 | +{ |
525 | + int i; |
526 | + register char *d = (char*)dest, *s = (char*)src; |
527 | + |
528 | + for (i = 0; i < len; i++) |
529 | + d[i] = s[i]; |
530 | +} |
531 | + |
532 | void * |
533 | grub_memmove (void *to, const void *from, int len) |
534 | { |
535 | diff -Naur grub-0.95-orig/stage2/graphics.c grub-0.95/stage2/graphics.c |
536 | --- grub-0.95-orig/stage2/graphics.c 1970-01-01 01:00:00.000000000 +0100 |
537 | +++ grub-0.95/stage2/graphics.c 2004-02-15 11:20:57.744017928 +0100 |
538 | @@ -0,0 +1,552 @@ |
539 | +/* graphics.c - graphics mode support for GRUB */ |
540 | +/* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based |
541 | + * on a patch by Paulo César Pereira de Andrade <pcpa@conectiva.com.br> |
542 | + */ |
543 | +/* |
544 | + * GRUB -- GRand Unified Bootloader |
545 | + * Copyright (C) 2001,2002 Red Hat, Inc. |
546 | + * Portions copyright (C) 2000 Conectiva, Inc. |
547 | + * |
548 | + * This program is free software; you can redistribute it and/or modify |
549 | + * it under the terms of the GNU General Public License as published by |
550 | + * the Free Software Foundation; either version 2 of the License, or |
551 | + * (at your option) any later version. |
552 | + * |
553 | + * This program is distributed in the hope that it will be useful, |
554 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
555 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
556 | + * GNU General Public License for more details. |
557 | + * |
558 | + * You should have received a copy of the GNU General Public License |
559 | + * along with this program; if not, write to the Free Software |
560 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
561 | + */ |
562 | + |
563 | + |
564 | + |
565 | +#ifdef SUPPORT_GRAPHICS |
566 | + |
567 | +#include <term.h> |
568 | +#include <shared.h> |
569 | +#include <graphics.h> |
570 | + |
571 | +int saved_videomode; |
572 | +unsigned char *font8x16; |
573 | + |
574 | +int graphics_inited = 0; |
575 | +static char splashimage[64]; |
576 | + |
577 | +#define VSHADOW VSHADOW1 |
578 | +unsigned char VSHADOW1[38400]; |
579 | +unsigned char VSHADOW2[38400]; |
580 | +unsigned char VSHADOW4[38400]; |
581 | +unsigned char VSHADOW8[38400]; |
582 | + |
583 | +/* constants to define the viewable area */ |
584 | +const int x0 = 0; |
585 | +const int x1 = 80; |
586 | +const int y0 = 0; |
587 | +const int y1 = 30; |
588 | + |
589 | +/* text buffer has to be kept around so that we can write things as we |
590 | + * scroll and the like */ |
591 | +unsigned short text[80 * 30]; |
592 | + |
593 | +/* why do these have to be kept here? */ |
594 | +int foreground = (63 << 16) | (63 << 8) | (63), background = 0, border = 0; |
595 | + |
596 | +/* current position */ |
597 | +static int fontx = 0; |
598 | +static int fonty = 0; |
599 | + |
600 | +/* global state so that we don't try to recursively scroll or cursor */ |
601 | +static int no_scroll = 0; |
602 | + |
603 | +/* color state */ |
604 | +static int graphics_standard_color = A_NORMAL; |
605 | +static int graphics_normal_color = A_NORMAL; |
606 | +static int graphics_highlight_color = A_REVERSE; |
607 | +static int graphics_current_color = A_NORMAL; |
608 | +static color_state graphics_color_state = COLOR_STATE_STANDARD; |
609 | + |
610 | + |
611 | +/* graphics local functions */ |
612 | +static void graphics_setxy(int col, int row); |
613 | +static void graphics_scroll(); |
614 | + |
615 | +/* FIXME: where do these really belong? */ |
616 | +static inline void outb(unsigned short port, unsigned char val) |
617 | +{ |
618 | + __asm __volatile ("outb %0,%1"::"a" (val), "d" (port)); |
619 | +} |
620 | + |
621 | +static void MapMask(int value) { |
622 | + outb(0x3c4, 2); |
623 | + outb(0x3c5, value); |
624 | +} |
625 | + |
626 | +/* bit mask register */ |
627 | +static void BitMask(int value) { |
628 | + outb(0x3ce, 8); |
629 | + outb(0x3cf, value); |
630 | +} |
631 | + |
632 | + |
633 | + |
634 | +/* Set the splash image */ |
635 | +void graphics_set_splash(char *splashfile) { |
636 | + grub_strcpy(splashimage, splashfile); |
637 | +} |
638 | + |
639 | +/* Get the current splash image */ |
640 | +char *graphics_get_splash(void) { |
641 | + return splashimage; |
642 | +} |
643 | + |
644 | +/* Initialize a vga16 graphics display with the palette based off of |
645 | + * the image in splashimage. If the image doesn't exist, leave graphics |
646 | + * mode. */ |
647 | +int graphics_init() |
648 | +{ |
649 | + if (!graphics_inited) { |
650 | + saved_videomode = set_videomode(0x12); |
651 | + } |
652 | + |
653 | + if (!read_image(splashimage)) { |
654 | + set_videomode(saved_videomode); |
655 | + grub_printf("failed to read image\n"); |
656 | + return 0; |
657 | + } |
658 | + |
659 | + font8x16 = (unsigned char*)graphics_get_font(); |
660 | + |
661 | + graphics_inited = 1; |
662 | + |
663 | + /* make sure that the highlight color is set correctly */ |
664 | + graphics_highlight_color = ((graphics_normal_color >> 4) | |
665 | + ((graphics_normal_color & 0xf) << 4)); |
666 | + |
667 | + return 1; |
668 | +} |
669 | + |
670 | +/* Leave graphics mode */ |
671 | +void graphics_end(void) |
672 | +{ |
673 | + if (graphics_inited) { |
674 | + set_videomode(saved_videomode); |
675 | + graphics_inited = 0; |
676 | + } |
677 | +} |
678 | + |
679 | +/* Print ch on the screen. Handle any needed scrolling or the like */ |
680 | +void graphics_putchar(int ch) { |
681 | + ch &= 0xff; |
682 | + |
683 | + graphics_cursor(0); |
684 | + |
685 | + if (ch == '\n') { |
686 | + if (fonty + 1 < y1) |
687 | + graphics_setxy(fontx, fonty + 1); |
688 | + else |
689 | + graphics_scroll(); |
690 | + graphics_cursor(1); |
691 | + return; |
692 | + } else if (ch == '\r') { |
693 | + graphics_setxy(x0, fonty); |
694 | + graphics_cursor(1); |
695 | + return; |
696 | + } |
697 | + |
698 | + graphics_cursor(0); |
699 | + |
700 | + text[fonty * 80 + fontx] = ch; |
701 | + text[fonty * 80 + fontx] &= 0x00ff; |
702 | + if (graphics_current_color & 0xf0) |
703 | + text[fonty * 80 + fontx] |= 0x100; |
704 | + |
705 | + graphics_cursor(0); |
706 | + |
707 | + if ((fontx + 1) >= x1) { |
708 | + graphics_setxy(x0, fonty); |
709 | + if (fonty + 1 < y1) |
710 | + graphics_setxy(x0, fonty + 1); |
711 | + else |
712 | + graphics_scroll(); |
713 | + } else { |
714 | + graphics_setxy(fontx + 1, fonty); |
715 | + } |
716 | + |
717 | + graphics_cursor(1); |
718 | +} |
719 | + |
720 | +/* get the current location of the cursor */ |
721 | +int graphics_getxy(void) { |
722 | + return (fontx << 8) | fonty; |
723 | +} |
724 | + |
725 | +void graphics_gotoxy(int x, int y) { |
726 | + graphics_cursor(0); |
727 | + |
728 | + graphics_setxy(x, y); |
729 | + |
730 | + graphics_cursor(1); |
731 | +} |
732 | + |
733 | +void graphics_cls(void) { |
734 | + int i; |
735 | + unsigned char *mem, *s1, *s2, *s4, *s8; |
736 | + |
737 | + graphics_cursor(0); |
738 | + graphics_gotoxy(x0, y0); |
739 | + |
740 | + mem = (unsigned char*)VIDEOMEM; |
741 | + s1 = (unsigned char*)VSHADOW1; |
742 | + s2 = (unsigned char*)VSHADOW2; |
743 | + s4 = (unsigned char*)VSHADOW4; |
744 | + s8 = (unsigned char*)VSHADOW8; |
745 | + |
746 | + for (i = 0; i < 80 * 30; i++) |
747 | + text[i] = ' '; |
748 | + graphics_cursor(1); |
749 | + |
750 | + BitMask(0xff); |
751 | + |
752 | + /* plano 1 */ |
753 | + MapMask(1); |
754 | + grub_memcpy(mem, s1, 38400); |
755 | + |
756 | + /* plano 2 */ |
757 | + MapMask(2); |
758 | + grub_memcpy(mem, s2, 38400); |
759 | + |
760 | + /* plano 3 */ |
761 | + MapMask(4); |
762 | + grub_memcpy(mem, s4, 38400); |
763 | + |
764 | + /* plano 4 */ |
765 | + MapMask(8); |
766 | + grub_memcpy(mem, s8, 38400); |
767 | + |
768 | + MapMask(15); |
769 | + |
770 | +} |
771 | + |
772 | +void graphics_setcolorstate (color_state state) { |
773 | + switch (state) { |
774 | + case COLOR_STATE_STANDARD: |
775 | + graphics_current_color = graphics_standard_color; |
776 | + break; |
777 | + case COLOR_STATE_NORMAL: |
778 | + graphics_current_color = graphics_normal_color; |
779 | + break; |
780 | + case COLOR_STATE_HIGHLIGHT: |
781 | + graphics_current_color = graphics_highlight_color; |
782 | + break; |
783 | + default: |
784 | + graphics_current_color = graphics_standard_color; |
785 | + break; |
786 | + } |
787 | + |
788 | + graphics_color_state = state; |
789 | +} |
790 | + |
791 | +void graphics_setcolor (int normal_color, int highlight_color) { |
792 | + graphics_normal_color = normal_color; |
793 | + graphics_highlight_color = highlight_color; |
794 | + |
795 | + graphics_setcolorstate (graphics_color_state); |
796 | +} |
797 | + |
798 | +void graphics_setcursor (int on) { |
799 | + /* FIXME: we don't have a cursor in graphics */ |
800 | + return; |
801 | +} |
802 | + |
803 | +/* Read in the splashscreen image and set the palette up appropriately. |
804 | + * Format of splashscreen is an xpm (can be gzipped) with 16 colors and |
805 | + * 640x480. */ |
806 | +int read_image(char *s) |
807 | +{ |
808 | + char buf[32], pal[16]; |
809 | + unsigned char c, base, mask, *s1, *s2, *s4, *s8; |
810 | + unsigned i, len, idx, colors, x, y, width, height; |
811 | + |
812 | + if (!grub_open(s)) |
813 | + return 0; |
814 | + |
815 | + /* read header */ |
816 | + if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) { |
817 | + grub_close(); |
818 | + return 0; |
819 | + } |
820 | + |
821 | + /* parse info */ |
822 | + while (grub_read(&c, 1)) { |
823 | + if (c == '"') |
824 | + break; |
825 | + } |
826 | + |
827 | + while (grub_read(&c, 1) && (c == ' ' || c == '\t')) |
828 | + ; |
829 | + |
830 | + i = 0; |
831 | + width = c - '0'; |
832 | + while (grub_read(&c, 1)) { |
833 | + if (c >= '0' && c <= '9') |
834 | + width = width * 10 + c - '0'; |
835 | + else |
836 | + break; |
837 | + } |
838 | + while (grub_read(&c, 1) && (c == ' ' || c == '\t')) |
839 | + ; |
840 | + |
841 | + height = c - '0'; |
842 | + while (grub_read(&c, 1)) { |
843 | + if (c >= '0' && c <= '9') |
844 | + height = height * 10 + c - '0'; |
845 | + else |
846 | + break; |
847 | + } |
848 | + while (grub_read(&c, 1) && (c == ' ' || c == '\t')) |
849 | + ; |
850 | + |
851 | + colors = c - '0'; |
852 | + while (grub_read(&c, 1)) { |
853 | + if (c >= '0' && c <= '9') |
854 | + colors = colors * 10 + c - '0'; |
855 | + else |
856 | + break; |
857 | + } |
858 | + |
859 | + base = 0; |
860 | + while (grub_read(&c, 1) && c != '"') |
861 | + ; |
862 | + |
863 | + /* palette */ |
864 | + for (i = 0, idx = 1; i < colors; i++) { |
865 | + len = 0; |
866 | + |
867 | + while (grub_read(&c, 1) && c != '"') |
868 | + ; |
869 | + grub_read(&c, 1); /* char */ |
870 | + base = c; |
871 | + grub_read(buf, 4); /* \t c # */ |
872 | + |
873 | + while (grub_read(&c, 1) && c != '"') { |
874 | + if (len < sizeof(buf)) |
875 | + buf[len++] = c; |
876 | + } |
877 | + |
878 | + if (len == 6 && idx < 15) { |
879 | + int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2; |
880 | + int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2; |
881 | + int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2; |
882 | + |
883 | + pal[idx] = base; |
884 | + graphics_set_palette(idx, r, g, b); |
885 | + ++idx; |
886 | + } |
887 | + } |
888 | + |
889 | + x = y = len = 0; |
890 | + |
891 | + s1 = (unsigned char*)VSHADOW1; |
892 | + s2 = (unsigned char*)VSHADOW2; |
893 | + s4 = (unsigned char*)VSHADOW4; |
894 | + s8 = (unsigned char*)VSHADOW8; |
895 | + |
896 | + for (i = 0; i < 38400; i++) |
897 | + s1[i] = s2[i] = s4[i] = s8[i] = 0; |
898 | + |
899 | + /* parse xpm data */ |
900 | + while (y < height) { |
901 | + while (1) { |
902 | + if (!grub_read(&c, 1)) { |
903 | + grub_close(); |
904 | + return 0; |
905 | + } |
906 | + if (c == '"') |
907 | + break; |
908 | + } |
909 | + |
910 | + while (grub_read(&c, 1) && c != '"') { |
911 | + for (i = 1; i < 15; i++) |
912 | + if (pal[i] == c) { |
913 | + c = i; |
914 | + break; |
915 | + } |
916 | + |
917 | + mask = 0x80 >> (x & 7); |
918 | + if (c & 1) |
919 | + s1[len + (x >> 3)] |= mask; |
920 | + if (c & 2) |
921 | + s2[len + (x >> 3)] |= mask; |
922 | + if (c & 4) |
923 | + s4[len + (x >> 3)] |= mask; |
924 | + if (c & 8) |
925 | + s8[len + (x >> 3)] |= mask; |
926 | + |
927 | + if (++x >= 640) { |
928 | + x = 0; |
929 | + |
930 | + if (y < 480) |
931 | + len += 80; |
932 | + ++y; |
933 | + } |
934 | + } |
935 | + } |
936 | + |
937 | + grub_close(); |
938 | + |
939 | + graphics_set_palette(0, (background >> 16), (background >> 8) & 63, |
940 | + background & 63); |
941 | + graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63, |
942 | + foreground & 63); |
943 | + graphics_set_palette(0x11, (border >> 16), (border >> 8) & 63, |
944 | + border & 63); |
945 | + |
946 | + return 1; |
947 | +} |
948 | + |
949 | + |
950 | +/* Convert a character which is a hex digit to the appropriate integer */ |
951 | +int hex(int v) |
952 | +{ |
953 | + if (v >= 'A' && v <= 'F') |
954 | + return (v - 'A' + 10); |
955 | + if (v >= 'a' && v <= 'f') |
956 | + return (v - 'a' + 10); |
957 | + return (v - '0'); |
958 | +} |
959 | + |
960 | + |
961 | +/* move the graphics cursor location to col, row */ |
962 | +static void graphics_setxy(int col, int row) { |
963 | + if (col >= x0 && col < x1) { |
964 | + fontx = col; |
965 | + cursorX = col << 3; |
966 | + } |
967 | + if (row >= y0 && row < y1) { |
968 | + fonty = row; |
969 | + cursorY = row << 4; |
970 | + } |
971 | +} |
972 | + |
973 | +/* scroll the screen */ |
974 | +static void graphics_scroll() { |
975 | + int i, j; |
976 | + |
977 | + /* we don't want to scroll recursively... that would be bad */ |
978 | + if (no_scroll) |
979 | + return; |
980 | + no_scroll = 1; |
981 | + |
982 | + /* move everything up a line */ |
983 | + for (j = y0 + 1; j < y1; j++) { |
984 | + graphics_gotoxy(x0, j - 1); |
985 | + for (i = x0; i < x1; i++) { |
986 | + graphics_putchar(text[j * 80 + i]); |
987 | + } |
988 | + } |
989 | + |
990 | + /* last line should be blank */ |
991 | + graphics_gotoxy(x0, y1 - 1); |
992 | + for (i = x0; i < x1; i++) |
993 | + graphics_putchar(' '); |
994 | + graphics_setxy(x0, y1 - 1); |
995 | + |
996 | + no_scroll = 0; |
997 | +} |
998 | + |
999 | + |
1000 | +void graphics_cursor(int set) { |
1001 | + unsigned char *pat, *mem, *ptr, chr[16 << 2]; |
1002 | + int i, ch, invert, offset; |
1003 | + |
1004 | + if (set && no_scroll) |
1005 | + return; |
1006 | + |
1007 | + offset = cursorY * 80 + fontx; |
1008 | + ch = text[fonty * 80 + fontx] & 0xff; |
1009 | + invert = (text[fonty * 80 + fontx] & 0xff00) != 0; |
1010 | + pat = font8x16 + (ch << 4); |
1011 | + |
1012 | + mem = (unsigned char*)VIDEOMEM + offset; |
1013 | + |
1014 | + if (!set) { |
1015 | + for (i = 0; i < 16; i++) { |
1016 | + unsigned char mask = pat[i]; |
1017 | + |
1018 | + if (!invert) { |
1019 | + chr[i ] = ((unsigned char*)VSHADOW1)[offset]; |
1020 | + chr[16 + i] = ((unsigned char*)VSHADOW2)[offset]; |
1021 | + chr[32 + i] = ((unsigned char*)VSHADOW4)[offset]; |
1022 | + chr[48 + i] = ((unsigned char*)VSHADOW8)[offset]; |
1023 | + |
1024 | + /* FIXME: if (shade) */ |
1025 | + if (1) { |
1026 | + if (ch == DISP_VERT || ch == DISP_LL || |
1027 | + ch == DISP_UR || ch == DISP_LR) { |
1028 | + unsigned char pmask = ~(pat[i] >> 1); |
1029 | + |
1030 | + chr[i ] &= pmask; |
1031 | + chr[16 + i] &= pmask; |
1032 | + chr[32 + i] &= pmask; |
1033 | + chr[48 + i] &= pmask; |
1034 | + } |
1035 | + if (i > 0 && ch != DISP_VERT) { |
1036 | + unsigned char pmask = ~(pat[i - 1] >> 1); |
1037 | + |
1038 | + chr[i ] &= pmask; |
1039 | + chr[16 + i] &= pmask; |
1040 | + chr[32 + i] &= pmask; |
1041 | + chr[48 + i] &= pmask; |
1042 | + if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) { |
1043 | + pmask = ~pat[i - 1]; |
1044 | + |
1045 | + chr[i ] &= pmask; |
1046 | + chr[16 + i] &= pmask; |
1047 | + chr[32 + i] &= pmask; |
1048 | + chr[48 + i] &= pmask; |
1049 | + } |
1050 | + } |
1051 | + } |
1052 | + chr[i ] |= mask; |
1053 | + chr[16 + i] |= mask; |
1054 | + chr[32 + i] |= mask; |
1055 | + chr[48 + i] |= mask; |
1056 | + |
1057 | + offset += 80; |
1058 | + } |
1059 | + else { |
1060 | + chr[i ] = mask; |
1061 | + chr[16 + i] = mask; |
1062 | + chr[32 + i] = mask; |
1063 | + chr[48 + i] = mask; |
1064 | + } |
1065 | + } |
1066 | + } |
1067 | + else { |
1068 | + MapMask(15); |
1069 | + ptr = mem; |
1070 | + for (i = 0; i < 16; i++, ptr += 80) { |
1071 | + cursorBuf[i] = pat[i]; |
1072 | + *ptr = ~pat[i]; |
1073 | + } |
1074 | + return; |
1075 | + } |
1076 | + |
1077 | + offset = 0; |
1078 | + for (i = 1; i < 16; i <<= 1, offset += 16) { |
1079 | + int j; |
1080 | + |
1081 | + MapMask(i); |
1082 | + ptr = mem; |
1083 | + for (j = 0; j < 16; j++, ptr += 80) |
1084 | + *ptr = chr[j + offset]; |
1085 | + } |
1086 | + |
1087 | + MapMask(15); |
1088 | +} |
1089 | + |
1090 | +#endif /* SUPPORT_GRAPHICS */ |
1091 | diff -Naur grub-0.95-orig/stage2/graphics.h grub-0.95/stage2/graphics.h |
1092 | --- grub-0.95-orig/stage2/graphics.h 1970-01-01 01:00:00.000000000 +0100 |
1093 | +++ grub-0.95/stage2/graphics.h 2004-02-15 11:20:57.746017624 +0100 |
1094 | @@ -0,0 +1,42 @@ |
1095 | +/* graphics.h - graphics console interface */ |
1096 | +/* |
1097 | + * GRUB -- GRand Unified Bootloader |
1098 | + * Copyright (C) 2002 Free Software Foundation, Inc. |
1099 | + * |
1100 | + * This program is free software; you can redistribute it and/or modify |
1101 | + * it under the terms of the GNU General Public License as published by |
1102 | + * the Free Software Foundation; either version 2 of the License, or |
1103 | + * (at your option) any later version. |
1104 | + * |
1105 | + * This program is distributed in the hope that it will be useful, |
1106 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1107 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1108 | + * GNU General Public License for more details. |
1109 | + * |
1110 | + * You should have received a copy of the GNU General Public License |
1111 | + * along with this program; if not, write to the Free Software |
1112 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
1113 | + */ |
1114 | + |
1115 | +#ifndef GRAPHICS_H |
1116 | +#define GRAPHICS_H |
1117 | + |
1118 | +/* magic constant */ |
1119 | +#define VIDEOMEM 0xA0000 |
1120 | + |
1121 | +/* function prototypes */ |
1122 | +char *graphics_get_splash(void); |
1123 | + |
1124 | +int read_image(char *s); |
1125 | +void graphics_cursor(int set); |
1126 | + |
1127 | +/* function prototypes for asm functions */ |
1128 | +void * graphics_get_font(); |
1129 | +void graphics_set_palette(int idx, int red, int green, int blue); |
1130 | +void set_int1c_handler(); |
1131 | +void unset_int1c_handler(); |
1132 | + |
1133 | +extern short cursorX, cursorY; |
1134 | +extern char cursorBuf[16]; |
1135 | + |
1136 | +#endif /* GRAPHICS_H */ |
1137 | diff -Naur grub-0.95-orig/stage2/Makefile.am grub-0.95/stage2/Makefile.am |
1138 | --- grub-0.95-orig/stage2/Makefile.am 2003-10-19 18:45:18.000000000 +0200 |
1139 | +++ grub-0.95/stage2/Makefile.am 2004-02-15 11:20:57.748017320 +0100 |
1140 | @@ -7,7 +7,7 @@ |
1141 | fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \ |
1142 | imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \ |
1143 | nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \ |
1144 | - terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h |
1145 | + terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h |
1146 | EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS) |
1147 | |
1148 | # For <stage1.h>. |
1149 | @@ -19,7 +19,7 @@ |
1150 | disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ |
1151 | fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ |
1152 | fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ |
1153 | - terminfo.c tparm.c |
1154 | + terminfo.c tparm.c graphics.c |
1155 | libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ |
1156 | -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \ |
1157 | -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ |
1158 | @@ -80,8 +80,14 @@ |
1159 | HERCULES_FLAGS = |
1160 | endif |
1161 | |
1162 | +if GRAPHICS_SUPPORT |
1163 | +GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1 |
1164 | +else |
1165 | +GRAPHICS_FLAGS = |
1166 | +endif |
1167 | + |
1168 | STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \ |
1169 | - $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) |
1170 | + $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS) |
1171 | |
1172 | STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 |
1173 | STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 |
1174 | @@ -91,7 +97,8 @@ |
1175 | cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ |
1176 | fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ |
1177 | fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \ |
1178 | - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c |
1179 | + hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \ |
1180 | + graphics.c |
1181 | pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) |
1182 | pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) |
1183 | pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK) |
1184 | diff -Naur grub-0.95-orig/stage2/shared.h grub-0.95/stage2/shared.h |
1185 | --- grub-0.95-orig/stage2/shared.h 2004-01-11 10:39:22.000000000 +0100 |
1186 | +++ grub-0.95/stage2/shared.h 2004-02-15 11:20:57.760015496 +0100 |
1187 | @@ -871,6 +871,7 @@ |
1188 | int grub_tolower (int c); |
1189 | int grub_isspace (int c); |
1190 | int grub_strncat (char *s1, const char *s2, int n); |
1191 | +void grub_memcpy(void *dest, const void *src, int len); |
1192 | void *grub_memmove (void *to, const void *from, int len); |
1193 | void *grub_memset (void *start, int c, int len); |
1194 | int grub_strncat (char *s1, const char *s2, int n); |
1195 | diff -Naur grub-0.95-orig/stage2/shared.h.orig grub-0.95/stage2/shared.h.orig |
1196 | --- grub-0.95-orig/stage2/shared.h.orig 1970-01-01 01:00:00.000000000 +0100 |
1197 | +++ grub-0.95/stage2/shared.h.orig 2004-01-11 10:39:22.000000000 +0100 |
1198 | @@ -0,0 +1,980 @@ |
1199 | +/* shared.h - definitions used in all GRUB-specific code */ |
1200 | +/* |
1201 | + * GRUB -- GRand Unified Bootloader |
1202 | + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
1203 | + * |
1204 | + * This program is free software; you can redistribute it and/or modify |
1205 | + * it under the terms of the GNU General Public License as published by |
1206 | + * the Free Software Foundation; either version 2 of the License, or |
1207 | + * (at your option) any later version. |
1208 | + * |
1209 | + * This program is distributed in the hope that it will be useful, |
1210 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1211 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1212 | + * GNU General Public License for more details. |
1213 | + * |
1214 | + * You should have received a copy of the GNU General Public License |
1215 | + * along with this program; if not, write to the Free Software |
1216 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
1217 | + */ |
1218 | + |
1219 | +/* |
1220 | + * Generic defines to use anywhere |
1221 | + */ |
1222 | + |
1223 | +#ifndef GRUB_SHARED_HEADER |
1224 | +#define GRUB_SHARED_HEADER 1 |
1225 | + |
1226 | +#include <config.h> |
1227 | + |
1228 | +/* Add an underscore to a C symbol in assembler code if needed. */ |
1229 | +#ifdef HAVE_ASM_USCORE |
1230 | +# define EXT_C(sym) _ ## sym |
1231 | +#else |
1232 | +# define EXT_C(sym) sym |
1233 | +#endif |
1234 | + |
1235 | +/* Maybe redirect memory requests through grub_scratch_mem. */ |
1236 | +#ifdef GRUB_UTIL |
1237 | +extern char *grub_scratch_mem; |
1238 | +# define RAW_ADDR(x) ((x) + (int) grub_scratch_mem) |
1239 | +# define RAW_SEG(x) (RAW_ADDR ((x) << 4) >> 4) |
1240 | +#else |
1241 | +# define RAW_ADDR(x) (x) |
1242 | +# define RAW_SEG(x) (x) |
1243 | +#endif |
1244 | + |
1245 | +/* |
1246 | + * Integer sizes |
1247 | + */ |
1248 | + |
1249 | +#define MAXINT 0x7FFFFFFF |
1250 | + |
1251 | +/* Maximum command line size. Before you blindly increase this value, |
1252 | + see the comment in char_io.c (get_cmdline). */ |
1253 | +#define MAX_CMDLINE 1600 |
1254 | +#define NEW_HEAPSIZE 1500 |
1255 | + |
1256 | +/* 512-byte scratch area */ |
1257 | +#define SCRATCHADDR RAW_ADDR (0x77e00) |
1258 | +#define SCRATCHSEG RAW_SEG (0x77e0) |
1259 | + |
1260 | +/* |
1261 | + * This is the location of the raw device buffer. It is 31.5K |
1262 | + * in size. |
1263 | + */ |
1264 | + |
1265 | +#define BUFFERLEN 0x7e00 |
1266 | +#define BUFFERADDR RAW_ADDR (0x70000) |
1267 | +#define BUFFERSEG RAW_SEG (0x7000) |
1268 | + |
1269 | +#define BOOT_PART_TABLE RAW_ADDR (0x07be) |
1270 | + |
1271 | +/* |
1272 | + * BIOS disk defines |
1273 | + */ |
1274 | +#define BIOSDISK_READ 0x0 |
1275 | +#define BIOSDISK_WRITE 0x1 |
1276 | +#define BIOSDISK_ERROR_GEOMETRY 0x100 |
1277 | +#define BIOSDISK_FLAG_LBA_EXTENSION 0x1 |
1278 | + |
1279 | +/* |
1280 | + * This is the filesystem (not raw device) buffer. |
1281 | + * It is 32K in size, do not overrun! |
1282 | + */ |
1283 | + |
1284 | +#define FSYS_BUFLEN 0x8000 |
1285 | +#define FSYS_BUF RAW_ADDR (0x68000) |
1286 | + |
1287 | +/* Command-line buffer for Multiboot kernels and modules. This area |
1288 | + includes the area into which Stage 1.5 and Stage 1 are loaded, but |
1289 | + that's no problem. */ |
1290 | +#define MB_CMDLINE_BUF RAW_ADDR (0x2000) |
1291 | +#define MB_CMDLINE_BUFLEN 0x6000 |
1292 | + |
1293 | +/* The buffer for the password. */ |
1294 | +#define PASSWORD_BUF RAW_ADDR (0x78000) |
1295 | +#define PASSWORD_BUFLEN 0x200 |
1296 | + |
1297 | +/* The buffer for the command-line. */ |
1298 | +#define CMDLINE_BUF (PASSWORD_BUF + PASSWORD_BUFLEN) |
1299 | +#define CMDLINE_BUFLEN MAX_CMDLINE |
1300 | + |
1301 | +/* The kill buffer for the command-line. */ |
1302 | +#define KILL_BUF (CMDLINE_BUF + CMDLINE_BUFLEN) |
1303 | +#define KILL_BUFLEN MAX_CMDLINE |
1304 | + |
1305 | +/* The history buffer for the command-line. */ |
1306 | +#define HISTORY_BUF (KILL_BUF + KILL_BUFLEN) |
1307 | +#define HISTORY_SIZE 5 |
1308 | +#define HISTORY_BUFLEN (MAX_CMDLINE * HISTORY_SIZE) |
1309 | + |
1310 | +/* The buffer for the completion. */ |
1311 | +#define COMPLETION_BUF (HISTORY_BUF + HISTORY_BUFLEN) |
1312 | +#define COMPLETION_BUFLEN MAX_CMDLINE |
1313 | + |
1314 | +/* The buffer for the unique string. */ |
1315 | +#define UNIQUE_BUF (COMPLETION_BUF + COMPLETION_BUFLEN) |
1316 | +#define UNIQUE_BUFLEN MAX_CMDLINE |
1317 | + |
1318 | +/* The buffer for the menu entries. */ |
1319 | +#define MENU_BUF (UNIQUE_BUF + UNIQUE_BUFLEN) |
1320 | +#define MENU_BUFLEN (0x8000 + PASSWORD_BUF - UNIQUE_BUF) |
1321 | + |
1322 | +/* The size of the drive map. */ |
1323 | +#define DRIVE_MAP_SIZE 8 |
1324 | + |
1325 | +/* The size of the key map. */ |
1326 | +#define KEY_MAP_SIZE 128 |
1327 | + |
1328 | +/* The size of the io map. */ |
1329 | +#define IO_MAP_SIZE 128 |
1330 | + |
1331 | +/* |
1332 | + * Linux setup parameters |
1333 | + */ |
1334 | + |
1335 | +#define LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ |
1336 | +#define LINUX_DEFAULT_SETUP_SECTS 4 |
1337 | +#define LINUX_FLAG_CAN_USE_HEAP 0x80 |
1338 | +#define LINUX_INITRD_MAX_ADDRESS 0x38000000 |
1339 | +#define LINUX_MAX_SETUP_SECTS 64 |
1340 | +#define LINUX_BOOT_LOADER_TYPE 0x71 |
1341 | +#define LINUX_HEAP_END_OFFSET (0x9000 - 0x200) |
1342 | + |
1343 | +#define LINUX_BZIMAGE_ADDR RAW_ADDR (0x100000) |
1344 | +#define LINUX_ZIMAGE_ADDR RAW_ADDR (0x10000) |
1345 | +#define LINUX_OLD_REAL_MODE_ADDR RAW_ADDR (0x90000) |
1346 | +#define LINUX_SETUP_STACK 0x9000 |
1347 | + |
1348 | +#define LINUX_FLAG_BIG_KERNEL 0x1 |
1349 | + |
1350 | +/* Linux's video mode selection support. Actually I hate it! */ |
1351 | +#define LINUX_VID_MODE_NORMAL 0xFFFF |
1352 | +#define LINUX_VID_MODE_EXTENDED 0xFFFE |
1353 | +#define LINUX_VID_MODE_ASK 0xFFFD |
1354 | + |
1355 | +#define LINUX_CL_OFFSET 0x9000 |
1356 | +#define LINUX_CL_END_OFFSET 0x90FF |
1357 | +#define LINUX_SETUP_MOVE_SIZE 0x9100 |
1358 | +#define LINUX_CL_MAGIC 0xA33F |
1359 | + |
1360 | +/* |
1361 | + * General disk stuff |
1362 | + */ |
1363 | + |
1364 | +#define SECTOR_SIZE 0x200 |
1365 | +#define SECTOR_BITS 9 |
1366 | +#define BIOS_FLAG_FIXED_DISK 0x80 |
1367 | + |
1368 | +#define BOOTSEC_LOCATION RAW_ADDR (0x7C00) |
1369 | +#define BOOTSEC_SIGNATURE 0xAA55 |
1370 | +#define BOOTSEC_BPB_OFFSET 0x3 |
1371 | +#define BOOTSEC_BPB_LENGTH 0x3B |
1372 | +#define BOOTSEC_BPB_SYSTEM_ID 0x3 |
1373 | +#define BOOTSEC_BPB_HIDDEN_SECTORS 0x1C |
1374 | +#define BOOTSEC_PART_OFFSET 0x1BE |
1375 | +#define BOOTSEC_PART_LENGTH 0x40 |
1376 | +#define BOOTSEC_SIG_OFFSET 0x1FE |
1377 | +#define BOOTSEC_LISTSIZE 8 |
1378 | + |
1379 | +/* Not bad, perhaps. */ |
1380 | +#define NETWORK_DRIVE 0x20 |
1381 | + |
1382 | +/* |
1383 | + * GRUB specific information |
1384 | + * (in LSB order) |
1385 | + */ |
1386 | + |
1387 | +#include <stage1.h> |
1388 | + |
1389 | +#define STAGE2_VER_MAJ_OFFS 0x6 |
1390 | +#define STAGE2_INSTALLPART 0x8 |
1391 | +#define STAGE2_SAVED_ENTRYNO 0xc |
1392 | +#define STAGE2_STAGE2_ID 0x10 |
1393 | +#define STAGE2_FORCE_LBA 0x11 |
1394 | +#define STAGE2_VER_STR_OFFS 0x12 |
1395 | + |
1396 | +/* Stage 2 identifiers */ |
1397 | +#define STAGE2_ID_STAGE2 0 |
1398 | +#define STAGE2_ID_FFS_STAGE1_5 1 |
1399 | +#define STAGE2_ID_E2FS_STAGE1_5 2 |
1400 | +#define STAGE2_ID_FAT_STAGE1_5 3 |
1401 | +#define STAGE2_ID_MINIX_STAGE1_5 4 |
1402 | +#define STAGE2_ID_REISERFS_STAGE1_5 5 |
1403 | +#define STAGE2_ID_VSTAFS_STAGE1_5 6 |
1404 | +#define STAGE2_ID_JFS_STAGE1_5 7 |
1405 | +#define STAGE2_ID_XFS_STAGE1_5 8 |
1406 | + |
1407 | +#ifndef STAGE1_5 |
1408 | +# define STAGE2_ID STAGE2_ID_STAGE2 |
1409 | +#else |
1410 | +# if defined(FSYS_FFS) |
1411 | +# define STAGE2_ID STAGE2_ID_FFS_STAGE1_5 |
1412 | +# elif defined(FSYS_EXT2FS) |
1413 | +# define STAGE2_ID STAGE2_ID_E2FS_STAGE1_5 |
1414 | +# elif defined(FSYS_FAT) |
1415 | +# define STAGE2_ID STAGE2_ID_FAT_STAGE1_5 |
1416 | +# elif defined(FSYS_MINIX) |
1417 | +# define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5 |
1418 | +# elif defined(FSYS_REISERFS) |
1419 | +# define STAGE2_ID STAGE2_ID_REISERFS_STAGE1_5 |
1420 | +# elif defined(FSYS_VSTAFS) |
1421 | +# define STAGE2_ID STAGE2_ID_VSTAFS_STAGE1_5 |
1422 | +# elif defined(FSYS_JFS) |
1423 | +# define STAGE2_ID STAGE2_ID_JFS_STAGE1_5 |
1424 | +# elif defined(FSYS_XFS) |
1425 | +# define STAGE2_ID STAGE2_ID_XFS_STAGE1_5 |
1426 | +# else |
1427 | +# error "unknown Stage 2" |
1428 | +# endif |
1429 | +#endif |
1430 | + |
1431 | +/* |
1432 | + * defines for use when switching between real and protected mode |
1433 | + */ |
1434 | + |
1435 | +#define CR0_PE_ON 0x1 |
1436 | +#define CR0_PE_OFF 0xfffffffe |
1437 | +#define PROT_MODE_CSEG 0x8 |
1438 | +#define PROT_MODE_DSEG 0x10 |
1439 | +#define PSEUDO_RM_CSEG 0x18 |
1440 | +#define PSEUDO_RM_DSEG 0x20 |
1441 | +#define STACKOFF (0x2000 - 0x10) |
1442 | +#define PROTSTACKINIT (FSYS_BUF - 0x10) |
1443 | + |
1444 | + |
1445 | +/* |
1446 | + * Assembly code defines |
1447 | + * |
1448 | + * "EXT_C" is assumed to be defined in the Makefile by the configure |
1449 | + * command. |
1450 | + */ |
1451 | + |
1452 | +#define ENTRY(x) .globl EXT_C(x) ; EXT_C(x): |
1453 | +#define VARIABLE(x) ENTRY(x) |
1454 | + |
1455 | + |
1456 | +#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ |
1457 | +#define K_STATUS 0x64 /* keyboard status */ |
1458 | +#define K_CMD 0x64 /* keybd ctlr command (write-only) */ |
1459 | + |
1460 | +#define K_OBUF_FUL 0x01 /* output buffer full */ |
1461 | +#define K_IBUF_FUL 0x02 /* input buffer full */ |
1462 | + |
1463 | +#define KC_CMD_WIN 0xd0 /* read output port */ |
1464 | +#define KC_CMD_WOUT 0xd1 /* write output port */ |
1465 | +#define KB_OUTPUT_MASK 0xdd /* enable output buffer full interrupt |
1466 | + enable data line |
1467 | + enable clock line */ |
1468 | +#define KB_A20_ENABLE 0x02 |
1469 | + |
1470 | +/* Codes for getchar. */ |
1471 | +#define ASCII_CHAR(x) ((x) & 0xFF) |
1472 | +#if !defined(GRUB_UTIL) || !defined(HAVE_LIBCURSES) |
1473 | +# define KEY_LEFT 0x4B00 |
1474 | +# define KEY_RIGHT 0x4D00 |
1475 | +# define KEY_UP 0x4800 |
1476 | +# define KEY_DOWN 0x5000 |
1477 | +# define KEY_IC 0x5200 /* insert char */ |
1478 | +# define KEY_DC 0x5300 /* delete char */ |
1479 | +# define KEY_BACKSPACE 0x0008 |
1480 | +# define KEY_HOME 0x4700 |
1481 | +# define KEY_END 0x4F00 |
1482 | +# define KEY_NPAGE 0x5100 |
1483 | +# define KEY_PPAGE 0x4900 |
1484 | +# define A_NORMAL 0x7 |
1485 | +# define A_REVERSE 0x70 |
1486 | +#elif defined(HAVE_NCURSES_CURSES_H) |
1487 | +# include <ncurses/curses.h> |
1488 | +#elif defined(HAVE_NCURSES_H) |
1489 | +# include <ncurses.h> |
1490 | +#elif defined(HAVE_CURSES_H) |
1491 | +# include <curses.h> |
1492 | +#endif |
1493 | + |
1494 | +/* In old BSD curses, A_NORMAL and A_REVERSE are not defined, so we |
1495 | + define them here if they are undefined. */ |
1496 | +#ifndef A_NORMAL |
1497 | +# define A_NORMAL 0 |
1498 | +#endif /* ! A_NORMAL */ |
1499 | +#ifndef A_REVERSE |
1500 | +# ifdef A_STANDOUT |
1501 | +# define A_REVERSE A_STANDOUT |
1502 | +# else /* ! A_STANDOUT */ |
1503 | +# define A_REVERSE 0 |
1504 | +# endif /* ! A_STANDOUT */ |
1505 | +#endif /* ! A_REVERSE */ |
1506 | + |
1507 | +/* Define ACS_* ourselves, since the definitions are not consistent among |
1508 | + various curses implementations. */ |
1509 | +#undef ACS_ULCORNER |
1510 | +#undef ACS_URCORNER |
1511 | +#undef ACS_LLCORNER |
1512 | +#undef ACS_LRCORNER |
1513 | +#undef ACS_HLINE |
1514 | +#undef ACS_VLINE |
1515 | +#undef ACS_LARROW |
1516 | +#undef ACS_RARROW |
1517 | +#undef ACS_UARROW |
1518 | +#undef ACS_DARROW |
1519 | + |
1520 | +#define ACS_ULCORNER '+' |
1521 | +#define ACS_URCORNER '+' |
1522 | +#define ACS_LLCORNER '+' |
1523 | +#define ACS_LRCORNER '+' |
1524 | +#define ACS_HLINE '-' |
1525 | +#define ACS_VLINE '|' |
1526 | +#define ACS_LARROW '<' |
1527 | +#define ACS_RARROW '>' |
1528 | +#define ACS_UARROW '^' |
1529 | +#define ACS_DARROW 'v' |
1530 | + |
1531 | +/* Special graphics characters for IBM displays. */ |
1532 | +#define DISP_UL 218 |
1533 | +#define DISP_UR 191 |
1534 | +#define DISP_LL 192 |
1535 | +#define DISP_LR 217 |
1536 | +#define DISP_HORIZ 196 |
1537 | +#define DISP_VERT 179 |
1538 | +#define DISP_LEFT 0x1b |
1539 | +#define DISP_RIGHT 0x1a |
1540 | +#define DISP_UP 0x18 |
1541 | +#define DISP_DOWN 0x19 |
1542 | + |
1543 | +/* Remap some libc-API-compatible function names so that we prevent |
1544 | + circularararity. */ |
1545 | +#ifndef WITHOUT_LIBC_STUBS |
1546 | +#define memmove grub_memmove |
1547 | +#define memcpy grub_memmove /* we don't need a separate memcpy */ |
1548 | +#define memset grub_memset |
1549 | +#define isspace grub_isspace |
1550 | +#define printf grub_printf |
1551 | +#define sprintf grub_sprintf |
1552 | +#undef putchar |
1553 | +#define putchar grub_putchar |
1554 | +#define strncat grub_strncat |
1555 | +#define strstr grub_strstr |
1556 | +#define memcmp grub_memcmp |
1557 | +#define strcmp grub_strcmp |
1558 | +#define tolower grub_tolower |
1559 | +#define strlen grub_strlen |
1560 | +#define strcpy grub_strcpy |
1561 | +#endif /* WITHOUT_LIBC_STUBS */ |
1562 | + |
1563 | + |
1564 | +#ifndef ASM_FILE |
1565 | +/* |
1566 | + * Below this should be ONLY defines and other constructs for C code. |
1567 | + */ |
1568 | + |
1569 | +/* multiboot stuff */ |
1570 | + |
1571 | +#include "mb_header.h" |
1572 | +#include "mb_info.h" |
1573 | + |
1574 | +/* For the Linux/i386 boot protocol version 2.03. */ |
1575 | +struct linux_kernel_header |
1576 | +{ |
1577 | + char code1[0x0020]; |
1578 | + unsigned short cl_magic; /* Magic number 0xA33F */ |
1579 | + unsigned short cl_offset; /* The offset of command line */ |
1580 | + char code2[0x01F1 - 0x0020 - 2 - 2]; |
1581 | + unsigned char setup_sects; /* The size of the setup in sectors */ |
1582 | + unsigned short root_flags; /* If the root is mounted readonly */ |
1583 | + unsigned short syssize; /* obsolete */ |
1584 | + unsigned short swap_dev; /* obsolete */ |
1585 | + unsigned short ram_size; /* obsolete */ |
1586 | + unsigned short vid_mode; /* Video mode control */ |
1587 | + unsigned short root_dev; /* Default root device number */ |
1588 | + unsigned short boot_flag; /* 0xAA55 magic number */ |
1589 | + unsigned short jump; /* Jump instruction */ |
1590 | + unsigned long header; /* Magic signature "HdrS" */ |
1591 | + unsigned short version; /* Boot protocol version supported */ |
1592 | + unsigned long realmode_swtch; /* Boot loader hook */ |
1593 | + unsigned long start_sys; /* Points to kernel version string */ |
1594 | + unsigned char type_of_loader; /* Boot loader identifier */ |
1595 | + unsigned char loadflags; /* Boot protocol option flags */ |
1596 | + unsigned short setup_move_size; /* Move to high memory size */ |
1597 | + unsigned long code32_start; /* Boot loader hook */ |
1598 | + unsigned long ramdisk_image; /* initrd load address */ |
1599 | + unsigned long ramdisk_size; /* initrd size */ |
1600 | + unsigned long bootsect_kludge; /* obsolete */ |
1601 | + unsigned short heap_end_ptr; /* Free memory after setup end */ |
1602 | + unsigned short pad1; /* Unused */ |
1603 | + char *cmd_line_ptr; /* Points to the kernel command line */ |
1604 | + unsigned long initrd_addr_max; /* The highest address of initrd */ |
1605 | +} __attribute__ ((packed)); |
1606 | + |
1607 | +/* Memory map address range descriptor used by GET_MMAP_ENTRY. */ |
1608 | +struct mmar_desc |
1609 | +{ |
1610 | + unsigned long desc_len; /* Size of this descriptor. */ |
1611 | + unsigned long long addr; /* Base address. */ |
1612 | + unsigned long long length; /* Length in bytes. */ |
1613 | + unsigned long type; /* Type of address range. */ |
1614 | +} __attribute__ ((packed)); |
1615 | + |
1616 | +/* VBE controller information. */ |
1617 | +struct vbe_controller |
1618 | +{ |
1619 | + unsigned char signature[4]; |
1620 | + unsigned short version; |
1621 | + unsigned long oem_string; |
1622 | + unsigned long capabilities; |
1623 | + unsigned long video_mode; |
1624 | + unsigned short total_memory; |
1625 | + unsigned short oem_software_rev; |
1626 | + unsigned long oem_vendor_name; |
1627 | + unsigned long oem_product_name; |
1628 | + unsigned long oem_product_rev; |
1629 | + unsigned char reserved[222]; |
1630 | + unsigned char oem_data[256]; |
1631 | +} __attribute__ ((packed)); |
1632 | + |
1633 | +/* VBE mode information. */ |
1634 | +struct vbe_mode |
1635 | +{ |
1636 | + unsigned short mode_attributes; |
1637 | + unsigned char win_a_attributes; |
1638 | + unsigned char win_b_attributes; |
1639 | + unsigned short win_granularity; |
1640 | + unsigned short win_size; |
1641 | + unsigned short win_a_segment; |
1642 | + unsigned short win_b_segment; |
1643 | + unsigned long win_func; |
1644 | + unsigned short bytes_per_scanline; |
1645 | + |
1646 | + /* >=1.2 */ |
1647 | + unsigned short x_resolution; |
1648 | + unsigned short y_resolution; |
1649 | + unsigned char x_char_size; |
1650 | + unsigned char y_char_size; |
1651 | + unsigned char number_of_planes; |
1652 | + unsigned char bits_per_pixel; |
1653 | + unsigned char number_of_banks; |
1654 | + unsigned char memory_model; |
1655 | + unsigned char bank_size; |
1656 | + unsigned char number_of_image_pages; |
1657 | + unsigned char reserved0; |
1658 | + |
1659 | + /* direct color */ |
1660 | + unsigned char red_mask_size; |
1661 | + unsigned char red_field_position; |
1662 | + unsigned char green_mask_size; |
1663 | + unsigned char green_field_position; |
1664 | + unsigned char blue_mask_size; |
1665 | + unsigned char blue_field_position; |
1666 | + unsigned char reserved_mask_size; |
1667 | + unsigned char reserved_field_position; |
1668 | + unsigned char direct_color_mode_info; |
1669 | + |
1670 | + /* >=2.0 */ |
1671 | + unsigned long phys_base; |
1672 | + unsigned long reserved1; |
1673 | + unsigned short reversed2; |
1674 | + |
1675 | + /* >=3.0 */ |
1676 | + unsigned short linear_bytes_per_scanline; |
1677 | + unsigned char banked_number_of_image_pages; |
1678 | + unsigned char linear_number_of_image_pages; |
1679 | + unsigned char linear_red_mask_size; |
1680 | + unsigned char linear_red_field_position; |
1681 | + unsigned char linear_green_mask_size; |
1682 | + unsigned char linear_green_field_position; |
1683 | + unsigned char linear_blue_mask_size; |
1684 | + unsigned char linear_blue_field_position; |
1685 | + unsigned char linear_reserved_mask_size; |
1686 | + unsigned char linear_reserved_field_position; |
1687 | + unsigned long max_pixel_clock; |
1688 | + |
1689 | + unsigned char reserved3[189]; |
1690 | +} __attribute__ ((packed)); |
1691 | + |
1692 | + |
1693 | +#undef NULL |
1694 | +#define NULL ((void *) 0) |
1695 | + |
1696 | +/* Error codes (descriptions are in common.c) */ |
1697 | +typedef enum |
1698 | +{ |
1699 | + ERR_NONE = 0, |
1700 | + ERR_BAD_FILENAME, |
1701 | + ERR_BAD_FILETYPE, |
1702 | + ERR_BAD_GZIP_DATA, |
1703 | + ERR_BAD_GZIP_HEADER, |
1704 | + ERR_BAD_PART_TABLE, |
1705 | + ERR_BAD_VERSION, |
1706 | + ERR_BELOW_1MB, |
1707 | + ERR_BOOT_COMMAND, |
1708 | + ERR_BOOT_FAILURE, |
1709 | + ERR_BOOT_FEATURES, |
1710 | + ERR_DEV_FORMAT, |
1711 | + ERR_DEV_VALUES, |
1712 | + ERR_EXEC_FORMAT, |
1713 | + ERR_FILELENGTH, |
1714 | + ERR_FILE_NOT_FOUND, |
1715 | + ERR_FSYS_CORRUPT, |
1716 | + ERR_FSYS_MOUNT, |
1717 | + ERR_GEOM, |
1718 | + ERR_NEED_LX_KERNEL, |
1719 | + ERR_NEED_MB_KERNEL, |
1720 | + ERR_NO_DISK, |
1721 | + ERR_NO_PART, |
1722 | + ERR_NUMBER_PARSING, |
1723 | + ERR_OUTSIDE_PART, |
1724 | + ERR_READ, |
1725 | + ERR_SYMLINK_LOOP, |
1726 | + ERR_UNRECOGNIZED, |
1727 | + ERR_WONT_FIT, |
1728 | + ERR_WRITE, |
1729 | + ERR_BAD_ARGUMENT, |
1730 | + ERR_UNALIGNED, |
1731 | + ERR_PRIVILEGED, |
1732 | + ERR_DEV_NEED_INIT, |
1733 | + ERR_NO_DISK_SPACE, |
1734 | + ERR_NUMBER_OVERFLOW, |
1735 | + |
1736 | + MAX_ERR_NUM |
1737 | +} grub_error_t; |
1738 | + |
1739 | +extern unsigned long install_partition; |
1740 | +extern unsigned long boot_drive; |
1741 | +extern unsigned long install_second_sector; |
1742 | +extern struct apm_info apm_bios_info; |
1743 | +extern unsigned long boot_part_addr; |
1744 | +extern int saved_entryno; |
1745 | +extern unsigned char force_lba; |
1746 | +extern char version_string[]; |
1747 | +extern char config_file[]; |
1748 | +extern unsigned long linux_text_len; |
1749 | +extern char *linux_data_tmp_addr; |
1750 | +extern char *linux_data_real_addr; |
1751 | + |
1752 | +#ifdef GRUB_UTIL |
1753 | +/* If not using config file, this variable is set to zero, |
1754 | + otherwise non-zero. */ |
1755 | +extern int use_config_file; |
1756 | +/* If using the preset menu, this variable is set to non-zero, |
1757 | + otherwise zero. */ |
1758 | +extern int use_preset_menu; |
1759 | +/* If not using curses, this variable is set to zero, otherwise non-zero. */ |
1760 | +extern int use_curses; |
1761 | +/* The flag for verbose messages. */ |
1762 | +extern int verbose; |
1763 | +/* The flag for read-only. */ |
1764 | +extern int read_only; |
1765 | +/* The number of floppies to be probed. */ |
1766 | +extern int floppy_disks; |
1767 | +/* The map between BIOS drives and UNIX device file names. */ |
1768 | +extern char **device_map; |
1769 | +/* The filename which stores the information about a device map. */ |
1770 | +extern char *device_map_file; |
1771 | +/* The array of geometries. */ |
1772 | +extern struct geometry *disks; |
1773 | +/* Assign DRIVE to a device name DEVICE. */ |
1774 | +extern void assign_device_name (int drive, const char *device); |
1775 | +#endif |
1776 | + |
1777 | +#ifndef STAGE1_5 |
1778 | +/* GUI interface variables. */ |
1779 | +extern int fallback_entry; |
1780 | +extern int default_entry; |
1781 | +extern int current_entryno; |
1782 | + |
1783 | +/* The constants for password types. */ |
1784 | +typedef enum |
1785 | +{ |
1786 | + PASSWORD_PLAIN, |
1787 | + PASSWORD_MD5, |
1788 | + PASSWORD_UNSUPPORTED |
1789 | +} |
1790 | +password_t; |
1791 | + |
1792 | +extern char *password; |
1793 | +extern password_t password_type; |
1794 | +extern int auth; |
1795 | +extern char commands[]; |
1796 | + |
1797 | +/* For `more'-like feature. */ |
1798 | +extern int max_lines; |
1799 | +extern int count_lines; |
1800 | +extern int use_pager; |
1801 | +#endif |
1802 | + |
1803 | +#ifndef NO_DECOMPRESSION |
1804 | +extern int no_decompression; |
1805 | +extern int compressed_file; |
1806 | +#endif |
1807 | + |
1808 | +/* instrumentation variables */ |
1809 | +extern void (*disk_read_hook) (int, int, int); |
1810 | +extern void (*disk_read_func) (int, int, int); |
1811 | + |
1812 | +#ifndef STAGE1_5 |
1813 | +/* The flag for debug mode. */ |
1814 | +extern int debug; |
1815 | +#endif /* STAGE1_5 */ |
1816 | + |
1817 | +extern unsigned long current_drive; |
1818 | +extern unsigned long current_partition; |
1819 | + |
1820 | +extern int fsys_type; |
1821 | + |
1822 | +/* The information for a disk geometry. The CHS information is only for |
1823 | + DOS/Partition table compatibility, and the real number of sectors is |
1824 | + stored in TOTAL_SECTORS. */ |
1825 | +struct geometry |
1826 | +{ |
1827 | + /* The number of cylinders */ |
1828 | + unsigned long cylinders; |
1829 | + /* The number of heads */ |
1830 | + unsigned long heads; |
1831 | + /* The number of sectors */ |
1832 | + unsigned long sectors; |
1833 | + /* The total number of sectors */ |
1834 | + unsigned long total_sectors; |
1835 | + /* Flags */ |
1836 | + unsigned long flags; |
1837 | +}; |
1838 | + |
1839 | +extern unsigned long part_start; |
1840 | +extern unsigned long part_length; |
1841 | + |
1842 | +extern int current_slice; |
1843 | + |
1844 | +extern int buf_drive; |
1845 | +extern int buf_track; |
1846 | +extern struct geometry buf_geom; |
1847 | + |
1848 | +/* these are the current file position and maximum file position */ |
1849 | +extern int filepos; |
1850 | +extern int filemax; |
1851 | + |
1852 | +/* |
1853 | + * Common BIOS/boot data. |
1854 | + */ |
1855 | + |
1856 | +extern struct multiboot_info mbi; |
1857 | +extern unsigned long saved_drive; |
1858 | +extern unsigned long saved_partition; |
1859 | +#ifndef STAGE1_5 |
1860 | +extern unsigned long saved_mem_upper; |
1861 | +extern unsigned long extended_memory; |
1862 | +#endif |
1863 | + |
1864 | +/* |
1865 | + * Error variables. |
1866 | + */ |
1867 | + |
1868 | +extern grub_error_t errnum; |
1869 | +extern char *err_list[]; |
1870 | + |
1871 | +/* Simplify declaration of entry_addr. */ |
1872 | +typedef void (*entry_func) (int, int, int, int, int, int) |
1873 | + __attribute__ ((noreturn)); |
1874 | + |
1875 | +extern entry_func entry_addr; |
1876 | + |
1877 | +/* Enter the stage1.5/stage2 C code after the stack is set up. */ |
1878 | +void cmain (void); |
1879 | + |
1880 | +/* Halt the processor (called after an unrecoverable error). */ |
1881 | +void stop (void) __attribute__ ((noreturn)); |
1882 | + |
1883 | +/* Reboot the system. */ |
1884 | +void grub_reboot (void) __attribute__ ((noreturn)); |
1885 | + |
1886 | +/* Halt the system, using APM if possible. If NO_APM is true, don't use |
1887 | + APM even if it is available. */ |
1888 | +void grub_halt (int no_apm) __attribute__ ((noreturn)); |
1889 | + |
1890 | +/* Copy MAP to the drive map and set up int13_handler. */ |
1891 | +void set_int13_handler (unsigned short *map); |
1892 | + |
1893 | +/* Set up int15_handler. */ |
1894 | +void set_int15_handler (void); |
1895 | + |
1896 | +/* Restore the original int15 handler. */ |
1897 | +void unset_int15_handler (void); |
1898 | + |
1899 | +/* Track the int13 handler to probe I/O address space. */ |
1900 | +void track_int13 (int drive); |
1901 | + |
1902 | +/* The key map. */ |
1903 | +extern unsigned short bios_key_map[]; |
1904 | +extern unsigned short ascii_key_map[]; |
1905 | +extern unsigned short io_map[]; |
1906 | + |
1907 | +/* calls for direct boot-loader chaining */ |
1908 | +void chain_stage1 (unsigned long segment, unsigned long offset, |
1909 | + unsigned long part_table_addr) |
1910 | + __attribute__ ((noreturn)); |
1911 | +void chain_stage2 (unsigned long segment, unsigned long offset, |
1912 | + int second_sector) |
1913 | + __attribute__ ((noreturn)); |
1914 | + |
1915 | +/* do some funky stuff, then boot linux */ |
1916 | +void linux_boot (void) __attribute__ ((noreturn)); |
1917 | + |
1918 | +/* do some funky stuff, then boot bzImage linux */ |
1919 | +void big_linux_boot (void) __attribute__ ((noreturn)); |
1920 | + |
1921 | +/* booting a multiboot executable */ |
1922 | +void multi_boot (int start, int mb_info) __attribute__ ((noreturn)); |
1923 | + |
1924 | +/* If LINEAR is nonzero, then set the Intel processor to linear mode. |
1925 | + Otherwise, bit 20 of all memory accesses is always forced to zero, |
1926 | + causing a wraparound effect for bugwards compatibility with the |
1927 | + 8086 CPU. */ |
1928 | +void gateA20 (int linear); |
1929 | + |
1930 | +/* memory probe routines */ |
1931 | +int get_memsize (int type); |
1932 | +int get_eisamemsize (void); |
1933 | + |
1934 | +/* Fetch the next entry in the memory map and return the continuation |
1935 | + value. DESC is a pointer to the descriptor buffer, and CONT is the |
1936 | + previous continuation value (0 to get the first entry in the |
1937 | + map). */ |
1938 | +int get_mmap_entry (struct mmar_desc *desc, int cont); |
1939 | + |
1940 | +/* Get the linear address of a ROM configuration table. Return zero, |
1941 | + if fails. */ |
1942 | +unsigned long get_rom_config_table (void); |
1943 | + |
1944 | +/* Get APM BIOS information. */ |
1945 | +void get_apm_info (void); |
1946 | + |
1947 | +/* Get VBE controller information. */ |
1948 | +int get_vbe_controller_info (struct vbe_controller *controller); |
1949 | + |
1950 | +/* Get VBE mode information. */ |
1951 | +int get_vbe_mode_info (int mode_number, struct vbe_mode *mode); |
1952 | + |
1953 | +/* Set VBE mode. */ |
1954 | +int set_vbe_mode (int mode_number); |
1955 | + |
1956 | +/* Return the data area immediately following our code. */ |
1957 | +int get_code_end (void); |
1958 | + |
1959 | +/* low-level timing info */ |
1960 | +int getrtsecs (void); |
1961 | +int currticks (void); |
1962 | + |
1963 | +/* Clear the screen. */ |
1964 | +void cls (void); |
1965 | + |
1966 | +/* Turn on/off cursor. */ |
1967 | +int setcursor (int on); |
1968 | + |
1969 | +/* Get the current cursor position (where 0,0 is the top left hand |
1970 | + corner of the screen). Returns packed values, (RET >> 8) is x, |
1971 | + (RET & 0xff) is y. */ |
1972 | +int getxy (void); |
1973 | + |
1974 | +/* Set the cursor position. */ |
1975 | +void gotoxy (int x, int y); |
1976 | + |
1977 | +/* Displays an ASCII character. IBM displays will translate some |
1978 | + characters to special graphical ones (see the DISP_* constants). */ |
1979 | +void grub_putchar (int c); |
1980 | + |
1981 | +/* Wait for a keypress, and return its packed BIOS/ASCII key code. |
1982 | + Use ASCII_CHAR(ret) to extract the ASCII code. */ |
1983 | +int getkey (void); |
1984 | + |
1985 | +/* Like GETKEY, but doesn't block, and returns -1 if no keystroke is |
1986 | + available. */ |
1987 | +int checkkey (void); |
1988 | + |
1989 | +/* Low-level disk I/O */ |
1990 | +int get_diskinfo (int drive, struct geometry *geometry); |
1991 | +int biosdisk (int subfunc, int drive, struct geometry *geometry, |
1992 | + int sector, int nsec, int segment); |
1993 | +void stop_floppy (void); |
1994 | + |
1995 | +/* Command-line interface functions. */ |
1996 | +#ifndef STAGE1_5 |
1997 | + |
1998 | +/* The flags for the builtins. */ |
1999 | +#define BUILTIN_CMDLINE 0x1 /* Run in the command-line. */ |
2000 | +#define BUILTIN_MENU 0x2 /* Run in the menu. */ |
2001 | +#define BUILTIN_TITLE 0x4 /* Only for the command title. */ |
2002 | +#define BUILTIN_SCRIPT 0x8 /* Run in the script. */ |
2003 | +#define BUILTIN_NO_ECHO 0x10 /* Don't print command on booting. */ |
2004 | +#define BUILTIN_HELP_LIST 0x20 /* Show help in listing. */ |
2005 | + |
2006 | +/* The table for a builtin. */ |
2007 | +struct builtin |
2008 | +{ |
2009 | + /* The command name. */ |
2010 | + char *name; |
2011 | + /* The callback function. */ |
2012 | + int (*func) (char *, int); |
2013 | + /* The combination of the flags defined above. */ |
2014 | + int flags; |
2015 | + /* The short version of the documentation. */ |
2016 | + char *short_doc; |
2017 | + /* The long version of the documentation. */ |
2018 | + char *long_doc; |
2019 | +}; |
2020 | + |
2021 | +/* All the builtins are registered in this. */ |
2022 | +extern struct builtin *builtin_table[]; |
2023 | + |
2024 | +/* The constants for kernel types. */ |
2025 | +typedef enum |
2026 | +{ |
2027 | + KERNEL_TYPE_NONE, /* None is loaded. */ |
2028 | + KERNEL_TYPE_MULTIBOOT, /* Multiboot. */ |
2029 | + KERNEL_TYPE_LINUX, /* Linux. */ |
2030 | + KERNEL_TYPE_BIG_LINUX, /* Big Linux. */ |
2031 | + KERNEL_TYPE_FREEBSD, /* FreeBSD. */ |
2032 | + KERNEL_TYPE_NETBSD, /* NetBSD. */ |
2033 | + KERNEL_TYPE_CHAINLOADER /* Chainloader. */ |
2034 | +} |
2035 | +kernel_t; |
2036 | + |
2037 | +extern kernel_t kernel_type; |
2038 | +extern int show_menu; |
2039 | +extern int grub_timeout; |
2040 | + |
2041 | +void init_builtins (void); |
2042 | +void init_config (void); |
2043 | +char *skip_to (int after_equal, char *cmdline); |
2044 | +struct builtin *find_command (char *command); |
2045 | +void print_cmdline_message (int forever); |
2046 | +void enter_cmdline (char *heap, int forever); |
2047 | +int run_script (char *script, char *heap); |
2048 | +#endif |
2049 | + |
2050 | +/* C library replacement functions with identical semantics. */ |
2051 | +void grub_printf (const char *format,...); |
2052 | +int grub_sprintf (char *buffer, const char *format, ...); |
2053 | +int grub_tolower (int c); |
2054 | +int grub_isspace (int c); |
2055 | +int grub_strncat (char *s1, const char *s2, int n); |
2056 | +void *grub_memmove (void *to, const void *from, int len); |
2057 | +void *grub_memset (void *start, int c, int len); |
2058 | +int grub_strncat (char *s1, const char *s2, int n); |
2059 | +char *grub_strstr (const char *s1, const char *s2); |
2060 | +int grub_memcmp (const char *s1, const char *s2, int n); |
2061 | +int grub_strcmp (const char *s1, const char *s2); |
2062 | +int grub_strlen (const char *str); |
2063 | +char *grub_strcpy (char *dest, const char *src); |
2064 | + |
2065 | +#ifndef GRUB_UTIL |
2066 | +typedef unsigned long grub_jmp_buf[6]; |
2067 | +#else |
2068 | +/* In the grub shell, use the libc jmp_buf instead. */ |
2069 | +# include <setjmp.h> |
2070 | +# define grub_jmp_buf jmp_buf |
2071 | +#endif |
2072 | + |
2073 | +#ifdef GRUB_UTIL |
2074 | +# define grub_setjmp setjmp |
2075 | +# define grub_longjmp longjmp |
2076 | +#else /* ! GRUB_UTIL */ |
2077 | +int grub_setjmp (grub_jmp_buf env); |
2078 | +void grub_longjmp (grub_jmp_buf env, int val); |
2079 | +#endif /* ! GRUB_UTIL */ |
2080 | + |
2081 | +/* The environment for restarting Stage 2. */ |
2082 | +extern grub_jmp_buf restart_env; |
2083 | +/* The environment for restarting the command-line interface. */ |
2084 | +extern grub_jmp_buf restart_cmdline_env; |
2085 | + |
2086 | +/* misc */ |
2087 | +void init_page (void); |
2088 | +void print_error (void); |
2089 | +char *convert_to_ascii (char *buf, int c, ...); |
2090 | +int get_cmdline (char *prompt, char *cmdline, int maxlen, |
2091 | + int echo_char, int history); |
2092 | +int substring (const char *s1, const char *s2); |
2093 | +int nul_terminate (char *str); |
2094 | +int get_based_digit (int c, int base); |
2095 | +int safe_parse_maxint (char **str_ptr, int *myint_ptr); |
2096 | +int memcheck (int start, int len); |
2097 | +void grub_putstr (const char *str); |
2098 | + |
2099 | +#ifndef NO_DECOMPRESSION |
2100 | +/* Compression support. */ |
2101 | +int gunzip_test_header (void); |
2102 | +int gunzip_read (char *buf, int len); |
2103 | +#endif /* NO_DECOMPRESSION */ |
2104 | + |
2105 | +int rawread (int drive, int sector, int byte_offset, int byte_len, char *buf); |
2106 | +int devread (int sector, int byte_offset, int byte_len, char *buf); |
2107 | +int rawwrite (int drive, int sector, char *buf); |
2108 | +int devwrite (int sector, int sector_len, char *buf); |
2109 | + |
2110 | +/* Parse a device string and initialize the global parameters. */ |
2111 | +char *set_device (char *device); |
2112 | +int open_device (void); |
2113 | +int real_open_partition (int flags); |
2114 | +int open_partition (void); |
2115 | +int next_partition (unsigned long drive, unsigned long dest, |
2116 | + unsigned long *partition, int *type, |
2117 | + unsigned long *start, unsigned long *len, |
2118 | + unsigned long *offset, int *entry, |
2119 | + unsigned long *ext_offset, char *buf); |
2120 | + |
2121 | +/* Sets device to the one represented by the SAVED_* parameters. */ |
2122 | +int make_saved_active (void); |
2123 | + |
2124 | +/* Set or clear the current root partition's hidden flag. */ |
2125 | +int set_partition_hidden_flag (int hidden); |
2126 | + |
2127 | +/* Open a file or directory on the active device, using GRUB's |
2128 | + internal filesystem support. */ |
2129 | +int grub_open (char *filename); |
2130 | + |
2131 | +/* Read LEN bytes into BUF from the file that was opened with |
2132 | + GRUB_OPEN. If LEN is -1, read all the remaining data in the file. */ |
2133 | +int grub_read (char *buf, int len); |
2134 | + |
2135 | +/* Reposition a file offset. */ |
2136 | +int grub_seek (int offset); |
2137 | + |
2138 | +/* Close a file. */ |
2139 | +void grub_close (void); |
2140 | + |
2141 | +/* List the contents of the directory that was opened with GRUB_OPEN, |
2142 | + printing all completions. */ |
2143 | +int dir (char *dirname); |
2144 | + |
2145 | +int set_bootdev (int hdbias); |
2146 | + |
2147 | +/* Display statistics on the current active device. */ |
2148 | +void print_fsys_type (void); |
2149 | + |
2150 | +/* Display device and filename completions. */ |
2151 | +void print_a_completion (char *filename); |
2152 | +int print_completions (int is_filename, int is_completion); |
2153 | + |
2154 | +/* Copies the current partition data to the desired address. */ |
2155 | +void copy_current_part_entry (char *buf); |
2156 | + |
2157 | +#ifndef STAGE1_5 |
2158 | +void bsd_boot (kernel_t type, int bootdev, char *arg) |
2159 | + __attribute__ ((noreturn)); |
2160 | + |
2161 | +/* Define flags for load_image here. */ |
2162 | +/* Don't pass a Linux's mem option automatically. */ |
2163 | +#define KERNEL_LOAD_NO_MEM_OPTION (1 << 0) |
2164 | + |
2165 | +kernel_t load_image (char *kernel, char *arg, kernel_t suggested_type, |
2166 | + unsigned long load_flags); |
2167 | + |
2168 | +int load_module (char *module, char *arg); |
2169 | +int load_initrd (char *initrd); |
2170 | + |
2171 | +int check_password(char *entered, char* expected, password_t type); |
2172 | +#endif |
2173 | + |
2174 | +void init_bios_info (void); |
2175 | + |
2176 | +#endif /* ASM_FILE */ |
2177 | + |
2178 | +#endif /* ! GRUB_SHARED_HEADER */ |
2179 | diff -Naur grub-0.95-orig/stage2/stage2.c grub-0.95/stage2/stage2.c |
2180 | --- grub-0.95-orig/stage2/stage2.c 2003-07-09 13:45:53.000000000 +0200 |
2181 | +++ grub-0.95/stage2/stage2.c 2004-02-15 11:20:57.763015040 +0100 |
2182 | @@ -233,6 +233,7 @@ |
2183 | { |
2184 | int c, time1, time2 = -1, first_entry = 0; |
2185 | char *cur_entry = 0; |
2186 | + struct term_entry *prev_term = NULL; |
2187 | |
2188 | /* |
2189 | * Main loop for menu UI. |
2190 | @@ -714,6 +715,15 @@ |
2191 | |
2192 | cls (); |
2193 | setcursor (1); |
2194 | + /* if our terminal needed initialization, we should shut it down |
2195 | + * before booting the kernel, but we want to save what it was so |
2196 | + * we can come back if needed */ |
2197 | + prev_term = current_term; |
2198 | + if (current_term->shutdown) |
2199 | + { |
2200 | + (*current_term->shutdown)(); |
2201 | + current_term = term_table; /* assumption: console is first */ |
2202 | + } |
2203 | |
2204 | while (1) |
2205 | { |
2206 | @@ -748,6 +758,13 @@ |
2207 | break; |
2208 | } |
2209 | |
2210 | + /* if we get back here, we should go back to what our term was before */ |
2211 | + current_term = prev_term; |
2212 | + if (current_term->startup) |
2213 | + /* if our terminal fails to initialize, fall back to console since |
2214 | + * it should always work */ |
2215 | + if ((*current_term->startup)() == 0) |
2216 | + current_term = term_table; /* we know that console is first */ |
2217 | show_menu = 1; |
2218 | goto restart; |
2219 | } |
2220 | @@ -1049,6 +1066,10 @@ |
2221 | while (is_preset); |
2222 | } |
2223 | |
2224 | + /* go ahead and make sure the terminal is setup */ |
2225 | + if (current_term->startup) |
2226 | + (*current_term->startup)(); |
2227 | + |
2228 | if (! num_entries) |
2229 | { |
2230 | /* If no acceptable config file, goto command-line, starting |
2231 | diff -Naur grub-0.95-orig/stage2/term.h grub-0.95/stage2/term.h |
2232 | --- grub-0.95-orig/stage2/term.h 2003-07-09 13:45:53.000000000 +0200 |
2233 | +++ grub-0.95/stage2/term.h 2004-02-15 11:20:57.765014736 +0100 |
2234 | @@ -60,6 +60,8 @@ |
2235 | const char *name; |
2236 | /* The feature flags defined above. */ |
2237 | unsigned long flags; |
2238 | + /* Default for maximum number of lines if not specified */ |
2239 | + unsigned short max_lines; |
2240 | /* Put a character. */ |
2241 | void (*putchar) (int c); |
2242 | /* Check if any input character is available. */ |
2243 | @@ -79,6 +81,11 @@ |
2244 | void (*setcolor) (int normal_color, int highlight_color); |
2245 | /* Turn on/off the cursor. */ |
2246 | int (*setcursor) (int on); |
2247 | + |
2248 | + /* function to start a terminal */ |
2249 | + int (*startup) (void); |
2250 | + /* function to use to shutdown a terminal */ |
2251 | + void (*shutdown) (void); |
2252 | }; |
2253 | |
2254 | /* This lists up available terminals. */ |
2255 | @@ -124,4 +131,23 @@ |
2256 | int hercules_setcursor (int on); |
2257 | #endif |
2258 | |
2259 | +#ifdef SUPPORT_GRAPHICS |
2260 | +extern int foreground, background, border, graphics_inited; |
2261 | + |
2262 | +void graphics_set_splash(char *splashfile); |
2263 | +int set_videomode (int mode); |
2264 | +void graphics_putchar (int c); |
2265 | +int graphics_getxy(void); |
2266 | +void graphics_gotoxy(int x, int y); |
2267 | +void graphics_cls(void); |
2268 | +void graphics_setcolorstate (color_state state); |
2269 | +void graphics_setcolor (int normal_color, int highlight_color); |
2270 | +void graphics_setcursor (int on); |
2271 | +int graphics_init(void); |
2272 | +void graphics_end(void); |
2273 | + |
2274 | +int hex(int v); |
2275 | +void graphics_set_palette(int idx, int red, int green, int blue); |
2276 | +#endif /* SUPPORT_GRAPHICS */ |
2277 | + |
2278 | #endif /* ! GRUB_TERM_HEADER */ |