?? grub-0.97-patch5-splash
字號:
@@ -8802,6 +8963,7 @@ &builtin_cdrom, #endif &builtin_chainloader,+ &builtin_clear, &builtin_cmp, &builtin_color, &builtin_commandline,@@ -8822,6 +8984,9 @@ &builtin_embed, &builtin_fallback, &builtin_find,+#ifdef SUPPORT_GRAPHICS+ &builtin_foreground,+#endif &builtin_fstest, &builtin_geometry, &builtin_halt,@@ -8870,9 +9035,12 @@ &builtin_setkey, &builtin_setup, &builtin_setvbe,-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)+#ifdef SUPPORT_GRAPHICS+ &builtin_splashimage,+#endif /* SUPPORT_GRAPHICS */+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS) &builtin_terminal,-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES SUPPORT_GRAPHICS */ #ifdef SUPPORT_SERIAL &builtin_terminfo, #endif /* SUPPORT_SERIAL */diff -Naur grub-0.97_emulation/stage2/char_io.c grub-0.97_splash/stage2/char_io.c--- grub-0.97_emulation/stage2/char_io.c 2006-10-24 12:28:51.000000000 +0800+++ grub-0.97_splash/stage2/char_io.c 2006-10-24 12:28:51.000000000 +0800@@ -35,6 +35,7 @@ { "console", 0,+ 24, console_putchar, console_checkkey, console_getkey,@@ -43,13 +44,16 @@ console_cls, console_setcolorstate, console_setcolor,- console_setcursor+ console_setcursor,+ 0,+ 0 }, #ifdef SUPPORT_SERIAL { "serial", /* A serial device must be initialized. */ TERM_NEED_INIT,+ 24, serial_putchar, serial_checkkey, serial_getkey,@@ -58,6 +62,8 @@ serial_cls, serial_setcolorstate, 0,+ 0,+ 0, 0 }, #endif /* SUPPORT_SERIAL */@@ -65,6 +71,7 @@ { "hercules", 0,+ 24, hercules_putchar, console_checkkey, console_getkey,@@ -73,9 +80,28 @@ hercules_cls, hercules_setcolorstate, hercules_setcolor,- hercules_setcursor+ hercules_setcursor,+ 0,+ 0 }, #endif /* SUPPORT_HERCULES */+#ifdef SUPPORT_GRAPHICS+ { "graphics",+ TERM_NEED_INIT, /* flags */+ 30, /* number of lines */+ graphics_putchar, /* putchar */+ console_checkkey, /* checkkey */+ console_getkey, /* getkey */+ graphics_getxy, /* getxy */+ graphics_gotoxy, /* gotoxy */+ graphics_cls, /* cls */+ graphics_setcolorstate, /* setcolorstate */+ graphics_setcolor, /* setcolor */+ graphics_setcursor, /* nocursor */+ graphics_init, /* initialize */+ graphics_end /* shutdown */+ },+#endif /* SUPPORT_GRAPHICS */ /* This must be the last entry. */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };@@ -1124,10 +1150,11 @@ the following grub_printf call will print newlines. */ count_lines = -1; + grub_printf("\n"); if (current_term->setcolorstate) current_term->setcolorstate (COLOR_STATE_HIGHLIGHT); - grub_printf ("\n[Hit return to continue]");+ grub_printf ("[Hit return to continue]"); if (current_term->setcolorstate) current_term->setcolorstate (COLOR_STATE_NORMAL);@@ -1318,6 +1345,55 @@ return ! errnum; } +#if 0+void+grub_memcpy(void *dest, const void *src, int len)+{+ int i;+ register char *d = (char*)dest, *s = (char*)src;++ for (i = 0; i < len; i++)+ d[i] = s[i];+}+#endif++/* struct copy needs the memcpy function */+/* #undef memcpy */+#if 1+void * grub_memcpy(void * to, const void * from, unsigned int n)+{+ /* This assembly code is stolen from+ * linux-2.4.22/include/asm-i386/string.h+ * It assumes ds=es=data space, this should be normal.+ */+ int d0, d1, d2;+ __asm__ __volatile__(+ "rep ; movsl\n\t"+ "testb $2,%b4\n\t"+ "je 1f\n\t"+ "movsw\n"+ "1:\ttestb $1,%b4\n\t"+ "je 2f\n\t"+ "movsb\n"+ "2:"+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)+ : "memory");+ return to;+}+#else+/* just in case the assembly version of grub_memcpy does not work. */+void * grub_memcpy(void * to, const void * from, unsigned int n)+{+ char *d = (char *)to, *s = (char *)from;++ while (n--)+ *d++ = *s++;++ return to;+}+#endif+ void * grub_memmove (void *to, const void *from, int len) {diff -Naur grub-0.97_emulation/stage2/graphics.c grub-0.97_splash/stage2/graphics.c--- grub-0.97_emulation/stage2/graphics.c 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_splash/stage2/graphics.c 2006-10-24 12:28:51.000000000 +0800@@ -0,0 +1,556 @@+/* graphics.c - graphics mode support for GRUB */+/* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based+ * on a patch by Paulo C閟ar Pereira de Andrade <pcpa@conectiva.com.br>+ */+/*+ * GRUB -- GRand Unified Bootloader+ * Copyright (C) 2001,2002 Red Hat, Inc.+ * Portions copyright (C) 2000 Conectiva, Inc.+ *+ * This program is free software; you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation; either version 2 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.+ */++++#ifdef SUPPORT_GRAPHICS++#include <term.h>+#include <shared.h>+#include <graphics.h>++int saved_videomode;+unsigned char *font8x16;++int graphics_inited = 0;+static char splashimage[64];++#define VSHADOW VSHADOW1+static unsigned char *VSHADOW1 = (unsigned char *)0x3A0000; //unsigned char VSHADOW1[38400];+static unsigned char *VSHADOW2 = (unsigned char *)0x3A9600; //unsigned char VSHADOW2[38400];+static unsigned char *VSHADOW4 = (unsigned char *)0x3B2C00; //unsigned char VSHADOW4[38400];+static unsigned char *VSHADOW8 = (unsigned char *)0x3BC200; //unsigned char VSHADOW8[38400];++/* constants to define the viewable area */+const int x0 = 0;+const int x1 = 80;+const int y0 = 0;+const int y1 = 30;++/* text buffer has to be kept around so that we can write things as we+ * scroll and the like */+static unsigned short text[80 * 30];++/* why do these have to be kept here? */+int foreground = (63 << 16) | (63 << 8) | (63), background = 0, border = 0;++/* current position */+static int fontx = 0;+static int fonty = 0;++/* global state so that we don't try to recursively scroll or cursor */+static int no_scroll = 0;++/* color state */+static int graphics_standard_color = A_NORMAL;+static int graphics_normal_color = A_NORMAL;+static int graphics_highlight_color = A_REVERSE;+static int graphics_current_color = A_NORMAL;+static color_state graphics_color_state = COLOR_STATE_STANDARD;+++/* graphics local functions */+static void graphics_setxy(int col, int row);+static void graphics_scroll(void);+static int read_image(char *s);++/* FIXME: where do these really belong? */+static inline void outb(unsigned short port, unsigned char val)+{+ __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));+}++static void MapMask(int value) {+ outb(0x3c4, 2);+ outb(0x3c5, value);+}++/* bit mask register */+static void BitMask(int value) {+ outb(0x3ce, 8);+ outb(0x3cf, value);+}++++/* Set the splash image */+void graphics_set_splash(char *splashfile) {+ grub_strcpy(splashimage, splashfile);+}++/* Get the current splash image */+char *graphics_get_splash(void) {+ return splashimage;+}++/* Initialize a vga16 graphics display with the palette based off of+ * the image in splashimage. If the image doesn't exist, leave graphics+ * mode. */+int graphics_init()+{+ if (! graphics_inited) {+ saved_videomode = set_videomode(0x12);+ }++ if (! read_image(splashimage)) {+ set_videomode(saved_videomode);+ grub_printf("failed to read image\n");+ return 0;+ }++ font8x16 = (unsigned char*)graphics_get_font();++ graphics_inited = 1;++ /* make sure that the highlight color is set correctly */+ graphics_highlight_color = ((graphics_normal_color >> 4) | + ((graphics_normal_color & 0xf) << 4));++ return 1;+}++/* Leave graphics mode */+void graphics_end(void)+{+ if (graphics_inited) {+ set_videomode(saved_videomode);+ graphics_inited = 0;+ }+}++/* Print ch on the screen. Handle any needed scrolling or the like */+void graphics_putchar(int ch) {+ ch &= 0xff;++ graphics_cursor(0);++ if (ch == '\n') {+ if (fonty + 1 < y1)+ graphics_setxy(fontx, fonty + 1);+ else+ graphics_scroll();+ graphics_cursor(1);+ return;+ } else if (ch == '\r') {+ graphics_setxy(x0, fonty);+ graphics_cursor(1);+ return;+ }++ graphics_cursor(0);++ text[fonty * 80 + fontx] = ch;+ text[fonty * 80 + fontx] &= 0x00ff;+ if (graphics_current_color & 0xf0)+ text[fonty * 80 + fontx] |= 0x100;++ graphics_cursor(0);++ if ((fontx + 1) >= x1) {+ graphics_setxy(x0, fonty);+ if (fonty + 1 < y1)+ graphics_setxy(x0, fonty + 1);+ else+ graphics_scroll();+ } else {+ graphics_setxy(fontx + 1, fonty);+ }++ graphics_cursor(1);+}++/* get the current location of the cursor */+int graphics_getxy(void) {+ return (fontx << 8) | fonty;+}++void graphics_gotoxy(int x, int y) {+ graphics_cursor(0);++ graphics_setxy(x, y);++ graphics_cursor(1);+}++void graphics_cls(void) {+ int i;+ unsigned char *mem, *s1, *s2, *s4, *s8;++ graphics_cursor(0);+ graphics_gotoxy(x0, y0);++ mem = (unsigned char*)VIDEOMEM;+ s1 = (unsigned char*)VSHADOW1;+ s2 = (unsigned char*)VSHADOW2;+ s4 = (unsigned char*)VSHADOW4;+ s8 = (unsigned char*)VSHADOW8;++ for (i = 0; i < 80 * 30; i++)+ text[i] = ' ';+ graphics_cursor(1);++ BitMask(0xff);++ /* plano 1 */+ MapMask(1);+ grub_memcpy(mem, s1, 38400);++ /* plano 2 */+ MapMask(2);+ grub_memcpy(mem, s2, 38400);++ /* plano 3 */+ MapMask(4);+ grub_memcpy(mem, s4, 38400);++ /* plano 4 */+ MapMask(8);+ grub_memcpy(mem, s8, 38400);++ MapMask(15);+ +}++void graphics_setcolorstate (color_state state) {+ switch (state) {+ case COLOR_STATE_STANDARD:+ graphics_current_color = graphics_standard_color;+ break;+ case COLOR_STATE_NORMAL:+ graphics_current_color = graphics_normal_color;+ break;+ case COLOR_STATE_HIGHLIGHT:+ graphics_current_color = graphics_highlight_color;+ break;+ default:+ graphics_current_color = graphics_standard_color;+ break;+ }++ graphics_color_state = state;+}++void graphics_setcolor (int normal_color, int highlight_color) {+ graphics_normal_color = normal_color;+ graphics_highlight_color = highlight_color;++ graphics_setcolorstate (graphics_color_state);+}++int graphics_setcursor (int on) {+ /* FIXME: we don't have a cursor in graphics */+ return 0;+}++/* Read in the splashscreen image and set the palette up appropriately.+ * Format of splashscreen is an xpm (can be gzipped) with 16 colors and+ * 640x480. */+static int+read_image(char *s)+{+ char buf[32], pal[16];+ unsigned char c, base, mask, *s1, *s2, *s4, *s8;+ unsigned i, len, idx, colors, x, y, width, height;++ if (! grub_open(s))+ goto set_palette; //return 0;++ /* read header */+ if (! grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {+ grub_close();+ goto set_palette; //return 0;+ }+ + /* parse info */+ while (grub_read((char *)&c, 1)) {+ if (c == '"')+ break;+ }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -