]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/grub-0.93-graphics.patch
Hinzugefuegt:
[people/pmueller/ipfire-2.x.git] / src / patches / grub-0.93-graphics.patch
CommitLineData
cd1a2927
MT
1--- grub-0.93/stage2/Makefile.am.graphics 2002-12-28 23:37:03.000000000 -0500
2+++ grub-0.93/stage2/Makefile.am 2002-12-28 23:37:03.000000000 -0500
3@@ -7,7 +7,7 @@
4 fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
5 imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
6 nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
7- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
8+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
9 EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
10
11 # For <stage1.h>.
12@@ -19,7 +19,7 @@
13 disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
14 fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
15 fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
16- terminfo.c tparm.c
17+ terminfo.c tparm.c graphics.c
18 libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
19 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
20 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
21@@ -80,8 +80,14 @@
22 HERCULES_FLAGS =
23 endif
24
25+if GRAPHICS_SUPPORT
26+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
27+else
28+GRAPHICS_FLAGS =
29+endif
30+
31 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
32- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
33+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
34
35 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
36 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
37@@ -91,7 +97,8 @@
38 cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
39 fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
40 fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
41- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
42+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
43+ graphics.c
44 pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
45 pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
46 pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
47--- grub-0.93/stage2/asm.S.graphics 2002-12-28 23:37:03.000000000 -0500
48+++ grub-0.93/stage2/asm.S 2002-12-28 23:37:03.000000000 -0500
49@@ -2224,6 +2224,156 @@
50 pop %ebx
51 pop %ebp
52 ret
53+
54+/* graphics mode functions */
55+#ifdef SUPPORT_GRAPHICS
56+VARIABLE(cursorX)
57+.word 0
58+VARIABLE(cursorY)
59+.word 0
60+VARIABLE(cursorCount)
61+.word 0
62+VARIABLE(cursorBuf)
63+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
64+
65+
66+/*
67+ * int set_videomode(mode)
68+ * BIOS call "INT 10H Function 0h" to set video mode
69+ * Call with %ah = 0x0
70+ * %al = video mode
71+ * Returns old videomode.
72+ */
73+ENTRY(set_videomode)
74+ push %ebp
75+ push %ebx
76+ push %ecx
77+
78+ movb 0x10(%esp), %cl
79+
80+ call EXT_C(prot_to_real)
81+ .code16
82+
83+ xorw %bx, %bx
84+ movb $0xf, %ah
85+ int $0x10 /* Get Current Video mode */
86+ movb %al, %ch
87+ xorb %ah, %ah
88+ movb %cl, %al
89+ int $0x10 /* Set Video mode */
90+
91+ DATA32 call EXT_C(real_to_prot)
92+ .code32
93+
94+ xorb %ah, %ah
95+ movb %ch, %al
96+
97+ pop %ecx
98+ pop %ebx
99+ pop %ebp
100+ ret
101+
102+
103+/*
104+ * unsigned char * graphics_get_font()
105+ * BIOS call "INT 10H Function 11h" to set font
106+ * Call with %ah = 0x11
107+ */
108+ENTRY(graphics_get_font)
109+ push %ebp
110+ push %ebx
111+ push %ecx
112+ push %edx
113+
114+ call EXT_C(prot_to_real)
115+ .code16
116+
117+ movw $0x1130, %ax
118+ movb $6, %bh /* font 8x16 */
119+ int $0x10
120+ movw %bp, %dx
121+ movw %es, %cx
122+
123+ DATA32 call EXT_C(real_to_prot)
124+ .code32
125+
126+ xorl %eax, %eax
127+ movw %cx, %ax
128+ shll $4, %eax
129+ movw %dx, %ax
130+
131+ pop %edx
132+ pop %ecx
133+ pop %ebx
134+ pop %ebp
135+ ret
136+
137+
138+
139+/*
140+ * graphics_set_palette(index, red, green, blue)
141+ * BIOS call "INT 10H Function 10h" to set individual dac register
142+ * Call with %ah = 0x10
143+ * %bx = register number
144+ * %ch = new value for green (0-63)
145+ * %cl = new value for blue (0-63)
146+ * %dh = new value for red (0-63)
147+ */
148+
149+ENTRY(graphics_set_palette)
150+ push %ebp
151+ push %eax
152+ push %ebx
153+ push %ecx
154+ push %edx
155+
156+ movw $0x3c8, %bx /* address write mode register */
157+
158+ /* wait vertical retrace */
159+
160+ movw $0x3da, %dx
161+l1b: inb %dx, %al /* wait vertical active display */
162+ test $8, %al
163+ jnz l1b
164+
165+l2b: inb %dx, %al /* wait vertical retrace */
166+ test $8, %al
167+ jnz l2b
168+
169+ mov %bx, %dx
170+ movb 0x18(%esp), %al /* index */
171+ outb %al, %dx
172+ inc %dx
173+
174+ movb 0x1c(%esp), %al /* red */
175+ outb %al, %dx
176+
177+ movb 0x20(%esp), %al /* green */
178+ outb %al, %dx
179+
180+ movb 0x24(%esp), %al /* blue */
181+ outb %al, %dx
182+
183+ movw 0x18(%esp), %bx
184+
185+ call EXT_C(prot_to_real)
186+ .code16
187+
188+ movb %bl, %bh
189+ movw $0x1000, %ax
190+ int $0x10
191+
192+ DATA32 call EXT_C(real_to_prot)
193+ .code32
194+
195+ pop %edx
196+ pop %ecx
197+ pop %ebx
198+ pop %eax
199+ pop %ebp
200+ ret
201+
202+#endif /* SUPPORT_GRAPHICS */
203
204 /*
205 * getrtsecs()
206--- grub-0.93/stage2/builtins.c.graphics 2002-12-28 23:37:03.000000000 -0500
207+++ grub-0.93/stage2/builtins.c 2002-12-28 23:37:03.000000000 -0500
208@@ -857,6 +857,138 @@
209 };
210 #endif /* SUPPORT_NETBOOT */
211
212+static int terminal_func (char *arg, int flags);
213+
214+#ifdef SUPPORT_GRAPHICS
215+\f
216+static int splashimage_func(char *arg, int flags) {
217+ char splashimage[64];
218+ int i;
219+
220+ /* filename can only be 64 characters due to our buffer size */
221+ if (strlen(arg) > 63)
222+ return 1;
223+ if (flags == BUILTIN_CMDLINE) {
224+ if (!grub_open(arg))
225+ return 1;
226+ grub_close();
227+ }
228+
229+ strcpy(splashimage, arg);
230+
231+ /* get rid of TERM_NEED_INIT from the graphics terminal. */
232+ for (i = 0; term_table[i].name; i++) {
233+ if (grub_strcmp (term_table[i].name, "graphics") == 0) {
234+ term_table[i].flags &= ~TERM_NEED_INIT;
235+ break;
236+ }
237+ }
238+
239+ graphics_set_splash(splashimage);
240+
241+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
242+ graphics_end();
243+ graphics_init();
244+ graphics_cls();
245+ }
246+
247+ /* FIXME: should we be explicitly switching the terminal as a
248+ * side effect here? */
249+ terminal_func("graphics", flags);
250+
251+ return 0;
252+}
253+
254+static struct builtin builtin_splashimage =
255+{
256+ "splashimage",
257+ splashimage_func,
258+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
259+ "splashimage FILE",
260+ "Load FILE as the background image when in graphics mode."
261+};
262+
263+\f
264+/* foreground */
265+static int
266+foreground_func(char *arg, int flags)
267+{
268+ if (grub_strlen(arg) == 6) {
269+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
270+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
271+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
272+
273+ foreground = (r << 16) | (g << 8) | b;
274+ if (graphics_inited)
275+ graphics_set_palette(15, r, g, b);
276+
277+ return (0);
278+ }
279+
280+ return (1);
281+}
282+
283+static struct builtin builtin_foreground =
284+{
285+ "foreground",
286+ foreground_func,
287+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
288+ "foreground RRGGBB",
289+ "Sets the foreground color when in graphics mode."
290+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
291+};
292+
293+\f
294+/* background */
295+static int
296+background_func(char *arg, int flags)
297+{
298+ if (grub_strlen(arg) == 6) {
299+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
300+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
301+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
302+
303+ background = (r << 16) | (g << 8) | b;
304+ if (graphics_inited)
305+ graphics_set_palette(0, r, g, b);
306+ return (0);
307+ }
308+
309+ return (1);
310+}
311+
312+static struct builtin builtin_background =
313+{
314+ "background",
315+ background_func,
316+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
317+ "background RRGGBB",
318+ "Sets the background color when in graphics mode."
319+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
320+};
321+
322+#endif /* SUPPORT_GRAPHICS */
323+
324+\f
325+/* clear */
326+static int
327+clear_func()
328+{
329+ if (current_term->cls)
330+ current_term->cls();
331+
332+ return 0;
333+}
334+
335+static struct builtin builtin_clear =
336+{
337+ "clear",
338+ clear_func,
339+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
340+ "clear",
341+ "Clear the screen"
342+};
343+
344 \f
345 /* displayapm */
346 static int
347@@ -4071,7 +4203,7 @@
348 };
349
350 \f
351-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
352+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
353 /* terminal */
354 static int
355 terminal_func (char *arg, int flags)
356@@ -4230,17 +4362,21 @@
357 end:
358 current_term = term_table + default_term;
359 current_term->flags = term_flags;
360-
361+
362 if (lines)
363 max_lines = lines;
364 else
365- /* 24 would be a good default value. */
366- max_lines = 24;
367-
368+ max_lines = current_term->max_lines;
369+
370 /* If the interface is currently the command-line,
371 restart it to repaint the screen. */
372- if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
373+ if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
374+ if (prev_term->shutdown)
375+ prev_term->shutdown();
376+ if (current_term->startup)
377+ current_term->startup();
378 grub_longjmp (restart_cmdline_env, 0);
379+ }
380
381 return 0;
382 }
383@@ -4250,7 +4386,7 @@
384 "terminal",
385 terminal_func,
386 BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
387- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
388+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
389 "Select a terminal. When multiple terminals are specified, wait until"
390 " you push any key to continue. If both console and serial are specified,"
391 " the terminal to which you input a key first will be selected. If no"
392@@ -4262,7 +4398,7 @@
393 " seconds. The option --lines specifies the maximum number of lines."
394 " The option --silent is used to suppress messages."
395 };
396-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
397+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
398
399 \f
400 #ifdef SUPPORT_SERIAL
401@@ -4785,6 +4921,9 @@
402 /* The table of builtin commands. Sorted in dictionary order. */
403 struct builtin *builtin_table[] =
404 {
405+#ifdef SUPPORT_GRAPHICS
406+ &builtin_background,
407+#endif
408 &builtin_blocklist,
409 &builtin_boot,
410 #ifdef SUPPORT_NETBOOT
411@@ -4792,6 +4931,7 @@
412 #endif /* SUPPORT_NETBOOT */
413 &builtin_cat,
414 &builtin_chainloader,
415+ &builtin_clear,
416 &builtin_cmp,
417 &builtin_color,
418 &builtin_configfile,
419@@ -4811,6 +4951,9 @@
420 &builtin_embed,
421 &builtin_fallback,
422 &builtin_find,
423+#ifdef SUPPORT_GRAPHICS
424+ &builtin_foreground,
425+#endif
426 &builtin_fstest,
427 &builtin_geometry,
428 &builtin_halt,
429@@ -4854,9 +4997,12 @@
430 #endif /* SUPPORT_SERIAL */
431 &builtin_setkey,
432 &builtin_setup,
433-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
434+#ifdef SUPPORT_GRAPHICS
435+ &builtin_splashimage,
436+#endif /* SUPPORT_GRAPHICS */
437+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
438 &builtin_terminal,
439-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
440+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
441 #ifdef SUPPORT_SERIAL
442 &builtin_terminfo,
443 #endif /* SUPPORT_SERIAL */
444--- grub-0.93/stage2/char_io.c.graphics 2002-12-02 18:49:07.000000000 -0500
445+++ grub-0.93/stage2/char_io.c 2002-12-28 23:37:03.000000000 -0500
446@@ -35,6 +35,7 @@
447 {
448 "console",
449 0,
450+ 24,
451 console_putchar,
452 console_checkkey,
453 console_getkey,
454@@ -43,13 +44,16 @@
455 console_cls,
456 console_setcolorstate,
457 console_setcolor,
458- console_setcursor
459+ console_setcursor,
460+ 0,
461+ 0
462 },
463 #ifdef SUPPORT_SERIAL
464 {
465 "serial",
466 /* A serial device must be initialized. */
467 TERM_NEED_INIT,
468+ 24,
469 serial_putchar,
470 serial_checkkey,
471 serial_getkey,
472@@ -58,6 +62,8 @@
473 serial_cls,
474 serial_setcolorstate,
475 0,
476+ 0,
477+ 0,
478 0
479 },
480 #endif /* SUPPORT_SERIAL */
481@@ -65,6 +71,7 @@
482 {
483 "hercules",
484 0,
485+ 24,
486 hercules_putchar,
487 console_checkkey,
488 console_getkey,
489@@ -73,9 +80,28 @@
490 hercules_cls,
491 hercules_setcolorstate,
492 hercules_setcolor,
493- hercules_setcursor
494+ hercules_setcursor,
495+ 0,
496+ 0
497 },
498 #endif /* SUPPORT_HERCULES */
499+#ifdef SUPPORT_GRAPHICS
500+ { "graphics",
501+ TERM_NEED_INIT, /* flags */
502+ 30, /* number of lines */
503+ graphics_putchar, /* putchar */
504+ console_checkkey, /* checkkey */
505+ console_getkey, /* getkey */
506+ graphics_getxy, /* getxy */
507+ graphics_gotoxy, /* gotoxy */
508+ graphics_cls, /* cls */
509+ graphics_setcolorstate, /* setcolorstate */
510+ graphics_setcolor, /* setcolor */
511+ graphics_setcursor, /* nocursor */
512+ graphics_init, /* initialize */
513+ graphics_end /* shutdown */
514+ },
515+#endif /* SUPPORT_GRAPHICS */
516 /* This must be the last entry. */
517 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
518 };
519@@ -1039,13 +1065,15 @@
520 the following grub_printf call will print newlines. */
521 count_lines = -1;
522
523+ grub_printf("\n");
524 if (current_term->setcolorstate)
525 current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
526
527- grub_printf ("\n[Hit return to continue]");
528+ grub_printf ("[Hit return to continue]");
529
530 if (current_term->setcolorstate)
531 current_term->setcolorstate (COLOR_STATE_NORMAL);
532+
533
534 do
535 {
536@@ -1083,7 +1111,7 @@
537 cls (void)
538 {
539 /* If the terminal is dumb, there is no way to clean the terminal. */
540- if (current_term->flags & TERM_DUMB)
541+ if (current_term->flags & TERM_DUMB)
542 grub_putchar ('\n');
543 else
544 current_term->cls ();
545@@ -1207,6 +1235,16 @@
546 return ! errnum;
547 }
548
549+void
550+grub_memcpy(void *dest, const void *src, int len)
551+{
552+ int i;
553+ register char *d = (char*)dest, *s = (char*)src;
554+
555+ for (i = 0; i < len; i++)
556+ d[i] = s[i];
557+}
558+
559 void *
560 grub_memmove (void *to, const void *from, int len)
561 {
562--- /dev/null 2002-10-04 14:48:04.000000000 -0400
563+++ grub-0.93/stage2/graphics.c 2002-12-28 23:37:03.000000000 -0500
564@@ -0,0 +1,552 @@
565+/* graphics.c - graphics mode support for GRUB */
566+/* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
567