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