Fixes issue #498.
include $(PKGROOT)/Include
PKG_NAME = grub
-PKG_VER = 0.97
+PKG_VER = 1.98
PKG_REL = 0
PKG_MAINTAINER =
PKG_LICENSE = GPLv2+
PKG_SUMMARY = Grand Unified Boot Loader.
-PKG_BUILD_DEPS+= autoconf automake paxctl
-PKG_DEPS += ncurses
+PKG_BUILD_DEPS+= autoconf automake bison paxctl
+PKG_DEPS += freetype ncurses
define PKG_DESCRIPTION
GRUB (Grand Unified Boot Loader) is an experimental boot loader \
PKG_TARBALL = $(THISAPP).tar.gz
-# Manual list patches because they need to be applied in speical order
-PKG_PATCHES = $(THISAPP)-disk_geometry-1.patch
-PKG_PATCHES += grub-0.95-graphics.patch
-PKG_PATCHES += grub-0.91-splashimagehelp.patch
-PKG_PATCHES += grub-0.93-graphics-bootterm.patch
-PKG_PATCHES += grub-0.95-xpmjunk.patch
-PKG_PATCHES += grub-0.95-splash-error-term.patch
-PKG_PATCHES += grub-0.93-special-device-names.patch
-PKG_PATCHES += grub-0.95-moreraid.patch
-PKG_PATCHES += grub-0.94-i2o.patch
-PKG_PATCHES += grub-0.93-configfile.patch
-PKG_PATCHES += $(THISAPP)-256byte_inode-1.patch
-PKG_PATCHES += $(THISAPP)-install.in.patch
-PKG_PATCHES += grub-0.94-installcopyonly.patch
-PKG_PATCHES += $(THISAPP)-ext4-1.patch
-
define QUALITY_AGENT_WHITELIST_EXECSTACK
/usr/sbin/grub
endef
-CFLAGS += -fno-strict-aliasing -fno-stack-protector -fno-pic -fno-pie -nopie
-CXXFLAGS =
-
-###############################################################################
-# Installation Details
-###############################################################################
-
-define STAGE_PREPARE_CMDS
- cd $(DIR_APP) && autoconf
-endef
+#CFLAGS += -fno-strict-aliasing -fno-stack-protector -fno-pic -fno-pie -nopie
+#CXXFLAGS =
define STAGE_BUILD
cd $(DIR_APP) && \
grub_cv_prog_objcopy_absolute=yes \
./configure \
--prefix=/usr \
- --mandir=/usr/share/man
+ --sysconfdir=/etc
cd $(DIR_APP) && make $(PARALLELISMFLAGS)
endef
for i in $(DIR_SOURCE)/{grub.conf,splash.xpm.gz}; do \
cp -vf $$i $(BUILDROOT)/boot/grub; \
done
-
- # Grub uses anonymous mapping and will be killed by PaX.
- # The following command changes Grub's PaX flags:
- paxctl -spme $(BUILDROOT)/usr/sbin/grub
endef
+++ /dev/null
-diff -ur grub-0.91/docs/grub.texi grub/docs/grub.texi
---- grub-0.91/docs/grub.texi Mon Jan 21 22:57:46 2002
-+++ grub/docs/grub.texi Mon Jan 21 22:57:51 2002
-@@ -1891,6 +1891,7 @@
- * rarp:: Initialize a network device via RARP
- * serial:: Set up a serial device
- * setkey:: Configure the key map
-+* splashimage:: Use a splash image
- * terminal:: Choose a terminal
- * tftpserver:: Specify a TFTP server
- * unhide:: Unhide a partition
-@@ -2260,6 +2261,16 @@
- @end deffn
-
-
-+@node splashimage
-+@subsection splashimage
-+
-+@deffn Command splashimage file
-+Select an image to use as the background image. This should be
-+specified using normal GRUB device naming syntax. The format of the
-+file is a gzipped xpm which is 640x480 with a 14 color palette.
-+@end deffn
-+
-+
- @node terminal
- @subsection terminal
-
+++ /dev/null
---- grub-0.93/stage2/asm.S.config 2002-12-02 18:18:56.000000000 -0500
-+++ grub-0.93/stage2/asm.S 2002-12-28 22:01:24.000000000 -0500
-@@ -97,7 +97,7 @@
- .string VERSION
- VARIABLE(config_file)
- #ifndef STAGE1_5
-- .string "/boot/grub/menu.lst"
-+ .string "/boot/grub/grub.conf"
- #else /* STAGE1_5 */
- .long 0xffffffff
- .string "/boot/grub/stage2"
---- grub-0.93/stage2/builtins.c.config 2002-12-03 23:41:57.000000000 -0500
-+++ grub-0.93/stage2/builtins.c 2002-12-28 22:01:24.000000000 -0500
-@@ -3838,7 +3838,7 @@
-
- /* The prefix was determined. */
- grub_sprintf (stage2, "%s%s", prefix, "/stage2");
-- grub_sprintf (config_filename, "%s%s", prefix, "/menu.lst");
-+ grub_sprintf (config_filename, "%s%s", prefix, "/grub.conf");
- *real_config_filename = 0;
-
- /* Check if stage2 exists. */
---- grub-0.93/grub/asmstub.c.config 2002-12-02 18:20:45.000000000 -0500
-+++ grub-0.93/grub/asmstub.c 2002-12-28 22:01:24.000000000 -0500
-@@ -71,7 +71,7 @@
- unsigned long boot_drive = 0;
- int saved_entryno = 0;
- char version_string[] = VERSION;
--char config_file[128] = "/boot/grub/menu.lst"; /* FIXME: arbitrary */
-+char config_file[128] = "/boot/grub/grub.conf"; /* FIXME: arbitrary */
- unsigned long linux_text_len = 0;
- char *linux_data_tmp_addr = 0;
- char *linux_data_real_addr = 0;
---- grub-0.93/docs/grub.8.config 2002-12-07 22:17:59.000000000 -0500
-+++ grub-0.93/docs/grub.8 2002-12-28 22:01:24.000000000 -0500
-@@ -15,7 +15,7 @@
- specify stage2 boot_drive [default=0x0]
- .TP
- \fB\-\-config\-file\fR=\fIFILE\fR
--specify stage2 config_file [default=/boot/grub/menu.lst]
-+specify stage2 config_file [default=/boot/grub/grub.conf]
- .TP
- \fB\-\-device\-map\fR=\fIFILE\fR
- use the device map file FILE
---- grub-0.93/docs/grub.texi.config 2002-12-02 17:35:28.000000000 -0500
-+++ grub-0.93/docs/grub.texi 2002-12-28 22:01:24.000000000 -0500
-@@ -989,7 +989,7 @@
- keys) that will do everything to boot an OS.
-
- To enable the menu, you need a configuration file,
--@file{menu.lst} under the boot directory. We'll analyze an example
-+@file{grub.conf} under the boot directory. We'll analyze an example
- file.
-
- The file first contains some general settings, the menu interface
-@@ -1596,8 +1596,8 @@
-
- An absolute file name resembles a Unix absolute file name, using
- @samp{/} for the directory separator (not @samp{\} as in DOS). One
--example is @samp{(hd0,0)/boot/grub/menu.lst}. This means the file
--@file{/boot/grub/menu.lst} in the first partition of the first hard
-+example is @samp{(hd0,0)/boot/grub/grub.conf}. This means the file
-+@file{/boot/grub/grub.conf} in the first partition of the first hard
- disk. If you omit the device name in an absolute file name, GRUB uses
- GRUB's @dfn{root device} implicitly. So if you set the root device to,
- say, @samp{(hd1,0)} by the command @command{root} (@pxref{root}), then
-@@ -3249,7 +3249,7 @@
-
- @item --config-file=@var{file}
- Read the configuration file @var{file} instead of
--@file{/boot/grub/menu.lst}. The format is the same as the normal GRUB
-+@file{/boot/grub/grub.conf}. The format is the same as the normal GRUB
- syntax. See @ref{Filesystem}, for more information.
-
- @item --boot-drive=@var{drive}
+++ /dev/null
---- grub-0.93/stage2/builtins.c.bootterm 2002-12-29 02:01:50.000000000 -0500
-+++ grub-0.93/stage2/builtins.c 2002-12-29 02:01:07.000000000 -0500
-@@ -233,12 +233,22 @@
- static int
- boot_func (char *arg, int flags)
- {
-+ struct term_entry *prev_term = current_term;
- /* Clear the int15 handler if we can boot the kernel successfully.
- This assumes that the boot code never fails only if KERNEL_TYPE is
- not KERNEL_TYPE_NONE. Is this assumption is bad? */
- if (kernel_type != KERNEL_TYPE_NONE)
- unset_int15_handler ();
-
-+ /* if our terminal needed initialization, we should shut it down
-+ * before booting the kernel, but we want to save what it was so
-+ * we can come back if needed */
-+ if (current_term->shutdown)
-+ {
-+ (*current_term->shutdown)();
-+ current_term = term_table; /* assumption: console is first */
-+ }
-+
- #ifdef SUPPORT_NETBOOT
- /* Shut down the networking. */
- cleanup_net ();
-@@ -302,6 +312,13 @@
- return 1;
- }
-
-+ /* if we get back here, we should go back to what our term was before */
-+ current_term = prev_term;
-+ if (current_term->startup)
-+ /* if our terminal fails to initialize, fall back to console since
-+ * it should always work */
-+ if ((*current_term->startup)() == 0)
-+ current_term = term_table; /* we know that console is first */
- return 0;
- }
-
+++ /dev/null
---- grub-0.93/lib/device.c.raid 2002-05-20 05:53:46.000000000 -0400
-+++ grub-0.93/lib/device.c 2002-12-28 23:24:10.000000000 -0500
-@@ -689,7 +689,14 @@
- if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
- strcpy (dev + strlen(dev) - 5, "/part");
- }
-- sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
-+
-+ sprintf (dev + strlen(dev), "%s%d",
-+ /* Compaq smart and others */
-+ (strncmp(dev, "/dev/ida/", 9) == 0 ||
-+ strncmp(dev, "/dev/ataraid/", 13) == 0 ||
-+ strncmp(dev, "/dev/cciss/", 11) == 0 ||
-+ strncmp(dev, "/dev/rd/", 8) == 0) ? "p" : "",
-+ ((partition >> 16) & 0xFF) + 1);
-
- /* Open the partition. */
- fd = open (dev, O_RDWR);
+++ /dev/null
-Only in grub-0.94/docs: grub.info
-Only in grub-0.94/docs: multiboot.info
-diff -ur grub-0.94/lib/device.c grub-0.94.new/lib/device.c
---- grub-0.94/lib/device.c 2004-05-07 04:50:36.375238696 +0200
-+++ grub-0.94.new/lib/device.c 2004-05-07 04:48:57.611253104 +0200
-@@ -419,6 +419,12 @@
- {
- sprintf (name, "/dev/rd/c%dd%d", controller, drive);
- }
-+
-+static void
-+get_i2o_disk_name (char *name, int unit)
-+{
-+ sprintf (name, "/dev/i2o/hd%c", unit + 'a');
-+}
- #endif
-
- /* Check if DEVICE can be read. If an error occurs, return zero,
-@@ -789,6 +795,26 @@
- }
- }
- }
-+
-+ /* I2O disks. */
-+ for (i = 0; i < 8; i++)
-+ {
-+ char name[16];
-+
-+ get_i2o_disk_name (name, i);
-+ if (check_device (name))
-+ {
-+ (*map)[num_hd + 0x80] = strdup (name);
-+ assert ((*map)[num_hd + 0x80]);
-+
-+ /* If the device map file is opened, write the map. */
-+ if (fp)
-+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
-+
-+ num_hd++;
-+ }
-+ }
-+
- #endif /* __linux__ */
-
- /* OK, close the device map file if opened. */
+++ /dev/null
---- grub-0.94/util/grub-install.in.copyonly 2004-02-02 16:33:29.172127985 -0500
-+++ grub-0.94/util/grub-install.in 2004-02-02 16:34:26.027454320 -0500
-@@ -40,6 +40,7 @@
- force_lba=
- recheck=no
- debug=no
-+justcopy=no
-
- # look for secure tempfile creation wrappers on this platform
- if test -x /bin/tempfile; then
-@@ -221,6 +222,17 @@
- echo "$tmp_fname"
- }
-
-+copy_images() {
-+ # Copy the GRUB images to the GRUB directory.
-+ for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
-+ rm -f $file || exit 1
-+ done
-+ for file in \
-+ ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do
-+ cp -f $file ${grubdir} || exit 1
-+ done
-+}
-+
- # Check the arguments.
- for option in "$@"; do
- case "$option" in
-@@ -240,6 +252,8 @@
- force_lba="--force-lba" ;;
- --recheck)
- recheck=yes ;;
-+ --just-copy)
-+ justcopy=yes ;;
- # This is an undocumented feature...
- --debug)
- debug=yes ;;
-@@ -258,12 +272,6 @@
- esac
- done
-
--if test "x$install_device" = x; then
-- echo "install_device not specified." 1>&2
-- usage
-- exit 1
--fi
--
- # If the debugging feature is enabled, print commands.
- if test $debug = yes; then
- set -x
-@@ -286,6 +294,18 @@
- grubdir=${bootdir}/grub
- device_map=${grubdir}/device.map
-
-+# if they just want the images copied, copy the images and then exit
-+if test $justcopy = yes; then
-+ copy_images
-+ exit 0
-+fi
-+
-+if test "x$install_device" = x; then
-+ echo "install_device not specified." 1>&2
-+ usage
-+ exit 1
-+fi
-+
- # Check if GRUB is installed.
- # This is necessary, because the user can specify "grub --read-only".
- set $grub_shell dummy
-@@ -317,14 +337,7 @@
- test -d "$bootdir" || mkdir "$bootdir" || exit 1
- test -d "$grubdir" || mkdir "$grubdir" || exit 1
-
--# Copy the GRUB images to the GRUB directory.
--for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
-- rm -f $file || exit 1
--done
--for file in \
-- ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do
-- cp -f $file ${grubdir} || exit 1
--done
-+copy_images
-
- # If --recheck is specified, remove the device map, if present.
- if test $recheck = yes; then
+++ /dev/null
---- grub-0.95/stage2/asm.S.graphics 2004-06-18 17:35:51.932054040 -0400
-+++ grub-0.95/stage2/asm.S 2004-06-18 17:35:52.473971656 -0400
-@@ -2215,6 +2215,156 @@
- pop %ebx
- pop %ebp
- ret
-+
-+/* graphics mode functions */
-+#ifdef SUPPORT_GRAPHICS
-+VARIABLE(cursorX)
-+.word 0
-+VARIABLE(cursorY)
-+.word 0
-+VARIABLE(cursorCount)
-+.word 0
-+VARIABLE(cursorBuf)
-+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-+
-+
-+/*
-+ * int set_videomode(mode)
-+ * BIOS call "INT 10H Function 0h" to set video mode
-+ * Call with %ah = 0x0
-+ * %al = video mode
-+ * Returns old videomode.
-+ */
-+ENTRY(set_videomode)
-+ push %ebp
-+ push %ebx
-+ push %ecx
-+
-+ movb 0x10(%esp), %cl
-+
-+ call EXT_C(prot_to_real)
-+ .code16
-+
-+ xorw %bx, %bx
-+ movb $0xf, %ah
-+ int $0x10 /* Get Current Video mode */
-+ movb %al, %ch
-+ xorb %ah, %ah
-+ movb %cl, %al
-+ int $0x10 /* Set Video mode */
-+
-+ DATA32 call EXT_C(real_to_prot)
-+ .code32
-+
-+ xorb %ah, %ah
-+ movb %ch, %al
-+
-+ pop %ecx
-+ pop %ebx
-+ pop %ebp
-+ ret
-+
-+
-+/*
-+ * unsigned char * graphics_get_font()
-+ * BIOS call "INT 10H Function 11h" to set font
-+ * Call with %ah = 0x11
-+ */
-+ENTRY(graphics_get_font)
-+ push %ebp
-+ push %ebx
-+ push %ecx
-+ push %edx
-+
-+ call EXT_C(prot_to_real)
-+ .code16
-+
-+ movw $0x1130, %ax
-+ movb $6, %bh /* font 8x16 */
-+ int $0x10
-+ movw %bp, %dx
-+ movw %es, %cx
-+
-+ DATA32 call EXT_C(real_to_prot)
-+ .code32
-+
-+ xorl %eax, %eax
-+ movw %cx, %ax
-+ shll $4, %eax
-+ movw %dx, %ax
-+
-+ pop %edx
-+ pop %ecx
-+ pop %ebx
-+ pop %ebp
-+ ret
-+
-+
-+
-+/*
-+ * graphics_set_palette(index, red, green, blue)
-+ * BIOS call "INT 10H Function 10h" to set individual dac register
-+ * Call with %ah = 0x10
-+ * %bx = register number
-+ * %ch = new value for green (0-63)
-+ * %cl = new value for blue (0-63)
-+ * %dh = new value for red (0-63)
-+ */
-+
-+ENTRY(graphics_set_palette)
-+ push %ebp
-+ push %eax
-+ push %ebx
-+ push %ecx
-+ push %edx
-+
-+ movw $0x3c8, %bx /* address write mode register */
-+
-+ /* wait vertical retrace */
-+
-+ movw $0x3da, %dx
-+l1b: inb %dx, %al /* wait vertical active display */
-+ test $8, %al
-+ jnz l1b
-+
-+l2b: inb %dx, %al /* wait vertical retrace */
-+ test $8, %al
-+ jnz l2b
-+
-+ mov %bx, %dx
-+ movb 0x18(%esp), %al /* index */
-+ outb %al, %dx
-+ inc %dx
-+
-+ movb 0x1c(%esp), %al /* red */
-+ outb %al, %dx
-+
-+ movb 0x20(%esp), %al /* green */
-+ outb %al, %dx
-+
-+ movb 0x24(%esp), %al /* blue */
-+ outb %al, %dx
-+
-+ movw 0x18(%esp), %bx
-+
-+ call EXT_C(prot_to_real)
-+ .code16
-+
-+ movb %bl, %bh
-+ movw $0x1000, %ax
-+ int $0x10
-+
-+ DATA32 call EXT_C(real_to_prot)
-+ .code32
-+
-+ pop %edx
-+ pop %ecx
-+ pop %ebx
-+ pop %eax
-+ pop %ebp
-+ ret
-+
-+#endif /* SUPPORT_GRAPHICS */
-
- /*
- * getrtsecs()
---- grub-0.95/stage2/stage2.c.graphics 2004-06-18 17:35:52.314995824 -0400
-+++ grub-0.95/stage2/stage2.c 2004-06-18 17:35:52.494968464 -0400
-@@ -233,6 +233,7 @@
- {
- int c, time1, time2 = -1, first_entry = 0;
- char *cur_entry = 0;
-+ struct term_entry *prev_term = NULL;
-
- /*
- * Main loop for menu UI.
-@@ -807,6 +808,15 @@
-
- cls ();
- setcursor (1);
-+ /* if our terminal needed initialization, we should shut it down
-+ * before booting the kernel, but we want to save what it was so
-+ * we can come back if needed */
-+ prev_term = current_term;
-+ if (current_term->shutdown)
-+ {
-+ (*current_term->shutdown)();
-+ current_term = term_table; /* assumption: console is first */
-+ }
-
- while (1)
- {
-@@ -838,6 +848,13 @@
- break;
- }
-
-+ /* if we get back here, we should go back to what our term was before */
-+ current_term = prev_term;
-+ if (current_term->startup)
-+ /* if our terminal fails to initialize, fall back to console since
-+ * it should always work */
-+ if ((*current_term->startup)() == 0)
-+ current_term = term_table; /* we know that console is first */
- show_menu = 1;
- goto restart;
- }
-@@ -1082,6 +1099,10 @@
- while (is_preset);
- }
-
-+ /* go ahead and make sure the terminal is setup */
-+ if (current_term->startup)
-+ (*current_term->startup)();
-+
- if (! num_entries)
- {
- /* If no acceptable config file, goto command-line, starting
---- grub-0.95/stage2/builtins.c.graphics 2004-06-18 17:35:52.370987312 -0400
-+++ grub-0.95/stage2/builtins.c 2004-06-18 17:35:52.482970288 -0400
-@@ -858,6 +858,138 @@
- };
- #endif /* SUPPORT_NETBOOT */
-
-+static int terminal_func (char *arg, int flags);
-+
-+#ifdef SUPPORT_GRAPHICS
-+\f
-+static int splashimage_func(char *arg, int flags) {
-+ char splashimage[64];
-+ int i;
-+
-+ /* filename can only be 64 characters due to our buffer size */
-+ if (strlen(arg) > 63)
-+ return 1;
-+ if (flags == BUILTIN_CMDLINE) {
-+ if (!grub_open(arg))
-+ return 1;
-+ grub_close();
-+ }
-+
-+ strcpy(splashimage, arg);
-+
-+ /* get rid of TERM_NEED_INIT from the graphics terminal. */
-+ for (i = 0; term_table[i].name; i++) {
-+ if (grub_strcmp (term_table[i].name, "graphics") == 0) {
-+ term_table[i].flags &= ~TERM_NEED_INIT;
-+ break;
-+ }
-+ }
-+
-+ graphics_set_splash(splashimage);
-+
-+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
-+ graphics_end();
-+ graphics_init();
-+ graphics_cls();
-+ }
-+
-+ /* FIXME: should we be explicitly switching the terminal as a
-+ * side effect here? */
-+ terminal_func("graphics", flags);
-+
-+ return 0;
-+}
-+
-+static struct builtin builtin_splashimage =
-+{
-+ "splashimage",
-+ splashimage_func,
-+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
-+ "splashimage FILE",
-+ "Load FILE as the background image when in graphics mode."
-+};
-+
-+\f
-+/* foreground */
-+static int
-+foreground_func(char *arg, int flags)
-+{
-+ if (grub_strlen(arg) == 6) {
-+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
-+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
-+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
-+
-+ foreground = (r << 16) | (g << 8) | b;
-+ if (graphics_inited)
-+ graphics_set_palette(15, r, g, b);
-+
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+static struct builtin builtin_foreground =
-+{
-+ "foreground",
-+ foreground_func,
-+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
-+ "foreground RRGGBB",
-+ "Sets the foreground color when in graphics mode."
-+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
-+};
-+
-+\f
-+/* background */
-+static int
-+background_func(char *arg, int flags)
-+{
-+ if (grub_strlen(arg) == 6) {
-+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
-+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
-+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
-+
-+ background = (r << 16) | (g << 8) | b;
-+ if (graphics_inited)
-+ graphics_set_palette(0, r, g, b);
-+ return (0);
-+ }
-+
-+ return (1);
-+}
-+
-+static struct builtin builtin_background =
-+{
-+ "background",
-+ background_func,
-+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
-+ "background RRGGBB",
-+ "Sets the background color when in graphics mode."
-+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
-+};
-+
-+#endif /* SUPPORT_GRAPHICS */
-+
-+\f
-+/* clear */
-+static int
-+clear_func()
-+{
-+ if (current_term->cls)
-+ current_term->cls();
-+
-+ return 0;
-+}
-+
-+static struct builtin builtin_clear =
-+{
-+ "clear",
-+ clear_func,
-+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
-+ "clear",
-+ "Clear the screen"
-+};
-+
- \f
- /* displayapm */
- static int
-@@ -4090,7 +4222,7 @@
- };
-
- \f
--#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
-+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
- /* terminal */
- static int
- terminal_func (char *arg, int flags)
-@@ -4249,17 +4381,21 @@
- end:
- current_term = term_table + default_term;
- current_term->flags = term_flags;
--
-+
- if (lines)
- max_lines = lines;
- else
-- /* 24 would be a good default value. */
-- max_lines = 24;
--
-+ max_lines = current_term->max_lines;
-+
- /* If the interface is currently the command-line,
- restart it to repaint the screen. */
-- if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
-+ if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
-+ if (prev_term->shutdown)
-+ prev_term->shutdown();
-+ if (current_term->startup)
-+ current_term->startup();
- grub_longjmp (restart_cmdline_env, 0);
-+ }
-
- return 0;
- }
-@@ -4269,7 +4405,7 @@
- "terminal",
- terminal_func,
- BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
-- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
-+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
- "Select a terminal. When multiple terminals are specified, wait until"
- " you push any key to continue. If both console and serial are specified,"
- " the terminal to which you input a key first will be selected. If no"
-@@ -4281,7 +4417,7 @@
- " seconds. The option --lines specifies the maximum number of lines."
- " The option --silent is used to suppress messages."
- };
--#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
-+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
-
- \f
- #ifdef SUPPORT_SERIAL
-@@ -4809,6 +4945,9 @@
- /* The table of builtin commands. Sorted in dictionary order. */
- struct builtin *builtin_table[] =
- {
-+#ifdef SUPPORT_GRAPHICS
-+ &builtin_background,
-+#endif
- &builtin_blocklist,
- &builtin_boot,
- #ifdef SUPPORT_NETBOOT
-@@ -4816,6 +4955,7 @@
- #endif /* SUPPORT_NETBOOT */
- &builtin_cat,
- &builtin_chainloader,
-+ &builtin_clear,
- &builtin_cmp,
- &builtin_color,
- &builtin_configfile,
-@@ -4835,6 +4975,9 @@
- &builtin_embed,
- &builtin_fallback,
- &builtin_find,
-+#ifdef SUPPORT_GRAPHICS
-+ &builtin_foreground,
-+#endif
- &builtin_fstest,
- &builtin_geometry,
- &builtin_halt,
-@@ -4878,9 +5021,12 @@
- #endif /* SUPPORT_SERIAL */
- &builtin_setkey,
- &builtin_setup,
--#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 */
---- /dev/null 2004-02-23 16:02:56.000000000 -0500
-+++ grub-0.95/stage2/graphics.c 2004-06-18 17:35:52.488969376 -0400
-@@ -0,0 +1,552 @@
-+/* 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ésar 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
-+unsigned char VSHADOW1[38400];
-+unsigned char VSHADOW2[38400];
-+unsigned char VSHADOW4[38400];
-+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 */
-+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();
-+
-+/* 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);
-+}
-+
-+void graphics_setcursor (int on) {
-+ /* FIXME: we don't have a cursor in graphics */
-+ return;
-+}
-+
-+/* 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. */
-+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))
-+ return 0;
-+
-+ /* read header */
-+ if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
-+ grub_close();
-+ return 0;
-+ }
-+
-+ /* parse info */
-+ while (grub_read(&c, 1)) {
-+ if (c == '"')
-+ break;
-+ }
-+
-+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
-+ ;
-+
-+ i = 0;
-+ width = c - '0';
-+ while (grub_read(&c, 1)) {
-+ if (c >= '0' && c <= '9')
-+ width = width * 10 + c - '0';
-+ else
-+ break;
-+ }
-+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
-+ ;
-+
-+ height = c - '0';
-+ while (grub_read(&c, 1)) {
-+ if (c >= '0' && c <= '9')
-+ height = height * 10 + c - '0';
-+ else
-+ break;
-+ }
-+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
-+ ;
-+
-+ colors = c - '0';
-+ while (grub_read(&c, 1)) {
-+ if (c >= '0' && c <= '9')
-+ colors = colors * 10 + c - '0';
-+ else
-+ break;
-+ }
-+
-+ base = 0;
-+ while (grub_read(&c, 1) && c != '"')
-+ ;
-+
-+ /* palette */
-+ for (i = 0, idx = 1; i < colors; i++) {
-+ len = 0;
-+
-+ while (grub_read(&c, 1) && c != '"')
-+ ;
-+ grub_read(&c, 1); /* char */
-+ base = c;
-+ grub_read(buf, 4); /* \t c # */
-+
-+ while (grub_read(&c, 1) && c != '"') {
-+ if (len < sizeof(buf))
-+ buf[len++] = c;
-+ }
-+
-+ if (len == 6 && idx < 15) {
-+ int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
-+ int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
-+ int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
-+
-+ pal[idx] = base;
-+ graphics_set_palette(idx, r, g, b);
-+ ++idx;
-+ }
-+ }
-+
-+ x = y = len = 0;
-+
-+ s1 = (unsigned char*)VSHADOW1;
-+ s2 = (unsigned char*)VSHADOW2;
-+ s4 = (unsigned char*)VSHADOW4;
-+ s8 = (unsigned char*)VSHADOW8;
-+
-+ for (i = 0; i < 38400; i++)
-+ s1[i] = s2[i] = s4[i] = s8[i] = 0;
-+
-+ /* parse xpm data */
-+ while (y < height) {
-+ while (1) {
-+ if (!grub_read(&c, 1)) {
-+ grub_close();
-+ return 0;
-+ }
-+ if (c == '"')
-+ break;
-+ }
-+
-+ while (grub_read(&c, 1) && c != '"') {
-+ for (i = 1; i < 15; i++)
-+ if (pal[i] == c) {
-+ c = i;
-+ break;
-+ }
-+
-+ mask = 0x80 >> (x & 7);
-+ if (c & 1)
-+ s1[len + (x >> 3)] |= mask;
-+ if (c & 2)
-+ s2[len + (x >> 3)] |= mask;
-+ if (c & 4)
-+ s4[len + (x >> 3)] |= mask;
-+ if (c & 8)
-+ s8[len + (x >> 3)] |= mask;
-+
-+ if (++x >= 640) {
-+ x = 0;
-+
-+ if (y < 480)
-+ len += 80;
-+ ++y;
-+ }
-+ }
-+ }
-+
-+ grub_close();
-+
-+ graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
-+ background & 63);
-+ graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
-+ foreground & 63);
-+ graphics_set_palette(0x11, (border >> 16), (border >> 8) & 63,
-+ border & 63);
-+
-+ return 1;
-+}
-+
-+
-+/* Convert a character which is a hex digit to the appropriate integer */
-+int hex(int v)
-+{
-+ if (v >= 'A' && v <= 'F')
-+ return (v - 'A' + 10);
-+ if (v >= 'a' && v <= 'f')
-+ return (v - 'a' + 10);
-+ return (v - '0');
-+}
-+
-+
-+/* move the graphics cursor location to col, row */
-+static void graphics_setxy(int col, int row) {
-+ if (col >= x0 && col < x1) {
-+ fontx = col;
-+ cursorX = col << 3;
-+ }
-+ if (row >= y0 && row < y1) {
-+ fonty = row;
-+ cursorY = row << 4;
-+ }
-+}
-+
-+/* scroll the screen */
-+static void graphics_scroll() {
-+ int i, j;
-+
-+ /* we don't want to scroll recursively... that would be bad */
-+ if (no_scroll)
-+ return;
-+ no_scroll = 1;
-+
-+ /* move everything up a line */
-+ for (j = y0 + 1; j < y1; j++) {
-+ graphics_gotoxy(x0, j - 1);
-+ for (i = x0; i < x1; i++) {
-+ graphics_putchar(text[j * 80 + i]);
-+ }
-+ }
-+
-+ /* last line should be blank */
-+ graphics_gotoxy(x0, y1 - 1);
-+ for (i = x0; i < x1; i++)
-+ graphics_putchar(' ');
-+ graphics_setxy(x0, y1 - 1);
-+
-+ no_scroll = 0;
-+}
-+
-+
-+void graphics_cursor(int set) {
-+ unsigned char *pat, *mem, *ptr, chr[16 << 2];
-+ int i, ch, invert, offset;
-+
-+ if (set && no_scroll)
-+ return;
-+
-+ offset = cursorY * 80 + fontx;
-+ ch = text[fonty * 80 + fontx] & 0xff;
-+ invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
-+ pat = font8x16 + (ch << 4);
-+
-+ mem = (unsigned char*)VIDEOMEM + offset;
-+
-+ if (!set) {
-+ for (i = 0; i < 16; i++) {
-+ unsigned char mask = pat[i];
-+
-+ if (!invert) {
-+ chr[i ] = ((unsigned char*)VSHADOW1)[offset];
-+ chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
-+ chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
-+ chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
-+
-+ /* FIXME: if (shade) */
-+ if (1) {
-+ if (ch == DISP_VERT || ch == DISP_LL ||
-+ ch == DISP_UR || ch == DISP_LR) {
-+ unsigned char pmask = ~(pat[i] >> 1);
-+
-+ chr[i ] &= pmask;
-+ chr[16 + i] &= pmask;
-+ chr[32 + i] &= pmask;
-+ chr[48 + i] &= pmask;
-+ }
-+ if (i > 0 && ch != DISP_VERT) {
-+ unsigned char pmask = ~(pat[i - 1] >> 1);
-+
-+ chr[i ] &= pmask;
-+ chr[16 + i] &= pmask;
-+ chr[32 + i] &= pmask;
-+ chr[48 + i] &= pmask;
-+ if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
-+ pmask = ~pat[i - 1];
-+
-+ chr[i ] &= pmask;
-+ chr[16 + i] &= pmask;
-+ chr[32 + i] &= pmask;
-+ chr[48 + i] &= pmask;
-+ }
-+ }
-+ }
-+ chr[i ] |= mask;
-+ chr[16 + i] |= mask;
-+ chr[32 + i] |= mask;
-+ chr[48 + i] |= mask;
-+
-+ offset += 80;
-+ }
-+ else {
-+ chr[i ] = mask;
-+ chr[16 + i] = mask;
-+ chr[32 + i] = mask;
-+ chr[48 + i] = mask;
-+ }
-+ }
-+ }
-+ else {
-+ MapMask(15);
-+ ptr = mem;
-+ for (i = 0; i < 16; i++, ptr += 80) {
-+ cursorBuf[i] = pat[i];
-+ *ptr = ~pat[i];
-+ }
-+ return;
-+ }
-+
-+ offset = 0;
-+ for (i = 1; i < 16; i <<= 1, offset += 16) {
-+ int j;
-+
-+ MapMask(i);
-+ ptr = mem;
-+ for (j = 0; j < 16; j++, ptr += 80)
-+ *ptr = chr[j + offset];
-+ }
-+
-+ MapMask(15);
-+}
-+
-+#endif /* SUPPORT_GRAPHICS */
---- grub-0.95/stage2/Makefile.am.graphics 2004-06-13 13:57:27.000000000 -0400
-+++ grub-0.95/stage2/Makefile.am 2004-06-18 17:36:58.289966104 -0400
-@@ -7,7 +7,7 @@
- fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
- imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
- nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
-- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
-+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
- EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
-
- # For <stage1.h>.
-@@ -19,7 +19,7 @@
- disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
- fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
- fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
-- terminfo.c tparm.c
-+ terminfo.c tparm.c graphics.c
- libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
- -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
- -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
-@@ -80,8 +80,14 @@
- HERCULES_FLAGS =
- endif
-
-+if GRAPHICS_SUPPORT
-+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
-+else
-+GRAPHICS_FLAGS =
-+endif
-+
- STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
-- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
-+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
-
- STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
- STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
-@@ -91,7 +97,8 @@
- cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
- fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
- fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
-- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
-+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
-+ graphics.c
- pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
- pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
- pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
---- grub-0.95/stage2/term.h.graphics 2003-07-09 07:45:53.000000000 -0400
-+++ grub-0.95/stage2/term.h 2004-06-18 17:35:52.496968160 -0400
-@@ -60,6 +60,8 @@
- const char *name;
- /* The feature flags defined above. */
- unsigned long flags;
-+ /* Default for maximum number of lines if not specified */
-+ unsigned short max_lines;
- /* Put a character. */
- void (*putchar) (int c);
- /* Check if any input character is available. */
-@@ -79,6 +81,11 @@
- void (*setcolor) (int normal_color, int highlight_color);
- /* Turn on/off the cursor. */
- int (*setcursor) (int on);
-+
-+ /* function to start a terminal */
-+ int (*startup) (void);
-+ /* function to use to shutdown a terminal */
-+ void (*shutdown) (void);
- };
-
- /* This lists up available terminals. */
-@@ -124,4 +131,23 @@
- int hercules_setcursor (int on);
- #endif
-
-+#ifdef SUPPORT_GRAPHICS
-+extern int foreground, background, border, graphics_inited;
-+
-+void graphics_set_splash(char *splashfile);
-+int set_videomode (int mode);
-+void graphics_putchar (int c);
-+int graphics_getxy(void);
-+void graphics_gotoxy(int x, int y);
-+void graphics_cls(void);
-+void graphics_setcolorstate (color_state state);
-+void graphics_setcolor (int normal_color, int highlight_color);
-+void graphics_setcursor (int on);
-+int graphics_init(void);
-+void graphics_end(void);
-+
-+int hex(int v);
-+void graphics_set_palette(int idx, int red, int green, int blue);
-+#endif /* SUPPORT_GRAPHICS */
-+
- #endif /* ! GRUB_TERM_HEADER */
---- /dev/null 2004-02-23 16:02:56.000000000 -0500
-+++ grub-0.95/stage2/graphics.h 2004-06-18 17:35:52.490969072 -0400
-@@ -0,0 +1,42 @@
-+/* graphics.h - graphics console interface */
-+/*
-+ * GRUB -- GRand Unified Bootloader
-+ * Copyright (C) 2002 Free Software Foundation, 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.
-+ */
-+
-+#ifndef GRAPHICS_H
-+#define GRAPHICS_H
-+
-+/* magic constant */
-+#define VIDEOMEM 0xA0000
-+
-+/* function prototypes */
-+char *graphics_get_splash(void);
-+
-+int read_image(char *s);
-+void graphics_cursor(int set);
-+
-+/* function prototypes for asm functions */
-+void * graphics_get_font();
-+void graphics_set_palette(int idx, int red, int green, int blue);
-+void set_int1c_handler();
-+void unset_int1c_handler();
-+
-+extern short cursorX, cursorY;
-+extern char cursorBuf[16];
-+
-+#endif /* GRAPHICS_H */
---- grub-0.95/stage2/shared.h.graphics 2004-06-18 17:35:52.372987008 -0400
-+++ grub-0.95/stage2/shared.h 2004-06-18 17:35:52.492968768 -0400
-@@ -873,6 +873,7 @@
- int grub_tolower (int c);
- int grub_isspace (int c);
- int grub_strncat (char *s1, const char *s2, int n);
-+void grub_memcpy(void *dest, const void *src, int len);
- void *grub_memmove (void *to, const void *from, int len);
- void *grub_memset (void *start, int c, int len);
- int grub_strncat (char *s1, const char *s2, int n);
---- grub-0.95/stage2/char_io.c.graphics 2004-05-23 12:45:43.000000000 -0400
-+++ grub-0.95/stage2/char_io.c 2004-06-18 17:35:52.485969832 -0400
-@@ -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 }
- };
-@@ -1046,13 +1072,15 @@
- 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);
-+
-
- do
- {
-@@ -1090,7 +1118,7 @@
- cls (void)
- {
- /* If the terminal is dumb, there is no way to clean the terminal. */
-- if (current_term->flags & TERM_DUMB)
-+ if (current_term->flags & TERM_DUMB)
- grub_putchar ('\n');
- else
- current_term->cls ();
-@@ -1214,6 +1242,16 @@
- return ! errnum;
- }
-
-+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];
-+}
-+
- void *
- grub_memmove (void *to, const void *from, int len)
- {
---- grub-0.95/configure.ac.graphics 2004-06-18 17:35:52.211011632 -0400
-+++ grub-0.95/configure.ac 2004-06-18 17:35:52.498967856 -0400
-@@ -595,6 +595,11 @@
- [ --enable-diskless enable diskless support])
- AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
-
-+dnl Graphical splashscreen support
-+AC_ARG_ENABLE(graphics,
-+ [ --disable-graphics disable graphics terminal support])
-+AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno)
-+
- dnl Hercules terminal
- AC_ARG_ENABLE(hercules,
- [ --disable-hercules disable hercules terminal support])
+++ /dev/null
---- grub-0.95/lib/device.c.moreraid 2004-11-30 17:09:36.736099360 -0500
-+++ grub-0.95/lib/device.c 2004-11-30 17:12:17.319686944 -0500
-@@ -544,6 +544,17 @@
- }
-
- static void
-+get_cciss_disk_name (char * name, int controller, int drive)
-+{
-+ sprintf (name, "/dev/cciss/c%dd%d", controller, drive);
-+}
-+
-+static void
-+get_cpqarray_disk_name (char * name, int controller, int drive)
-+{
-+ sprintf (name, "/dev/ida/c%dd%d", controller, drive);
-+}
-+static void
- get_ataraid_disk_name (char *name, int unit)
- {
- sprintf (name, "/dev/ataraid/d%c", unit + '0');
-@@ -920,7 +931,7 @@
-
- for (controller = 0; controller < 8; controller++)
- {
-- for (drive = 0; drive < 15; drive++)
-+ for (drive = 0; drive < 32; drive++)
- {
- char name[24];
-
-@@ -940,6 +951,70 @@
- }
- }
- #endif /* __linux__ */
-+
-+#ifdef __linux__
-+ /* This is for cciss - we have
-+ /dev/cciss/c<controller>d<logical drive>p<partition>.
-+
-+ cciss driver currently supports up to 8 controllers, 16 logical
-+ drives, and 7 partitions. */
-+ {
-+ int controller, drive;
-+
-+ for (controller = 0; controller < 8; controller++)
-+ {
-+ for (drive = 0; drive < 16; drive++)
-+ {
-+ char name[24];
-+
-+ get_cciss_disk_name (name, controller, drive);
-+ if (check_device (name))
-+ {
-+ (*map)[num_hd + 0x80] = strdup (name);
-+ assert ((*map)[num_hd + 0x80]);
-+
-+ /* If the device map file is opened, write the map. */
-+ if (fp)
-+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
-+
-+ num_hd++;
-+ }
-+ }
-+ }
-+ }
-+#endif /* __linux__ */
-+
-+#ifdef __linux__
-+ /* This is for cpqarray - we have
-+ /dev/ida/c<controller>d<logical drive>p<partition>.
-+
-+ cpqarray driver currently supports up to 8 controllers, 16 logical
-+ drives, and 15 partitions. */
-+ {
-+ int controller, drive;
-+
-+ for (controller = 0; controller < 8; controller++)
-+ {
-+ for (drive = 0; drive < 15; drive++)
-+ {
-+ char name[24];
-+
-+ get_cpqarray_disk_name (name, controller, drive);
-+ if (check_device (name))
-+ {
-+ (*map)[num_hd + 0x80] = strdup (name);
-+ assert ((*map)[num_hd + 0x80]);
-+
-+ /* If the device map file is opened, write the map. */
-+ if (fp)
-+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
-+
-+ num_hd++;
-+ }
-+ }
-+ }
-+ }
-+#endif /* __linux__ */
-
- /* OK, close the device map file if opened. */
- if (fp)
+++ /dev/null
---- grub-0.95/stage2/graphics.c.old 2005-01-11 09:34:17.125451981 -0500
-+++ grub-0.95/stage2/graphics.c 2005-01-11 09:34:03.743949015 -0500
-@@ -108,12 +108,8 @@
- * mode. */
- int graphics_init()
- {
-- if (!graphics_inited) {
-- saved_videomode = set_videomode(0x12);
-- }
--
- if (!read_image(splashimage)) {
-- set_videomode(saved_videomode);
-+ current_term = term_table;
- grub_printf("failed to read image\n");
- return 0;
- }
-@@ -303,6 +299,8 @@
- if (!xpm_open(s))
- return 0;
-
-+ saved_videomode = set_videomode(0x12);
-+
- /* parse info */
- while (grub_read(&c, 1)) {
- if (c == '"')
+++ /dev/null
---- grub-0.95/stage2/graphics.c.xpmjunk 2005-01-04 17:01:35.492804523 -0500
-+++ grub-0.95/stage2/graphics.c 2005-01-04 17:02:52.722495885 -0500
-@@ -262,6 +262,35 @@
- return;
- }
-
-+/* Open the file, and search for a valid XPM header. Return 1 if one is found,
-+ * leaving the current position as the start of the next line. Else,
-+ * return 0.
-+ */
-+int xpm_open(const char *s) {
-+ char buf, prev, target[]="/* XPM */\n";
-+ int pos=0;
-+
-+ if (!grub_open(s))
-+ return 0;
-+
-+ prev='\n';
-+ buf=0;
-+ do {
-+ if (grub_read(&buf, 1) != 1) {
-+ grub_close();
-+ return 0;
-+ }
-+ if ((pos == 0 && prev == '\n') || pos > 0) {
-+ if (buf == target[pos])
-+ pos++;
-+ else
-+ pos=0;
-+ }
-+ prev=buf;
-+ } while (target[pos]);
-+ return 1;
-+}
-+
- /* 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. */
-@@ -271,15 +300,9 @@
- unsigned char c, base, mask, *s1, *s2, *s4, *s8;
- unsigned i, len, idx, colors, x, y, width, height;
-
-- if (!grub_open(s))
-+ if (!xpm_open(s))
- return 0;
-
-- /* read header */
-- if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
-- grub_close();
-- return 0;
-- }
--
- /* parse info */
- while (grub_read(&c, 1)) {
- if (c == '"')
+++ /dev/null
-Submitted By: Jeremy Huntwork (jhuntwork at linuxfromscratch dot org)
-Date: 2008-04-03
-Initial Package Version: 0.97
-Upstream Status: Not sent. Development on 'GRUB legacy' abandoned for 'GRUB2'.
-Origin: http://bugs.debian.org/463123
-Description: Fixes GRUB to recognize ext2 filesystems created with 256-byte
-inodes.
-
-diff -Nrup a/stage2/fsys_ext2fs.c b/stage2/fsys_ext2fs.c
---- a/stage2/fsys_ext2fs.c 2004-08-08 20:19:18.000000000 +0200
-+++ b/stage2/fsys_ext2fs.c 2008-01-30 14:27:20.000000000 +0100
-@@ -79,7 +79,52 @@ struct ext2_super_block
- __u32 s_rev_level; /* Revision level */
- __u16 s_def_resuid; /* Default uid for reserved blocks */
- __u16 s_def_resgid; /* Default gid for reserved blocks */
-- __u32 s_reserved[235]; /* Padding to the end of the block */
-+ /*
-+ * These fields are for EXT2_DYNAMIC_REV superblocks only.
-+ *
-+ * Note: the difference between the compatible feature set and
-+ * the incompatible feature set is that if there is a bit set
-+ * in the incompatible feature set that the kernel doesn't
-+ * know about, it should refuse to mount the filesystem.
-+ *
-+ * e2fsck's requirements are more strict; if it doesn't know
-+ * about a feature in either the compatible or incompatible
-+ * feature set, it must abort and not try to meddle with
-+ * things it doesn't understand...
-+ */
-+ __u32 s_first_ino; /* First non-reserved inode */
-+ __u16 s_inode_size; /* size of inode structure */
-+ __u16 s_block_group_nr; /* block group # of this superblock */
-+ __u32 s_feature_compat; /* compatible feature set */
-+ __u32 s_feature_incompat; /* incompatible feature set */
-+ __u32 s_feature_ro_compat; /* readonly-compatible feature set */
-+ __u8 s_uuid[16]; /* 128-bit uuid for volume */
-+ char s_volume_name[16]; /* volume name */
-+ char s_last_mounted[64]; /* directory where last mounted */
-+ __u32 s_algorithm_usage_bitmap; /* For compression */
-+ /*
-+ * Performance hints. Directory preallocation should only
-+ * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
-+ */
-+ __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
-+ __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
-+ __u16 s_reserved_gdt_blocks;/* Per group table for online growth */
-+ /*
-+ * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
-+ */
-+ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
-+ __u32 s_journal_inum; /* inode number of journal file */
-+ __u32 s_journal_dev; /* device number of journal file */
-+ __u32 s_last_orphan; /* start of list of inodes to delete */
-+ __u32 s_hash_seed[4]; /* HTREE hash seed */
-+ __u8 s_def_hash_version; /* Default hash version to use */
-+ __u8 s_jnl_backup_type; /* Default type of journal backup */
-+ __u16 s_reserved_word_pad;
-+ __u32 s_default_mount_opts;
-+ __u32 s_first_meta_bg; /* First metablock group */
-+ __u32 s_mkfs_time; /* When the filesystem was created */
-+ __u32 s_jnl_blocks[17]; /* Backup of the journal inode */
-+ __u32 s_reserved[172]; /* Padding to the end of the block */
- };
-
- struct ext2_group_desc
-@@ -218,6 +263,9 @@ struct ext2_dir_entry
- #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
- #define EXT2_ADDR_PER_BLOCK_BITS(s) (log2(EXT2_ADDR_PER_BLOCK(s)))
-
-+#define EXT2_INODE_SIZE(s) (SUPERBLOCK->s_inode_size)
-+#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
-+
- /* linux/ext2_fs.h */
- #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
- /* kind of from ext2/super.c */
-@@ -553,7 +601,7 @@ ext2fs_dir (char *dirname)
- gdp = GROUP_DESC;
- ino_blk = gdp[desc].bg_inode_table +
- (((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group))
-- >> log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)));
-+ >> log2 (EXT2_INODES_PER_BLOCK (SUPERBLOCK)));
- #ifdef E2DEBUG
- printf ("inode table fsblock=%d\n", ino_blk);
- #endif /* E2DEBUG */
-@@ -565,13 +613,12 @@ ext2fs_dir (char *dirname)
- /* reset indirect blocks! */
- mapblock2 = mapblock1 = -1;
-
-- raw_inode = INODE +
-- ((current_ino - 1)
-- & (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode) - 1));
-+ raw_inode = (struct ext2_inode *)((char *)INODE +
-+ ((current_ino - 1) & (EXT2_INODES_PER_BLOCK (SUPERBLOCK) - 1)) *
-+ EXT2_INODE_SIZE (SUPERBLOCK));
- #ifdef E2DEBUG
- printf ("ipb=%d, sizeof(inode)=%d\n",
-- (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)),
-- sizeof (struct ext2_inode));
-+ EXT2_INODES_PER_BLOCK (SUPERBLOCK), EXT2_INODE_SIZE (SUPERBLOCK));
- printf ("inode=%x, raw_inode=%x\n", INODE, raw_inode);
- printf ("offset into inode table block=%d\n", (int) raw_inode - (int) INODE);
- for (i = (unsigned char *) INODE; i <= (unsigned char *) raw_inode;
+++ /dev/null
-Submitted By: Jim Gifford <jim@linuxfromscratch.org>
-Date: 05-28-2006
-Initial Package Version: 0.97
-Upstream Status: Unknown
-Origin: Fedora and Mandriva
-Description: This patch fixes issues with disk geometry not being
- detected properly. Part of this patch also fixes
- gcc 4 compile errors, which are a part of the issue.
-
-diff -Naur grub-0.97.orig/configure grub-0.97/configure
---- grub-0.97.orig/configure 2005-05-07 19:48:12.000000000 -0700
-+++ grub-0.97/configure 2006-05-28 20:29:36.025466751 -0700
-@@ -3485,9 +3485,9 @@
- echo "$as_me:$LINENO: result: $size_flag" >&5
- echo "${ECHO_T}$size_flag" >&6
- if test "x$size_flag" = xyes; then
-- STAGE2_CFLAGS="-Os"
-+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
- else
-- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
-+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
- fi
- # OpenBSD has a GCC extension for protecting applications from
- # stack smashing attacks, but GRUB doesn't want this feature.
-diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
---- grub-0.97.orig/configure.ac 2005-05-07 19:36:03.000000000 -0700
-+++ grub-0.97/configure.ac 2006-05-28 20:28:41.538819726 -0700
-@@ -93,9 +93,9 @@
- CFLAGS=$saved_CFLAGS
- ])
- if test "x$size_flag" = xyes; then
-- STAGE2_CFLAGS="-Os"
-+ STAGE2_CFLAGS="-Os -fno-strict-aliasing"
- else
-- STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
-+ STAGE2_CFLAGS="-O2 -fno-strict-aliasing -fno-strength-reduce -fno-unroll-loops"
- fi
- # OpenBSD has a GCC extension for protecting applications from
- # stack smashing attacks, but GRUB doesn't want this feature.
-diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
---- grub-0.97.orig/lib/device.c 2005-03-27 15:14:25.000000000 -0800
-+++ grub-0.97/lib/device.c 2006-05-28 20:34:03.546804777 -0700
-@@ -131,6 +131,152 @@
- #include <shared.h>
- #include <device.h>
-
-+#if defined(__linux__)
-+/* The 2.6 kernel has removed all of the geometry handling for IDE drives
-+ * that did fixups for LBA, etc. This means that the geometry we get
-+ * with the ioctl has a good chance of being wrong. So, we get to
-+ * also know about partition tables and try to read what the geometry
-+ * is there. *grumble* Very closely based on code from cfdisk
-+ */
-+static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
-+ struct hd_geometry hdg;
-+
-+ if (ioctl (fd, HDIO_GETGEO, &hdg))
-+ return;
-+
-+ *cyl = hdg.cylinders;
-+ *heads = hdg.heads;
-+ *sectors = hdg.sectors;
-+}
-+
-+struct partition {
-+ unsigned char boot_ind; /* 0x80 - active */
-+ unsigned char head; /* starting head */
-+ unsigned char sector; /* starting sector */
-+ unsigned char cyl; /* starting cylinder */
-+ unsigned char sys_ind; /* What partition type */
-+ unsigned char end_head; /* end head */
-+ unsigned char end_sector; /* end sector */
-+ unsigned char end_cyl; /* end cylinder */
-+ unsigned char start4[4]; /* starting sector counting from 0 */
-+ unsigned char size4[4]; /* nr of sectors in partition */
-+};
-+
-+#define ALIGNMENT 2
-+typedef union {
-+ struct {
-+ unsigned char align[ALIGNMENT];
-+ unsigned char b[SECTOR_SIZE];
-+ } c;
-+ struct {
-+ unsigned char align[ALIGNMENT];
-+ unsigned char buffer[0x1BE];
-+ struct partition part[4];
-+ unsigned char magicflag[2];
-+ } p;
-+} partition_table;
-+
-+#define PART_TABLE_FLAG0 0x55
-+#define PART_TABLE_FLAG1 0xAA
-+
-+static void
-+get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
-+ int *sectors) {
-+ struct partition *p;
-+ int i,h,s,hh,ss;
-+ int first = 1;
-+ int bad = 0;
-+
-+ if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
-+ bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
-+ /* Matthew Wilcox: slightly friendlier version of
-+ fatal(_("Bad signature on partition table"), 3);
-+ */
-+ fprintf(stderr, "Unknown partition table signature\n");
-+ return;
-+ }
-+
-+ hh = ss = 0;
-+ for (i=0; i<4; i++) {
-+ p = &(bufp->p.part[i]);
-+ if (p->sys_ind != 0) {
-+ h = p->end_head + 1;
-+ s = (p->end_sector & 077);
-+ if (first) {
-+ hh = h;
-+ ss = s;
-+ first = 0;
-+ } else if (hh != h || ss != s)
-+ bad = 1;
-+ }
-+ }
-+
-+ if (!first && !bad) {
-+ *heads = hh;
-+ *sectors = ss;
-+ }
-+}
-+
-+static long long my_lseek (unsigned int fd, long long offset,
-+ unsigned int origin)
-+{
-+#if defined(__linux__) && (!defined(__GLIBC__) || \
-+ ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-+ /* Maybe libc doesn't have large file support. */
-+ loff_t offset, result;
-+ static int _llseek (uint filedes, ulong hi, ulong lo,
-+ loff_t *res, uint wh);
-+ _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
-+ loff_t *, res, uint, wh);
-+
-+ if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
-+ return (long long) -1;
-+ return result;
-+#else
-+ return lseek(fd, offset, SEEK_SET);
-+#endif
-+}
-+
-+static void get_linux_geometry (int fd, struct geometry *geom) {
-+ long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
-+ long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
-+ partition_table bufp;
-+ char *buff, *buf_unaligned;
-+
-+ buf_unaligned = malloc(sizeof(partition_table) + 4095);
-+ buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
-+ (~(4096-1)));
-+
-+ get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
-+
-+ if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
-+ fprintf(stderr, "Unable to seek");
-+ }
-+
-+ if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
-+ memcpy(bufp.c.b, buff, SECTOR_SIZE);
-+ get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
-+ } else {
-+ fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
-+ }
-+
-+ if (pt_head && pt_sectors) {
-+ int cyl_size;
-+
-+ geom->heads = pt_head;
-+ geom->sectors = pt_sectors;
-+ cyl_size = pt_head * pt_sectors;
-+ geom->cylinders = geom->total_sectors/cyl_size;
-+ } else {
-+ geom->heads = kern_head;
-+ geom->sectors = kern_sectors;
-+ geom->cylinders = kern_cyl;
-+ }
-+
-+ return;
-+}
-+#endif
-+
- /* Get the geometry of a drive DRIVE. */
- void
- get_drive_geometry (struct geometry *geom, char **map, int drive)
-@@ -151,21 +297,16 @@
- #if defined(__linux__)
- /* Linux */
- {
-- struct hd_geometry hdg;
- unsigned long nr;
--
-- if (ioctl (fd, HDIO_GETGEO, &hdg))
-- goto fail;
-
- if (ioctl (fd, BLKGETSIZE, &nr))
- goto fail;
-
- /* Got the geometry, so save it. */
-- geom->cylinders = hdg.cylinders;
-- geom->heads = hdg.heads;
-- geom->sectors = hdg.sectors;
- geom->total_sectors = nr;
--
-+ get_linux_geometry(fd, geom);
-+ if (!geom->heads && !geom->cylinders && !geom->sectors)
-+ goto fail;
- goto success;
- }
-
-@@ -844,6 +985,7 @@
- {
- char dev[PATH_MAX]; /* XXX */
- int fd;
-+ off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
-
- if ((partition & 0x00FF00) != 0x00FF00)
- {
-@@ -870,35 +1012,13 @@
- errnum = ERR_NO_PART;
- return 0;
- }
--
--#if defined(__linux__) && (!defined(__GLIBC__) || \
-- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-- /* Maybe libc doesn't have large file support. */
-- {
-- loff_t offset, result;
-- static int _llseek (uint filedes, ulong hi, ulong lo,
-- loff_t *res, uint wh);
-- _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
-- loff_t *, res, uint, wh);
-
-- offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
-- if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
-- {
-- errnum = ERR_DEV_VALUES;
-- return 0;
-- }
-- }
--#else
-- {
-- off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
-
-- if (lseek (fd, offset, SEEK_SET) != offset)
-- {
-- errnum = ERR_DEV_VALUES;
-- return 0;
-- }
-- }
--#endif
-+ if (my_lseek(fd, offset, SEEK_SET) != offset)
-+ {
-+ errnum = ERR_DEV_VALUES;
-+ return 0;
-+ }
-
- if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
- {
-diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
---- grub-0.97.orig/stage2/Makefile.am 2005-02-02 12:37:35.000000000 -0800
-+++ grub-0.97/stage2/Makefile.am 2006-05-28 20:28:41.590818435 -0700
-@@ -24,7 +24,8 @@
- -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
- -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
- -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
-- -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1
-+ -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 \
-+ -fno-strict-aliasing
-
- # Stage 2 and Stage 1.5's.
- pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
-diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
---- grub-0.97.orig/stage2/boot.c 2004-03-30 03:44:08.000000000 -0800
-+++ grub-0.97/stage2/boot.c 2006-05-28 20:33:30.123638792 -0700
-@@ -55,7 +55,7 @@
- pu;
- /* presuming that MULTIBOOT_SEARCH is large enough to encompass an
- executable header */
-- unsigned char buffer[MULTIBOOT_SEARCH];
-+ char buffer[MULTIBOOT_SEARCH];
-
- /* sets the header pointer to point to the beginning of the
- buffer by default */
-@@ -98,7 +98,7 @@
- /* ELF loading supported if multiboot, FreeBSD and NetBSD. */
- if ((type == KERNEL_TYPE_MULTIBOOT
- || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
-- || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
-+ || grub_strcmp ((char *) pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
- || suggested_type == KERNEL_TYPE_NETBSD)
- && len > sizeof (Elf32_Ehdr)
- && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer))))
-@@ -824,8 +824,12 @@
- moveto = (mbi.mem_upper + 0x400) << 10;
-
- moveto = (moveto - len) & 0xfffff000;
-+#if 0
- max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
- ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
-+#else
-+ max_addr = LINUX_INITRD_MAX_ADDRESS;
-+#endif
- if (moveto + len >= max_addr)
- moveto = (max_addr - len) & 0xfffff000;
-
-diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
---- grub-0.97.orig/stage2/disk_io.c 2004-05-23 09:35:24.000000000 -0700
-+++ grub-0.97/stage2/disk_io.c 2006-05-28 20:28:41.582818634 -0700
-@@ -127,12 +127,19 @@
- int filepos;
- int filemax;
-
--static inline unsigned long
--log2 (unsigned long word)
-+#define log2(n) ffz(~(n))
-+
-+/* include/asm-i386/bitops.h */
-+/*
-+ * ffz = Find First Zero in word. Undefined if no zero exists,
-+ * so code should check against ~0UL first..
-+ */
-+static __inline__ unsigned long
-+ffz (unsigned long word)
- {
-- asm volatile ("bsfl %1,%0"
-- : "=r" (word)
-- : "r" (word));
-+ __asm__ ("bsfl %1,%0"
-+: "=r" (word)
-+: "r" (~word));
- return word;
- }
-
-diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
---- grub-0.97.orig/stage2/freebsd.h 2003-07-09 04:45:52.000000000 -0700
-+++ grub-0.97/stage2/freebsd.h 2006-05-28 20:28:41.582818634 -0700
-@@ -78,7 +78,7 @@
- struct bootinfo
- {
- unsigned int bi_version;
-- unsigned char *bi_kernelname;
-+ char *bi_kernelname;
- struct nfs_diskless *bi_nfs_diskless;
- /* End of fields that are always present. */
- #define bi_endcommon bi_n_bios_used
-diff -Naur grub-0.97.orig/stage2/fsys_fat.c grub-0.97/stage2/fsys_fat.c
---- grub-0.97.orig/stage2/fsys_fat.c 2005-03-15 08:52:00.000000000 -0800
-+++ grub-0.97/stage2/fsys_fat.c 2006-05-28 20:28:41.582818634 -0700
-@@ -54,12 +54,19 @@
-
- #define FAT_CACHE_SIZE 2048
-
-+#define log2(n) ffz(~(n))
-+
-+/* include/asm-i386/bitops.h */
-+/*
-+ * ffz = Find First Zero in word. Undefined if no zero exists,
-+ * so code should check against ~0UL first..
-+ */
- static __inline__ unsigned long
--log2 (unsigned long word)
-+ffz (unsigned long word)
- {
- __asm__ ("bsfl %1,%0"
-- : "=r" (word)
-- : "r" (word));
-+: "=r" (word)
-+: "r" (~word));
- return word;
- }
-
-diff -Naur grub-0.97.orig/stage2/fsys_iso9660.c grub-0.97/stage2/fsys_iso9660.c
---- grub-0.97.orig/stage2/fsys_iso9660.c 2004-05-11 05:11:19.000000000 -0700
-+++ grub-0.97/stage2/fsys_iso9660.c 2006-05-28 20:28:41.582818634 -0700
-@@ -55,13 +55,19 @@
- #define RRCONT_BUF ((unsigned char *)(FSYS_BUF + 6144))
- #define NAME_BUF ((unsigned char *)(FSYS_BUF + 8192))
-
-+#define log2(n) ffz(~(n))
-
--static inline unsigned long
--log2 (unsigned long word)
-+/* include/asm-i386/bitops.h */
-+/*
-+ * ffz = Find First Zero in word. Undefined if no zero exists,
-+ * so code should check against ~0UL first..
-+ */
-+static __inline__ unsigned long
-+ffz (unsigned long word)
- {
-- asm volatile ("bsfl %1,%0"
-- : "=r" (word)
-- : "r" (word));
-+ __asm__ ("bsfl %1,%0"
-+: "=r" (word)
-+: "r" (~word));
- return word;
- }
-
-@@ -120,7 +126,7 @@
- break;
- /* check ISO_VD_PRIMARY and ISO_STANDARD_ID */
- if (PRIMDESC->type.l == ISO_VD_PRIMARY
-- && !memcmp(PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
-+ && !memcmp((char *) PRIMDESC->id, ISO_STANDARD_ID, sizeof(PRIMDESC->id)))
- {
- ISO_SUPER->vol_sector = sector;
- INODE->file_start = 0;
-@@ -175,7 +181,7 @@
- for (; idr->length.l > 0;
- idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
- {
-- const char *name = idr->name;
-+ const u_int8_t *name = idr->name;
- unsigned int name_len = idr->name_len.l;
-
- file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
-@@ -198,7 +204,7 @@
- rr_len = (idr->length.l - idr->name_len.l
- - sizeof(struct iso_directory_record)
- + sizeof(idr->name));
-- rr_ptr.ptr = ((unsigned char *)idr + idr->name_len.l
-+ rr_ptr.ptr = ((char *)idr + idr->name_len.l
- + sizeof(struct iso_directory_record)
- - sizeof(idr->name));
- if (rr_ptr.i & 1)
-@@ -331,9 +337,9 @@
- memcpy(NAME_BUF, name, name_len);
- name = NAME_BUF;
- }
-- rr_ptr.ptr = RRCONT_BUF + ce_ptr->u.ce.offset.l;
-+ rr_ptr.ptr = (char *) RRCONT_BUF + ce_ptr->u.ce.offset.l;
- rr_len = ce_ptr->u.ce.size.l;
-- if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, RRCONT_BUF))
-+ if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, (char *) RRCONT_BUF))
- {
- errnum = 0; /* this is not fatal. */
- break;
-@@ -344,7 +350,7 @@
-
- filemax = MAXINT;
- if (name_len >= pathlen
-- && !memcmp(name, dirname, pathlen))
-+ && !memcmp((char *) name, dirname, pathlen))
- {
- if (dirname[pathlen] == '/' || !print_possibilities)
- {
-@@ -381,7 +387,7 @@
- print_possibilities = -print_possibilities;
- memcpy(NAME_BUF, name, name_len);
- NAME_BUF[name_len] = '\0';
-- print_a_completion (NAME_BUF);
-+ print_a_completion ((char *) NAME_BUF);
- #endif
- }
- }
-diff -Naur grub-0.97.orig/stage2/fsys_reiserfs.c grub-0.97/stage2/fsys_reiserfs.c
---- grub-0.97.orig/stage2/fsys_reiserfs.c 2004-02-18 14:09:10.000000000 -0800
-+++ grub-0.97/stage2/fsys_reiserfs.c 2006-05-28 20:28:41.586818535 -0700
-@@ -365,13 +365,19 @@
- #define JOURNAL_START ((__u32 *) (INFO + 1))
- #define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN))
-
-+#define log2(n) ffz(~(n))
-
-+/* include/asm-i386/bitops.h */
-+/*
-+ * ffz = Find First Zero in word. Undefined if no zero exists,
-+ * so code should check against ~0UL first..
-+ */
- static __inline__ unsigned long
--log2 (unsigned long word)
-+ffz (unsigned long word)
- {
- __asm__ ("bsfl %1,%0"
-- : "=r" (word)
-- : "r" (word));
-+: "=r" (word)
-+: "r" (~word));
- return word;
- }
-
-diff -Naur grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs.c
---- grub-0.97.orig/stage2/fsys_vstafs.c 2003-07-09 04:45:53.000000000 -0700
-+++ grub-0.97/stage2/fsys_vstafs.c 2006-05-28 20:28:41.586818535 -0700
-@@ -186,35 +186,35 @@
- int
- vstafs_read (char *addr, int len)
- {
-- struct alloc *a;
-+ struct alloc *b;
- int size, ret = 0, offset, curr_len = 0;
-- int curr_ext;
-+ int curr_exten;
- char extent;
- int ext_size;
- char *curr_pos;
-
- get_file_info (f_sector);
- size = FILE_INFO->len-VSTAFS_START_DATA;
-- a = FILE_INFO->blocks;
-+ b = FILE_INFO->blocks;
-
- if (filepos > 0)
- {
-- if (filepos < a[0].a_len * 512 - VSTAFS_START_DATA)
-+ if (filepos < b[0].a_len * 512 - VSTAFS_START_DATA)
- {
- offset = filepos + VSTAFS_START_DATA;
- extent = 0;
-- curr_len = a[0].a_len * 512 - offset - filepos;
-+ curr_len = b[0].a_len * 512 - offset - filepos;
- }
- else
- {
-- ext_size = a[0].a_len * 512 - VSTAFS_START_DATA;
-+ ext_size = b[0].a_len * 512 - VSTAFS_START_DATA;
- offset = filepos - ext_size;
- extent = 1;
- do
- {
- curr_len -= ext_size;
- offset -= ext_size;
-- ext_size = a[extent+1].a_len * 512;
-+ ext_size = b[extent+1].a_len * 512;
- }
- while (extent < FILE_INFO->extents && offset>ext_size);
- }
-@@ -223,16 +223,16 @@
- {
- offset = VSTAFS_START_DATA;
- extent = 0;
-- curr_len = a[0].a_len * 512 - offset;
-+ curr_len = b[0].a_len * 512 - offset;
- }
-
- curr_pos = addr;
- if (curr_len > len)
- curr_len = len;
-
-- for (curr_ext=extent;
-- curr_ext < FILE_INFO->extents;
-- curr_len = a[curr_ext].a_len * 512, curr_pos += curr_len, curr_ext++)
-+ for (curr_exten = extent;
-+ curr_exten < FILE_INFO->extents;
-+ curr_len = b[curr_exten].a_len * 512, curr_pos += curr_len, curr_exten++)
- {
- ret += curr_len;
- size -= curr_len;
-@@ -242,7 +242,7 @@
- curr_len += size;
- }
-
-- devread (a[curr_ext].a_start,offset, curr_len, curr_pos);
-+ devread (b[curr_exten].a_start, offset, curr_len, curr_pos);
- offset = 0;
- }
-
-diff -Naur grub-0.97.orig/stage2/fsys_xfs.c grub-0.97/stage2/fsys_xfs.c
---- grub-0.97.orig/stage2/fsys_xfs.c 2005-05-07 19:15:55.000000000 -0700
-+++ grub-0.97/stage2/fsys_xfs.c 2006-05-28 20:28:41.586818535 -0700
-@@ -97,7 +97,7 @@
- return ino & XFS_INO_MASK(XFS_INO_OFFSET_BITS);
- }
-
--static inline __const__ xfs_uint16_t
-+static inline __attribute__((const)) xfs_uint16_t
- le16 (xfs_uint16_t x)
- {
- __asm__("xchgb %b0,%h0" \
-@@ -106,7 +106,7 @@
- return x;
- }
-
--static inline __const__ xfs_uint32_t
-+static inline __attribute__((const)) xfs_uint32_t
- le32 (xfs_uint32_t x)
- {
- #if 0
-@@ -122,7 +122,7 @@
- return x;
- }
-
--static inline __const__ xfs_uint64_t
-+static inline __attribute__((const)) xfs_uint64_t
- le64 (xfs_uint64_t x)
- {
- xfs_uint32_t h = x >> 32;
-@@ -368,7 +368,7 @@
- default:
- namelen = sfe->namelen;
- *ino = sf_ino ((char *)sfe, namelen);
-- name = sfe->name;
-+ name = (char *) sfe->name;
- sfe = (xfs_dir2_sf_entry_t *)
- ((char *)sfe + namelen + 11 - xfs.i8param);
- }
-diff -Naur grub-0.97.orig/stage2/gunzip.c grub-0.97/stage2/gunzip.c
---- grub-0.97.orig/stage2/gunzip.c 2003-07-09 04:45:53.000000000 -0700
-+++ grub-0.97/stage2/gunzip.c 2006-05-28 20:28:41.586818535 -0700
-@@ -277,7 +277,7 @@
- * is a compressed file, and simply mark it as such.
- */
- if (no_decompression
-- || grub_read (buf, 10) != 10
-+ || grub_read ((char *) buf, 10) != 10
- || ((*((unsigned short *) buf) != GZIP_HDR_LE)
- && (*((unsigned short *) buf) != OLD_GZIP_HDR_LE)))
- {
-@@ -293,7 +293,7 @@
- if (buf[2] != DEFLATED
- || (buf[3] & UNSUPP_FLAGS)
- || ((buf[3] & EXTRA_FIELD)
-- && (grub_read (buf, 2) != 2
-+ && (grub_read ((char *) buf, 2) != 2
- || bad_field (*((unsigned short *) buf))))
- || ((buf[3] & ORIG_NAME) && bad_field (-1))
- || ((buf[3] & COMMENT) && bad_field (-1)))
-@@ -308,7 +308,7 @@
-
- filepos = filemax - 8;
-
-- if (grub_read (buf, 8) != 8)
-+ if (grub_read ((char *) buf, 8) != 8)
- {
- if (! errnum)
- errnum = ERR_BAD_GZIP_HEADER;
-@@ -485,8 +485,8 @@
-
- #define INBUFSIZ 0x2000
-
--static uch inbuf[INBUFSIZ];
--static int bufloc;
-+static unsigned char inbuf[INBUFSIZ];
-+static int bufloc;
-
- static int
- get_byte (void)
-@@ -494,7 +494,7 @@
- if (filepos == gzip_data_offset || bufloc == INBUFSIZ)
- {
- bufloc = 0;
-- grub_read (inbuf, INBUFSIZ);
-+ grub_read ((char *) inbuf, INBUFSIZ);
- }
-
- return inbuf[bufloc++];
-@@ -925,7 +925,7 @@
- unsigned m; /* mask for bit lengths table */
- unsigned n; /* number of lengths to get */
- unsigned nb; /* number of bit length codes */
-- unsigned nl; /* number of literal/length codes */
-+ unsigned nc; /* number of literal/length codes */
- unsigned nd; /* number of distance codes */
- unsigned ll[286 + 30]; /* literal/length and distance code lengths */
- register ulg b; /* bit buffer */
-@@ -937,7 +937,7 @@
-
- /* read in table lengths */
- NEEDBITS (5);
-- nl = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
-+ nc = 257 + ((unsigned) b & 0x1f); /* number of literal/length codes */
- DUMPBITS (5);
- NEEDBITS (5);
- nd = 1 + ((unsigned) b & 0x1f); /* number of distance codes */
-@@ -945,7 +945,7 @@
- NEEDBITS (4);
- nb = 4 + ((unsigned) b & 0xf); /* number of bit length codes */
- DUMPBITS (4);
-- if (nl > 286 || nd > 30)
-+ if (nc > 286 || nd > 30)
- {
- errnum = ERR_BAD_GZIP_DATA;
- return;
-@@ -970,7 +970,7 @@
- }
-
- /* read in literal and distance code lengths */
-- n = nl + nd;
-+ n = nc + nd;
- m = mask_bits[bl];
- i = l = 0;
- while ((unsigned) i < n)
-@@ -1034,7 +1034,7 @@
-
- /* build the decoding tables for literal/length and distance codes */
- bl = lbits;
-- if ((i = huft_build (ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
-+ if ((i = huft_build (ll, nc, 257, cplens, cplext, &tl, &bl)) != 0)
- {
- #if 0
- if (i == 1)
-@@ -1045,7 +1045,7 @@
- return;
- }
- bd = dbits;
-- if ((i = huft_build (ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
-+ if ((i = huft_build (ll + nc, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
- {
- #if 0
- if (i == 1)
-diff -Naur grub-0.97.orig/stage2/md5.c grub-0.97/stage2/md5.c
---- grub-0.97.orig/stage2/md5.c 2003-07-09 04:45:53.000000000 -0700
-+++ grub-0.97/stage2/md5.c 2006-05-28 20:28:41.590818435 -0700
-@@ -166,7 +166,7 @@
- inputlen -= 64 - buflen;
- while (inputlen >= 64)
- {
-- md5_transform (input);
-+ md5_transform ((unsigned char *) input);
- input += 64;
- inputlen -= 64;
- }
-@@ -211,7 +211,7 @@
- char *p;
- int saltlen;
- int i, n;
-- unsigned char alt_result[16];
-+ char alt_result[16];
- unsigned char *digest;
-
- if (check)
-diff -Naur grub-0.97.orig/stage2/start_eltorito.S grub-0.97/stage2/start_eltorito.S
---- grub-0.97.orig/stage2/start_eltorito.S 2004-03-27 08:14:20.000000000 -0800
-+++ grub-0.97/stage2/start_eltorito.S 2006-05-28 20:31:17.770936712 -0700
-@@ -40,9 +40,9 @@
- #define ABS(x) (x-_start+BOOTSEC_LOCATION)
-
- #ifdef STAGE1_5
--# define STAGE_ADDR 0x2000
-+# define STAGE_ADDR 0x2200
- #else
--# define STAGE_ADDR 0x8000
-+# define STAGE_ADDR 0x8200
- #endif /* STAGE1_5 */
-
- /* Print message string */
-@@ -71,12 +71,14 @@
- . = _start + 8 /* Pad to file offset 8 */
-
- /* This table gets filled in by mkisofs using the
-- -boot-info-table option */
--bi_pvd: .long 0xDEADBEEF /* LBA of primary volume descript */
--bi_file: .long 0xDEADBEEF /* LBA of boot file */
--bi_length: .long 0xDEADBEEF /* Length of boot file */
--bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
--bi_reserved: .space (10*4) /* Reserved */
-+ -boot-info-table option If not, the values in this
-+ table are default values that we can use to get us
-+ what we need, at least under a certain set of assumptions. */
-+bi_pvd: .long 16 /* LBA of primary volume descript */
-+bi_file: .long 0 /* LBA of boot file */
-+bi_length: .long 0xDEADBEEF /* Length of boot file */
-+bi_csum: .long 0xDEADBEEF /* Checksum of boot file */
-+bi_reserved: .space (10*4) /* Reserved */
-
- real_start:
- xor %ax, %ax
-@@ -92,10 +94,28 @@
- /* save drive reference first thing! */
- mov %dl, ABS(BootDrive)
-
-- /* print a notification message on the screen */
-- MSG(notification_string)
-+ /* check if machine support IBM/MS int 13h extensions */
-+ mov $0x41, %ah
-+ mov $0x55AA, %bx
-+ int $0x13
-+ jnc load_image
-+
-+ /* bios doesn't support int 13h extensions, print error messages */
-+ MSG(int13_error_string1)
-+ MSG(notification_done)
-+ MSG(int13_error_string2)
-+ MSG(notification_done)
-+ MSG(int13_error_string3)
-+ MSG(notification_done)
-+ /* even when bios says that it doesn't support int 13h
-+ extensions, do not stop here and try to load image anyway,
-+ because some bioses says that there isn't support for
-+ extended functions but have the needed extended read function
-+ (int 13h, function AH=42h) */
-
- load_image:
-+ /* print a notification message on the screen */
-+ MSG(notification_string)
- /* Set up boot file sector, size, load address */
- mov ABS(bi_length), %eax
- add $(ISO_SECTOR_SIZE-1), %eax
-@@ -105,6 +125,8 @@
- mov %bx, %es
- xor %bx, %bx
- mov ABS(bi_file), %eax
-+ inc %eax /* do not reload the first sector (this code) */
-+ dec %bp /* this way we have more room for code in stage1 */
- call getlinsec
- mov %ds, %ax
- mov %ax, %es
-@@ -115,7 +137,7 @@
- mov $ABS(firstlist - BOOTSEC_LISTSIZE), %si
- mov (%si), %ebp
- mov ABS(BootDrive), %dl /* this makes sure %dl is our "boot" drive */
-- ljmp $0, $(STAGE_ADDR+SECTOR_SIZE) /* jump to main() in asm.S */
-+ ljmp $0, $(STAGE_ADDR) /* jump to main() in asm.S */
-
- /* go here when you need to stop the machine hard after an error condition */
- stop: jmp stop
-@@ -171,11 +193,11 @@
- */
- xint13:
- movb $6, ABS(RetryCount)
-- pushal
- .try:
-+ pushal
- int $0x13
- jc 1f
-- add $(8*4), %sp /* Clean up stack */
-+ popal /* Clean up stack */
- ret
- 1:
- mov %ah, %dl /* Save error code */
-@@ -276,6 +298,10 @@
-
- read_error_string: .string "Read error 0x"
-
-+int13_error_string1: .string "Support for IBM/MS INT 13h extensions not found"
-+int13_error_string2: .string "GRUB cannot be loaded if int 13h/function AH=42h isn't present"
-+int13_error_string3: .string "Trying to load stage 2 anyway..."
-+
- /*
- * EBIOS disk address packet
- */
-@@ -306,7 +332,8 @@
- .word 0
- .word 0
-
-- . = _start + SECTOR_SIZE - BOOTSEC_LISTSIZE
-+ /* size of the code we can place between main body and fixed top location */
-+ . = _start + 1536 - BOOTSEC_LISTSIZE
-
- /* fill the first data listing with the default */
- blocklist_default_start:/* this is the sector start parameter, in logical
-@@ -321,6 +348,12 @@
- #endif
- blocklist_default_seg: /* this is the segment of the starting address
- to load the data into */
-- .word (STAGE_ADDR + SECTOR_SIZE) >> 4
-+ .word (STAGE_ADDR) >> 4
-
- firstlist: /* this label has to be after the list data!!! */
-+
-+ /* this is a workaround to allow more code to be added in stage1,
-+ it allows more code to be added for this stage, but for this
-+ we can't reload the first sector. So we have to align the code
-+ to ISO_SECTOR_SIZE. */
-+ . = _start + ISO_SECTOR_SIZE
-diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
---- grub-0.97.orig/util/grub-install.in 2004-07-24 11:57:31.000000000 -0700
-+++ grub-0.97/util/grub-install.in 2006-05-28 20:30:31.484088268 -0700
-@@ -336,6 +336,10 @@
- # Create a safe temporary file.
- test -n "$mklog" && log_file=`$mklog`
-
-+ # Before all invocations of the grub shell, call sync to make sure
-+ # the raw device is in sync with any bufferring in filesystems.
-+ sync
-+
- $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
- quit
- EOF
-@@ -450,6 +454,10 @@
- # Create a safe temporary file.
- test -n "$mklog" && log_file=`$mklog`
-
-+# Before all invocations of the grub shell, call sync to make sure
-+# the raw device is in sync with any bufferring in filesystems.
-+sync
-+
- # Now perform the installation.
- $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
- root $root_drive
+++ /dev/null
-Submitted By: Zack Winkles (eikniw AT gmail DOT com)
-Date: 2009-02-27
-Initial Package Version: 0.97
-Origin: http://www.mail-archive.com/bug-grub@gnu.org/msg11458.html
-Upstream Status: Not accepted (package no longer maintained)
-Description: Implement support extents, as implemented in ext4.
-
-diff -Naur grub-0.97.orig/stage2/fsys_ext2fs.c grub-0.97/stage2/fsys_ext2fs.c
---- grub-0.97.orig/stage2/fsys_ext2fs.c 2004-08-08 14:19:18.000000000 -0400
-+++ grub-0.97/stage2/fsys_ext2fs.c 2009-02-27 17:10:00.000000000 -0500
-@@ -51,6 +51,9 @@
- #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
- #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
-
-+/* Inode flags */
-+#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
-+
- /* include/linux/ext2_fs.h */
- struct ext2_super_block
- {
-@@ -191,6 +194,42 @@
- #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
- ~EXT2_DIR_ROUND)
-
-+/* linux/ext4_fs_extents.h */
-+/*
-+ * This is the extent on-disk structure.
-+ * It's used at the bottom of the tree.
-+ */
-+struct ext4_extent {
-+ __u32 ee_block; /* first logical block extent covers */
-+ __u16 ee_len; /* number of blocks covered by extent */
-+ __u16 ee_start_hi; /* high 16 bits of physical block */
-+ __u32 ee_start; /* low 32 bits of physical block */
-+};
-+
-+/*
-+ * This is index on-disk structure.
-+ * It's used at all the levels except the bottom.
-+ */
-+struct ext4_extent_idx {
-+ __u32 ei_block; /* index covers logical blocks from 'block' */
-+ __u32 ei_leaf; /* pointer to the physical block of the next *
-+ * level. leaf or next index could be there */
-+ __u16 ei_leaf_hi; /* high 16 bits of physical block */
-+ __u16 ei_unused;
-+};
-+
-+/*
-+ * Each block (leaves and indexes), even inode-stored has header.
-+ */
-+struct ext4_extent_header {
-+ __u16 eh_magic; /* probably will support different formats */
-+ __u16 eh_entries; /* number of valid entries */
-+ __u16 eh_max; /* capacity of store in entries */
-+ __u16 eh_depth; /* has tree real underlying blocks? */
-+ __u32 eh_generation; /* generation of the tree */
-+};
-+
-+#define EXT4_EXT_MAGIC 0xf30a
-
- /* ext2/super.c */
- #define log2(n) ffz(~(n))
-@@ -279,6 +318,27 @@
- EXT2_BLOCK_SIZE (SUPERBLOCK), (char *) buffer);
- }
-
-+/* Walk through extents index tree to find the good leaf */
-+static struct ext4_extent_header *
-+ext4_recurse_extent_index(struct ext4_extent_header *extent_block, int logical_block)
-+{
-+ int i;
-+ struct ext4_extent_idx *index = (struct ext4_extent_idx *) (extent_block + 1);
-+ if (extent_block->eh_magic != EXT4_EXT_MAGIC)
-+ return NULL;
-+ if (extent_block->eh_depth == 0)
-+ return extent_block;
-+ for (i = 0; i < extent_block->eh_entries; i++)
-+ {
-+ if (logical_block < index[i].ei_block)
-+ break;
-+ }
-+ if (i == 0 || !ext2_rdfsb(index[i-1].ei_leaf, DATABLOCK1))
-+ return NULL;
-+ return (ext4_recurse_extent_index((struct ext4_extent_header *) DATABLOCK1, logical_block));
-+}
-+
-+
- /* from
- ext2/inode.c:ext2_bmap()
- */
-@@ -287,7 +347,6 @@
- static int
- ext2fs_block_map (int logical_block)
- {
--
- #ifdef E2DEBUG
- unsigned char *i;
- for (i = (unsigned char *) INODE;
-@@ -308,82 +367,106 @@
- printf ("logical block %d\n", logical_block);
- #endif /* E2DEBUG */
-
-- /* if it is directly pointed to by the inode, return that physical addr */
-- if (logical_block < EXT2_NDIR_BLOCKS)
-+ if (!(INODE->i_flags & EXT4_EXTENTS_FL))
- {
--#ifdef E2DEBUG
-- printf ("returning %d\n", (unsigned char *) (INODE->i_block[logical_block]));
-- printf ("returning %d\n", INODE->i_block[logical_block]);
--#endif /* E2DEBUG */
-- return INODE->i_block[logical_block];
-- }
-- /* else */
-- logical_block -= EXT2_NDIR_BLOCKS;
-- /* try the indirect block */
-- if (logical_block < EXT2_ADDR_PER_BLOCK (SUPERBLOCK))
-- {
-- if (mapblock1 != 1
-- && !ext2_rdfsb (INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1))
-- {
-- errnum = ERR_FSYS_CORRUPT;
-- return -1;
-- }
-- mapblock1 = 1;
-- return ((__u32 *) DATABLOCK1)[logical_block];
-- }
-- /* else */
-- logical_block -= EXT2_ADDR_PER_BLOCK (SUPERBLOCK);
-- /* now try the double indirect block */
-- if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2)))
-- {
-- int bnum;
-- if (mapblock1 != 2
-- && !ext2_rdfsb (INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1))
-- {
-- errnum = ERR_FSYS_CORRUPT;
-- return -1;
-- }
-- mapblock1 = 2;
-- if ((bnum = (((__u32 *) DATABLOCK1)
-- [logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)]))
-- != mapblock2
-- && !ext2_rdfsb (bnum, DATABLOCK2))
-- {
-- errnum = ERR_FSYS_CORRUPT;
-- return -1;
-- }
-- mapblock2 = bnum;
-+ /* if it is directly pointed to by the inode, return that physical addr */
-+ if (logical_block < EXT2_NDIR_BLOCKS)
-+ {
-+#ifdef E2DEBUG
-+ printf ("returning %d\n", (unsigned char *) (INODE->i_block[logical_block]));
-+ printf ("returning %d\n", INODE->i_block[logical_block]);
-+#endif /* E2DEBUG */
-+ return INODE->i_block[logical_block];
-+ }
-+ /* else */
-+ logical_block -= EXT2_NDIR_BLOCKS;
-+ /* try the indirect block */
-+ if (logical_block < EXT2_ADDR_PER_BLOCK (SUPERBLOCK))
-+ {
-+ if (mapblock1 != 1 && !ext2_rdfsb (INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ mapblock1 = 1;
-+ return ((__u32 *) DATABLOCK1)[logical_block];
-+ }
-+ /* else */
-+ logical_block -= EXT2_ADDR_PER_BLOCK (SUPERBLOCK);
-+ /* now try the double indirect block */
-+ if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2)))
-+ {
-+ int bnum;
-+ if (mapblock1 != 2 && !ext2_rdfsb (INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ mapblock1 = 2;
-+ if ((bnum = (((__u32 *) DATABLOCK1)
-+ [logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)]))
-+ != mapblock2
-+ && !ext2_rdfsb (bnum, DATABLOCK2))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ mapblock2 = bnum;
-+ return ((__u32 *) DATABLOCK2)
-+ [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
-+ }
-+ /* else */
-+ mapblock2 = -1;
-+ logical_block -= (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2));
-+ if (mapblock1 != 3
-+ && !ext2_rdfsb (INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ mapblock1 = 3;
-+ if (!ext2_rdfsb (((__u32 *) DATABLOCK1)
-+ [logical_block >> (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)
-+ * 2)],
-+ DATABLOCK2))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ if (!ext2_rdfsb (((__u32 *) DATABLOCK2)
-+ [(logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK))
-+ & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)],
-+ DATABLOCK2))
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+
- return ((__u32 *) DATABLOCK2)
-- [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
-+ [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
- }
-- /* else */
-- mapblock2 = -1;
-- logical_block -= (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2));
-- if (mapblock1 != 3
-- && !ext2_rdfsb (INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1))
-- {
-- errnum = ERR_FSYS_CORRUPT;
-- return -1;
-- }
-- mapblock1 = 3;
-- if (!ext2_rdfsb (((__u32 *) DATABLOCK1)
-- [logical_block >> (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)
-- * 2)],
-- DATABLOCK2))
-- {
-- errnum = ERR_FSYS_CORRUPT;
-- return -1;
-- }
-- if (!ext2_rdfsb (((__u32 *) DATABLOCK2)
-- [(logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK))
-- & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)],
-- DATABLOCK2))
-+ /* inode is in extents format */
-+ else
- {
-+ int i;
-+ struct ext4_extent_header *extent_hdr =
-+ ext4_recurse_extent_index((struct ext4_extent_header *) INODE->i_block, logical_block);
-+ struct ext4_extent *extent = (struct ext4_extent *) (extent_hdr + 1);
-+ if ( extent_hdr == NULL || extent_hdr->eh_magic != EXT4_EXT_MAGIC)
-+ {
-+ errnum = ERR_FSYS_CORRUPT;
-+ return -1;
-+ }
-+ for (i = 0; i<extent_hdr->eh_entries; i++)
-+ {
-+ if (extent[i].ee_block <= logical_block && logical_block < extent[i].ee_block + extent[i].ee_len && !(extent[i].ee_len>>15))
-+ return (logical_block - extent[i].ee_block + extent[i].ee_start);
-+ }
-+ /* We should not arrive here */
-+
- errnum = ERR_FSYS_CORRUPT;
- return -1;
- }
-- return ((__u32 *) DATABLOCK2)
-- [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
- }
-
- /* preconditions: all preconds of ext2fs_block_map */
+++ /dev/null
---- grub-0.97/util/grub-install.in.install 2005-12-12 18:15:45.000000000 -0500
-+++ grub-0.97/util/grub-install.in 2005-12-12 18:18:11.000000000 -0500
-@@ -324,6 +324,15 @@
- test -d "$bootdir" || mkdir "$bootdir" || exit 1
- test -d "$grubdir" || mkdir "$grubdir" || exit 1
-
-+# Copy the GRUB images to the GRUB directory.
-+for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
-+ rm -f $file || exit 1
-+done
-+for file in \
-+ ${pkgdatadir}/stage1 ${pkgdatadir}/stage2 ${pkgdatadir}/*stage1_5; do
-+ cp -f $file ${grubdir} || exit 1
-+done
-+
- # If --recheck is specified, remove the device map, if present.
- if test $recheck = yes; then
- rm -f $device_map
-@@ -406,15 +415,6 @@
- exit 1
- fi
-
--# Copy the GRUB images to the GRUB directory.
--for file in ${grubdir}/stage1 ${grubdir}/stage2 ${grubdir}/*stage1_5; do
-- rm -f $file || exit 1
--done
--for file in \
-- ${pkglibdir}/stage1 ${pkglibdir}/stage2 ${pkglibdir}/*stage1_5; do
-- cp -f $file ${grubdir} || exit 1
--done
--
- # Make a default file.
- ${grub_set_default} --root-directory=${rootdir} default
-