~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to stubdom/grub.patches/10graphics.diff

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
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.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 @@
 
20
        pop     %ebx
 
21
        pop     %ebp
 
22
        ret
 
23
-               
 
24
+
 
25
+
 
26
+/* graphics mode functions */
 
27
+#ifdef SUPPORT_GRAPHICS
 
28
+VARIABLE(cursorX)
 
29
+.word  0
 
30
+VARIABLE(cursorY)
 
31
+.word  0
 
32
+VARIABLE(cursorCount)
 
33
+.word 0
 
34
+VARIABLE(cursorBuf)
 
35
+.byte  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 
36
+
 
37
+
 
38
+/*
 
39
+ * set_int1c_handler(void)
 
40
+ */
 
41
+ENTRY(set_int1c_handler)
 
42
+       pushl   %edi
 
43
+
 
44
+       /* save the original int1c handler */
 
45
+       movl    $0x70, %edi
 
46
+       movw    (%edi), %ax
 
47
+       movw    %ax, ABS(int1c_offset)
 
48
+       movw    2(%edi), %ax
 
49
+       movw    %ax, ABS(int1c_segment)
 
50
+
 
51
+       /* save the new int1c handler */
 
52
+       movw    $ABS(int1c_handler), %ax
 
53
+       movw    %ax, (%edi)
 
54
+       xorw    %ax, %ax
 
55
+       movw    %ax, 2(%edi)
 
56
+
 
57
+       popl    %edi
 
58
+       ret
 
59
+
 
60
+
 
61
+/*
 
62
+ * unset_int1c_handler(void)
 
63
+ */
 
64
+ENTRY(unset_int1c_handler)
 
65
+       pushl   %edi
 
66
+
 
67
+       /* check if int1c_handler is set */
 
68
+       movl    $0x70, %edi
 
69
+       movw    $ABS(int1c_handler), %ax
 
70
+       cmpw    %ax, (%edi)
 
71
+       jne     int1c_1
 
72
+       xorw    %ax, %ax
 
73
+       cmpw    %ax, 2(%edi)
 
74
+       jne     int1c_1
 
75
+
 
76
+       /* restore the original */
 
77
+       movw    ABS(int1c_offset), %ax
 
78
+       movw    %ax, (%edi)
 
79
+       movw    ABS(int1c_segment), %ax
 
80
+       movw    %ax, 2(%edi)
 
81
+
 
82
+int1c_1:
 
83
+       popl    %edi
 
84
+       ret
 
85
+
 
86
+
 
87
+/*
 
88
+ * blinks graphics cursor
 
89
+ */
 
90
+       .code16
 
91
+write_data:
 
92
+       movw    $0, %ax
 
93
+       movw    %ax, %ds
 
94
+
 
95
+       mov     $0xA000, %ax            /* video in es:di */
 
96
+       mov     %ax, %es
 
97
+       mov     $80, %ax
 
98
+       movw    $ABS(cursorY), %si
 
99
+       mov     %ds:(%si), %bx
 
100
+       mul     %bx
 
101
+       movw    $ABS(cursorX), %si
 
102
+       mov     %ds:(%si), %bx
 
103
+       shr     $3, %bx                 /* %bx /= 8 */
 
104
+       add     %bx, %ax
 
105
+       mov     %ax, %di
 
106
+
 
107
+       movw    $ABS(cursorBuf), %si    /* fontBuf in ds:si */
 
108
+
 
109
+       /* prepare for data moving */
 
110
+       mov     $16, %dx                /* altura da fonte */
 
111
+       mov     $80, %bx                /* bytes por linha */
 
112
+
 
113
+write_loop:
 
114
+       movb    %ds:(%si), %al
 
115
+       xorb    $0xff, %al
 
116
+       movb    %al, %ds:(%si)          /* invert cursorBuf */
 
117
+       movb    %al, %es:(%di)          /* write to video */
 
118
+       add     %bx, %di
 
119
+       inc     %si
 
120
+       dec     %dx
 
121
+       jg      write_loop
 
122
+       ret
 
123
+
 
124
+int1c_handler:
 
125
+       pusha
 
126
+       mov     $0, %ax
 
127
+       mov     %ax, %ds
 
128
+       mov     $ABS(cursorCount), %si
 
129
+       mov     %ds:(%si), %ax
 
130
+       inc     %ax
 
131
+       mov     %ax, %ds:(%si)
 
132
+       cmp     $9, %ax
 
133
+       jne     int1c_done
 
134
+
 
135
+       mov     $0, %ax
 
136
+       mov     %ax, %ds:(%si)
 
137
+       call    write_data
 
138
+
 
139
+int1c_done:
 
140
+       popa
 
141
+       iret
 
142
+       /* call previous int1c handler */
 
143
+       /* ljmp */
 
144
+       .byte   0xea
 
145
+int1c_offset:  .word   0
 
146
+int1c_segment: .word   0
 
147
+       .code32
 
148
+
 
149
+
 
150
+/*
 
151
+ * unsigned char set_videomode(unsigned char mode)
 
152
+ * BIOS call "INT 10H Function 0h" to set video mode
 
153
+ *     Call with       %ah = 0x0
 
154
+ *                     %al = video mode
 
155
+ *  Returns old videomode.
 
156
+ */
 
157
+ENTRY(set_videomode)
 
158
+       pushl   %ebp
 
159
+       movl    %esp,%ebp
 
160
+       pushl   %ebx
 
161
+       pushl   %ecx
 
162
+
 
163
+       movb    8(%ebp), %cl
 
164
+
 
165
+       call    EXT_C(prot_to_real)
 
166
+       .code16
 
167
+
 
168
+       xorb    %al, %al
 
169
+       movb    $0xf, %ah
 
170
+       int     $0x10                   /* Get Current Video mode */
 
171
+       movb    %al, %ch
 
172
+       xorb    %ah, %ah
 
173
+       movb    %cl, %al
 
174
+       int     $0x10                   /* Set Video mode */
 
175
+
 
176
+       DATA32  call    EXT_C(real_to_prot)
 
177
+       .code32
 
178
+
 
179
+       xorl    %eax, %eax
 
180
+       movb    %ch, %al
 
181
+
 
182
+       popl    %ecx
 
183
+       popl    %ebx
 
184
+       popl    %ebp
 
185
+       ret
 
186
+
 
187
+
 
188
+/*
 
189
+ * int get_videomode()
 
190
+ * BIOS call "INT 10H Function 0Fh" to get current video mode
 
191
+ *     Call with       %al = 0x0
 
192
+ *                     %ah = 0xF
 
193
+ *     Returns current videomode.
 
194
+ */
 
195
+ENTRY(get_videomode)
 
196
+       pushl   %ebp
 
197
+       movl    %esp,%ebp
 
198
+       pushl   %ebx
 
199
+       pushl   %ecx
 
200
+
 
201
+       call    EXT_C(prot_to_real)
 
202
+       .code16
 
203
+
 
204
+       xorb    %al, %al
 
205
+       movb    $0xF, %ah
 
206
+       int     $0x10                   /* Get Current Video mode */
 
207
+       movb    %al, %cl        /* For now we only want display mode */
 
208
+
 
209
+       DATA32  call    EXT_C(real_to_prot)
 
210
+       .code32
 
211
+
 
212
+       xorl    %eax, %eax
 
213
+       movb    %cl, %al
 
214
+
 
215
+       popl    %ecx
 
216
+       popl    %ebx
 
217
+       popl    %ebp
 
218
+       ret
 
219
+
 
220
+
 
221
+/*
 
222
+ * unsigned char * graphics_get_font()
 
223
+ * BIOS call "INT 10H Function 11h" to set font
 
224
+ *      Call with       %ah = 0x11
 
225
+ */
 
226
+ENTRY(graphics_get_font)
 
227
+       push    %ebp
 
228
+       push    %ebx
 
229
+       push    %ecx
 
230
+       push    %edx
 
231
+
 
232
+       call    EXT_C(prot_to_real)
 
233
+       .code16
 
234
+
 
235
+       movw    $0x1130, %ax
 
236
+       movb    $6, %bh         /* font 8x16 */
 
237
+       int     $0x10
 
238
+       movw    %bp, %dx
 
239
+       movw    %es, %cx
 
240
+
 
241
+       DATA32  call    EXT_C(real_to_prot)
 
242
+       .code32
 
243
+
 
244
+       xorl    %eax, %eax
 
245
+       movw    %cx, %ax
 
246
+       shll    $4, %eax
 
247
+       movw    %dx, %ax
 
248
+
 
249
+       pop     %edx
 
250
+       pop     %ecx
 
251
+       pop     %ebx
 
252
+       pop     %ebp
 
253
+       ret
 
254
+
 
255
+
 
256
+/*
 
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)
 
264
+ */
 
265
+
 
266
+ENTRY(graphics_set_palette)
 
267
+       push    %ebp
 
268
+       push    %eax
 
269
+       push    %ebx
 
270
+       push    %ecx
 
271
+       push    %edx
 
272
+
 
273
+       movw    $0x3c8, %bx             /* address write mode register */
 
274
+
 
275
+       /* wait vertical retrace */
 
276
+       movw    $0x3da, %dx
 
277
+l1b:
 
278
+       inb     %dx, %al        /* wait vertical active display */
 
279
+       test    $8, %al
 
280
+       jnz     l1b
 
281
+
 
282
+l2b:
 
283
+       inb     %dx, %al        /* wait vertical retrace */
 
284
+       test    $8, %al
 
285
+       jnz     l2b
 
286
+
 
287
+       mov     %bx, %dx
 
288
+       movb    0x18(%esp), %al         /* index */
 
289
+       outb    %al, %dx
 
290
+       inc     %dx
 
291
+
 
292
+       movb    0x1c(%esp), %al         /* red */
 
293
+       outb    %al, %dx
 
294
+
 
295
+       movb    0x20(%esp), %al         /* green */
 
296
+       outb    %al, %dx
 
297
+
 
298
+       movb    0x24(%esp), %al         /* blue */
 
299
+       outb    %al, %dx
 
300
+
 
301
+       movw    0x18(%esp), %bx
 
302
+
 
303
+       call    EXT_C(prot_to_real)
 
304
+       .code16
 
305
+
 
306
+       movb    %bl, %bh
 
307
+       movw    $0x1000, %ax
 
308
+       int     $0x10
 
309
+
 
310
+       DATA32  call    EXT_C(real_to_prot)
 
311
+       .code32
 
312
+
 
313
+       pop     %edx
 
314
+       pop     %ecx
 
315
+       pop     %ebx
 
316
+       pop     %eax
 
317
+       pop     %ebp
 
318
+       ret
 
319
+#endif /* SUPPORT_GRAPHICS */
 
320
+
 
321
+
 
322
 /*
 
323
  * getrtsecs()
 
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
 
328
@@ -28,6 +28,10 @@
 
329
 #include <filesys.h>
 
330
 #include <term.h>
 
331
 
 
332
+#ifdef SUPPORT_GRAPHICS
 
333
+# include <graphics.h>
 
334
+#endif
 
335
+
 
336
 #ifdef SUPPORT_NETBOOT
 
337
 # define GRUB  1
 
338
 # include <etherboot.h>
 
339
@@ -237,12 +241,22 @@
 
340
 static int
 
341
 boot_func (char *arg, int flags)
 
342
 {
 
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 ();
 
349
 
 
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) 
 
354
+    {
 
355
+      current_term->shutdown();
 
356
+      current_term = term_table; /* assumption: console is first */
 
357
+    }
 
358
+
 
359
 #ifdef SUPPORT_NETBOOT
 
360
   /* Shut down the networking.  */
 
361
   cleanup_net ();
 
362
@@ -306,6 +320,13 @@
 
363
       return 1;
 
364
     }
 
365
 
 
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 */
 
373
   return 0;
 
374
 }
 
375
 
 
376
@@ -852,6 +873,251 @@
 
377
 };
 
378
 #endif /* SUPPORT_NETBOOT */
 
379
 
 
380
+#ifdef SUPPORT_GRAPHICS
 
381
+
 
382
+static int splashimage_func(char *arg, int flags) {
 
383
+  int i;
 
384
+    
 
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...");
 
389
+    getkey();
 
390
+    return 1;
 
391
+  }
 
392
+
 
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;
 
397
+      break;
 
398
+    }
 
399
+  }
 
400
+
 
401
+  graphics_set_splash(arg);
 
402
+
 
403
+  if (flags == BUILTIN_CMDLINE && graphics_inited) {
 
404
+    graphics_end();
 
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");
 
412
+      return 1;
 
413
+    }
 
414
+    graphics_cls();
 
415
+  }
 
416
+
 
417
+  if (flags == BUILTIN_MENU)
 
418
+    current_term = term_table + i;
 
419
+
 
420
+  return 0;
 
421
+}
 
422
+
 
423
+static struct builtin builtin_splashimage =
 
424
+{
 
425
+  "splashimage",
 
426
+  splashimage_func,
 
427
+  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
 
428
+  "splashimage FILE",
 
429
+  "Load FILE as the background image when in graphics mode."
 
430
+};
 
431
+
 
432
+
 
433
+/* shade */
 
434
+static int
 
435
+shade_func(char *arg, int flags)
 
436
+{
 
437
+    int new_shade;
 
438
+
 
439
+    if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
 
440
+       return (1);
 
441
+
 
442
+    if (shade != new_shade) {
 
443
+       shade = new_shade;
 
444
+       if (flags == BUILTIN_CMDLINE && graphics_inited) {
 
445
+           graphics_end();
 
446
+           graphics_init();
 
447
+           graphics_cls();
 
448
+       }
 
449
+    }
 
450
+
 
451
+    return 0;
 
452
+}
 
453
+
 
454
+static struct builtin builtin_shade =
 
455
+{
 
456
+  "shade",
 
457
+  shade_func,
 
458
+  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
 
459
+  "shade INTEGER",
 
460
+  "If set to 0, disables the use of shaded text, else enables it."
 
461
+};
 
462
+
 
463
+
 
464
+/* foreground */
 
465
+static int
 
466
+foreground_func(char *arg, int flags)
 
467
+{
 
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;
 
472
+
 
473
+       foreground = (r << 16) | (g << 8) | b;
 
474
+       if (graphics_inited)
 
475
+           graphics_set_palette(15, r, g, b);
 
476
+
 
477
+       return 0;
 
478
+    }
 
479
+
 
480
+    return 1;
 
481
+}
 
482
+
 
483
+static struct builtin builtin_foreground =
 
484
+{
 
485
+  "foreground",
 
486
+  foreground_func,
 
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."
 
491
+};
 
492
+
 
493
+
 
494
+/* background */
 
495
+static int
 
496
+background_func(char *arg, int flags)
 
497
+{
 
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;
 
502
+
 
503
+       background = (r << 16) | (g << 8) | b;
 
504
+       if (graphics_inited)
 
505
+           graphics_set_palette(0, r, g, b);
 
506
+       return 0;
 
507
+    }
 
508
+
 
509
+    return 1;
 
510
+}
 
511
+
 
512
+static struct builtin builtin_background =
 
513
+{
 
514
+  "background",
 
515
+  background_func,
 
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."
 
520
+};
 
521
+
 
522
+
 
523
+/* border */
 
524
+static int
 
525
+border_func(char *arg, int flags)
 
526
+{
 
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;
 
531
+
 
532
+       window_border = (r << 16) | (g << 8) | b;
 
533
+       if (graphics_inited)
 
534
+           graphics_set_palette(0x11, r, g, b);
 
535
+
 
536
+       return 0;
 
537
+    }
 
538
+
 
539
+    return 1;
 
540
+}
 
541
+
 
542
+static struct builtin builtin_border =
 
543
+{
 
544
+  "border",
 
545
+  border_func,
 
546
+  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
 
547
+  "border RRGGBB",
 
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."
 
550
+};
 
551
+
 
552
+
 
553
+/* viewport */
 
554
+static int
 
555
+viewport_func (char *arg, int flags)
 
556
+{
 
557
+    int i;
 
558
+    int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
 
559
+    int *pos[4] = { &x0, &y0, &x1, &y1 };
 
560
+
 
561
+    if (!arg)
 
562
+       return (1);
 
563
+    for (i = 0; i < 4; i++) {
 
564
+       if (!*arg)
 
565
+           return (1);
 
566
+    while (*arg && (*arg == ' ' || *arg == '\t'))
 
567
+           ++arg;
 
568
+       if (!safe_parse_maxint(&arg, pos[i]))
 
569
+           return (1);
 
570
+       while (*arg && (*arg != ' ' && *arg != '\t'))
 
571
+           ++arg;
 
572
+    }
 
573
+
 
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)
 
576
+       return 1;
 
577
+
 
578
+    view_x0 = x0;
 
579
+    view_y0 = y0;
 
580
+    view_x1 = x1;
 
581
+    view_y1 = y1;
 
582
+
 
