]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/grub-0.95-graphics.patch
Another fix for grub-install for virtio
[people/pmueller/ipfire-2.x.git] / src / patches / grub-0.95-graphics.patch
CommitLineData
4ff9093d
MT
1--- grub-0.95/stage2/asm.S.graphics 2004-06-18 17:35:51.932054040 -0400
2+++ grub-0.95/stage2/asm.S 2004-06-18 17:35:52.473971656 -0400
3@@ -2215,6 +2215,156 @@
4 pop %ebx
5 pop %ebp
6 ret
7+
8+/* graphics mode functions */
9+#ifdef SUPPORT_GRAPHICS
10+VARIABLE(cursorX)
11+.word 0
12+VARIABLE(cursorY)
13+.word 0
14+VARIABLE(cursorCount)
15+.word 0
16+VARIABLE(cursorBuf)
17+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
18+
19+
20+/*
21+ * int set_videomode(mode)
22+ * BIOS call "INT 10H Function 0h" to set video mode
23+ * Call with %ah = 0x0
24+ * %al = video mode
25+ * Returns old videomode.
26+ */
27+ENTRY(set_videomode)
28+ push %ebp
29+ push %ebx
30+ push %ecx
31+
32+ movb 0x10(%esp), %cl
33+
34+ call EXT_C(prot_to_real)
35+ .code16
36+
37+ xorw %bx, %bx
38+ movb $0xf, %ah
39+ int $0x10 /* Get Current Video mode */
40+ movb %al, %ch
41+ xorb %ah, %ah
42+ movb %cl, %al
43+ int $0x10 /* Set Video mode */
44+
45+ DATA32 call EXT_C(real_to_prot)
46+ .code32
47+
48+ xorb %ah, %ah
49+ movb %ch, %al
50+
51+ pop %ecx
52+ pop %ebx
53+ pop %ebp
54+ ret
55+
56+
57+/*
58+ * unsigned char * graphics_get_font()
59+ * BIOS call "INT 10H Function 11h" to set font
60+ * Call with %ah = 0x11
61+ */
62+ENTRY(graphics_get_font)
63+ push %ebp
64+ push %ebx
65+ push %ecx
66+ push %edx
67+
68+ call EXT_C(prot_to_real)
69+ .code16
70+
71+ movw $0x1130, %ax
72+ movb $6, %bh /* font 8x16 */
73+ int $0x10
74+ movw %bp, %dx
75+ movw %es, %cx
76+
77+ DATA32 call EXT_C(real_to_prot)
78+ .code32
79+
80+ xorl %eax, %eax
81+ movw %cx, %ax
82+ shll $4, %eax
83+ movw %dx, %ax
84+
85+ pop %edx
86+ pop %ecx
87+ pop %ebx
88+ pop %ebp
89+ ret
90+
91+
92+
93+/*
94+ * graphics_set_palette(index, red, green, blue)
95+ * BIOS call "INT 10H Function 10h" to set individual dac register
96+ * Call with %ah = 0x10
97+ * %bx = register number
98+ * %ch = new value for green (0-63)
99+ * %cl = new value for blue (0-63)
100+ * %dh = new value for red (0-63)
101+ */
102+
103+ENTRY(graphics_set_palette)
104+ push %ebp
105+ push %eax
106+ push %ebx
107+ push %ecx
108+ push %edx
109+
110+ movw $0x3c8, %bx /* address write mode register */
111+
112+ /* wait vertical retrace */
113+
114+ movw $0x3da, %dx
115+l1b: inb %dx, %al /* wait vertical active display */
116+ test $8, %al
117+ jnz l1b
118+
119+l2b: inb %dx, %al /* wait vertical retrace */
120+ test $8, %al
121+ jnz l2b
122+
123+ mov %bx, %dx
124+ movb 0x18(%esp), %al /* index */
125+ outb %al, %dx
126+ inc %dx
127+
128+ movb 0x1c(%esp), %al /* red */
129+ outb %al, %dx
130+
131+ movb 0x20(%esp), %al /* green */
132+ outb %al, %dx
133+
134+ movb 0x24(%esp), %al /* blue */
135+ outb %al, %dx
136+
137+ movw 0x18(%esp), %bx
138+
139+ call EXT_C(prot_to_real)
140+ .code16
141+
142+ movb %bl, %bh
143+ movw $0x1000, %ax
144+ int $0x10
145+
146+ DATA32 call EXT_C(real_to_prot)
147+ .code32
148+
149+ pop %edx
150+ pop %ecx
151+ pop %ebx
152+ pop %eax
153+ pop %ebp
154+ ret
155+
156+#endif /* SUPPORT_GRAPHICS */
157
158 /*
159 * getrtsecs()
160--- grub-0.95/stage2/stage2.c.graphics 2004-06-18 17:35:52.314995824 -0400
161+++ grub-0.95/stage2/stage2.c 2004-06-18 17:35:52.494968464 -0400
162@@ -233,6 +233,7 @@
163 {
164 int c, time1, time2 = -1, first_entry = 0;
165 char *cur_entry = 0;
166+ struct term_entry *prev_term = NULL;
167
168 /*
169 * Main loop for menu UI.
170@@ -807,6 +808,15 @@
171
172 cls ();
173 setcursor (1);
174+ /* if our terminal needed initialization, we should shut it down
175+ * before booting the kernel, but we want to save what it was so
176+ * we can come back if needed */
177+ prev_term = current_term;
178+ if (current_term->shutdown)
179+ {
180+ (*current_term->shutdown)();
181+ current_term = term_table; /* assumption: console is first */
182+ }
183
184 while (1)
185 {
186@@ -838,6 +848,13 @@
187 break;
188 }
189
190+ /* if we get back here, we should go back to what our term was before */
191+ current_term = prev_term;
192+ if (current_term->startup)
193+ /* if our terminal fails to initialize, fall back to console since
194+ * it should always work */
195+ if ((*current_term->startup)() == 0)
196+ current_term = term_table; /* we know that console is first */
197 show_menu = 1;
198 goto restart;
199 }
200@@ -1082,6 +1099,10 @@
201 while (is_preset);
202 }
203
204+ /* go ahead and make sure the terminal is setup */
205+ if (current_term->startup)
206+ (*current_term->startup)();
207+
208 if (! num_entries)
209 {
210 /* If no acceptable config file, goto command-line, starting
211--- grub-0.95/stage2/builtins.c.graphics 2004-06-18 17:35:52.370987312 -0400
212+++ grub-0.95/stage2/builtins.c 2004-06-18 17:35:52.482970288 -0400
213@@ -858,6 +858,138 @@
214 };
215 #endif /* SUPPORT_NETBOOT */
216
217+static int terminal_func (char *arg, int flags);
218+
219+#ifdef SUPPORT_GRAPHICS
220+\f
221+static int splashimage_func(char *arg, int flags) {
222+ char splashimage[64];
223+ int i;
224+
225+ /* filename can only be 64 characters due to our buffer size */
226+ if (strlen(arg) > 63)
227+ return 1;
228+ if (flags == BUILTIN_CMDLINE) {
229+ if (!grub_open(arg))
230+ return 1;
231+ grub_close();
232+ }
233+
234+ strcpy(splashimage, arg);
235+
236+ /* get rid of TERM_NEED_INIT from the graphics terminal. */
237+ for (i = 0; term_table[i].name; i++) {
238+ if (grub_strcmp (term_table[i].name, "graphics") == 0) {
239+ term_table[i].flags &= ~TERM_NEED_INIT;
240+ break;
241+ }
242+ }
243+
244+ graphics_set_splash(splashimage);
245+
246+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
247+ graphics_end();
248+ graphics_init();
249+ graphics_cls();
250+ }
251+
252+ /* FIXME: should we be explicitly switching the terminal as a
253+ * side effect here? */
254+ terminal_func("graphics", flags);
255+
256+ return 0;
257+}
258+
259+static struct builtin builtin_splashimage =
260+{
261+ "splashimage",
262+ splashimage_func,
263+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
264+ "splashimage FILE",
265+ "Load FILE as the background image when in graphics mode."
266+};
267+
268+\f
269+/* foreground */
270+static int
271+foreground_func(char *arg, int flags)
272+{
273+ if (grub_strlen(arg) == 6) {
274+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
275+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
276+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
277+
278+ foreground = (r << 16) | (g << 8) | b;
279+ if (graphics_inited)
280+ graphics_set_palette(15, r, g, b);
281+
282+ return (0);
283+ }
284+
285+ return (1);
286+}
287+
288+static struct builtin builtin_foreground =
289+{
290+ "foreground",
291+ foreground_func,
292+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
293+ "foreground RRGGBB",
294+ "Sets the foreground color when in graphics mode."
295+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
296+};
297+
298+\f
299+/* background */
300+static int
301+background_func(char *arg, int flags)
302+{
303+ if (grub_strlen(arg) == 6) {
304+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
305+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
306+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
307+
308+ background = (r << 16) | (g << 8) | b;
309+ if (graphics_inited)
310+ graphics_set_palette(0, r, g, b);
311+ return (0);
312+ }
313+
314+ return (1);
315+}
316+
317+static struct builtin builtin_background =
318+{
319+ "background",
320+ background_func,
321+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
322+ "background RRGGBB",
323+ "Sets the background color when in graphics mode."
324+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
325+};
326+
327+#endif /* SUPPORT_GRAPHICS */
328+
329+\f
330+/* clear */
331+static int
332+clear_func()
333+{
334+ if (current_term->cls)
335+ current_term->cls();
336+
337+ return 0;
338+}
339+
340+static struct builtin builtin_clear =
341+{
342+ "clear",
343+ clear_func,
344+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
345+ "clear",
346+ "Clear the screen"
347+};
348+
349 \f
350 /* displayapm */
351 static int
352@@ -4090,7 +4222,7 @@
353 };
354
355 \f
356-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
357+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
358 /* terminal */
359 static int
360 terminal_func (char *arg, int flags)
361@@ -4249,17 +4381,21 @@
362 end:
363 current_term = term_table + default_term;
364 current_term->flags = term_flags;
365-
366+
367 if (lines)
368 max_lines = lines;
369 else
370- /* 24 would be a good default value. */
371- max_lines = 24;
372-
373+ max_lines = current_term->max_lines;
374+
375 /* If the interface is currently the command-line,
376 restart it to repaint the screen. */
377- if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
378+ if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
379+ if (prev_term->shutdown)
380+ prev_term->shutdown();
381+ if (current_term->startup)
382+ current_term->startup();
383 grub_longjmp (restart_cmdline_env, 0);
384+ }
385
386 return 0;
387 }
388@@ -4269,7 +4405,7 @@
389 "terminal",
390 terminal_func,
391 BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
392- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
393+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
394 "Select a terminal. When multiple terminals are specified, wait until"
395 " you push any key to continue. If both console and serial are specified,"
396 " the terminal to which you input a key first will be selected. If no"
397@@ -4281,7 +4417,7 @@
398 " seconds. The option --lines specifies the maximum number of lines."
399 " The option --silent is used to suppress messages."
400 };
401-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
402+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
403
404 \f
405 #ifdef SUPPORT_SERIAL
406@@ -4809,6 +4945,9 @@
407 /* The table of builtin commands. Sorted in dictionary order. */
408 struct builtin *builtin_table[] =
409 {
410+#ifdef SUPPORT_GRAPHICS
411+ &builtin_background,
412+#endif
413 &builtin_blocklist,
414 &builtin_boot,
415 #ifdef SUPPORT_NETBOOT
416@@ -4816,6 +4955,7 @@
417 #endif /* SUPPORT_NETBOOT */
418 &builtin_cat,
419 &builtin_chainloader,
420+ &builtin_clear,
421 &builtin_cmp,
422 &builtin_color,
423 &builtin_configfile,
424@@ -4835,6 +4975,9 @@
425 &builtin_embed,
426 &builtin_fallback,
427 &builtin_find,
428+#ifdef SUPPORT_GRAPHICS
429+ &builtin_foreground,
430+#endif
431 &builtin_fstest,
432 &builtin_geometry,
433 &builtin_halt,
434@@ -4878,9 +5021,12 @@
435 #endif /* SUPPORT_SERIAL */
436 &builtin_setkey,
437 &builtin_setup,
438-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
439+#ifdef SUPPORT_GRAPHICS
440+ &builtin_splashimage,
441+#endif /* SUPPORT_GRAPHICS */
442+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
443 &builtin_terminal,
444-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
445+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
446 #ifdef SUPPORT_SERIAL
447 &builtin_terminfo,
448 #endif /* SUPPORT_SERIAL */
449--- /dev/null 2004-02-23 16:02:56.000000000 -0500
450+++ grub-0.95/stage2/graphics.c 2004-06-18 17:35:52.488969376 -0400
451@@ -0,0 +1,552 @@
452+/* graphics.c - graphics mode support for GRUB */
453+/* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
454