source: patches/grub-0.97-fixes-1.patch@ 926e7ee

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 926e7ee was 5a4020f, checked in by Jim Gifford <clfs@…>, 18 years ago

Updated Grub Patch

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