583
+    if (flags == BUILTIN_CMDLINE && graphics_inited) {
 
584
+       graphics_end();
 
585
+       graphics_init();
 
586
+       graphics_cls();
 
587
+    }
 
588
+
 
589
+    return 0;
 
590
+}
 
591
+
 
592
+static struct builtin builtin_viewport =
 
593
+{
 
594
+  "viewport",
 
595
+  viewport_func,
 
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."
 
601
+};
 
602
+
 
603
+#endif /* SUPPORT_GRAPHICS */
 
604
+
 
605
+
 
606
+/* clear */
 
607
+static int 
 
608
+clear_func() 
 
609
+{
 
610
+  if (current_term->cls)
 
611
+    current_term->cls();
 
612
+
 
613
+  return 0;
 
614
+}
 
615
+
 
616
+static struct builtin builtin_clear =
 
617
+{
 
618
+  "clear",
 
619
+  clear_func,
 
620
+  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
 
621
+  "clear",
 
622
+  "Clear the screen"
 
623
+};
 
624
+
 
625
 
 
626
 /* displayapm */
 
627
 static int
 
628
@@ -1454,14 +1720,20 @@
 
629
 
 
630
 
 
631
 /* help */
 
632
-#define MAX_SHORT_DOC_LEN      39
 
633
-#define MAX_LONG_DOC_LEN       66
 
634
-
 
635
 static int
 
636
 help_func (char *arg, int flags)
 
637
 {
 
638
-  int all = 0;
 
639
-  
 
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)
 
645
+    {
 
646
+      max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
 
647
+      max_long_doc_len = (view_x1 - view_x0) - 14;
 
648
+    }
 
649
+#endif
 
650
+
 
651
   if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
 
652
     {
 
653
       all = 1;
 
654
@@ -1491,13 +1763,13 @@
 
655
 
 
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;
 
662
 
 
663
          for (i = 0; i < len; i++)
 
664
            grub_putchar ((*builtin)->short_doc[i]);
 
665
 
 
666
-         for (; i < MAX_SHORT_DOC_LEN; i++)
 
667
+         for (; i < max_short_doc_len; i++)
 
668
            grub_putchar (' ');
 
669
 
 
670
          if (! left)
 
671
@@ -1546,10 +1818,10 @@
 
672
                      int i;
 
673
 
 
674
                      /* If LEN is too long, fold DOC.  */
 
675
-                     if (len > MAX_LONG_DOC_LEN)
 
676
+                     if (len > max_long_doc_len)
 
677
                        {
 
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] == ' ')
 
682
                              break;
 
683
                        }
 
684
@@ -4085,7 +4357,7 @@
 
685
 };
 
686
 
 
687
 
 
688
-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
 
689
+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
 
690
 /* terminal */
 
691
 static int
 
692
 terminal_func (char *arg, int flags)
 
693
@@ -4244,17 +4516,29 @@
 
694
  end:
 
695
   current_term = term_table + default_term;
 
696
   current_term->flags = term_flags;
 
697
-  
 
698
+
 
699
   if (lines)
 
700
     max_lines = lines;
 
701
   else
 
702
-    /* 24 would be a good default value.  */
 
703
-    max_lines = 24;
 
704
-  
 
705
+    max_lines = current_term->max_lines;
 
706
+
 
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();
 
720
+        }
 
721
+      }
 
722
+    }
 
723
     grub_longjmp (restart_cmdline_env, 0);
 
724
+  }
 
725
   
 
726
   return 0;
 
727
 }
 
728
@@ -4264,7 +4548,7 @@
 
729
   "terminal",
 
730
   terminal_func,
 
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."
 
740
 };
 
741
-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
 
742
+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
 
743
 
 
744
 
 
745
 #ifdef SUPPORT_SERIAL
 
746
@@ -4795,13 +5079,20 @@
 
747
 /* The table of builtin commands. Sorted in dictionary order.  */
 
748
 struct builtin *builtin_table[] =
 
749
 {
 
750
+#ifdef SUPPORT_GRAPHICS
 
751
+  &builtin_background,
 
752
+#endif
 
753
   &builtin_blocklist,
 
754
   &builtin_boot,
 
755
 #ifdef SUPPORT_NETBOOT
 
756
   &builtin_bootp,
 
757
 #endif /* SUPPORT_NETBOOT */
 
758
+#ifdef SUPPORT_GRAPHICS
 
759
+  &builtin_border,
 
760
+#endif
 
761
   &builtin_cat,
 
762
   &builtin_chainloader,
 
763
+  &builtin_clear,
 
764
   &builtin_cmp,
 
765
   &builtin_color,
 
766
   &builtin_configfile,
 
767
@@ -4821,6 +5112,9 @@
 
768
   &builtin_embed,
 
769
   &builtin_fallback,
 
770
   &builtin_find,
 
771
+#ifdef SUPPORT_GRAPHICS
 
772
+  &builtin_foreground,
 
773
+#endif
 
774
   &builtin_fstest,
 
775
   &builtin_geometry,
 
776
   &builtin_halt,
 
777
@@ -4864,9 +5158,13 @@
 
778
 #endif /* SUPPORT_SERIAL */
 
779
   &builtin_setkey,
 
780
   &builtin_setup,
 
781
-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
 
782
+#ifdef SUPPORT_GRAPHICS
 
783
+  &builtin_shade,
 
784
+  &builtin_splashimage,
 
785
+#endif /* SUPPORT_GRAPHICS */
 
786
+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
 
787
   &builtin_terminal,
 
788
-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
 
789
+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
 
790
 #ifdef SUPPORT_SERIAL
 
791
   &builtin_terminfo,
 
792
 #endif /* SUPPORT_SERIAL */
 
793
@@ -4880,5 +5178,8 @@
 
794
   &builtin_unhide,
 
795
   &builtin_uppermem,
 
796
   &builtin_vbeprobe,
 
797
+#ifdef SUPPORT_GRAPHICS
 
798
+  &builtin_viewport,
 
799
+#endif
 
800
   0
 
801
 };
 
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
 
805
@@ -29,12 +29,17 @@
 
806
 # include <serial.h>
 
807
 #endif
 
808
 
 
809
+#ifdef SUPPORT_GRAPHICS
 
810
+# include <graphics.h>
 
811
+#endif
 
812
+
 
813
 #ifndef STAGE1_5
 
814
 struct term_entry term_table[] =
 
815
   {
 
816
     {
 
817
       "console",
 
818
       0,
 
819
+      24,
 
820
       console_putchar,
 
821
       console_checkkey,
 
822
       console_getkey,
 
823
@@ -43,13 +48,16 @@
 
824
       console_cls,
 
825
       console_setcolorstate,
 
826
       console_setcolor,
 
827
-      console_setcursor
 
828
+      console_setcursor,
 
829
+      0, 
 
830
+      0
 
831
     },
 
832
 #ifdef SUPPORT_SERIAL
 
833
     {
 
834
       "serial",
 
835
       /* A serial device must be initialized.  */
 
836
       TERM_NEED_INIT,
 
837
+      24,
 
838
       serial_putchar,
 
839
       serial_checkkey,
 
840
       serial_getkey,
 
841
@@ -58,6 +66,8 @@
 
842
       serial_cls,
 
843
       serial_setcolorstate,
 
844
       0,
 
845
+      0,
 
846
+      0, 
 
847
       0
 
848
     },
 
849
 #endif /* SUPPORT_SERIAL */
 
850
@@ -65,6 +75,7 @@
 
851
     {
 
852
       "hercules",
 
853
       0,
 
854
+      24,
 
855
       hercules_putchar,
 
856
       console_checkkey,
 
857
       console_getkey,
 
858
@@ -73,11 +84,30 @@
 
859
       hercules_cls,
 
860
       hercules_setcolorstate,
 
861
       hercules_setcolor,
 
862
-      hercules_setcursor
 
863
+      hercules_setcursor,
 
864
+      0,
 
865
+      0
 
866
     },      
 
867
 #endif /* SUPPORT_HERCULES */
 
868
+#ifdef SUPPORT_GRAPHICS
 
869
+    { "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 */
 
883
+    },
 
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 }
 
888
   };
 
889
 
 
890
 /* This must be console.  */
 
891
@@ -305,9 +335,10 @@
 
892
 
 
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
 
897
-  
 
898
+
 
899
+  /* command-line limits */
 
900
+  int cmdline_width = 78, col_start = 0;
 
901
   int xpos, lpos, c, section;
 
902
   /* The length of PROMPT.  */
 
903
   int plen;
 
904
@@ -338,7 +369,7 @@
 
905
       
 
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)
 
910
        cl_refresh (1, 0);
 
911
       else if (xpos - count < 1)
 
912
        cl_refresh (1, 0);
 
913
@@ -354,7 +385,7 @@
 
914
                grub_putchar ('\b');
 
915
            }
 
916
          else
 
917
-           gotoxy (xpos, getxy () & 0xFF);
 
918
+           gotoxy (xpos + col_start, getxy () & 0xFF);
 
919
        }
 
920
     }
 
921
 
 
922
@@ -364,7 +395,7 @@
 
923
       lpos += count;
 
924
 
 
925
       /* If the cursor goes outside, scroll the screen to the right.  */
 
926
-      if (xpos + count >= CMDLINE_WIDTH)
 
927
+      if (xpos + count >= cmdline_width)
 
928
        cl_refresh (1, 0);
 
929
       else
 
930
        {
 
931
@@ -383,7 +414,7 @@
 
932
                }
 
933
            }
 
934
          else
 
935
-           gotoxy (xpos, getxy () & 0xFF);
 
936
+           gotoxy (xpos + col_start, getxy () & 0xFF);
 
937
        }
 
938
     }
 
939
 
 
940
@@ -398,14 +429,14 @@
 
941
       if (full)
 
942
        {
 
943
          /* Recompute the section number.  */
 
944
-         if (lpos + plen < CMDLINE_WIDTH)
 
945
+         if (lpos + plen < cmdline_width)
 
946
            section = 0;
 
947
          else
 
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);
 
952
 
 
953
          /* From the start to the end.  */
 
954
-         len = CMDLINE_WIDTH;
 
955
+         len = cmdline_width;
 
956
          pos = 0;
 
957
          grub_putchar ('\r');
 
958
 
 
959
@@ -445,8 +476,8 @@
 
960
          if (! full)
 
961
            offset = xpos - 1;
 
962
          
 
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;
 
968
          start += offset;
 
969
        }
 
970
@@ -471,7 +502,7 @@
 
971
       
 
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)
 
976
        {
 
977
          if (start + len < llen)
 
978
            grub_putchar ('>');
 
979
@@ -488,7 +519,7 @@
 
980
            grub_putchar ('\b');
 
981
        }
 
982
       else
 
983
-       gotoxy (xpos, getxy () & 0xFF);
 
984
+       gotoxy (xpos + col_start, getxy () & 0xFF);
 
985
     }
 
986
 
 
987
   /* Initialize the command-line.  */
 
988
@@ -518,10 +549,10 @@
 
989
          
 
990
          llen += l;
 
991
          lpos += l;
 
992
-         if (xpos + l >= CMDLINE_WIDTH)
 
993
+         if (xpos + l >= cmdline_width)
 
994
            cl_refresh (1, 0);
 
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);
 
999
          else
 
1000
            cl_refresh (0, l + llen - lpos);
 
1001
        }
 
1002
@@ -533,12 +564,22 @@
 
1003
       grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
 
1004
       llen -= count;
 
1005
       
 
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);
 
1010
       else
 
1011
        cl_refresh (0, llen + count - lpos);
 
1012
     }
 
1013
 
 
1014
+  max_lines = current_term->max_lines;
 
1015
+#ifdef SUPPORT_GRAPHICS
 
1016
+  if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
 
1017
+    {
 
1018
+      cmdline_width = (view_x1 - view_x0) - 2;
 
1019
+      col_start = view_x0;
 
1020
+      max_lines = view_y1 - view_y0;
 
1021
+    }
 
1022
+#endif
 
1023
+
 
1024
   plen = grub_strlen (prompt);
 
1025
   llen = grub_strlen (cmdline);
 
1026
 
 
1027
@@ -1006,6 +1047,48 @@
 
1028
 }
 
1029
 #endif /* ! STAGE1_5 */
 
1030
 
 
1031
+#ifndef STAGE1_5
 
1032
+/* Internal pager.  */
 
1033
+int
 
1034
+do_more (void)
 
1035
+{
 
1036
+  if (count_lines >= 0)
 
1037
+    {
 
1038
+      count_lines++;
 
1039
+      if (count_lines >= max_lines - 2)
 
1040
+        {
 
1041
+          int tmp;
 
1042
+
 
1043
+          /* It's important to disable the feature temporarily, because
 
1044
+             the following grub_printf call will print newlines.  */
 
1045
+          count_lines = -1;
 
1046
+
 
1047
+          grub_printf("\n");
 
1048
+          if (current_term->setcolorstate)
 
1049
+            current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
 
1050
+
 
1051
+          grub_printf ("[Hit return to continue]");
 
1052
+
 
1053
+          if (current_term->setcolorstate)
 
1054
+            current_term->setcolorstate (COLOR_STATE_NORMAL);
 
1055
+
 
1056
+
 
1057
+          do
 
1058
+            {
 
1059
+              tmp = ASCII_CHAR (getkey ());
 
1060
+            }
 
1061
+          while (tmp != '\n' && tmp != '\r');
 
1062
+          grub_printf ("\r                        \r");
 
1063
+
 
1064
+          /* Restart to count lines.  */
 
1065
+          count_lines = 0;
 
1066
+          return 1;
 
1067
+        }
 
1068
+    }
 
1069
+  return 0;
 
1070
+}
 
1071
+#endif
 
1072
+
 
1073
 /* Display an ASCII character.  */
 
1074
 void
 
1075
 grub_putchar (int c)
 
1076
@@ -1034,38 +1117,11 @@
 
1077
 
 
1078
   if (c == '\n')
 
1079
     {
 
1080
+      int flag;
 
1081
       /* Internal `more'-like feature.  */
 
1082
-      if (count_lines >= 0)
 
1083
-       {
 
1084
-         count_lines++;
 
1085
-         if (count_lines >= max_lines - 2)
 
1086
-           {
 
1087
-             int tmp;
 
1088
-             
 
1089
-             /* It's important to disable the feature temporarily, because
 
1090
-                the following grub_printf call will print newlines.  */
 
1091
-             count_lines = -1;
 
1092
-
 
1093
-             if (current_term->setcolorstate)
 
1094
-               current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
 
1095
-             
 
1096
-             grub_printf ("\n[Hit return to continue]");
 
1097
-
 
1098
-             if (current_term->setcolorstate)
 
1099
-               current_term->setcolorstate (COLOR_STATE_NORMAL);
 
1100
-             
 
1101
-             do
 
1102
-               {
 
1103
-                 tmp = ASCII_CHAR (getkey ());
 
1104
-               }
 
1105
-             while (tmp != '\n' && tmp != '\r');
 
1106
-             grub_printf ("\r                        \r");
 
1107
-             
 
1108
-             /* Restart to count lines.  */
 
1109
-             count_lines = 0;
 
1110
-             return;
 
1111
-           }
 
1112
-       }
 
1113
+      flag = do_more ();
 
1114
+      if (flag)
 
1115
+        return;
 
1116
     }
 
1117
 
 
1118
   current_term->putchar (c);
 
1119
@@ -1090,7 +1146,7 @@
 
1120
 cls (void)
 
1121
 {
 
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');
 
1126
   else
 
1127
     current_term->cls ();
 
1128
@@ -1217,6 +1273,16 @@
 
1129
   return ! errnum;
 
1130
 }
 
1131
 
 
1132
+void
 
1133
+grub_memcpy(void *dest, const void *src, int len)
 
1134
+{
 
1135
+  int i;
 
1136
+  register char *d = (char*)dest, *s = (char*)src;
 
1137
+
 
1138
+  for (i = 0; i < len; i++)
 
1139
+    d[i] = s[i];
 
1140
+}
 
1141
+
 
1142
 void *
 
1143
 grub_memmove (void *to, const void *from, int len)
 
