1
diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
2
--- grub-0.97.orig/configure.ac 2005-05-07 23:36:03.000000000 -0300
3
+++ grub-0.97/configure.ac 2005-06-12 20:56:49.000000000 -0300
5
[ --enable-diskless enable diskless support])
6
AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
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)
14
AC_ARG_ENABLE(hercules,
15
[ --disable-hercules disable hercules terminal support])
16
diff -Naur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S
17
--- grub-0.97.orig/stage2/asm.S 2004-06-19 13:55:22.000000000 -0300
18
+++ grub-0.97/stage2/asm.S 2005-06-13 14:05:31.000000000 -0300
19
@@ -2216,7 +2216,304 @@
26
+/* graphics mode functions */
27
+#ifdef SUPPORT_GRAPHICS
32
+VARIABLE(cursorCount)
35
+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
39
+ * set_int1c_handler(void)
41
+ENTRY(set_int1c_handler)
44
+ /* save the original int1c handler */
47
+ movw %ax, ABS(int1c_offset)
49
+ movw %ax, ABS(int1c_segment)
51
+ /* save the new int1c handler */
52
+ movw $ABS(int1c_handler), %ax
62
+ * unset_int1c_handler(void)
64
+ENTRY(unset_int1c_handler)
67
+ /* check if int1c_handler is set */
69
+ movw $ABS(int1c_handler), %ax
76
+ /* restore the original */
77
+ movw ABS(int1c_offset), %ax
79
+ movw ABS(int1c_segment), %ax
88
+ * blinks graphics cursor
95
+ mov $0xA000, %ax /* video in es:di */
98
+ movw $ABS(cursorY), %si
101
+ movw $ABS(cursorX), %si
103
+ shr $3, %bx /* %bx /= 8 */
107
+ movw $ABS(cursorBuf), %si /* fontBuf in ds:si */
109
+ /* prepare for data moving */
110
+ mov $16, %dx /* altura da fonte */
111
+ mov $80, %bx /* bytes por linha */
114
+ movb %ds:(%si), %al
116
+ movb %al, %ds:(%si) /* invert cursorBuf */
117
+ movb %al, %es:(%di) /* write to video */
128
+ mov $ABS(cursorCount), %si
142
+ /* call previous int1c handler */
145
+int1c_offset: .word 0
146
+int1c_segment: .word 0
151
+ * unsigned char set_videomode(unsigned char mode)
152
+ * BIOS call "INT 10H Function 0h" to set video mode
153
+ * Call with %ah = 0x0
155
+ * Returns old videomode.
157
+ENTRY(set_videomode)
165
+ call EXT_C(prot_to_real)
170
+ int $0x10 /* Get Current Video mode */
174
+ int $0x10 /* Set Video mode */
176
+ DATA32 call EXT_C(real_to_prot)
189
+ * int get_videomode()
190
+ * BIOS call "INT 10H Function 0Fh" to get current video mode
191
+ * Call with %al = 0x0
193
+ * Returns current videomode.
195
+ENTRY(get_videomode)
201
+ call EXT_C(prot_to_real)
206
+ int $0x10 /* Get Current Video mode */
207
+ movb %al, %cl /* For now we only want display mode */
209
+ DATA32 call EXT_C(real_to_prot)
222
+ * unsigned char * graphics_get_font()
223
+ * BIOS call "INT 10H Function 11h" to set font
224
+ * Call with %ah = 0x11
226
+ENTRY(graphics_get_font)
232
+ call EXT_C(prot_to_real)
236
+ movb $6, %bh /* font 8x16 */
241
+ DATA32 call EXT_C(real_to_prot)
257
+ * graphics_set_palette(index, red, green, blue)
258
+ * BIOS call "INT 10H Function 10h" to set individual dac register
259
+ * Call with %ah = 0x10
260
+ * %bx = register number
261
+ * %ch = new value for green (0-63)
262
+ * %cl = new value for blue (0-63)
263
+ * %dh = new value for red (0-63)
266
+ENTRY(graphics_set_palette)
273
+ movw $0x3c8, %bx /* address write mode register */
275
+ /* wait vertical retrace */
278
+ inb %dx, %al /* wait vertical active display */
283
+ inb %dx, %al /* wait vertical retrace */
288
+ movb 0x18(%esp), %al /* index */
292
+ movb 0x1c(%esp), %al /* red */
295
+ movb 0x20(%esp), %al /* green */
298
+ movb 0x24(%esp), %al /* blue */
301
+ movw 0x18(%esp), %bx
303
+ call EXT_C(prot_to_real)
310
+ DATA32 call EXT_C(real_to_prot)
319
+#endif /* SUPPORT_GRAPHICS */
324
* if a seconds value can be read, read it and return it (BCD),
325
diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c
326
--- grub-0.97.orig/stage2/builtins.c 2005-02-15 19:58:23.000000000 -0200
327
+++ grub-0.97/stage2/builtins.c 2005-06-13 18:44:03.000000000 -0300
332
+#ifdef SUPPORT_GRAPHICS
333
+# include <graphics.h>
336
#ifdef SUPPORT_NETBOOT
338
# include <etherboot.h>
339
@@ -237,12 +241,22 @@
341
boot_func (char *arg, int flags)
343
+ struct term_entry *prev_term = current_term;
344
/* Clear the int15 handler if we can boot the kernel successfully.
345
This assumes that the boot code never fails only if KERNEL_TYPE is
346
not KERNEL_TYPE_NONE. Is this assumption is bad? */
347
if (kernel_type != KERNEL_TYPE_NONE)
348
unset_int15_handler ();
350
+ /* if our terminal needed initialization, we should shut it down
351
+ * before booting the kernel, but we want to save what it was so
352
+ * we can come back if needed */
353
+ if (current_term->shutdown)
355
+ current_term->shutdown();
356
+ current_term = term_table; /* assumption: console is first */
359
#ifdef SUPPORT_NETBOOT
360
/* Shut down the networking. */
366
+ /* if we get back here, we should go back to what our term was before */
367
+ current_term = prev_term;
368
+ if (current_term->startup)
369
+ /* if our terminal fails to initialize, fall back to console since
370
+ * it should always work */
371
+ if (current_term->startup() == 0)
372
+ current_term = term_table; /* we know that console is first */
376
@@ -852,6 +873,251 @@
378
#endif /* SUPPORT_NETBOOT */
380
+#ifdef SUPPORT_GRAPHICS
382
+static int splashimage_func(char *arg, int flags) {
385
+ /* filename can only be 256 characters due to our buffer size */
386
+ if (grub_strlen(arg) > 256) {
387
+ grub_printf("Splash image filename too large\n");
388
+ grub_printf("Press any key to continue...");
393
+ /* get rid of TERM_NEED_INIT from the graphics terminal. */
394
+ for (i = 0; term_table[i].name; i++) {
395
+ if (grub_strcmp (term_table[i].name, "graphics") == 0) {
396
+ term_table[i].flags &= ~TERM_NEED_INIT;
401
+ graphics_set_splash(arg);
403
+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
405
+ if (graphics_init() == 0) {
406
+ /* Fallback to default term */
407
+ current_term = term_table;
408
+ max_lines = current_term->max_lines;
409
+ if (current_term->cls)
410
+ current_term->cls();
411
+ grub_printf("Failed to set splash image and/or graphics mode\n");
417
+ if (flags == BUILTIN_MENU)
418
+ current_term = term_table + i;
423
+static struct builtin builtin_splashimage =
427
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
428
+ "splashimage FILE",
429
+ "Load FILE as the background image when in graphics mode."
435
+shade_func(char *arg, int flags)
439
+ if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
442
+ if (shade != new_shade) {
444
+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
454
+static struct builtin builtin_shade =
458
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
460
+ "If set to 0, disables the use of shaded text, else enables it."
466
+foreground_func(char *arg, int flags)
468
+ if (grub_strlen(arg) == 6) {
469
+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
470
+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
471
+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
473
+ foreground = (r << 16) | (g << 8) | b;
474
+ if (graphics_inited)
475
+ graphics_set_palette(15, r, g, b);
483
+static struct builtin builtin_foreground =
487
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
488
+ "foreground RRGGBB",
489
+ "Sets the foreground color when in graphics mode."
490
+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
496
+background_func(char *arg, int flags)
498
+ if (grub_strlen(arg) == 6) {
499
+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
500
+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
501
+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
503
+ background = (r << 16) | (g << 8) | b;
504
+ if (graphics_inited)
505
+ graphics_set_palette(0, r, g, b);
512
+static struct builtin builtin_background =
516
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
517
+ "background RRGGBB",
518
+ "Sets the background color when in graphics mode."
519
+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
525
+border_func(char *arg, int flags)
527
+ if (grub_strlen(arg) == 6) {
528
+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
529
+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
530
+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
532
+ window_border = (r << 16) | (g << 8) | b;
533
+ if (graphics_inited)
534
+ graphics_set_palette(0x11, r, g, b);
542
+static struct builtin builtin_border =
546
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
548
+ "Sets the border video color when in graphics mode."
549
+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
555
+viewport_func (char *arg, int flags)
558
+ int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
559
+ int *pos[4] = { &x0, &y0, &x1, &y1 };
563
+ for (i = 0; i < 4; i++) {
566
+ while (*arg && (*arg == ' ' || *arg == '\t'))
568
+ if (!safe_parse_maxint(&arg, pos[i]))
570
+ while (*arg && (*arg != ' ' && *arg != '\t'))
574
+ /* minimum size is 65 colums and 16 rows */
575
+ if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
583
+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
592
+static struct builtin builtin_viewport =
596
+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
597
+ "viewport x0 y0 x1 y1",
598
+ "Changes grub internals to output text in the window defined by"
599
+ " four parameters. The x and y parameters are 0 based. This option"
600
+ " only works with the graphics interface."
603
+#endif /* SUPPORT_GRAPHICS */
610
+ if (current_term->cls)
611
+ current_term->cls();
616
+static struct builtin builtin_clear =
620
+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
628
@@ -1454,14 +1720,20 @@
632
-#define MAX_SHORT_DOC_LEN 39
633
-#define MAX_LONG_DOC_LEN 66
636
help_func (char *arg, int flags)
640
+ int all = 0, max_short_doc_len, max_long_doc_len;
641
+ max_short_doc_len = 39;
642
+ max_long_doc_len = 66;
643
+#ifdef SUPPORT_GRAPHICS
644
+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
646
+ max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
647
+ max_long_doc_len = (view_x1 - view_x0) - 14;
651
if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
654
@@ -1491,13 +1763,13 @@
656
len = grub_strlen ((*builtin)->short_doc);
657
/* If the length of SHORT_DOC is too long, truncate it. */
658
- if (len > MAX_SHORT_DOC_LEN - 1)
659
- len = MAX_SHORT_DOC_LEN - 1;
660
+ if (len > max_short_doc_len - 1)
661
+ len = max_short_doc_len - 1;
663
for (i = 0; i < len; i++)
664
grub_putchar ((*builtin)->short_doc[i]);
666
- for (; i < MAX_SHORT_DOC_LEN; i++)
667
+ for (; i < max_short_doc_len; i++)
671
@@ -1546,10 +1818,10 @@
674
/* If LEN is too long, fold DOC. */
675
- if (len > MAX_LONG_DOC_LEN)
676
+ if (len > max_long_doc_len)
678
/* Fold this line at the position of a space. */
679
- for (len = MAX_LONG_DOC_LEN; len > 0; len--)
680
+ for (len = max_long_doc_len; len > 0; len--)
681
if (doc[len - 1] == ' ')
684
@@ -4085,7 +4357,7 @@
688
-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
689
+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
692
terminal_func (char *arg, int flags)
693
@@ -4244,17 +4516,29 @@
695
current_term = term_table + default_term;
696
current_term->flags = term_flags;
702
- /* 24 would be a good default value. */
705
+ max_lines = current_term->max_lines;
707
/* If the interface is currently the command-line,
708
restart it to repaint the screen. */
709
- if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
710
+ if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
711
+ if (prev_term->shutdown)
712
+ prev_term->shutdown();
713
+ if (current_term->startup) {
714
+ /* If startup fails, return to previous term */
715
+ if (current_term->startup() == 0) {
716
+ current_term = prev_term;
717
+ max_lines = current_term->max_lines;
718
+ if (current_term->cls) {
719
+ current_term->cls();
723
grub_longjmp (restart_cmdline_env, 0);
728
@@ -4264,7 +4548,7 @@
731
BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
732
- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
733
+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
734
"Select a terminal. When multiple terminals are specified, wait until"
735
" you push any key to continue. If both console and serial are specified,"
736
" the terminal to which you input a key first will be selected. If no"
737
@@ -4276,7 +4560,7 @@
738
" seconds. The option --lines specifies the maximum number of lines."
739
" The option --silent is used to suppress messages."
741
-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
742
+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
745
#ifdef SUPPORT_SERIAL
746
@@ -4795,13 +5079,20 @@
747
/* The table of builtin commands. Sorted in dictionary order. */
748
struct builtin *builtin_table[] =
750
+#ifdef SUPPORT_GRAPHICS
751
+ &builtin_background,
755
#ifdef SUPPORT_NETBOOT
757
#endif /* SUPPORT_NETBOOT */
758
+#ifdef SUPPORT_GRAPHICS
762
&builtin_chainloader,
767
@@ -4821,6 +5112,9 @@
771
+#ifdef SUPPORT_GRAPHICS
772
+ &builtin_foreground,
777
@@ -4864,9 +5158,13 @@
778
#endif /* SUPPORT_SERIAL */
781
-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
782
+#ifdef SUPPORT_GRAPHICS
784
+ &builtin_splashimage,
785
+#endif /* SUPPORT_GRAPHICS */
786
+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
788
-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
789
+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
790
#ifdef SUPPORT_SERIAL
792
#endif /* SUPPORT_SERIAL */
793
@@ -4880,5 +5178,8 @@
797
+#ifdef SUPPORT_GRAPHICS
802
diff -Naur grub-0.97.orig/stage2/char_io.c grub-0.97/stage2/char_io.c
803
--- grub-0.97.orig/stage2/char_io.c 2005-02-01 18:51:23.000000000 -0200
804
+++ grub-0.97/stage2/char_io.c 2005-06-12 20:56:49.000000000 -0300
809
+#ifdef SUPPORT_GRAPHICS
810
+# include <graphics.h>
814
struct term_entry term_table[] =
825
console_setcolorstate,
832
#ifdef SUPPORT_SERIAL
835
/* A serial device must be initialized. */
843
serial_setcolorstate,
849
#endif /* SUPPORT_SERIAL */
860
hercules_setcolorstate,
863
+ hercules_setcursor,
867
#endif /* SUPPORT_HERCULES */
868
+#ifdef SUPPORT_GRAPHICS
870
+ TERM_NEED_INIT, /* flags */
871
+ 30, /* number of lines */
872
+ graphics_putchar, /* putchar */
873
+ console_checkkey, /* checkkey */
874
+ console_getkey, /* getkey */
875
+ graphics_getxy, /* getxy */
876
+ graphics_gotoxy, /* gotoxy */
877
+ graphics_cls, /* cls */
878
+ graphics_setcolorstate, /* setcolorstate */
879
+ graphics_setcolor, /* setcolor */
880
+ graphics_setcursor, /* nocursor */
881
+ graphics_init, /* initialize */
882
+ graphics_end /* shutdown */
884
+#endif /* SUPPORT_GRAPHICS */
885
/* This must be the last entry. */
886
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
887
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
890
/* This must be console. */
893
/* XXX: These should be defined in shared.h, but I leave these here,
894
until this code is freezed. */
895
-#define CMDLINE_WIDTH 78
896
#define CMDLINE_MARGIN 10
899
+ /* command-line limits */
900
+ int cmdline_width = 78, col_start = 0;
901
int xpos, lpos, c, section;
902
/* The length of PROMPT. */
906
/* If the cursor is in the first section, display the first section
907
instead of the second. */
908
- if (section == 1 && plen + lpos < CMDLINE_WIDTH)
909
+ if (section == 1 && plen + lpos < cmdline_width)
911
else if (xpos - count < 1)
917
- gotoxy (xpos, getxy () & 0xFF);
918
+ gotoxy (xpos + col_start, getxy () & 0xFF);
925
/* If the cursor goes outside, scroll the screen to the right. */
926
- if (xpos + count >= CMDLINE_WIDTH)
927
+ if (xpos + count >= cmdline_width)
935
- gotoxy (xpos, getxy () & 0xFF);
936
+ gotoxy (xpos + col_start, getxy () & 0xFF);
940
@@ -398,14 +429,14 @@
943
/* Recompute the section number. */
944
- if (lpos + plen < CMDLINE_WIDTH)
945
+ if (lpos + plen < cmdline_width)
948
- section = ((lpos + plen - CMDLINE_WIDTH)
949
- / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
950
+ section = ((lpos + plen - cmdline_width)
951
+ / (cmdline_width - 1 - CMDLINE_MARGIN) + 1);
953
/* From the start to the end. */
954
- len = CMDLINE_WIDTH;
955
+ len = cmdline_width;
963
- start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
964
- + CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
965
+ start = ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN)
966
+ + cmdline_width - plen - CMDLINE_MARGIN);
967
xpos = lpos + 1 - start;
972
/* If the cursor is at the last position, put `>' or a space,
973
depending on if there are more characters in BUF. */
974
- if (pos == CMDLINE_WIDTH)
975
+ if (pos == cmdline_width)
977
if (start + len < llen)
983
- gotoxy (xpos, getxy () & 0xFF);
984
+ gotoxy (xpos + col_start, getxy () & 0xFF);
987
/* Initialize the command-line. */
988
@@ -518,10 +549,10 @@
992
- if (xpos + l >= CMDLINE_WIDTH)
993
+ if (xpos + l >= cmdline_width)
995
- else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
996
- cl_refresh (0, CMDLINE_WIDTH - xpos);
997
+ else if (xpos + l + llen - lpos > cmdline_width)
998
+ cl_refresh (0, cmdline_width - xpos);
1000
cl_refresh (0, l + llen - lpos);
1002
@@ -533,12 +564,22 @@
1003
grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
1006
- if (xpos + llen + count - lpos > CMDLINE_WIDTH)
1007
- cl_refresh (0, CMDLINE_WIDTH - xpos);
1008
+ if (xpos + llen + count - lpos > cmdline_width)
1009
+ cl_refresh (0, cmdline_width - xpos);
1011
cl_refresh (0, llen + count - lpos);
1014
+ max_lines = current_term->max_lines;
1015
+#ifdef SUPPORT_GRAPHICS
1016
+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
1018
+ cmdline_width = (view_x1 - view_x0) - 2;
1019
+ col_start = view_x0;
1020
+ max_lines = view_y1 - view_y0;
1024
plen = grub_strlen (prompt);
1025
llen = grub_strlen (cmdline);
1027
@@ -1006,6 +1047,48 @@
1029
#endif /* ! STAGE1_5 */
1032
+/* Internal pager. */
1036
+ if (count_lines >= 0)
1039
+ if (count_lines >= max_lines - 2)
1043
+ /* It's important to disable the feature temporarily, because
1044
+ the following grub_printf call will print newlines. */
1047
+ grub_printf("\n");
1048
+ if (current_term->setcolorstate)
1049
+ current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
1051
+ grub_printf ("[Hit return to continue]");
1053
+ if (current_term->setcolorstate)
1054
+ current_term->setcolorstate (COLOR_STATE_NORMAL);
1059
+ tmp = ASCII_CHAR (getkey ());
1061
+ while (tmp != '\n' && tmp != '\r');
1062
+ grub_printf ("\r \r");
1064
+ /* Restart to count lines. */
1073
/* Display an ASCII character. */
1075
grub_putchar (int c)
1076
@@ -1034,38 +1117,11 @@
1081
/* Internal `more'-like feature. */
1082
- if (count_lines >= 0)
1085
- if (count_lines >= max_lines - 2)
1089
- /* It's important to disable the feature temporarily, because
1090
- the following grub_printf call will print newlines. */
1093
- if (current_term->setcolorstate)
1094
- current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
1096
- grub_printf ("\n[Hit return to continue]");
1098
- if (current_term->setcolorstate)
1099
- current_term->setcolorstate (COLOR_STATE_NORMAL);
1103
- tmp = ASCII_CHAR (getkey ());
1105
- while (tmp != '\n' && tmp != '\r');
1106
- grub_printf ("\r \r");
1108
- /* Restart to count lines. */
1113
+ flag = do_more ();
1118
current_term->putchar (c);
1119
@@ -1090,7 +1146,7 @@
1122
/* If the terminal is dumb, there is no way to clean the terminal. */
1123
- if (current_term->flags & TERM_DUMB)
1124
+ if (current_term->flags & TERM_DUMB)
1125
grub_putchar ('\n');
1127
current_term->cls ();
1128
@@ -1217,6 +1273,16 @@
1133
+grub_memcpy(void *dest, const void *src, int len)
1136
+ register char *d = (char*)dest, *s = (char*)src;
1138
+ for (i = 0; i < len; i++)
1143
grub_memmove (void *to, const void *from, int len)
1145
diff -Naur grub-0.97.orig/stage2/cmdline.c grub-0.97/stage2/cmdline.c
1146
--- grub-0.97.orig/stage2/cmdline.c 2004-08-16 20:23:01.000000000 -0300
1147
+++ grub-0.97/stage2/cmdline.c 2005-06-12 20:56:49.000000000 -0300
1150
print_cmdline_message (int forever)
1152
- printf (" [ Minimal BASH-like line editing is supported. For the first word, TAB\n"
1153
- " lists possible command completions. Anywhere else TAB lists the possible\n"
1154
- " completions of a device/filename.%s ]\n",
1155
- (forever ? "" : " ESC at any time exits."));
1156
+ grub_printf(" [ Minimal BASH-like line editing is supported. For\n"
1157
+ " the first word, TAB lists possible command\n"
1158
+ " completions. Anywhere else TAB lists the possible\n"
1159
+ " completions of a device/filename.%s ]\n",
1160
+ (forever ? "" : " ESC at any time\n exits."));
1163
/* Find the builtin whose command name is COMMAND and return the
1164
diff -Naur grub-0.97.orig/stage2/graphics.c grub-0.97/stage2/graphics.c
1165
--- grub-0.97.orig/stage2/graphics.c 1969-12-31 21:00:00.000000000 -0300
1166
+++ grub-0.97/stage2/graphics.c 2005-06-13 19:13:31.000000000 -0300
1169
+ * graphics.c - graphics mode support for GRUB
1170
+ * Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
1171
+ * on a patch by Paulo Cļæ½sar Pereira de Andrade <pcpa@conectiva.com.br>
1172
+ * Options and enhancements made by Herton Ronaldo Krzesinski
1173
+ * <herton@mandriva.com>
1175
+ * GRUB -- GRand Unified Bootloader
1176
+ * Copyright (C) 2001,2002 Red Hat, Inc.
1177
+ * Portions copyright (C) 2000 Conectiva, Inc.
1179
+ * This program is free software; you can redistribute it and/or modify
1180
+ * it under the terms of the GNU General Public License as published by
1181
+ * the Free Software Foundation; either version 2 of the License, or
1182
+ * (at your option) any later version.
1184
+ * This program is distributed in the hope that it will be useful,
1185
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1186
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1187
+ * GNU General Public License for more details.
1189
+ * You should have received a copy of the GNU General Public License
1190
+ * along with this program; if not, write to the Free Software
1191
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1194
+#ifdef SUPPORT_GRAPHICS
1197
+#include <shared.h>
1198
+#include <graphics.h>
1200
+int saved_videomode;
1201
+unsigned char *font8x16;
1203
+int graphics_inited = 0;
1204
+static char splashimage[256];
1206
+int shade = 1, no_cursor = 0;
1208
+#define VSHADOW VSHADOW1
1209
+unsigned char VSHADOW1[38400];
1210
+unsigned char VSHADOW2[38400];
1211
+unsigned char VSHADOW4[38400];
1212
+unsigned char VSHADOW8[38400];
1214
+/* define the default viewable area */
1220
+/* text buffer has to be kept around so that we can write things as we
1221
+ * scroll and the like */
1222
+unsigned short text[80 * 30];
1224
+/* graphics options */
1225
+int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
1227
+/* current position */
1228
+static int fontx = 0;
1229
+static int fonty = 0;
1231
+/* global state so that we don't try to recursively scroll or cursor */
1232
+static int no_scroll = 0;
1235
+static int graphics_standard_color = A_NORMAL;
1236
+static int graphics_normal_color = A_NORMAL;
1237
+static int graphics_highlight_color = A_REVERSE;
1238
+static int graphics_current_color = A_NORMAL;
1239
+static color_state graphics_color_state = COLOR_STATE_STANDARD;
1241
+static inline void outb(unsigned short port, unsigned char val)
1243
+ __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
1246
+static void MapMask(int value) {
1248
+ outb(0x3c5, value);
1251
+/* bit mask register */
1252
+static void BitMask(int value) {
1254
+ outb(0x3cf, value);
1257
+/* move the graphics cursor location to col, row */
1258
+static void graphics_setxy(int col, int row) {
1259
+ if (col >= view_x0 && col < view_x1) {
1261
+ cursorX = col << 3;
1263
+ if (row >= view_y0 && row < view_y1) {
1265
+ cursorY = row << 4;
1269
+/* scroll the screen */
1270
+static void graphics_scroll() {
1273
+ /* we don't want to scroll recursively... that would be bad */
1278
+ /* disable pager temporarily */
1282
+ /* move everything up a line */
1283
+ for (j = view_y0 + 1; j < view_y1; j++) {
1284
+ graphics_gotoxy(view_x0, j - 1);
1285
+ for (i = view_x0; i < view_x1; i++) {
1286
+ graphics_putchar(text[j * 80 + i]);
1290
+ /* last line should be blank */
1291
+ graphics_gotoxy(view_x0, view_y1 - 1);
1292
+ for (i = view_x0; i < view_x1; i++)
1293
+ graphics_putchar(' ');
1294
+ graphics_setxy(view_x0, view_y1 - 1);
1301
+/* Set the splash image */
1302
+void graphics_set_splash(char *splashfile) {
1303
+ grub_strcpy(splashimage, splashfile);
1306
+/* Get the current splash image */
1307
+char *graphics_get_splash(void) {
1308
+ return splashimage;
1312
+ * Initialize a vga16 graphics display with the palette based off of
1313
+ * the image in splashimage. If the image doesn't exist, leave graphics
1314
+ * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List":
1315
+ * text/ text pixel pixel colors disply scrn system
1316
+ * grph resol box resolution pages addr
1317
+ * 12h G 80x30 8x16 640x480 16/256K . A000 VGA,ATI VIP
1318
+ * G 80x30 8x16 640x480 16/64 . A000 ATI EGA Wonder
1319
+ * G . . 640x480 16 . . UltraVision+256K EGA
1321
+int graphics_init()
1323
+ if (!graphics_inited) {
1324
+ saved_videomode = set_videomode(0x12);
1325
+ if (get_videomode() != 0x12) {
1326
+ set_videomode(saved_videomode);
1329
+ graphics_inited = 1;
1334
+ font8x16 = (unsigned char*)graphics_get_font();
1336
+ /* make sure that the highlight color is set correctly */
1337
+ graphics_highlight_color = ((graphics_normal_color >> 4) |
1338
+ ((graphics_normal_color & 0xf) << 4));
1342
+ if (!read_image(splashimage)) {
1343
+ grub_printf("Failed to read splash image (%s)\n", splashimage);
1344
+ grub_printf("Press any key to continue...");
1346
+ set_videomode(saved_videomode);
1347
+ graphics_inited = 0;
1351
+ set_int1c_handler();
1356
+/* Leave graphics mode */
1357
+void graphics_end(void)
1359
+ if (graphics_inited) {
1360
+ unset_int1c_handler();
1361
+ set_videomode(saved_videomode);
1362
+ graphics_inited = 0;
1367
+/* Print ch on the screen. Handle any needed scrolling or the like */
1368
+void graphics_putchar(int ch) {
1371
+ graphics_cursor(0);
1374
+ if (fonty + 1 < view_y1)
1375
+ graphics_setxy(fontx, fonty + 1);
1377
+ graphics_scroll();
1378
+ graphics_cursor(1);
1380
+ } else if (ch == '\r') {
1381
+ graphics_setxy(view_x0, fonty);
1382
+ graphics_cursor(1);
1386
+ graphics_cursor(0);
1388
+ text[fonty * 80 + fontx] = ch;
1389
+ text[fonty * 80 + fontx] &= 0x00ff;
1390
+ if (graphics_current_color & 0xf0)
1391
+ text[fonty * 80 + fontx] |= 0x100;
1393
+ graphics_cursor(0);
1395
+ if ((fontx + 1) >= view_x1) {
1396
+ graphics_setxy(view_x0, fonty);
1397
+ if (fonty + 1 < view_y1)
1398
+ graphics_setxy(view_x0, fonty + 1);
1400
+ graphics_scroll();
1401
+ graphics_cursor(1);
1403
+ graphics_cursor(0);
1405
+ graphics_setxy(fontx + 1, fonty);
1408
+ graphics_cursor(1);
1411
+/* get the current location of the cursor */
1412
+int graphics_getxy(void) {
1413
+ return (fontx << 8) | fonty;
1416
+void graphics_gotoxy(int x, int y) {
1417
+ graphics_cursor(0);
1419
+ graphics_setxy(x, y);
1421
+ graphics_cursor(1);
1424
+void graphics_cls(void) {
1426
+ unsigned char *mem, *s1, *s2, *s4, *s8;
1428
+ graphics_cursor(0);
1429
+ graphics_gotoxy(view_x0, view_y0);
1431
+ mem = (unsigned char*)VIDEOMEM;
1432
+ s1 = (unsigned char*)VSHADOW1;
1433
+ s2 = (unsigned char*)VSHADOW2;
1434
+ s4 = (unsigned char*)VSHADOW4;
1435
+ s8 = (unsigned char*)VSHADOW8;
1437
+ for (i = 0; i < 80 * 30; i++)
1439
+ graphics_cursor(1);
1445
+ grub_memcpy(mem, s1, 38400);
1449
+ grub_memcpy(mem, s2, 38400);
1453
+ grub_memcpy(mem, s4, 38400);
1457
+ grub_memcpy(mem, s8, 38400);
1463
+ set_int1c_handler();
1467
+void graphics_setcolorstate (color_state state) {
1469
+ case COLOR_STATE_STANDARD:
1470
+ graphics_current_color = graphics_standard_color;
1472
+ case COLOR_STATE_NORMAL:
1473
+ graphics_current_color = graphics_normal_color;
1475
+ case COLOR_STATE_HIGHLIGHT:
1476
+ graphics_current_color = graphics_highlight_color;
1479
+ graphics_current_color = graphics_standard_color;
1483
+ graphics_color_state = state;
1486
+void graphics_setcolor (int normal_color, int highlight_color) {
1487
+ graphics_normal_color = normal_color;
1488
+ graphics_highlight_color = highlight_color;
1490
+ graphics_setcolorstate (graphics_color_state);
1493
+int graphics_setcursor (int on) {
1494
+ if (!no_cursor && !on) {
1496
+ unset_int1c_handler();
1497
+ graphics_cursor(0);
1499
+ else if(no_cursor && on) {
1501
+ set_int1c_handler();
1502
+ graphics_cursor(1);
1507
+/* Read in the splashscreen image and set the palette up appropriately.
1508
+ * Format of splashscreen is an xpm (can be gzipped) with 16 colors and
1510
+int read_image(char *s)
1512
+ char buf[32], pal[16], c;
1513
+ unsigned char base, mask, *s1, *s2, *s4, *s8;
1514
+ unsigned i, len, idx, colors, x, y, width, height;
1516
+ if (!grub_open(s))
1520
+ if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
1526
+ while (grub_read(&c, 1)) {
1531
+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
1536
+ while (grub_read(&c, 1)) {
1537
+ if (c >= '0' && c <= '9')
1538
+ width = width * 10 + c - '0';
1542
+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
1546
+ while (grub_read(&c, 1)) {
1547
+ if (c >= '0' && c <= '9')
1548
+ height = height * 10 + c - '0';
1552
+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
1556
+ while (grub_read(&c, 1)) {
1557
+ if (c >= '0' && c <= '9')
1558
+ colors = colors * 10 + c - '0';
1564
+ while (grub_read(&c, 1) && c != '"')
1568
+ for (i = 0, idx = 1; i < colors; i++) {
1571
+ while (grub_read(&c, 1) && c != '"')
1573
+ grub_read(&c, 1); /* char */
1575
+ grub_read(buf, 4); /* \t c # */
1577
+ while (grub_read(&c, 1) && c != '"') {
1578
+ if (len < sizeof(buf))
1582
+ if (len == 6 && idx < 15) {
1583
+ int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
1584
+ int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
1585
+ int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
1588
+ graphics_set_palette(idx, r, g, b);
1595
+ s1 = (unsigned char*)VSHADOW1;
1596
+ s2 = (unsigned char*)VSHADOW2;
1597
+ s4 = (unsigned char*)VSHADOW4;
1598
+ s8 = (unsigned char*)VSHADOW8;
1600
+ for (i = 0; i < 38400; i++)
1601
+ s1[i] = s2[i] = s4[i] = s8[i] = 0;
1603
+ /* parse xpm data */
1604
+ while (y < height) {
1606
+ if (!grub_read(&c, 1)) {
1614
+ while (grub_read(&c, 1) && c != '"') {
1615
+ for (i = 1; i < 15; i++)
1616
+ if (pal[i] == c) {
1621
+ mask = 0x80 >> (x & 7);
1623
+ s1[len + (x >> 3)] |= mask;
1625
+ s2[len + (x >> 3)] |= mask;
1627
+ s4[len + (x >> 3)] |= mask;
1629
+ s8[len + (x >> 3)] |= mask;
1643
+ graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
1645
+ graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
1647
+ graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63,
1648
+ window_border & 63);
1653
+/* Convert a character which is a hex digit to the appropriate integer */
1656
+ if (v >= 'A' && v <= 'F')
1657
+ return (v - 'A' + 10);
1658
+ if (v >= 'a' && v <= 'f')
1659
+ return (v - 'a' + 10);
1663
+void graphics_cursor(int set) {
1664
+ unsigned char *pat, *mem, *ptr, chr[16 << 2];
1665
+ int i, ch, invert, offset;
1667
+ if (set && (no_cursor || no_scroll))
1670
+ offset = cursorY * 80 + fontx;
1671
+ ch = text[fonty * 80 + fontx] & 0xff;
1672
+ invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
1673
+ pat = font8x16 + (ch << 4);
1675
+ mem = (unsigned char*)VIDEOMEM + offset;
1678
+ for (i = 0; i < 16; i++) {
1679
+ unsigned char mask = pat[i];
1682
+ chr[i ] = ((unsigned char*)VSHADOW1)[offset];
1683
+ chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
1684
+ chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
1685
+ chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
1688
+ if (ch == DISP_VERT || ch == DISP_LL ||
1689
+ ch == DISP_UR || ch == DISP_LR) {
1690
+ unsigned char pmask = ~(pat[i] >> 1);
1693
+ chr[16 + i] &= pmask;
1694
+ chr[32 + i] &= pmask;
1695
+ chr[48 + i] &= pmask;
1697
+ if (i > 0 && ch != DISP_VERT) {
1698
+ unsigned char pmask = ~(pat[i - 1] >> 1);
1701
+ chr[16 + i] &= pmask;
1702
+ chr[32 + i] &= pmask;
1703
+ chr[48 + i] &= pmask;
1704
+ if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
1705
+ pmask = ~pat[i - 1];
1708
+ chr[16 + i] &= pmask;
1709
+ chr[32 + i] &= pmask;
1710
+ chr[48 + i] &= pmask;
1715
+ chr[16 + i] |= mask;
1716
+ chr[32 + i] |= mask;
1717
+ chr[48 + i] |= mask;
1723
+ chr[16 + i] = mask;
1724
+ chr[32 + i] = mask;
1725
+ chr[48 + i] = mask;
1732
+ for (i = 0; i < 16; i++, ptr += 80) {
1733
+ cursorBuf[i] = pat[i];
1740
+ for (i = 1; i < 16; i <<= 1, offset += 16) {
1745
+ for (j = 0; j < 16; j++, ptr += 80)
1746
+ *ptr = chr[j + offset];
1752
+#endif /* SUPPORT_GRAPHICS */
1753
diff -Naur grub-0.97.orig/stage2/graphics.h grub-0.97/stage2/graphics.h
1754
--- grub-0.97.orig/stage2/graphics.h 1969-12-31 21:00:00.000000000 -0300
1755
+++ grub-0.97/stage2/graphics.h 2005-06-12 20:56:49.000000000 -0300
1757
+/* graphics.h - graphics console interface */
1759
+ * GRUB -- GRand Unified Bootloader
1760
+ * Copyright (C) 2002 Free Software Foundation, Inc.
1762
+ * This program is free software; you can redistribute it and/or modify
1763
+ * it under the terms of the GNU General Public License as published by
1764
+ * the Free Software Foundation; either version 2 of the License, or
1765
+ * (at your option) any later version.
1767
+ * This program is distributed in the hope that it will be useful,
1768
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1769
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1770
+ * GNU General Public License for more details.
1772
+ * You should have received a copy of the GNU General Public License
1773
+ * along with this program; if not, write to the Free Software
1774
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1780
+/* magic constant */
1781
+#define VIDEOMEM 0xA0000
1783
+/* function prototypes */
1784
+char *graphics_get_splash(void);
1786
+int read_image(char *s);
1787
+void graphics_cursor(int set);
1789
+/* function prototypes for asm functions */
1790
+void * graphics_get_font();
1791
+void graphics_set_palette(int idx, int red, int green, int blue);
1792
+void set_int1c_handler();
1793
+void unset_int1c_handler();
1795
+extern short cursorX, cursorY;
1796
+extern char cursorBuf[16];
1798
+extern int view_x0, view_y0, view_x1, view_y1;
1800
+#endif /* GRAPHICS_H */
1801
diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
1802
--- grub-0.97.orig/stage2/Makefile.am 2005-02-02 18:37:35.000000000 -0200
1803
+++ grub-0.97/stage2/Makefile.am 2005-06-12 20:56:49.000000000 -0300
1805
fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
1806
imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
1807
nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
1808
- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
1809
+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
1810
EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
1814
disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
1815
fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
1816
fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
1817
- terminfo.c tparm.c
1818
+ terminfo.c tparm.c graphics.c
1819
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
1820
-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
1821
-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
1826
+if GRAPHICS_SUPPORT
1827
+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
1832
STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
1833
- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
1834
+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
1836
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
1837
STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
1839
cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
1840
fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
1841
fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
1842
- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
1843
+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
1845
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1846
pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
1847
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
1848
diff -Naur grub-0.97.orig/stage2/shared.h grub-0.97/stage2/shared.h
1849
--- grub-0.97.orig/stage2/shared.h 2004-06-19 13:40:09.000000000 -0300
1850
+++ grub-0.97/stage2/shared.h 2005-06-12 20:56:49.000000000 -0300
1851
@@ -792,6 +792,11 @@
1852
/* Set the cursor position. */
1853
void gotoxy (int x, int y);
1856
+ Returns 1 = if pager was used
1857
+ 0 = if pager wasn't used */
1858
+int do_more (void);
1860
/* Displays an ASCII character. IBM displays will translate some
1861
characters to special graphical ones (see the DISP_* constants). */
1862
void grub_putchar (int c);
1864
int grub_tolower (int c);
1865
int grub_isspace (int c);
1866
int grub_strncat (char *s1, const char *s2, int n);
1867
+void grub_memcpy(void *dest, const void *src, int len);
1868
void *grub_memmove (void *to, const void *from, int len);
1869
void *grub_memset (void *start, int c, int len);
1870
int grub_strncat (char *s1, const char *s2, int n);
1871
diff -Naur grub-0.97.orig/stage2/stage2.c grub-0.97/stage2/stage2.c
1872
--- grub-0.97.orig/stage2/stage2.c 2005-03-19 14:51:57.000000000 -0300
1873
+++ grub-0.97/stage2/stage2.c 2005-06-13 22:38:08.000000000 -0300
1878
+#ifdef SUPPORT_GRAPHICS
1879
+# include <graphics.h>
1882
+int col_start, col_end, row_start, box_size;
1884
grub_jmp_buf restart_env;
1886
#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
1887
@@ -105,13 +111,13 @@
1888
if (highlight && current_term->setcolorstate)
1889
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
1892
+ gotoxy (2 + col_start, y);
1894
- for (x = 3; x < 75; x++)
1895
+ for (x = 3 + col_start; x < (col_end - 5); x++)
1897
- if (*entry && x <= 72)
1898
+ if (*entry && x <= (col_end - 8))
1901
+ if (x == (col_end - 8))
1902
grub_putchar (DISP_RIGHT);
1904
grub_putchar (*entry++);
1910
+ gotoxy ((col_end - 6), y);
1912
if (current_term->setcolorstate)
1913
current_term->setcolorstate (COLOR_STATE_STANDARD);
1918
- gotoxy (77, y + 1);
1919
+ gotoxy ((col_end - 3), y + 1);
1922
grub_putchar (DISP_UP);
1923
@@ -151,14 +157,14 @@
1927
- gotoxy (77, y + size);
1928
+ gotoxy ((col_end - 3), y + size);
1931
grub_putchar (DISP_DOWN);
1935
- gotoxy (74, y + entryno + 1);
1936
+ gotoxy ((col_end - 6), y + entryno + 1);
1940
@@ -196,30 +202,30 @@
1941
if (current_term->setcolorstate)
1942
current_term->setcolorstate (COLOR_STATE_NORMAL);
1945
+ gotoxy (1 + col_start, y);
1947
grub_putchar (DISP_UL);
1948
- for (i = 0; i < 73; i++)
1949
+ for (i = col_start; i < (col_end - 7); i++)
1950
grub_putchar (DISP_HORIZ);
1951
grub_putchar (DISP_UR);
1956
- gotoxy (1, y + i);
1957
+ gotoxy (1 + col_start, y + i);
1962
grub_putchar (DISP_VERT);
1963
- gotoxy (75, y + i);
1964
+ gotoxy ((col_end - 5), y + i);
1965
grub_putchar (DISP_VERT);
1970
grub_putchar (DISP_LL);
1971
- for (i = 0; i < 73; i++)
1972
+ for (i = col_start; i < (col_end - 7); i++)
1973
grub_putchar (DISP_HORIZ);
1974
grub_putchar (DISP_LR);
1978
int c, time1, time2 = -1, first_entry = 0;
1979
char *cur_entry = 0;
1980
+ struct term_entry *prev_term = NULL;
1983
* Main loop for menu UI.
1984
@@ -250,6 +257,22 @@
1992
+ /* if we're using viewport we need to make sure to setup
1993
+ coordinates correctly. */
1994
+#ifdef SUPPORT_GRAPHICS
1995
+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
1997
+ col_start = view_x0;
1998
+ col_end = view_x1;
1999
+ row_start = view_y0;
2000
+ box_size = (view_y1 - view_y0) - 13;
2004
/* If the timeout was expired or wasn't set, force to show the menu
2006
if (grub_timeout < 0)
2007
@@ -302,36 +325,36 @@
2008
if (current_term->flags & TERM_DUMB)
2009
print_entries_raw (num_entries, first_entry, menu_entries);
2011
- print_border (3, 12);
2012
+ print_border (3 + row_start, box_size);
2015
- Use the %c and %c keys to select which entry is highlighted.\n",
2016
+ Use the %c and %c keys to select which entry is highlighted.\n",
2017
DISP_UP, DISP_DOWN);
2019
if (! auth && password)
2022
- Press enter to boot the selected OS or \'p\' to enter a\n\
2023
- password to unlock the next set of features.");
2024
+ Press enter to boot the selected OS or \'p\' to enter a\n\
2025
+ password to unlock the next set of features.");
2031
- Press enter to boot the selected OS, \'e\' to edit the\n\
2032
- commands before booting, or \'c\' for a command-line.");
2033
+ Press enter to boot the selected OS, \'e\' to edit the\n\
2034
+ commands before booting, or \'c\' for a command-line.");
2037
- Press \'b\' to boot, \'e\' to edit the selected command in the\n\
2038
- boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
2039
- after (\'O\' for before) the selected line, \'d\' to remove the\n\
2040
- selected line, or escape to go back to the main menu.");
2041
+ Press \'b\' to boot, \'e\' to edit the selected command in the\n\
2042
+ boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
2043
+ after (\'O\' for before) the selected line, \'d\' to remove the\n\
2044
+ selected line, or escape to go back to the main menu.");
2047
if (current_term->flags & TERM_DUMB)
2048
grub_printf ("\n\nThe selected entry is %d ", entryno);
2050
- print_entries (3, 12, first_entry, entryno, menu_entries);
2051
+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
2054
/* XX using RT clock now, need to initialize value */
2055
@@ -358,10 +381,10 @@
2056
entryno, grub_timeout);
2060
- grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",
2061
+ gotoxy (3 + col_start, 10 + box_size + row_start);
2062
+ grub_printf (" The highlighted entry will be booted automatically in %d seconds. ",
2064
- gotoxy (74, 4 + entryno);
2065
+ gotoxy ((col_end - 6), 4 + entryno + row_start);
2069
@@ -387,12 +410,12 @@
2070
if (current_term->flags & TERM_DUMB)
2071
grub_putchar ('\r');
2074
+ gotoxy (3 + col_start, 10 + box_size + row_start);
2077
fallback_entryno = -1;
2078
if (! (current_term->flags & TERM_DUMB))
2079
- gotoxy (74, 4 + entryno);
2080
+ gotoxy ((col_end - 6), 4 + entryno + row_start);
2083
/* We told them above (at least in SUPPORT_SERIAL) to use
2084
@@ -408,12 +431,12 @@
2088
- print_entry (4 + entryno, 0,
2089
+ print_entry (4 + entryno + row_start, 0,
2090
get_entry (menu_entries,
2091
first_entry + entryno,
2094
- print_entry (4 + entryno, 1,
2095
+ print_entry (4 + entryno + row_start, 1,
2096
get_entry (menu_entries,
2097
first_entry + entryno,
2100
else if (first_entry > 0)
2103
- print_entries (3, 12, first_entry, entryno,
2104
+ print_entries (3 + row_start, box_size, first_entry, entryno,
2108
@@ -433,29 +456,29 @@
2113
+ if (entryno < (box_size - 1))
2115
- print_entry (4 + entryno, 0,
2116
+ print_entry (4 + entryno + row_start, 0,
2117
get_entry (menu_entries,
2118
first_entry + entryno,
2121
- print_entry (4 + entryno, 1,
2122
+ print_entry (4 + entryno + row_start, 1,
2123
get_entry (menu_entries,
2124
first_entry + entryno,
2127
- else if (num_entries > 12 + first_entry)
2128
+ else if (num_entries > box_size + first_entry)
2131
- print_entries (3, 12, first_entry, entryno, menu_entries);
2132
+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
2139
- first_entry -= 12;
2140
+ first_entry -= box_size;
2141
if (first_entry < 0)
2143
entryno += first_entry;
2144
@@ -463,20 +486,20 @@
2148
- print_entries (3, 12, first_entry, entryno, menu_entries);
2149
+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
2154
- first_entry += 12;
2155
+ first_entry += box_size;
2156
if (first_entry + entryno + 1 >= num_entries)
2158
- first_entry = num_entries - 12;
2159
+ first_entry = num_entries - box_size;
2160
if (first_entry < 0)
2162
entryno = num_entries - first_entry - 1;
2164
- print_entries (3, 12, first_entry, entryno, menu_entries);
2165
+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
2170
if ((c == 'd') || (c == 'o') || (c == 'O'))
2172
if (! (current_term->flags & TERM_DUMB))
2173
- print_entry (4 + entryno, 0,
2174
+ print_entry (4 + entryno + row_start, 0,
2175
get_entry (menu_entries,
2176
first_entry + entryno,
2180
if (entryno >= num_entries)
2182
- if (first_entry && num_entries < 12 + first_entry)
2183
+ if (first_entry && num_entries < box_size + first_entry)
2191
- print_entries (3, 12, first_entry, entryno, menu_entries);
2192
+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
2195
cur_entry = menu_entries;
2197
if (current_term->flags & TERM_DUMB)
2198
grub_printf ("\r ");
2201
+ gotoxy (1 + col_start, 9 + box_size + row_start);
2203
/* Wipe out the previously entered password */
2204
grub_memset (entered, 0, sizeof (entered));
2205
@@ -714,6 +737,15 @@
2209
+ /* if our terminal needed initialization, we should shut it down
2210
+ * before booting the kernel, but we want to save what it was so
2211
+ * we can come back if needed */
2212
+ prev_term = current_term;
2213
+ if (current_term->shutdown)
2215
+ current_term->shutdown();
2216
+ current_term = term_table; /* assumption: console is first */
2221
@@ -748,6 +780,13 @@
2225
+ /* if we get back here, we should go back to what our term was before */
2226
+ current_term = prev_term;
2227
+ if (current_term->startup)
2228
+ /* if our terminal fails to initialize, fall back to console since
2229
+ * it should always work */
2230
+ if (current_term->startup() == 0)
2231
+ current_term = term_table; /* we know that console is first */
2235
@@ -1050,6 +1089,16 @@
2239
+ /* go ahead and make sure the terminal is setup */
2240
+ if (current_term->startup)
2242
+ /* If initialization fails, go back to default terminal */
2243
+ if (current_term->startup() == 0)
2245
+ current_term = term_table;
2251
/* If no acceptable config file, goto command-line, starting
2252
diff -Naur grub-0.97.orig/stage2/term.h grub-0.97/stage2/term.h
2253
--- grub-0.97.orig/stage2/term.h 2003-07-09 08:45:53.000000000 -0300
2254
+++ grub-0.97/stage2/term.h 2005-06-13 14:07:40.000000000 -0300
2257
/* The feature flags defined above. */
2258
unsigned long flags;
2259
+ /* Default for maximum number of lines if not specified */
2260
+ unsigned short max_lines;
2261
/* Put a character. */
2262
void (*putchar) (int c);
2263
/* Check if any input character is available. */
2265
void (*setcolor) (int normal_color, int highlight_color);
2266
/* Turn on/off the cursor. */
2267
int (*setcursor) (int on);
2268
+ /* function to start a terminal */
2269
+ int (*startup) (void);
2270
+ /* function to use to shutdown a terminal */
2271
+ void (*shutdown) (void);
2274
/* This lists up available terminals. */
2275
@@ -124,4 +130,24 @@
2276
int hercules_setcursor (int on);
2279
+#ifdef SUPPORT_GRAPHICS
2280
+extern int foreground, background, window_border, graphics_inited, saved_videomode;
2282
+void graphics_set_splash(char *splashfile);
2283
+int set_videomode(int mode);
2284
+int get_videomode(void);
2285
+void graphics_putchar (int c);
2286
+int graphics_getxy(void);
2287
+void graphics_gotoxy(int x, int y);
2288
+void graphics_cls(void);
2289
+void graphics_setcolorstate (color_state state);
2290
+void graphics_setcolor (int normal_color, int highlight_color);
2291
+int graphics_setcursor (int on);
2292
+int graphics_init(void);
2293
+void graphics_end(void);
2296
+void graphics_set_palette(int idx, int red, int green, int blue);
2297
+#endif /* SUPPORT_GRAPHICS */
2299
#endif /* ! GRUB_TERM_HEADER */