1 Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
3 Initial Package Version: 0.97
5 Upstream Status: Unknown
6 Description: Contains various fixes and enhancements
9 XFS Filesystem Boot Freeze Fixes
10 Removed 2GB Memory Limitation
12 Fixes for initrd support
13 Grub installation Fixes
14 Linux 2.6 geometry Fixes
16 Autoconf and aclocal updates
18 http://trac.cross-lfs.org/browser/trunk/patches/grub-0.97-fixes-1.patch
23 -# generated automatically by aclocal 1.9.4 -*- Autoconf -*-
24 +# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
26 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
27 -# Free Software Foundation, Inc.
28 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
29 +# 2005 Free Software Foundation, Inc.
30 # This file is free software; the Free Software Foundation
31 # gives unlimited permission to copy and/or distribute it,
32 # with or without modifications, as long as this notice is preserved.
34 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
38 -# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
39 -# Generated from amversion.in; do not edit by hand.
41 -# This program is free software; you can redistribute it and/or modify
42 -# it under the terms of the GNU General Public License as published by
43 -# the Free Software Foundation; either version 2, or (at your option)
46 -# This program is distributed in the hope that it will be useful,
47 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
48 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 -# GNU General Public License for more details.
51 -# You should have received a copy of the GNU General Public License
52 -# along with this program; if not, write to the Free Software
53 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
54 +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
56 +# This file is free software; the Free Software Foundation
57 +# gives unlimited permission to copy and/or distribute it,
58 +# with or without modifications, as long as this notice is preserved.
60 # AM_AUTOMAKE_VERSION(VERSION)
61 # ----------------------------
62 @@ -40,26 +28,15 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api
63 # Call AM_AUTOMAKE_VERSION so it can be traced.
64 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
65 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
66 - [AM_AUTOMAKE_VERSION([1.9.4])])
70 -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
71 + [AM_AUTOMAKE_VERSION([1.9.6])])
73 -# This program is free software; you can redistribute it and/or modify
74 -# it under the terms of the GNU General Public License as published by
75 -# the Free Software Foundation; either version 2, or (at your option)
77 +# AM_AUX_DIR_EXPAND -*- Autoconf -*-
79 -# This program is distributed in the hope that it will be useful,
80 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
81 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82 -# GNU General Public License for more details.
84 -# You should have received a copy of the GNU General Public License
85 -# along with this program; if not, write to the Free Software
86 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
88 +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
90 +# This file is free software; the Free Software Foundation
91 +# gives unlimited permission to copy and/or distribute it,
92 +# with or without modifications, as long as this notice is preserved.
94 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
95 # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
96 @@ -106,26 +83,16 @@ AC_PREREQ([2.50])dnl
97 am_aux_dir=`cd $ac_aux_dir && pwd`
100 -# AM_CONDITIONAL -*- Autoconf -*-
101 +# AM_CONDITIONAL -*- Autoconf -*-
103 -# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
105 -# This program is free software; you can redistribute it and/or modify
106 -# it under the terms of the GNU General Public License as published by
107 -# the Free Software Foundation; either version 2, or (at your option)
108 -# any later version.
110 -# This program is distributed in the hope that it will be useful,
111 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
112 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
113 -# GNU General Public License for more details.
115 -# You should have received a copy of the GNU General Public License
116 -# along with this program; if not, write to the Free Software
117 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
119 +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
120 +# Free Software Foundation, Inc.
122 +# This file is free software; the Free Software Foundation
123 +# gives unlimited permission to copy and/or distribute it,
124 +# with or without modifications, as long as this notice is preserved.
129 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
130 # -------------------------------------
131 @@ -149,26 +116,15 @@ AC_CONFIG_COMMANDS_PRE(
132 Usually this means the macro was only invoked conditionally.]])
135 -# serial 7 -*- Autoconf -*-
137 -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
138 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
139 # Free Software Foundation, Inc.
141 +# This file is free software; the Free Software Foundation
142 +# gives unlimited permission to copy and/or distribute it,
143 +# with or without modifications, as long as this notice is preserved.
145 -# This program is free software; you can redistribute it and/or modify
146 -# it under the terms of the GNU General Public License as published by
147 -# the Free Software Foundation; either version 2, or (at your option)
148 -# any later version.
150 -# This program is distributed in the hope that it will be useful,
151 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
152 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
153 -# GNU General Public License for more details.
155 -# You should have received a copy of the GNU General Public License
156 -# along with this program; if not, write to the Free Software
157 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
162 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
163 # written in clear, in which case automake, when reading aclocal.m4,
164 @@ -177,7 +133,6 @@ fi])])
165 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
169 # _AM_DEPENDENCIES(NAME)
170 # ----------------------
171 # See how the compiler implements dependency checking.
172 @@ -317,27 +272,16 @@ AM_CONDITIONAL([AMDEP], [test "x$enable_
173 AC_SUBST([AMDEPBACKSLASH])
176 -# Generate code to set up dependency tracking. -*- Autoconf -*-
178 -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
179 -# Free Software Foundation, Inc.
181 -# This program is free software; you can redistribute it and/or modify
182 -# it under the terms of the GNU General Public License as published by
183 -# the Free Software Foundation; either version 2, or (at your option)
184 -# any later version.
185 +# Generate code to set up dependency tracking. -*- Autoconf -*-
187 -# This program is distributed in the hope that it will be useful,
188 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
189 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190 -# GNU General Public License for more details.
192 -# You should have received a copy of the GNU General Public License
193 -# along with this program; if not, write to the Free Software
194 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
196 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
197 +# Free Software Foundation, Inc.
199 +# This file is free software; the Free Software Foundation
200 +# gives unlimited permission to copy and/or distribute it,
201 +# with or without modifications, as long as this notice is preserved.
206 # _AM_OUTPUT_DEPENDENCY_COMMANDS
207 # ------------------------------
208 @@ -396,30 +340,19 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS]
209 [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
212 -# Do all the work for Automake. -*- Autoconf -*-
213 +# Do all the work for Automake. -*- Autoconf -*-
215 -# This macro actually does too much some checks are only needed if
216 -# your package does certain things. But this isn't really a big deal.
218 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
219 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
220 # Free Software Foundation, Inc.
222 +# This file is free software; the Free Software Foundation
223 +# gives unlimited permission to copy and/or distribute it,
224 +# with or without modifications, as long as this notice is preserved.
226 -# This program is free software; you can redistribute it and/or modify
227 -# it under the terms of the GNU General Public License as published by
228 -# the Free Software Foundation; either version 2, or (at your option)
229 -# any later version.
231 -# This program is distributed in the hope that it will be useful,
232 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
233 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
234 -# GNU General Public License for more details.
236 -# You should have received a copy of the GNU General Public License
237 -# along with this program; if not, write to the Free Software
238 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
243 +# This macro actually does too much. Some checks are only needed if
244 +# your package does certain things. But this isn't really a big deal.
246 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
247 # AM_INIT_AUTOMAKE([OPTIONS])
248 @@ -521,51 +454,27 @@ for _am_header in $config_headers :; do
250 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
252 +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
254 +# This file is free software; the Free Software Foundation
255 +# gives unlimited permission to copy and/or distribute it,
256 +# with or without modifications, as long as this notice is preserved.
260 # Define $install_sh.
262 -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
264 -# This program is free software; you can redistribute it and/or modify
265 -# it under the terms of the GNU General Public License as published by
266 -# the Free Software Foundation; either version 2, or (at your option)
267 -# any later version.
269 -# This program is distributed in the hope that it will be useful,
270 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
271 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
272 -# GNU General Public License for more details.
274 -# You should have received a copy of the GNU General Public License
275 -# along with this program; if not, write to the Free Software
276 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
279 AC_DEFUN([AM_PROG_INSTALL_SH],
280 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
281 install_sh=${install_sh-"$am_aux_dir/install-sh"}
282 AC_SUBST(install_sh)])
285 -# Copyright (C) 2003 Free Software Foundation, Inc.
287 -# This program is free software; you can redistribute it and/or modify
288 -# it under the terms of the GNU General Public License as published by
289 -# the Free Software Foundation; either version 2, or (at your option)
290 -# any later version.
292 -# This program is distributed in the hope that it will be useful,
293 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
294 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
295 -# GNU General Public License for more details.
297 -# You should have received a copy of the GNU General Public License
298 -# along with this program; if not, write to the Free Software
299 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
301 +# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
303 +# This file is free software; the Free Software Foundation
304 +# gives unlimited permission to copy and/or distribute it,
305 +# with or without modifications, as long as this notice is preserved.
310 # Check whether the underlying file-system supports filenames
311 # with a leading dot. For instance MS-DOS doesn't.
312 @@ -580,28 +489,17 @@ fi
313 rmdir .tst 2>/dev/null
314 AC_SUBST([am__leading_dot])])
316 -# Add --enable-maintainer-mode option to configure.
317 +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
320 -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004
321 +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
322 # Free Software Foundation, Inc.
324 +# This file is free software; the Free Software Foundation
325 +# gives unlimited permission to copy and/or distribute it,
326 +# with or without modifications, as long as this notice is preserved.
328 -# This program is free software; you can redistribute it and/or modify
329 -# it under the terms of the GNU General Public License as published by
330 -# the Free Software Foundation; either version 2, or (at your option)
331 -# any later version.
333 -# This program is distributed in the hope that it will be useful,
334 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
335 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
336 -# GNU General Public License for more details.
338 -# You should have received a copy of the GNU General Public License
339 -# along with this program; if not, write to the Free Software
340 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
346 AC_DEFUN([AM_MAINTAINER_MODE],
347 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
348 @@ -620,26 +518,15 @@ AC_DEFUN([AM_MAINTAINER_MODE],
350 AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
352 -# Check to see how 'make' treats includes. -*- Autoconf -*-
354 -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
355 +# Check to see how 'make' treats includes. -*- Autoconf -*-
357 -# This program is free software; you can redistribute it and/or modify
358 -# it under the terms of the GNU General Public License as published by
359 -# the Free Software Foundation; either version 2, or (at your option)
360 -# any later version.
362 -# This program is distributed in the hope that it will be useful,
363 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
364 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
365 -# GNU General Public License for more details.
367 -# You should have received a copy of the GNU General Public License
368 -# along with this program; if not, write to the Free Software
369 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
371 +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
373 +# This file is free software; the Free Software Foundation
374 +# gives unlimited permission to copy and/or distribute it,
375 +# with or without modifications, as long as this notice is preserved.
382 @@ -683,27 +570,16 @@ AC_MSG_RESULT([$_am_result])
389 -# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
391 -# This program is free software; you can redistribute it and/or modify
392 -# it under the terms of the GNU General Public License as published by
393 -# the Free Software Foundation; either version 2, or (at your option)
394 -# any later version.
395 +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
397 -# This program is distributed in the hope that it will be useful,
398 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
399 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
400 -# GNU General Public License for more details.
402 -# You should have received a copy of the GNU General Public License
403 -# along with this program; if not, write to the Free Software
404 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
406 +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
407 +# Free Software Foundation, Inc.
409 +# This file is free software; the Free Software Foundation
410 +# gives unlimited permission to copy and/or distribute it,
411 +# with or without modifications, as long as this notice is preserved.
416 # AM_MISSING_PROG(NAME, PROGRAM)
417 # ------------------------------
418 @@ -729,27 +605,16 @@ else
422 +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
424 +# This file is free software; the Free Software Foundation
425 +# gives unlimited permission to copy and/or distribute it,
426 +# with or without modifications, as long as this notice is preserved.
430 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
432 -# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
434 -# This program is free software; you can redistribute it and/or modify
435 -# it under the terms of the GNU General Public License as published by
436 -# the Free Software Foundation; either version 2, or (at your option)
437 -# any later version.
439 -# This program is distributed in the hope that it will be useful,
440 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
441 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
442 -# GNU General Public License for more details.
444 -# You should have received a copy of the GNU General Public License
445 -# along with this program; if not, write to the Free Software
446 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
450 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
451 # created by `make install' are always world readable, even if the
452 # installer happens to have an overly restrictive umask (e.g. 077).
453 @@ -803,26 +668,15 @@ else
455 AC_SUBST([mkdir_p])])
457 -# Helper functions for option handling. -*- Autoconf -*-
458 +# Helper functions for option handling. -*- Autoconf -*-
460 -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
462 -# This program is free software; you can redistribute it and/or modify
463 -# it under the terms of the GNU General Public License as published by
464 -# the Free Software Foundation; either version 2, or (at your option)
465 -# any later version.
467 -# This program is distributed in the hope that it will be useful,
468 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
469 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
470 -# GNU General Public License for more details.
472 -# You should have received a copy of the GNU General Public License
473 -# along with this program; if not, write to the Free Software
474 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
476 +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
478 +# This file is free software; the Free Software Foundation
479 +# gives unlimited permission to copy and/or distribute it,
480 +# with or without modifications, as long as this notice is preserved.
485 # _AM_MANGLE_OPTION(NAME)
486 # -----------------------
487 @@ -847,28 +701,16 @@ AC_DEFUN([_AM_SET_OPTIONS],
488 AC_DEFUN([_AM_IF_OPTION],
489 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
492 -# Check to make sure that the build environment is sane.
495 -# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
497 -# This program is free software; you can redistribute it and/or modify
498 -# it under the terms of the GNU General Public License as published by
499 -# the Free Software Foundation; either version 2, or (at your option)
500 -# any later version.
501 +# Check to make sure that the build environment is sane. -*- Autoconf -*-
503 -# This program is distributed in the hope that it will be useful,
504 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
505 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
506 -# GNU General Public License for more details.
508 -# You should have received a copy of the GNU General Public License
509 -# along with this program; if not, write to the Free Software
510 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
512 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
513 +# Free Software Foundation, Inc.
515 +# This file is free software; the Free Software Foundation
516 +# gives unlimited permission to copy and/or distribute it,
517 +# with or without modifications, as long as this notice is preserved.
524 @@ -911,25 +753,14 @@ Check your system clock])
528 -# AM_PROG_INSTALL_STRIP
530 -# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
532 -# This program is free software; you can redistribute it and/or modify
533 -# it under the terms of the GNU General Public License as published by
534 -# the Free Software Foundation; either version 2, or (at your option)
535 -# any later version.
537 -# This program is distributed in the hope that it will be useful,
538 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
539 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
540 -# GNU General Public License for more details.
542 -# You should have received a copy of the GNU General Public License
543 -# along with this program; if not, write to the Free Software
544 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
546 +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
548 +# This file is free software; the Free Software Foundation
549 +# gives unlimited permission to copy and/or distribute it,
550 +# with or without modifications, as long as this notice is preserved.
552 +# AM_PROG_INSTALL_STRIP
553 +# ---------------------
554 # One issue with vendor `install' (even GNU) is that you can't
555 # specify the program used to strip binaries. This is especially
556 # annoying in cross-compiling environments, where the build's strip
557 @@ -952,25 +783,13 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
559 # Check how to create a tarball. -*- Autoconf -*-
561 -# Copyright (C) 2004 Free Software Foundation, Inc.
563 -# This program is free software; you can redistribute it and/or modify
564 -# it under the terms of the GNU General Public License as published by
565 -# the Free Software Foundation; either version 2, or (at your option)
566 -# any later version.
568 -# This program is distributed in the hope that it will be useful,
569 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
570 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
571 -# GNU General Public License for more details.
573 -# You should have received a copy of the GNU General Public License
574 -# along with this program; if not, write to the Free Software
575 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
579 +# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
581 +# This file is free software; the Free Software Foundation
582 +# gives unlimited permission to copy and/or distribute it,
583 +# with or without modifications, as long as this notice is preserved.
587 # _AM_PROG_TAR(FORMAT)
588 # --------------------
592 +2006-05-02 Pavel Roskin <proski@gnu.org>
594 + * stage2/stage2.c (run_menu): Fix "savedefault" to save only top
595 + level menu positions. Remember current position when calling a
596 + submenu. Don't recalculate it when booting from a submenu.
598 + * grub/main.c (main): Make sure the boot drive number doesn't
601 +2006-05-02 Vesa Jaaskelainen <chaac@nic.fi>
603 + * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2
604 + to GRUB Legacy. Problem reported by Gerardo Richarte.
606 +2006-04-23 Robert Millan <robertmh@gnu.org>
608 + * grub/asmstub.c (get_diskinfo): Optimize sysctl routine.
610 +2006-04-20 Robert Millan <robertmh@gnu.org>
612 + Fixes for kernel of FreeBSD:
613 + * grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl
614 + before opening a device for writing.
615 + * util/grub-install.in: Devices don't have this "r" prefix anymore.
617 +2006-04-16 Yoshinori K. Okuji <okuji@enbug.org>
619 + * docs/multiboot.texi: Correct the offset of address
620 + fields. Reported by Jeroen Dekkers.
622 +2006-03-21 Yoshinori K. Okuji <okuji@enbug.org>
624 + * stage2/builtins.c (setup_func): Specify the size of DEVICE to
625 + grub_strncat instead of a strange number 256. Reported by Vitaly
626 + Fertman <vitaly@namesys.com>.
628 +2005-09-29 Yoshinori K. Okuji <okuji@enbug.org>
630 + * docs/multiboot.texi: Fix a bug in the byte order of
631 + boot_device. I hope this won't affect any OS image.
632 + Increased the version number to 0.6.94.
634 +2005-09-28 Yoshinori K. Okuji <okuji@enbug.org>
636 + * stage2/boot.c (load_image): Even if an OS image is an ELF
637 + object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is
640 2005-05-08 Yoshinori K. Okuji <okuji@enbug.org>
642 * configure.ac (AC_INIT): Upgraded to 0.97.
645 @@ -311,7 +311,7 @@ ac_includes_default="\
649 -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT PERL CC ac_ct_CC CFLAGS LDFLAGS CPPFLAGS EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS RANLIB ac_ct_RANLIB STAGE1_CFLAGS STAGE2_CFLAGS GRUB_CFLAGS OBJCOPY ac_ct_OBJCOPY GRUB_LIBS CPP EGREP NETBOOT_SUPPORT_TRUE NETBOOT_SUPPORT_FALSE DISKLESS_SUPPORT_TRUE DISKLESS_SUPPORT_FALSE HERCULES_SUPPORT_TRUE HERCULES_SUPPORT_FALSE SERIAL_SUPPORT_TRUE SERIAL_SUPPORT_FALSE SERIAL_SPEED_SIMULATION_TRUE SERIAL_SPEED_SIMULATION_FALSE BUILD_EXAMPLE_KERNEL_TRUE BUILD_EXAMPLE_KERNEL_FALSE FSYS_CFLAGS NET_CFLAGS NET_EXTRAFLAGS NETBOOT_DRIVERS CCASFLAGS LIBOBJS LTLIBOBJS'
650 +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT PERL CC ac_ct_CC CFLAGS LDFLAGS CPPFLAGS EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS RANLIB ac_ct_RANLIB STAGE1_CFLAGS STAGE2_CFLAGS GRUB_CFLAGS OBJCOPY ac_ct_OBJCOPY GRUB_LIBS CPP EGREP NETBOOT_SUPPORT_TRUE NETBOOT_SUPPORT_FALSE DISKLESS_SUPPORT_TRUE DISKLESS_SUPPORT_FALSE GRAPHICS_SUPPORT_TRUE GRAPHICS_SUPPORT_FALSE HERCULES_SUPPORT_TRUE HERCULES_SUPPORT_FALSE SERIAL_SUPPORT_TRUE SERIAL_SUPPORT_FALSE SERIAL_SPEED_SIMULATION_TRUE SERIAL_SPEED_SIMULATION_FALSE BUILD_EXAMPLE_KERNEL_TRUE BUILD_EXAMPLE_KERNEL_FALSE FSYS_CFLAGS NET_CFLAGS NET_EXTRAFLAGS NETBOOT_DRIVERS CCASFLAGS LIBOBJS LTLIBOBJS'
653 # Initialize some variables set by options.
654 @@ -914,6 +914,7 @@ Optional Features:
655 set the default memory location for WD/SMC
656 --enable-cs-scan=LIST probe for CS89x0 base address using LIST
657 --enable-diskless enable diskless support
658 + --disable-graphics disable graphics terminal support
659 --disable-hercules disable hercules terminal support
660 --disable-serial disable serial terminal support
661 --enable-serial-speed-simulation
662 @@ -5966,6 +5967,22 @@ else
666 +# Check whether --enable-graphics or --disable-graphics was given.
667 +if test "${enable_graphics+set}" = set; then
668 + enableval="$enable_graphics"
673 +if test "x$enable_graphics" != xno; then
674 + GRAPHICS_SUPPORT_TRUE=
675 + GRAPHICS_SUPPORT_FALSE='#'
677 + GRAPHICS_SUPPORT_TRUE='#'
678 + GRAPHICS_SUPPORT_FALSE=
682 # Check whether --enable-hercules or --disable-hercules was given.
683 if test "${enable_hercules+set}" = set; then
684 enableval="$enable_hercules"
685 @@ -6270,6 +6287,13 @@ echo "$as_me: error: conditional \"DISKL
686 Usually this means the macro was only invoked conditionally." >&2;}
687 { (exit 1); exit 1; }; }
689 +if test -z "${GRAPHICS_SUPPORT_TRUE}" && test -z "${GRAPHICS_SUPPORT_FALSE}"; then
690 + { { echo "$as_me:$LINENO: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
691 +Usually this means the macro was only invoked conditionally." >&5
692 +echo "$as_me: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
693 +Usually this means the macro was only invoked conditionally." >&2;}
694 + { (exit 1); exit 1; }; }
696 if test -z "${HERCULES_SUPPORT_TRUE}" && test -z "${HERCULES_SUPPORT_FALSE}"; then
697 { { echo "$as_me:$LINENO: error: conditional \"HERCULES_SUPPORT\" was never defined.
698 Usually this means the macro was only invoked conditionally." >&5
699 @@ -6907,6 +6931,8 @@ s,@NETBOOT_SUPPORT_TRUE@,$NETBOOT_SUPPOR
700 s,@NETBOOT_SUPPORT_FALSE@,$NETBOOT_SUPPORT_FALSE,;t t
701 s,@DISKLESS_SUPPORT_TRUE@,$DISKLESS_SUPPORT_TRUE,;t t
702 s,@DISKLESS_SUPPORT_FALSE@,$DISKLESS_SUPPORT_FALSE,;t t
703 +s,@GRAPHICS_SUPPORT_TRUE@,$GRAPHICS_SUPPORT_TRUE,;t t
704 +s,@GRAPHICS_SUPPORT_FALSE@,$GRAPHICS_SUPPORT_FALSE,;t t
705 s,@HERCULES_SUPPORT_TRUE@,$HERCULES_SUPPORT_TRUE,;t t
706 s,@HERCULES_SUPPORT_FALSE@,$HERCULES_SUPPORT_FALSE,;t t
707 s,@SERIAL_SUPPORT_TRUE@,$SERIAL_SUPPORT_TRUE,;t t
710 @@ -595,6 +595,11 @@ AC_ARG_ENABLE(diskless,
711 [ --enable-diskless enable diskless support])
712 AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
714 +dnl Graphical splashscreen support
715 +AC_ARG_ENABLE(graphics,
716 + [ --disable-graphics disable graphics terminal support])
717 +AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno)
719 dnl Hercules terminal
720 AC_ARG_ENABLE(hercules,
721 [ --disable-hercules disable hercules terminal support])
725 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23.
726 -.TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF
727 +.TH GRUB "8" "September 2005" "grub (GNU GRUB 0.97)" FSF
729 grub \- the grub shell
733 @@ -2199,6 +2199,7 @@ Commands usable anywhere in the menu and
734 * rarp:: Initialize a network device via RARP
735 * serial:: Set up a serial device
736 * setkey:: Configure the key map
737 +* splashimage:: Use a splash image
738 * terminal:: Choose a terminal
739 * terminfo:: Define escape sequences for a terminal
740 * tftpserver:: Specify a TFTP server
741 @@ -2578,6 +2579,16 @@ character each of the symbols correspond
746 +@subsection splashimage
748 +@deffn Command splashimage file
749 +Select an image to use as the background image. This should be
750 +specified using normal GRUB device naming syntax. The format of the
751 +file is a gzipped xpm which is 640x480 with a 14 color palette.
758 @@ -2685,6 +2696,7 @@ you forget a command, you can run the co
759 * module:: Load a module
760 * modulenounzip:: Load a module without decompression
761 * pause:: Wait for a key press
762 +* print:: Print a message
763 * quit:: Exit from the grub shell
764 * reboot:: Reboot your computer
765 * read:: Read data from memory
766 @@ -3091,6 +3103,16 @@ change floppies.
773 +@deffn Command print message @dots{}
774 +Print the @var{message}. Note that placing @key{^G} (ASCII code 7) in the
775 +message will cause the speaker to emit the standard beep sound, which is
776 +useful for visually impaired people.
783 --- a/docs/multiboot.texi
784 +++ b/docs/multiboot.texi
787 Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
788 Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
789 -Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
790 +Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
792 Permission is granted to make and distribute verbatim copies of
793 this manual provided the copyright notice and this permission notice
794 @@ -57,7 +57,7 @@ into another language, under the above c
795 @vskip 0pt plus 1filll
796 Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
797 Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
798 -Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
799 +Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
801 Permission is granted to make and distribute verbatim copies of
802 this manual provided the copyright notice and this permission notice
803 @@ -80,7 +80,7 @@ into another language, under the above c
804 @top Multiboot Specification
806 This file documents Multiboot Specification, the proposal for the boot
807 -sequence standard. This edition documents version 0.6.93.
808 +sequence standard. This edition documents version 0.6.94.
812 @@ -426,7 +426,7 @@ mode table (@pxref{Boot information form
815 If bit 16 in the @samp{flags} word is set, then the fields at offsets
816 -8-24 in the Multiboot header are valid, and the boot loader should use
817 +12-28 in the Multiboot header are valid, and the boot loader should use
818 them instead of the fields in the actual executable header to calculate
819 where to load the OS image. This information does not need to be
820 provided if the kernel image is in @sc{elf} format, but it @emph{must}
821 @@ -677,7 +677,7 @@ follows:
824 +-------+-------+-------+-------+
825 -| drive | part1 | part2 | part3 |
826 +| part3 | part2 | part1 | drive |
827 +-------+-------+-------+-------+
830 @@ -1199,6 +1199,13 @@ The maintainer changes to the GNU GRUB m
831 @email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn.
835 +The byte order of the @samp{boot_device} in Multiboot information is
836 +reversed. This was a mistake.
839 +The offset of the address fields were wrong.
846 @@ -42,6 +42,12 @@ int grub_stage2 (void);
847 #include <sys/time.h>
850 +#include <sys/mman.h>
854 +#define PAGESIZE 4096
858 # include <sys/ioctl.h> /* ioctl */
859 @@ -55,6 +61,10 @@ int grub_stage2 (void);
860 # endif /* ! BLKFLSBUF */
861 #endif /* __linux__ */
863 +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
864 +# include <sys/sysctl.h>
867 /* We want to prevent any circularararity in our stubs, as well as
868 libc name clashes. */
869 #define WITHOUT_LIBC_STUBS 1
870 @@ -144,6 +154,22 @@ grub_stage2 (void)
871 assert (grub_scratch_mem == 0);
872 scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15);
879 + /* Align to a multiple of PAGESIZE, assumed to be a power of two. */
880 + p = (char *) (((long) scratch) & ~(PAGESIZE - 1));
882 + /* The simulated stack needs to be executable, since GCC uses stack
883 + * trampolines to implement nested functions.
885 + ret = mprotect (p, 0x100000 + EXTENDED_MEMSIZE + 15,
886 + PROT_READ | PROT_WRITE | PROT_EXEC);
890 grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4);
892 /* FIXME: simulate the memory holes using mprot, if available. */
893 @@ -777,7 +803,39 @@ get_diskinfo (int drive, struct geometry
895 /* Open read/write, or read-only if that failed. */
897 - disks[drive].flags = open (devname, O_RDWR);
899 +/* By default, kernel of FreeBSD does not allow overwriting MBR */
900 +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
901 +#define GEOM_SYSCTL "kern.geom.debugflags"
902 + int old_flags, flags;
903 + size_t sizeof_int = sizeof (int);
905 + if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0)
906 + grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
908 + if ((old_flags & 0x10) == 0)
910 + /* "allow foot shooting", see geom(4) */
911 + flags = old_flags | 0x10;
913 + if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0)
916 + grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
922 + disks[drive].flags = open (devname, O_RDWR);
923 +#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
924 + if (flags != old_flags)
926 + if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0)
927 + grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
932 if (disks[drive].flags == -1)
936 @@ -32,6 +32,7 @@ int grub_stage2 (void);
937 #define WITHOUT_LIBC_STUBS 1
942 char *program_name = 0;
943 int use_config_file = 1;
944 @@ -192,6 +193,12 @@ main (int argc, char **argv)
948 + if (boot_drive >= NUM_DISKS)
950 + fprintf (stderr, "boot_drive should be from 0 to %d\n",
956 case OPT_NO_CONFIG_FILE:
959 @@ -131,6 +131,152 @@ get_kfreebsd_version ()
963 +#if defined(__linux__)
964 +/* The 2.6 kernel has removed all of the geometry handling for IDE drives
965 + * that did fixups for LBA, etc. This means that the geometry we get
966 + * with the ioctl has a good chance of being wrong. So, we get to
967 + * also know about partition tables and try to read what the geometry
968 + * is there. *grumble* Very closely based on code from cfdisk
970 +static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
971 + struct hd_geometry hdg;
973 + if (ioctl (fd, HDIO_GETGEO, &hdg))
976 + *cyl = hdg.cylinders;
977 + *heads = hdg.heads;
978 + *sectors = hdg.sectors;
982 + unsigned char boot_ind; /* 0x80 - active */
983 + unsigned char head; /* starting head */
984 + unsigned char sector; /* starting sector */
985 + unsigned char cyl; /* starting cylinder */
986 + unsigned char sys_ind; /* What partition type */
987 + unsigned char end_head; /* end head */
988 + unsigned char end_sector; /* end sector */
989 + unsigned char end_cyl; /* end cylinder */
990 + unsigned char start4[4]; /* starting sector counting from 0 */
991 + unsigned char size4[4]; /* nr of sectors in partition */
997 + unsigned char align[ALIGNMENT];
998 + unsigned char b[SECTOR_SIZE];
1001 + unsigned char align[ALIGNMENT];
1002 + unsigned char buffer[0x1BE];
1003 + struct partition part[4];
1004 + unsigned char magicflag[2];
1008 +#define PART_TABLE_FLAG0 0x55
1009 +#define PART_TABLE_FLAG1 0xAA
1012 +get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
1014 + struct partition *p;
1019 + if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
1020 + bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
1021 + /* Matthew Wilcox: slightly friendlier version of
1022 + fatal(_("Bad signature on partition table"), 3);
1024 + fprintf(stderr, "Unknown partition table signature\n");
1029 + for (i=0; i<4; i++) {
1030 + p = &(bufp->p.part[i]);
1031 + if (p->sys_ind != 0) {
1032 + h = p->end_head + 1;
1033 + s = (p->end_sector & 077);
1038 + } else if (hh != h || ss != s)
1043 + if (!first && !bad) {
1049 +static long long my_lseek (unsigned int fd, long long offset,
1050 + unsigned int origin)
1052 +#if defined(__linux__) && (!defined(__GLIBC__) || \
1053 + ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
1054 + /* Maybe libc doesn't have large file support. */
1055 + loff_t offset, result;
1056 + static int _llseek (uint filedes, ulong hi, ulong lo,
1057 + loff_t *res, uint wh);
1058 + _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
1059 + loff_t *, res, uint, wh);
1061 + if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
1062 + return (long long) -1;
1065 + return lseek(fd, offset, SEEK_SET);
1069 +static void get_linux_geometry (int fd, struct geometry *geom) {
1070 + long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
1071 + long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
1072 + partition_table bufp;
1073 + char *buff, *buf_unaligned;
1075 + buf_unaligned = malloc(sizeof(partition_table) + 4095);
1076 + buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
1079 + get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
1081 + if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
1082 + fprintf(stderr, "Unable to seek");
1085 + if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
1086 + memcpy(bufp.c.b, buff, SECTOR_SIZE);
1087 + get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
1089 + fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
1092 + if (pt_head && pt_sectors) {
1095 + geom->heads = pt_head;
1096 + geom->sectors = pt_sectors;
1097 + cyl_size = pt_head * pt_sectors;
1098 + geom->cylinders = geom->total_sectors/cyl_size;
1100 + geom->heads = kern_head;
1101 + geom->sectors = kern_sectors;
1102 + geom->cylinders = kern_cyl;
1109 /* Get the geometry of a drive DRIVE. */
1111 get_drive_geometry (struct geometry *geom, char **map, int drive)
1112 @@ -151,21 +297,16 @@ get_drive_geometry (struct geometry *geo
1113 #if defined(__linux__)
1116 - struct hd_geometry hdg;
1119 - if (ioctl (fd, HDIO_GETGEO, &hdg))
1122 if (ioctl (fd, BLKGETSIZE, &nr))
1125 /* Got the geometry, so save it. */
1126 - geom->cylinders = hdg.cylinders;
1127 - geom->heads = hdg.heads;
1128 - geom->sectors = hdg.sectors;
1129 geom->total_sectors = nr;
1131 + get_linux_geometry(fd, geom);
1132 + if (!geom->heads && !geom->cylinders && !geom->sectors)
1137 @@ -403,6 +544,18 @@ get_dac960_disk_name (char *name, int co
1141 +get_cciss_disk_name (char *name, int controller, int drive)
1143 + sprintf (name, "/dev/cciss/c%dd%d", controller, drive);
1147 +get_ida_disk_name (char *name, int controller, int drive)
1149 + sprintf (name, "/dev/ida/c%dd%d", controller, drive);
1153 get_ataraid_disk_name (char *name, int unit)
1155 sprintf (name, "/dev/ataraid/d%c", unit + '0');
1156 @@ -801,6 +954,74 @@ init_device_map (char ***map, const char
1161 + /* This is for CCISS, its like the DAC960 - we have
1162 + /dev/cciss/<controller>d<logical drive>p<partition>
1164 + It currently supports up to 3 controllers, 10 logical volumes
1167 + Code gratuitously copied from DAC960 above.
1168 + Horms <horms@verge.net.au> 23rd July 2004
1171 + int controller, drive;
1173 + for (controller = 0; controller < 2; controller++)
1175 + for (drive = 0; drive < 9; drive++)
1179 + get_cciss_disk_name (name, controller, drive);
1180 + if (check_device (name))
1182 + (*map)[num_hd + 0x80] = strdup (name);
1183 + assert ((*map)[num_hd + 0x80]);
1185 + /* If the device map file is opened, write the map. */
1187 + fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
1195 + /* This is for Compaq Smart Array, its like the DAC960 - we have
1196 + /dev/ida/<controller>d<logical drive>p<partition>
1198 + It currently supports up to 3 controllers, 10 logical volumes
1201 + Code gratuitously copied from DAC960 above.
1202 + Piotr Roszatycki <dexter@debian.org>
1205 + int controller, drive;
1207 + for (controller = 0; controller < 2; controller++)
1209 + for (drive = 0; drive < 9; drive++)
1213 + get_ida_disk_name (name, controller, drive);
1214 + if (check_device (name))
1216 + (*map)[num_hd + 0x80] = strdup (name);
1217 + assert ((*map)[num_hd + 0x80]);
1219 + /* If the device map file is opened, write the map. */
1221 + fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
1228 #endif /* __linux__ */
1230 /* OK, close the device map file if opened. */
1231 @@ -844,6 +1065,7 @@ write_to_partition (char **map, int driv
1233 char dev[PATH_MAX]; /* XXX */
1235 + off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
1237 if ((partition & 0x00FF00) != 0x00FF00)
1239 @@ -861,8 +1083,14 @@ write_to_partition (char **map, int driv
1240 if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
1241 strcpy (dev + strlen(dev) - 5, "/part");
1243 - sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
1245 + sprintf (dev + strlen(dev), "%s%d",
1246 + /* Compaq smart and others */
1247 + (strncmp(dev, "/dev/ida/", 9) == 0 ||
1248 + strncmp(dev, "/dev/ataraid/", 13) == 0 ||
1249 + strncmp(dev, "/dev/cciss/", 11) == 0 ||
1250 + strncmp(dev, "/dev/rd/", 8) == 0) ? "p" : "",
1251 + ((partition >> 16) & 0xFF) + 1);
1253 /* Open the partition. */
1254 fd = open (dev, O_RDWR);
1256 @@ -870,35 +1098,13 @@ write_to_partition (char **map, int driv
1257 errnum = ERR_NO_PART;
1261 -#if defined(__linux__) && (!defined(__GLIBC__) || \
1262 - ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
1263 - /* Maybe libc doesn't have large file support. */
1265 - loff_t offset, result;
1266 - static int _llseek (uint filedes, ulong hi, ulong lo,
1267 - loff_t *res, uint wh);
1268 - _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
1269 - loff_t *, res, uint, wh);
1271 - offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
1272 - if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
1274 - errnum = ERR_DEV_VALUES;
1280 - off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
1282 - if (lseek (fd, offset, SEEK_SET) != offset)
1284 - errnum = ERR_DEV_VALUES;
1289 + if (my_lseek(fd, offset, SEEK_SET) != offset)
1291 + errnum = ERR_DEV_VALUES;
1295 if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
1299 @@ -1651,7 +1651,29 @@ ENTRY(gateA20)
1303 -3: /* use keyboard controller */
1305 + * try to switch gateA20 using PORT92, the "Fast A20 and Init"
1310 + /* skip the port92 code if it's unimplemented (read returns 0xff) */
1314 + /* set or clear bit1, the ALT_A20_GATE bit */
1322 + /* clear the INIT_NOW bit don't accidently reset the machine */
1326 +6: /* use keyboard controller */
1330 @@ -1661,9 +1683,12 @@ ENTRY(gateA20)
1336 andb $K_IBUF_FUL, %al
1340 movb $KB_OUTPUT_MASK, %al
1343 @@ -1684,6 +1709,8 @@ gdoit:
1349 andb $K_IBUF_FUL, %al
1352 @@ -1991,6 +2018,11 @@ ENTRY(ascii_key_map)
1353 ENTRY(console_getkey)
1357 + call EXT_C(console_checkkey)
1361 call EXT_C(prot_to_real)
1364 @@ -2216,7 +2248,304 @@ ENTRY(console_setcursor)
1371 +/* graphics mode functions */
1372 +#ifdef SUPPORT_GRAPHICS
1377 +VARIABLE(cursorCount)
1379 +VARIABLE(cursorBuf)
1380 +.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1384 + * set_int1c_handler(void)
1386 +ENTRY(set_int1c_handler)
1389 + /* save the original int1c handler */
1392 + movw %ax, ABS(int1c_offset)
1394 + movw %ax, ABS(int1c_segment)
1396 + /* save the new int1c handler */
1397 + movw $ABS(int1c_handler), %ax
1407 + * unset_int1c_handler(void)
1409 +ENTRY(unset_int1c_handler)
1412 + /* check if int1c_handler is set */
1414 + movw $ABS(int1c_handler), %ax
1421 + /* restore the original */
1422 + movw ABS(int1c_offset), %ax
1424 + movw ABS(int1c_segment), %ax
1433 + * blinks graphics cursor
1440 + mov $0xA000, %ax /* video in es:di */
1443 + movw $ABS(cursorY), %si
1444 + mov %ds:(%si), %bx
1446 + movw $ABS(cursorX), %si
1447 + mov %ds:(%si), %bx
1448 + shr $3, %bx /* %bx /= 8 */
1452 + movw $ABS(cursorBuf), %si /* fontBuf in ds:si */
1454 + /* prepare for data moving */
1455 + mov $16, %dx /* altura da fonte */
1456 + mov $80, %bx /* bytes por linha */
1459 + movb %ds:(%si), %al
1461 + movb %al, %ds:(%si) /* invert cursorBuf */
1462 + movb %al, %es:(%di) /* write to video */
1473 + mov $ABS(cursorCount), %si
1474 + mov %ds:(%si), %ax
1476 + mov %ax, %ds:(%si)
1481 + mov %ax, %ds:(%si)
1487 + /* call previous int1c handler */
1490 +int1c_offset: .word 0
1491 +int1c_segment: .word 0
1496 + * unsigned char set_videomode(unsigned char mode)
1497 + * BIOS call "INT 10H Function 0h" to set video mode
1498 + * Call with %ah = 0x0
1499 + * %al = video mode
1500 + * Returns old videomode.
1502 +ENTRY(set_videomode)
1510 + call EXT_C(prot_to_real)
1515 + int $0x10 /* Get Current Video mode */
1519 + int $0x10 /* Set Video mode */
1521 + DATA32 call EXT_C(real_to_prot)
1534 + * int get_videomode()
1535 + * BIOS call "INT 10H Function 0Fh" to get current video mode
1536 + * Call with %al = 0x0
1538 + * Returns current videomode.
1540 +ENTRY(get_videomode)
1546 + call EXT_C(prot_to_real)
1551 + int $0x10 /* Get Current Video mode */
1552 + movb %al, %cl /* For now we only want display mode */
1554 + DATA32 call EXT_C(real_to_prot)
1567 + * unsigned char * graphics_get_font()
1568 + * BIOS call "INT 10H Function 11h" to set font
1569 + * Call with %ah = 0x11
1571 +ENTRY(graphics_get_font)
1577 + call EXT_C(prot_to_real)
1581 + movb $6, %bh /* font 8x16 */
1586 + DATA32 call EXT_C(real_to_prot)
1602 + * graphics_set_palette(index, red, green, blue)
1603 + * BIOS call "INT 10H Function 10h" to set individual dac register
1604 + * Call with %ah = 0x10
1605 + * %bx = register number
1606 + * %ch = new value for green (0-63)
1607 + * %cl = new value for blue (0-63)
1608 + * %dh = new value for red (0-63)
1611 +ENTRY(graphics_set_palette)
1618 + movw $0x3c8, %bx /* address write mode register */
1620 + /* wait vertical retrace */
1623 + inb %dx, %al /* wait vertical active display */
1628 + inb %dx, %al /* wait vertical retrace */
1633 + movb 0x18(%esp), %al /* index */
1637 + movb 0x1c(%esp), %al /* red */
1640 + movb 0x20(%esp), %al /* green */
1643 + movb 0x24(%esp), %al /* blue */
1646 + movw 0x18(%esp), %bx
1648 + call EXT_C(prot_to_real)
1655 + DATA32 call EXT_C(real_to_prot)
1664 +#endif /* SUPPORT_GRAPHICS */
1669 * if a seconds value can be read, read it and return it (BCD),
1673 /* boot.c - load and bootstrap a kernel */
1675 * GRUB -- GRand Unified Bootloader
1676 - * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
1677 + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
1679 * This program is free software; you can redistribute it and/or modify
1680 * it under the terms of the GNU General Public License as published by
1681 @@ -29,6 +29,8 @@ static int cur_addr;
1682 entry_func entry_addr;
1683 static struct mod_list mll[99];
1684 static int linux_mem_size;
1685 +static int elf_kernel_addr;
1686 +static int elf_kernel_size;
1689 * The next two functions, 'load_image' and 'load_module', are the building
1690 @@ -96,7 +98,7 @@ load_image (char *kernel, char *arg, ker
1691 lh = (struct linux_kernel_header *) buffer;
1693 /* ELF loading supported if multiboot, FreeBSD and NetBSD. */
1694 - if ((type == KERNEL_TYPE_MULTIBOOT
1695 + if (((type == KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KLUDGE))
1696 || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
1697 || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
1698 || suggested_type == KERNEL_TYPE_NETBSD)
1699 @@ -594,6 +596,7 @@ load_image (char *kernel, char *arg, ker
1701 /* reset this to zero for now */
1703 + elf_kernel_addr = ~0;
1705 /* scan for program segments */
1706 for (i = 0; i < pu.elf->e_phnum; i++)
1707 @@ -630,6 +633,8 @@ load_image (char *kernel, char *arg, ker
1708 /* mark memory as used */
1709 if (cur_addr < memaddr + memsiz)
1710 cur_addr = memaddr + memsiz;
1711 + if (elf_kernel_addr > cur_addr)
1712 + elf_kernel_addr = cur_addr;
1713 printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
1715 /* increment number of segments */
1716 @@ -647,6 +652,8 @@ load_image (char *kernel, char *arg, ker
1720 + elf_kernel_size = cur_addr - elf_kernel_addr;
1725 @@ -824,8 +831,11 @@ load_initrd (char *initrd)
1726 moveto = (mbi.mem_upper + 0x400) << 10;
1728 moveto = (moveto - len) & 0xfffff000;
1729 - max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
1730 - ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
1731 + max_addr = LINUX_INITRD_MAX_ADDRESS;
1732 + if (lh->header == LINUX_MAGIC_SIGNATURE &&
1733 + lh->version >= 0x0203 &&
1734 + lh->initrd_addr_max < max_addr)
1735 + max_addr = lh->initrd_addr_max;
1736 if (moveto + len >= max_addr)
1737 moveto = (max_addr - len) & 0xfffff000;
1739 @@ -864,6 +874,129 @@ bsd_boot_entry (int flags, int bootdev,
1743 +#define mem_align4k(p) ((p) + 0xFFF) & 0xFFFFF000
1746 +kfreebsd_setenv (char *env, const char *var, const char *value)
1750 + if (env[0] == '\0' && env[1] == '\0')
1759 + grub_sprintf (env, "%s=%s", var, value);
1760 + env[grub_strlen (env) + 1] = '\0';
1764 +kfreebsd_read_hints (char *buf)
1766 + char *buf_end = buf;
1768 + if (grub_open ("/boot/device.hints"))
1775 + env_len = grub_read (buf, -1);
1778 + buf_end += env_len;
1779 + *(buf_end++) = '\0';
1786 + envp = line_start = buf;
1789 + char *envp_current = envp;
1794 + while (*envp == ' ')
1799 + grub_memmove (envp_current, envp, env_len + 1);
1800 + envp = envp_current;
1803 + while (*envp != '\n')
1810 + grub_memmove (envp_current, envp, env_len + 1);
1811 + envp = envp_current;
1817 + grub_memmove (line_start, envp, env_len + 1);
1821 + line_start = envp;
1829 + buf_end = buf + env_len;
1830 + *(buf_end++) = '\0';
1837 +kfreebsd_set_module_string (u32_t type, u32_t *dst, char *src)
1842 + *(dst++) = size = grub_strlen (src) + 1;
1843 + grub_strcpy ((void *) dst, src);
1845 + return dst + (size + sizeof(u32_t) - 1) / sizeof(u32_t);
1849 +kfreebsd_set_module_var (u32_t type, u32_t *dst, u32_t src)
1852 + *(dst++) = sizeof(u32_t);
1859 +kfreebsd_set_modules (u32_t *modulep)
1861 + /* XXX: Need to copy the whole module structure. */
1862 + /* XXX: How to pass the module name ? */
1868 * All "*_boot" commands depend on the images being loaded into memory
1869 @@ -877,7 +1010,10 @@ void
1870 bsd_boot (kernel_t type, int bootdev, char *arg)
1881 @@ -886,8 +1022,21 @@ bsd_boot (kernel_t type, int bootdev, ch
1885 + while (*arg != '/')
1889 while (*(++arg) && *arg != ' ');
1893 + bsd_root = grub_strstr (str, "root=");
1897 + /* XXX: should copy the str or terminate it. */
1903 @@ -910,6 +1059,8 @@ bsd_boot (kernel_t type, int bootdev, ch
1908 + clval |= RB_PAUSE;
1912 @@ -927,14 +1078,17 @@ bsd_boot (kernel_t type, int bootdev, ch
1914 if (type == KERNEL_TYPE_FREEBSD)
1919 clval |= RB_BOOTINFO;
1921 bi.bi_version = BOOTINFO_VERSION;
1924 - while ((--arg) > (char *) MB_CMDLINE_BUF && *arg != '/');
1926 - bi.bi_kernelname = arg + 1;
1927 + bi.bi_pad[0] = bi.bi_pad[1] = 0;
1929 + if (*kernelname == '/')
1930 + bi.bi_kernelname = kernelname;
1932 bi.bi_kernelname = 0;
1934 @@ -961,6 +1115,30 @@ bsd_boot (kernel_t type, int bootdev, ch
1935 bi.bi_basemem = mbi.mem_lower;
1936 bi.bi_extmem = extended_memory;
1938 + /* Setup the environment. */
1939 + bi.bi_envp = cur_addr = mem_align4k (cur_addr);
1940 + grub_memset ((void *) cur_addr, 0, 2);
1941 + cur_addr = (int) kfreebsd_read_hints ((void *) cur_addr);
1943 + envp = (char *) bi.bi_envp;
1944 + kfreebsd_setenv (envp, "kernelname", kernelname);
1945 + kfreebsd_setenv (envp, "vfs.root.mountfrom", bsd_root);
1947 + /* Setup the modules list. */
1948 + bi.bi_modulep = cur_addr = mem_align4k (cur_addr);
1949 + modp = (u32_t *) bi.bi_modulep;
1950 + /* The first module is the kernel. */
1951 + modp = kfreebsd_set_module_string (MODINFO_NAME, modp, kernelname);
1952 + modp = kfreebsd_set_module_string (MODINFO_TYPE, modp, "elf kernel");
1953 + modp = kfreebsd_set_module_string (MODINFO_ARGS, modp, arg);
1954 + modp = kfreebsd_set_module_var (MODINFO_ADDR, modp, elf_kernel_addr);
1955 + modp = kfreebsd_set_module_var (MODINFO_SIZE, modp, elf_kernel_size);
1956 + /* Now the real modules. */
1957 + modp = kfreebsd_set_modules(modp);
1959 + /* Set the kernel end. */
1960 + bi.bi_kernend = cur_addr = mem_align4k (((int) modp) + 1);
1962 if (mbi.flags & MB_INFO_AOUT_SYMS)
1964 bi.bi_symtab = mbi.syms.a.addr;
1965 @@ -970,8 +1148,9 @@ bsd_boot (kernel_t type, int bootdev, ch
1967 else if (mbi.flags & MB_INFO_ELF_SHDR)
1969 - /* FIXME: Should check if a symbol table exists and, if exists,
1970 - pass the table to BI. */
1971 + bi.bi_symtab = mbi.syms.e.addr;
1972 + bi.bi_esymtab = mbi.syms.e.addr
1973 + + mbi.syms.e.size * mbi.syms.e.num * mbi.syms.e.shndx;
1977 --- a/stage2/builtins.c
1978 +++ b/stage2/builtins.c
1980 #include <filesys.h>
1983 +#ifdef SUPPORT_GRAPHICS
1984 +# include <graphics.h>
1987 #ifdef SUPPORT_NETBOOT
1989 # include <etherboot.h>
1990 @@ -82,6 +86,10 @@ static unsigned short bios_drive_map[DRI
1991 inside other functions. */
1992 static int configfile_func (char *arg, int flags);
1994 +static int savedefault_helper (char *arg, int flags);
1996 +static int savedefault_shell (char *arg, int flags);
1998 /* Initialize the data for builtins. */
2000 init_builtins (void)
2001 @@ -237,12 +245,22 @@ static struct builtin builtin_blocklist
2003 boot_func (char *arg, int flags)
2005 + struct term_entry *prev_term = current_term;
2006 /* Clear the int15 handler if we can boot the kernel successfully.
2007 This assumes that the boot code never fails only if KERNEL_TYPE is
2008 not KERNEL_TYPE_NONE. Is this assumption is bad? */
2009 if (kernel_type != KERNEL_TYPE_NONE)
2010 unset_int15_handler ();
2012 + /* if our terminal needed initialization, we should shut it down
2013 + * before booting the kernel, but we want to save what it was so
2014 + * we can come back if needed */
2015 + if (current_term->shutdown)
2017 + current_term->shutdown();
2018 + current_term = term_table; /* assumption: console is first */
2021 #ifdef SUPPORT_NETBOOT
2022 /* Shut down the networking. */
2024 @@ -306,6 +324,13 @@ boot_func (char *arg, int flags)
2028 + /* if we get back here, we should go back to what our term was before */
2029 + current_term = prev_term;
2030 + if (current_term->startup)
2031 + /* if our terminal fails to initialize, fall back to console since
2032 + * it should always work */
2033 + if (current_term->startup() == 0)
2034 + current_term = term_table; /* we know that console is first */
2038 @@ -852,6 +877,251 @@ static struct builtin builtin_dhcp =
2040 #endif /* SUPPORT_NETBOOT */
2042 +#ifdef SUPPORT_GRAPHICS
2044 +static int splashimage_func(char *arg, int flags) {
2047 + /* filename can only be 256 characters due to our buffer size */
2048 + if (grub_strlen(arg) > 256) {
2049 + grub_printf("Splash image filename too large\n");
2050 + grub_printf("Press any key to continue...");
2055 + /* get rid of TERM_NEED_INIT from the graphics terminal. */
2056 + for (i = 0; term_table[i].name; i++) {
2057 + if (grub_strcmp (term_table[i].name, "graphics") == 0) {
2058 + term_table[i].flags &= ~TERM_NEED_INIT;
2063 + graphics_set_splash(arg);
2065 + if (flags == BUILTIN_CMDLINE && graphics_inited) {
2067 + if (graphics_init() == 0) {
2068 + /* Fallback to default term */
2069 + current_term = term_table;
2070 + max_lines = current_term->max_lines;
2071 + if (current_term->cls)
2072 + current_term->cls();
2073 + grub_printf("Failed to set splash image and/or graphics mode\n");
2079 + if (flags == BUILTIN_MENU)
2080 + current_term = term_table + i;
2085 +static struct builtin builtin_splashimage =
2089 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2090 + "splashimage FILE",
2091 + "Load FILE as the background image when in graphics mode."
2097 +shade_func(char *arg, int flags)
2101 + if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
2104 + if (shade != new_shade) {
2105 + shade = new_shade;
2106 + if (flags == BUILTIN_CMDLINE && graphics_inited) {
2116 +static struct builtin builtin_shade =
2120 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2122 + "If set to 0, disables the use of shaded text, else enables it."
2128 +foreground_func(char *arg, int flags)
2130 + if (grub_strlen(arg) == 6) {
2131 + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2132 + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2133 + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2135 + foreground = (r << 16) | (g << 8) | b;
2136 + if (graphics_inited)
2137 + graphics_set_palette(15, r, g, b);
2145 +static struct builtin builtin_foreground =
2149 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2150 + "foreground RRGGBB",
2151 + "Sets the foreground color when in graphics mode."
2152 + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2158 +background_func(char *arg, int flags)
2160 + if (grub_strlen(arg) == 6) {
2161 + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2162 + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2163 + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2165 + background = (r << 16) | (g << 8) | b;
2166 + if (graphics_inited)
2167 + graphics_set_palette(0, r, g, b);
2174 +static struct builtin builtin_background =
2178 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2179 + "background RRGGBB",
2180 + "Sets the background color when in graphics mode."
2181 + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2187 +border_func(char *arg, int flags)
2189 + if (grub_strlen(arg) == 6) {
2190 + int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2191 + int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2192 + int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2194 + window_border = (r << 16) | (g << 8) | b;
2195 + if (graphics_inited)
2196 + graphics_set_palette(0x11, r, g, b);
2204 +static struct builtin builtin_border =
2208 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2210 + "Sets the border video color when in graphics mode."
2211 + "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2217 +viewport_func (char *arg, int flags)
2220 + int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
2221 + int *pos[4] = { &x0, &y0, &x1, &y1 };
2225 + for (i = 0; i < 4; i++) {
2228 + while (*arg && (*arg == ' ' || *arg == '\t'))
2230 + if (!safe_parse_maxint(&arg, pos[i]))
2232 + while (*arg && (*arg != ' ' && *arg != '\t'))
2236 + /* minimum size is 65 colums and 16 rows */
2237 + if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
2245 + if (flags == BUILTIN_CMDLINE && graphics_inited) {
2254 +static struct builtin builtin_viewport =
2258 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2259 + "viewport x0 y0 x1 y1",
2260 + "Changes grub internals to output text in the window defined by"
2261 + " four parameters. The x and y parameters are 0 based. This option"
2262 + " only works with the graphics interface."
2265 +#endif /* SUPPORT_GRAPHICS */
2272 + if (current_term->cls)
2273 + current_term->cls();
2278 +static struct builtin builtin_clear =
2282 + BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
2284 + "Clear the screen"
2290 @@ -1454,14 +1724,20 @@ static struct builtin builtin_halt =
2294 -#define MAX_SHORT_DOC_LEN 39
2295 -#define MAX_LONG_DOC_LEN 66
2298 help_func (char *arg, int flags)
2302 + int all = 0, max_short_doc_len, max_long_doc_len;
2303 + max_short_doc_len = 39;
2304 + max_long_doc_len = 66;
2305 +#ifdef SUPPORT_GRAPHICS
2306 + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
2308 + max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
2309 + max_long_doc_len = (view_x1 - view_x0) - 14;
2313 if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
2316 @@ -1491,13 +1767,13 @@ help_func (char *arg, int flags)
2318 len = grub_strlen ((*builtin)->short_doc);
2319 /* If the length of SHORT_DOC is too long, truncate it. */
2320 - if (len > MAX_SHORT_DOC_LEN - 1)
2321 - len = MAX_SHORT_DOC_LEN - 1;
2322 + if (len > max_short_doc_len - 1)
2323 + len = max_short_doc_len - 1;
2325 for (i = 0; i < len; i++)
2326 grub_putchar ((*builtin)->short_doc[i]);
2328 - for (; i < MAX_SHORT_DOC_LEN; i++)
2329 + for (; i < max_short_doc_len; i++)
2333 @@ -1546,10 +1822,10 @@ help_func (char *arg, int flags)
2336 /* If LEN is too long, fold DOC. */
2337 - if (len > MAX_LONG_DOC_LEN)
2338 + if (len > max_long_doc_len)
2340 /* Fold this line at the position of a space. */
2341 - for (len = MAX_LONG_DOC_LEN; len > 0; len--)
2342 + for (len = max_long_doc_len; len > 0; len--)
2343 if (doc[len - 1] == ' ')
2346 @@ -2323,6 +2599,25 @@ static struct builtin builtin_ioprobe =
2347 "Probe I/O ports used for the drive DRIVE."
2352 +print_func (char *arg, int flags)
2354 + printf("%s\n", arg);
2359 +static struct builtin builtin_print =
2363 + BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO,
2364 + "print [MESSAGE ...]",
2372 @@ -3221,7 +3516,102 @@ static struct builtin builtin_rootnoveri
2374 savedefault_func (char *arg, int flags)
2376 -#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
2377 +#if !defined(SUPPORT_DISKLESS)
2378 + #if !defined(GRUB_UTIL)
2379 + savedefault_helper(arg, flags);
2381 + savedefault_shell(arg, flags);
2383 +#else /* !SUPPORT_DISKLESS */
2384 + errnum = ERR_UNRECOGNIZED;
2386 +#endif /* !SUPPORT_DISKLESS */
2389 +#if !defined(SUPPORT_DISKLESS) && defined(GRUB_UTIL)
2390 +/* savedefault_shell */
2392 +savedefault_shell(char *arg, int flags)
2394 + int once_only = 0;
2396 + int curr_default = -1;
2397 + int curr_prev_default = -1;
2398 + int new_prev_default = -1;
2400 + size_t bytes = 10;
2402 + char *default_file = (char *) DEFAULT_FILE_BUF;
2408 + if (grub_memcmp ("--default=", arg, sizeof ("--default=") - 1) == 0)
2410 + char *p = arg + sizeof ("--default=") - 1;
2411 + if (! safe_parse_maxint (&p, &new_default))
2413 + arg = skip_to (0, arg);
2415 + else if (grub_memcmp ("--once", arg, sizeof ("--once") - 1) == 0)
2418 + arg = skip_to (0, arg);
2424 + *default_file = 0;
2425 + grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN);
2426 + for (i = grub_strlen(default_file); i >= 0; i--)
2427 + if (default_file[i] == '/')
2432 + default_file[i] = 0;
2433 + grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i);
2435 + if(!(fp = fopen(default_file,"w")))
2437 + errnum = ERR_READ;
2443 + sscanf(line, "%d:%d", &curr_prev_default, &curr_default);
2445 + if(curr_default != -1)
2446 + new_prev_default = curr_default;
2449 + if(curr_prev_default != -1)
2450 + new_prev_default = curr_prev_default;
2452 + new_prev_default = 0;
2456 + sprintf(buf, "%d:%d\n", new_prev_default, new_default);
2458 + sprintf(buf, "%d\n", new_default);
2468 +/* savedefault_helper */
2470 +savedefault_helper (char *arg, int flags)
2472 +#if !defined(SUPPORT_DISKLESS)
2473 unsigned long tmp_drive = saved_drive;
2474 unsigned long tmp_partition = saved_partition;
2475 char *default_file = (char *) DEFAULT_FILE_BUF;
2476 @@ -3300,19 +3690,23 @@ savedefault_func (char *arg, int flags)
2480 - if (len != sizeof (buf))
2482 - /* This is too small. Do not modify the file manually, please! */
2483 - errnum = ERR_READ;
2487 if (sector_count > 2)
2489 /* Is this possible?! Too fragmented! */
2490 errnum = ERR_FSYS_CORRUPT;
2495 + if((tmp = grub_strstr(buf, ":")) != NULL)
2497 + int f_len = grub_strlen(buf) - grub_strlen(tmp);
2500 + for(a = 0; a < f_len; a++)
2501 + grub_memcpy(&def[a], &buf[a], sizeof(char));
2502 + safe_parse_maxint (&def, &entryno);
2505 /* Set up a string to be written. */
2506 grub_memset (buf, '\n', sizeof (buf));
2507 @@ -3830,15 +4224,15 @@ setup_func (char *arg, int flags)
2510 grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF);
2511 - grub_strncat (device, tmp, 256);
2512 + grub_strncat (device, tmp, sizeof (device));
2514 if ((partition & 0x00FF00) != 0x00FF00)
2517 grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF));
2518 - grub_strncat (device, tmp, 256);
2519 + grub_strncat (device, tmp, sizeof (device));
2521 - grub_strncat (device, ")", 256);
2522 + grub_strncat (device, ")", sizeof (device));
2525 int embed_stage1_5 (char *stage1_5, int drive, int partition)
2526 @@ -4085,7 +4479,7 @@ static struct builtin builtin_setup =
2530 -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
2531 +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
2534 terminal_func (char *arg, int flags)
2535 @@ -4244,17 +4638,29 @@ terminal_func (char *arg, int flags)
2537 current_term = term_table + default_term;
2538 current_term->flags = term_flags;
2544 - /* 24 would be a good default value. */
2547 + max_lines = current_term->max_lines;
2549 /* If the interface is currently the command-line,
2550 restart it to repaint the screen. */
2551 - if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
2552 + if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
2553 + if (prev_term->shutdown)
2554 + prev_term->shutdown();
2555 + if (current_term->startup) {
2556 + /* If startup fails, return to previous term */
2557 + if (current_term->startup() == 0) {
2558 + current_term = prev_term;
2559 + max_lines = current_term->max_lines;
2560 + if (current_term->cls) {
2561 + current_term->cls();
2565 grub_longjmp (restart_cmdline_env, 0);
2570 @@ -4264,7 +4670,7 @@ static struct builtin builtin_terminal =
2573 BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
2574 - "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
2575 + "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
2576 "Select a terminal. When multiple terminals are specified, wait until"
2577 " you push any key to continue. If both console and serial are specified,"
2578 " the terminal to which you input a key first will be selected. If no"
2579 @@ -4276,7 +4682,7 @@ static struct builtin builtin_terminal =
2580 " seconds. The option --lines specifies the maximum number of lines."
2581 " The option --silent is used to suppress messages."
2583 -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
2584 +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
2587 #ifdef SUPPORT_SERIAL
2588 @@ -4795,13 +5201,20 @@ static struct builtin builtin_vbeprobe =
2589 /* The table of builtin commands. Sorted in dictionary order. */
2590 struct builtin *builtin_table[] =
2592 +#ifdef SUPPORT_GRAPHICS
2593 + &builtin_background,
2597 #ifdef SUPPORT_NETBOOT
2599 #endif /* SUPPORT_NETBOOT */
2600 +#ifdef SUPPORT_GRAPHICS
2604 &builtin_chainloader,
2608 &builtin_configfile,
2609 @@ -4821,6 +5234,9 @@ struct builtin *builtin_table[] =
2613 +#ifdef SUPPORT_GRAPHICS
2614 + &builtin_foreground,
2619 @@ -4848,6 +5264,7 @@ struct builtin *builtin_table[] =
2626 #endif /* GRUB_UTIL */
2627 @@ -4864,9 +5281,13 @@ struct builtin *builtin_table[] =
2628 #endif /* SUPPORT_SERIAL */
2631 -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
2632 +#ifdef SUPPORT_GRAPHICS
2634 + &builtin_splashimage,
2635 +#endif /* SUPPORT_GRAPHICS */
2636 +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
2638 -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
2639 +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
2640 #ifdef SUPPORT_SERIAL
2642 #endif /* SUPPORT_SERIAL */
2643 @@ -4880,5 +5301,8 @@ struct builtin *builtin_table[] =
2647 +#ifdef SUPPORT_GRAPHICS
2648 + &builtin_viewport,
2652 --- a/stage2/char_io.c
2653 +++ b/stage2/char_io.c
2655 # include <serial.h>
2658 +#ifdef SUPPORT_GRAPHICS
2659 +# include <graphics.h>
2663 struct term_entry term_table[] =
2672 @@ -43,13 +48,16 @@ struct term_entry term_table[] =
2674 console_setcolorstate,
2677 + console_setcursor,
2681 #ifdef SUPPORT_SERIAL
2684 /* A serial device must be initialized. */
2690 @@ -58,6 +66,8 @@ struct term_entry term_table[] =
2692 serial_setcolorstate,
2698 #endif /* SUPPORT_SERIAL */
2699 @@ -65,6 +75,7 @@ struct term_entry term_table[] =
2707 @@ -73,11 +84,30 @@ struct term_entry term_table[] =
2709 hercules_setcolorstate,
2711 - hercules_setcursor
2712 + hercules_setcursor,
2716 #endif /* SUPPORT_HERCULES */
2717 +#ifdef SUPPORT_GRAPHICS
2719 + TERM_NEED_INIT, /* flags */
2720 + 30, /* number of lines */
2721 + graphics_putchar, /* putchar */
2722 + console_checkkey, /* checkkey */
2723 + console_getkey, /* getkey */
2724 + graphics_getxy, /* getxy */
2725 + graphics_gotoxy, /* gotoxy */
2726 + graphics_cls, /* cls */
2727 + graphics_setcolorstate, /* setcolorstate */
2728 + graphics_setcolor, /* setcolor */
2729 + graphics_setcursor, /* nocursor */
2730 + graphics_init, /* initialize */
2731 + graphics_end /* shutdown */
2733 +#endif /* SUPPORT_GRAPHICS */
2734 /* This must be the last entry. */
2735 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
2736 + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
2739 /* This must be console. */
2740 @@ -305,9 +335,10 @@ real_get_cmdline (char *prompt, char *cm
2742 /* XXX: These should be defined in shared.h, but I leave these here,
2743 until this code is freezed. */
2744 -#define CMDLINE_WIDTH 78
2745 #define CMDLINE_MARGIN 10
2748 + /* command-line limits */
2749 + int cmdline_width = 78, col_start = 0;
2750 int xpos, lpos, c, section;
2751 /* The length of PROMPT. */
2753 @@ -338,7 +369,7 @@ real_get_cmdline (char *prompt, char *cm
2755 /* If the cursor is in the first section, display the first section
2756 instead of the second. */
2757 - if (section == 1 && plen + lpos < CMDLINE_WIDTH)
2758 + if (section == 1 && plen + lpos < cmdline_width)
2760 else if (xpos - count < 1)
2762 @@ -354,7 +385,7 @@ real_get_cmdline (char *prompt, char *cm
2763 grub_putchar ('\b');
2766 - gotoxy (xpos, getxy () & 0xFF);
2767 + gotoxy (xpos + col_start, getxy () & 0xFF);
2771 @@ -364,7 +395,7 @@ real_get_cmdline (char *prompt, char *cm
2774 /* If the cursor goes outside, scroll the screen to the right. */
2775 - if (xpos + count >= CMDLINE_WIDTH)
2776 + if (xpos + count >= cmdline_width)
2780 @@ -383,7 +414,7 @@ real_get_cmdline (char *prompt, char *cm
2784 - gotoxy (xpos, getxy () & 0xFF);
2785 + gotoxy (xpos + col_start, getxy () & 0xFF);
2789 @@ -398,14 +429,14 @@ real_get_cmdline (char *prompt, char *cm
2792 /* Recompute the section number. */
2793 - if (lpos + plen < CMDLINE_WIDTH)
2794 + if (lpos + plen < cmdline_width)
2797 - section = ((lpos + plen - CMDLINE_WIDTH)
2798 - / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
2799 + section = ((lpos + plen - cmdline_width)
2800 + / (cmdline_width - 1 - CMDLINE_MARGIN) + 1);
2802 /* From the start to the end. */
2803 - len = CMDLINE_WIDTH;
2804 + len = cmdline_width;
2806 grub_putchar ('\r');
2808 @@ -445,8 +476,8 @@ real_get_cmdline (char *prompt, char *cm
2812 - start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
2813 - + CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
2814 + start = ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN)
2815 + + cmdline_width - plen - CMDLINE_MARGIN);
2816 xpos = lpos + 1 - start;
2819 @@ -471,7 +502,7 @@ real_get_cmdline (char *prompt, char *cm
2821 /* If the cursor is at the last position, put `>' or a space,
2822 depending on if there are more characters in BUF. */
2823 - if (pos == CMDLINE_WIDTH)
2824 + if (pos == cmdline_width)
2826 if (start + len < llen)
2828 @@ -488,7 +519,7 @@ real_get_cmdline (char *prompt, char *cm
2829 grub_putchar ('\b');
2832 - gotoxy (xpos, getxy () & 0xFF);
2833 + gotoxy (xpos + col_start, getxy () & 0xFF);
2836 /* Initialize the command-line. */
2837 @@ -518,10 +549,10 @@ real_get_cmdline (char *prompt, char *cm
2841 - if (xpos + l >= CMDLINE_WIDTH)
2842 + if (xpos + l >= cmdline_width)
2844 - else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
2845 - cl_refresh (0, CMDLINE_WIDTH - xpos);
2846 + else if (xpos + l + llen - lpos > cmdline_width)
2847 + cl_refresh (0, cmdline_width - xpos);
2849 cl_refresh (0, l + llen - lpos);
2851 @@ -533,12 +564,22 @@ real_get_cmdline (char *prompt, char *cm
2852 grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
2855 - if (xpos + llen + count - lpos > CMDLINE_WIDTH)
2856 - cl_refresh (0, CMDLINE_WIDTH - xpos);
2857 + if (xpos + llen + count - lpos > cmdline_width)
2858 + cl_refresh (0, cmdline_width - xpos);
2860 cl_refresh (0, llen + count - lpos);
2863 + max_lines = current_term->max_lines;
2864 +#ifdef SUPPORT_GRAPHICS
2865 + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
2867 + cmdline_width = (view_x1 - view_x0) - 2;
2868 + col_start = view_x0;
2869 + max_lines = view_y1 - view_y0;
2873 plen = grub_strlen (prompt);
2874 llen = grub_strlen (cmdline);
2876 @@ -1006,6 +1047,48 @@ checkkey (void)
2878 #endif /* ! STAGE1_5 */
2881 +/* Internal pager. */
2885 + if (count_lines >= 0)
2888 + if (count_lines >= max_lines - 2)
2892 + /* It's important to disable the feature temporarily, because
2893 + the following grub_printf call will print newlines. */
2896 + grub_printf("\n");
2897 + if (current_term->setcolorstate)
2898 + current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
2900 + grub_printf ("[Hit return to continue]");
2902 + if (current_term->setcolorstate)
2903 + current_term->setcolorstate (COLOR_STATE_NORMAL);
2908 + tmp = ASCII_CHAR (getkey ());
2910 + while (tmp != '\n' && tmp != '\r');
2911 + grub_printf ("\r \r");
2913 + /* Restart to count lines. */
2922 /* Display an ASCII character. */
2924 grub_putchar (int c)
2925 @@ -1034,38 +1117,11 @@ grub_putchar (int c)
2930 /* Internal `more'-like feature. */
2931 - if (count_lines >= 0)
2934 - if (count_lines >= max_lines - 2)
2938 - /* It's important to disable the feature temporarily, because
2939 - the following grub_printf call will print newlines. */
2942 - if (current_term->setcolorstate)
2943 - current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
2945 - grub_printf ("\n[Hit return to continue]");
2947 - if (current_term->setcolorstate)
2948 - current_term->setcolorstate (COLOR_STATE_NORMAL);
2952 - tmp = ASCII_CHAR (getkey ());
2954 - while (tmp != '\n' && tmp != '\r');
2955 - grub_printf ("\r \r");
2957 - /* Restart to count lines. */
2962 + flag = do_more ();
2967 current_term->putchar (c);
2968 @@ -1090,7 +1146,7 @@ void
2971 /* If the terminal is dumb, there is no way to clean the terminal. */
2972 - if (current_term->flags & TERM_DUMB)
2973 + if (current_term->flags & TERM_DUMB)
2974 grub_putchar ('\n');
2976 current_term->cls ();
2977 @@ -1175,13 +1231,13 @@ grub_strlen (const char *str)
2978 #endif /* ! STAGE1_5 */
2981 -memcheck (int addr, int len)
2982 +memcheck (unsigned long int addr, unsigned long int len)
2985 - auto int start_addr (void);
2986 - auto int end_addr (void);
2987 + auto unsigned long int start_addr (void);
2988 + auto int unsigned long end_addr (void);
2990 - auto int start_addr (void)
2991 + auto unsigned long int start_addr (void)
2994 # if defined(HAVE_START_SYMBOL)
2995 @@ -1192,7 +1248,7 @@ memcheck (int addr, int len)
2999 - auto int end_addr (void)
3000 + auto unsigned long int end_addr (void)
3003 # if defined(HAVE_END_SYMBOL)
3004 @@ -1217,6 +1273,16 @@ memcheck (int addr, int len)
3009 +grub_memcpy(void *dest, const void *src, int len)
3012 + register char *d = (char*)dest, *s = (char*)src;
3014 + for (i = 0; i < len; i++)
3019 grub_memmove (void *to, const void *from, int len)
3021 --- a/stage2/cmdline.c
3022 +++ b/stage2/cmdline.c
3023 @@ -50,10 +50,11 @@ skip_to (int after_equal, char *cmdline)
3025 print_cmdline_message (int forever)
3027 - printf (" [ Minimal BASH-like line editing is supported. For the first word, TAB\n"
3028 - " lists possible command completions. Anywhere else TAB lists the possible\n"
3029 - " completions of a device/filename.%s ]\n",
3030 - (forever ? "" : " ESC at any time exits."));
3031 + grub_printf(" [ Minimal BASH-like line editing is supported. For\n"
3032 + " the first word, TAB lists possible command\n"
3033 + " completions. Anywhere else TAB lists the possible\n"
3034 + " completions of a device/filename.%s ]\n",
3035 + (forever ? "" : " ESC at any time\n exits."));
3038 /* Find the builtin whose command name is COMMAND and return the
3039 --- a/stage2/freebsd.h
3040 +++ b/stage2/freebsd.h
3044 * GRUB -- GRand Unified Bootloader
3045 - * Copyright (C) 2001 Free Software Foundation, Inc.
3046 + * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
3048 * This program is free software; you can redistribute it and/or modify
3049 * it under the terms of the GNU General Public License as published by
3051 #define RB_CDROM 0x2000 /* use cdrom as root */
3052 #define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */
3053 #define RB_MUTE 0x10000 /* Come up with the console muted */
3054 +#define RB_SELFTEST 0x20000 /* don't complete the boot; do selftest */
3055 +#define RB_RESERVED1 0x40000 /* reserved for internal use of boot blocks */
3056 +#define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */
3057 +#define RB_PAUSE 0x100000 /* pause after each output line during probe */
3058 #define RB_MULTIPLE 0x20000000 /* Use multiple consoles */
3060 #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
3063 #define N_BIOS_GEOM 8
3065 +typedef unsigned char u8_t;
3066 +typedef unsigned int u32_t;
3069 * A zero bootinfo field often means that there is no info available.
3070 * Flags are used to indicate the validity of fields where zero is a
3075 - unsigned int bi_version;
3076 - unsigned char *bi_kernelname;
3077 - struct nfs_diskless *bi_nfs_diskless;
3079 + u8_t *bi_kernelname;
3080 + u32_t bi_nfs_diskless;
3081 /* End of fields that are always present. */
3082 #define bi_endcommon bi_n_bios_used
3083 - unsigned int bi_n_bios_used;
3084 - unsigned long bi_bios_geom[N_BIOS_GEOM];
3085 - unsigned int bi_size;
3086 - unsigned char bi_memsizes_valid;
3087 - unsigned char bi_bios_dev;
3088 - unsigned char bi_pad[2];
3089 - unsigned long bi_basemem;
3090 - unsigned long bi_extmem;
3091 - unsigned long bi_symtab;
3092 - unsigned long bi_esymtab;
3093 + u32_t bi_n_bios_used;
3094 + u32_t bi_bios_geom[N_BIOS_GEOM];
3096 + u8_t bi_memsizes_valid;
3103 + /* Items below only from advanced bootloader */
3109 +#define MODINFO_END 0x0000 /* End of list */
3110 +#define MODINFO_NAME 0x0001 /* Name of module (string) */
3111 +#define MODINFO_TYPE 0x0002 /* Type of module (string) */
3112 +#define MODINFO_ADDR 0x0003 /* Loaded address */
3113 +#define MODINFO_SIZE 0x0004 /* Size of module */
3114 +#define MODINFO_EMPTY 0x0005 /* Has been deleted */
3115 +#define MODINFO_ARGS 0x0006 /* Parameters string */
3116 +#define MODINFO_METADATA 0x8000 /* Module-specfic */
3119 +++ b/stage2/graphics.c
3122 + * graphics.c - graphics mode support for GRUB
3123 + * Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
3124 + * on a patch by Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
3125 + * Options and enhancements made by Herton Ronaldo Krzesinski
3126 + * <herton@mandriva.com>
3128 + * GRUB -- GRand Unified Bootloader
3129 + * Copyright (C) 2001,2002 Red Hat, Inc.
3130 + * Portions copyright (C) 2000 Conectiva, Inc.
3132 + * This program is free software; you can redistribute it and/or modify
3133 + * it under the terms of the GNU General Public License as published by
3134 + * the Free Software Foundation; either version 2 of the License, or
3135 + * (at your option) any later version.
3137 + * This program is distributed in the hope that it will be useful,
3138 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3139 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3140 + * GNU General Public License for more details.
3142 + * You should have received a copy of the GNU General Public License
3143 + * along with this program; if not, write to the Free Software
3144 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3147 +#ifdef SUPPORT_GRAPHICS
3150 +#include <shared.h>
3151 +#include <graphics.h>
3153 +int saved_videomode;
3154 +unsigned char *font8x16;
3156 +int graphics_inited = 0;
3157 +static char splashimage[256];
3159 +int shade = 1, no_cursor = 0;
3161 +#define VSHADOW VSHADOW1
3162 +unsigned char VSHADOW1[38400];
3163 +unsigned char VSHADOW2[38400];
3164 +unsigned char VSHADOW4[38400];
3165 +unsigned char VSHADOW8[38400];
3167 +/* define the default viewable area */
3173 +/* text buffer has to be kept around so that we can write things as we
3174 + * scroll and the like */
3175 +unsigned short text[80 * 30];
3177 +/* graphics options */
3178 +int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
3180 +/* current position */
3181 +static int fontx = 0;
3182 +static int fonty = 0;
3184 +/* global state so that we don't try to recursively scroll or cursor */
3185 +static int no_scroll = 0;
3188 +static int graphics_standard_color = A_NORMAL;
3189 +static int graphics_normal_color = A_NORMAL;
3190 +static int graphics_highlight_color = A_REVERSE;
3191 +static int graphics_current_color = A_NORMAL;
3192 +static color_state graphics_color_state = COLOR_STATE_STANDARD;
3194 +static inline void outb(unsigned short port, unsigned char val)
3196 + __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
3199 +static void MapMask(int value) {
3201 + outb(0x3c5, value);
3204 +/* bit mask register */
3205 +static void BitMask(int value) {
3207 + outb(0x3cf, value);
3210 +/* move the graphics cursor location to col, row */
3211 +static void graphics_setxy(int col, int row) {
3212 + if (col >= view_x0 && col < view_x1) {
3214 + cursorX = col << 3;
3216 + if (row >= view_y0 && row < view_y1) {
3218 + cursorY = row << 4;
3222 +/* scroll the screen */
3223 +static void graphics_scroll() {
3226 + /* we don't want to scroll recursively... that would be bad */
3231 + /* disable pager temporarily */
3235 + /* move everything up a line */
3236 + for (j = view_y0 + 1; j < view_y1; j++) {
3237 + graphics_gotoxy(view_x0, j - 1);
3238 + for (i = view_x0; i < view_x1; i++) {
3239 + graphics_putchar(text[j * 80 + i]);
3243 + /* last line should be blank */
3244 + graphics_gotoxy(view_x0, view_y1 - 1);
3245 + for (i = view_x0; i < view_x1; i++)
3246 + graphics_putchar(' ');
3247 + graphics_setxy(view_x0, view_y1 - 1);
3254 +/* Set the splash image */
3255 +void graphics_set_splash(char *splashfile) {
3256 + grub_strcpy(splashimage, splashfile);
3259 +/* Get the current splash image */
3260 +char *graphics_get_splash(void) {
3261 + return splashimage;
3265 + * Initialize a vga16 graphics display with the palette based off of
3266 + * the image in splashimage. If the image doesn't exist, leave graphics
3267 + * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List":
3268 + * text/ text pixel pixel colors disply scrn system
3269 + * grph resol box resolution pages addr
3270 + * 12h G 80x30 8x16 640x480 16/256K . A000 VGA,ATI VIP
3271 + * G 80x30 8x16 640x480 16/64 . A000 ATI EGA Wonder
3272 + * G . . 640x480 16 . . UltraVision+256K EGA
3274 +int graphics_init()
3276 + if (!graphics_inited) {
3277 + saved_videomode = set_videomode(0x12);
3278 + if (get_videomode() != 0x12) {
3279 + set_videomode(saved_videomode);
3282 + graphics_inited = 1;
3287 + font8x16 = (unsigned char*)graphics_get_font();
3289 + /* make sure that the highlight color is set correctly */
3290 + graphics_highlight_color = ((graphics_normal_color >> 4) |
3291 + ((graphics_normal_color & 0xf) << 4));
3295 + if (!read_image(splashimage)) {
3296 + grub_printf("Failed to read splash image (%s)\n", splashimage);
3297 + grub_printf("Press any key to continue...");
3299 + set_videomode(saved_videomode);
3300 + graphics_inited = 0;
3304 + set_int1c_handler();
3309 +/* Leave graphics mode */
3310 +void graphics_end(void)
3312 + if (graphics_inited) {
3313 + unset_int1c_handler();
3314 + set_videomode(saved_videomode);
3315 + graphics_inited = 0;
3320 +/* Print ch on the screen. Handle any needed scrolling or the like */
3321 +void graphics_putchar(int ch) {
3324 + graphics_cursor(0);
3327 + if (fonty + 1 < view_y1)
3328 + graphics_setxy(fontx, fonty + 1);
3330 + graphics_scroll();
3331 + graphics_cursor(1);
3333 + } else if (ch == '\r') {
3334 + graphics_setxy(view_x0, fonty);
3335 + graphics_cursor(1);
3339 + graphics_cursor(0);
3341 + text[fonty * 80 + fontx] = ch;
3342 + text[fonty * 80 + fontx] &= 0x00ff;
3343 + if (graphics_current_color & 0xf0)
3344 + text[fonty * 80 + fontx] |= 0x100;
3346 + graphics_cursor(0);
3348 + if ((fontx + 1) >= view_x1) {
3349 + graphics_setxy(view_x0, fonty);
3350 + if (fonty + 1 < view_y1)
3351 + graphics_setxy(view_x0, fonty + 1);
3353 + graphics_scroll();
3354 + graphics_cursor(1);
3356 + graphics_cursor(0);
3358 + graphics_setxy(fontx + 1, fonty);
3361 + graphics_cursor(1);
3364 +/* get the current location of the cursor */
3365 +int graphics_getxy(void) {
3366 + return (fontx << 8) | fonty;
3369 +void graphics_gotoxy(int x, int y) {
3370 + graphics_cursor(0);
3372 + graphics_setxy(x, y);
3374 + graphics_cursor(1);
3377 +void graphics_cls(void) {
3379 + unsigned char *mem, *s1, *s2, *s4, *s8;
3381 + graphics_cursor(0);
3382 + graphics_gotoxy(view_x0, view_y0);
3384 + mem = (unsigned char*)VIDEOMEM;
3385 + s1 = (unsigned char*)VSHADOW1;
3386 + s2 = (unsigned char*)VSHADOW2;
3387 + s4 = (unsigned char*)VSHADOW4;
3388 + s8 = (unsigned char*)VSHADOW8;
3390 + for (i = 0; i < 80 * 30; i++)
3392 + graphics_cursor(1);
3398 + grub_memcpy(mem, s1, 38400);
3402 + grub_memcpy(mem, s2, 38400);
3406 + grub_memcpy(mem, s4, 38400);
3410 + grub_memcpy(mem, s8, 38400);
3416 + set_int1c_handler();
3420 +void graphics_setcolorstate (color_state state) {
3422 + case COLOR_STATE_STANDARD:
3423 + graphics_current_color = graphics_standard_color;
3425 + case COLOR_STATE_NORMAL:
3426 + graphics_current_color = graphics_normal_color;
3428 + case COLOR_STATE_HIGHLIGHT:
3429 + graphics_current_color = graphics_highlight_color;
3432 + graphics_current_color = graphics_standard_color;
3436 + graphics_color_state = state;
3439 +void graphics_setcolor (int normal_color, int highlight_color) {
3440 + graphics_normal_color = normal_color;
3441 + graphics_highlight_color = highlight_color;
3443 + graphics_setcolorstate (graphics_color_state);
3446 +int graphics_setcursor (int on) {
3447 + if (!no_cursor && !on) {
3449 + unset_int1c_handler();
3450 + graphics_cursor(0);
3452 + else if(no_cursor && on) {
3454 + set_int1c_handler();
3455 + graphics_cursor(1);
3460 +/* Read in the splashscreen image and set the palette up appropriately.
3461 + * Format of splashscreen is an xpm (can be gzipped) with 16 colors and
3463 +int read_image(char *s)
3465 + char buf[32], pal[16], c;
3466 + unsigned char base, mask, *s1, *s2, *s4, *s8;
3467 + unsigned i, len, idx, colors, x, y, width, height;
3469 + if (!grub_open(s))
3473 + if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
3479 + while (grub_read(&c, 1)) {
3484 + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3489 + while (grub_read(&c, 1)) {
3490 + if (c >= '0' && c <= '9')
3491 + width = width * 10 + c - '0';
3495 + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3499 + while (grub_read(&c, 1)) {
3500 + if (c >= '0' && c <= '9')
3501 + height = height * 10 + c - '0';
3505 + while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3509 + while (grub_read(&c, 1)) {
3510 + if (c >= '0' && c <= '9')
3511 + colors = colors * 10 + c - '0';
3517 + while (grub_read(&c, 1) && c != '"')
3521 + for (i = 0, idx = 1; i < colors; i++) {
3524 + while (grub_read(&c, 1) && c != '"')
3526 + grub_read(&c, 1); /* char */
3528 + grub_read(buf, 4); /* \t c # */
3530 + while (grub_read(&c, 1) && c != '"') {
3531 + if (len < sizeof(buf))
3535 + if (len == 6 && idx < 15) {
3536 + int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
3537 + int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
3538 + int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
3541 + graphics_set_palette(idx, r, g, b);
3548 + s1 = (unsigned char*)VSHADOW1;
3549 + s2 = (unsigned char*)VSHADOW2;
3550 + s4 = (unsigned char*)VSHADOW4;
3551 + s8 = (unsigned char*)VSHADOW8;
3553 + for (i = 0; i < 38400; i++)
3554 + s1[i] = s2[i] = s4[i] = s8[i] = 0;
3556 + /* parse xpm data */
3557 + while (y < height) {
3559 + if (!grub_read(&c, 1)) {
3567 + while (grub_read(&c, 1) && c != '"') {
3568 + for (i = 1; i < 15; i++)
3569 + if (pal[i] == c) {
3574 + mask = 0x80 >> (x & 7);
3576 + s1[len + (x >> 3)] |= mask;
3578 + s2[len + (x >> 3)] |= mask;
3580 + s4[len + (x >> 3)] |= mask;
3582 + s8[len + (x >> 3)] |= mask;
3596 + graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
3598 + graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
3600 + graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63,
3601 + window_border & 63);
3606 +/* Convert a character which is a hex digit to the appropriate integer */
3609 + if (v >= 'A' && v <= 'F')
3610 + return (v - 'A' + 10);
3611 + if (v >= 'a' && v <= 'f')
3612 + return (v - 'a' + 10);
3616 +void graphics_cursor(int set) {
3617 + unsigned char *pat, *mem, *ptr, chr[16 << 2];
3618 + int i, ch, invert, offset;
3620 + if (set && (no_cursor || no_scroll))
3623 + offset = cursorY * 80 + fontx;
3624 + ch = text[fonty * 80 + fontx] & 0xff;
3625 + invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
3626 + pat = font8x16 + (ch << 4);
3628 + mem = (unsigned char*)VIDEOMEM + offset;
3631 + for (i = 0; i < 16; i++) {
3632 + unsigned char mask = pat[i];
3635 + chr[i ] = ((unsigned char*)VSHADOW1)[offset];
3636 + chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
3637 + chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
3638 + chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
3641 + if (ch == DISP_VERT || ch == DISP_LL ||
3642 + ch == DISP_UR || ch == DISP_LR) {
3643 + unsigned char pmask = ~(pat[i] >> 1);
3646 + chr[16 + i] &= pmask;
3647 + chr[32 + i] &= pmask;
3648 + chr[48 + i] &= pmask;
3650 + if (i > 0 && ch != DISP_VERT) {
3651 + unsigned char pmask = ~(pat[i - 1] >> 1);
3654 + chr[16 + i] &= pmask;
3655 + chr[32 + i] &= pmask;
3656 + chr[48 + i] &= pmask;
3657 + if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
3658 + pmask = ~pat[i - 1];
3661 + chr[16 + i] &= pmask;
3662 + chr[32 + i] &= pmask;
3663 + chr[48 + i] &= pmask;
3668 + chr[16 + i] |= mask;
3669 + chr[32 + i] |= mask;
3670 + chr[48 + i] |= mask;
3676 + chr[16 + i] = mask;
3677 + chr[32 + i] = mask;
3678 + chr[48 + i] = mask;
3685 + for (i = 0; i < 16; i++, ptr += 80) {
3686 + cursorBuf[i] = pat[i];
3693 + for (i = 1; i < 16; i <<= 1, offset += 16) {
3698 + for (j = 0; j < 16; j++, ptr += 80)
3699 + *ptr = chr[j + offset];
3705 +#endif /* SUPPORT_GRAPHICS */
3707 +++ b/stage2/graphics.h
3709 +/* graphics.h - graphics console interface */
3711 + * GRUB -- GRand Unified Bootloader
3712 + * Copyright (C) 2002 Free Software Foundation, Inc.
3714 + * This program is free software; you can redistribute it and/or modify
3715 + * it under the terms of the GNU General Public License as published by
3716 + * the Free Software Foundation; either version 2 of the License, or
3717 + * (at your option) any later version.
3719 + * This program is distributed in the hope that it will be useful,
3720 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3721 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3722 + * GNU General Public License for more details.
3724 + * You should have received a copy of the GNU General Public License
3725 + * along with this program; if not, write to the Free Software
3726 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3732 +/* magic constant */
3733 +#define VIDEOMEM 0xA0000
3735 +/* function prototypes */
3736 +char *graphics_get_splash(void);
3738 +int read_image(char *s);
3739 +void graphics_cursor(int set);
3741 +/* function prototypes for asm functions */
3742 +void * graphics_get_font();
3743 +void graphics_set_palette(int idx, int red, int green, int blue);
3744 +void set_int1c_handler();
3745 +void unset_int1c_handler();
3747 +extern short cursorX, cursorY;
3748 +extern char cursorBuf[16];
3750 +extern int view_x0, view_y0, view_x1, view_y1;
3752 +#endif /* GRAPHICS_H */
3753 --- a/stage2/Makefile.am
3754 +++ b/stage2/Makefile.am
3755 @@ -7,7 +7,7 @@ noinst_HEADERS = apic.h defs.h dir.h dis
3756 fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
3757 imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
3758 nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
3759 - terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
3760 + terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
3761 EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
3764 @@ -19,7 +19,7 @@ libgrub_a_SOURCES = boot.c builtins.c ch
3765 disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
3766 fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
3767 fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
3768 - terminfo.c tparm.c
3769 + terminfo.c tparm.c graphics.c
3770 libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
3771 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
3772 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
3773 @@ -79,8 +79,14 @@ else
3777 +if GRAPHICS_SUPPORT
3778 +GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
3783 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
3784 - $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
3785 + $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
3787 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
3788 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
3789 @@ -90,7 +96,8 @@ pre_stage2_exec_SOURCES = asm.S bios.c b
3790 cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
3791 fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
3792 fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
3793 - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
3794 + hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
3796 pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
3797 pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
3798 pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
3799 --- a/stage2/shared.h
3800 +++ b/stage2/shared.h
3801 @@ -499,7 +499,11 @@ struct vbe_mode
3802 unsigned char linear_reserved_field_position;
3803 unsigned long max_pixel_clock;
3805 - unsigned char reserved3[189];
3806 + /* Reserved field to make structure to be 256 bytes long, VESA BIOS
3807 + Extension 3.0 Specification says to reserve 189 bytes here but
3808 + that doesn't make structure to be 256 bytes. So additional one is
3810 + unsigned char reserved3[189 + 1];
3811 } __attribute__ ((packed));
3814 @@ -792,6 +796,11 @@ int getxy (void);
3815 /* Set the cursor position. */
3816 void gotoxy (int x, int y);
3819 + Returns 1 = if pager was used
3820 + 0 = if pager wasn't used */
3821 +int do_more (void);
3823 /* Displays an ASCII character. IBM displays will translate some
3824 characters to special graphical ones (see the DISP_* constants). */
3825 void grub_putchar (int c);
3826 @@ -871,6 +880,7 @@ int grub_sprintf (char *buffer, const ch
3827 int grub_tolower (int c);
3828 int grub_isspace (int c);
3829 int grub_strncat (char *s1, const char *s2, int n);
3830 +void grub_memcpy(void *dest, const void *src, int len);
3831 void *grub_memmove (void *to, const void *from, int len);
3832 void *grub_memset (void *start, int c, int len);
3833 int grub_strncat (char *s1, const char *s2, int n);
3834 @@ -911,7 +921,7 @@ int substring (const char *s1, const cha
3835 int nul_terminate (char *str);
3836 int get_based_digit (int c, int base);
3837 int safe_parse_maxint (char **str_ptr, int *myint_ptr);
3838 -int memcheck (int start, int len);
3839 +int memcheck (unsigned long int start, unsigned long int len);
3840 void grub_putstr (const char *str);
3842 #ifndef NO_DECOMPRESSION
3843 --- a/stage2/stage2.c
3844 +++ b/stage2/stage2.c
3849 +#ifdef SUPPORT_GRAPHICS
3850 +# include <graphics.h>
3853 +int col_start, col_end, row_start, box_size;
3855 grub_jmp_buf restart_env;
3857 #if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
3858 @@ -105,13 +111,13 @@ print_entry (int y, int highlight, char
3859 if (highlight && current_term->setcolorstate)
3860 current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
3863 + gotoxy (2 + col_start, y);
3865 - for (x = 3; x < 75; x++)
3866 + for (x = 3 + col_start; x < (col_end - 5); x++)
3868 - if (*entry && x <= 72)
3869 + if (*entry && x <= (col_end - 8))
3872 + if (x == (col_end - 8))
3873 grub_putchar (DISP_RIGHT);
3875 grub_putchar (*entry++);
3876 @@ -119,7 +125,7 @@ print_entry (int y, int highlight, char
3881 + gotoxy ((col_end - 6), y);
3883 if (current_term->setcolorstate)
3884 current_term->setcolorstate (COLOR_STATE_STANDARD);
3885 @@ -131,7 +137,7 @@ print_entries (int y, int size, int firs
3889 - gotoxy (77, y + 1);
3890 + gotoxy ((col_end - 3), y + 1);
3893 grub_putchar (DISP_UP);
3894 @@ -151,14 +157,14 @@ print_entries (int y, int size, int firs
3898 - gotoxy (77, y + size);
3899 + gotoxy ((col_end - 3), y + size);
3902 grub_putchar (DISP_DOWN);
3906 - gotoxy (74, y + entryno + 1);
3907 + gotoxy ((col_end - 6), y + entryno + 1);
3911 @@ -196,30 +202,30 @@ print_border (int y, int size)
3912 if (current_term->setcolorstate)
3913 current_term->setcolorstate (COLOR_STATE_NORMAL);
3916 + gotoxy (1 + col_start, y);
3918 grub_putchar (DISP_UL);
3919 - for (i = 0; i < 73; i++)
3920 + for (i = col_start; i < (col_end - 7); i++)
3921 grub_putchar (DISP_HORIZ);
3922 grub_putchar (DISP_UR);
3927 - gotoxy (1, y + i);
3928 + gotoxy (1 + col_start, y + i);
3933 grub_putchar (DISP_VERT);
3934 - gotoxy (75, y + i);
3935 + gotoxy ((col_end - 5), y + i);
3936 grub_putchar (DISP_VERT);
3941 grub_putchar (DISP_LL);
3942 - for (i = 0; i < 73; i++)
3943 + for (i = col_start; i < (col_end - 7); i++)
3944 grub_putchar (DISP_HORIZ);
3945 grub_putchar (DISP_LR);
3947 @@ -233,6 +239,7 @@ run_menu (char *menu_entries, char *conf
3949 int c, time1, time2 = -1, first_entry = 0;
3950 char *cur_entry = 0;
3951 + struct term_entry *prev_term = NULL;
3954 * Main loop for menu UI.
3955 @@ -250,6 +257,22 @@ restart:
3963 + /* if we're using viewport we need to make sure to setup
3964 + coordinates correctly. */
3965 +#ifdef SUPPORT_GRAPHICS
3966 + if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
3968 + col_start = view_x0;
3969 + col_end = view_x1;
3970 + row_start = view_y0;
3971 + box_size = (view_y1 - view_y0) - 13;
3975 /* If the timeout was expired or wasn't set, force to show the menu
3977 if (grub_timeout < 0)
3978 @@ -302,36 +325,36 @@ restart:
3979 if (current_term->flags & TERM_DUMB)
3980 print_entries_raw (num_entries, first_entry, menu_entries);
3982 - print_border (3, 12);
3983 + print_border (3 + row_start, box_size);
3986 - Use the %c and %c keys to select which entry is highlighted.\n",
3987 + Use the %c and %c keys to select which entry is highlighted.\n",
3988 DISP_UP, DISP_DOWN);
3990 if (! auth && password)
3993 - Press enter to boot the selected OS or \'p\' to enter a\n\
3994 - password to unlock the next set of features.");
3995 + Press enter to boot the selected OS or \'p\' to enter a\n\
3996 + password to unlock the next set of features.");
4002 - Press enter to boot the selected OS, \'e\' to edit the\n\
4003 - commands before booting, or \'c\' for a command-line.");
4004 + Press enter to boot the selected OS, \'e\' to edit the\n\
4005 + commands before booting, or \'c\' for a command-line.");
4008 - Press \'b\' to boot, \'e\' to edit the selected command in the\n\
4009 - boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
4010 - after (\'O\' for before) the selected line, \'d\' to remove the\n\
4011 - selected line, or escape to go back to the main menu.");
4012 + Press \'b\' to boot, \'e\' to edit the selected command in the\n\
4013 + boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
4014 + after (\'O\' for before) the selected line, \'d\' to remove the\n\
4015 + selected line, or escape to go back to the main menu.");
4018 if (current_term->flags & TERM_DUMB)
4019 grub_printf ("\n\nThe selected entry is %d ", entryno);
4021 - print_entries (3, 12, first_entry, entryno, menu_entries);
4022 + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4025 /* XX using RT clock now, need to initialize value */
4026 @@ -358,10 +381,10 @@ restart:
4027 entryno, grub_timeout);
4031 - grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",
4032 + gotoxy (3 + col_start, 10 + box_size + row_start);
4033 + grub_printf (" The highlighted entry will be booted automatically in %d seconds. ",
4035 - gotoxy (74, 4 + entryno);
4036 + gotoxy ((col_end - 6), 4 + entryno + row_start);
4040 @@ -387,12 +410,12 @@ restart:
4041 if (current_term->flags & TERM_DUMB)
4042 grub_putchar ('\r');
4045 + gotoxy (3 + col_start, 10 + box_size + row_start);
4048 fallback_entryno = -1;
4049 if (! (current_term->flags & TERM_DUMB))
4050 - gotoxy (74, 4 + entryno);
4051 + gotoxy ((col_end - 6), 4 + entryno + row_start);
4054 /* We told them above (at least in SUPPORT_SERIAL) to use
4055 @@ -408,12 +431,12 @@ restart:
4059 - print_entry (4 + entryno, 0,
4060 + print_entry (4 + entryno + row_start, 0,
4061 get_entry (menu_entries,
4062 first_entry + entryno,
4065 - print_entry (4 + entryno, 1,
4066 + print_entry (4 + entryno + row_start, 1,
4067 get_entry (menu_entries,
4068 first_entry + entryno,
4070 @@ -421,7 +444,7 @@ restart:
4071 else if (first_entry > 0)
4074 - print_entries (3, 12, first_entry, entryno,
4075 + print_entries (3 + row_start, box_size, first_entry, entryno,
4079 @@ -433,29 +456,29 @@ restart:
4084 + if (entryno < (box_size - 1))
4086 - print_entry (4 + entryno, 0,
4087 + print_entry (4 + entryno + row_start, 0,
4088 get_entry (menu_entries,
4089 first_entry + entryno,
4092 - print_entry (4 + entryno, 1,
4093 + print_entry (4 + entryno + row_start, 1,
4094 get_entry (menu_entries,
4095 first_entry + entryno,
4098 - else if (num_entries > 12 + first_entry)
4099 + else if (num_entries > box_size + first_entry)
4102 - print_entries (3, 12, first_entry, entryno, menu_entries);
4103 + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4110 - first_entry -= 12;
4111 + first_entry -= box_size;
4112 if (first_entry < 0)
4114 entryno += first_entry;
4115 @@ -463,20 +486,20 @@ restart:
4119 - print_entries (3, 12, first_entry, entryno, menu_entries);
4120 + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4125 - first_entry += 12;
4126 + first_entry += box_size;
4127 if (first_entry + entryno + 1 >= num_entries)
4129 - first_entry = num_entries - 12;
4130 + first_entry = num_entries - box_size;
4131 if (first_entry < 0)
4133 entryno = num_entries - first_entry - 1;
4135 - print_entries (3, 12, first_entry, entryno, menu_entries);
4136 + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4140 @@ -489,7 +512,7 @@ restart:
4141 if ((c == 'd') || (c == 'o') || (c == 'O'))
4143 if (! (current_term->flags & TERM_DUMB))
4144 - print_entry (4 + entryno, 0,
4145 + print_entry (4 + entryno + row_start, 0,
4146 get_entry (menu_entries,
4147 first_entry + entryno,
4149 @@ -537,7 +560,7 @@ restart:
4151 if (entryno >= num_entries)
4153 - if (first_entry && num_entries < 12 + first_entry)
4154 + if (first_entry && num_entries < box_size + first_entry)
4158 @@ -549,7 +572,7 @@ restart:
4162 - print_entries (3, 12, first_entry, entryno, menu_entries);
4163 + print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4166 cur_entry = menu_entries;
4167 @@ -570,7 +593,7 @@ restart:
4168 if (current_term->flags & TERM_DUMB)
4169 grub_printf ("\r ");
4172 + gotoxy (1 + col_start, 9 + box_size + row_start);
4174 /* Wipe out the previously entered password */
4175 grub_memset (entered, 0, sizeof (entered));
4176 @@ -651,7 +674,10 @@ restart:
4180 - run_menu (heap, NULL, new_num_entries, new_heap, 0);
4182 + current_entryno = first_entry + entryno;
4183 + run_menu (heap, NULL, new_num_entries, new_heap, 0);
4188 @@ -714,6 +740,15 @@ restart:
4192 + /* if our terminal needed initialization, we should shut it down
4193 + * before booting the kernel, but we want to save what it was so
4194 + * we can come back if needed */
4195 + prev_term = current_term;
4196 + if (current_term->shutdown)
4198 + current_term->shutdown();
4199 + current_term = term_table; /* assumption: console is first */
4204 @@ -727,7 +762,8 @@ restart:
4205 cur_entry = get_entry (config_entries, first_entry + entryno, 1);
4207 /* Set CURRENT_ENTRYNO for the command "savedefault". */
4208 - current_entryno = first_entry + entryno;
4209 + if (config_entries)
4210 + current_entryno = first_entry + entryno;
4212 if (run_script (cur_entry, heap))
4214 @@ -748,6 +784,13 @@ restart:
4218 + /* if we get back here, we should go back to what our term was before */
4219 + current_term = prev_term;
4220 + if (current_term->startup)
4221 + /* if our terminal fails to initialize, fall back to console since
4222 + * it should always work */
4223 + if (current_term->startup() == 0)
4224 + current_term = term_table; /* we know that console is first */
4228 @@ -891,8 +934,18 @@ cmain (void)
4229 len = grub_read (buf, sizeof (buf));
4234 buf[sizeof (buf) - 1] = 0;
4235 - safe_parse_maxint (&p, &saved_entryno);
4237 + if((tmp = grub_strstr(p, ":")) != NULL)
4240 + grub_memcpy(&def, &tmp, sizeof(p));
4242 + grub_memcpy(&def, &p, sizeof(p));
4244 + safe_parse_maxint (&def, &saved_entryno);
4248 @@ -1050,6 +1103,16 @@ cmain (void)
4252 + /* go ahead and make sure the terminal is setup */
4253 + if (current_term->startup)
4255 + /* If initialization fails, go back to default terminal */
4256 + if (current_term->startup() == 0)
4258 + current_term = term_table;
4264 /* If no acceptable config file, goto command-line, starting
4267 @@ -60,6 +60,8 @@ struct term_entry
4269 /* The feature flags defined above. */
4270 unsigned long flags;
4271 + /* Default for maximum number of lines if not specified */
4272 + unsigned short max_lines;
4273 /* Put a character. */
4274 void (*putchar) (int c);
4275 /* Check if any input character is available. */
4276 @@ -79,6 +81,10 @@ struct term_entry
4277 void (*setcolor) (int normal_color, int highlight_color);
4278 /* Turn on/off the cursor. */
4279 int (*setcursor) (int on);
4280 + /* function to start a terminal */
4281 + int (*startup) (void);
4282 + /* function to use to shutdown a terminal */
4283 + void (*shutdown) (void);
4286 /* This lists up available terminals. */
4287 @@ -124,4 +130,24 @@ void hercules_setcolor (int normal_color
4288 int hercules_setcursor (int on);
4291 +#ifdef SUPPORT_GRAPHICS
4292 +extern int foreground, background, window_border, graphics_inited, saved_videomode;
4294 +void graphics_set_splash(char *splashfile);
4295 +int set_videomode(int mode);
4296 +int get_videomode(void);
4297 +void graphics_putchar (int c);
4298 +int graphics_getxy(void);
4299 +void graphics_gotoxy(int x, int y);
4300 +void graphics_cls(void);
4301 +void graphics_setcolorstate (color_state state);
4302 +void graphics_setcolor (int normal_color, int highlight_color);
4303 +int graphics_setcursor (int on);
4304 +int graphics_init(void);
4305 +void graphics_end(void);
4308 +void graphics_set_palette(int idx, int red, int green, int blue);
4309 +#endif /* SUPPORT_GRAPHICS */
4311 #endif /* ! GRUB_TERM_HEADER */
4314 @@ -121,3 +121,4 @@ Vesa Jaaskelainen <jaaskela@tietomyrsky.
4315 Yedidyah Bar-David <didi@post.tau.ac.il>
4316 Yury V. Umanets <umka@namesys.com>
4317 Yuri Zaporogets <yuriz@ukr.net>
4318 +Vitaly Fertman <vitaly@namesys.com>
4319 --- a/util/grub-install.in
4320 +++ b/util/grub-install.in
4321 @@ -81,6 +81,50 @@ Report bugs to <bug-grub@gnu.org>.
4325 +# Usage: getraid_mdadm mddevice
4326 +# Routine to find a physical device from an md device
4327 +# If found, the first grub BIOS device (from device.map) is returned
4328 +# If no BIOS drives match the RAID devices, the first device returned
4329 +# from mdadm -D is returned
4332 + mdadm=$(mdadm -D "$device") || {
4333 + echo "$PROG: mdadm -D $device failed" >&2
4337 + echo "$mdadm" | awk '
4338 + $1 == "Number" && $2 == "Major" { start = 1; next }
4339 + $1 == "UUID" { print "uuid=" $3; start = 0; next }
4341 + $2 == 0 && $3 == 0 { next }
4342 + { devices = devices "\n" $NF }
4343 + END { print "devices='\''" devices "'\''" }
4347 + # Convert RAID devices list into a list of disks
4348 + tmp_disks=`echo "$devices" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
4349 + -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
4350 + -e 's%\(fd[0-9]*\)$%\1%' \
4351 + -e 's%/part[0-9]*$%/disc%' \
4352 + -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
4354 + sed -n '1h;2,$H;${g;s/\n/|/g;p}'`
4356 + # Find first BIOS disk that's a member of the RAID array
4357 + # Default to first RAID member if no tmp_disks are BIOS devices
4358 + set -- `egrep $tmp_disks $device_map | \
4361 + device=${2:-${tmp_disks%%|*}}
4363 + # Return first partition on BIOS disk that's part of the RAID
4364 + echo "$devices" | \
4365 + sed -n "\:${device}:p" | \
4369 # Usage: convert os_device
4370 # Convert an OS device to the corresponding GRUB drive.
4371 # This part is OS-specific.
4372 @@ -96,6 +140,10 @@ convert () {
4373 # Break the device name into the disk part and the partition part.
4376 + # Find an actual physical device if we're passed a RAID device
4378 + /dev/md*) set -- `getraid_mdadm $1`
4380 tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
4381 -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
4382 -e 's%\(fd[0-9]*\)$%\1%' \
4383 @@ -112,8 +160,8 @@ convert () {
4384 tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
4385 tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
4386 freebsd* | kfreebsd*-gnu)
4387 - tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \
4388 - | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'`
4389 + tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
4390 + | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
4391 tmp_part=`echo "$1" \
4392 | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
4393 | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
4394 @@ -131,7 +179,7 @@ convert () {
4396 # Get the drive name.
4397 tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
4398 - | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'`
4399 + | sed 's%.*\(([hf]d[0-9][a-z0-9,]*)\).*%\1%'`
4401 # If not found, print an error message and exit.
4402 if test "x$tmp_drive" = x; then
4403 @@ -148,13 +196,13 @@ convert () {
4405 if echo $tmp_part | grep "^s" >/dev/null; then
4406 tmp_pc_slice=`echo $tmp_part \
4407 - | sed "s%s\([0-9]*\)[a-g]*$%\1%"`
4408 + | sed "s%s\([0-9]*\)[a-z]*$%\1%"`
4409 tmp_drive=`echo "$tmp_drive" \
4410 | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
4412 - if echo $tmp_part | grep "[a-g]$" >/dev/null; then
4413 + if echo $tmp_part | grep "[a-z]$" >/dev/null; then
4414 tmp_bsd_partition=`echo "$tmp_part" \
4415 - | sed "s%[^a-g]*\([a-g]\)$%\1%"`
4416 + | sed "s%[^a-z]*\([a-z]\)$%\1%"`
4417 tmp_drive=`echo "$tmp_drive" \
4418 | sed "s%)%,$tmp_bsd_partition)%"`
4420 @@ -336,6 +384,10 @@ else
4421 # Create a safe temporary file.
4422 test -n "$mklog" && log_file=`$mklog`
4424 + # Before all invocations of the grub shell, call sync to make sure
4425 + # the raw device is in sync with any bufferring in filesystems.
4428 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
4431 @@ -450,6 +502,24 @@ rm -f $log_file
4432 # Create a safe temporary file.
4433 test -n "$mklog" && log_file=`$mklog`
4435 +# Sync to prevent GRUB from not finding stage files (notably, on XFS)
4438 +# XFS needs special magic
4440 +if which xfs_freeze > /dev/null ; then
4442 +Due to a bug in xfs_freeze, the following command might produce a segmentation
4443 +fault when ${grubdir} is not in an XFS filesystem. This error is harmless and
4446 + if xfs_freeze -f ${grubdir} ; then xfs_frozen=true ; fi
4449 +# Before all invocations of the grub shell, call sync to make sure
4450 +# the raw device is in sync with any bufferring in filesystems.
4453 # Now perform the installation.
4454 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
4456 @@ -457,6 +527,10 @@ setup $force_lba --stage2=$grubdir/stage
4460 +if ${xfs_frozen} ; then
4461 + xfs_freeze -u ${grubdir}
4464 if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then