1144
 {
 
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
 
1148
@@ -50,10 +50,11 @@
 
1149
 void
 
1150
 print_cmdline_message (int forever)
 
1151
 {
 
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."));
 
1161
 }
 
1162
 
 
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
 
1167
@@ -0,0 +1,585 @@
 
1168
+/*
 
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>
 
1174
+ *
 
1175
+ *  GRUB  --  GRand Unified Bootloader
 
1176
+ *  Copyright (C) 2001,2002  Red Hat, Inc.
 
1177
+ *  Portions copyright (C) 2000  Conectiva, Inc.
 
1178
+ *
 
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.
 
1183
+ *
 
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.
 
1188
+ *
 
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.
 
1192
+ */
 
1193
+
 
1194
+#ifdef SUPPORT_GRAPHICS
 
1195
+
 
1196
+#include <term.h>
 
1197
+#include <shared.h>
 
1198
+#include <graphics.h>
 
1199
+
 
1200
+int saved_videomode;
 
1201
+unsigned char *font8x16;
 
1202
+
 
1203
+int graphics_inited = 0;
 
1204
+static char splashimage[256];
 
1205
+
 
1206
+int shade = 1, no_cursor = 0;
 
1207
+
 
1208
+#define VSHADOW VSHADOW1
 
1209
+unsigned char VSHADOW1[38400];
 
1210
+unsigned char VSHADOW2[38400];
 
1211
+unsigned char VSHADOW4[38400];
 
1212
+unsigned char VSHADOW8[38400];
 
1213
+
 
1214
+/* define the default viewable area */
 
1215
+int view_x0 = 0;
 
1216
+int view_y0 = 0;
 
1217
+int view_x1 = 80;
 
1218
+int view_y1 = 30;
 
1219
+
 
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];
 
1223
+
 
1224
+/* graphics options */
 
1225
+int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
 
1226
+
 
1227
+/* current position */
 
1228
+static int fontx = 0;
 
1229
+static int fonty = 0;
 
1230
+
 
1231
+/* global state so that we don't try to recursively scroll or cursor */
 
1232
+static int no_scroll = 0;
 
1233
+
 
1234
+/* color state */
 
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;
 
1240
+
 
1241
+static inline void outb(unsigned short port, unsigned char val)
 
1242
+{
 
1243
+    __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
 
1244
+}
 
1245
+
 
1246
+static void MapMask(int value) {
 
1247
+    outb(0x3c4, 2);
 
1248
+    outb(0x3c5, value);
 
1249
+}
 
1250
+
 
1251
+/* bit mask register */
 
1252
+static void BitMask(int value) {
 
1253
+    outb(0x3ce, 8);
 
1254
+    outb(0x3cf, value);
 
1255
+}
 
1256
+
 
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) {
 
1260
+        fontx = col;
 
1261
+        cursorX = col << 3;
 
1262
+    }
 
1263
+    if (row >= view_y0 && row < view_y1) {
 
1264
+        fonty = row;
 
1265
+        cursorY = row << 4;
 
1266
+    }
 
1267
+}
 
1268
+
 
1269
+/* scroll the screen */
 
1270
+static void graphics_scroll() {
 
1271
+    int i, j, k;
 
1272
+
 
1273
+    /* we don't want to scroll recursively... that would be bad */
 
1274
+    if (no_scroll)
 
1275
+        return;
 
1276
+    no_scroll = 1;
 
1277
+
 
1278
+    /* disable pager temporarily */
 
1279
+    k = count_lines;
 
1280
+    count_lines = -1;
 
1281
+    
 
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]);
 
1287
+        }
 
1288
+    }
 
1289
+
 
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);
 
1295
+
 
1296
+    count_lines = k;
 
1297
+
 
1298
+    no_scroll = 0;
 
1299
+}
 
1300
+
 
1301
+/* Set the splash image */
 
1302
+void graphics_set_splash(char *splashfile) {
 
1303
+    grub_strcpy(splashimage, splashfile);
 
1304
+}
 
1305
+
 
1306
+/* Get the current splash image */
 
1307
+char *graphics_get_splash(void) {
 
1308
+    return splashimage;
 
1309
+}
 
1310
+
 
1311
+/* 
 
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
 
1320
+ */
 
1321
+int graphics_init()
 
1322
+{
 
1323
+    if (!graphics_inited) {
 
1324
+        saved_videomode = set_videomode(0x12);
 
1325
+        if (get_videomode() != 0x12) {
 
1326
+            set_videomode(saved_videomode);
 
1327
+            return 0;
 
1328
+        }
 
1329
+        graphics_inited = 1;
 
1330
+    }
 
1331
+    else
 
1332
+        return 1;
 
1333
+
 
1334
+    font8x16 = (unsigned char*)graphics_get_font();
 
1335
+
 
1336
+    /* make sure that the highlight color is set correctly */
 
1337
+    graphics_highlight_color = ((graphics_normal_color >> 4) | 
 
1338
+                                ((graphics_normal_color & 0xf) << 4));
 
1339
+
 
1340
+    graphics_cls();
 
1341
+
 
1342
+    if (!read_image(splashimage)) {
 
1343
+        grub_printf("Failed to read splash image (%s)\n", splashimage);
 
1344
+        grub_printf("Press any key to continue...");
 
1345
+        getkey();
 
1346
+        set_videomode(saved_videomode);
 
1347
+        graphics_inited = 0;
 
1348
+        return 0;
 
1349
+    }
 
1350
+
 
1351
+    set_int1c_handler();
 
1352
+
 
1353
+    return 1;
 
1354
+}
 
1355
+
 
1356
+/* Leave graphics mode */
 
1357
+void graphics_end(void)
 
1358
+{
 
1359
+    if (graphics_inited) {
 
1360
+        unset_int1c_handler();
 
1361
+        set_videomode(saved_videomode);
 
1362
+        graphics_inited = 0;
 
1363
+        no_cursor = 0;
 
1364
+    }
 
1365
+}
 
1366
+
 
1367
+/* Print ch on the screen.  Handle any needed scrolling or the like */
 
1368
+void graphics_putchar(int ch) {
 
1369
+    ch &= 0xff;
 
1370
+
 
1371
+    graphics_cursor(0);
 
1372
+
 
1373
+    if (ch == '\n') {
 
1374
+        if (fonty + 1 < view_y1)
 
1375
+            graphics_setxy(fontx, fonty + 1);
 
1376
+        else
 
1377
+            graphics_scroll();
 
1378
+        graphics_cursor(1);
 
1379
+        return;
 
1380
+    } else if (ch == '\r') {
 
1381
+        graphics_setxy(view_x0, fonty);
 
1382
+        graphics_cursor(1);
 
1383
+        return;
 
1384
+    }
 
1385
+
 
1386
+    graphics_cursor(0);
 
1387
+
 
1388
+    text[fonty * 80 + fontx] = ch;
 
1389
+    text[fonty * 80 + fontx] &= 0x00ff;
 
1390
+    if (graphics_current_color & 0xf0)
 
1391
+        text[fonty * 80 + fontx] |= 0x100;
 
1392
+
 
1393
+    graphics_cursor(0);
 
1394
+
 
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);
 
1399
+        else
 
1400
+            graphics_scroll();
 
1401
+        graphics_cursor(1);
 
1402
+        do_more ();
 
1403
+        graphics_cursor(0);
 
1404
+    } else {
 
1405
+        graphics_setxy(fontx + 1, fonty);
 
1406
+    }
 
1407
+
 
1408
+    graphics_cursor(1);
 
1409
+}
 
1410
+
 
1411
+/* get the current location of the cursor */
 
1412
+int graphics_getxy(void) {
 
1413
+    return (fontx << 8) | fonty;
 
1414
+}
 
1415
+
 
1416
+void graphics_gotoxy(int x, int y) {
 
1417
+    graphics_cursor(0);
 
1418
+
 
1419
+    graphics_setxy(x, y);
 
1420
+
 
1421
+    graphics_cursor(1);
 
1422
+}
 
1423
+
 
1424
+void graphics_cls(void) {
 
1425
+    int i;
 
1426
+    unsigned char *mem, *s1, *s2, *s4, *s8;
 
1427
+
 
1428
+    graphics_cursor(0);
 
1429
+    graphics_gotoxy(view_x0, view_y0);
 
1430
+
 
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;
 
1436
+
 
1437
+    for (i = 0; i < 80 * 30; i++)
 
1438
+        text[i] = ' ';
 
1439
+    graphics_cursor(1);
 
1440
+
 
1441
+    BitMask(0xff);
 
1442
+
 
1443
+    /* plane 1 */
 
1444
+    MapMask(1);
 
1445
+    grub_memcpy(mem, s1, 38400);
 
1446
+
 
1447
+    /* plane 2 */
 
1448
+    MapMask(2);
 
1449
+    grub_memcpy(mem, s2, 38400);
 
1450
+
 
1451
+    /* plane 3 */
 
1452
+    MapMask(4);
 
1453
+    grub_memcpy(mem, s4, 38400);
 
1454
+
 
1455
+    /* plane 4 */
 
1456
+    MapMask(8);
 
1457
+    grub_memcpy(mem, s8, 38400);
 
1458
+
 
1459
+    MapMask(15);
 
1460
+
 
1461
+    if (no_cursor) {
 
1462
+        no_cursor = 0;
 
1463
+        set_int1c_handler();
 
1464
+    }
 
1465
+}
 
