source: patches/grub-0.97-fixes-2.patch@ e74f725

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since e74f725 was a1811b6, checked in by Joe Ciccone <jciccone@…>, 14 years ago

Update the grub patches.

  • Property mode set to 100644
File size: 128.8 KB
RevLine 
[5a4020f]1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
2Date: 2006-07-04
3Initial Package Version: 0.97
4Origin: Debian
5Upstream Status: Unknown
6Description: Contains various fixes and enhancements
7 Graphics mode support
8 Fixes for Raid Support
9 XFS Filesystem Boot Freeze Fixes
10 Removed 2GB Memory Limitation
11 Freebsd support
12 Fixes for initrd support
13 Grub installation Fixes
14 Linux 2.6 geometry Fixes
15 Intel Mac Support
16 Autoconf and aclocal updates
17
18diff -Naur grub-0.97.orig/aclocal.m4 grub-0.97/aclocal.m4
19--- grub-0.97.orig/aclocal.m4 2005-05-07 19:41:18.000000000 -0700
20+++ grub-0.97/aclocal.m4 2006-07-04 00:08:22.000000000 -0700
21@@ -1,7 +1,7 @@
22-# generated automatically by aclocal 1.9.4 -*- Autoconf -*-
23+# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
24
25-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
26-# Free Software Foundation, Inc.
27+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
28+# 2005 Free Software Foundation, Inc.
29 # This file is free software; the Free Software Foundation
30 # gives unlimited permission to copy and/or distribute it,
31 # with or without modifications, as long as this notice is preserved.
32@@ -11,23 +11,11 @@
33 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
34 # PARTICULAR PURPOSE.
35
36-# -*- Autoconf -*-
37-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
38-# Generated from amversion.in; do not edit by hand.
39-
40-# This program is free software; you can redistribute it and/or modify
41-# it under the terms of the GNU General Public License as published by
42-# the Free Software Foundation; either version 2, or (at your option)
43-# any later version.
44-
45-# This program is distributed in the hope that it will be useful,
46-# but WITHOUT ANY WARRANTY; without even the implied warranty of
47-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48-# GNU General Public License for more details.
49-
50-# You should have received a copy of the GNU General Public License
51-# along with this program; if not, write to the Free Software
52-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
53+# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
54+#
55+# This file is free software; the Free Software Foundation
56+# gives unlimited permission to copy and/or distribute it,
57+# with or without modifications, as long as this notice is preserved.
58
59 # AM_AUTOMAKE_VERSION(VERSION)
60 # ----------------------------
61@@ -40,26 +28,15 @@
62 # Call AM_AUTOMAKE_VERSION so it can be traced.
63 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
64 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
65- [AM_AUTOMAKE_VERSION([1.9.4])])
66-
67-# AM_AUX_DIR_EXPAND
68-
69-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
70+ [AM_AUTOMAKE_VERSION([1.9.6])])
71
72-# This program is free software; you can redistribute it and/or modify
73-# it under the terms of the GNU General Public License as published by
74-# the Free Software Foundation; either version 2, or (at your option)
75-# any later version.
76+# AM_AUX_DIR_EXPAND -*- Autoconf -*-
77
78-# This program is distributed in the hope that it will be useful,
79-# but WITHOUT ANY WARRANTY; without even the implied warranty of
80-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81-# GNU General Public License for more details.
82-
83-# You should have received a copy of the GNU General Public License
84-# along with this program; if not, write to the Free Software
85-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
86-# 02111-1307, USA.
87+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
88+#
89+# This file is free software; the Free Software Foundation
90+# gives unlimited permission to copy and/or distribute it,
91+# with or without modifications, as long as this notice is preserved.
92
93 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
94 # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
95@@ -106,26 +83,16 @@
96 am_aux_dir=`cd $ac_aux_dir && pwd`
97 ])
98
99-# AM_CONDITIONAL -*- Autoconf -*-
100+# AM_CONDITIONAL -*- Autoconf -*-
101
102-# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
103-
104-# This program is free software; you can redistribute it and/or modify
105-# it under the terms of the GNU General Public License as published by
106-# the Free Software Foundation; either version 2, or (at your option)
107-# any later version.
108-
109-# This program is distributed in the hope that it will be useful,
110-# but WITHOUT ANY WARRANTY; without even the implied warranty of
111-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
112-# GNU General Public License for more details.
113-
114-# You should have received a copy of the GNU General Public License
115-# along with this program; if not, write to the Free Software
116-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
117-# 02111-1307, USA.
118+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
119+# Free Software Foundation, Inc.
120+#
121+# This file is free software; the Free Software Foundation
122+# gives unlimited permission to copy and/or distribute it,
123+# with or without modifications, as long as this notice is preserved.
124
125-# serial 6
126+# serial 7
127
128 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
129 # -------------------------------------
130@@ -149,26 +116,15 @@
131 Usually this means the macro was only invoked conditionally.]])
132 fi])])
133
134-# serial 7 -*- Autoconf -*-
135
136-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
137+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
138 # Free Software Foundation, Inc.
139+#
140+# This file is free software; the Free Software Foundation
141+# gives unlimited permission to copy and/or distribute it,
142+# with or without modifications, as long as this notice is preserved.
143
144-# This program is free software; you can redistribute it and/or modify
145-# it under the terms of the GNU General Public License as published by
146-# the Free Software Foundation; either version 2, or (at your option)
147-# any later version.
148-
149-# This program is distributed in the hope that it will be useful,
150-# but WITHOUT ANY WARRANTY; without even the implied warranty of
151-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152-# GNU General Public License for more details.
153-
154-# You should have received a copy of the GNU General Public License
155-# along with this program; if not, write to the Free Software
156-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
157-# 02111-1307, USA.
158-
159+# serial 8
160
161 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
162 # written in clear, in which case automake, when reading aclocal.m4,
163@@ -177,7 +133,6 @@
164 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
165
166
167-
168 # _AM_DEPENDENCIES(NAME)
169 # ----------------------
170 # See how the compiler implements dependency checking.
171@@ -317,27 +272,16 @@
172 AC_SUBST([AMDEPBACKSLASH])
173 ])
174
175-# Generate code to set up dependency tracking. -*- Autoconf -*-
176-
177-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
178-# Free Software Foundation, Inc.
179-
180-# This program is free software; you can redistribute it and/or modify
181-# it under the terms of the GNU General Public License as published by
182-# the Free Software Foundation; either version 2, or (at your option)
183-# any later version.
184+# Generate code to set up dependency tracking. -*- Autoconf -*-
185
186-# This program is distributed in the hope that it will be useful,
187-# but WITHOUT ANY WARRANTY; without even the implied warranty of
188-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189-# GNU General Public License for more details.
190-
191-# You should have received a copy of the GNU General Public License
192-# along with this program; if not, write to the Free Software
193-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
194-# 02111-1307, USA.
195+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
196+# Free Software Foundation, Inc.
197+#
198+# This file is free software; the Free Software Foundation
199+# gives unlimited permission to copy and/or distribute it,
200+# with or without modifications, as long as this notice is preserved.
201
202-#serial 2
203+#serial 3
204
205 # _AM_OUTPUT_DEPENDENCY_COMMANDS
206 # ------------------------------
207@@ -396,30 +340,19 @@
208 [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
209 ])
210
211-# Do all the work for Automake. -*- Autoconf -*-
212+# Do all the work for Automake. -*- Autoconf -*-
213
214-# This macro actually does too much some checks are only needed if
215-# your package does certain things. But this isn't really a big deal.
216-
217-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
218+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
219 # Free Software Foundation, Inc.
220+#
221+# This file is free software; the Free Software Foundation
222+# gives unlimited permission to copy and/or distribute it,
223+# with or without modifications, as long as this notice is preserved.
224
225-# This program is free software; you can redistribute it and/or modify
226-# it under the terms of the GNU General Public License as published by
227-# the Free Software Foundation; either version 2, or (at your option)
228-# any later version.
229-
230-# This program is distributed in the hope that it will be useful,
231-# but WITHOUT ANY WARRANTY; without even the implied warranty of
232-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
233-# GNU General Public License for more details.
234-
235-# You should have received a copy of the GNU General Public License
236-# along with this program; if not, write to the Free Software
237-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
238-# 02111-1307, USA.
239+# serial 12
240
241-# serial 11
242+# This macro actually does too much. Some checks are only needed if
243+# your package does certain things. But this isn't really a big deal.
244
245 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
246 # AM_INIT_AUTOMAKE([OPTIONS])
247@@ -521,51 +454,27 @@
248 done
249 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
250
251+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
252+#
253+# This file is free software; the Free Software Foundation
254+# gives unlimited permission to copy and/or distribute it,
255+# with or without modifications, as long as this notice is preserved.
256+
257 # AM_PROG_INSTALL_SH
258 # ------------------
259 # Define $install_sh.
260-
261-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
262-
263-# This program is free software; you can redistribute it and/or modify
264-# it under the terms of the GNU General Public License as published by
265-# the Free Software Foundation; either version 2, or (at your option)
266-# any later version.
267-
268-# This program is distributed in the hope that it will be useful,
269-# but WITHOUT ANY WARRANTY; without even the implied warranty of
270-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
271-# GNU General Public License for more details.
272-
273-# You should have received a copy of the GNU General Public License
274-# along with this program; if not, write to the Free Software
275-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
276-# 02111-1307, USA.
277-
278 AC_DEFUN([AM_PROG_INSTALL_SH],
279 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
280 install_sh=${install_sh-"$am_aux_dir/install-sh"}
281 AC_SUBST(install_sh)])
282
283-# -*- Autoconf -*-
284-# Copyright (C) 2003 Free Software Foundation, Inc.
285-
286-# This program is free software; you can redistribute it and/or modify
287-# it under the terms of the GNU General Public License as published by
288-# the Free Software Foundation; either version 2, or (at your option)
289-# any later version.
290-
291-# This program is distributed in the hope that it will be useful,
292-# but WITHOUT ANY WARRANTY; without even the implied warranty of
293-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
294-# GNU General Public License for more details.
295-
296-# You should have received a copy of the GNU General Public License
297-# along with this program; if not, write to the Free Software
298-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
299-# 02111-1307, USA.
300+# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
301+#
302+# This file is free software; the Free Software Foundation
303+# gives unlimited permission to copy and/or distribute it,
304+# with or without modifications, as long as this notice is preserved.
305
306-# serial 1
307+# serial 2
308
309 # Check whether the underlying file-system supports filenames
310 # with a leading dot. For instance MS-DOS doesn't.
311@@ -580,28 +489,17 @@
312 rmdir .tst 2>/dev/null
313 AC_SUBST([am__leading_dot])])
314
315-# Add --enable-maintainer-mode option to configure.
316+# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
317 # From Jim Meyering
318
319-# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004
320+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
321 # Free Software Foundation, Inc.
322+#
323+# This file is free software; the Free Software Foundation
324+# gives unlimited permission to copy and/or distribute it,
325+# with or without modifications, as long as this notice is preserved.
326
327-# This program is free software; you can redistribute it and/or modify
328-# it under the terms of the GNU General Public License as published by
329-# the Free Software Foundation; either version 2, or (at your option)
330-# any later version.
331-
332-# This program is distributed in the hope that it will be useful,
333-# but WITHOUT ANY WARRANTY; without even the implied warranty of
334-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
335-# GNU General Public License for more details.
336-
337-# You should have received a copy of the GNU General Public License
338-# along with this program; if not, write to the Free Software
339-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
340-# 02111-1307, USA.
341-
342-# serial 3
343+# serial 4
344
345 AC_DEFUN([AM_MAINTAINER_MODE],
346 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
347@@ -620,26 +518,15 @@
348
349 AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
350
351-# Check to see how 'make' treats includes. -*- Autoconf -*-
352-
353-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
354+# Check to see how 'make' treats includes. -*- Autoconf -*-
355
356-# This program is free software; you can redistribute it and/or modify
357-# it under the terms of the GNU General Public License as published by
358-# the Free Software Foundation; either version 2, or (at your option)
359-# any later version.
360-
361-# This program is distributed in the hope that it will be useful,
362-# but WITHOUT ANY WARRANTY; without even the implied warranty of
363-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
364-# GNU General Public License for more details.
365-
366-# You should have received a copy of the GNU General Public License
367-# along with this program; if not, write to the Free Software
368-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
369-# 02111-1307, USA.
370+# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
371+#
372+# This file is free software; the Free Software Foundation
373+# gives unlimited permission to copy and/or distribute it,
374+# with or without modifications, as long as this notice is preserved.
375
376-# serial 2
377+# serial 3
378
379 # AM_MAKE_INCLUDE()
380 # -----------------
381@@ -683,27 +570,16 @@
382 rm -f confinc confmf
383 ])
384
385-# -*- Autoconf -*-
386-
387-
388-# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
389-
390-# This program is free software; you can redistribute it and/or modify
391-# it under the terms of the GNU General Public License as published by
392-# the Free Software Foundation; either version 2, or (at your option)
393-# any later version.
394+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
395
396-# This program is distributed in the hope that it will be useful,
397-# but WITHOUT ANY WARRANTY; without even the implied warranty of
398-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
399-# GNU General Public License for more details.
400-
401-# You should have received a copy of the GNU General Public License
402-# along with this program; if not, write to the Free Software
403-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
404-# 02111-1307, USA.
405+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
406+# Free Software Foundation, Inc.
407+#
408+# This file is free software; the Free Software Foundation
409+# gives unlimited permission to copy and/or distribute it,
410+# with or without modifications, as long as this notice is preserved.
411
412-# serial 3
413+# serial 4
414
415 # AM_MISSING_PROG(NAME, PROGRAM)
416 # ------------------------------
417@@ -729,27 +605,16 @@
418 fi
419 ])
420
421+# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
422+#
423+# This file is free software; the Free Software Foundation
424+# gives unlimited permission to copy and/or distribute it,
425+# with or without modifications, as long as this notice is preserved.
426+
427 # AM_PROG_MKDIR_P
428 # ---------------
429 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
430-
431-# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
432-
433-# This program is free software; you can redistribute it and/or modify
434-# it under the terms of the GNU General Public License as published by
435-# the Free Software Foundation; either version 2, or (at your option)
436-# any later version.
437-
438-# This program is distributed in the hope that it will be useful,
439-# but WITHOUT ANY WARRANTY; without even the implied warranty of
440-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
441-# GNU General Public License for more details.
442-
443-# You should have received a copy of the GNU General Public License
444-# along with this program; if not, write to the Free Software
445-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
446-# 02111-1307, USA.
447-
448+#
449 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
450 # created by `make install' are always world readable, even if the
451 # installer happens to have an overly restrictive umask (e.g. 077).
452@@ -803,26 +668,15 @@
453 fi
454 AC_SUBST([mkdir_p])])
455
456-# Helper functions for option handling. -*- Autoconf -*-
457+# Helper functions for option handling. -*- Autoconf -*-
458
459-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
460-
461-# This program is free software; you can redistribute it and/or modify
462-# it under the terms of the GNU General Public License as published by
463-# the Free Software Foundation; either version 2, or (at your option)
464-# any later version.
465-
466-# This program is distributed in the hope that it will be useful,
467-# but WITHOUT ANY WARRANTY; without even the implied warranty of
468-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
469-# GNU General Public License for more details.
470-
471-# You should have received a copy of the GNU General Public License
472-# along with this program; if not, write to the Free Software
473-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
474-# 02111-1307, USA.
475+# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
476+#
477+# This file is free software; the Free Software Foundation
478+# gives unlimited permission to copy and/or distribute it,
479+# with or without modifications, as long as this notice is preserved.
480
481-# serial 2
482+# serial 3
483
484 # _AM_MANGLE_OPTION(NAME)
485 # -----------------------
486@@ -847,28 +701,16 @@
487 AC_DEFUN([_AM_IF_OPTION],
488 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
489
490-#
491-# Check to make sure that the build environment is sane.
492-#
493-
494-# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
495-
496-# This program is free software; you can redistribute it and/or modify
497-# it under the terms of the GNU General Public License as published by
498-# the Free Software Foundation; either version 2, or (at your option)
499-# any later version.
500+# Check to make sure that the build environment is sane. -*- Autoconf -*-
501
502-# This program is distributed in the hope that it will be useful,
503-# but WITHOUT ANY WARRANTY; without even the implied warranty of
504-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
505-# GNU General Public License for more details.
506-
507-# You should have received a copy of the GNU General Public License
508-# along with this program; if not, write to the Free Software
509-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
510-# 02111-1307, USA.
511+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
512+# Free Software Foundation, Inc.
513+#
514+# This file is free software; the Free Software Foundation
515+# gives unlimited permission to copy and/or distribute it,
516+# with or without modifications, as long as this notice is preserved.
517
518-# serial 3
519+# serial 4
520
521 # AM_SANITY_CHECK
522 # ---------------
523@@ -911,25 +753,14 @@
524 fi
525 AC_MSG_RESULT(yes)])
526
527-# AM_PROG_INSTALL_STRIP
528-
529-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
530-
531-# This program is free software; you can redistribute it and/or modify
532-# it under the terms of the GNU General Public License as published by
533-# the Free Software Foundation; either version 2, or (at your option)
534-# any later version.
535-
536-# This program is distributed in the hope that it will be useful,
537-# but WITHOUT ANY WARRANTY; without even the implied warranty of
538-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
539-# GNU General Public License for more details.
540-
541-# You should have received a copy of the GNU General Public License
542-# along with this program; if not, write to the Free Software
543-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
544-# 02111-1307, USA.
545+# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
546+#
547+# This file is free software; the Free Software Foundation
548+# gives unlimited permission to copy and/or distribute it,
549+# with or without modifications, as long as this notice is preserved.
550
551+# AM_PROG_INSTALL_STRIP
552+# ---------------------
553 # One issue with vendor `install' (even GNU) is that you can't
554 # specify the program used to strip binaries. This is especially
555 # annoying in cross-compiling environments, where the build's strip
556@@ -952,25 +783,13 @@
557
558 # Check how to create a tarball. -*- Autoconf -*-
559
560-# Copyright (C) 2004 Free Software Foundation, Inc.
561-
562-# This program is free software; you can redistribute it and/or modify
563-# it under the terms of the GNU General Public License as published by
564-# the Free Software Foundation; either version 2, or (at your option)
565-# any later version.
566-
567-# This program is distributed in the hope that it will be useful,
568-# but WITHOUT ANY WARRANTY; without even the implied warranty of
569-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
570-# GNU General Public License for more details.
571-
572-# You should have received a copy of the GNU General Public License
573-# along with this program; if not, write to the Free Software
574-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
575-# 02111-1307, USA.
576-
577-# serial 1
578+# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
579+#
580+# This file is free software; the Free Software Foundation
581+# gives unlimited permission to copy and/or distribute it,
582+# with or without modifications, as long as this notice is preserved.
583
584+# serial 2
585
586 # _AM_PROG_TAR(FORMAT)
587 # --------------------
588diff -Naur grub-0.97.orig/ChangeLog grub-0.97/ChangeLog
589--- grub-0.97.orig/ChangeLog 2005-05-07 19:47:02.000000000 -0700
590+++ grub-0.97/ChangeLog 2006-07-04 00:01:50.000000000 -0700
591@@ -1,3 +1,51 @@
592+2006-05-02 Pavel Roskin <proski@gnu.org>
593+
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.
597+
598+ * grub/main.c (main): Make sure the boot drive number doesn't
599+ exceed 255.
600+
601+2006-05-02 Vesa Jaaskelainen <chaac@nic.fi>
602+
603+ * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2
604+ to GRUB Legacy. Problem reported by Gerardo Richarte.
605+
606+2006-04-23 Robert Millan <robertmh@gnu.org>
607+
608+ * grub/asmstub.c (get_diskinfo): Optimize sysctl routine.
609+
610+2006-04-20 Robert Millan <robertmh@gnu.org>
611+
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.
616+
617+2006-04-16 Yoshinori K. Okuji <okuji@enbug.org>
618+
619+ * docs/multiboot.texi: Correct the offset of address
620+ fields. Reported by Jeroen Dekkers.
621+
622+2006-03-21 Yoshinori K. Okuji <okuji@enbug.org>
623+
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>.
627+
628+2005-09-29 Yoshinori K. Okuji <okuji@enbug.org>
629+
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.
633+
634+2005-09-28 Yoshinori K. Okuji <okuji@enbug.org>
635+
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
638+ specified.
639+
640 2005-05-08 Yoshinori K. Okuji <okuji@enbug.org>
641
642 * configure.ac (AC_INIT): Upgraded to 0.97.
643diff -Naur grub-0.97.orig/configure grub-0.97/configure
644--- grub-0.97.orig/configure 2005-05-07 19:48:12.000000000 -0700
645+++ grub-0.97/configure 2006-07-04 00:08:05.000000000 -0700
646@@ -311,7 +311,7 @@
647 # include <unistd.h>
648 #endif"
649
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 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'
651+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'
652 ac_subst_files=''
653
654 # Initialize some variables set by options.
655@@ -914,6 +914,7 @@
656 set the default memory location for WD/SMC
657 --enable-cs-scan=LIST probe for CS89x0 base address using LIST
658 --enable-diskless enable diskless support
659+ --disable-graphics disable graphics terminal support
660 --disable-hercules disable hercules terminal support
661 --disable-serial disable serial terminal support
662 --enable-serial-speed-simulation
663@@ -5966,6 +5967,22 @@
664 fi
665
666
667+# Check whether --enable-graphics or --disable-graphics was given.
668+if test "${enable_graphics+set}" = set; then
669+ enableval="$enable_graphics"
670+
671+fi;
672+
673+
674+if test "x$enable_graphics" != xno; then
675+ GRAPHICS_SUPPORT_TRUE=
676+ GRAPHICS_SUPPORT_FALSE='#'
677+else
678+ GRAPHICS_SUPPORT_TRUE='#'
679+ GRAPHICS_SUPPORT_FALSE=
680+fi
681+
682+
683 # Check whether --enable-hercules or --disable-hercules was given.
684 if test "${enable_hercules+set}" = set; then
685 enableval="$enable_hercules"
686@@ -6270,6 +6287,13 @@
687 Usually this means the macro was only invoked conditionally." >&2;}
688 { (exit 1); exit 1; }; }
689 fi
690+if test -z "${GRAPHICS_SUPPORT_TRUE}" && test -z "${GRAPHICS_SUPPORT_FALSE}"; then
691+ { { echo "$as_me:$LINENO: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
692+Usually this means the macro was only invoked conditionally." >&5
693+echo "$as_me: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
694+Usually this means the macro was only invoked conditionally." >&2;}
695+ { (exit 1); exit 1; }; }
696+fi
697 if test -z "${HERCULES_SUPPORT_TRUE}" && test -z "${HERCULES_SUPPORT_FALSE}"; then
698 { { echo "$as_me:$LINENO: error: conditional \"HERCULES_SUPPORT\" was never defined.
699 Usually this means the macro was only invoked conditionally." >&5
700@@ -6907,6 +6931,8 @@
701 s,@NETBOOT_SUPPORT_FALSE@,$NETBOOT_SUPPORT_FALSE,;t t
702 s,@DISKLESS_SUPPORT_TRUE@,$DISKLESS_SUPPORT_TRUE,;t t
703 s,@DISKLESS_SUPPORT_FALSE@,$DISKLESS_SUPPORT_FALSE,;t t
704+s,@GRAPHICS_SUPPORT_TRUE@,$GRAPHICS_SUPPORT_TRUE,;t t
705+s,@GRAPHICS_SUPPORT_FALSE@,$GRAPHICS_SUPPORT_FALSE,;t t
706 s,@HERCULES_SUPPORT_TRUE@,$HERCULES_SUPPORT_TRUE,;t t
707 s,@HERCULES_SUPPORT_FALSE@,$HERCULES_SUPPORT_FALSE,;t t
708 s,@SERIAL_SUPPORT_TRUE@,$SERIAL_SUPPORT_TRUE,;t t
709diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
710--- grub-0.97.orig/configure.ac 2005-05-07 19:36:03.000000000 -0700
711+++ grub-0.97/configure.ac 2006-07-03 23:58:41.000000000 -0700
712@@ -595,6 +595,11 @@
713 [ --enable-diskless enable diskless support])
714 AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
715
716+dnl Graphical splashscreen support
717+AC_ARG_ENABLE(graphics,
718+ [ --disable-graphics disable graphics terminal support])
719+AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno)
720+
721 dnl Hercules terminal
722 AC_ARG_ENABLE(hercules,
723 [ --disable-hercules disable hercules terminal support])
724diff -Naur grub-0.97.orig/docs/grub.8 grub-0.97/docs/grub.8
725--- grub-0.97.orig/docs/grub.8 2005-05-07 19:48:56.000000000 -0700
726+++ grub-0.97/docs/grub.8 2006-07-04 00:01:50.000000000 -0700
727@@ -1,5 +1,5 @@
728 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23.
729-.TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF
730+.TH GRUB "8" "September 2005" "grub (GNU GRUB 0.97)" FSF
731 .SH NAME
732 grub \- the grub shell
733 .SH SYNOPSIS
734diff -Naur grub-0.97.orig/docs/grub.texi grub-0.97/docs/grub.texi
735--- grub-0.97.orig/docs/grub.texi 2005-05-07 19:59:59.000000000 -0700
736+++ grub-0.97/docs/grub.texi 2006-07-04 00:00:54.000000000 -0700
737@@ -2199,6 +2199,7 @@
738 * rarp:: Initialize a network device via RARP
739 * serial:: Set up a serial device
740 * setkey:: Configure the key map
741+* splashimage:: Use a splash image
742 * terminal:: Choose a terminal
743 * terminfo:: Define escape sequences for a terminal
744 * tftpserver:: Specify a TFTP server
745@@ -2578,6 +2579,16 @@
746 @end deffn
747
748
749+@node splashimage
750+@subsection splashimage
751+
752+@deffn Command splashimage file
753+Select an image to use as the background image. This should be
754+specified using normal GRUB device naming syntax. The format of the
755+file is a gzipped xpm which is 640x480 with a 14 color palette.
756+@end deffn
757+
758+
759 @node terminal
760 @subsection terminal
761
762@@ -2685,6 +2696,7 @@
763 * module:: Load a module
764 * modulenounzip:: Load a module without decompression
765 * pause:: Wait for a key press
766+* print:: Print a message
767 * quit:: Exit from the grub shell
768 * reboot:: Reboot your computer
769 * read:: Read data from memory
770@@ -3091,6 +3103,16 @@
771 @end deffn
772
773
774+@node print
775+@subsection print
776+
777+@deffn Command print message @dots{}
778+Print the @var{message}. Note that placing @key{^G} (ASCII code 7) in the
779+message will cause the speaker to emit the standard beep sound, which is
780+useful for visually impaired people.
781+@end deffn
782+
783+
784 @node quit
785 @subsection quit
786
787diff -Naur grub-0.97.orig/docs/multiboot.texi grub-0.97/docs/multiboot.texi
788--- grub-0.97.orig/docs/multiboot.texi 2003-07-09 04:45:36.000000000 -0700
789+++ grub-0.97/docs/multiboot.texi 2006-07-04 00:01:50.000000000 -0700
790@@ -25,7 +25,7 @@
791 @ifinfo
792 Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
793 Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
794-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
795+Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
796
797 Permission is granted to make and distribute verbatim copies of
798 this manual provided the copyright notice and this permission notice
799@@ -57,7 +57,7 @@
800 @vskip 0pt plus 1filll
801 Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
802 Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
803-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
804+Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
805
806 Permission is granted to make and distribute verbatim copies of
807 this manual provided the copyright notice and this permission notice
808@@ -80,7 +80,7 @@
809 @top Multiboot Specification
810
811 This file documents Multiboot Specification, the proposal for the boot
812-sequence standard. This edition documents version 0.6.93.
813+sequence standard. This edition documents version 0.6.94.
814 @end ifnottex
815
816 @menu
817@@ -426,7 +426,7 @@
818 kernel.
819
820 If bit 16 in the @samp{flags} word is set, then the fields at offsets
821-8-24 in the Multiboot header are valid, and the boot loader should use
822+12-28 in the Multiboot header are valid, and the boot loader should use
823 them instead of the fields in the actual executable header to calculate
824 where to load the OS image. This information does not need to be
825 provided if the kernel image is in @sc{elf} format, but it @emph{must}
826@@ -677,7 +677,7 @@
827 @example
828 @group
829 +-------+-------+-------+-------+
830-| drive | part1 | part2 | part3 |
831+| part3 | part2 | part1 | drive |
832 +-------+-------+-------+-------+
833 @end group
834 @end example
835@@ -1199,6 +1199,13 @@
836 @email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn.
837 @end itemize
838
839+@item
840+The byte order of the @samp{boot_device} in Multiboot information is
841+reversed. This was a mistake.
842+
843+@item
844+The offset of the address fields were wrong.
845+
846 @item 0.6
847 @itemize @bullet
848 @item
849diff -Naur grub-0.97.orig/grub/asmstub.c grub-0.97/grub/asmstub.c
850--- grub-0.97.orig/grub/asmstub.c 2005-02-16 12:45:14.000000000 -0800
851+++ grub-0.97/grub/asmstub.c 2006-07-04 00:01:50.000000000 -0700
852@@ -55,6 +61,10 @@
853 # endif /* ! BLKFLSBUF */
854 #endif /* __linux__ */
855
856+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
857+# include <sys/sysctl.h>
858+#endif
859+
860 /* We want to prevent any circularararity in our stubs, as well as
861 libc name clashes. */
862 #define WITHOUT_LIBC_STUBS 1
863@@ -777,7 +803,39 @@
864
865 /* Open read/write, or read-only if that failed. */
866 if (! read_only)
867- disks[drive].flags = open (devname, O_RDWR);
868+ {
869+/* By default, kernel of FreeBSD does not allow overwriting MBR */
870+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
871+#define GEOM_SYSCTL "kern.geom.debugflags"
872+ int old_flags, flags;
873+ size_t sizeof_int = sizeof (int);
874+
875+ if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0)
876+ grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
877+
878+ if ((old_flags & 0x10) == 0)
879+ {
880+ /* "allow foot shooting", see geom(4) */
881+ flags = old_flags | 0x10;
882+
883+ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0)
884+ {
885+ flags = old_flags;
886+ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
887+ }
888+ }
889+ else
890+ flags = old_flags;
891+#endif
892+ disks[drive].flags = open (devname, O_RDWR);
893+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
894+ if (flags != old_flags)
895+ {
896+ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0)
897+ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
898+ }
899+#endif
900+ }
901
902 if (disks[drive].flags == -1)
903 {
904diff -Naur grub-0.97.orig/grub/main.c grub-0.97/grub/main.c
905--- grub-0.97.orig/grub/main.c 2003-07-09 04:45:36.000000000 -0700
906+++ grub-0.97/grub/main.c 2006-07-04 00:01:50.000000000 -0700
907@@ -32,6 +32,7 @@
908 #define WITHOUT_LIBC_STUBS 1
909 #include <shared.h>
910 #include <term.h>
911+#include <device.h>
912
913 char *program_name = 0;
914 int use_config_file = 1;
915@@ -192,6 +193,12 @@
916 perror ("strtoul");
917 exit (1);
918 }
919+ if (boot_drive >= NUM_DISKS)
920+ {
921+ fprintf (stderr, "boot_drive should be from 0 to %d\n",
922+ NUM_DISKS - 1);
923+ exit (1);
924+ }
925 break;
926
927 case OPT_NO_CONFIG_FILE:
928diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
929--- grub-0.97.orig/lib/device.c 2005-03-27 15:14:25.000000000 -0800
930+++ grub-0.97/lib/device.c 2006-07-04 00:00:44.000000000 -0700
931@@ -131,6 +131,152 @@
932 #include <shared.h>
933 #include <device.h>
934
935+#if defined(__linux__)
936+/* The 2.6 kernel has removed all of the geometry handling for IDE drives
937+ * that did fixups for LBA, etc. This means that the geometry we get
938+ * with the ioctl has a good chance of being wrong. So, we get to
939+ * also know about partition tables and try to read what the geometry
940+ * is there. *grumble* Very closely based on code from cfdisk
941+ */
942+static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
943+ struct hd_geometry hdg;
944+
945+ if (ioctl (fd, HDIO_GETGEO, &hdg))
946+ return;
947+
948+ *cyl = hdg.cylinders;
949+ *heads = hdg.heads;
950+ *sectors = hdg.sectors;
951+}
952+
953+struct partition {
954+ unsigned char boot_ind; /* 0x80 - active */
955+ unsigned char head; /* starting head */
956+ unsigned char sector; /* starting sector */
957+ unsigned char cyl; /* starting cylinder */
958+ unsigned char sys_ind; /* What partition type */
959+ unsigned char end_head; /* end head */
960+ unsigned char end_sector; /* end sector */
961+ unsigned char end_cyl; /* end cylinder */
962+ unsigned char start4[4]; /* starting sector counting from 0 */
963+ unsigned char size4[4]; /* nr of sectors in partition */
964+};
965+
966+#define ALIGNMENT 2
967+typedef union {
968+ struct {
969+ unsigned char align[ALIGNMENT];
970+ unsigned char b[SECTOR_SIZE];
971+ } c;
972+ struct {
973+ unsigned char align[ALIGNMENT];
974+ unsigned char buffer[0x1BE];
975+ struct partition part[4];
976+ unsigned char magicflag[2];
977+ } p;
978+} partition_table;
979+
980+#define PART_TABLE_FLAG0 0x55
981+#define PART_TABLE_FLAG1 0xAA
982+
983+static void
984+get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
985+ int *sectors) {
986+ struct partition *p;
987+ int i,h,s,hh,ss;
988+ int first = 1;
989+ int bad = 0;
990+
991+ if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
992+ bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
993+ /* Matthew Wilcox: slightly friendlier version of
994+ fatal(_("Bad signature on partition table"), 3);
995+ */
996+ fprintf(stderr, "Unknown partition table signature\n");
997+ return;
998+ }
999+
1000+ hh = ss = 0;
1001+ for (i=0; i<4; i++) {
1002+ p = &(bufp->p.part[i]);
1003+ if (p->sys_ind != 0) {
1004+ h = p->end_head + 1;
1005+ s = (p->end_sector & 077);
1006+ if (first) {
1007+ hh = h;
1008+ ss = s;
1009+ first = 0;
1010+ } else if (hh != h || ss != s)
1011+ bad = 1;
1012+ }
1013+ }
1014+
1015+ if (!first && !bad) {
1016+ *heads = hh;
1017+ *sectors = ss;
1018+ }
1019+}
1020+
1021+static long long my_lseek (unsigned int fd, long long offset,
1022+ unsigned int origin)
1023+{
1024+#if defined(__linux__) && (!defined(__GLIBC__) || \
1025+ ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
1026+ /* Maybe libc doesn't have large file support. */
1027+ loff_t offset, result;
1028+ static int _llseek (uint filedes, ulong hi, ulong lo,
1029+ loff_t *res, uint wh);
1030+ _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
1031+ loff_t *, res, uint, wh);
1032+
1033+ if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
1034+ return (long long) -1;
1035+ return result;
1036+#else
1037+ return lseek(fd, offset, SEEK_SET);
1038+#endif
1039+}
1040+
1041+static void get_linux_geometry (int fd, struct geometry *geom) {
1042+ long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
1043+ long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
1044+ partition_table bufp;
1045+ char *buff, *buf_unaligned;
1046+
1047+ buf_unaligned = malloc(sizeof(partition_table) + 4095);
1048+ buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
1049+ (~(4096-1)));
1050+
1051+ get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
1052+
1053+ if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
1054+ fprintf(stderr, "Unable to seek");
1055+ }
1056+
1057+ if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
1058+ memcpy(bufp.c.b, buff, SECTOR_SIZE);
1059+ get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
1060+ } else {
1061+ fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
1062+ }
1063+
1064+ if (pt_head && pt_sectors) {
1065+ int cyl_size;
1066+
1067+ geom->heads = pt_head;
1068+ geom->sectors = pt_sectors;
1069+ cyl_size = pt_head * pt_sectors;
1070+ geom->cylinders = geom->total_sectors/cyl_size;
1071+ } else {
1072+ geom->heads = kern_head;
1073+ geom->sectors = kern_sectors;
1074+ geom->cylinders = kern_cyl;
1075+ }
1076+
1077+ return;
1078+}
1079+#endif
1080+
1081 /* Get the geometry of a drive DRIVE. */
1082 void
1083 get_drive_geometry (struct geometry *geom, char **map, int drive)
1084@@ -151,21 +297,16 @@
1085 #if defined(__linux__)
1086 /* Linux */
1087 {
1088- struct hd_geometry hdg;
1089 unsigned long nr;
1090-
1091- if (ioctl (fd, HDIO_GETGEO, &hdg))
1092- goto fail;
1093
1094 if (ioctl (fd, BLKGETSIZE, &nr))
1095 goto fail;
1096
1097 /* Got the geometry, so save it. */
1098- geom->cylinders = hdg.cylinders;
1099- geom->heads = hdg.heads;
1100- geom->sectors = hdg.sectors;
1101 geom->total_sectors = nr;
1102-
1103+ get_linux_geometry(fd, geom);
1104+ if (!geom->heads && !geom->cylinders && !geom->sectors)
1105+ goto fail;
1106 goto success;
1107 }
1108
1109@@ -403,6 +544,18 @@
1110 }
1111
1112 static void
1113+get_cciss_disk_name (char *name, int controller, int drive)
1114+{
1115+ sprintf (name, "/dev/cciss/c%dd%d", controller, drive);
1116+}
1117+
1118+static void
1119+get_ida_disk_name (char *name, int controller, int drive)
1120+{
1121+ sprintf (name, "/dev/ida/c%dd%d", controller, drive);
1122+}
1123+
1124+static void
1125 get_ataraid_disk_name (char *name, int unit)
1126 {
1127 sprintf (name, "/dev/ataraid/d%c", unit + '0');
1128@@ -801,6 +954,74 @@
1129 }
1130 }
1131 }
1132+
1133+ /* This is for CCISS, its like the DAC960 - we have
1134+ /dev/cciss/<controller>d<logical drive>p<partition>
1135+
1136+ It currently supports up to 3 controllers, 10 logical volumes
1137+ and 10 partitions
1138+
1139+ Code gratuitously copied from DAC960 above.
1140+ Horms <horms@verge.net.au> 23rd July 2004
1141+ */
1142+ {
1143+ int controller, drive;
1144+
1145+ for (controller = 0; controller < 2; controller++)
1146+ {
1147+ for (drive = 0; drive < 9; drive++)
1148+ {
1149+ char name[24];
1150+
1151+ get_cciss_disk_name (name, controller, drive);
1152+ if (check_device (name))
1153+ {
1154+ (*map)[num_hd + 0x80] = strdup (name);
1155+ assert ((*map)[num_hd + 0x80]);
1156+
1157+ /* If the device map file is opened, write the map. */
1158+ if (fp)
1159+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
1160+
1161+ num_hd++;
1162+ }
1163+ }
1164+ }
1165+ }
1166+
1167+ /* This is for Compaq Smart Array, its like the DAC960 - we have
1168+ /dev/ida/<controller>d<logical drive>p<partition>
1169+
1170+ It currently supports up to 3 controllers, 10 logical volumes
1171+ and 15 partitions
1172+
1173+ Code gratuitously copied from DAC960 above.
1174+ Piotr Roszatycki <dexter@debian.org>
1175+ */
1176+ {
1177+ int controller, drive;
1178+
1179+ for (controller = 0; controller < 2; controller++)
1180+ {
1181+ for (drive = 0; drive < 9; drive++)
1182+ {
1183+ char name[24];
1184+
1185+ get_ida_disk_name (name, controller, drive);
1186+ if (check_device (name))
1187+ {
1188+ (*map)[num_hd + 0x80] = strdup (name);
1189+ assert ((*map)[num_hd + 0x80]);
1190+
1191+ /* If the device map file is opened, write the map. */
1192+ if (fp)
1193+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
1194+
1195+ num_hd++;
1196+ }
1197+ }
1198+ }
1199+ }
1200 #endif /* __linux__ */
1201
1202 /* OK, close the device map file if opened. */
1203@@ -844,6 +1065,7 @@
1204 {
1205 char dev[PATH_MAX]; /* XXX */
1206 int fd;
1207+ off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
1208
1209 if ((partition & 0x00FF00) != 0x00FF00)
1210 {
1211@@ -861,8 +1083,14 @@
1212 if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
1213 strcpy (dev + strlen(dev) - 5, "/part");
1214 }
1215- sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
1216-
1217+ sprintf (dev + strlen(dev), "%s%d",
1218+ /* Compaq smart and others */
1219+ (strncmp(dev, "/dev/ida/", 9) == 0 ||
1220+ strncmp(dev, "/dev/ataraid/", 13) == 0 ||
1221+ strncmp(dev, "/dev/cciss/", 11) == 0 ||
1222+ strncmp(dev, "/dev/rd/", 8) == 0) ? "p" : "",
1223+ ((partition >> 16) & 0xFF) + 1);
1224+
1225 /* Open the partition. */
1226 fd = open (dev, O_RDWR);
1227 if (fd < 0)
1228@@ -870,35 +1098,13 @@
1229 errnum = ERR_NO_PART;
1230 return 0;
1231 }
1232-
1233-#if defined(__linux__) && (!defined(__GLIBC__) || \
1234- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
1235- /* Maybe libc doesn't have large file support. */
1236- {
1237- loff_t offset, result;
1238- static int _llseek (uint filedes, ulong hi, ulong lo,
1239- loff_t *res, uint wh);
1240- _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
1241- loff_t *, res, uint, wh);
1242
1243- offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
1244- if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
1245- {
1246- errnum = ERR_DEV_VALUES;
1247- return 0;
1248- }
1249- }
1250-#else
1251- {
1252- off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
1253
1254- if (lseek (fd, offset, SEEK_SET) != offset)
1255- {
1256- errnum = ERR_DEV_VALUES;
1257- return 0;
1258- }
1259- }
1260-#endif
1261+ if (my_lseek(fd, offset, SEEK_SET) != offset)
1262+ {
1263+ errnum = ERR_DEV_VALUES;
1264+ return 0;
1265+ }
1266
1267 if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
1268 {
1269diff -Naur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S
1270--- grub-0.97.orig/stage2/asm.S 2004-06-19 09:55:22.000000000 -0700
1271+++ grub-0.97/stage2/asm.S 2006-07-04 00:01:19.000000000 -0700
1272@@ -1651,7 +1651,29 @@
1273 jnz 3f
1274 ret
1275
1276-3: /* use keyboard controller */
1277+3: /*
1278+ * try to switch gateA20 using PORT92, the "Fast A20 and Init"
1279+ * register
1280+ */
1281+ mov $0x92, %dx
1282+ inb %dx, %al
1283+ /* skip the port92 code if it's unimplemented (read returns 0xff) */
1284+ cmpb $0xff, %al
1285+ jz 6f
1286+
1287+ /* set or clear bit1, the ALT_A20_GATE bit */
1288+ movb 4(%esp), %ah
1289+ testb %ah, %ah
1290+ jz 4f
1291+ orb $2, %al
1292+ jmp 5f
1293+4: and $0xfd, %al
1294+
1295+ /* clear the INIT_NOW bit don't accidently reset the machine */
1296+5: and $0xfe, %al
1297+ outb %al, %dx
1298+
1299+6: /* use keyboard controller */
1300 pushl %eax
1301
1302 call gloop1
1303@@ -1661,9 +1683,12 @@
1304
1305 gloopint1:
1306 inb $K_STATUS
1307+ cmpb $0xff, %al
1308+ jz gloopint1_done
1309 andb $K_IBUF_FUL, %al
1310 jnz gloopint1
1311
1312+gloopint1_done:
1313 movb $KB_OUTPUT_MASK, %al
1314 cmpb $0, 0x8(%esp)
1315 jz gdoit
1316@@ -1684,6 +1709,8 @@
1317
1318 gloop1:
1319 inb $K_STATUS
1320+ cmpb $0xff, %al
1321+ jz gloop2ret
1322 andb $K_IBUF_FUL, %al
1323 jnz gloop1
1324
1325@@ -1991,6 +2018,11 @@
1326 ENTRY(console_getkey)
1327 push %ebp
1328
1329+wait_for_key:
1330+ call EXT_C(console_checkkey)
1331+ incl %eax
1332+ jz wait_for_key
1333+
1334 call EXT_C(prot_to_real)
1335 .code16
1336
1337@@ -2216,7 +2248,304 @@
1338 pop %ebx
1339 pop %ebp
1340 ret
1341-
1342+
1343+
1344+/* graphics mode functions */
1345+#ifdef SUPPORT_GRAPHICS
1346+VARIABLE(cursorX)
1347+.word 0
1348+VARIABLE(cursorY)
1349+.word 0
1350+VARIABLE(cursorCount)
1351+.word 0
1352+VARIABLE(cursorBuf)
1353+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1354+
1355+
1356+/*
1357+ * set_int1c_handler(void)
1358+ */
1359+ENTRY(set_int1c_handler)
1360+ pushl %edi
1361+
1362+ /* save the original int1c handler */
1363+ movl $0x70, %edi
1364+ movw (%edi), %ax
1365+ movw %ax, ABS(int1c_offset)
1366+ movw 2(%edi), %ax
1367+ movw %ax, ABS(int1c_segment)
1368+
1369+ /* save the new int1c handler */
1370+ movw $ABS(int1c_handler), %ax
1371+ movw %ax, (%edi)
1372+ xorw %ax, %ax
1373+ movw %ax, 2(%edi)
1374+
1375+ popl %edi
1376+ ret
1377+
1378+
1379+/*
1380+ * unset_int1c_handler(void)
1381+ */
1382+ENTRY(unset_int1c_handler)
1383+ pushl %edi
1384+
1385+ /* check if int1c_handler is set */
1386+ movl $0x70, %edi
1387+ movw $ABS(int1c_handler), %ax
1388+ cmpw %ax, (%edi)
1389+ jne int1c_1
1390+ xorw %ax, %ax
1391+ cmpw %ax, 2(%edi)
1392+ jne int1c_1
1393+
1394+ /* restore the original */
1395+ movw ABS(int1c_offset), %ax
1396+ movw %ax, (%edi)
1397+ movw ABS(int1c_segment), %ax
1398+ movw %ax, 2(%edi)
1399+
1400+int1c_1:
1401+ popl %edi
1402+ ret
1403+
1404+
1405+/*
1406+ * blinks graphics cursor
1407+ */
1408+ .code16
1409+write_data:
1410+ movw $0, %ax
1411+ movw %ax, %ds
1412+
1413+ mov $0xA000, %ax /* video in es:di */
1414+ mov %ax, %es
1415+ mov $80, %ax
1416+ movw $ABS(cursorY), %si
1417+ mov %ds:(%si), %bx
1418+ mul %bx
1419+ movw $ABS(cursorX), %si
1420+ mov %ds:(%si), %bx
1421+ shr $3, %bx /* %bx /= 8 */
1422+ add %bx, %ax
1423+ mov %ax, %di
1424+
1425+ movw $ABS(cursorBuf), %si /* fontBuf in ds:si */
1426+
1427+ /* prepare for data moving */
1428+ mov $16, %dx /* altura da fonte */
1429+ mov $80, %bx /* bytes por linha */
1430+
1431+write_loop:
1432+ movb %ds:(%si), %al
1433+ xorb $0xff, %al
1434+ movb %al, %ds:(%si) /* invert cursorBuf */
1435+ movb %al, %es:(%di) /* write to video */
1436+ add %bx, %di
1437+ inc %si
1438+ dec %dx
1439+ jg write_loop
1440+ ret
1441+
1442+int1c_handler:
1443+ pusha
1444+ mov $0, %ax
1445+ mov %ax, %ds
1446+ mov $ABS(cursorCount), %si
1447+ mov %ds:(%si), %ax
1448+ inc %ax
1449+ mov %ax, %ds:(%si)
1450+ cmp $9, %ax
1451+ jne int1c_done
1452+
1453+ mov $0, %ax
1454+ mov %ax, %ds:(%si)
1455+ call write_data
1456+
1457+int1c_done:
1458+ popa
1459+ iret
1460+ /* call previous int1c handler */
1461+ /* ljmp */
1462+ .byte 0xea
1463+int1c_offset: .word 0
1464+int1c_segment: .word 0
1465+ .code32
1466+
1467+
1468+/*
1469+ * unsigned char set_videomode(unsigned char mode)
1470+ * BIOS call "INT 10H Function 0h" to set video mode
1471+ * Call with %ah = 0x0
1472+ * %al = video mode
1473+ * Returns old videomode.
1474+ */
1475+ENTRY(set_videomode)
1476+ pushl %ebp
1477+ movl %esp,%ebp
1478+ pushl %ebx
1479+ pushl %ecx
1480+
1481+ movb 8(%ebp), %cl
1482+
1483+ call EXT_C(prot_to_real)
1484+ .code16
1485+
1486+ xorb %al, %al
1487+ movb $0xf, %ah
1488+ int $0x10 /* Get Current Video mode */
1489+ movb %al, %ch
1490+ xorb %ah, %ah
1491+ movb %cl, %al
1492+ int $0x10 /* Set Video mode */
1493+
1494+ DATA32 call EXT_C(real_to_prot)
1495+ .code32
1496+
1497+ xorl %eax, %eax
1498+ movb %ch, %al
1499+
1500+ popl %ecx
1501+ popl %ebx
1502+ popl %ebp
1503+ ret
1504+
1505+
1506+/*
1507+ * int get_videomode()
1508+ * BIOS call "INT 10H Function 0Fh" to get current video mode
1509+ * Call with %al = 0x0
1510+ * %ah = 0xF
1511+ * Returns current videomode.
1512+ */
1513+ENTRY(get_videomode)
1514+ pushl %ebp
1515+ movl %esp,%ebp
1516+ pushl %ebx
1517+ pushl %ecx
1518+
1519+ call EXT_C(prot_to_real)
1520+ .code16
1521+
1522+ xorb %al, %al
1523+ movb $0xF, %ah
1524+ int $0x10 /* Get Current Video mode */
1525+ movb %al, %cl /* For now we only want display mode */
1526+
1527+ DATA32 call EXT_C(real_to_prot)
1528+ .code32
1529+
1530+ xorl %eax, %eax
1531+ movb %cl, %al
1532+
1533+ popl %ecx
1534+ popl %ebx
1535+ popl %ebp
1536+ ret
1537+
1538+
1539+/*
1540+ * unsigned char * graphics_get_font()
1541+ * BIOS call "INT 10H Function 11h" to set font
1542+ * Call with %ah = 0x11
1543+ */
1544+ENTRY(graphics_get_font)
1545+ push %ebp
1546+ push %ebx
1547+ push %ecx
1548+ push %edx
1549+
1550+ call EXT_C(prot_to_real)
1551+ .code16
1552+
1553+ movw $0x1130, %ax
1554+ movb $6, %bh /* font 8x16 */
1555+ int $0x10
1556+ movw %bp, %dx
1557+ movw %es, %cx
1558+
1559+ DATA32 call EXT_C(real_to_prot)
1560+ .code32
1561+
1562+ xorl %eax, %eax
1563+ movw %cx, %ax
1564+ shll $4, %eax
1565+ movw %dx, %ax
1566+
1567+ pop %edx
1568+ pop %ecx
1569+ pop %ebx
1570+ pop %ebp
1571+ ret
1572+
1573+
1574+/*
1575+ * graphics_set_palette(index, red, green, blue)
1576+ * BIOS call "INT 10H Function 10h" to set individual dac register
1577+ * Call with %ah = 0x10
1578+ * %bx = register number
1579+ * %ch = new value for green (0-63)
1580+ * %cl = new value for blue (0-63)
1581+ * %dh = new value for red (0-63)
1582+ */
1583+
1584+ENTRY(graphics_set_palette)
1585+ push %ebp
1586+ push %eax
1587+ push %ebx
1588+ push %ecx
1589+ push %edx
1590+
1591+ movw $0x3c8, %bx /* address write mode register */
1592+
1593+ /* wait vertical retrace */
1594+ movw $0x3da, %dx
1595+l1b:
1596+ inb %dx, %al /* wait vertical active display */
1597+ test $8, %al
1598+ jnz l1b
1599+
1600+l2b:
1601+ inb %dx, %al /* wait vertical retrace */
1602+ test $8, %al
1603+ jnz l2b
1604+
1605+ mov %bx, %dx
1606+ movb 0x18(%esp), %al /* index */
1607+ outb %al, %dx
1608+ inc %dx
1609+
1610+ movb 0x1c(%esp), %al /* red */
1611+ outb %al, %dx
1612+
1613+ movb 0x20(%esp), %al /* green */
1614+ outb %al, %dx
1615+
1616+ movb 0x24(%esp), %al /* blue */
1617+ outb %al, %dx
1618+
1619+ movw 0x18(%esp), %bx
1620+
1621+ call EXT_C(prot_to_real)
1622+ .code16
1623+
1624+ movb %bl, %bh
1625+ movw $0x1000, %ax
1626+ int $0x10
1627+
1628+ DATA32 call EXT_C(real_to_prot)
1629+ .code32
1630+
1631+ pop %edx
1632+ pop %ecx
1633+ pop %ebx
1634+ pop %eax
1635+ pop %ebp
1636+ ret
1637+#endif /* SUPPORT_GRAPHICS */
1638+
1639+
1640 /*
1641 * getrtsecs()
1642 * if a seconds value can be read, read it and return it (BCD),
1643diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
1644--- grub-0.97.orig/stage2/boot.c 2004-03-30 03:44:08.000000000 -0800
1645+++ grub-0.97/stage2/boot.c 2006-07-04 00:01:50.000000000 -0700
1646@@ -1,7 +1,7 @@
1647 /* boot.c - load and bootstrap a kernel */
1648 /*
1649 * GRUB -- GRand Unified Bootloader
1650- * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
1651+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
1652 *
1653 * This program is free software; you can redistribute it and/or modify
1654 * it under the terms of the GNU General Public License as published by
1655@@ -29,6 +29,8 @@
1656 entry_func entry_addr;
1657 static struct mod_list mll[99];
1658 static int linux_mem_size;
1659+static int elf_kernel_addr;
1660+static int elf_kernel_size;
1661
1662 /*
1663 * The next two functions, 'load_image' and 'load_module', are the building
1664@@ -96,7 +98,7 @@
1665 lh = (struct linux_kernel_header *) buffer;
1666
1667 /* ELF loading supported if multiboot, FreeBSD and NetBSD. */
1668- if ((type == KERNEL_TYPE_MULTIBOOT
1669+ if (((type == KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KLUDGE))
1670 || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
1671 || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
1672 || suggested_type == KERNEL_TYPE_NETBSD)
1673@@ -594,6 +596,7 @@
1674
1675 /* reset this to zero for now */
1676 cur_addr = 0;
1677+ elf_kernel_addr = ~0;
1678
1679 /* scan for program segments */
1680 for (i = 0; i < pu.elf->e_phnum; i++)
1681@@ -630,6 +633,8 @@
1682 /* mark memory as used */
1683 if (cur_addr < memaddr + memsiz)
1684 cur_addr = memaddr + memsiz;
1685+ if (elf_kernel_addr > cur_addr)
1686+ elf_kernel_addr = cur_addr;
1687 printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
1688 memsiz - filesiz);
1689 /* increment number of segments */
1690@@ -647,6 +652,8 @@
1691 }
1692 }
1693
1694+ elf_kernel_size = cur_addr - elf_kernel_addr;
1695+
1696 if (! errnum)
1697 {
1698 if (! loaded)
1699@@ -824,8 +831,11 @@
1700 moveto = (mbi.mem_upper + 0x400) << 10;
1701
1702 moveto = (moveto - len) & 0xfffff000;
1703- max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
1704- ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
1705+ max_addr = LINUX_INITRD_MAX_ADDRESS;
1706+ if (lh->header == LINUX_MAGIC_SIGNATURE &&
1707+ lh->version >= 0x0203 &&
1708+ lh->initrd_addr_max < max_addr)
1709+ max_addr = lh->initrd_addr_max;
1710 if (moveto + len >= max_addr)
1711 moveto = (max_addr - len) & 0xfffff000;
1712
1713@@ -864,6 +874,129 @@
1714 }
1715 #endif
1716
1717+#define mem_align4k(p) ((p) + 0xFFF) & 0xFFFFF000
1718+
1719+static void
1720+kfreebsd_setenv (char *env, const char *var, const char *value)
1721+{
1722+ while (1)
1723+ {
1724+ if (env[0] == '\0' && env[1] == '\0')
1725+ {
1726+ env++;
1727+ break;
1728+ }
1729+ else
1730+ env++;
1731+ }
1732+
1733+ grub_sprintf (env, "%s=%s", var, value);
1734+ env[grub_strlen (env) + 1] = '\0';
1735+}
1736+
1737+static char *
1738+kfreebsd_read_hints (char *buf)
1739+{
1740+ char *buf_end = buf;
1741+
1742+ if (grub_open ("/boot/device.hints"))
1743+ {
1744+ char *line_start;
1745+ int line_len = 0;
1746+ char *envp;
1747+ int env_len;
1748+
1749+ env_len = grub_read (buf, -1);
1750+ if (env_len)
1751+ {
1752+ buf_end += env_len;
1753+ *(buf_end++) = '\0';
1754+ }
1755+ else
1756+ return buf_end;
1757+
1758+ grub_close ();
1759+
1760+ envp = line_start = buf;
1761+ while (*envp)
1762+ {
1763+ char *envp_current = envp;
1764+
1765+ switch (*envp)
1766+ {
1767+ case ' ':
1768+ while (*envp == ' ')
1769+ {
1770+ envp++;
1771+ env_len--;
1772+ }
1773+ grub_memmove (envp_current, envp, env_len + 1);
1774+ envp = envp_current;
1775+ break;
1776+ case '#':
1777+ while (*envp != '\n')
1778+ {
1779+ envp++;
1780+ env_len--;
1781+ }
1782+ if (!line_len)
1783+ envp++;
1784+ grub_memmove (envp_current, envp, env_len + 1);
1785+ envp = envp_current;
1786+ break;
1787+ case '\n':
1788+ if (!line_len)
1789+ {
1790+ env_len--;
1791+ grub_memmove (line_start, envp, env_len + 1);
1792+ }
1793+ *(envp++) = '\0';
1794+ line_len = 0;
1795+ line_start = envp;
1796+ default:
1797+ envp++;
1798+ line_len++;
1799+ break;
1800+ }
1801+ }
1802+
1803+ buf_end = buf + env_len;
1804+ *(buf_end++) = '\0';
1805+ }
1806+
1807+ return buf_end;
1808+}
1809+
1810+static u32_t *
1811+kfreebsd_set_module_string (u32_t type, u32_t *dst, char *src)
1812+{
1813+ int size;
1814+
1815+ *(dst++) = type;
1816+ *(dst++) = size = grub_strlen (src) + 1;
1817+ grub_strcpy ((void *) dst, src);
1818+
1819+ return dst + (size + sizeof(u32_t) - 1) / sizeof(u32_t);
1820+}
1821+
1822+static u32_t *
1823+kfreebsd_set_module_var (u32_t type, u32_t *dst, u32_t src)
1824+{
1825+ *(dst++) = type;
1826+ *(dst++) = sizeof(u32_t);
1827+ *(dst++) = src;
1828+
1829+ return dst;
1830+}
1831+
1832+static u32_t *
1833+kfreebsd_set_modules (u32_t *modulep)
1834+{
1835+ /* XXX: Need to copy the whole module structure. */
1836+ /* XXX: How to pass the module name ? */
1837+
1838+ return modulep;
1839+}
1840
1841 /*
1842 * All "*_boot" commands depend on the images being loaded into memory
1843@@ -877,7 +1010,10 @@
1844 bsd_boot (kernel_t type, int bootdev, char *arg)
1845 {
1846 char *str;
1847- int clval = 0, i;
1848+ char *kernelname;
1849+ char *bsd_root;
1850+ int clval = 0;
1851+ int i;
1852 struct bootinfo bi;
1853
1854 #ifdef GRUB_UTIL
1855@@ -886,8 +1022,21 @@
1856 stop_floppy ();
1857 #endif
1858
1859+ while (*arg != '/')
1860+ arg++;
1861+ kernelname = arg;
1862+
1863 while (*(++arg) && *arg != ' ');
1864+ *(arg++) = 0;
1865 str = arg;
1866+
1867+ bsd_root = grub_strstr (str, "root=");
1868+ if (bsd_root)
1869+ {
1870+ bsd_root += 5;
1871+ /* XXX: should copy the str or terminate it. */
1872+ }
1873+
1874 while (*str)
1875 {
1876 if (*str == '-')
1877@@ -910,6 +1059,8 @@
1878 clval |= RB_GDB;
1879 if (*str == 'h')
1880 clval |= RB_SERIAL;
1881+ if (*str == 'p')
1882+ clval |= RB_PAUSE;
1883 if (*str == 'm')
1884 clval |= RB_MUTE;
1885 if (*str == 'r')
1886@@ -927,14 +1078,17 @@
1887
1888 if (type == KERNEL_TYPE_FREEBSD)
1889 {
1890+ char *envp;
1891+ u32_t *modp;
1892+
1893 clval |= RB_BOOTINFO;
1894
1895 bi.bi_version = BOOTINFO_VERSION;
1896
1897- *arg = 0;
1898- while ((--arg) > (char *) MB_CMDLINE_BUF && *arg != '/');
1899- if (*arg == '/')
1900- bi.bi_kernelname = arg + 1;
1901+ bi.bi_pad[0] = bi.bi_pad[1] = 0;
1902+
1903+ if (*kernelname == '/')
1904+ bi.bi_kernelname = kernelname;
1905 else
1906 bi.bi_kernelname = 0;
1907
1908@@ -961,6 +1115,30 @@
1909 bi.bi_basemem = mbi.mem_lower;
1910 bi.bi_extmem = extended_memory;
1911
1912+ /* Setup the environment. */
1913+ bi.bi_envp = cur_addr = mem_align4k (cur_addr);
1914+ grub_memset ((void *) cur_addr, 0, 2);
1915+ cur_addr = (int) kfreebsd_read_hints ((void *) cur_addr);
1916+
1917+ envp = (char *) bi.bi_envp;
1918+ kfreebsd_setenv (envp, "kernelname", kernelname);
1919+ kfreebsd_setenv (envp, "vfs.root.mountfrom", bsd_root);
1920+
1921+ /* Setup the modules list. */
1922+ bi.bi_modulep = cur_addr = mem_align4k (cur_addr);
1923+ modp = (u32_t *) bi.bi_modulep;
1924+ /* The first module is the kernel. */
1925+ modp = kfreebsd_set_module_string (MODINFO_NAME, modp, kernelname);
1926+ modp = kfreebsd_set_module_string (MODINFO_TYPE, modp, "elf kernel");
1927+ modp = kfreebsd_set_module_string (MODINFO_ARGS, modp, arg);
1928+ modp = kfreebsd_set_module_var (MODINFO_ADDR, modp, elf_kernel_addr);
1929+ modp = kfreebsd_set_module_var (MODINFO_SIZE, modp, elf_kernel_size);
1930+ /* Now the real modules. */
1931+ modp = kfreebsd_set_modules(modp);
1932+
1933+ /* Set the kernel end. */
1934+ bi.bi_kernend = cur_addr = mem_align4k (((int) modp) + 1);
1935+
1936 if (mbi.flags & MB_INFO_AOUT_SYMS)
1937 {
1938 bi.bi_symtab = mbi.syms.a.addr;
1939@@ -970,8 +1148,9 @@
1940 #if 0
1941 else if (mbi.flags & MB_INFO_ELF_SHDR)
1942 {
1943- /* FIXME: Should check if a symbol table exists and, if exists,
1944- pass the table to BI. */
1945+ bi.bi_symtab = mbi.syms.e.addr;
1946+ bi.bi_esymtab = mbi.syms.e.addr
1947+ + mbi.syms.e.size * mbi.syms.e.num * mbi.syms.e.shndx;
1948 }
1949 #endif
1950 else
1951diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c
1952--- grub-0.97.orig/stage2/builtins.c 2005-02-15 13:58:23.000000000 -0800
1953+++ grub-0.97/stage2/builtins.c 2006-07-04 00:01:50.000000000 -0700
1954@@ -28,6 +28,10 @@
1955 #include <filesys.h>
1956 #include <term.h>
1957
1958+#ifdef SUPPORT_GRAPHICS
1959+# include <graphics.h>
1960+#endif
1961+
1962 #ifdef SUPPORT_NETBOOT
1963 # define GRUB 1
1964 # include <etherboot.h>
1965@@ -82,6 +86,10 @@
1966 inside other functions. */
1967 static int configfile_func (char *arg, int flags);
1968
1969+static int savedefault_helper (char *arg, int flags);
1970+
1971+static int savedefault_shell (char *arg, int flags);
1972+
1973 /* Initialize the data for builtins. */
1974 void
1975 init_builtins (void)
1976@@ -237,12 +245,22 @@
1977 static int
1978 boot_func (char *arg, int flags)
1979 {
1980+ struct term_entry *prev_term = current_term;
1981 /* Clear the int15 handler if we can boot the kernel successfully.
1982 This assumes that the boot code never fails only if KERNEL_TYPE is
1983 not KERNEL_TYPE_NONE. Is this assumption is bad? */
1984 if (kernel_type != KERNEL_TYPE_NONE)
1985 unset_int15_handler ();
1986
1987+ /* if our terminal needed initialization, we should shut it down
1988+ * before booting the kernel, but we want to save what it was so
1989+ * we can come back if needed */
1990+ if (current_term->shutdown)
1991+ {
1992+ current_term->shutdown();
1993+ current_term = term_table; /* assumption: console is first */
1994+ }
1995+
1996 #ifdef SUPPORT_NETBOOT
1997 /* Shut down the networking. */
1998 cleanup_net ();
1999@@ -306,6 +324,13 @@
2000 return 1;
2001 }
2002
2003+ /* if we get back here, we should go back to what our term was before */
2004+ current_term = prev_term;
2005+ if (current_term->startup)
2006+ /* if our terminal fails to initialize, fall back to console since
2007+ * it should always work */
2008+ if (current_term->startup() == 0)
2009+ current_term = term_table; /* we know that console is first */
2010 return 0;
2011 }
2012
2013@@ -852,6 +877,251 @@
2014 };
2015 #endif /* SUPPORT_NETBOOT */
2016
2017+#ifdef SUPPORT_GRAPHICS
2018+
2019
2020+static int splashimage_func(char *arg, int flags) {
2021+ int i;
2022+
2023+ /* filename can only be 256 characters due to our buffer size */
2024+ if (grub_strlen(arg) > 256) {
2025+ grub_printf("Splash image filename too large\n");
2026+ grub_printf("Press any key to continue...");
2027+ getkey();
2028+ return 1;
2029+ }
2030+
2031+ /* get rid of TERM_NEED_INIT from the graphics terminal. */
2032+ for (i = 0; term_table[i].name; i++) {
2033+ if (grub_strcmp (term_table[i].name, "graphics") == 0) {
2034+ term_table[i].flags &= ~TERM_NEED_INIT;
2035+ break;
2036+ }
2037+ }
2038+
2039+ graphics_set_splash(arg);
2040+
2041+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
2042+ graphics_end();
2043+ if (graphics_init() == 0) {
2044+ /* Fallback to default term */
2045+ current_term = term_table;
2046+ max_lines = current_term->max_lines;
2047+ if (current_term->cls)
2048+ current_term->cls();
2049+ grub_printf("Failed to set splash image and/or graphics mode\n");
2050+ return 1;
2051+ }
2052+ graphics_cls();
2053+ }
2054+
2055+ if (flags == BUILTIN_MENU)
2056+ current_term = term_table + i;
2057+
2058+ return 0;
2059+}
2060+
2061+static struct builtin builtin_splashimage =
2062+{
2063+ "splashimage",
2064+ splashimage_func,
2065+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2066+ "splashimage FILE",
2067+ "Load FILE as the background image when in graphics mode."
2068+};
2069+
2070+
2071
2072+/* shade */
2073+static int
2074+shade_func(char *arg, int flags)
2075+{
2076+ int new_shade;
2077+
2078+ if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
2079+ return (1);
2080+
2081+ if (shade != new_shade) {
2082+ shade = new_shade;
2083+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
2084+ graphics_end();
2085+ graphics_init();
2086+ graphics_cls();
2087+ }
2088+ }
2089+
2090+ return 0;
2091+}
2092+
2093+static struct builtin builtin_shade =
2094+{
2095+ "shade",
2096+ shade_func,
2097+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2098+ "shade INTEGER",
2099+ "If set to 0, disables the use of shaded text, else enables it."
2100+};
2101+
2102+
2103
2104+/* foreground */
2105+static int
2106+foreground_func(char *arg, int flags)
2107+{
2108+ if (grub_strlen(arg) == 6) {
2109+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2110+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2111+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2112+
2113+ foreground = (r << 16) | (g << 8) | b;
2114+ if (graphics_inited)
2115+ graphics_set_palette(15, r, g, b);
2116+
2117+ return 0;
2118+ }
2119+
2120+ return 1;
2121+}
2122+
2123+static struct builtin builtin_foreground =
2124+{
2125+ "foreground",
2126+ foreground_func,
2127+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2128+ "foreground RRGGBB",
2129+ "Sets the foreground color when in graphics mode."
2130+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2131+};
2132+
2133+
2134
2135+/* background */
2136+static int
2137+background_func(char *arg, int flags)
2138+{
2139+ if (grub_strlen(arg) == 6) {
2140+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2141+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2142+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2143+
2144+ background = (r << 16) | (g << 8) | b;
2145+ if (graphics_inited)
2146+ graphics_set_palette(0, r, g, b);
2147+ return 0;
2148+ }
2149+
2150+ return 1;
2151+}
2152+
2153+static struct builtin builtin_background =
2154+{
2155+ "background",
2156+ background_func,
2157+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2158+ "background RRGGBB",
2159+ "Sets the background color when in graphics mode."
2160+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2161+};
2162+
2163+
2164
2165+/* border */
2166+static int
2167+border_func(char *arg, int flags)
2168+{
2169+ if (grub_strlen(arg) == 6) {
2170+ int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
2171+ int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
2172+ int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
2173+
2174+ window_border = (r << 16) | (g << 8) | b;
2175+ if (graphics_inited)
2176+ graphics_set_palette(0x11, r, g, b);
2177+
2178+ return 0;
2179+ }
2180+
2181+ return 1;
2182+}
2183+
2184+static struct builtin builtin_border =
2185+{
2186+ "border",
2187+ border_func,
2188+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2189+ "border RRGGBB",
2190+ "Sets the border video color when in graphics mode."
2191+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
2192+};
2193+
2194+
2195
2196+/* viewport */
2197+static int
2198+viewport_func (char *arg, int flags)
2199+{
2200+ int i;
2201+ int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
2202+ int *pos[4] = { &x0, &y0, &x1, &y1 };
2203+
2204+ if (!arg)
2205+ return (1);
2206+ for (i = 0; i < 4; i++) {
2207+ if (!*arg)
2208+ return (1);
2209+ while (*arg && (*arg == ' ' || *arg == '\t'))
2210+ ++arg;
2211+ if (!safe_parse_maxint(&arg, pos[i]))
2212+ return (1);
2213+ while (*arg && (*arg != ' ' && *arg != '\t'))
2214+ ++arg;
2215+ }
2216+
2217+ /* minimum size is 65 colums and 16 rows */
2218+ if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
2219+ return 1;
2220+
2221+ view_x0 = x0;
2222+ view_y0 = y0;
2223+ view_x1 = x1;
2224+ view_y1 = y1;
2225+
2226+ if (flags == BUILTIN_CMDLINE && graphics_inited) {
2227+ graphics_end();
2228+ graphics_init();
2229+ graphics_cls();
2230+ }
2231+
2232+ return 0;
2233+}
2234+
2235+static struct builtin builtin_viewport =
2236+{
2237+ "viewport",
2238+ viewport_func,
2239+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
2240+ "viewport x0 y0 x1 y1",
2241+ "Changes grub internals to output text in the window defined by"
2242+ " four parameters. The x and y parameters are 0 based. This option"
2243+ " only works with the graphics interface."
2244+};
2245+
2246+#endif /* SUPPORT_GRAPHICS */
2247+
2248+
2249
2250+/* clear */
2251+static int
2252+clear_func()
2253+{
2254+ if (current_term->cls)
2255+ current_term->cls();
2256+
2257+ return 0;
2258+}
2259+
2260+static struct builtin builtin_clear =
2261+{
2262+ "clear",
2263+ clear_func,
2264+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
2265+ "clear",
2266+ "Clear the screen"
2267+};
2268+
2269
2270
2271 /* displayapm */
2272 static int
2273@@ -1454,14 +1724,20 @@
2274
2275
2276
2277 /* help */
2278-#define MAX_SHORT_DOC_LEN 39
2279-#define MAX_LONG_DOC_LEN 66
2280-
2281 static int
2282 help_func (char *arg, int flags)
2283 {
2284- int all = 0;
2285-
2286+ int all = 0, max_short_doc_len, max_long_doc_len;
2287+ max_short_doc_len = 39;
2288+ max_long_doc_len = 66;
2289+#ifdef SUPPORT_GRAPHICS
2290+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
2291+ {
2292+ max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
2293+ max_long_doc_len = (view_x1 - view_x0) - 14;
2294+ }
2295+#endif
2296+
2297 if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
2298 {
2299 all = 1;
2300@@ -1491,13 +1767,13 @@
2301
2302 len = grub_strlen ((*builtin)->short_doc);
2303 /* If the length of SHORT_DOC is too long, truncate it. */
2304- if (len > MAX_SHORT_DOC_LEN - 1)
2305- len = MAX_SHORT_DOC_LEN - 1;
2306+ if (len > max_short_doc_len - 1)
2307+ len = max_short_doc_len - 1;
2308
2309 for (i = 0; i < len; i++)
2310 grub_putchar ((*builtin)->short_doc[i]);
2311
2312- for (; i < MAX_SHORT_DOC_LEN; i++)
2313+ for (; i < max_short_doc_len; i++)
2314 grub_putchar (' ');
2315
2316 if (! left)
2317@@ -1546,10 +1822,10 @@
2318 int i;
2319
2320 /* If LEN is too long, fold DOC. */
2321- if (len > MAX_LONG_DOC_LEN)
2322+ if (len > max_long_doc_len)
2323 {
2324 /* Fold this line at the position of a space. */
2325- for (len = MAX_LONG_DOC_LEN; len > 0; len--)
2326+ for (len = max_long_doc_len; len > 0; len--)
2327 if (doc[len - 1] == ' ')
2328 break;
2329 }
2330@@ -2323,6 +2599,25 @@
2331 "Probe I/O ports used for the drive DRIVE."
2332 };
2333
2334+/* print */
2335+static int
2336+print_func (char *arg, int flags)
2337+{
2338+ printf("%s\n", arg);
2339+
2340+ return 0;
2341+}
2342+
2343+static struct builtin builtin_print =
2344+{
2345+ "print",
2346+ print_func,
2347+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO,
2348+ "print [MESSAGE ...]",
2349+ "Print MESSAGE."
2350+};
2351+
2352+
2353
2354
2355 /* kernel */
2356 static int
2357@@ -3221,7 +3516,102 @@
2358 static int
2359 savedefault_func (char *arg, int flags)
2360 {
2361-#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
2362+#if !defined(SUPPORT_DISKLESS)
2363+ #if !defined(GRUB_UTIL)
2364+ savedefault_helper(arg, flags);
2365+ #else
2366+ savedefault_shell(arg, flags);
2367+ #endif
2368+#else /* !SUPPORT_DISKLESS */
2369+ errnum = ERR_UNRECOGNIZED;
2370+ return 1;
2371+#endif /* !SUPPORT_DISKLESS */
2372+}
2373+
2374+#if !defined(SUPPORT_DISKLESS) && defined(GRUB_UTIL)
2375+/* savedefault_shell */
2376+static int
2377+savedefault_shell(char *arg, int flags)
2378+ {
2379+ int once_only = 0;
2380+ int new_default;
2381+ int curr_default = -1;
2382+ int curr_prev_default = -1;
2383+ int new_prev_default = -1;
2384+ FILE *fp;
2385+ size_t bytes = 10;
2386+ char line[bytes];
2387+ char *default_file = (char *) DEFAULT_FILE_BUF;
2388+ char buf[bytes];
2389+ int i;
2390+
2391+ while (1)
2392+ {
2393+ if (grub_memcmp ("--default=", arg, sizeof ("--default=") - 1) == 0)
2394+ {
2395+ char *p = arg + sizeof ("--default=") - 1;
2396+ if (! safe_parse_maxint (&p, &new_default))
2397+ return 1;
2398+ arg = skip_to (0, arg);
2399+ }
2400+ else if (grub_memcmp ("--once", arg, sizeof ("--once") - 1) == 0)
2401+ {
2402+ once_only = 1;
2403+ arg = skip_to (0, arg);
2404+ }
2405+ else
2406+ break;
2407+ }
2408+
2409+ *default_file = 0;
2410+ grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN);
2411+ for (i = grub_strlen(default_file); i >= 0; i--)
2412+ if (default_file[i] == '/')
2413+ {
2414+ i++;
2415+ break;
2416+ }
2417+ default_file[i] = 0;
2418+ grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i);
2419+
2420+ if(!(fp = fopen(default_file,"w")))
2421+ {
2422+ errnum = ERR_READ;
2423+ goto fail;
2424+ }
2425+
2426+ read(&line, -1);
2427+
2428+ sscanf(line, "%d:%d", &curr_prev_default, &curr_default);
2429+
2430+ if(curr_default != -1)
2431+ new_prev_default = curr_default;
2432+ else
2433+ {
2434+ if(curr_prev_default != -1)
2435+ new_prev_default = curr_prev_default;
2436+ else
2437+ new_prev_default = 0;
2438+ }
2439+
2440+ if(once_only)
2441+ sprintf(buf, "%d:%d\n", new_prev_default, new_default);
2442+ else
2443+ sprintf(buf, "%d\n", new_default);
2444+
2445+ fprintf(fp, buf);
2446+
2447+fail:
2448+ fclose(fp);
2449+ return errnum;
2450+}
2451+#endif
2452+
2453+/* savedefault_helper */
2454+static int
2455+savedefault_helper (char *arg, int flags)
2456+{
2457+#if !defined(SUPPORT_DISKLESS)
2458 unsigned long tmp_drive = saved_drive;
2459 unsigned long tmp_partition = saved_partition;
2460 char *default_file = (char *) DEFAULT_FILE_BUF;
2461@@ -3300,19 +3690,23 @@
2462 disk_read_hook = 0;
2463 grub_close ();
2464
2465- if (len != sizeof (buf))
2466- {
2467- /* This is too small. Do not modify the file manually, please! */
2468- errnum = ERR_READ;
2469- goto fail;
2470- }
2471-
2472 if (sector_count > 2)
2473 {
2474 /* Is this possible?! Too fragmented! */
2475 errnum = ERR_FSYS_CORRUPT;
2476 goto fail;
2477 }
2478+
2479+ char *tmp;
2480+ if((tmp = grub_strstr(buf, ":")) != NULL)
2481+ {
2482+ int f_len = grub_strlen(buf) - grub_strlen(tmp);
2483+ char *def;
2484+ int a;
2485+ for(a = 0; a < f_len; a++)
2486+ grub_memcpy(&def[a], &buf[a], sizeof(char));
2487+ safe_parse_maxint (&def, &entryno);
2488+ }
2489
2490 /* Set up a string to be written. */
2491 grub_memset (buf, '\n', sizeof (buf));
2492@@ -3830,15 +4224,15 @@
2493 {
2494 char tmp[16];
2495 grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF);
2496- grub_strncat (device, tmp, 256);
2497+ grub_strncat (device, tmp, sizeof (device));
2498 }
2499 if ((partition & 0x00FF00) != 0x00FF00)
2500 {
2501 char tmp[16];
2502 grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF));
2503- grub_strncat (device, tmp, 256);
2504+ grub_strncat (device, tmp, sizeof (device));
2505 }
2506- grub_strncat (device, ")", 256);
2507+ grub_strncat (device, ")", sizeof (device));
2508 }
2509
2510 int embed_stage1_5 (char *stage1_5, int drive, int partition)
2511@@ -4085,7 +4479,7 @@
2512 };
2513
2514
2515
2516-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
2517+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
2518 /* terminal */
2519 static int
2520 terminal_func (char *arg, int flags)
2521@@ -4244,17 +4638,29 @@
2522 end:
2523 current_term = term_table + default_term;
2524 current_term->flags = term_flags;
2525-
2526+
2527 if (lines)
2528 max_lines = lines;
2529 else
2530- /* 24 would be a good default value. */
2531- max_lines = 24;
2532-
2533+ max_lines = current_term->max_lines;
2534+
2535 /* If the interface is currently the command-line,
2536 restart it to repaint the screen. */
2537- if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
2538+ if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
2539+ if (prev_term->shutdown)
2540+ prev_term->shutdown();
2541+ if (current_term->startup) {
2542+ /* If startup fails, return to previous term */
2543+ if (current_term->startup() == 0) {
2544+ current_term = prev_term;
2545+ max_lines = current_term->max_lines;
2546+ if (current_term->cls) {
2547+ current_term->cls();
2548+ }
2549+ }
2550+ }
2551 grub_longjmp (restart_cmdline_env, 0);
2552+ }
2553
2554 return 0;
2555 }
2556@@ -4264,7 +4670,7 @@
2557 "terminal",
2558 terminal_func,
2559 BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
2560- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
2561+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
2562 "Select a terminal. When multiple terminals are specified, wait until"
2563 " you push any key to continue. If both console and serial are specified,"
2564 " the terminal to which you input a key first will be selected. If no"
2565@@ -4276,7 +4682,7 @@
2566 " seconds. The option --lines specifies the maximum number of lines."
2567 " The option --silent is used to suppress messages."
2568 };
2569-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
2570+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
2571
2572
2573
2574 #ifdef SUPPORT_SERIAL
2575@@ -4795,13 +5201,20 @@
2576 /* The table of builtin commands. Sorted in dictionary order. */
2577 struct builtin *builtin_table[] =
2578 {
2579+#ifdef SUPPORT_GRAPHICS
2580+ &builtin_background,
2581+#endif
2582 &builtin_blocklist,
2583 &builtin_boot,
2584 #ifdef SUPPORT_NETBOOT
2585 &builtin_bootp,
2586 #endif /* SUPPORT_NETBOOT */
2587+#ifdef SUPPORT_GRAPHICS
2588+ &builtin_border,
2589+#endif
2590 &builtin_cat,
2591 &builtin_chainloader,
2592+ &builtin_clear,
2593 &builtin_cmp,
2594 &builtin_color,
2595 &builtin_configfile,
2596@@ -4821,6 +5234,9 @@
2597 &builtin_embed,
2598 &builtin_fallback,
2599 &builtin_find,
2600+#ifdef SUPPORT_GRAPHICS
2601+ &builtin_foreground,
2602+#endif
2603 &builtin_fstest,
2604 &builtin_geometry,
2605 &builtin_halt,
2606@@ -4848,6 +5264,7 @@
2607 &builtin_parttype,
2608 &builtin_password,
2609 &builtin_pause,
2610+ &builtin_print,
2611 #ifdef GRUB_UTIL
2612 &builtin_quit,
2613 #endif /* GRUB_UTIL */
2614@@ -4864,9 +5281,13 @@
2615 #endif /* SUPPORT_SERIAL */
2616 &builtin_setkey,
2617 &builtin_setup,
2618-#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
2619+#ifdef SUPPORT_GRAPHICS
2620+ &builtin_shade,
2621+ &builtin_splashimage,
2622+#endif /* SUPPORT_GRAPHICS */
2623+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
2624 &builtin_terminal,
2625-#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
2626+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
2627 #ifdef SUPPORT_SERIAL
2628 &builtin_terminfo,
2629 #endif /* SUPPORT_SERIAL */
2630@@ -4880,5 +5301,8 @@
2631 &builtin_unhide,
2632 &builtin_uppermem,
2633 &builtin_vbeprobe,
2634+#ifdef SUPPORT_GRAPHICS
2635+ &builtin_viewport,
2636+#endif
2637 0
2638 };
2639diff -Naur grub-0.97.orig/stage2/char_io.c grub-0.97/stage2/char_io.c
2640--- grub-0.97.orig/stage2/char_io.c 2005-02-01 12:51:23.000000000 -0800
2641+++ grub-0.97/stage2/char_io.c 2006-07-03 23:59:27.000000000 -0700
2642@@ -29,12 +29,17 @@
2643 # include <serial.h>
2644 #endif
2645
2646+#ifdef SUPPORT_GRAPHICS
2647+# include <graphics.h>
2648+#endif
2649+
2650 #ifndef STAGE1_5
2651 struct term_entry term_table[] =
2652 {
2653 {
2654 "console",
2655 0,
2656+ 24,
2657 console_putchar,
2658 console_checkkey,
2659 console_getkey,
2660@@ -43,13 +48,16 @@
2661 console_cls,
2662 console_setcolorstate,
2663 console_setcolor,
2664- console_setcursor
2665+ console_setcursor,
2666+ 0,
2667+ 0
2668 },
2669 #ifdef SUPPORT_SERIAL
2670 {
2671 "serial",
2672 /* A serial device must be initialized. */
2673 TERM_NEED_INIT,
2674+ 24,
2675 serial_putchar,
2676 serial_checkkey,
2677 serial_getkey,
2678@@ -58,6 +66,8 @@
2679 serial_cls,
2680 serial_setcolorstate,
2681 0,
2682+ 0,
2683+ 0,
2684 0
2685 },
2686 #endif /* SUPPORT_SERIAL */
2687@@ -65,6 +75,7 @@
2688 {
2689 "hercules",
2690 0,
2691+ 24,
2692 hercules_putchar,
2693 console_checkkey,
2694 console_getkey,
2695@@ -73,11 +84,30 @@
2696 hercules_cls,
2697 hercules_setcolorstate,
2698 hercules_setcolor,
2699- hercules_setcursor
2700+ hercules_setcursor,
2701+ 0,
2702+ 0
2703 },
2704 #endif /* SUPPORT_HERCULES */
2705+#ifdef SUPPORT_GRAPHICS
2706+ { "graphics",
2707+ TERM_NEED_INIT, /* flags */
2708+ 30, /* number of lines */
2709+ graphics_putchar, /* putchar */
2710+ console_checkkey, /* checkkey */
2711+ console_getkey, /* getkey */
2712+ graphics_getxy, /* getxy */
2713+ graphics_gotoxy, /* gotoxy */
2714+ graphics_cls, /* cls */
2715+ graphics_setcolorstate, /* setcolorstate */
2716+ graphics_setcolor, /* setcolor */
2717+ graphics_setcursor, /* nocursor */
2718+ graphics_init, /* initialize */
2719+ graphics_end /* shutdown */
2720+ },
2721+#endif /* SUPPORT_GRAPHICS */
2722 /* This must be the last entry. */
2723- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
2724+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
2725 };
2726
2727 /* This must be console. */
2728@@ -305,9 +335,10 @@
2729
2730 /* XXX: These should be defined in shared.h, but I leave these here,
2731 until this code is freezed. */
2732-#define CMDLINE_WIDTH 78
2733 #define CMDLINE_MARGIN 10
2734-
2735+
2736+ /* command-line limits */
2737+ int cmdline_width = 78, col_start = 0;
2738 int xpos, lpos, c, section;
2739 /* The length of PROMPT. */
2740 int plen;
2741@@ -338,7 +369,7 @@
2742
2743 /* If the cursor is in the first section, display the first section
2744 instead of the second. */
2745- if (section == 1 && plen + lpos < CMDLINE_WIDTH)
2746+ if (section == 1 && plen + lpos < cmdline_width)
2747 cl_refresh (1, 0);
2748 else if (xpos - count < 1)
2749 cl_refresh (1, 0);
2750@@ -354,7 +385,7 @@
2751 grub_putchar ('\b');
2752 }
2753 else
2754- gotoxy (xpos, getxy () & 0xFF);
2755+ gotoxy (xpos + col_start, getxy () & 0xFF);
2756 }
2757 }
2758
2759@@ -364,7 +395,7 @@
2760 lpos += count;
2761
2762 /* If the cursor goes outside, scroll the screen to the right. */
2763- if (xpos + count >= CMDLINE_WIDTH)
2764+ if (xpos + count >= cmdline_width)
2765 cl_refresh (1, 0);
2766 else
2767 {
2768@@ -383,7 +414,7 @@
2769 }
2770 }
2771 else
2772- gotoxy (xpos, getxy () & 0xFF);
2773+ gotoxy (xpos + col_start, getxy () & 0xFF);
2774 }
2775 }
2776
2777@@ -398,14 +429,14 @@
2778 if (full)
2779 {
2780 /* Recompute the section number. */
2781- if (lpos + plen < CMDLINE_WIDTH)
2782+ if (lpos + plen < cmdline_width)
2783 section = 0;
2784 else
2785- section = ((lpos + plen - CMDLINE_WIDTH)
2786- / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
2787+ section = ((lpos + plen - cmdline_width)
2788+ / (cmdline_width - 1 - CMDLINE_MARGIN) + 1);
2789
2790 /* From the start to the end. */
2791- len = CMDLINE_WIDTH;
2792+ len = cmdline_width;
2793 pos = 0;
2794 grub_putchar ('\r');
2795
2796@@ -445,8 +476,8 @@
2797 if (! full)
2798 offset = xpos - 1;
2799
2800- start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
2801- + CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
2802+ start = ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN)
2803+ + cmdline_width - plen - CMDLINE_MARGIN);
2804 xpos = lpos + 1 - start;
2805 start += offset;
2806 }
2807@@ -471,7 +502,7 @@
2808
2809 /* If the cursor is at the last position, put `>' or a space,
2810 depending on if there are more characters in BUF. */
2811- if (pos == CMDLINE_WIDTH)
2812+ if (pos == cmdline_width)
2813 {
2814 if (start + len < llen)
2815 grub_putchar ('>');
2816@@ -488,7 +519,7 @@
2817 grub_putchar ('\b');
2818 }
2819 else
2820- gotoxy (xpos, getxy () & 0xFF);
2821+ gotoxy (xpos + col_start, getxy () & 0xFF);
2822 }
2823
2824 /* Initialize the command-line. */
2825@@ -518,10 +549,10 @@
2826
2827 llen += l;
2828 lpos += l;
2829- if (xpos + l >= CMDLINE_WIDTH)
2830+ if (xpos + l >= cmdline_width)
2831 cl_refresh (1, 0);
2832- else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
2833- cl_refresh (0, CMDLINE_WIDTH - xpos);
2834+ else if (xpos + l + llen - lpos > cmdline_width)
2835+ cl_refresh (0, cmdline_width - xpos);
2836 else
2837 cl_refresh (0, l + llen - lpos);
2838 }
2839@@ -533,12 +564,22 @@
2840 grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
2841 llen -= count;
2842
2843- if (xpos + llen + count - lpos > CMDLINE_WIDTH)
2844- cl_refresh (0, CMDLINE_WIDTH - xpos);
2845+ if (xpos + llen + count - lpos > cmdline_width)
2846+ cl_refresh (0, cmdline_width - xpos);
2847 else
2848 cl_refresh (0, llen + count - lpos);
2849 }
2850
2851+ max_lines = current_term->max_lines;
2852+#ifdef SUPPORT_GRAPHICS
2853+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
2854+ {
2855+ cmdline_width = (view_x1 - view_x0) - 2;
2856+ col_start = view_x0;
2857+ max_lines = view_y1 - view_y0;
2858+ }
2859+#endif
2860+
2861 plen = grub_strlen (prompt);
2862 llen = grub_strlen (cmdline);
2863
2864@@ -1006,6 +1047,48 @@
2865 }
2866 #endif /* ! STAGE1_5 */
2867
2868+#ifndef STAGE1_5
2869+/* Internal pager. */
2870+int
2871+do_more (void)
2872+{
2873+ if (count_lines >= 0)
2874+ {
2875+ count_lines++;
2876+ if (count_lines >= max_lines - 2)
2877+ {
2878+ int tmp;
2879+
2880+ /* It's important to disable the feature temporarily, because
2881+ the following grub_printf call will print newlines. */
2882+ count_lines = -1;
2883+
2884+ grub_printf("\n");
2885+ if (current_term->setcolorstate)
2886+ current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
2887+
2888+ grub_printf ("[Hit return to continue]");
2889+
2890+ if (current_term->setcolorstate)
2891+ current_term->setcolorstate (COLOR_STATE_NORMAL);
2892+
2893+
2894+ do
2895+ {
2896+ tmp = ASCII_CHAR (getkey ());
2897+ }
2898+ while (tmp != '\n' && tmp != '\r');
2899+ grub_printf ("\r \r");
2900+
2901+ /* Restart to count lines. */
2902+ count_lines = 0;
2903+ return 1;
2904+ }
2905+ }
2906+ return 0;
2907+}
2908+#endif
2909+
2910 /* Display an ASCII character. */
2911 void
2912 grub_putchar (int c)
2913@@ -1034,38 +1117,11 @@
2914
2915 if (c == '\n')
2916 {
2917+ int flag;
2918 /* Internal `more'-like feature. */
2919- if (count_lines >= 0)
2920- {
2921- count_lines++;
2922- if (count_lines >= max_lines - 2)
2923- {
2924- int tmp;
2925-
2926- /* It's important to disable the feature temporarily, because
2927- the following grub_printf call will print newlines. */
2928- count_lines = -1;
2929-
2930- if (current_term->setcolorstate)
2931- current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
2932-
2933- grub_printf ("\n[Hit return to continue]");
2934-
2935- if (current_term->setcolorstate)
2936- current_term->setcolorstate (COLOR_STATE_NORMAL);
2937-
2938- do
2939- {
2940- tmp = ASCII_CHAR (getkey ());
2941- }
2942- while (tmp != '\n' && tmp != '\r');
2943- grub_printf ("\r \r");
2944-
2945- /* Restart to count lines. */
2946- count_lines = 0;
2947- return;
2948- }
2949- }
2950+ flag = do_more ();
2951+ if (flag)
2952+ return;
2953 }
2954
2955 current_term->putchar (c);
2956@@ -1090,7 +1146,7 @@
2957 cls (void)
2958 {
2959 /* If the terminal is dumb, there is no way to clean the terminal. */
2960- if (current_term->flags & TERM_DUMB)
2961+ if (current_term->flags & TERM_DUMB)
2962 grub_putchar ('\n');
2963 else
2964 current_term->cls ();
2965@@ -1175,13 +1231,13 @@
2966 #endif /* ! STAGE1_5 */
2967
2968 int
2969-memcheck (int addr, int len)
2970+memcheck (unsigned long int addr, unsigned long int len)
2971 {
2972 #ifdef GRUB_UTIL
2973- auto int start_addr (void);
2974- auto int end_addr (void);
2975+ auto unsigned long int start_addr (void);
2976+ auto int unsigned long end_addr (void);
2977
2978- auto int start_addr (void)
2979+ auto unsigned long int start_addr (void)
2980 {
2981 int ret;
2982 # if defined(HAVE_START_SYMBOL)
2983@@ -1192,7 +1248,7 @@
2984 return ret;
2985 }
2986
2987- auto int end_addr (void)
2988+ auto unsigned long int end_addr (void)
2989 {
2990 int ret;
2991 # if defined(HAVE_END_SYMBOL)
2992@@ -1217,6 +1273,16 @@
2993 return ! errnum;
2994 }
2995
2996+void
2997+grub_memcpy(void *dest, const void *src, int len)
2998+{
2999+ int i;
3000+ register char *d = (char*)dest, *s = (char*)src;
3001+
3002+ for (i = 0; i < len; i++)
3003+ d[i] = s[i];
3004+}
3005+
3006 void *
3007 grub_memmove (void *to, const void *from, int len)
3008 {
3009diff -Naur grub-0.97.orig/stage2/cmdline.c grub-0.97/stage2/cmdline.c
3010--- grub-0.97.orig/stage2/cmdline.c 2004-08-16 16:23:01.000000000 -0700
3011+++ grub-0.97/stage2/cmdline.c 2006-07-03 23:58:41.000000000 -0700
3012@@ -50,10 +50,11 @@
3013 void
3014 print_cmdline_message (int forever)
3015 {
3016- printf (" [ Minimal BASH-like line editing is supported. For the first word, TAB\n"
3017- " lists possible command completions. Anywhere else TAB lists the possible\n"
3018- " completions of a device/filename.%s ]\n",
3019- (forever ? "" : " ESC at any time exits."));
3020+ grub_printf(" [ Minimal BASH-like line editing is supported. For\n"
3021+ " the first word, TAB lists possible command\n"
3022+ " completions. Anywhere else TAB lists the possible\n"
3023+ " completions of a device/filename.%s ]\n",
3024+ (forever ? "" : " ESC at any time\n exits."));
3025 }
3026
3027 /* Find the builtin whose command name is COMMAND and return the
3028diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
3029--- grub-0.97.orig/stage2/freebsd.h 2003-07-09 04:45:52.000000000 -0700
3030+++ grub-0.97/stage2/freebsd.h 2006-07-03 23:59:36.000000000 -0700
3031@@ -1,7 +1,7 @@
3032
3033 /*
3034 * GRUB -- GRand Unified Bootloader
3035- * Copyright (C) 2001 Free Software Foundation, Inc.
3036+ * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
3037 *
3038 * This program is free software; you can redistribute it and/or modify
3039 * it under the terms of the GNU General Public License as published by
3040@@ -35,6 +35,10 @@
3041 #define RB_CDROM 0x2000 /* use cdrom as root */
3042 #define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */
3043 #define RB_MUTE 0x10000 /* Come up with the console muted */
3044+#define RB_SELFTEST 0x20000 /* don't complete the boot; do selftest */
3045+#define RB_RESERVED1 0x40000 /* reserved for internal use of boot blocks */
3046+#define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */
3047+#define RB_PAUSE 0x100000 /* pause after each output line during probe */
3048 #define RB_MULTIPLE 0x20000000 /* Use multiple consoles */
3049
3050 #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
3051@@ -70,6 +74,9 @@
3052
3053 #define N_BIOS_GEOM 8
3054
3055+typedef unsigned char u8_t;
3056+typedef unsigned int u32_t;
3057+
3058 /*
3059 * A zero bootinfo field often means that there is no info available.
3060 * Flags are used to indicate the validity of fields where zero is a
3061@@ -77,19 +84,33 @@
3062 */
3063 struct bootinfo
3064 {
3065- unsigned int bi_version;
3066- unsigned char *bi_kernelname;
3067- struct nfs_diskless *bi_nfs_diskless;
3068+ u32_t bi_version;
3069+ u8_t *bi_kernelname;
3070+ u32_t bi_nfs_diskless;
3071 /* End of fields that are always present. */
3072 #define bi_endcommon bi_n_bios_used
3073- unsigned int bi_n_bios_used;
3074- unsigned long bi_bios_geom[N_BIOS_GEOM];
3075- unsigned int bi_size;
3076- unsigned char bi_memsizes_valid;
3077- unsigned char bi_bios_dev;
3078- unsigned char bi_pad[2];
3079- unsigned long bi_basemem;
3080- unsigned long bi_extmem;
3081- unsigned long bi_symtab;
3082- unsigned long bi_esymtab;
3083+ u32_t bi_n_bios_used;
3084+ u32_t bi_bios_geom[N_BIOS_GEOM];
3085+ u32_t bi_size;
3086+ u8_t bi_memsizes_valid;
3087+ u8_t bi_bios_dev;
3088+ u8_t bi_pad[2];
3089+ u32_t bi_basemem;
3090+ u32_t bi_extmem;
3091+ u32_t bi_symtab;
3092+ u32_t bi_esymtab;
3093+ /* Items below only from advanced bootloader */
3094+ u32_t bi_kernend;
3095+ u32_t bi_envp;
3096+ u32_t bi_modulep;
3097 };
3098+
3099+#define MODINFO_END 0x0000 /* End of list */
3100+#define MODINFO_NAME 0x0001 /* Name of module (string) */
3101+#define MODINFO_TYPE 0x0002 /* Type of module (string) */
3102+#define MODINFO_ADDR 0x0003 /* Loaded address */
3103+#define MODINFO_SIZE 0x0004 /* Size of module */
3104+#define MODINFO_EMPTY 0x0005 /* Has been deleted */
3105+#define MODINFO_ARGS 0x0006 /* Parameters string */
3106+#define MODINFO_METADATA 0x8000 /* Module-specfic */
3107+
3108diff -Naur grub-0.97.orig/stage2/graphics.c grub-0.97/stage2/graphics.c
3109--- grub-0.97.orig/stage2/graphics.c 1969-12-31 16:00:00.000000000 -0800
3110+++ grub-0.97/stage2/graphics.c 2006-07-03 23:58:41.000000000 -0700
3111@@ -0,0 +1,585 @@
3112+/*
3113+ * graphics.c - graphics mode support for GRUB
3114+ * Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
3115+ * on a patch by Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
3116+ * Options and enhancements made by Herton Ronaldo Krzesinski
3117+ * <herton@mandriva.com>
3118+ *
3119+ * GRUB -- GRand Unified Bootloader
3120+ * Copyright (C) 2001,2002 Red Hat, Inc.
3121+ * Portions copyright (C) 2000 Conectiva, Inc.
3122+ *
3123+ * This program is free software; you can redistribute it and/or modify
3124+ * it under the terms of the GNU General Public License as published by
3125+ * the Free Software Foundation; either version 2 of the License, or
3126+ * (at your option) any later version.
3127+ *
3128+ * This program is distributed in the hope that it will be useful,
3129+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3130+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3131+ * GNU General Public License for more details.
3132+ *
3133+ * You should have received a copy of the GNU General Public License
3134+ * along with this program; if not, write to the Free Software
3135+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3136+ */
3137+
3138+#ifdef SUPPORT_GRAPHICS
3139+
3140+#include <term.h>
3141+#include <shared.h>
3142+#include <graphics.h>
3143+
3144+int saved_videomode;
3145+unsigned char *font8x16;
3146+
3147+int graphics_inited = 0;
3148+static char splashimage[256];
3149+
3150+int shade = 1, no_cursor = 0;
3151+
3152+#define VSHADOW VSHADOW1
3153+unsigned char VSHADOW1[38400];
3154+unsigned char VSHADOW2[38400];
3155+unsigned char VSHADOW4[38400];
3156+unsigned char VSHADOW8[38400];
3157+
3158+/* define the default viewable area */
3159+int view_x0 = 0;
3160+int view_y0 = 0;
3161+int view_x1 = 80;
3162+int view_y1 = 30;
3163+
3164+/* text buffer has to be kept around so that we can write things as we
3165+ * scroll and the like */
3166+unsigned short text[80 * 30];
3167+
3168+/* graphics options */
3169+int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
3170+
3171+/* current position */
3172+static int fontx = 0;
3173+static int fonty = 0;
3174+
3175+/* global state so that we don't try to recursively scroll or cursor */
3176+static int no_scroll = 0;
3177+
3178+/* color state */
3179+static int graphics_standard_color = A_NORMAL;
3180+static int graphics_normal_color = A_NORMAL;
3181+static int graphics_highlight_color = A_REVERSE;
3182+static int graphics_current_color = A_NORMAL;
3183+static color_state graphics_color_state = COLOR_STATE_STANDARD;
3184+
3185+static inline void outb(unsigned short port, unsigned char val)
3186+{
3187+ __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
3188+}
3189+
3190+static void MapMask(int value) {
3191+ outb(0x3c4, 2);
3192+ outb(0x3c5, value);
3193+}
3194+
3195+/* bit mask register */
3196+static void BitMask(int value) {
3197+ outb(0x3ce, 8);
3198+ outb(0x3cf, value);
3199+}
3200+
3201+/* move the graphics cursor location to col, row */
3202+static void graphics_setxy(int col, int row) {
3203+ if (col >= view_x0 && col < view_x1) {
3204+ fontx = col;
3205+ cursorX = col << 3;
3206+ }
3207+ if (row >= view_y0 && row < view_y1) {
3208+ fonty = row;
3209+ cursorY = row << 4;
3210+ }
3211+}
3212+
3213+/* scroll the screen */
3214+static void graphics_scroll() {
3215+ int i, j, k;
3216+
3217+ /* we don't want to scroll recursively... that would be bad */
3218+ if (no_scroll)
3219+ return;
3220+ no_scroll = 1;
3221+
3222+ /* disable pager temporarily */
3223+ k = count_lines;
3224+ count_lines = -1;
3225+
3226+ /* move everything up a line */
3227+ for (j = view_y0 + 1; j < view_y1; j++) {
3228+ graphics_gotoxy(view_x0, j - 1);
3229+ for (i = view_x0; i < view_x1; i++) {
3230+ graphics_putchar(text[j * 80 + i]);
3231+ }
3232+ }
3233+
3234+ /* last line should be blank */
3235+ graphics_gotoxy(view_x0, view_y1 - 1);
3236+ for (i = view_x0; i < view_x1; i++)
3237+ graphics_putchar(' ');
3238+ graphics_setxy(view_x0, view_y1 - 1);
3239+
3240+ count_lines = k;
3241+
3242+ no_scroll = 0;
3243+}
3244+
3245+/* Set the splash image */
3246+void graphics_set_splash(char *splashfile) {
3247+ grub_strcpy(splashimage, splashfile);
3248+}
3249+
3250+/* Get the current splash image */
3251+char *graphics_get_splash(void) {
3252+ return splashimage;
3253+}
3254+
3255+/*
3256+ * Initialize a vga16 graphics display with the palette based off of
3257+ * the image in splashimage. If the image doesn't exist, leave graphics
3258+ * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List":
3259+ * text/ text pixel pixel colors disply scrn system
3260+ * grph resol box resolution pages addr
3261+ * 12h G 80x30 8x16 640x480 16/256K . A000 VGA,ATI VIP
3262+ * G 80x30 8x16 640x480 16/64 . A000 ATI EGA Wonder
3263+ * G . . 640x480 16 . . UltraVision+256K EGA
3264+ */
3265+int graphics_init()
3266+{
3267+ if (!graphics_inited) {
3268+ saved_videomode = set_videomode(0x12);
3269+ if (get_videomode() != 0x12) {
3270+ set_videomode(saved_videomode);
3271+ return 0;
3272+ }
3273+ graphics_inited = 1;
3274+ }
3275+ else
3276+ return 1;
3277+
3278+ font8x16 = (unsigned char*)graphics_get_font();
3279+
3280+ /* make sure that the highlight color is set correctly */
3281+ graphics_highlight_color = ((graphics_normal_color >> 4) |
3282+ ((graphics_normal_color & 0xf) << 4));
3283+
3284+ graphics_cls();
3285+
3286+ if (!read_image(splashimage)) {
3287+ grub_printf("Failed to read splash image (%s)\n", splashimage);
3288+ grub_printf("Press any key to continue...");
3289+ getkey();
3290+ set_videomode(saved_videomode);
3291+ graphics_inited = 0;
3292+ return 0;
3293+ }
3294+
3295+ set_int1c_handler();
3296+
3297+ return 1;
3298+}
3299+
3300+/* Leave graphics mode */
3301+void graphics_end(void)
3302+{
3303+ if (graphics_inited) {
3304+ unset_int1c_handler();
3305+ set_videomode(saved_videomode);
3306+ graphics_inited = 0;
3307+ no_cursor = 0;
3308+ }
3309+}
3310+
3311+/* Print ch on the screen. Handle any needed scrolling or the like */
3312+void graphics_putchar(int ch) {
3313+ ch &= 0xff;
3314+
3315+ graphics_cursor(0);
3316+
3317+ if (ch == '\n') {
3318+ if (fonty + 1 < view_y1)
3319+ graphics_setxy(fontx, fonty + 1);
3320+ else
3321+ graphics_scroll();
3322+ graphics_cursor(1);
3323+ return;
3324+ } else if (ch == '\r') {
3325+ graphics_setxy(view_x0, fonty);
3326+ graphics_cursor(1);
3327+ return;
3328+ }
3329+
3330+ graphics_cursor(0);
3331+
3332+ text[fonty * 80 + fontx] = ch;
3333+ text[fonty * 80 + fontx] &= 0x00ff;
3334+ if (graphics_current_color & 0xf0)
3335+ text[fonty * 80 + fontx] |= 0x100;
3336+
3337+ graphics_cursor(0);
3338+
3339+ if ((fontx + 1) >= view_x1) {
3340+ graphics_setxy(view_x0, fonty);
3341+ if (fonty + 1 < view_y1)
3342+ graphics_setxy(view_x0, fonty + 1);
3343+ else
3344+ graphics_scroll();
3345+ graphics_cursor(1);
3346+ do_more ();
3347+ graphics_cursor(0);
3348+ } else {
3349+ graphics_setxy(fontx + 1, fonty);
3350+ }
3351+
3352+ graphics_cursor(1);
3353+}
3354+
3355+/* get the current location of the cursor */
3356+int graphics_getxy(void) {
3357+ return (fontx << 8) | fonty;
3358+}
3359+
3360+void graphics_gotoxy(int x, int y) {
3361+ graphics_cursor(0);
3362+
3363+ graphics_setxy(x, y);
3364+
3365+ graphics_cursor(1);
3366+}
3367+
3368+void graphics_cls(void) {
3369+ int i;
3370+ unsigned char *mem, *s1, *s2, *s4, *s8;
3371+
3372+ graphics_cursor(0);
3373+ graphics_gotoxy(view_x0, view_y0);
3374+
3375+ mem = (unsigned char*)VIDEOMEM;
3376+ s1 = (unsigned char*)VSHADOW1;
3377+ s2 = (unsigned char*)VSHADOW2;
3378+ s4 = (unsigned char*)VSHADOW4;
3379+ s8 = (unsigned char*)VSHADOW8;
3380+
3381+ for (i = 0; i < 80 * 30; i++)
3382+ text[i] = ' ';
3383+ graphics_cursor(1);
3384+
3385+ BitMask(0xff);
3386+
3387+ /* plane 1 */
3388+ MapMask(1);
3389+ grub_memcpy(mem, s1, 38400);
3390+
3391+ /* plane 2 */
3392+ MapMask(2);
3393+ grub_memcpy(mem, s2, 38400);
3394+
3395+ /* plane 3 */
3396+ MapMask(4);
3397+ grub_memcpy(mem, s4, 38400);
3398+
3399+ /* plane 4 */
3400+ MapMask(8);
3401+ grub_memcpy(mem, s8, 38400);
3402+
3403+ MapMask(15);
3404+
3405+ if (no_cursor) {
3406+ no_cursor = 0;
3407+ set_int1c_handler();
3408+ }
3409+}
3410+
3411+void graphics_setcolorstate (color_state state) {
3412+ switch (state) {
3413+ case COLOR_STATE_STANDARD:
3414+ graphics_current_color = graphics_standard_color;
3415+ break;
3416+ case COLOR_STATE_NORMAL:
3417+ graphics_current_color = graphics_normal_color;
3418+ break;
3419+ case COLOR_STATE_HIGHLIGHT:
3420+ graphics_current_color = graphics_highlight_color;
3421+ break;
3422+ default:
3423+ graphics_current_color = graphics_standard_color;
3424+ break;
3425+ }
3426+
3427+ graphics_color_state = state;
3428+}
3429+
3430+void graphics_setcolor (int normal_color, int highlight_color) {
3431+ graphics_normal_color = normal_color;
3432+ graphics_highlight_color = highlight_color;
3433+
3434+ graphics_setcolorstate (graphics_color_state);
3435+}
3436+
3437+int graphics_setcursor (int on) {
3438+ if (!no_cursor && !on) {
3439+ no_cursor = 1;
3440+ unset_int1c_handler();
3441+ graphics_cursor(0);
3442+ }
3443+ else if(no_cursor && on) {
3444+ no_cursor = 0;
3445+ set_int1c_handler();
3446+ graphics_cursor(1);
3447+ }
3448+ return 0;
3449+}
3450+
3451+/* Read in the splashscreen image and set the palette up appropriately.
3452+ * Format of splashscreen is an xpm (can be gzipped) with 16 colors and
3453+ * 640x480. */
3454+int read_image(char *s)
3455+{
3456+ char buf[32], pal[16], c;
3457+ unsigned char base, mask, *s1, *s2, *s4, *s8;
3458+ unsigned i, len, idx, colors, x, y, width, height;
3459+
3460+ if (!grub_open(s))
3461+ return 0;
3462+
3463+ /* read header */
3464+ if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
3465+ grub_close();
3466+ return 0;
3467+ }
3468+
3469+ /* parse info */
3470+ while (grub_read(&c, 1)) {
3471+ if (c == '"')
3472+ break;
3473+ }
3474+
3475+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3476+ ;
3477+
3478+ i = 0;
3479+ width = c - '0';
3480+ while (grub_read(&c, 1)) {
3481+ if (c >= '0' && c <= '9')
3482+ width = width * 10 + c - '0';
3483+ else
3484+ break;
3485+ }
3486+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3487+ ;
3488+
3489+ height = c - '0';
3490+ while (grub_read(&c, 1)) {
3491+ if (c >= '0' && c <= '9')
3492+ height = height * 10 + c - '0';
3493+ else
3494+ break;
3495+ }
3496+ while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
3497+ ;
3498+
3499+ colors = c - '0';
3500+ while (grub_read(&c, 1)) {
3501+ if (c >= '0' && c <= '9')
3502+ colors = colors * 10 + c - '0';
3503+ else
3504+ break;
3505+ }
3506+
3507+ base = 0;
3508+ while (grub_read(&c, 1) && c != '"')
3509+ ;
3510+
3511+ /* palette */
3512+ for (i = 0, idx = 1; i < colors; i++) {
3513+ len = 0;
3514+
3515+ while (grub_read(&c, 1) && c != '"')
3516+ ;
3517+ grub_read(&c, 1); /* char */
3518+ base = c;
3519+ grub_read(buf, 4); /* \t c # */
3520+
3521+ while (grub_read(&c, 1) && c != '"') {
3522+ if (len < sizeof(buf))
3523+ buf[len++] = c;
3524+ }
3525+
3526+ if (len == 6 && idx < 15) {
3527+ int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
3528+ int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
3529+ int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
3530+
3531+ pal[idx] = base;
3532+ graphics_set_palette(idx, r, g, b);
3533+ ++idx;
3534+ }
3535+ }
3536+
3537+ x = y = len = 0;
3538+
3539+ s1 = (unsigned char*)VSHADOW1;
3540+ s2 = (unsigned char*)VSHADOW2;
3541+ s4 = (unsigned char*)VSHADOW4;
3542+ s8 = (unsigned char*)VSHADOW8;
3543+
3544+ for (i = 0; i < 38400; i++)
3545+ s1[i] = s2[i] = s4[i] = s8[i] = 0;
3546+
3547+ /* parse xpm data */
3548+ while (y < height) {
3549+ while (1) {
3550+ if (!grub_read(&c, 1)) {
3551+ grub_close();
3552+ return 0;
3553+ }
3554+ if (c == '"')
3555+ break;
3556+ }
3557+
3558+ while (grub_read(&c, 1) && c != '"') {
3559+ for (i = 1; i < 15; i++)
3560+ if (pal[i] == c) {
3561+ c = i;
3562+ break;
3563+ }
3564+
3565+ mask = 0x80 >> (x & 7);
3566+ if (c & 1)
3567+ s1[len + (x >> 3)] |= mask;
3568+ if (c & 2)
3569+ s2[len + (x >> 3)] |= mask;
3570+ if (c & 4)
3571+ s4[len + (x >> 3)] |= mask;
3572+ if (c & 8)
3573+ s8[len + (x >> 3)] |= mask;
3574+
3575+ if (++x >= 640) {
3576+ x = 0;
3577+
3578+ if (y < 480)
3579+ len += 80;
3580+ ++y;
3581+ }
3582+ }
3583+ }
3584+
3585+ grub_close();
3586+
3587+ graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
3588+ background & 63);
3589+ graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
3590+ foreground & 63);
3591+ graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63,
3592+ window_border & 63);
3593+
3594+ return 1;
3595+}
3596+
3597+/* Convert a character which is a hex digit to the appropriate integer */
3598+int hex(int v)
3599+{
3600+ if (v >= 'A' && v <= 'F')
3601+ return (v - 'A' + 10);
3602+ if (v >= 'a' && v <= 'f')
3603+ return (v - 'a' + 10);
3604+ return (v - '0');
3605+}
3606+
3607+void graphics_cursor(int set) {
3608+ unsigned char *pat, *mem, *ptr, chr[16 << 2];
3609+ int i, ch, invert, offset;
3610+
3611+ if (set && (no_cursor || no_scroll))
3612+ return;
3613+
3614+ offset = cursorY * 80 + fontx;
3615+ ch = text[fonty * 80 + fontx] & 0xff;
3616+ invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
3617+ pat = font8x16 + (ch << 4);
3618+
3619+ mem = (unsigned char*)VIDEOMEM + offset;
3620+
3621+ if (!set) {
3622+ for (i = 0; i < 16; i++) {
3623+ unsigned char mask = pat[i];
3624+
3625+ if (!invert) {
3626+ chr[i ] = ((unsigned char*)VSHADOW1)[offset];
3627+ chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
3628+ chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
3629+ chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
3630+
3631+ if (shade) {
3632+ if (ch == DISP_VERT || ch == DISP_LL ||
3633+ ch == DISP_UR || ch == DISP_LR) {
3634+ unsigned char pmask = ~(pat[i] >> 1);
3635+
3636+ chr[i ] &= pmask;
3637+ chr[16 + i] &= pmask;
3638+ chr[32 + i] &= pmask;
3639+ chr[48 + i] &= pmask;
3640+ }
3641+ if (i > 0 && ch != DISP_VERT) {
3642+ unsigned char pmask = ~(pat[i - 1] >> 1);
3643+
3644+ chr[i ] &= pmask;
3645+ chr[16 + i] &= pmask;
3646+ chr[32 + i] &= pmask;
3647+ chr[48 + i] &= pmask;
3648+ if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
3649+ pmask = ~pat[i - 1];
3650+
3651+ chr[i ] &= pmask;
3652+ chr[16 + i] &= pmask;
3653+ chr[32 + i] &= pmask;
3654+ chr[48 + i] &= pmask;
3655+ }
3656+ }
3657+ }
3658+ chr[i ] |= mask;
3659+ chr[16 + i] |= mask;
3660+ chr[32 + i] |= mask;
3661+ chr[48 + i] |= mask;
3662+
3663+ offset += 80;
3664+ }
3665+ else {
3666+ chr[i ] = mask;
3667+ chr[16 + i] = mask;
3668+ chr[32 + i] = mask;
3669+ chr[48 + i] = mask;
3670+ }
3671+ }
3672+ }
3673+ else {
3674+ MapMask(15);
3675+ ptr = mem;
3676+ for (i = 0; i < 16; i++, ptr += 80) {
3677+ cursorBuf[i] = pat[i];
3678+ *ptr = ~pat[i];
3679+ }
3680+ return;
3681+ }
3682+
3683+ offset = 0;
3684+ for (i = 1; i < 16; i <<= 1, offset += 16) {
3685+ int j;
3686+
3687+ MapMask(i);
3688+ ptr = mem;
3689+ for (j = 0; j < 16; j++, ptr += 80)
3690+ *ptr = chr[j + offset];
3691+ }
3692+
3693+ MapMask(15);
3694+}
3695+
3696+#endif /* SUPPORT_GRAPHICS */
3697diff -Naur grub-0.97.orig/stage2/graphics.h grub-0.97/stage2/graphics.h
3698--- grub-0.97.orig/stage2/graphics.h 1969-12-31 16:00:00.000000000 -0800
3699+++ grub-0.97/stage2/graphics.h 2006-07-03 23:58:41.000000000 -0700
3700@@ -0,0 +1,44 @@
3701+/* graphics.h - graphics console interface */
3702+/*
3703+ * GRUB -- GRand Unified Bootloader
3704+ * Copyright (C) 2002 Free Software Foundation, Inc.
3705+ *
3706+ * This program is free software; you can redistribute it and/or modify
3707+ * it under the terms of the GNU General Public License as published by
3708+ * the Free Software Foundation; either version 2 of the License, or
3709+ * (at your option) any later version.
3710+ *
3711+ * This program is distributed in the hope that it will be useful,
3712+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3713+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3714+ * GNU General Public License for more details.
3715+ *
3716+ * You should have received a copy of the GNU General Public License
3717+ * along with this program; if not, write to the Free Software
3718+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3719+ */
3720+
3721+#ifndef GRAPHICS_H
3722+#define GRAPHICS_H
3723+
3724+/* magic constant */
3725+#define VIDEOMEM 0xA0000
3726+
3727+/* function prototypes */
3728+char *graphics_get_splash(void);
3729+
3730+int read_image(char *s);
3731+void graphics_cursor(int set);
3732+
3733+/* function prototypes for asm functions */
3734+void * graphics_get_font();
3735+void graphics_set_palette(int idx, int red, int green, int blue);
3736+void set_int1c_handler();
3737+void unset_int1c_handler();
3738+
3739+extern short cursorX, cursorY;
3740+extern char cursorBuf[16];
3741+extern int shade;
3742+extern int view_x0, view_y0, view_x1, view_y1;
3743+
3744+#endif /* GRAPHICS_H */
3745diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
3746--- grub-0.97.orig/stage2/Makefile.am 2005-02-02 12:37:35.000000000 -0800
3747+++ grub-0.97/stage2/Makefile.am 2006-07-03 23:58:41.000000000 -0700
3748@@ -7,7 +7,7 @@
3749 fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
3750 imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
3751 nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
3752- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
3753+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
3754 EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
3755
3756 # For <stage1.h>.
3757@@ -19,7 +19,7 @@
3758 disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
3759 fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
3760 fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
3761- terminfo.c tparm.c
3762+ terminfo.c tparm.c graphics.c
3763 libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
3764 -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
3765 -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
3766@@ -79,8 +79,14 @@
3767 HERCULES_FLAGS =
3768 endif
3769
3770+if GRAPHICS_SUPPORT
3771+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
3772+else
3773+GRAPHICS_FLAGS =
3774+endif
3775+
3776 STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
3777- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
3778+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
3779
3780 STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
3781 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
3782@@ -90,7 +96,8 @@
3783 cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
3784 fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
3785 fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
3786- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
3787+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
3788+ graphics.c
3789 pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
3790 pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
3791 pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
3792diff -Naur grub-0.97.orig/stage2/shared.h grub-0.97/stage2/shared.h
3793--- grub-0.97.orig/stage2/shared.h 2004-06-19 09:40:09.000000000 -0700
3794+++ grub-0.97/stage2/shared.h 2006-07-04 00:01:50.000000000 -0700
3795@@ -499,7 +499,11 @@
3796 unsigned char linear_reserved_field_position;
3797 unsigned long max_pixel_clock;
3798
3799- unsigned char reserved3[189];
3800+ /* Reserved field to make structure to be 256 bytes long, VESA BIOS
3801+ Extension 3.0 Specification says to reserve 189 bytes here but
3802+ that doesn't make structure to be 256 bytes. So additional one is
3803+ added here. */
3804+ unsigned char reserved3[189 + 1];
3805 } __attribute__ ((packed));
3806
3807
3808@@ -792,6 +796,11 @@
3809 /* Set the cursor position. */
3810 void gotoxy (int x, int y);
3811
3812+/* Internal pager
3813+ Returns 1 = if pager was used
3814+ 0 = if pager wasn't used */
3815+int do_more (void);
3816+
3817 /* Displays an ASCII character. IBM displays will translate some
3818 characters to special graphical ones (see the DISP_* constants). */
3819 void grub_putchar (int c);
3820@@ -871,6 +880,7 @@
3821 int grub_tolower (int c);
3822 int grub_isspace (int c);
3823 int grub_strncat (char *s1, const char *s2, int n);
3824+void grub_memcpy(void *dest, const void *src, int len);
3825 void *grub_memmove (void *to, const void *from, int len);
3826 void *grub_memset (void *start, int c, int len);
3827 int grub_strncat (char *s1, const char *s2, int n);
3828@@ -911,7 +921,7 @@
3829 int nul_terminate (char *str);
3830 int get_based_digit (int c, int base);
3831 int safe_parse_maxint (char **str_ptr, int *myint_ptr);
3832-int memcheck (int start, int len);
3833+int memcheck (unsigned long int start, unsigned long int len);
3834 void grub_putstr (const char *str);
3835
3836 #ifndef NO_DECOMPRESSION
3837diff -Naur grub-0.97.orig/stage2/stage2.c grub-0.97/stage2/stage2.c
3838--- grub-0.97.orig/stage2/stage2.c 2005-03-19 09:51:57.000000000 -0800
3839+++ grub-0.97/stage2/stage2.c 2006-07-04 00:01:50.000000000 -0700
3840@@ -20,6 +20,12 @@
3841 #include <shared.h>
3842 #include <term.h>
3843
3844+#ifdef SUPPORT_GRAPHICS
3845+# include <graphics.h>
3846+#endif
3847+
3848+int col_start, col_end, row_start, box_size;
3849+
3850 grub_jmp_buf restart_env;
3851
3852 #if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
3853@@ -105,13 +111,13 @@
3854 if (highlight && current_term->setcolorstate)
3855 current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
3856
3857- gotoxy (2, y);
3858+ gotoxy (2 + col_start, y);
3859 grub_putchar (' ');
3860- for (x = 3; x < 75; x++)
3861+ for (x = 3 + col_start; x < (col_end - 5); x++)
3862 {
3863- if (*entry && x <= 72)
3864+ if (*entry && x <= (col_end - 8))
3865 {
3866- if (x == 72)
3867+ if (x == (col_end - 8))
3868 grub_putchar (DISP_RIGHT);
3869 else
3870 grub_putchar (*entry++);
3871@@ -119,7 +125,7 @@
3872 else
3873 grub_putchar (' ');
3874 }
3875- gotoxy (74, y);
3876+ gotoxy ((col_end - 6), y);
3877
3878 if (current_term->setcolorstate)
3879 current_term->setcolorstate (COLOR_STATE_STANDARD);
3880@@ -131,7 +137,7 @@
3881 {
3882 int i;
3883
3884- gotoxy (77, y + 1);
3885+ gotoxy ((col_end - 3), y + 1);
3886
3887 if (first)
3888 grub_putchar (DISP_UP);
3889@@ -151,14 +157,14 @@
3890 menu_entries++;
3891 }
3892
3893- gotoxy (77, y + size);
3894+ gotoxy ((col_end - 3), y + size);
3895
3896 if (*menu_entries)
3897 grub_putchar (DISP_DOWN);
3898 else
3899 grub_putchar (' ');
3900
3901- gotoxy (74, y + entryno + 1);
3902+ gotoxy ((col_end - 6), y + entryno + 1);
3903 }
3904
3905 static void
3906@@ -196,30 +202,30 @@
3907 if (current_term->setcolorstate)
3908 current_term->setcolorstate (COLOR_STATE_NORMAL);
3909
3910- gotoxy (1, y);
3911+ gotoxy (1 + col_start, y);
3912
3913 grub_putchar (DISP_UL);
3914- for (i = 0; i < 73; i++)
3915+ for (i = col_start; i < (col_end - 7); i++)
3916 grub_putchar (DISP_HORIZ);
3917 grub_putchar (DISP_UR);
3918
3919 i = 1;
3920 while (1)
3921 {
3922- gotoxy (1, y + i);
3923+ gotoxy (1 + col_start, y + i);
3924
3925 if (i > size)
3926 break;
3927
3928 grub_putchar (DISP_VERT);
3929- gotoxy (75, y + i);
3930+ gotoxy ((col_end - 5), y + i);
3931 grub_putchar (DISP_VERT);
3932
3933 i++;
3934 }
3935
3936 grub_putchar (DISP_LL);
3937- for (i = 0; i < 73; i++)
3938+ for (i = col_start; i < (col_end - 7); i++)
3939 grub_putchar (DISP_HORIZ);
3940 grub_putchar (DISP_LR);
3941
3942@@ -233,6 +239,7 @@
3943 {
3944 int c, time1, time2 = -1, first_entry = 0;
3945 char *cur_entry = 0;
3946+ struct term_entry *prev_term = NULL;
3947
3948 /*
3949 * Main loop for menu UI.
3950@@ -250,6 +257,22 @@
3951 }
3952 }
3953
3954+ col_start = 0;
3955+ col_end = 80;
3956+ row_start = 0;
3957+ box_size = 12;
3958+ /* if we're using viewport we need to make sure to setup
3959+ coordinates correctly. */
3960+#ifdef SUPPORT_GRAPHICS
3961+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
3962+ {
3963+ col_start = view_x0;
3964+ col_end = view_x1;
3965+ row_start = view_y0;
3966+ box_size = (view_y1 - view_y0) - 13;
3967+ }
3968+#endif
3969+
3970 /* If the timeout was expired or wasn't set, force to show the menu
3971 interface. */
3972 if (grub_timeout < 0)
3973@@ -302,36 +325,36 @@
3974 if (current_term->flags & TERM_DUMB)
3975 print_entries_raw (num_entries, first_entry, menu_entries);
3976 else
3977- print_border (3, 12);
3978+ print_border (3 + row_start, box_size);
3979
3980 grub_printf ("\n\
3981- Use the %c and %c keys to select which entry is highlighted.\n",
3982+ Use the %c and %c keys to select which entry is highlighted.\n",
3983 DISP_UP, DISP_DOWN);
3984
3985 if (! auth && password)
3986 {
3987 printf ("\
3988- Press enter to boot the selected OS or \'p\' to enter a\n\
3989- password to unlock the next set of features.");
3990+ Press enter to boot the selected OS or \'p\' to enter a\n\
3991+ password to unlock the next set of features.");
3992 }
3993 else
3994 {
3995 if (config_entries)
3996 printf ("\
3997- Press enter to boot the selected OS, \'e\' to edit the\n\
3998- commands before booting, or \'c\' for a command-line.");
3999+ Press enter to boot the selected OS, \'e\' to edit the\n\
4000+ commands before booting, or \'c\' for a command-line.");
4001 else
4002 printf ("\
4003- Press \'b\' to boot, \'e\' to edit the selected command in the\n\
4004- boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
4005- after (\'O\' for before) the selected line, \'d\' to remove the\n\
4006- selected line, or escape to go back to the main menu.");
4007+ Press \'b\' to boot, \'e\' to edit the selected command in the\n\
4008+ boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
4009+ after (\'O\' for before) the selected line, \'d\' to remove the\n\
4010+ selected line, or escape to go back to the main menu.");
4011 }
4012
4013 if (current_term->flags & TERM_DUMB)
4014 grub_printf ("\n\nThe selected entry is %d ", entryno);
4015 else
4016- print_entries (3, 12, first_entry, entryno, menu_entries);
4017+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4018 }
4019
4020 /* XX using RT clock now, need to initialize value */
4021@@ -358,10 +381,10 @@
4022 entryno, grub_timeout);
4023 else
4024 {
4025- gotoxy (3, 22);
4026- grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",
4027+ gotoxy (3 + col_start, 10 + box_size + row_start);
4028+ grub_printf (" The highlighted entry will be booted automatically in %d seconds. ",
4029 grub_timeout);
4030- gotoxy (74, 4 + entryno);
4031+ gotoxy ((col_end - 6), 4 + entryno + row_start);
4032 }
4033
4034 grub_timeout--;
4035@@ -387,12 +410,12 @@
4036 if (current_term->flags & TERM_DUMB)
4037 grub_putchar ('\r');
4038 else
4039- gotoxy (3, 22);
4040+ gotoxy (3 + col_start, 10 + box_size + row_start);
4041 printf (" ");
4042 grub_timeout = -1;
4043 fallback_entryno = -1;
4044 if (! (current_term->flags & TERM_DUMB))
4045- gotoxy (74, 4 + entryno);
4046+ gotoxy ((col_end - 6), 4 + entryno + row_start);
4047 }
4048
4049 /* We told them above (at least in SUPPORT_SERIAL) to use
4050@@ -408,12 +431,12 @@
4051 {
4052 if (entryno > 0)
4053 {
4054- print_entry (4 + entryno, 0,
4055+ print_entry (4 + entryno + row_start, 0,
4056 get_entry (menu_entries,
4057 first_entry + entryno,
4058 0));
4059 entryno--;
4060- print_entry (4 + entryno, 1,
4061+ print_entry (4 + entryno + row_start, 1,
4062 get_entry (menu_entries,
4063 first_entry + entryno,
4064 0));
4065@@ -421,7 +444,7 @@
4066 else if (first_entry > 0)
4067 {
4068 first_entry--;
4069- print_entries (3, 12, first_entry, entryno,
4070+ print_entries (3 + row_start, box_size, first_entry, entryno,
4071 menu_entries);
4072 }
4073 }
4074@@ -433,29 +456,29 @@
4075 entryno++;
4076 else
4077 {
4078- if (entryno < 11)
4079+ if (entryno < (box_size - 1))
4080 {
4081- print_entry (4 + entryno, 0,
4082+ print_entry (4 + entryno + row_start, 0,
4083 get_entry (menu_entries,
4084 first_entry + entryno,
4085 0));
4086 entryno++;
4087- print_entry (4 + entryno, 1,
4088+ print_entry (4 + entryno + row_start, 1,
4089 get_entry (menu_entries,
4090 first_entry + entryno,
4091 0));
4092 }
4093- else if (num_entries > 12 + first_entry)
4094+ else if (num_entries > box_size + first_entry)
4095 {
4096 first_entry++;
4097- print_entries (3, 12, first_entry, entryno, menu_entries);
4098+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4099 }
4100 }
4101 }
4102 else if (c == 7)
4103 {
4104 /* Page Up */
4105- first_entry -= 12;
4106+ first_entry -= box_size;
4107 if (first_entry < 0)
4108 {
4109 entryno += first_entry;
4110@@ -463,20 +486,20 @@
4111 if (entryno < 0)
4112 entryno = 0;
4113 }
4114- print_entries (3, 12, first_entry, entryno, menu_entries);
4115+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4116 }
4117 else if (c == 3)
4118 {
4119 /* Page Down */
4120- first_entry += 12;
4121+ first_entry += box_size;
4122 if (first_entry + entryno + 1 >= num_entries)
4123 {
4124- first_entry = num_entries - 12;
4125+ first_entry = num_entries - box_size;
4126 if (first_entry < 0)
4127 first_entry = 0;
4128 entryno = num_entries - first_entry - 1;
4129 }
4130- print_entries (3, 12, first_entry, entryno, menu_entries);
4131+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4132 }
4133
4134 if (config_entries)
4135@@ -489,7 +512,7 @@
4136 if ((c == 'd') || (c == 'o') || (c == 'O'))
4137 {
4138 if (! (current_term->flags & TERM_DUMB))
4139- print_entry (4 + entryno, 0,
4140+ print_entry (4 + entryno + row_start, 0,
4141 get_entry (menu_entries,
4142 first_entry + entryno,
4143 0));
4144@@ -537,7 +560,7 @@
4145
4146 if (entryno >= num_entries)
4147 entryno--;
4148- if (first_entry && num_entries < 12 + first_entry)
4149+ if (first_entry && num_entries < box_size + first_entry)
4150 first_entry--;
4151 }
4152
4153@@ -549,7 +572,7 @@
4154 grub_printf ("\n");
4155 }
4156 else
4157- print_entries (3, 12, first_entry, entryno, menu_entries);
4158+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
4159 }
4160
4161 cur_entry = menu_entries;
4162@@ -570,7 +593,7 @@
4163 if (current_term->flags & TERM_DUMB)
4164 grub_printf ("\r ");
4165 else
4166- gotoxy (1, 21);
4167+ gotoxy (1 + col_start, 9 + box_size + row_start);
4168
4169 /* Wipe out the previously entered password */
4170 grub_memset (entered, 0, sizeof (entered));
4171@@ -651,7 +674,10 @@
4172 *(new_heap++) = 0;
4173
4174 if (config_entries)
4175- run_menu (heap, NULL, new_num_entries, new_heap, 0);
4176+ {
4177+ current_entryno = first_entry + entryno;
4178+ run_menu (heap, NULL, new_num_entries, new_heap, 0);
4179+ }
4180 else
4181 {
4182 cls ();
4183@@ -714,6 +740,15 @@
4184
4185 cls ();
4186 setcursor (1);
4187+ /* if our terminal needed initialization, we should shut it down
4188+ * before booting the kernel, but we want to save what it was so
4189+ * we can come back if needed */
4190+ prev_term = current_term;
4191+ if (current_term->shutdown)
4192+ {
4193+ current_term->shutdown();
4194+ current_term = term_table; /* assumption: console is first */
4195+ }
4196
4197 while (1)
4198 {
4199@@ -727,7 +762,8 @@
4200 cur_entry = get_entry (config_entries, first_entry + entryno, 1);
4201
4202 /* Set CURRENT_ENTRYNO for the command "savedefault". */
4203- current_entryno = first_entry + entryno;
4204+ if (config_entries)
4205+ current_entryno = first_entry + entryno;
4206
4207 if (run_script (cur_entry, heap))
4208 {
4209@@ -748,6 +784,13 @@
4210 break;
4211 }
4212
4213+ /* if we get back here, we should go back to what our term was before */
4214+ current_term = prev_term;
4215+ if (current_term->startup)
4216+ /* if our terminal fails to initialize, fall back to console since
4217+ * it should always work */
4218+ if (current_term->startup() == 0)
4219+ current_term = term_table; /* we know that console is first */
4220 show_menu = 1;
4221 goto restart;
4222 }
4223@@ -891,8 +934,18 @@
4224 len = grub_read (buf, sizeof (buf));
4225 if (len > 0)
4226 {
4227+ char *tmp;
4228+ char *def;
4229 buf[sizeof (buf) - 1] = 0;
4230- safe_parse_maxint (&p, &saved_entryno);
4231+
4232+ if((tmp = grub_strstr(p, ":")) != NULL)
4233+ {
4234+ *tmp++;
4235+ grub_memcpy(&def, &tmp, sizeof(p));
4236+ }else
4237+ grub_memcpy(&def, &p, sizeof(p));
4238+
4239+ safe_parse_maxint (&def, &saved_entryno);
4240 }
4241
4242 grub_close ();
4243@@ -1050,6 +1103,16 @@
4244 while (is_preset);
4245 }
4246
4247+ /* go ahead and make sure the terminal is setup */
4248+ if (current_term->startup)
4249+ {
4250+ /* If initialization fails, go back to default terminal */
4251+ if (current_term->startup() == 0)
4252+ {
4253+ current_term = term_table;
4254+ }
4255+ }
4256+
4257 if (! num_entries)
4258 {
4259 /* If no acceptable config file, goto command-line, starting
4260diff -Naur grub-0.97.orig/stage2/term.h grub-0.97/stage2/term.h
4261--- grub-0.97.orig/stage2/term.h 2003-07-09 04:45:53.000000000 -0700
4262+++ grub-0.97/stage2/term.h 2006-07-03 23:58:41.000000000 -0700
4263@@ -60,6 +60,8 @@
4264 const char *name;
4265 /* The feature flags defined above. */
4266 unsigned long flags;
4267+ /* Default for maximum number of lines if not specified */
4268+ unsigned short max_lines;
4269 /* Put a character. */
4270 void (*putchar) (int c);
4271 /* Check if any input character is available. */
4272@@ -79,6 +81,10 @@
4273 void (*setcolor) (int normal_color, int highlight_color);
4274 /* Turn on/off the cursor. */
4275 int (*setcursor) (int on);
4276+ /* function to start a terminal */
4277+ int (*startup) (void);
4278+ /* function to use to shutdown a terminal */
4279+ void (*shutdown) (void);
4280 };
4281
4282 /* This lists up available terminals. */
4283@@ -124,4 +130,24 @@
4284 int hercules_setcursor (int on);
4285 #endif
4286
4287+#ifdef SUPPORT_GRAPHICS
4288+extern int foreground, background, window_border, graphics_inited, saved_videomode;
4289+
4290+void graphics_set_splash(char *splashfile);
4291+int set_videomode(int mode);
4292+int get_videomode(void);
4293+void graphics_putchar (int c);
4294+int graphics_getxy(void);
4295+void graphics_gotoxy(int x, int y);
4296+void graphics_cls(void);
4297+void graphics_setcolorstate (color_state state);
4298+void graphics_setcolor (int normal_color, int highlight_color);
4299+int graphics_setcursor (int on);
4300+int graphics_init(void);
4301+void graphics_end(void);
4302+
4303+int hex(int v);
4304+void graphics_set_palette(int idx, int red, int green, int blue);
4305+#endif /* SUPPORT_GRAPHICS */
4306+
4307 #endif /* ! GRUB_TERM_HEADER */
4308diff -Naur grub-0.97.orig/THANKS grub-0.97/THANKS
4309--- grub-0.97.orig/THANKS 2005-05-07 19:17:43.000000000 -0700
4310+++ grub-0.97/THANKS 2006-07-04 00:01:50.000000000 -0700
4311@@ -121,3 +121,4 @@
4312 Yedidyah Bar-David <didi@post.tau.ac.il>
4313 Yury V. Umanets <umka@namesys.com>
4314 Yuri Zaporogets <yuriz@ukr.net>
4315+Vitaly Fertman <vitaly@namesys.com>
4316diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
4317--- grub-0.97.orig/util/grub-install.in 2004-07-24 11:57:31.000000000 -0700
4318+++ grub-0.97/util/grub-install.in 2006-07-04 00:01:50.000000000 -0700
4319@@ -81,6 +81,50 @@
4320 EOF
4321 }
4322
4323+# Usage: getraid_mdadm mddevice
4324+# Routine to find a physical device from an md device
4325+# If found, the first grub BIOS device (from device.map) is returned
4326+# If no BIOS drives match the RAID devices, the first device returned
4327+# from mdadm -D is returned
4328+getraid_mdadm() {
4329+ device=$1
4330+ mdadm=$(mdadm -D "$device") || {
4331+ echo "$PROG: mdadm -D $device failed" >&2
4332+ exit 1
4333+ }
4334+ eval "$(
4335+ echo "$mdadm" | awk '
4336+ $1 == "Number" && $2 == "Major" { start = 1; next }
4337+ $1 == "UUID" { print "uuid=" $3; start = 0; next }
4338+ !start { next }
4339+ $2 == 0 && $3 == 0 { next }
4340+ { devices = devices "\n" $NF }
4341+ END { print "devices='\''" devices "'\''" }
4342+ '
4343+ )"
4344+
4345+ # Convert RAID devices list into a list of disks
4346+ tmp_disks=`echo "$devices" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
4347+ -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
4348+ -e 's%\(fd[0-9]*\)$%\1%' \
4349+ -e 's%/part[0-9]*$%/disc%' \
4350+ -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
4351+ -e '/^$/d' |
4352+ sed -n '1h;2,$H;${g;s/\n/|/g;p}'`
4353+
4354+ # Find first BIOS disk that's a member of the RAID array
4355+ # Default to first RAID member if no tmp_disks are BIOS devices
4356+ set -- `egrep $tmp_disks $device_map | \
4357+ sort | \
4358+ sed -n 1p `
4359+ device=${2:-${tmp_disks%%|*}}
4360+
4361+ # Return first partition on BIOS disk that's part of the RAID
4362+ echo "$devices" | \
4363+ sed -n "\:${device}:p" | \
4364+ sed -n 1p
4365+}
4366+
4367 # Usage: convert os_device
4368 # Convert an OS device to the corresponding GRUB drive.
4369 # This part is OS-specific.
4370@@ -96,6 +140,10 @@
4371 # Break the device name into the disk part and the partition part.
4372 case "$host_os" in
4373 linux*)
4374+ # Find an actual physical device if we're passed a RAID device
4375+ case $1 in
4376+ /dev/md*) set -- `getraid_mdadm $1`
4377+ esac
4378 tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
4379 -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
4380 -e 's%\(fd[0-9]*\)$%\1%' \
4381@@ -112,8 +160,8 @@
4382 tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
4383 tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
4384 freebsd* | kfreebsd*-gnu)
4385- tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \
4386- | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'`
4387+ tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
4388+ | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
4389 tmp_part=`echo "$1" \
4390 | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
4391 | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
4392@@ -131,7 +179,7 @@
4393
4394 # Get the drive name.
4395 tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
4396- | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'`
4397+ | sed 's%.*\(([hf]d[0-9][a-z0-9,]*)\).*%\1%'`
4398
4399 # If not found, print an error message and exit.
4400 if test "x$tmp_drive" = x; then
4401@@ -148,13 +196,13 @@
4402 gnu*)
4403 if echo $tmp_part | grep "^s" >/dev/null; then
4404 tmp_pc_slice=`echo $tmp_part \
4405- | sed "s%s\([0-9]*\)[a-g]*$%\1%"`
4406+ | sed "s%s\([0-9]*\)[a-z]*$%\1%"`
4407 tmp_drive=`echo "$tmp_drive" \
4408 | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
4409 fi
4410- if echo $tmp_part | grep "[a-g]$" >/dev/null; then
4411+ if echo $tmp_part | grep "[a-z]$" >/dev/null; then
4412 tmp_bsd_partition=`echo "$tmp_part" \
4413- | sed "s%[^a-g]*\([a-g]\)$%\1%"`
4414+ | sed "s%[^a-z]*\([a-z]\)$%\1%"`
4415 tmp_drive=`echo "$tmp_drive" \
4416 | sed "s%)%,$tmp_bsd_partition)%"`
4417 fi
4418@@ -336,6 +384,10 @@
4419 # Create a safe temporary file.
4420 test -n "$mklog" && log_file=`$mklog`
4421
4422+ # Before all invocations of the grub shell, call sync to make sure
4423+ # the raw device is in sync with any bufferring in filesystems.
4424+ sync
4425+
4426 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
4427 quit
4428 EOF
4429@@ -450,6 +502,24 @@
4430 # Create a safe temporary file.
4431 test -n "$mklog" && log_file=`$mklog`
4432
4433+# Sync to prevent GRUB from not finding stage files (notably, on XFS)
4434+sync
4435+
4436+# XFS needs special magic
4437+xfs_frozen=false
4438+if which xfs_freeze > /dev/null ; then
4439+ cat << EOF
4440+Due to a bug in xfs_freeze, the following command might produce a segmentation
4441+fault when ${grubdir} is not in an XFS filesystem. This error is harmless and
4442+can be ignored.
4443+EOF
4444+ if xfs_freeze -f ${grubdir} ; then xfs_frozen=true ; fi
4445+fi
4446+
4447+# Before all invocations of the grub shell, call sync to make sure
4448+# the raw device is in sync with any bufferring in filesystems.
4449+sync
4450+
4451 # Now perform the installation.
4452 $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
4453 root $root_drive
4454@@ -457,6 +527,10 @@
4455 quit
4456 EOF
4457
4458+if ${xfs_frozen} ; then
4459+ xfs_freeze -u ${grubdir}
4460+fi
4461+
4462 if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then
4463 cat $log_file 1>&2
4464 exit 1
Note: See TracBrowser for help on using the repository browser.