1466
+
 
1467
+void graphics_setcolorstate (color_state state) {
 
1468
+    switch (state) {
 
1469
+    case COLOR_STATE_STANDARD:
 
1470
+        graphics_current_color = graphics_standard_color;
 
1471
+        break;
 
1472
+    case COLOR_STATE_NORMAL:
 
1473
+        graphics_current_color = graphics_normal_color;
 
1474
+        break;
 
1475
+    case COLOR_STATE_HIGHLIGHT:
 
1476
+        graphics_current_color = graphics_highlight_color;
 
1477
+        break;
 
1478
+    default:
 
1479
+        graphics_current_color = graphics_standard_color;
 
1480
+        break;
 
1481
+    }
 
1482
+
 
1483
+    graphics_color_state = state;
 
1484
+}
 
1485
+
 
1486
+void graphics_setcolor (int normal_color, int highlight_color) {
 
1487
+    graphics_normal_color = normal_color;
 
1488
+    graphics_highlight_color = highlight_color;
 
1489
+
 
1490
+    graphics_setcolorstate (graphics_color_state);
 
1491
+}
 
1492
+
 
1493
+int graphics_setcursor (int on) {
 
1494
+    if (!no_cursor && !on) {
 
1495
+        no_cursor = 1;
 
1496
+        unset_int1c_handler();
 
1497
+        graphics_cursor(0);
 
1498
+    }
 
1499
+    else if(no_cursor && on) {
 
1500
+        no_cursor = 0;
 
1501
+        set_int1c_handler();
 
1502
+        graphics_cursor(1);
 
1503
+    }
 
1504
+    return 0;
 
1505
+}
 
1506
+
 
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
 
1509
+ * 640x480. */
 
1510
+int read_image(char *s)
 
1511
+{
 
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;
 
1515
+
 
1516
+    if (!grub_open(s))
 
1517
+        return 0;
 
1518
+
 
1519
+    /* read header */
 
1520
+    if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
 
1521
+        grub_close();
 
1522
+        return 0;
 
1523
+    }
 
1524
+    
 
1525
+    /* parse info */
 
1526
+    while (grub_read(&c, 1)) {
 
1527
+        if (c == '"')
 
1528
+            break;
 
1529
+    }
 
1530
+
 
1531
+    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
 
1532
+        ;
 
1533
+
 
1534
+    i = 0;
 
1535
+    width = c - '0';
 
1536
+    while (grub_read(&c, 1)) {
 
1537
+        if (c >= '0' && c <= '9')
 
1538
+            width = width * 10 + c - '0';
 
1539
+        else
 
1540
+            break;
 
1541
+    }
 
1542
+    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
 
1543
+        ;
 
1544
+
 
1545
+    height = c - '0';
 
1546
+    while (grub_read(&c, 1)) {
 
1547
+        if (c >= '0' && c <= '9')
 
1548
+            height = height * 10 + c - '0';
 
1549
+        else
 
1550
+            break;
 
1551
+    }
 
1552
+    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
 
1553
+        ;
 
1554
+
 
1555
+    colors = c - '0';
 
1556
+    while (grub_read(&c, 1)) {
 
1557
+        if (c >= '0' && c <= '9')
 
1558
+            colors = colors * 10 + c - '0';
 
1559
+        else
 
1560
+            break;
 
1561
+    }
 
1562
+
 
1563
+    base = 0;
 
1564
+    while (grub_read(&c, 1) && c != '"')
 
1565
+        ;
 
1566
+
 
1567
+    /* palette */
 
1568
+    for (i = 0, idx = 1; i < colors; i++) {
 
1569
+        len = 0;
 
1570
+
 
1571
+        while (grub_read(&c, 1) && c != '"')
 
1572
+            ;
 
1573
+        grub_read(&c, 1);       /* char */
 
1574
+        base = c;
 
1575
+        grub_read(buf, 4);      /* \t c # */
 
1576
+
 
1577
+        while (grub_read(&c, 1) && c != '"') {
 
1578
+            if (len < sizeof(buf))
 
1579
+                buf[len++] = c;
 
1580
+        }
 
1581
+
 
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;
 
1586
+
 
1587
+            pal[idx] = base;
 
1588
+            graphics_set_palette(idx, r, g, b);
 
1589
+            ++idx;
 
1590
+        }
 
1591
+    }
 
1592
+
 
1593
+    x = y = len = 0;
 
1594
+
 
1595
+    s1 = (unsigned char*)VSHADOW1;
 
1596
+    s2 = (unsigned char*)VSHADOW2;
 
1597
+    s4 = (unsigned char*)VSHADOW4;
 
1598
+    s8 = (unsigned char*)VSHADOW8;
 
1599
+
 
1600
+    for (i = 0; i < 38400; i++)
 
1601
+        s1[i] = s2[i] = s4[i] = s8[i] = 0;
 
1602
+
 
1603
+    /* parse xpm data */
 
1604
+    while (y < height) {
 
1605
+        while (1) {
 
1606
+            if (!grub_read(&c, 1)) {
 
1607
+                grub_close();
 
1608
+                return 0;
 
1609
+            }
 
1610
+            if (c == '"')
 
1611
+                break;
 
1612
+        }
 
1613
+
 
1614
+        while (grub_read(&c, 1) && c != '"') {
 
1615
+            for (i = 1; i < 15; i++)
 
1616
+                if (pal[i] == c) {
 
1617
+                    c = i;
 
1618
+                    break;
 
1619
+                }
 
1620
+
 
1621
+            mask = 0x80 >> (x & 7);
 
1622
+            if (c & 1)
 
1623
+                s1[len + (x >> 3)] |= mask;
 
1624
+            if (c & 2)
 
1625
+                s2[len + (x >> 3)] |= mask;
 
1626
+            if (c & 4)
 
1627
+                s4[len + (x >> 3)] |= mask;
 
1628
+            if (c & 8)
 
1629
+                s8[len + (x >> 3)] |= mask;
 
1630
+
 
1631
+            if (++x >= 640) {
 
1632
+                x = 0;
 
1633
+
 
1634
+                if (y < 480)
 
1635
+                    len += 80;
 
1636
+                ++y;
 
1637
+            }
 
1638
+        }
 
1639
+    }
 
1640
+
 
1641
+    grub_close();
 
1642
+
 
1643
+    graphics_set_palette(0, (background >> 16), (background >> 8) & 63, 
 
1644
+                background & 63);
 
1645
+    graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63, 
 
1646
+                foreground & 63);
 
1647
+    graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63, 
 
1648
+                         window_border & 63);
 
1649
+
 
1650
+    return 1;
 
1651
+}
 
1652
+
 
1653
+/* Convert a character which is a hex digit to the appropriate integer */
 
1654
+int hex(int v)
 
1655
+{
 
1656
+    if (v >= 'A' && v <= 'F')
 
1657
+        return (v - 'A' + 10);
 
1658
+    if (v >= 'a' && v <= 'f')
 
1659
+        return (v - 'a' + 10);
 
1660
+    return (v - '0');
 
1661
+}
 
1662
+
 
1663
+void graphics_cursor(int set) {
 
1664
+    unsigned char *pat, *mem, *ptr, chr[16 << 2];
 
1665
+    int i, ch, invert, offset;
 
1666
+
 
1667
+    if (set && (no_cursor || no_scroll))
 
1668
+        return;
 
1669
+
 
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);
 
1674
+
 
1675
+    mem = (unsigned char*)VIDEOMEM + offset;
 
1676
+
 
1677
+    if (!set) {
 
1678
+        for (i = 0; i < 16; i++) {
 
1679
+            unsigned char mask = pat[i];
 
1680
+
 
1681
+            if (!invert) {
 
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];
 
1686
+
 
1687
+                if (shade) {
 
1688
+                    if (ch == DISP_VERT || ch == DISP_LL ||
 
1689
+                        ch == DISP_UR || ch == DISP_LR) {
 
1690
+                        unsigned char pmask = ~(pat[i] >> 1);
 
1691
+
 
1692
+                        chr[i     ] &= pmask;
 
1693
+                        chr[16 + i] &= pmask;
 
1694
+                        chr[32 + i] &= pmask;
 
1695
+                        chr[48 + i] &= pmask;
 
1696
+                    }
 
1697
+                    if (i > 0 && ch != DISP_VERT) {
 
1698
+                        unsigned char pmask = ~(pat[i - 1] >> 1);
 
1699
+
 
1700
+                        chr[i     ] &= pmask;
 
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];
 
1706
+
 
1707
+                            chr[i     ] &= pmask;
 
1708
+                            chr[16 + i] &= pmask;
 
1709
+                            chr[32 + i] &= pmask;
 
1710
+                            chr[48 + i] &= pmask;
 
1711
+                        }
 
1712
+                    }
 
1713
+                }
 
1714
+                chr[i     ] |= mask;
 
1715
+                chr[16 + i] |= mask;
 
1716
+                chr[32 + i] |= mask;
 
1717
+                chr[48 + i] |= mask;
 
1718
+
 
1719
+                offset += 80;
 
1720
+            }
 
1721
+            else {
 
1722
+                chr[i     ] = mask;
 
1723
+                chr[16 + i] = mask;
 
1724
+                chr[32 + i] = mask;
 
1725
+                chr[48 + i] = mask;
 
1726
+            }
 
1727
+        }
 
1728
+    }
 
1729
+    else {
 
1730
+        MapMask(15);
 
1731
+        ptr = mem;
 
1732
+        for (i = 0; i < 16; i++, ptr += 80) {
 
1733
+            cursorBuf[i] = pat[i];
 
1734
+            *ptr = ~pat[i];
 
1735
+        }
 
1736
+        return;
 
1737
+    }
 
1738
+
 
1739
+    offset = 0;
 
1740
+    for (i = 1; i < 16; i <<= 1, offset += 16) {
 
1741
+        int j;
 
1742
+
 
1743
+        MapMask(i);
 
1744
+        ptr = mem;
 
1745
+        for (j = 0; j < 16; j++, ptr += 80)
 
1746
+            *ptr = chr[j + offset];
 
1747
+    }
 
1748
+
 
1749
+    MapMask(15);
 
1750
+}
 
1751
+
 
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
 
1756
@@ -0,0 +1,44 @@
 
1757
+/* graphics.h - graphics console interface */
 
1758
+/*
 
1759
+ *  GRUB  --  GRand Unified Bootloader
 
1760
+ *  Copyright (C) 2002  Free Software Foundation, Inc.
 
1761
+ *
 
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.
 
1766
+ *
 
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.
 
1771
+ *
 
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.
 
1775
+ */
 
1776
+
 
1777
+#ifndef GRAPHICS_H
 
1778
+#define GRAPHICS_H
 
1779
+
 
1780
+/* magic constant */
 
1781
+#define VIDEOMEM 0xA0000
 
1782
+
 
1783
+/* function prototypes */
 
1784
+char *graphics_get_splash(void);
 
1785
+
 
1786
+int read_image(char *s);
 
1787
+void graphics_cursor(int set);
 
1788
+
 
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();
 
1794
+
 
1795
+extern short cursorX, cursorY;
 
1796
+extern char cursorBuf[16];
 
1797
+extern int shade;
 
1798
+extern int view_x0, view_y0, view_x1, view_y1;
 
1799
+
 
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
 
1804
@@ -7,7 +7,7 @@
 
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)
 
1811
 
 
1812
 # For <stage1.h>.
 
1813
@@ -19,7 +19,7 @@
 
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 \
 
1822
@@ -79,8 +79,14 @@
 
1823
 HERCULES_FLAGS =
 
1824
 endif
 
1825
 
 
1826
+if GRAPHICS_SUPPORT
 
1827
+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
 
1828
+else
 
1829
+GRAPHICS_FLAGS =
 
1830
+endif
 
1831
+
 
1832
 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
 
1833
-       $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
 
1834
+       $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
 
1835
 
 
1836
 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
 
1837
 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
 
1838
@@ -90,7 +96,8 @@
 
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 \
 
1844
+       graphics.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);
 
1854
 
 
1855
+/* Internal pager
 
1856
+   Returns 1 = if pager was used
 
1857
+           0 = if pager wasn't used  */
 
1858
+int do_more (void);
 
1859
+
 
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);
 
1863
@@ -871,6 +876,7 @@
 
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
 
1874
@@ -20,6 +20,12 @@
 
1875
 #include <shared.h>
 
1876
 #include <term.h>
 
1877
 
 
1878
+#ifdef SUPPORT_GRAPHICS
 
1879
+# include <graphics.h>
 
1880
+#endif
 
1881
+
 
1882
+int col_start, col_end, row_start, box_size;
 
1883
+
 
1884
 grub_jmp_buf restart_env;
 
1885
 
 
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);
 
1890
 
 
1891
-  gotoxy (2, y);
 
1892
+  gotoxy (2 + col_start, y);
 
1893
   grub_putchar (' ');
 
1894
-  for (x = 3; x < 75; x++)
 
1895
+  for (x = 3 + col_start; x < (col_end - 5); x++)
 
1896
     {
 
1897
-      if (*entry && x <= 72)
 
1898
+      if (*entry && x <= (col_end - 8))
 
1899
        {
 
1900
-         if (x == 72)
 
1901
+         if (x == (col_end - 8))
 
1902
            grub_putchar (DISP_RIGHT);
 
1903
          else
 
1904
            grub_putchar (*entry++);
 
1905
@@ -119,7 +125,7 @@
 
1906
       else
 
1907
        grub_putchar (' ');
 
1908
     }
 
1909
-  gotoxy (74, y);
 
1910
+  gotoxy ((col_end - 6), y);
 
1911
 
 
1912
   if (current_term->setcolorstate)
 
1913
     current_term->setcolorstate (COLOR_STATE_STANDARD);
 
1914
@@ -131,7 +137,7 @@
 
1915
 {
 
1916
   int i;
 
1917
   
 
1918
-  gotoxy (77, y + 1);
 
1919
+  gotoxy ((col_end - 3), y + 1);
 
1920
 
 
1921
   if (first)
 
1922
     grub_putchar (DISP_UP);
 
1923
@@ -151,14 +157,14 @@
 
1924
        menu_entries++;
 
1925
     }
 
1926
 
 
1927
-  gotoxy (77, y + size);
 
1928
+  gotoxy ((col_end - 3), y + size);
 
1929
 
 
1930
   if (*menu_entries)
 
1931
     grub_putchar (DISP_DOWN);
 
1932
   else
 
1933
     grub_putchar (' ');
 
1934
 
 
1935
-  gotoxy (74, y + entryno + 1);
 
1936
+  gotoxy ((col_end - 6), y + entryno + 1);
 
1937
 }
 
1938
 
 
1939
 static void
 
1940
@@ -196,30 +202,30 @@
 
1941
   if (current_term->setcolorstate)
 
1942
     current_term->setcolorstate (COLOR_STATE_NORMAL);
 
1943
   
 
1944
-  gotoxy (1, y);
 
1945
+  gotoxy (1 + col_start, y);
 
1946
 
 
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);
 
1952
 
 
1953
   i = 1;
 
1954
   while (1)
 
1955
     {
 
1956
-      gotoxy (1, y + i);
 
1957
+      gotoxy (1 + col_start, y + i);
 
1958
 
 
1959
       if (i > size)
 
1960
        break;
 
1961
       
 
1962
       grub_putchar (DISP_VERT);
 
1963
-      gotoxy (75, y + i);
 
1964
+      gotoxy ((col_end - 5), y + i);
 
1965
       grub_putchar (DISP_VERT);
 
1966
 
 
1967
       i++;
 
1968
     }
 
1969
 
 
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);
 
1975
 
 
1976
@@ -233,6 +239,7 @@
 
1977
 {
 
1978
   int c, time1, time2 = -1, first_entry = 0;
 
1979
   char *cur_entry = 0;
 
1980
+  struct term_entry *prev_term = NULL;
 
1981
 
 
1982
   /*
 
1983
    *  Main loop for menu UI.
 
1984
@@ -250,6 +257,22 @@
 
1985
        }
 
1986
     }
 
1987
 
 
1988
+  col_start = 0;
 
1989
+  col_end = 80;
 
1990
+  row_start = 0;
 
1991
+  box_size = 12;
 
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)
 
1996
+    {
 
1997
+      col_start = view_x0;
 
1998
+      col_end = view_x1;
 
1999
+      row_start = view_y0;
 
2000
+      box_size = (view_y1 - view_y0) - 13;
 
2001
+    }
 
2002
+#endif
 
2003
+
 
2004
   /* If the timeout was expired or wasn't set, force to show the menu
 
2005
      interface. */
 
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);
 
2010
       else
 
2011
-       print_border (3, 12);
 
2012
+       print_border (3 + row_start, box_size);
 
2013
 
 
2014
       grub_printf ("\n\
 
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);
 
2018
       
 
2019
       if (! auth && password)
 
2020
        {
 
2021
          printf ("\
 
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.");
 
2026
        }
 
2027
       else
 
2028
        {
 
2029
          if (config_entries)
 
2030
            printf ("\
 
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.");
 
2035
          else
 
2036
            printf ("\
 
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.");
 
2045
        }
 
2046
 
 
2047
       if (current_term->flags & TERM_DUMB)
 
2048
        grub_printf ("\n\nThe selected entry is %d ", entryno);
 
2049
       else
 
2050
-       print_entries (3, 12, first_entry, entryno, menu_entries);
 
2051
+       print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
 
2052
     }
 
2053
 
 
2054
   /* XX using RT clock now, need to initialize value */
 
2055
@@ -358,10 +381,10 @@
 
2056
                           entryno, grub_timeout);
 
2057
          else
 
2058
            {
 
2059
-             gotoxy (3, 22);
 
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.   ",
 
2063
                           grub_timeout);
 
2064
-             gotoxy (74, 4 + entryno);
 
2065
+             gotoxy ((col_end - 6), 4 + entryno + row_start);
 
2066
          }
 
2067
          
 
2068
          grub_timeout--;
 
2069
@@ -387,12 +410,12 @@
 
2070
              if (current_term->flags & TERM_DUMB)
 
2071
                grub_putchar ('\r');
 
2072
              else
 
2073
-               gotoxy (3, 22);
 
2074
+               gotoxy (3 + col_start, 10 + box_size + row_start);
 
2075
              printf ("                                                                    ");
 
2076
              grub_timeout = -1;
 
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);
 
2081
            }
 
2082
 
 
2083
          /* We told them above (at least in SUPPORT_SERIAL) to use
 
2084
@@ -408,12 +431,12 @@
 
2085
                {
 
2086
                  if (entryno > 0)
 
2087
                    {
 
2088
-                     print_entry (4 + entryno, 0,
 
2089
+                     print_entry (4 + entryno + row_start, 0,
 
2090
                                   get_entry (menu_entries,
 
2091
                                              first_entry + entryno,
 
2092
                                              0));
 
2093
                      entryno--;
 
2094
-                     print_entry (4 + entryno, 1,
 
2095
+                     print_entry (4 + entryno + row_start, 1,
 
2096
                                   get_entry (menu_entries,
 
2097
                                              first_entry + entryno,
 
2098
                                              0));
 
2099
@@ -421,7 +444,7 @@
 
2100
                  else if (first_entry > 0)
 
2101
                    {
 
2102
                      first_entry--;
 
2103
-                     print_entries (3, 12, first_entry, entryno,
 
2104
+                     print_entries (3 + row_start, box_size, first_entry, entryno,
 
2105
                                     menu_entries);
 
2106
                    }
 
2107
                }
 
2108
@@ -433,29 +456,29 @@
 
2109
                entryno++;
 
2110
              else
 
2111
                {
 
2112
-                 if (entryno < 11)
 
2113
+                 if (entryno < (box_size - 1))
 
2114
                    {
 
2115
-                     print_entry (4 + entryno, 0,
 
2116
+                     print_entry (4 + entryno + row_start, 0,
 
2117
                                   get_entry (menu_entries,
 
2118
                                              first_entry + entryno,
 
2119
                                              0));
 
2120
                      entryno++;
 
2121
-                     print_entry (4 + entryno, 1,
 
2122
+                     print_entry (4 + entryno + row_start, 1,
 
2123
                                   get_entry (menu_entries,
 
2124
                                              first_entry + entryno,
 
2125
                                              0));
 
2126
                  }
 
2127
-               else if (num_entries > 12 + first_entry)
 
2128
+               else if (num_entries > box_size + first_entry)
 
2129
                  {
 
2130
                    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);
 
2133
                  }
 
2134
                }
 
2135
            }
 
2136
          else if (c == 7)
 
2137
            {
 
2138
              /* Page Up */
 
2139
-             first_entry -= 12;
 
2140
+             first_entry -= box_size;
 
2141
              if (first_entry < 0)
 
2142
                {
 
2143
                  entryno += first_entry;
 
2144
@@ -463,20 +486,20 @@
 
2145
                  if (entryno < 0)
 
2146
                    entryno = 0;
 
2147
                }
 
2148
-             print_entries (3, 12, first_entry, entryno, menu_entries);
 
2149
+             print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
 
2150
            }
 
2151
          else if (c == 3)
 
2152
            {
 
2153
              /* Page Down */
 
2154
-             first_entry += 12;
 
2155
+             first_entry += box_size;
 
2156
              if (first_entry + entryno + 1 >= num_entries)
 
2157
                {
 
2158
-                 first_entry = num_entries - 12;
 
2159
+                 first_entry = num_entries - box_size;
 
2160
                  if (first_entry < 0)
 
2161
                    first_entry = 0;
 
2162
                  entryno = num_entries - first_entry - 1;
 
2163
                }
 
2164
-             print_entries (3, 12, first_entry, entryno, menu_entries);
 
2165
+             print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
 
2166
            }
 
2167
 
 
2168
          if (config_entries)
 
2169
@@ -489,7 +512,7 @@
 
2170
              if ((c == 'd') || (c == 'o') || (c == 'O'))
 
2171
                {
 
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,
 
2177
                                            0));
 
2178
@@ -537,7 +560,7 @@
 
2179
 
 
2180
                      if (entryno >= num_entries)
 
2181
                        entryno--;
 
2182
-                     if (first_entry && num_entries < 12 + first_entry)
 
2183
+                     if (first_entry && num_entries < box_size + first_entry)
 
2184
                        first_entry--;
 
2185
                    }
 
2186
 
 
2187
@@ -549,7 +572,7 @@
 
2188
                      grub_printf ("\n");
 
2189
                    }
 
2190
                  else
 
2191
-                   print_entries (3, 12, first_entry, entryno, menu_entries);
 
2192
+                   print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
 
2193
                }
 
2194
 
 
2195
              cur_entry = menu_entries;
 
2196
@@ -570,7 +593,7 @@
 
2197
                  if (current_term->flags & TERM_DUMB)
 
2198
                    grub_printf ("\r                                    ");
 
2199
                  else
 
2200
-                   gotoxy (1, 21);
 
2201
+                   gotoxy (1 + col_start, 9 + box_size + row_start);
 
2202
 
 
2203
                  /* Wipe out the previously entered password */
 
2204
                  grub_memset (entered, 0, sizeof (entered));
 
2205
@@ -714,6 +737,15 @@
 
2206
   
 
2207
   cls ();
 
2208
   setcursor (1);
 
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) 
 
2214
+    {
 
2215
+      current_term->shutdown();
 
2216
+      current_term = term_table; /* assumption: console is first */
 
2217
+    }
 
2218
   
 
2219
   while (1)
 
2220
     {
 
2221
@@ -748,6 +780,13 @@
 
2222
        break;
 
2223
     }
 
2224
 
 
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 */
 
2232
   show_menu = 1;
 
2233
   goto restart;
 
2234
 }
 
2235
@@ -1050,6 +1089,16 @@
 
2236
          while (is_preset);
 
2237
        }
 
2238
 
 
2239
+      /* go ahead and make sure the terminal is setup */
 
2240
+      if (current_term->startup)
 
2241
+       {
 
2242
+         /* If initialization fails, go back to default terminal */
 
2243
+         if (current_term->startup() == 0)
 
2244
+                 {
 
2245
+                     current_term = term_table;
 
2246
+                 }
 
2247
+       }
 
2248
+
 
2249
       if (! num_entries)
 
2250
        {
 
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
 
2255
@@ -60,6 +60,8 @@
 
2256
   const char *name;
 
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.  */
 
2264
@@ -79,6 +81,10 @@
 
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);
 
2272
 };
 
2273
 
 
2274
 /* This lists up available terminals.  */
 
2275
@@ -124,4 +130,24 @@
 
2276
 int hercules_setcursor (int on);
 
2277
 #endif
 
2278
 
 
2279
+#ifdef SUPPORT_GRAPHICS
 
2280
+extern int foreground, background, window_border, graphics_inited, saved_videomode;
 
2281
+
 
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);
 
2294
+
 
2295
+int hex(int v);
 
2296
+void graphics_set_palette(int idx, int red, int green, int blue);
 
2297
+#endif /* SUPPORT_GRAPHICS */
 
2298
+
 
2299
 #endif /* ! GRUB_TERM_HEADER */