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

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

Updated Grub Patch

  • Property mode set to 100644
File size: 129.7 KB
  • aclocal.m4

    Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
    Date: 2006-07-04
    Initial Package Version: 0.97
    Origin: Debian
    Upstream Status: Unknown
    Description: Contains various fixes and enhancements
    	Graphics mode support
    	Fixes for Raid Support
    	XFS Filesystem Boot Freeze Fixes
    	Removed 2GB Memory Limitation
    	Freebsd support
    	Fixes for initrd support
    	Grub installation Fixes
    	Linux 2.6 geometry Fixes
    	Intel Mac Support
    	Autoconf and aclocal updates
    
    diff -Naur grub-0.97.orig/aclocal.m4 grub-0.97/aclocal.m4
    old new  
    1 # generated automatically by aclocal 1.9.4 -*- Autoconf -*-
     1# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
    22
    3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    4 # Free Software Foundation, Inc.
     3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
     4# 2005  Free Software Foundation, Inc.
    55# This file is free software; the Free Software Foundation
    66# gives unlimited permission to copy and/or distribute it,
    77# with or without modifications, as long as this notice is preserved.
     
    1111# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    1212# PARTICULAR PURPOSE.
    1313
    14 #                                                        -*- Autoconf -*-
    15 # Copyright (C) 2002, 2003  Free Software Foundation, Inc.
    16 # Generated from amversion.in; do not edit by hand.
    17 
    18 # This program is free software; you can redistribute it and/or modify
    19 # it under the terms of the GNU General Public License as published by
    20 # the Free Software Foundation; either version 2, or (at your option)
    21 # any later version.
    22 
    23 # This program is distributed in the hope that it will be useful,
    24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    26 # GNU General Public License for more details.
    27 
    28 # You should have received a copy of the GNU General Public License
    29 # along with this program; if not, write to the Free Software
    30 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     14# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
     15#
     16# This file is free software; the Free Software Foundation
     17# gives unlimited permission to copy and/or distribute it,
     18# with or without modifications, as long as this notice is preserved.
    3119
    3220# AM_AUTOMAKE_VERSION(VERSION)
    3321# ----------------------------
     
    4028# Call AM_AUTOMAKE_VERSION so it can be traced.
    4129# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
    4230AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
    43          [AM_AUTOMAKE_VERSION([1.9.4])])
    44 
    45 # AM_AUX_DIR_EXPAND
    46 
    47 # Copyright (C) 2001, 2003 Free Software Foundation, Inc.
     31         [AM_AUTOMAKE_VERSION([1.9.6])])
    4832
    49 # This program is free software; you can redistribute it and/or modify
    50 # it under the terms of the GNU General Public License as published by
    51 # the Free Software Foundation; either version 2, or (at your option)
    52 # any later version.
     33# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
    5334
    54 # This program is distributed in the hope that it will be useful,
    55 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    56 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    57 # GNU General Public License for more details.
    58 
    59 # You should have received a copy of the GNU General Public License
    60 # along with this program; if not, write to the Free Software
    61 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    62 # 02111-1307, USA.
     35# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
     36#
     37# This file is free software; the Free Software Foundation
     38# gives unlimited permission to copy and/or distribute it,
     39# with or without modifications, as long as this notice is preserved.
    6340
    6441# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
    6542# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
     
    10683am_aux_dir=`cd $ac_aux_dir && pwd`
    10784])
    10885
    109 # AM_CONDITIONAL                                              -*- Autoconf -*-
     86# AM_CONDITIONAL                                            -*- Autoconf -*-
    11087
    111 # Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
    112 
    113 # This program is free software; you can redistribute it and/or modify
    114 # it under the terms of the GNU General Public License as published by
    115 # the Free Software Foundation; either version 2, or (at your option)
    116 # any later version.
    117 
    118 # This program is distributed in the hope that it will be useful,
    119 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    120 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    121 # GNU General Public License for more details.
    122 
    123 # You should have received a copy of the GNU General Public License
    124 # along with this program; if not, write to the Free Software
    125 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    126 # 02111-1307, USA.
     88# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
     89# 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.
    12794
    128 # serial 6
     95# serial 7
    12996
    13097# AM_CONDITIONAL(NAME, SHELL-CONDITION)
    13198# -------------------------------------
     
    149116Usually this means the macro was only invoked conditionally.]])
    150117fi])])
    151118
    152 # serial 7                                              -*- Autoconf -*-
    153119
    154 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
     120# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
    155121# 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.
    156126
    157 # This program is free software; you can redistribute it and/or modify
    158 # it under the terms of the GNU General Public License as published by
    159 # the Free Software Foundation; either version 2, or (at your option)
    160 # any later version.
    161 
    162 # This program is distributed in the hope that it will be useful,
    163 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    164 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    165 # GNU General Public License for more details.
    166 
    167 # You should have received a copy of the GNU General Public License
    168 # along with this program; if not, write to the Free Software
    169 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    170 # 02111-1307, USA.
    171 
     127# serial 8
    172128
    173129# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
    174130# written in clear, in which case automake, when reading aclocal.m4,
     
    177133# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
    178134
    179135
    180 
    181136# _AM_DEPENDENCIES(NAME)
    182137# ----------------------
    183138# See how the compiler implements dependency checking.
     
    317272AC_SUBST([AMDEPBACKSLASH])
    318273])
    319274
    320 # Generate code to set up dependency tracking.   -*- Autoconf -*-
    321 
    322 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
    323 #   Free Software Foundation, Inc.
    324 
    325 # This program is free software; you can redistribute it and/or modify
    326 # it under the terms of the GNU General Public License as published by
    327 # the Free Software Foundation; either version 2, or (at your option)
    328 # any later version.
     275# Generate code to set up dependency tracking.              -*- Autoconf -*-
    329276
    330 # This program is distributed in the hope that it will be useful,
    331 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    332 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    333 # GNU General Public License for more details.
    334 
    335 # You should have received a copy of the GNU General Public License
    336 # along with this program; if not, write to the Free Software
    337 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    338 # 02111-1307, USA.
     277# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
     278# Free Software Foundation, Inc.
     279#
     280# This file is free software; the Free Software Foundation
     281# gives unlimited permission to copy and/or distribute it,
     282# with or without modifications, as long as this notice is preserved.
    339283
    340 #serial 2
     284#serial 3
    341285
    342286# _AM_OUTPUT_DEPENDENCY_COMMANDS
    343287# ------------------------------
     
    396340     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
    397341])
    398342
    399 # Do all the work for Automake.                            -*- Autoconf -*-
     343# Do all the work for Automake.                             -*- Autoconf -*-
    400344
    401 # This macro actually does too much some checks are only needed if
    402 # your package does certain things.  But this isn't really a big deal.
    403 
    404 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
     345# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    405346# Free Software Foundation, Inc.
     347#
     348# This file is free software; the Free Software Foundation
     349# gives unlimited permission to copy and/or distribute it,
     350# with or without modifications, as long as this notice is preserved.
    406351
    407 # This program is free software; you can redistribute it and/or modify
    408 # it under the terms of the GNU General Public License as published by
    409 # the Free Software Foundation; either version 2, or (at your option)
    410 # any later version.
    411 
    412 # This program is distributed in the hope that it will be useful,
    413 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    414 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    415 # GNU General Public License for more details.
    416 
    417 # You should have received a copy of the GNU General Public License
    418 # along with this program; if not, write to the Free Software
    419 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    420 # 02111-1307, USA.
     352# serial 12
    421353
    422 # serial 11
     354# This macro actually does too much.  Some checks are only needed if
     355# your package does certain things.  But this isn't really a big deal.
    423356
    424357# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
    425358# AM_INIT_AUTOMAKE([OPTIONS])
     
    521454done
    522455echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
    523456
     457# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
     458#
     459# This file is free software; the Free Software Foundation
     460# gives unlimited permission to copy and/or distribute it,
     461# with or without modifications, as long as this notice is preserved.
     462
    524463# AM_PROG_INSTALL_SH
    525464# ------------------
    526465# Define $install_sh.
    527 
    528 # Copyright (C) 2001, 2003 Free Software Foundation, Inc.
    529 
    530 # This program is free software; you can redistribute it and/or modify
    531 # it under the terms of the GNU General Public License as published by
    532 # the Free Software Foundation; either version 2, or (at your option)
    533 # any later version.
    534 
    535 # This program is distributed in the hope that it will be useful,
    536 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    537 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    538 # GNU General Public License for more details.
    539 
    540 # You should have received a copy of the GNU General Public License
    541 # along with this program; if not, write to the Free Software
    542 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    543 # 02111-1307, USA.
    544 
    545466AC_DEFUN([AM_PROG_INSTALL_SH],
    546467[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
    547468install_sh=${install_sh-"$am_aux_dir/install-sh"}
    548469AC_SUBST(install_sh)])
    549470
    550 #                                                          -*- Autoconf -*-
    551 # Copyright (C) 2003  Free Software Foundation, Inc.
    552 
    553 # This program is free software; you can redistribute it and/or modify
    554 # it under the terms of the GNU General Public License as published by
    555 # the Free Software Foundation; either version 2, or (at your option)
    556 # any later version.
    557 
    558 # This program is distributed in the hope that it will be useful,
    559 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    560 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    561 # GNU General Public License for more details.
    562 
    563 # You should have received a copy of the GNU General Public License
    564 # along with this program; if not, write to the Free Software
    565 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    566 # 02111-1307, USA.
     471# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
     472#
     473# This file is free software; the Free Software Foundation
     474# gives unlimited permission to copy and/or distribute it,
     475# with or without modifications, as long as this notice is preserved.
    567476
    568 # serial 1
     477# serial 2
    569478
    570479# Check whether the underlying file-system supports filenames
    571480# with a leading dot.  For instance MS-DOS doesn't.
     
    580489rmdir .tst 2>/dev/null
    581490AC_SUBST([am__leading_dot])])
    582491
    583 # Add --enable-maintainer-mode option to configure.
     492# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
    584493# From Jim Meyering
    585494
    586 # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004
     495# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
    587496# Free Software Foundation, Inc.
     497#
     498# This file is free software; the Free Software Foundation
     499# gives unlimited permission to copy and/or distribute it,
     500# with or without modifications, as long as this notice is preserved.
    588501
    589 # This program is free software; you can redistribute it and/or modify
    590 # it under the terms of the GNU General Public License as published by
    591 # the Free Software Foundation; either version 2, or (at your option)
    592 # any later version.
    593 
    594 # This program is distributed in the hope that it will be useful,
    595 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    596 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    597 # GNU General Public License for more details.
    598 
    599 # You should have received a copy of the GNU General Public License
    600 # along with this program; if not, write to the Free Software
    601 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    602 # 02111-1307, USA.
    603 
    604 # serial 3
     502# serial 4
    605503
    606504AC_DEFUN([AM_MAINTAINER_MODE],
    607505[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
     
    620518
    621519AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
    622520
    623 # Check to see how 'make' treats includes.      -*- Autoconf -*-
    624 
    625 # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
     521# Check to see how 'make' treats includes.                  -*- Autoconf -*-
    626522
    627 # This program is free software; you can redistribute it and/or modify
    628 # it under the terms of the GNU General Public License as published by
    629 # the Free Software Foundation; either version 2, or (at your option)
    630 # any later version.
    631 
    632 # This program is distributed in the hope that it will be useful,
    633 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    634 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    635 # GNU General Public License for more details.
    636 
    637 # You should have received a copy of the GNU General Public License
    638 # along with this program; if not, write to the Free Software
    639 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    640 # 02111-1307, USA.
     523# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
     524#
     525# This file is free software; the Free Software Foundation
     526# gives unlimited permission to copy and/or distribute it,
     527# with or without modifications, as long as this notice is preserved.
    641528
    642 # serial 2
     529# serial 3
    643530
    644531# AM_MAKE_INCLUDE()
    645532# -----------------
     
    683570rm -f confinc confmf
    684571])
    685572
    686 #  -*- Autoconf -*-
    687 
    688 
    689 # Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
    690 
    691 # This program is free software; you can redistribute it and/or modify
    692 # it under the terms of the GNU General Public License as published by
    693 # the Free Software Foundation; either version 2, or (at your option)
    694 # any later version.
     573# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
    695574
    696 # This program is distributed in the hope that it will be useful,
    697 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    698 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    699 # GNU General Public License for more details.
    700 
    701 # You should have received a copy of the GNU General Public License
    702 # along with this program; if not, write to the Free Software
    703 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    704 # 02111-1307, USA.
     575# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
     576# Free Software Foundation, Inc.
     577#
     578# This file is free software; the Free Software Foundation
     579# gives unlimited permission to copy and/or distribute it,
     580# with or without modifications, as long as this notice is preserved.
    705581
    706 # serial 3
     582# serial 4
    707583
    708584# AM_MISSING_PROG(NAME, PROGRAM)
    709585# ------------------------------
     
    729605fi
    730606])
    731607
     608# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
     609#
     610# This file is free software; the Free Software Foundation
     611# gives unlimited permission to copy and/or distribute it,
     612# with or without modifications, as long as this notice is preserved.
     613
    732614# AM_PROG_MKDIR_P
    733615# ---------------
    734616# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
    735 
    736 # Copyright (C) 2003, 2004 Free Software Foundation, Inc.
    737 
    738 # This program is free software; you can redistribute it and/or modify
    739 # it under the terms of the GNU General Public License as published by
    740 # the Free Software Foundation; either version 2, or (at your option)
    741 # any later version.
    742 
    743 # This program is distributed in the hope that it will be useful,
    744 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    745 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    746 # GNU General Public License for more details.
    747 
    748 # You should have received a copy of the GNU General Public License
    749 # along with this program; if not, write to the Free Software
    750 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    751 # 02111-1307, USA.
    752 
     617#
    753618# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
    754619# created by `make install' are always world readable, even if the
    755620# installer happens to have an overly restrictive umask (e.g. 077).
     
    803668fi
    804669AC_SUBST([mkdir_p])])
    805670
    806 # Helper functions for option handling.                    -*- Autoconf -*-
     671# Helper functions for option handling.                     -*- Autoconf -*-
    807672
    808 # Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
    809 
    810 # This program is free software; you can redistribute it and/or modify
    811 # it under the terms of the GNU General Public License as published by
    812 # the Free Software Foundation; either version 2, or (at your option)
    813 # any later version.
    814 
    815 # This program is distributed in the hope that it will be useful,
    816 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    817 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    818 # GNU General Public License for more details.
    819 
    820 # You should have received a copy of the GNU General Public License
    821 # along with this program; if not, write to the Free Software
    822 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    823 # 02111-1307, USA.
     673# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
     674#
     675# This file is free software; the Free Software Foundation
     676# gives unlimited permission to copy and/or distribute it,
     677# with or without modifications, as long as this notice is preserved.
    824678
    825 # serial 2
     679# serial 3
    826680
    827681# _AM_MANGLE_OPTION(NAME)
    828682# -----------------------
     
    847701AC_DEFUN([_AM_IF_OPTION],
    848702[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
    849703
    850 #
    851 # Check to make sure that the build environment is sane.
    852 #
    853 
    854 # Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
    855 
    856 # This program is free software; you can redistribute it and/or modify
    857 # it under the terms of the GNU General Public License as published by
    858 # the Free Software Foundation; either version 2, or (at your option)
    859 # any later version.
     704# Check to make sure that the build environment is sane.    -*- Autoconf -*-
    860705
    861 # This program is distributed in the hope that it will be useful,
    862 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    863 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    864 # GNU General Public License for more details.
    865 
    866 # You should have received a copy of the GNU General Public License
    867 # along with this program; if not, write to the Free Software
    868 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    869 # 02111-1307, USA.
     706# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
     707# Free Software Foundation, Inc.
     708#
     709# This file is free software; the Free Software Foundation
     710# gives unlimited permission to copy and/or distribute it,
     711# with or without modifications, as long as this notice is preserved.
    870712
    871 # serial 3
     713# serial 4
    872714
    873715# AM_SANITY_CHECK
    874716# ---------------
     
    911753fi
    912754AC_MSG_RESULT(yes)])
    913755
    914 # AM_PROG_INSTALL_STRIP
    915 
    916 # Copyright (C) 2001, 2003 Free Software Foundation, Inc.
    917 
    918 # This program is free software; you can redistribute it and/or modify
    919 # it under the terms of the GNU General Public License as published by
    920 # the Free Software Foundation; either version 2, or (at your option)
    921 # any later version.
    922 
    923 # This program is distributed in the hope that it will be useful,
    924 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    925 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    926 # GNU General Public License for more details.
    927 
    928 # You should have received a copy of the GNU General Public License
    929 # along with this program; if not, write to the Free Software
    930 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    931 # 02111-1307, USA.
     756# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
     757#
     758# This file is free software; the Free Software Foundation
     759# gives unlimited permission to copy and/or distribute it,
     760# with or without modifications, as long as this notice is preserved.
    932761
     762# AM_PROG_INSTALL_STRIP
     763# ---------------------
    933764# One issue with vendor `install' (even GNU) is that you can't
    934765# specify the program used to strip binaries.  This is especially
    935766# annoying in cross-compiling environments, where the build's strip
     
    952783
    953784# Check how to create a tarball.                            -*- Autoconf -*-
    954785
    955 # Copyright (C) 2004  Free Software Foundation, Inc.
    956 
    957 # This program is free software; you can redistribute it and/or modify
    958 # it under the terms of the GNU General Public License as published by
    959 # the Free Software Foundation; either version 2, or (at your option)
    960 # any later version.
    961 
    962 # This program is distributed in the hope that it will be useful,
    963 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    964 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    965 # GNU General Public License for more details.
    966 
    967 # You should have received a copy of the GNU General Public License
    968 # along with this program; if not, write to the Free Software
    969 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    970 # 02111-1307, USA.
    971 
    972 # serial 1
     786# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
     787#
     788# This file is free software; the Free Software Foundation
     789# gives unlimited permission to copy and/or distribute it,
     790# with or without modifications, as long as this notice is preserved.
    973791
     792# serial 2
    974793
    975794# _AM_PROG_TAR(FORMAT)
    976795# --------------------
  • ChangeLog

    diff -Naur grub-0.97.orig/ChangeLog grub-0.97/ChangeLog
    old new  
     12006-05-02  Pavel Roskin  <proski@gnu.org>
     2
     3        * stage2/stage2.c (run_menu): Fix "savedefault" to save only top
     4        level menu positions.  Remember current position when calling a
     5        submenu.  Don't recalculate it when booting from a submenu.
     6
     7        * grub/main.c (main): Make sure the boot drive number doesn't
     8        exceed 255.
     9
     102006-05-02  Vesa Jaaskelainen  <chaac@nic.fi>
     11
     12        * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2
     13        to GRUB Legacy.  Problem reported by Gerardo Richarte.
     14
     152006-04-23  Robert Millan  <robertmh@gnu.org>
     16
     17        * grub/asmstub.c (get_diskinfo): Optimize sysctl routine.
     18
     192006-04-20  Robert Millan  <robertmh@gnu.org>
     20
     21        Fixes for kernel of FreeBSD:
     22        * grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl
     23        before opening a device for writing.
     24        * util/grub-install.in: Devices don't have this "r" prefix anymore.
     25
     262006-04-16  Yoshinori K. Okuji  <okuji@enbug.org>
     27
     28        * docs/multiboot.texi: Correct the offset of address
     29        fields. Reported by Jeroen Dekkers.
     30
     312006-03-21  Yoshinori K. Okuji  <okuji@enbug.org>
     32
     33        * stage2/builtins.c (setup_func): Specify the size of DEVICE to
     34        grub_strncat instead of a strange number 256. Reported by Vitaly
     35        Fertman <vitaly@namesys.com>.
     36
     372005-09-29  Yoshinori K. Okuji  <okuji@enbug.org>
     38
     39        * docs/multiboot.texi: Fix a bug in the byte order of
     40        boot_device. I hope this won't affect any OS image.
     41        Increased the version number to 0.6.94.
     42
     432005-09-28  Yoshinori K. Okuji  <okuji@enbug.org>
     44
     45        * stage2/boot.c (load_image): Even if an OS image is an ELF
     46        object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is
     47        specified.
     48
    1492005-05-08  Yoshinori K. Okuji  <okuji@enbug.org>
    250
    351        * configure.ac (AC_INIT): Upgraded to 0.97.
  • configure

    diff -Naur grub-0.97.orig/configure grub-0.97/configure
    old new  
    311311# include <unistd.h>
    312312#endif"
    313313
    314 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'
     314ac_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'
    315315ac_subst_files=''
    316316
    317317# Initialize some variables set by options.
     
    914914                          set the default memory location for WD/SMC
    915915  --enable-cs-scan=LIST   probe for CS89x0 base address using LIST
    916916  --enable-diskless       enable diskless support
     917  --disable-graphics      disable graphics terminal support
    917918  --disable-hercules      disable hercules terminal support
    918919  --disable-serial        disable serial terminal support
    919920  --enable-serial-speed-simulation
     
    59665967fi
    59675968
    59685969
     5970# Check whether --enable-graphics or --disable-graphics was given.
     5971if test "${enable_graphics+set}" = set; then
     5972  enableval="$enable_graphics"
     5973
     5974fi;
     5975
     5976
     5977if test "x$enable_graphics" != xno; then
     5978  GRAPHICS_SUPPORT_TRUE=
     5979  GRAPHICS_SUPPORT_FALSE='#'
     5980else
     5981  GRAPHICS_SUPPORT_TRUE='#'
     5982  GRAPHICS_SUPPORT_FALSE=
     5983fi
     5984
     5985
    59695986# Check whether --enable-hercules or --disable-hercules was given.
    59705987if test "${enable_hercules+set}" = set; then
    59715988  enableval="$enable_hercules"
     
    62706287Usually this means the macro was only invoked conditionally." >&2;}
    62716288   { (exit 1); exit 1; }; }
    62726289fi
     6290if test -z "${GRAPHICS_SUPPORT_TRUE}" && test -z "${GRAPHICS_SUPPORT_FALSE}"; then
     6291  { { echo "$as_me:$LINENO: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
     6292Usually this means the macro was only invoked conditionally." >&5
     6293echo "$as_me: error: conditional \"GRAPHICS_SUPPORT\" was never defined.
     6294Usually this means the macro was only invoked conditionally." >&2;}
     6295   { (exit 1); exit 1; }; }
     6296fi
    62736297if test -z "${HERCULES_SUPPORT_TRUE}" && test -z "${HERCULES_SUPPORT_FALSE}"; then
    62746298  { { echo "$as_me:$LINENO: error: conditional \"HERCULES_SUPPORT\" was never defined.
    62756299Usually this means the macro was only invoked conditionally." >&5
     
    69076931s,@NETBOOT_SUPPORT_FALSE@,$NETBOOT_SUPPORT_FALSE,;t t
    69086932s,@DISKLESS_SUPPORT_TRUE@,$DISKLESS_SUPPORT_TRUE,;t t
    69096933s,@DISKLESS_SUPPORT_FALSE@,$DISKLESS_SUPPORT_FALSE,;t t
     6934s,@GRAPHICS_SUPPORT_TRUE@,$GRAPHICS_SUPPORT_TRUE,;t t
     6935s,@GRAPHICS_SUPPORT_FALSE@,$GRAPHICS_SUPPORT_FALSE,;t t
    69106936s,@HERCULES_SUPPORT_TRUE@,$HERCULES_SUPPORT_TRUE,;t t
    69116937s,@HERCULES_SUPPORT_FALSE@,$HERCULES_SUPPORT_FALSE,;t t
    69126938s,@SERIAL_SUPPORT_TRUE@,$SERIAL_SUPPORT_TRUE,;t t
  • configure.ac

    diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
    old new  
    595595  [  --enable-diskless       enable diskless support])
    596596AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" = xyes)
    597597
     598dnl Graphical splashscreen support
     599AC_ARG_ENABLE(graphics,
     600  [  --disable-graphics      disable graphics terminal support])
     601AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" != xno)
     602
    598603dnl Hercules terminal
    599604AC_ARG_ENABLE(hercules,
    600605  [  --disable-hercules      disable hercules terminal support])
  • docs/grub.8

    diff -Naur grub-0.97.orig/docs/grub.8 grub-0.97/docs/grub.8
    old new  
    11.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
    2 .TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF
     2.TH GRUB "8" "September 2005" "grub (GNU GRUB 0.97)" FSF
    33.SH NAME
    44grub \- the grub shell
    55.SH SYNOPSIS
  • docs/grub.texi

    diff -Naur grub-0.97.orig/docs/grub.texi grub-0.97/docs/grub.texi
    old new  
    21992199* rarp::                        Initialize a network device via RARP
    22002200* serial::                      Set up a serial device
    22012201* setkey::                      Configure the key map
     2202* splashimage::                 Use a splash image
    22022203* terminal::                    Choose a terminal
    22032204* terminfo::                    Define escape sequences for a terminal
    22042205* tftpserver::                  Specify a TFTP server
     
    25782579@end deffn
    25792580
    25802581
     2582@node splashimage
     2583@subsection splashimage
     2584
     2585@deffn Command splashimage file
     2586Select an image to use as the background image.  This should be
     2587specified using normal GRUB device naming syntax.  The format of the
     2588file is a gzipped xpm which is 640x480 with a 14 color palette.
     2589@end deffn
     2590
     2591
    25812592@node terminal
    25822593@subsection terminal
    25832594
     
    26852696* module::                      Load a module
    26862697* modulenounzip::               Load a module without decompression
    26872698* pause::                       Wait for a key press
     2699* print::                       Print a message
    26882700* quit::                        Exit from the grub shell
    26892701* reboot::                      Reboot your computer
    26902702* read::                        Read data from memory
     
    30913103@end deffn
    30923104
    30933105
     3106@node print
     3107@subsection print
     3108
     3109@deffn Command print message @dots{}
     3110Print the @var{message}. Note that placing @key{^G} (ASCII code 7) in the
     3111message will cause the speaker to emit the standard beep sound, which is
     3112useful for visually impaired people.
     3113@end deffn
     3114
     3115
    30943116@node quit
    30953117@subsection quit
    30963118
  • docs/multiboot.texi

    diff -Naur grub-0.97.orig/docs/multiboot.texi grub-0.97/docs/multiboot.texi
    old new  
    2525@ifinfo
    2626Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
    2727Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
    28 Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     28Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
    2929
    3030Permission is granted to make and distribute verbatim copies of
    3131this manual provided the copyright notice and this permission notice
     
    5757@vskip 0pt plus 1filll
    5858Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
    5959Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
    60 Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     60Copyright @copyright{} 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
    6161
    6262Permission is granted to make and distribute verbatim copies of
    6363this manual provided the copyright notice and this permission notice
     
    8080@top Multiboot Specification
    8181
    8282This file documents Multiboot Specification, the proposal for the boot
    83 sequence standard. This edition documents version 0.6.93.
     83sequence standard. This edition documents version 0.6.94.
    8484@end ifnottex
    8585
    8686@menu
     
    426426kernel.
    427427
    428428If bit 16 in the @samp{flags} word is set, then the fields at offsets
    429 8-24 in the Multiboot header are valid, and the boot loader should use
     42912-28 in the Multiboot header are valid, and the boot loader should use
    430430them instead of the fields in the actual executable header to calculate
    431431where to load the OS image. This information does not need to be
    432432provided if the kernel image is in @sc{elf} format, but it @emph{must}
     
    677677@example
    678678@group
    679679+-------+-------+-------+-------+
    680 | drive | part1 | part2 | part3 |
     680| part3 | part2 | part1 | drive |
    681681+-------+-------+-------+-------+
    682682@end group
    683683@end example
     
    11991199@email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn.
    12001200@end itemize
    12011201
     1202@item
     1203The byte order of the @samp{boot_device} in Multiboot information is
     1204reversed. This was a mistake.
     1205
     1206@item
     1207The offset of the address fields were wrong.
     1208
    12021209@item 0.6
    12031210@itemize @bullet
    12041211@item
  • grub/asmstub.c

    diff -Naur grub-0.97.orig/grub/asmstub.c grub-0.97/grub/asmstub.c
    old new  
    4242#include <sys/time.h>
    4343#include <termios.h>
    4444#include <signal.h>
     45#include <sys/mman.h>
     46
     47#include <limits.h>
     48#ifndef PAGESIZE
     49#define PAGESIZE 4096
     50#endif
    4551
    4652#ifdef __linux__
    4753# include <sys/ioctl.h>         /* ioctl */
     
    5561# endif /* ! BLKFLSBUF */
    5662#endif /* __linux__ */
    5763
     64#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
     65# include <sys/sysctl.h>
     66#endif
     67
    5868/* We want to prevent any circularararity in our stubs, as well as
    5969   libc name clashes. */
    6070#define WITHOUT_LIBC_STUBS 1
     
    144154  assert (grub_scratch_mem == 0);
    145155  scratch = malloc (0x100000 + EXTENDED_MEMSIZE + 15);
    146156  assert (scratch);
     157
     158  {
     159    char *p;
     160    int ret;
     161
     162    /* Align to a multiple of PAGESIZE, assumed to be a power of two. */
     163    p = (char *) (((long) scratch) & ~(PAGESIZE - 1));
     164
     165    /* The simulated stack needs to be executable, since GCC uses stack
     166     * trampolines to implement nested functions.
     167     */
     168    ret = mprotect (p, 0x100000 + EXTENDED_MEMSIZE + 15,
     169                    PROT_READ | PROT_WRITE | PROT_EXEC);
     170    assert (ret == 0);
     171  }
     172
    147173  grub_scratch_mem = (char *) ((((int) scratch) >> 4) << 4);
    148174
    149175  /* FIXME: simulate the memory holes using mprot, if available. */
     
    777803
    778804      /* Open read/write, or read-only if that failed. */
    779805      if (! read_only)
    780         disks[drive].flags = open (devname, O_RDWR);
     806        {
     807/* By default, kernel of FreeBSD does not allow overwriting MBR */
     808#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
     809#define GEOM_SYSCTL     "kern.geom.debugflags"
     810          int old_flags, flags;
     811          size_t sizeof_int = sizeof (int);
     812
     813          if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0)
     814            grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
     815
     816          if ((old_flags & 0x10) == 0)
     817            {
     818              /* "allow foot shooting", see geom(4) */
     819              flags = old_flags | 0x10;
     820
     821              if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0)
     822                {
     823                  flags = old_flags;
     824                  grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
     825                }
     826            }
     827          else
     828            flags = old_flags;
     829#endif
     830          disks[drive].flags = open (devname, O_RDWR);
     831#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
     832          if (flags != old_flags)
     833            {
     834              if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0)
     835                grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
     836            }
     837#endif
     838        }
    781839
    782840      if (disks[drive].flags == -1)
    783841        {
  • grub/main.c

    diff -Naur grub-0.97.orig/grub/main.c grub-0.97/grub/main.c
    old new  
    3232#define WITHOUT_LIBC_STUBS 1
    3333#include <shared.h>
    3434#include <term.h>
     35#include <device.h>
    3536
    3637char *program_name = 0;
    3738int use_config_file = 1;
     
    192193              perror ("strtoul");
    193194              exit (1);
    194195            }
     196          if (boot_drive >= NUM_DISKS)
     197            {
     198              fprintf (stderr, "boot_drive should be from 0 to %d\n",
     199                       NUM_DISKS - 1);
     200              exit (1);
     201            }
    195202          break;
    196203
    197204        case OPT_NO_CONFIG_FILE:
  • lib/device.c

    diff -Naur grub-0.97.orig/lib/device.c grub-0.97/lib/device.c
    old new  
    131131#include <shared.h>
    132132#include <device.h>
    133133
     134#if defined(__linux__)
     135/* The 2.6 kernel has removed all of the geometry handling for IDE drives
     136 * that did fixups for LBA, etc.  This means that the geometry we get
     137 * with the ioctl has a good chance of being wrong.  So, we get to
     138 * also know about partition tables and try to read what the geometry
     139 * is there. *grumble*   Very closely based on code from cfdisk
     140 */
     141static void get_kernel_geometry(int fd, long long *cyl, int *heads, int *sectors) {
     142    struct hd_geometry hdg;
     143   
     144    if (ioctl (fd, HDIO_GETGEO, &hdg))
     145        return;
     146
     147    *cyl = hdg.cylinders;
     148    *heads = hdg.heads;
     149    *sectors = hdg.sectors;
     150}
     151
     152struct partition {
     153        unsigned char boot_ind;         /* 0x80 - active */
     154        unsigned char head;             /* starting head */
     155        unsigned char sector;           /* starting sector */
     156        unsigned char cyl;              /* starting cylinder */
     157        unsigned char sys_ind;          /* What partition type */
     158        unsigned char end_head;         /* end head */
     159        unsigned char end_sector;       /* end sector */
     160        unsigned char end_cyl;          /* end cylinder */
     161        unsigned char start4[4];        /* starting sector counting from 0 */
     162        unsigned char size4[4];         /* nr of sectors in partition */
     163};
     164
     165#define ALIGNMENT 2
     166typedef union {
     167    struct {
     168        unsigned char align[ALIGNMENT];
     169        unsigned char b[SECTOR_SIZE];
     170    } c;
     171    struct {
     172        unsigned char align[ALIGNMENT];
     173        unsigned char buffer[0x1BE];
     174        struct partition part[4];
     175        unsigned char magicflag[2];
     176    } p;
     177} partition_table;
     178
     179#define PART_TABLE_FLAG0 0x55
     180#define PART_TABLE_FLAG1 0xAA
     181
     182static void
     183get_partition_table_geometry(partition_table *bufp, long long *cyl, int *heads,
     184                             int *sectors) {
     185    struct partition *p;
     186    int i,h,s,hh,ss;
     187    int first = 1;
     188    int bad = 0;
     189
     190    if (bufp->p.magicflag[0] != PART_TABLE_FLAG0 ||
     191        bufp->p.magicflag[1] != PART_TABLE_FLAG1) {
     192            /* Matthew Wilcox: slightly friendlier version of
     193               fatal(_("Bad signature on partition table"), 3);
     194            */
     195            fprintf(stderr, "Unknown partition table signature\n");
     196            return;
     197    }
     198
     199    hh = ss = 0;
     200    for (i=0; i<4; i++) {
     201        p = &(bufp->p.part[i]);
     202        if (p->sys_ind != 0) {
     203            h = p->end_head + 1;
     204            s = (p->end_sector & 077);
     205            if (first) {
     206                hh = h;
     207                ss = s;
     208                first = 0;
     209            } else if (hh != h || ss != s)
     210                bad = 1;
     211        }
     212    }
     213
     214    if (!first && !bad) {
     215        *heads = hh;
     216        *sectors = ss;
     217    }
     218}
     219
     220static long long my_lseek (unsigned int fd, long long offset,
     221                           unsigned int origin)
     222{
     223#if defined(__linux__) && (!defined(__GLIBC__) || \
     224        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
     225  /* Maybe libc doesn't have large file support.  */
     226  loff_t offset, result;
     227  static int _llseek (uint filedes, ulong hi, ulong lo,
     228                      loff_t *res, uint wh);
     229  _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
     230             loff_t *, res, uint, wh);
     231 
     232  if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET) < 0)
     233    return (long long) -1;
     234  return result;
     235#else
     236  return lseek(fd, offset, SEEK_SET);
     237#endif
     238}
     239
     240static void get_linux_geometry (int fd, struct geometry *geom) {
     241    long long kern_cyl = 0; int kern_head = 0, kern_sectors = 0;
     242    long long pt_cyl = 0; int pt_head = 0, pt_sectors = 0;
     243    partition_table bufp;
     244    char *buff, *buf_unaligned;
     245
     246    buf_unaligned = malloc(sizeof(partition_table) + 4095);
     247    buff = (char *) (((unsigned long)buf_unaligned + 4096 - 1) &
     248                     (~(4096-1)));
     249
     250    get_kernel_geometry(fd, &kern_cyl, &kern_head, &kern_sectors);
     251
     252    if (my_lseek (fd, 0*SECTOR_SIZE, SEEK_SET) < 0) {
     253        fprintf(stderr, "Unable to seek");
     254    }
     255
     256    if (read(fd, buff, SECTOR_SIZE) == SECTOR_SIZE) {
     257        memcpy(bufp.c.b, buff, SECTOR_SIZE);
     258        get_partition_table_geometry(&bufp, &pt_cyl, &pt_head, &pt_sectors);
     259    } else {
     260        fprintf(stderr, "Unable to read partition table: %s\n", strerror(errno));
     261    }
     262
     263    if (pt_head && pt_sectors) {
     264        int cyl_size;
     265
     266        geom->heads = pt_head;
     267        geom->sectors = pt_sectors;
     268        cyl_size = pt_head * pt_sectors;
     269        geom->cylinders = geom->total_sectors/cyl_size;
     270    } else {
     271        geom->heads = kern_head;
     272        geom->sectors = kern_sectors;
     273        geom->cylinders = kern_cyl;
     274    }
     275
     276    return;
     277}
     278#endif
     279
    134280/* Get the geometry of a drive DRIVE.  */
    135281void
    136282get_drive_geometry (struct geometry *geom, char **map, int drive)
     
    151297#if defined(__linux__)
    152298  /* Linux */
    153299  {
    154     struct hd_geometry hdg;
    155300    unsigned long nr;
    156    
    157     if (ioctl (fd, HDIO_GETGEO, &hdg))
    158       goto fail;
    159301
    160302    if (ioctl (fd, BLKGETSIZE, &nr))
    161303      goto fail;
    162304   
    163305    /* Got the geometry, so save it. */
    164     geom->cylinders = hdg.cylinders;
    165     geom->heads = hdg.heads;
    166     geom->sectors = hdg.sectors;
    167306    geom->total_sectors = nr;
    168    
     307    get_linux_geometry(fd, geom);
     308    if (!geom->heads && !geom->cylinders && !geom->sectors)
     309        goto fail;
    169310    goto success;
    170311  }
    171312
     
    403544}
    404545
    405546static void
     547get_cciss_disk_name (char *name, int controller, int drive)
     548{
     549  sprintf (name, "/dev/cciss/c%dd%d", controller, drive);
     550}
     551
     552static void
     553get_ida_disk_name (char *name, int controller, int drive)
     554{
     555  sprintf (name, "/dev/ida/c%dd%d", controller, drive);
     556}
     557
     558static void
    406559get_ataraid_disk_name (char *name, int unit)
    407560{
    408561  sprintf (name, "/dev/ataraid/d%c", unit + '0');
     
    801954          }
    802955      }
    803956  }
     957
     958  /* This is for CCISS, its like the DAC960  - we have
     959     /dev/cciss/<controller>d<logical drive>p<partition>
     960
     961     It currently supports up to 3 controllers, 10 logical volumes
     962     and 10 partitions
     963
     964     Code gratuitously copied from DAC960 above.
     965     Horms <horms@verge.net.au> 23rd July 2004
     966  */
     967  {
     968    int controller, drive;
     969   
     970    for (controller = 0; controller < 2; controller++)
     971      {
     972        for (drive = 0; drive < 9; drive++)
     973          {
     974            char name[24];
     975           
     976            get_cciss_disk_name (name, controller, drive);
     977            if (check_device (name))
     978              {
     979                (*map)[num_hd + 0x80] = strdup (name);
     980                assert ((*map)[num_hd + 0x80]);
     981               
     982                /* If the device map file is opened, write the map.  */
     983                if (fp)
     984                  fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
     985               
     986                num_hd++;
     987              }
     988          }
     989      }
     990  }
     991
     992  /* This is for Compaq Smart Array, its like the DAC960  - we have
     993     /dev/ida/<controller>d<logical drive>p<partition>
     994
     995     It currently supports up to 3 controllers, 10 logical volumes
     996     and 15 partitions
     997
     998     Code gratuitously copied from DAC960 above.
     999     Piotr Roszatycki <dexter@debian.org>
     1000  */
     1001  {
     1002    int controller, drive;
     1003   
     1004    for (controller = 0; controller < 2; controller++)
     1005      {
     1006        for (drive = 0; drive < 9; drive++)
     1007          {
     1008            char name[24];
     1009           
     1010            get_ida_disk_name (name, controller, drive);
     1011            if (check_device (name))
     1012              {
     1013                (*map)[num_hd + 0x80] = strdup (name);
     1014                assert ((*map)[num_hd + 0x80]);
     1015               
     1016                /* If the device map file is opened, write the map.  */
     1017                if (fp)
     1018                  fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
     1019               
     1020                num_hd++;
     1021              }
     1022          }
     1023      }
     1024  }
    8041025#endif /* __linux__ */
    8051026 
    8061027  /* OK, close the device map file if opened.  */
     
    8441065{
    8451066  char dev[PATH_MAX];   /* XXX */
    8461067  int fd;
     1068  off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
    8471069 
    8481070  if ((partition & 0x00FF00) != 0x00FF00)
    8491071    {
     
    8611083      if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
    8621084        strcpy (dev + strlen(dev) - 5, "/part");
    8631085    }
    864   sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
    865  
     1086  sprintf (dev + strlen(dev), "%s%d",
     1087   /* Compaq smart and others */
     1088   (strncmp(dev, "/dev/ida/", 9) == 0 ||
     1089   strncmp(dev, "/dev/ataraid/", 13) == 0 ||
     1090   strncmp(dev, "/dev/cciss/", 11) == 0 ||
     1091   strncmp(dev, "/dev/rd/", 8) == 0) ? "p" : "",
     1092   ((partition >> 16) & 0xFF) + 1);
     1093
    8661094  /* Open the partition.  */
    8671095  fd = open (dev, O_RDWR);
    8681096  if (fd < 0)
     
    8701098      errnum = ERR_NO_PART;
    8711099      return 0;
    8721100    }
    873  
    874 #if defined(__linux__) && (!defined(__GLIBC__) || \
    875         ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
    876   /* Maybe libc doesn't have large file support.  */
    877   {
    878     loff_t offset, result;
    879     static int _llseek (uint filedes, ulong hi, ulong lo,
    880                         loff_t *res, uint wh);
    881     _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
    882                loff_t *, res, uint, wh);
    8831101
    884     offset = (loff_t) sector * (loff_t) SECTOR_SIZE;
    885     if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
    886       {
    887         errnum = ERR_DEV_VALUES;
    888         return 0;
    889       }
    890   }
    891 #else
    892   {
    893     off_t offset = (off_t) sector * (off_t) SECTOR_SIZE;
    8941102
    895     if (lseek (fd, offset, SEEK_SET) != offset)
    896       {
    897         errnum = ERR_DEV_VALUES;
    898         return 0;
    899       }
    900   }
    901 #endif
     1103  if (my_lseek(fd, offset, SEEK_SET) != offset)
     1104    {
     1105      errnum = ERR_DEV_VALUES;
     1106      return 0;
     1107    }
    9021108 
    9031109  if (write (fd, buf, size * SECTOR_SIZE) != (size * SECTOR_SIZE))
    9041110    {
  • stage2/asm.S

    diff -Naur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S
    old new  
    16511651        jnz     3f
    16521652        ret
    16531653
    1654 3:      /* use keyboard controller */
     16543:      /*
     1655         * try to switch gateA20 using PORT92, the "Fast A20 and Init"
     1656         * register
     1657        */
     1658        mov $0x92, %dx
     1659        inb %dx, %al
     1660        /* skip the port92 code if it's unimplemented (read returns 0xff) */
     1661        cmpb $0xff, %al
     1662        jz 6f
     1663       
     1664        /* set or clear bit1, the ALT_A20_GATE bit */
     1665        movb 4(%esp), %ah
     1666        testb %ah, %ah
     1667        jz 4f
     1668        orb $2, %al
     1669        jmp 5f
     16704:      and $0xfd, %al
     1671       
     1672        /* clear the INIT_NOW bit don't accidently reset the machine */
     16735:      and $0xfe, %al
     1674        outb %al, %dx
     1675       
     16766:      /* use keyboard controller */
    16551677        pushl   %eax
    16561678
    16571679        call    gloop1
     
    16611683
    16621684gloopint1:
    16631685        inb     $K_STATUS
     1686        cmpb    $0xff, %al
     1687        jz      gloopint1_done
    16641688        andb    $K_IBUF_FUL, %al
    16651689        jnz     gloopint1
    16661690
     1691gloopint1_done:
    16671692        movb    $KB_OUTPUT_MASK, %al
    16681693        cmpb    $0, 0x8(%esp)
    16691694        jz      gdoit
     
    16841709
    16851710gloop1:
    16861711        inb     $K_STATUS
     1712        cmpb    $0xff, %al
     1713        jz      gloop2ret
    16871714        andb    $K_IBUF_FUL, %al
    16881715        jnz     gloop1
    16891716
     
    19912018ENTRY(console_getkey)
    19922019        push    %ebp
    19932020
     2021wait_for_key:
     2022        call    EXT_C(console_checkkey)
     2023        incl    %eax
     2024        jz      wait_for_key
     2025       
    19942026        call    EXT_C(prot_to_real)
    19952027        .code16
    19962028
     
    22162248        pop     %ebx
    22172249        pop     %ebp
    22182250        ret
    2219                
     2251
     2252
     2253/* graphics mode functions */
     2254#ifdef SUPPORT_GRAPHICS
     2255VARIABLE(cursorX)
     2256.word   0
     2257VARIABLE(cursorY)
     2258.word   0
     2259VARIABLE(cursorCount)
     2260.word 0
     2261VARIABLE(cursorBuf)
     2262.byte   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     2263
     2264
     2265/*
     2266 * set_int1c_handler(void)
     2267 */
     2268ENTRY(set_int1c_handler)
     2269        pushl   %edi
     2270
     2271        /* save the original int1c handler */
     2272        movl    $0x70, %edi
     2273        movw    (%edi), %ax
     2274        movw    %ax, ABS(int1c_offset)
     2275        movw    2(%edi), %ax
     2276        movw    %ax, ABS(int1c_segment)
     2277
     2278        /* save the new int1c handler */
     2279        movw    $ABS(int1c_handler), %ax
     2280        movw    %ax, (%edi)
     2281        xorw    %ax, %ax
     2282        movw    %ax, 2(%edi)
     2283
     2284        popl    %edi
     2285        ret
     2286
     2287
     2288/*
     2289 * unset_int1c_handler(void)
     2290 */
     2291ENTRY(unset_int1c_handler)
     2292        pushl   %edi
     2293
     2294        /* check if int1c_handler is set */
     2295        movl    $0x70, %edi
     2296        movw    $ABS(int1c_handler), %ax
     2297        cmpw    %ax, (%edi)
     2298        jne     int1c_1
     2299        xorw    %ax, %ax
     2300        cmpw    %ax, 2(%edi)
     2301        jne     int1c_1
     2302
     2303        /* restore the original */
     2304        movw    ABS(int1c_offset), %ax
     2305        movw    %ax, (%edi)
     2306        movw    ABS(int1c_segment), %ax
     2307        movw    %ax, 2(%edi)
     2308
     2309int1c_1:
     2310        popl    %edi
     2311        ret
     2312
     2313
     2314/*
     2315 * blinks graphics cursor
     2316 */
     2317        .code16
     2318write_data:
     2319        movw    $0, %ax
     2320        movw    %ax, %ds
     2321
     2322        mov     $0xA000, %ax            /* video in es:di */
     2323        mov     %ax, %es
     2324        mov     $80, %ax
     2325        movw    $ABS(cursorY), %si
     2326        mov     %ds:(%si), %bx
     2327        mul     %bx
     2328        movw    $ABS(cursorX), %si
     2329        mov     %ds:(%si), %bx
     2330        shr     $3, %bx                 /* %bx /= 8 */
     2331        add     %bx, %ax
     2332        mov     %ax, %di
     2333
     2334        movw    $ABS(cursorBuf), %si    /* fontBuf in ds:si */
     2335
     2336        /* prepare for data moving */
     2337        mov     $16, %dx                /* altura da fonte */
     2338        mov     $80, %bx                /* bytes por linha */
     2339
     2340write_loop:
     2341        movb    %ds:(%si), %al
     2342        xorb    $0xff, %al
     2343        movb    %al, %ds:(%si)          /* invert cursorBuf */
     2344        movb    %al, %es:(%di)          /* write to video */
     2345        add     %bx, %di
     2346        inc     %si
     2347        dec     %dx
     2348        jg      write_loop
     2349        ret
     2350
     2351int1c_handler:
     2352        pusha
     2353        mov     $0, %ax
     2354        mov     %ax, %ds
     2355        mov     $ABS(cursorCount), %si
     2356        mov     %ds:(%si), %ax
     2357        inc     %ax
     2358        mov     %ax, %ds:(%si)
     2359        cmp     $9, %ax
     2360        jne     int1c_done
     2361
     2362        mov     $0, %ax
     2363        mov     %ax, %ds:(%si)
     2364        call    write_data
     2365
     2366int1c_done:
     2367        popa
     2368        iret
     2369        /* call previous int1c handler */
     2370        /* ljmp */
     2371        .byte   0xea
     2372int1c_offset:  .word   0
     2373int1c_segment: .word   0
     2374        .code32
     2375
     2376
     2377/*
     2378 * unsigned char set_videomode(unsigned char mode)
     2379 * BIOS call "INT 10H Function 0h" to set video mode
     2380 *      Call with       %ah = 0x0
     2381 *                      %al = video mode
     2382 *  Returns old videomode.
     2383 */
     2384ENTRY(set_videomode)
     2385        pushl   %ebp
     2386        movl    %esp,%ebp
     2387        pushl   %ebx
     2388        pushl   %ecx
     2389
     2390        movb    8(%ebp), %cl
     2391
     2392        call    EXT_C(prot_to_real)
     2393        .code16
     2394
     2395        xorb    %al, %al
     2396        movb    $0xf, %ah
     2397        int     $0x10                   /* Get Current Video mode */
     2398        movb    %al, %ch
     2399        xorb    %ah, %ah
     2400        movb    %cl, %al
     2401        int     $0x10                   /* Set Video mode */
     2402
     2403        DATA32  call    EXT_C(real_to_prot)
     2404        .code32
     2405
     2406        xorl    %eax, %eax
     2407        movb    %ch, %al
     2408
     2409        popl    %ecx
     2410        popl    %ebx
     2411        popl    %ebp
     2412        ret
     2413
     2414
     2415/*
     2416 * int get_videomode()
     2417 * BIOS call "INT 10H Function 0Fh" to get current video mode
     2418 *      Call with       %al = 0x0
     2419 *                      %ah = 0xF
     2420 *      Returns current videomode.
     2421 */
     2422ENTRY(get_videomode)
     2423        pushl   %ebp
     2424        movl    %esp,%ebp
     2425        pushl   %ebx
     2426        pushl   %ecx
     2427
     2428        call    EXT_C(prot_to_real)
     2429        .code16
     2430
     2431        xorb    %al, %al
     2432        movb    $0xF, %ah
     2433        int     $0x10                   /* Get Current Video mode */
     2434        movb    %al, %cl        /* For now we only want display mode */
     2435
     2436        DATA32  call    EXT_C(real_to_prot)
     2437        .code32
     2438
     2439        xorl    %eax, %eax
     2440        movb    %cl, %al
     2441
     2442        popl    %ecx
     2443        popl    %ebx
     2444        popl    %ebp
     2445        ret
     2446
     2447
     2448/*
     2449 * unsigned char * graphics_get_font()
     2450 * BIOS call "INT 10H Function 11h" to set font
     2451 *      Call with       %ah = 0x11
     2452 */
     2453ENTRY(graphics_get_font)
     2454        push    %ebp
     2455        push    %ebx
     2456        push    %ecx
     2457        push    %edx
     2458
     2459        call    EXT_C(prot_to_real)
     2460        .code16
     2461
     2462        movw    $0x1130, %ax
     2463        movb    $6, %bh         /* font 8x16 */
     2464        int     $0x10
     2465        movw    %bp, %dx
     2466        movw    %es, %cx
     2467
     2468        DATA32  call    EXT_C(real_to_prot)
     2469        .code32
     2470
     2471        xorl    %eax, %eax
     2472        movw    %cx, %ax
     2473        shll    $4, %eax
     2474        movw    %dx, %ax
     2475
     2476        pop     %edx
     2477        pop     %ecx
     2478        pop     %ebx
     2479        pop     %ebp
     2480        ret
     2481
     2482
     2483/*
     2484 * graphics_set_palette(index, red, green, blue)
     2485 * BIOS call "INT 10H Function 10h" to set individual dac register
     2486 *      Call with       %ah = 0x10
     2487 *                      %bx = register number
     2488 *                      %ch = new value for green (0-63)
     2489 *                      %cl = new value for blue (0-63)
     2490 *                      %dh = new value for red (0-63)
     2491 */
     2492
     2493ENTRY(graphics_set_palette)
     2494        push    %ebp
     2495        push    %eax
     2496        push    %ebx
     2497        push    %ecx
     2498        push    %edx
     2499
     2500        movw    $0x3c8, %bx             /* address write mode register */
     2501
     2502        /* wait vertical retrace */
     2503        movw    $0x3da, %dx
     2504l1b:
     2505        inb     %dx, %al        /* wait vertical active display */
     2506        test    $8, %al
     2507        jnz     l1b
     2508
     2509l2b:
     2510        inb     %dx, %al        /* wait vertical retrace */
     2511        test    $8, %al
     2512        jnz     l2b
     2513
     2514        mov     %bx, %dx
     2515        movb    0x18(%esp), %al         /* index */
     2516        outb    %al, %dx
     2517        inc     %dx
     2518
     2519        movb    0x1c(%esp), %al         /* red */
     2520        outb    %al, %dx
     2521
     2522        movb    0x20(%esp), %al         /* green */
     2523        outb    %al, %dx
     2524
     2525        movb    0x24(%esp), %al         /* blue */
     2526        outb    %al, %dx
     2527
     2528        movw    0x18(%esp), %bx
     2529
     2530        call    EXT_C(prot_to_real)
     2531        .code16
     2532
     2533        movb    %bl, %bh
     2534        movw    $0x1000, %ax
     2535        int     $0x10
     2536
     2537        DATA32  call    EXT_C(real_to_prot)
     2538        .code32
     2539
     2540        pop     %edx
     2541        pop     %ecx
     2542        pop     %ebx
     2543        pop     %eax
     2544        pop     %ebp
     2545        ret
     2546#endif /* SUPPORT_GRAPHICS */
     2547
     2548
    22202549/*
    22212550 * getrtsecs()
    22222551 *      if a seconds value can be read, read it and return it (BCD),
  • stage2/boot.c

    diff -Naur grub-0.97.orig/stage2/boot.c grub-0.97/stage2/boot.c
    old new  
    11/* boot.c - load and bootstrap a kernel */
    22/*
    33 *  GRUB  --  GRand Unified Bootloader
    4  *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
     4 *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005  Free Software Foundation, Inc.
    55 *
    66 *  This program is free software; you can redistribute it and/or modify
    77 *  it under the terms of the GNU General Public License as published by
     
    2929entry_func entry_addr;
    3030static struct mod_list mll[99];
    3131static int linux_mem_size;
     32static int elf_kernel_addr;
     33static int elf_kernel_size;
    3234
    3335/*
    3436 *  The next two functions, 'load_image' and 'load_module', are the building
     
    9698  lh = (struct linux_kernel_header *) buffer;
    9799 
    98100  /* ELF loading supported if multiboot, FreeBSD and NetBSD.  */
    99   if ((type == KERNEL_TYPE_MULTIBOOT
     101  if (((type == KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KLUDGE))
    100102       || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD
    101103       || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0
    102104       || suggested_type == KERNEL_TYPE_NETBSD)
     
    594596
    595597      /* reset this to zero for now */
    596598      cur_addr = 0;
     599      elf_kernel_addr = ~0;
    597600
    598601      /* scan for program segments */
    599602      for (i = 0; i < pu.elf->e_phnum; i++)
     
    630633              /* mark memory as used */
    631634              if (cur_addr < memaddr + memsiz)
    632635                cur_addr = memaddr + memsiz;
     636              if (elf_kernel_addr > cur_addr)
     637                elf_kernel_addr = cur_addr;
    633638              printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
    634639                      memsiz - filesiz);
    635640              /* increment number of segments */
     
    647652            }
    648653        }
    649654
     655      elf_kernel_size = cur_addr - elf_kernel_addr;
     656
    650657      if (! errnum)
    651658        {
    652659          if (! loaded)
     
    824831    moveto = (mbi.mem_upper + 0x400) << 10;
    825832 
    826833  moveto = (moveto - len) & 0xfffff000;
    827   max_addr = (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0203
    828               ? lh->initrd_addr_max : LINUX_INITRD_MAX_ADDRESS);
     834  max_addr = LINUX_INITRD_MAX_ADDRESS;
     835  if (lh->header == LINUX_MAGIC_SIGNATURE &&
     836      lh->version >= 0x0203 &&
     837      lh->initrd_addr_max < max_addr)
     838    max_addr = lh->initrd_addr_max;
    829839  if (moveto + len >= max_addr)
    830840    moveto = (max_addr - len) & 0xfffff000;
    831841 
     
    864874}
    865875#endif
    866876
     877#define mem_align4k(p)  ((p) + 0xFFF) & 0xFFFFF000
     878
     879static void
     880kfreebsd_setenv (char *env, const char *var, const char *value)
     881{
     882  while (1)
     883    {
     884      if (env[0] == '\0' && env[1] == '\0')
     885        {
     886          env++;
     887          break;
     888        }
     889      else
     890        env++;
     891    }
     892
     893  grub_sprintf (env, "%s=%s", var, value);
     894  env[grub_strlen (env) + 1] = '\0';
     895}
     896
     897static char *
     898kfreebsd_read_hints (char *buf)
     899{
     900  char *buf_end = buf;
     901
     902  if (grub_open ("/boot/device.hints"))
     903    {
     904      char *line_start;
     905      int line_len = 0;
     906      char *envp;
     907      int env_len;
     908
     909      env_len = grub_read (buf, -1);
     910      if (env_len)
     911        {
     912          buf_end += env_len;
     913          *(buf_end++) = '\0';
     914        }
     915      else
     916        return buf_end;
     917
     918      grub_close ();
     919
     920      envp = line_start = buf;
     921      while (*envp)
     922        {
     923          char *envp_current = envp;
     924       
     925          switch (*envp)
     926            {
     927              case ' ':
     928                while (*envp == ' ')
     929                  {
     930                    envp++;
     931                    env_len--;
     932                  }
     933                grub_memmove (envp_current, envp, env_len + 1);
     934                envp = envp_current;
     935                break;
     936              case '#':
     937                while (*envp != '\n')
     938                  {
     939                    envp++;
     940                    env_len--;
     941                  }
     942                if (!line_len)
     943                  envp++;
     944                grub_memmove (envp_current, envp, env_len + 1);
     945                envp = envp_current;
     946                break;
     947              case '\n':
     948                if (!line_len)
     949                  {
     950                    env_len--;
     951                    grub_memmove (line_start, envp, env_len + 1);
     952                  }
     953                *(envp++) = '\0';
     954                line_len = 0;
     955                line_start = envp;
     956              default:
     957                envp++;
     958                line_len++;
     959                break;
     960            }
     961        }
     962
     963      buf_end = buf + env_len;
     964      *(buf_end++) = '\0';
     965    }
     966
     967  return buf_end;
     968}
     969
     970static u32_t *
     971kfreebsd_set_module_string (u32_t type, u32_t *dst, char *src)
     972{
     973  int size;
     974
     975  *(dst++) = type;
     976  *(dst++) = size = grub_strlen (src) + 1;
     977  grub_strcpy ((void *) dst, src);
     978
     979  return dst + (size + sizeof(u32_t) - 1) / sizeof(u32_t);
     980}
     981
     982static u32_t *
     983kfreebsd_set_module_var (u32_t type, u32_t *dst, u32_t src)
     984{
     985  *(dst++) = type;
     986  *(dst++) = sizeof(u32_t);
     987  *(dst++) = src;
     988
     989  return dst;
     990}
     991
     992static u32_t *
     993kfreebsd_set_modules (u32_t *modulep)
     994{
     995  /* XXX: Need to copy the whole module structure.  */
     996  /* XXX: How to pass the module name ?  */
     997
     998  return modulep;
     999}
    8671000
    8681001/*
    8691002 *  All "*_boot" commands depend on the images being loaded into memory
     
    8771010bsd_boot (kernel_t type, int bootdev, char *arg)
    8781011{
    8791012  char *str;
    880   int clval = 0, i;
     1013  char *kernelname;
     1014  char *bsd_root;
     1015  int clval = 0;
     1016  int i;
    8811017  struct bootinfo bi;
    8821018
    8831019#ifdef GRUB_UTIL
     
    8861022  stop_floppy ();
    8871023#endif
    8881024
     1025  while (*arg != '/')
     1026    arg++;
     1027  kernelname = arg;
     1028
    8891029  while (*(++arg) && *arg != ' ');
     1030  *(arg++) = 0;
    8901031  str = arg;
     1032
     1033  bsd_root = grub_strstr (str, "root=");
     1034  if (bsd_root)
     1035    {
     1036      bsd_root += 5;
     1037      /* XXX: should copy the str or terminate it.  */
     1038    }
     1039
    8911040  while (*str)
    8921041    {
    8931042      if (*str == '-')
     
    9101059                clval |= RB_GDB;
    9111060              if (*str == 'h')
    9121061                clval |= RB_SERIAL;
     1062              if (*str == 'p')
     1063                clval |= RB_PAUSE;
    9131064              if (*str == 'm')
    9141065                clval |= RB_MUTE;
    9151066              if (*str == 'r')
     
    9271078
    9281079  if (type == KERNEL_TYPE_FREEBSD)
    9291080    {
     1081      char *envp;
     1082      u32_t *modp;
     1083
    9301084      clval |= RB_BOOTINFO;
    9311085
    9321086      bi.bi_version = BOOTINFO_VERSION;
    9331087
    934       *arg = 0;
    935       while ((--arg) > (char *) MB_CMDLINE_BUF && *arg != '/');
    936       if (*arg == '/')
    937         bi.bi_kernelname = arg + 1;
     1088      bi.bi_pad[0] = bi.bi_pad[1] = 0;
     1089
     1090      if (*kernelname == '/')
     1091        bi.bi_kernelname = kernelname;
    9381092      else
    9391093        bi.bi_kernelname = 0;
    9401094
     
    9611115      bi.bi_basemem = mbi.mem_lower;
    9621116      bi.bi_extmem = extended_memory;
    9631117
     1118      /* Setup the environment.  */
     1119      bi.bi_envp = cur_addr = mem_align4k (cur_addr);
     1120      grub_memset ((void *) cur_addr, 0, 2);
     1121      cur_addr = (int) kfreebsd_read_hints ((void *) cur_addr);
     1122
     1123      envp = (char *) bi.bi_envp;
     1124      kfreebsd_setenv (envp, "kernelname", kernelname);
     1125      kfreebsd_setenv (envp, "vfs.root.mountfrom", bsd_root);
     1126
     1127      /* Setup the modules list.  */
     1128      bi.bi_modulep = cur_addr = mem_align4k (cur_addr);
     1129      modp = (u32_t *) bi.bi_modulep;
     1130      /* The first module is the kernel.  */
     1131      modp = kfreebsd_set_module_string (MODINFO_NAME, modp, kernelname);
     1132      modp = kfreebsd_set_module_string (MODINFO_TYPE, modp, "elf kernel");
     1133      modp = kfreebsd_set_module_string (MODINFO_ARGS, modp, arg);
     1134      modp = kfreebsd_set_module_var (MODINFO_ADDR, modp, elf_kernel_addr);
     1135      modp = kfreebsd_set_module_var (MODINFO_SIZE, modp, elf_kernel_size);
     1136      /* Now the real modules.  */
     1137      modp = kfreebsd_set_modules(modp);
     1138
     1139      /* Set the kernel end.  */
     1140      bi.bi_kernend = cur_addr = mem_align4k (((int) modp) + 1);
     1141
    9641142      if (mbi.flags & MB_INFO_AOUT_SYMS)
    9651143        {
    9661144          bi.bi_symtab = mbi.syms.a.addr;
     
    9701148#if 0
    9711149      else if (mbi.flags & MB_INFO_ELF_SHDR)
    9721150        {
    973           /* FIXME: Should check if a symbol table exists and, if exists,
    974              pass the table to BI.  */
     1151          bi.bi_symtab = mbi.syms.e.addr;
     1152          bi.bi_esymtab = mbi.syms.e.addr
     1153            + mbi.syms.e.size * mbi.syms.e.num * mbi.syms.e.shndx;
    9751154        }
    9761155#endif
    9771156      else
  • stage2/builtins.c

    diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c
    old new  
    2828#include <filesys.h>
    2929#include <term.h>
    3030
     31#ifdef SUPPORT_GRAPHICS
     32# include <graphics.h>
     33#endif
     34
    3135#ifdef SUPPORT_NETBOOT
    3236# define GRUB   1
    3337# include <etherboot.h>
     
    8286   inside other functions.  */
    8387static int configfile_func (char *arg, int flags);
    8488
     89static int savedefault_helper (char *arg, int flags);
     90
     91static int savedefault_shell (char *arg, int flags);
     92
    8593/* Initialize the data for builtins.  */
    8694void
    8795init_builtins (void)
     
    237245static int
    238246boot_func (char *arg, int flags)
    239247{
     248  struct term_entry *prev_term = current_term;
    240249  /* Clear the int15 handler if we can boot the kernel successfully.
    241250     This assumes that the boot code never fails only if KERNEL_TYPE is
    242251     not KERNEL_TYPE_NONE. Is this assumption is bad?  */
    243252  if (kernel_type != KERNEL_TYPE_NONE)
    244253    unset_int15_handler ();
    245254
     255  /* if our terminal needed initialization, we should shut it down
     256   * before booting the kernel, but we want to save what it was so
     257   * we can come back if needed */
     258  if (current_term->shutdown)
     259    {
     260      current_term->shutdown();
     261      current_term = term_table; /* assumption: console is first */
     262    }
     263
    246264#ifdef SUPPORT_NETBOOT
    247265  /* Shut down the networking.  */
    248266  cleanup_net ();
     
    306324      return 1;
    307325    }
    308326
     327  /* if we get back here, we should go back to what our term was before */
     328  current_term = prev_term;
     329  if (current_term->startup)
     330      /* if our terminal fails to initialize, fall back to console since
     331       * it should always work */
     332      if (current_term->startup() == 0)
     333          current_term = term_table; /* we know that console is first */
    309334  return 0;
    310335}
    311336
     
    852877};
    853878#endif /* SUPPORT_NETBOOT */
    854879
     880#ifdef SUPPORT_GRAPHICS
     881
    855882
     883static int splashimage_func(char *arg, int flags) {
     884  int i;
     885   
     886  /* filename can only be 256 characters due to our buffer size */
     887  if (grub_strlen(arg) > 256) {
     888    grub_printf("Splash image filename too large\n");
     889    grub_printf("Press any key to continue...");
     890    getkey();
     891    return 1;
     892  }
     893
     894  /* get rid of TERM_NEED_INIT from the graphics terminal. */
     895  for (i = 0; term_table[i].name; i++) {
     896    if (grub_strcmp (term_table[i].name, "graphics") == 0) {
     897      term_table[i].flags &= ~TERM_NEED_INIT;
     898      break;
     899    }
     900  }
     901
     902  graphics_set_splash(arg);
     903
     904  if (flags == BUILTIN_CMDLINE && graphics_inited) {
     905    graphics_end();
     906    if (graphics_init() == 0) {
     907      /* Fallback to default term */
     908      current_term = term_table;
     909      max_lines = current_term->max_lines;
     910      if (current_term->cls)
     911        current_term->cls();
     912      grub_printf("Failed to set splash image and/or graphics mode\n");
     913      return 1;
     914    }
     915    graphics_cls();
     916  }
     917
     918  if (flags == BUILTIN_MENU)
     919    current_term = term_table + i;
     920
     921  return 0;
     922}
     923
     924static struct builtin builtin_splashimage =
     925{
     926  "splashimage",
     927  splashimage_func,
     928  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     929  "splashimage FILE",
     930  "Load FILE as the background image when in graphics mode."
     931};
     932
     933
    856934
     935/* shade */
     936static int
     937shade_func(char *arg, int flags)
     938{
     939    int new_shade;
     940
     941    if (!arg || safe_parse_maxint(&arg, &new_shade) == 0)
     942       return (1);
     943
     944    if (shade != new_shade) {
     945       shade = new_shade;
     946       if (flags == BUILTIN_CMDLINE && graphics_inited) {
     947           graphics_end();
     948           graphics_init();
     949           graphics_cls();
     950       }
     951    }
     952
     953    return 0;
     954}
     955
     956static struct builtin builtin_shade =
     957{
     958  "shade",
     959  shade_func,
     960  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     961  "shade INTEGER",
     962  "If set to 0, disables the use of shaded text, else enables it."
     963};
     964
     965
    857966
     967/* foreground */
     968static int
     969foreground_func(char *arg, int flags)
     970{
     971    if (grub_strlen(arg) == 6) {
     972        int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
     973        int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
     974        int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
     975
     976        foreground = (r << 16) | (g << 8) | b;
     977        if (graphics_inited)
     978            graphics_set_palette(15, r, g, b);
     979
     980        return 0;
     981    }
     982
     983    return 1;
     984}
     985
     986static struct builtin builtin_foreground =
     987{
     988  "foreground",
     989  foreground_func,
     990  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     991  "foreground RRGGBB",
     992  "Sets the foreground color when in graphics mode."
     993  "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
     994};
     995
     996
    858997
     998/* background */
     999static int
     1000background_func(char *arg, int flags)
     1001{
     1002    if (grub_strlen(arg) == 6) {
     1003        int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
     1004        int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
     1005        int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
     1006
     1007        background = (r << 16) | (g << 8) | b;
     1008        if (graphics_inited)
     1009            graphics_set_palette(0, r, g, b);
     1010        return 0;
     1011    }
     1012
     1013    return 1;
     1014}
     1015
     1016static struct builtin builtin_background =
     1017{
     1018  "background",
     1019  background_func,
     1020  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     1021  "background RRGGBB",
     1022  "Sets the background color when in graphics mode."
     1023  "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
     1024};
     1025
     1026
    8591027
     1028/* border */
     1029static int
     1030border_func(char *arg, int flags)
     1031{
     1032    if (grub_strlen(arg) == 6) {
     1033       int r = ((hex(arg[0]) << 4) | hex(arg[1])) >> 2;
     1034       int g = ((hex(arg[2]) << 4) | hex(arg[3])) >> 2;
     1035       int b = ((hex(arg[4]) << 4) | hex(arg[5])) >> 2;
     1036
     1037       window_border = (r << 16) | (g << 8) | b;
     1038       if (graphics_inited)
     1039           graphics_set_palette(0x11, r, g, b);
     1040
     1041       return 0;
     1042    }
     1043
     1044    return 1;
     1045}
     1046
     1047static struct builtin builtin_border =
     1048{
     1049  "border",
     1050  border_func,
     1051  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     1052  "border RRGGBB",
     1053  "Sets the border video color when in graphics mode."
     1054  "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal."
     1055};
     1056
     1057
    8601058
     1059/* viewport */
     1060static int
     1061viewport_func (char *arg, int flags)
     1062{
     1063    int i;
     1064    int x0 = 0, y0 = 0, x1 = 80, y1 = 30;
     1065    int *pos[4] = { &x0, &y0, &x1, &y1 };
     1066
     1067    if (!arg)
     1068       return (1);
     1069    for (i = 0; i < 4; i++) {
     1070       if (!*arg)
     1071           return (1);
     1072    while (*arg && (*arg == ' ' || *arg == '\t'))
     1073           ++arg;
     1074       if (!safe_parse_maxint(&arg, pos[i]))
     1075           return (1);
     1076       while (*arg && (*arg != ' ' && *arg != '\t'))
     1077           ++arg;
     1078    }
     1079
     1080    /* minimum size is 65 colums and 16 rows */
     1081    if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
     1082       return 1;
     1083
     1084    view_x0 = x0;
     1085    view_y0 = y0;
     1086    view_x1 = x1;
     1087    view_y1 = y1;
     1088
     1089    if (flags == BUILTIN_CMDLINE && graphics_inited) {
     1090       graphics_end();
     1091       graphics_init();
     1092       graphics_cls();
     1093    }
     1094
     1095    return 0;
     1096}
     1097
     1098static struct builtin builtin_viewport =
     1099{
     1100  "viewport",
     1101  viewport_func,
     1102  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
     1103  "viewport x0 y0 x1 y1",
     1104  "Changes grub internals to output text in the window defined by"
     1105  " four parameters. The x and y parameters are 0 based. This option"
     1106  " only works with the graphics interface."
     1107};
     1108
     1109#endif /* SUPPORT_GRAPHICS */
     1110
     1111
    8611112
     1113/* clear */
     1114static int
     1115clear_func()
     1116{
     1117  if (current_term->cls)
     1118    current_term->cls();
     1119
     1120  return 0;
     1121}
     1122
     1123static struct builtin builtin_clear =
     1124{
     1125  "clear",
     1126  clear_func,
     1127  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
  • stage2/char_io.c

    +  "clear",
    +  "Clear the screen"
    +};
    +
     
    
     /* displayapm */
     static int
    @@ -1454,14 +1724,20 @@
     
     
    
     /* help */
    -#define MAX_SHORT_DOC_LEN	39
    -#define MAX_LONG_DOC_LEN	66
    -
     static int
     help_func (char *arg, int flags)
     {
    -  int all = 0;
    -  
    +  int all = 0, max_short_doc_len, max_long_doc_len;
    +  max_short_doc_len = 39;
    +  max_long_doc_len = 66;
    +#ifdef SUPPORT_GRAPHICS
    +  if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
    +    {
    +      max_short_doc_len = (view_x1 - view_x0 + 1) / 2 - 1;
    +      max_long_doc_len = (view_x1 - view_x0) - 14;
    +    }
    +#endif
    +
       if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) == 0)
         {
           all = 1;
    @@ -1491,13 +1767,13 @@
     
     	  len = grub_strlen ((*builtin)->short_doc);
     	  /* If the length of SHORT_DOC is too long, truncate it.  */
    -	  if (len > MAX_SHORT_DOC_LEN - 1)
    -	    len = MAX_SHORT_DOC_LEN - 1;
    +	  if (len > max_short_doc_len - 1)
    +	    len = max_short_doc_len - 1;
     
     	  for (i = 0; i < len; i++)
     	    grub_putchar ((*builtin)->short_doc[i]);
     
    -	  for (; i < MAX_SHORT_DOC_LEN; i++)
    +	  for (; i < max_short_doc_len; i++)
     	    grub_putchar (' ');
     
     	  if (! left)
    @@ -1546,10 +1822,10 @@
     		      int i;
     
     		      /* If LEN is too long, fold DOC.  */
    -		      if (len > MAX_LONG_DOC_LEN)
    +		      if (len > max_long_doc_len)
     			{
     			  /* Fold this line at the position of a space.  */
    -			  for (len = MAX_LONG_DOC_LEN; len > 0; len--)
    +			  for (len = max_long_doc_len; len > 0; len--)
     			    if (doc[len - 1] == ' ')
     			      break;
     			}
    @@ -2323,6 +2599,25 @@
       "Probe I/O ports used for the drive DRIVE."
     };
     
    +/* print */
    +static int
    +print_func (char *arg, int flags)
    +{
    +  printf("%s\n", arg);
    +
    +  return 0;
    +}
    +
    +static struct builtin builtin_print =
    +{
    +  "print",
    +  print_func,
    +  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO,
    +  "print [MESSAGE ...]",
    +  "Print MESSAGE."
    +};
    +
    +
     
    
     /* kernel */
     static int
    @@ -3221,7 +3516,102 @@
     static int
     savedefault_func (char *arg, int flags)
     {
    -#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
    +#if !defined(SUPPORT_DISKLESS)
    +  #if !defined(GRUB_UTIL)
    +	savedefault_helper(arg, flags);
    +  #else
    +	savedefault_shell(arg, flags);
    +  #endif
    +#else /* !SUPPORT_DISKLESS */ 
    +  errnum = ERR_UNRECOGNIZED;
    +  return 1;
    +#endif /* !SUPPORT_DISKLESS */
    +}
    +
    +#if !defined(SUPPORT_DISKLESS) && defined(GRUB_UTIL)
    +/* savedefault_shell */
    +static int
    +savedefault_shell(char *arg, int flags)
    + {
    +  int once_only = 0;
    +  int new_default;
    +  int curr_default = -1;
    +  int curr_prev_default = -1;
    +  int new_prev_default = -1;
    +  FILE *fp;
    +  size_t bytes = 10;
    +  char line[bytes];
    +  char *default_file = (char *) DEFAULT_FILE_BUF;
    +  char buf[bytes];
    +  int i;
    +  
    +  while (1)
    +    {
    +      if (grub_memcmp ("--default=", arg, sizeof ("--default=") - 1) == 0)
    +        {
    +          char *p = arg + sizeof ("--default=") - 1;
    +          if (! safe_parse_maxint (&p, &new_default))
    +            return 1;
    +          arg = skip_to (0, arg);
    +        }
    +      else if (grub_memcmp ("--once", arg, sizeof ("--once") - 1) == 0)
    +        {
    +         once_only = 1;
    +         arg = skip_to (0, arg);
    +	}
    +      else
    +        break;
    +    }
    +
    +  *default_file = 0;
    +  grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN);
    +  for (i = grub_strlen(default_file); i >= 0; i--)
    +    if (default_file[i] == '/')
    +    {
    +      i++;
    +      break;
    +    }
    +  default_file[i] = 0;
    +  grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i);
    +
    +  if(!(fp = fopen(default_file,"w")))
    +    {
    +      errnum = ERR_READ;
    +      goto fail;
    +    }
    +  
    +  read(&line, -1);
    +    
    +  sscanf(line, "%d:%d", &curr_prev_default, &curr_default);
    +     
    +  if(curr_default != -1)
    +    new_prev_default = curr_default;
    +  else
    +    {
    +      if(curr_prev_default != -1)
    +        new_prev_default = curr_prev_default;
    +      else
    +        new_prev_default = 0;
    +    }
    +     
    +  if(once_only)
    +    sprintf(buf, "%d:%d\n", new_prev_default, new_default);
    +  else
    +    sprintf(buf, "%d\n", new_default);
    +     
    +  fprintf(fp, buf);   
    +     
    +fail:
    +  fclose(fp);
    +  return errnum;
    +}
    +#endif
    +
    +/* savedefault_helper */
    +static int
    +savedefault_helper (char *arg, int flags)
    +{
    +#if !defined(SUPPORT_DISKLESS)
       unsigned long tmp_drive = saved_drive;
       unsigned long tmp_partition = saved_partition;
       char *default_file = (char *) DEFAULT_FILE_BUF;
    @@ -3300,19 +3690,23 @@
           disk_read_hook = 0;
           grub_close ();
           
    -      if (len != sizeof (buf))
    -	{
    -	  /* This is too small. Do not modify the file manually, please!  */
    -	  errnum = ERR_READ;
    -	  goto fail;
    -	}
    -
           if (sector_count > 2)
     	{
     	  /* Is this possible?! Too fragmented!  */
     	  errnum = ERR_FSYS_CORRUPT;
     	  goto fail;
     	}
    +
    +      char *tmp;
    +      if((tmp = grub_strstr(buf, ":")) != NULL)
    +      {
    +       int f_len = grub_strlen(buf) - grub_strlen(tmp);
    +       char *def;
    +       int a;
    +       for(a = 0; a < f_len; a++)
    +         grub_memcpy(&def[a], &buf[a], sizeof(char));
    +       safe_parse_maxint (&def, &entryno);
    +      }
           
           /* Set up a string to be written.  */
           grub_memset (buf, '\n', sizeof (buf));
    @@ -3830,15 +4224,15 @@
     	{
     	  char tmp[16];
     	  grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF);
    -	  grub_strncat (device, tmp, 256);
    +	  grub_strncat (device, tmp, sizeof (device));
     	}
           if ((partition & 0x00FF00) != 0x00FF00)
     	{
     	  char tmp[16];
     	  grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF));
    -	  grub_strncat (device, tmp, 256);
    +	  grub_strncat (device, tmp, sizeof (device));
     	}
    -      grub_strncat (device, ")", 256);
    +      grub_strncat (device, ")", sizeof (device));
         }
       
       int embed_stage1_5 (char *stage1_5, int drive, int partition)
    @@ -4085,7 +4479,7 @@
     };
     
     
    
    -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
    +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
     /* terminal */
     static int
     terminal_func (char *arg, int flags)
    @@ -4244,17 +4638,29 @@
      end:
       current_term = term_table + default_term;
       current_term->flags = term_flags;
    -  
    +
       if (lines)
         max_lines = lines;
       else
    -    /* 24 would be a good default value.  */
    -    max_lines = 24;
    -  
    +    max_lines = current_term->max_lines;
    +
       /* If the interface is currently the command-line,
          restart it to repaint the screen.  */
    -  if (current_term != prev_term && (flags & BUILTIN_CMDLINE))
    +  if ((current_term != prev_term) && (flags & BUILTIN_CMDLINE)){
    +    if (prev_term->shutdown)
    +      prev_term->shutdown();
    +    if (current_term->startup) {
    +      /* If startup fails, return to previous term */
    +      if (current_term->startup() == 0) {
    +        current_term = prev_term;
    +        max_lines = current_term->max_lines;
    +        if (current_term->cls) {
    +          current_term->cls();
    +        }
    +      }
    +    }
         grub_longjmp (restart_cmdline_env, 0);
    +  }
       
       return 0;
     }
    @@ -4264,7 +4670,7 @@
       "terminal",
       terminal_func,
       BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
    -  "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules]",
    +  "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=SECS] [--lines=LINES] [--silent] [console] [serial] [hercules] [graphics]",
       "Select a terminal. When multiple terminals are specified, wait until"
       " you push any key to continue. If both console and serial are specified,"
       " the terminal to which you input a key first will be selected. If no"
    @@ -4276,7 +4682,7 @@
       " seconds. The option --lines specifies the maximum number of lines."
       " The option --silent is used to suppress messages."
     };
    -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
    +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
     
     
    
     #ifdef SUPPORT_SERIAL
    @@ -4795,13 +5201,20 @@
     /* The table of builtin commands. Sorted in dictionary order.  */
     struct builtin *builtin_table[] =
     {
    +#ifdef SUPPORT_GRAPHICS
    +  &builtin_background,
    +#endif
       &builtin_blocklist,
       &builtin_boot,
     #ifdef SUPPORT_NETBOOT
       &builtin_bootp,
     #endif /* SUPPORT_NETBOOT */
    +#ifdef SUPPORT_GRAPHICS
    +  &builtin_border,
    +#endif
       &builtin_cat,
       &builtin_chainloader,
    +  &builtin_clear,
       &builtin_cmp,
       &builtin_color,
       &builtin_configfile,
    @@ -4821,6 +5234,9 @@
       &builtin_embed,
       &builtin_fallback,
       &builtin_find,
    +#ifdef SUPPORT_GRAPHICS
    +  &builtin_foreground,
    +#endif
       &builtin_fstest,
       &builtin_geometry,
       &builtin_halt,
    @@ -4848,6 +5264,7 @@
       &builtin_parttype,
       &builtin_password,
       &builtin_pause,
    +  &builtin_print,
     #ifdef GRUB_UTIL
       &builtin_quit,
     #endif /* GRUB_UTIL */
    @@ -4864,9 +5281,13 @@
     #endif /* SUPPORT_SERIAL */
       &builtin_setkey,
       &builtin_setup,
    -#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES)
    +#ifdef SUPPORT_GRAPHICS
    +  &builtin_shade,
    +  &builtin_splashimage,
    +#endif /* SUPPORT_GRAPHICS */
    +#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPORT_GRAPHICS)
       &builtin_terminal,
    -#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */
    +#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */
     #ifdef SUPPORT_SERIAL
       &builtin_terminfo,
     #endif /* SUPPORT_SERIAL */
    @@ -4880,5 +5301,8 @@
       &builtin_unhide,
       &builtin_uppermem,
       &builtin_vbeprobe,
    +#ifdef SUPPORT_GRAPHICS
    +  &builtin_viewport,
    +#endif
       0
     };
    diff -Naur grub-0.97.orig/stage2/char_io.c grub-0.97/stage2/char_io.c
    old new  
    2929# include <serial.h>
    3030#endif
    3131
     32#ifdef SUPPORT_GRAPHICS
     33# include <graphics.h>
     34#endif
     35
    3236#ifndef STAGE1_5
    3337struct term_entry term_table[] =
    3438  {
    3539    {
    3640      "console",
    3741      0,
     42      24,
    3843      console_putchar,
    3944      console_checkkey,
    4045      console_getkey,
     
    4348      console_cls,
    4449      console_setcolorstate,
    4550      console_setcolor,
    46       console_setcursor
     51      console_setcursor,
     52      0,
     53      0
    4754    },
    4855#ifdef SUPPORT_SERIAL
    4956    {
    5057      "serial",
    5158      /* A serial device must be initialized.  */
    5259      TERM_NEED_INIT,
     60      24,
    5361      serial_putchar,
    5462      serial_checkkey,
    5563      serial_getkey,
     
    5866      serial_cls,
    5967      serial_setcolorstate,
    6068      0,
     69      0,
     70      0,
    6171      0
    6272    },
    6373#endif /* SUPPORT_SERIAL */
     
    6575    {
    6676      "hercules",
    6777      0,
     78      24,
    6879      hercules_putchar,
    6980      console_checkkey,
    7081      console_getkey,
     
    7384      hercules_cls,
    7485      hercules_setcolorstate,
    7586      hercules_setcolor,
    76       hercules_setcursor
     87      hercules_setcursor,
     88      0,
     89      0
    7790    },     
    7891#endif /* SUPPORT_HERCULES */
     92#ifdef SUPPORT_GRAPHICS
     93    { "graphics",
     94      TERM_NEED_INIT, /* flags */
     95      30, /* number of lines */
     96      graphics_putchar, /* putchar */
     97      console_checkkey, /* checkkey */
     98      console_getkey, /* getkey */
     99      graphics_getxy, /* getxy */
     100      graphics_gotoxy, /* gotoxy */
     101      graphics_cls, /* cls */
     102      graphics_setcolorstate, /* setcolorstate */
     103      graphics_setcolor, /* setcolor */
     104      graphics_setcursor, /* nocursor */
     105      graphics_init, /* initialize */
     106      graphics_end /* shutdown */
     107    },
     108#endif /* SUPPORT_GRAPHICS */
    79109    /* This must be the last entry.  */
    80     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
     110    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    81111  };
    82112
    83113/* This must be console.  */
     
    305335
    306336  /* XXX: These should be defined in shared.h, but I leave these here,
    307337     until this code is freezed.  */
    308 #define CMDLINE_WIDTH   78
    309338#define CMDLINE_MARGIN  10
    310  
     339
     340  /* command-line limits */
     341  int cmdline_width = 78, col_start = 0;
    311342  int xpos, lpos, c, section;
    312343  /* The length of PROMPT.  */
    313344  int plen;
     
    338369     
    339370      /* If the cursor is in the first section, display the first section
    340371         instead of the second.  */
    341       if (section == 1 && plen + lpos < CMDLINE_WIDTH)
     372      if (section == 1 && plen + lpos < cmdline_width)
    342373        cl_refresh (1, 0);
    343374      else if (xpos - count < 1)
    344375        cl_refresh (1, 0);
     
    354385                grub_putchar ('\b');
    355386            }
    356387          else
    357             gotoxy (xpos, getxy () & 0xFF);
     388            gotoxy (xpos + col_start, getxy () & 0xFF);
    358389        }
    359390    }
    360391
     
    364395      lpos += count;
    365396
    366397      /* If the cursor goes outside, scroll the screen to the right.  */
    367       if (xpos + count >= CMDLINE_WIDTH)
     398      if (xpos + count >= cmdline_width)
    368399        cl_refresh (1, 0);
    369400      else
    370401        {
     
    383414                }
    384415            }
    385416          else
    386             gotoxy (xpos, getxy () & 0xFF);
     417            gotoxy (xpos + col_start, getxy () & 0xFF);
    387418        }
    388419    }
    389420
     
    398429      if (full)
    399430        {
    400431          /* Recompute the section number.  */
    401           if (lpos + plen < CMDLINE_WIDTH)
     432          if (lpos + plen < cmdline_width)
    402433            section = 0;
    403434          else
    404             section = ((lpos + plen - CMDLINE_WIDTH)
    405                        / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1);
     435            section = ((lpos + plen - cmdline_width)
     436                       / (cmdline_width - 1 - CMDLINE_MARGIN) + 1);
    406437
    407438          /* From the start to the end.  */
    408           len = CMDLINE_WIDTH;
     439          len = cmdline_width;
    409440          pos = 0;
    410441          grub_putchar ('\r');
    411442
     
    445476          if (! full)
    446477            offset = xpos - 1;
    447478         
    448           start = ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN)
    449                    + CMDLINE_WIDTH - plen - CMDLINE_MARGIN);
     479          start = ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN)
     480                   + cmdline_width - plen - CMDLINE_MARGIN);
    450481          xpos = lpos + 1 - start;
    451482          start += offset;
    452483        }
     
    471502     
    472503      /* If the cursor is at the last position, put `>' or a space,
    473504         depending on if there are more characters in BUF.  */
    474       if (pos == CMDLINE_WIDTH)
     505      if (pos == cmdline_width)
    475506        {
    476507          if (start + len < llen)
    477508            grub_putchar ('>');
     
    488519            grub_putchar ('\b');
    489520        }
    490521      else
    491         gotoxy (xpos, getxy () & 0xFF);
     522        gotoxy (xpos + col_start, getxy () & 0xFF);
    492523    }
    493524
    494525  /* Initialize the command-line.  */
     
    518549         
    519550          llen += l;
    520551          lpos += l;
    521           if (xpos + l >= CMDLINE_WIDTH)
     552          if (xpos + l >= cmdline_width)
    522553            cl_refresh (1, 0);
    523           else if (xpos + l + llen - lpos > CMDLINE_WIDTH)
    524             cl_refresh (0, CMDLINE_WIDTH - xpos);
     554          else if (xpos + l + llen - lpos > cmdline_width)
     555            cl_refresh (0, cmdline_width - xpos);
    525556          else
    526557            cl_refresh (0, l + llen - lpos);
    527558        }
     
    533564      grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1);
    534565      llen -= count;
    535566     
    536       if (xpos + llen + count - lpos > CMDLINE_WIDTH)
    537         cl_refresh (0, CMDLINE_WIDTH - xpos);
     567      if (xpos + llen + count - lpos > cmdline_width)
     568        cl_refresh (0, cmdline_width - xpos);
    538569      else
    539570        cl_refresh (0, llen + count - lpos);
    540571    }
    541572
     573  max_lines = current_term->max_lines;
     574#ifdef SUPPORT_GRAPHICS
     575  if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
     576    {
     577      cmdline_width = (view_x1 - view_x0) - 2;
     578      col_start = view_x0;
     579      max_lines = view_y1 - view_y0;
     580    }
     581#endif
     582
    542583  plen = grub_strlen (prompt);
    543584  llen = grub_strlen (cmdline);
    544585
     
    10061047}
    10071048#endif /* ! STAGE1_5 */
    10081049
     1050#ifndef STAGE1_5
     1051/* Internal pager.  */
     1052int
     1053do_more (void)
     1054{
     1055  if (count_lines >= 0)
     1056    {
     1057      count_lines++;
     1058      if (count_lines >= max_lines - 2)
     1059        {
     1060          int tmp;
     1061
     1062          /* It's important to disable the feature temporarily, because
     1063             the following grub_printf call will print newlines.  */
     1064          count_lines = -1;
     1065
     1066          grub_printf("\n");
     1067          if (current_term->setcolorstate)
     1068            current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
     1069
     1070          grub_printf ("[Hit return to continue]");
     1071
     1072          if (current_term->setcolorstate)
     1073            current_term->setcolorstate (COLOR_STATE_NORMAL);
     1074
     1075
     1076          do
     1077            {
     1078              tmp = ASCII_CHAR (getkey ());
     1079            }
     1080          while (tmp != '\n' && tmp != '\r');
     1081          grub_printf ("\r                        \r");
     1082
     1083          /* Restart to count lines.  */
     1084          count_lines = 0;
     1085          return 1;
     1086        }
     1087    }
     1088  return 0;
     1089}
     1090#endif
     1091
    10091092/* Display an ASCII character.  */
    10101093void
    10111094grub_putchar (int c)
     
    10341117
    10351118  if (c == '\n')
    10361119    {
     1120      int flag;
    10371121      /* Internal `more'-like feature.  */
    1038       if (count_lines >= 0)
    1039         {
    1040           count_lines++;
    1041           if (count_lines >= max_lines - 2)
    1042             {
    1043               int tmp;
    1044              
    1045               /* It's important to disable the feature temporarily, because
    1046                  the following grub_printf call will print newlines.  */
    1047               count_lines = -1;
    1048 
    1049               if (current_term->setcolorstate)
    1050                 current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
    1051              
    1052               grub_printf ("\n[Hit return to continue]");
    1053 
    1054               if (current_term->setcolorstate)
    1055                 current_term->setcolorstate (COLOR_STATE_NORMAL);
    1056              
    1057               do
    1058                 {
    1059                   tmp = ASCII_CHAR (getkey ());
    1060                 }
    1061               while (tmp != '\n' && tmp != '\r');
    1062               grub_printf ("\r                        \r");
    1063              
    1064               /* Restart to count lines.  */
    1065               count_lines = 0;
    1066               return;
    1067             }
    1068         }
     1122      flag = do_more ();
     1123      if (flag)
     1124        return;
    10691125    }
    10701126
    10711127  current_term->putchar (c);
     
    10901146cls (void)
    10911147{
    10921148  /* If the terminal is dumb, there is no way to clean the terminal.  */
    1093   if (current_term->flags & TERM_DUMB)
     1149  if (current_term->flags & TERM_DUMB) 
    10941150    grub_putchar ('\n');
    10951151  else
    10961152    current_term->cls ();
     
    11751231#endif /* ! STAGE1_5 */
    11761232
    11771233int
    1178 memcheck (int addr, int len)
     1234memcheck (unsigned long int addr, unsigned long int len)
    11791235{
    11801236#ifdef GRUB_UTIL
    1181   auto int start_addr (void);
    1182   auto int end_addr (void);
     1237  auto unsigned long int start_addr (void);
     1238  auto int unsigned long end_addr (void);
    11831239 
    1184   auto int start_addr (void)
     1240  auto unsigned long int start_addr (void)
    11851241    {
    11861242      int ret;
    11871243# if defined(HAVE_START_SYMBOL)
     
    11921248      return ret;
    11931249    }
    11941250
    1195   auto int end_addr (void)
     1251  auto unsigned long int end_addr (void)
    11961252    {
    11971253      int ret;
    11981254# if defined(HAVE_END_SYMBOL)
     
    12171273  return ! errnum;
    12181274}
    12191275
     1276void
     1277grub_memcpy(void *dest, const void *src, int len)
     1278{
     1279  int i;
     1280  register char *d = (char*)dest, *s = (char*)src;
     1281
     1282  for (i = 0; i < len; i++)
     1283    d[i] = s[i];
     1284}
     1285
    12201286void *
    12211287grub_memmove (void *to, const void *from, int len)
    12221288{
  • stage2/cmdline.c

    diff -Naur grub-0.97.orig/stage2/cmdline.c grub-0.97/stage2/cmdline.c
    old new  
    5050void
    5151print_cmdline_message (int forever)
    5252{
    53   printf (" [ Minimal BASH-like line editing is supported.  For the first word, TAB\n"
    54           "   lists possible command completions.  Anywhere else TAB lists the possible\n"
    55           "   completions of a device/filename.%s ]\n",
    56           (forever ? "" : "  ESC at any time exits."));
     53  grub_printf("       [ Minimal BASH-like line editing is supported.   For\n"
     54              "         the   first   word,  TAB  lists  possible  command\n"
     55              "         completions.  Anywhere else TAB lists the possible\n"
     56              "         completions of a device/filename.%s ]\n",
     57              (forever ? "" : "  ESC at any time\n         exits."));
    5758}
    5859
    5960/* Find the builtin whose command name is COMMAND and return the
  • stage2/freebsd.h

    diff -Naur grub-0.97.orig/stage2/freebsd.h grub-0.97/stage2/freebsd.h
    old new  
    11
    22/*
    33 *  GRUB  --  GRand Unified Bootloader
    4  *  Copyright (C) 2001  Free Software Foundation, Inc.
     4 *  Copyright (C) 2001, 2004  Free Software Foundation, Inc.
    55 *
    66 *  This program is free software; you can redistribute it and/or modify
    77 *  it under the terms of the GNU General Public License as published by
     
    3535#define RB_CDROM        0x2000  /* use cdrom as root */
    3636#define RB_GDB          0x8000  /* use GDB remote debugger instead of DDB */
    3737#define RB_MUTE         0x10000 /* Come up with the console muted */
     38#define RB_SELFTEST     0x20000 /* don't complete the boot; do selftest */
     39#define RB_RESERVED1    0x40000 /* reserved for internal use of boot blocks */
     40#define RB_RESERVED2    0x80000 /* reserved for internal use of boot blocks */
     41#define RB_PAUSE        0x100000 /* pause after each output line during probe */
    3842#define RB_MULTIPLE     0x20000000      /* Use multiple consoles */
    3943
    4044#define RB_BOOTINFO     0x80000000      /* have `struct bootinfo *' arg */
     
    7074
    7175#define N_BIOS_GEOM             8
    7276
     77typedef unsigned char u8_t;
     78typedef unsigned int u32_t;
     79
    7380/*
    7481 * A zero bootinfo field often means that there is no info available.
    7582 * Flags are used to indicate the validity of fields where zero is a
     
    7784 */
    7885struct bootinfo
    7986  {
    80     unsigned int bi_version;
    81     unsigned char *bi_kernelname;
    82     struct nfs_diskless *bi_nfs_diskless;
     87    u32_t bi_version;
     88    u8_t *bi_kernelname;
     89    u32_t bi_nfs_diskless;
    8390    /* End of fields that are always present. */
    8491#define bi_endcommon            bi_n_bios_used
    85     unsigned int bi_n_bios_used;
    86     unsigned long bi_bios_geom[N_BIOS_GEOM];
    87     unsigned int bi_size;
    88     unsigned char bi_memsizes_valid;
    89     unsigned char bi_bios_dev;
    90     unsigned char bi_pad[2];
    91     unsigned long bi_basemem;
    92     unsigned long bi_extmem;
    93     unsigned long bi_symtab;
    94     unsigned long bi_esymtab;
     92    u32_t bi_n_bios_used;
     93    u32_t bi_bios_geom[N_BIOS_GEOM];
     94    u32_t bi_size;
     95    u8_t bi_memsizes_valid;
     96    u8_t bi_bios_dev;
     97    u8_t bi_pad[2];
     98    u32_t bi_basemem;
     99    u32_t bi_extmem;
     100    u32_t bi_symtab;
     101    u32_t bi_esymtab;
     102    /* Items below only from advanced bootloader */
     103    u32_t bi_kernend;
     104    u32_t bi_envp;
     105    u32_t bi_modulep;
    95106  };
     107
     108#define MODINFO_END             0x0000          /* End of list */
     109#define MODINFO_NAME            0x0001          /* Name of module (string) */
     110#define MODINFO_TYPE            0x0002          /* Type of module (string) */
     111#define MODINFO_ADDR            0x0003          /* Loaded address */
     112#define MODINFO_SIZE            0x0004          /* Size of module */
     113#define MODINFO_EMPTY           0x0005          /* Has been deleted */
     114#define MODINFO_ARGS            0x0006          /* Parameters string */
     115#define MODINFO_METADATA        0x8000          /* Module-specfic */
     116
  • stage2/graphics.c

    diff -Naur grub-0.97.orig/stage2/graphics.c grub-0.97/stage2/graphics.c
    old new  
     1/*
     2 * graphics.c - graphics mode support for GRUB
     3 * Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
     4 * on a patch by Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
     5 * Options and enhancements made by Herton Ronaldo Krzesinski
     6 * <herton@mandriva.com>
     7 *
     8 *  GRUB  --  GRand Unified Bootloader
     9 *  Copyright (C) 2001,2002  Red Hat, Inc.
     10 *  Portions copyright (C) 2000  Conectiva, Inc.
     11 *
     12 *  This program is free software; you can redistribute it and/or modify
     13 *  it under the terms of the GNU General Public License as published by
     14 *  the Free Software Foundation; either version 2 of the License, or
     15 *  (at your option) any later version.
     16 *
     17 *  This program is distributed in the hope that it will be useful,
     18 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 *  GNU General Public License for more details.
     21 *
     22 *  You should have received a copy of the GNU General Public License
     23 *  along with this program; if not, write to the Free Software
     24 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     25 */
     26
     27#ifdef SUPPORT_GRAPHICS
     28
     29#include <term.h>
     30#include <shared.h>
     31#include <graphics.h>
     32
     33int saved_videomode;
     34unsigned char *font8x16;
     35
     36int graphics_inited = 0;
     37static char splashimage[256];
     38
     39int shade = 1, no_cursor = 0;
     40
     41#define VSHADOW VSHADOW1
     42unsigned char VSHADOW1[38400];
     43unsigned char VSHADOW2[38400];
     44unsigned char VSHADOW4[38400];
     45unsigned char VSHADOW8[38400];
     46
     47/* define the default viewable area */
     48int view_x0 = 0;
     49int view_y0 = 0;
     50int view_x1 = 80;
     51int view_y1 = 30;
     52
     53/* text buffer has to be kept around so that we can write things as we
     54 * scroll and the like */
     55unsigned short text[80 * 30];
     56
     57/* graphics options */
     58int foreground = (63 << 16) | (63 << 8) | (63), background = 0, window_border = 0;
     59
     60/* current position */
     61static int fontx = 0;
     62static int fonty = 0;
     63
     64/* global state so that we don't try to recursively scroll or cursor */
     65static int no_scroll = 0;
     66
     67/* color state */
     68static int graphics_standard_color = A_NORMAL;
     69static int graphics_normal_color = A_NORMAL;
     70static int graphics_highlight_color = A_REVERSE;
     71static int graphics_current_color = A_NORMAL;
     72static color_state graphics_color_state = COLOR_STATE_STANDARD;
     73
     74static inline void outb(unsigned short port, unsigned char val)
     75{
     76    __asm __volatile ("outb %0,%1"::"a" (val), "d" (port));
     77}
     78
     79static void MapMask(int value) {
     80    outb(0x3c4, 2);
     81    outb(0x3c5, value);
     82}
     83
     84/* bit mask register */
     85static void BitMask(int value) {
     86    outb(0x3ce, 8);
     87    outb(0x3cf, value);
     88}
     89
     90/* move the graphics cursor location to col, row */
     91static void graphics_setxy(int col, int row) {
     92    if (col >= view_x0 && col < view_x1) {
     93        fontx = col;
     94        cursorX = col << 3;
     95    }
     96    if (row >= view_y0 && row < view_y1) {
     97        fonty = row;
     98        cursorY = row << 4;
     99    }
     100}
     101
     102/* scroll the screen */
     103static void graphics_scroll() {
     104    int i, j, k;
     105
     106    /* we don't want to scroll recursively... that would be bad */
     107    if (no_scroll)
     108        return;
     109    no_scroll = 1;
     110
     111    /* disable pager temporarily */
     112    k = count_lines;
     113    count_lines = -1;
     114   
     115    /* move everything up a line */
     116    for (j = view_y0 + 1; j < view_y1; j++) {
     117        graphics_gotoxy(view_x0, j - 1);
     118        for (i = view_x0; i < view_x1; i++) {
     119            graphics_putchar(text[j * 80 + i]);
     120        }
     121    }
     122
     123    /* last line should be blank */
     124    graphics_gotoxy(view_x0, view_y1 - 1);
     125    for (i = view_x0; i < view_x1; i++)
     126        graphics_putchar(' ');
     127    graphics_setxy(view_x0, view_y1 - 1);
     128
     129    count_lines = k;
     130
     131    no_scroll = 0;
     132}
     133
     134/* Set the splash image */
     135void graphics_set_splash(char *splashfile) {
     136    grub_strcpy(splashimage, splashfile);
     137}
     138
     139/* Get the current splash image */
     140char *graphics_get_splash(void) {
     141    return splashimage;
     142}
     143
     144/*
     145 * Initialize a vga16 graphics display with the palette based off of
     146 * the image in splashimage.  If the image doesn't exist, leave graphics
     147 * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List":
     148 *      text/ text pixel   pixel   colors disply scrn  system
     149 *      grph resol  box  resolution       pages  addr
     150 * 12h   G   80x30  8x16  640x480  16/256K  .    A000  VGA,ATI VIP
     151 *       G   80x30  8x16  640x480  16/64    .    A000  ATI EGA Wonder
     152 *       G     .     .    640x480  16       .      .   UltraVision+256K EGA
     153 */
     154int graphics_init()
     155{
     156    if (!graphics_inited) {
     157        saved_videomode = set_videomode(0x12);
     158        if (get_videomode() != 0x12) {
     159            set_videomode(saved_videomode);
     160            return 0;
     161        }
     162        graphics_inited = 1;
     163    }
     164    else
     165        return 1;
     166
     167    font8x16 = (unsigned char*)graphics_get_font();
     168
     169    /* make sure that the highlight color is set correctly */
     170    graphics_highlight_color = ((graphics_normal_color >> 4) |
     171                                ((graphics_normal_color & 0xf) << 4));
     172
     173    graphics_cls();
     174
     175    if (!read_image(splashimage)) {
     176        grub_printf("Failed to read splash image (%s)\n", splashimage);
     177        grub_printf("Press any key to continue...");
     178        getkey();
     179        set_videomode(saved_videomode);
     180        graphics_inited = 0;
     181        return 0;
     182    }
     183
     184    set_int1c_handler();
     185
     186    return 1;
     187}
     188
     189/* Leave graphics mode */
     190void graphics_end(void)
     191{
     192    if (graphics_inited) {
     193        unset_int1c_handler();
     194        set_videomode(saved_videomode);
     195        graphics_inited = 0;
     196        no_cursor = 0;
     197    }
     198}
     199
     200/* Print ch on the screen.  Handle any needed scrolling or the like */
     201void graphics_putchar(int ch) {
     202    ch &= 0xff;
     203
     204    graphics_cursor(0);
     205
     206    if (ch == '\n') {
     207        if (fonty + 1 < view_y1)
     208            graphics_setxy(fontx, fonty + 1);
     209        else
     210            graphics_scroll();
     211        graphics_cursor(1);
     212        return;
     213    } else if (ch == '\r') {
     214        graphics_setxy(view_x0, fonty);
     215        graphics_cursor(1);
     216        return;
     217    }
     218
     219    graphics_cursor(0);
     220
     221    text[fonty * 80 + fontx] = ch;
     222    text[fonty * 80 + fontx] &= 0x00ff;
     223    if (graphics_current_color & 0xf0)
     224        text[fonty * 80 + fontx] |= 0x100;
     225
     226    graphics_cursor(0);
     227
     228    if ((fontx + 1) >= view_x1) {
     229        graphics_setxy(view_x0, fonty);
     230        if (fonty + 1 < view_y1)
     231            graphics_setxy(view_x0, fonty + 1);
     232        else
     233            graphics_scroll();
     234        graphics_cursor(1);
     235        do_more ();
     236        graphics_cursor(0);
     237    } else {
     238        graphics_setxy(fontx + 1, fonty);
     239    }
     240
     241    graphics_cursor(1);
     242}
     243
     244/* get the current location of the cursor */
     245int graphics_getxy(void) {
     246    return (fontx << 8) | fonty;
     247}
     248
     249void graphics_gotoxy(int x, int y) {
     250    graphics_cursor(0);
     251
     252    graphics_setxy(x, y);
     253
     254    graphics_cursor(1);
     255}
     256
     257void graphics_cls(void) {
     258    int i;
     259    unsigned char *mem, *s1, *s2, *s4, *s8;
     260
     261    graphics_cursor(0);
     262    graphics_gotoxy(view_x0, view_y0);
     263
     264    mem = (unsigned char*)VIDEOMEM;
     265    s1 = (unsigned char*)VSHADOW1;
     266    s2 = (unsigned char*)VSHADOW2;
     267    s4 = (unsigned char*)VSHADOW4;
     268    s8 = (unsigned char*)VSHADOW8;
     269
     270    for (i = 0; i < 80 * 30; i++)
     271        text[i] = ' ';
     272    graphics_cursor(1);
     273
     274    BitMask(0xff);
     275
     276    /* plane 1 */
     277    MapMask(1);
     278    grub_memcpy(mem, s1, 38400);
     279
     280    /* plane 2 */
     281    MapMask(2);
     282    grub_memcpy(mem, s2, 38400);
     283
     284    /* plane 3 */
     285    MapMask(4);
     286    grub_memcpy(mem, s4, 38400);
     287
     288    /* plane 4 */
     289    MapMask(8);
     290    grub_memcpy(mem, s8, 38400);
     291
     292    MapMask(15);
     293
     294    if (no_cursor) {
     295        no_cursor = 0;
     296        set_int1c_handler();
     297    }
     298}
     299
     300void graphics_setcolorstate (color_state state) {
     301    switch (state) {
     302    case COLOR_STATE_STANDARD:
     303        graphics_current_color = graphics_standard_color;
     304        break;
     305    case COLOR_STATE_NORMAL:
     306        graphics_current_color = graphics_normal_color;
     307        break;
     308    case COLOR_STATE_HIGHLIGHT:
     309        graphics_current_color = graphics_highlight_color;
     310        break;
     311    default:
     312        graphics_current_color = graphics_standard_color;
     313        break;
     314    }
     315
     316    graphics_color_state = state;
     317}
     318
     319void graphics_setcolor (int normal_color, int highlight_color) {
     320    graphics_normal_color = normal_color;
     321    graphics_highlight_color = highlight_color;
     322
     323    graphics_setcolorstate (graphics_color_state);
     324}
     325
     326int graphics_setcursor (int on) {
     327    if (!no_cursor && !on) {
     328        no_cursor = 1;
     329        unset_int1c_handler();
     330        graphics_cursor(0);
     331    }
     332    else if(no_cursor && on) {
     333        no_cursor = 0;
     334        set_int1c_handler();
     335        graphics_cursor(1);
     336    }
     337    return 0;
     338}
     339
     340/* Read in the splashscreen image and set the palette up appropriately.
     341 * Format of splashscreen is an xpm (can be gzipped) with 16 colors and
     342 * 640x480. */
     343int read_image(char *s)
     344{
     345    char buf[32], pal[16], c;
     346    unsigned char base, mask, *s1, *s2, *s4, *s8;
     347    unsigned i, len, idx, colors, x, y, width, height;
     348
     349    if (!grub_open(s))
     350        return 0;
     351
     352    /* read header */
     353    if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
     354        grub_close();
     355        return 0;
     356    }
     357   
     358    /* parse info */
     359    while (grub_read(&c, 1)) {
     360        if (c == '"')
     361            break;
     362    }
     363
     364    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
     365        ;
     366
     367    i = 0;
     368    width = c - '0';
     369    while (grub_read(&c, 1)) {
     370        if (c >= '0' && c <= '9')
     371            width = width * 10 + c - '0';
     372        else
     373            break;
     374    }
     375    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
     376        ;
     377
     378    height = c - '0';
     379    while (grub_read(&c, 1)) {
     380        if (c >= '0' && c <= '9')
     381            height = height * 10 + c - '0';
     382        else
     383            break;
     384    }
     385    while (grub_read(&c, 1) && (c == ' ' || c == '\t'))
     386        ;
     387
     388    colors = c - '0';
     389    while (grub_read(&c, 1)) {
     390        if (c >= '0' && c <= '9')
     391            colors = colors * 10 + c - '0';
     392        else
     393            break;
     394    }
     395
     396    base = 0;
     397    while (grub_read(&c, 1) && c != '"')
     398        ;
     399
     400    /* palette */
     401    for (i = 0, idx = 1; i < colors; i++) {
     402        len = 0;
     403
     404        while (grub_read(&c, 1) && c != '"')
     405            ;
     406        grub_read(&c, 1);       /* char */
     407        base = c;
     408        grub_read(buf, 4);      /* \t c # */
     409
     410        while (grub_read(&c, 1) && c != '"') {
     411            if (len < sizeof(buf))
     412                buf[len++] = c;
     413        }
     414
     415        if (len == 6 && idx < 15) {
     416            int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;
     417            int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;
     418            int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;
     419
     420            pal[idx] = base;
     421            graphics_set_palette(idx, r, g, b);
     422            ++idx;
     423        }
     424    }
     425
     426    x = y = len = 0;
     427
     428    s1 = (unsigned char*)VSHADOW1;
     429    s2 = (unsigned char*)VSHADOW2;
     430    s4 = (unsigned char*)VSHADOW4;
     431    s8 = (unsigned char*)VSHADOW8;
     432
     433    for (i = 0; i < 38400; i++)
     434        s1[i] = s2[i] = s4[i] = s8[i] = 0;
     435
     436    /* parse xpm data */
     437    while (y < height) {
     438        while (1) {
     439            if (!grub_read(&c, 1)) {
     440                grub_close();
     441                return 0;
     442            }
     443            if (c == '"')
     444                break;
     445        }
     446
     447        while (grub_read(&c, 1) && c != '"') {
     448            for (i = 1; i < 15; i++)
     449                if (pal[i] == c) {
     450                    c = i;
     451                    break;
     452                }
     453
     454            mask = 0x80 >> (x & 7);
     455            if (c & 1)
     456                s1[len + (x >> 3)] |= mask;
     457            if (c & 2)
     458                s2[len + (x >> 3)] |= mask;
     459            if (c & 4)
     460                s4[len + (x >> 3)] |= mask;
     461            if (c & 8)
     462                s8[len + (x >> 3)] |= mask;
     463
     464            if (++x >= 640) {
     465                x = 0;
     466
     467                if (y < 480)
     468                    len += 80;
     469                ++y;
     470            }
     471        }
     472    }
     473
     474    grub_close();
     475
     476    graphics_set_palette(0, (background >> 16), (background >> 8) & 63,
     477                background & 63);
     478    graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,
     479                foreground & 63);
     480    graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8) & 63,
     481                         window_border & 63);
     482
     483    return 1;
     484}
     485
     486/* Convert a character which is a hex digit to the appropriate integer */
     487int hex(int v)
     488{
     489    if (v >= 'A' && v <= 'F')
     490        return (v - 'A' + 10);
     491    if (v >= 'a' && v <= 'f')
     492        return (v - 'a' + 10);
     493    return (v - '0');
     494}
     495
     496void graphics_cursor(int set) {
     497    unsigned char *pat, *mem, *ptr, chr[16 << 2];
     498    int i, ch, invert, offset;
     499
     500    if (set && (no_cursor || no_scroll))
     501        return;
     502
     503    offset = cursorY * 80 + fontx;
     504    ch = text[fonty * 80 + fontx] & 0xff;
     505    invert = (text[fonty * 80 + fontx] & 0xff00) != 0;
     506    pat = font8x16 + (ch << 4);
     507
     508    mem = (unsigned char*)VIDEOMEM + offset;
     509
     510    if (!set) {
     511        for (i = 0; i < 16; i++) {
     512            unsigned char mask = pat[i];
     513
     514            if (!invert) {
     515                chr[i     ] = ((unsigned char*)VSHADOW1)[offset];
     516                chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];
     517                chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];
     518                chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];
     519
     520                if (shade) {
     521                    if (ch == DISP_VERT || ch == DISP_LL ||
     522                        ch == DISP_UR || ch == DISP_LR) {
     523                        unsigned char pmask = ~(pat[i] >> 1);
     524
     525                        chr[i     ] &= pmask;
     526                        chr[16 + i] &= pmask;
     527                        chr[32 + i] &= pmask;
     528                        chr[48 + i] &= pmask;
     529                    }
     530                    if (i > 0 && ch != DISP_VERT) {
     531                        unsigned char pmask = ~(pat[i - 1] >> 1);
     532
     533                        chr[i     ] &= pmask;
     534                        chr[16 + i] &= pmask;
     535                        chr[32 + i] &= pmask;
     536                        chr[48 + i] &= pmask;
     537                        if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {
     538                            pmask = ~pat[i - 1];
     539
     540                            chr[i     ] &= pmask;
     541                            chr[16 + i] &= pmask;
     542                            chr[32 + i] &= pmask;
     543                            chr[48 + i] &= pmask;
     544                        }
     545                    }
     546                }
     547                chr[i     ] |= mask;
     548                chr[16 + i] |= mask;
     549                chr[32 + i] |= mask;
     550                chr[48 + i] |= mask;
     551
     552                offset += 80;
     553            }
     554            else {
     555                chr[i     ] = mask;
     556                chr[16 + i] = mask;
     557                chr[32 + i] = mask;
     558                chr[48 + i] = mask;
     559            }
     560        }
     561    }
     562    else {
     563        MapMask(15);
     564        ptr = mem;
     565        for (i = 0; i < 16; i++, ptr += 80) {
     566            cursorBuf[i] = pat[i];
     567            *ptr = ~pat[i];
     568        }
     569        return;
     570    }
     571
     572    offset = 0;
     573    for (i = 1; i < 16; i <<= 1, offset += 16) {
     574        int j;
     575
     576        MapMask(i);
     577        ptr = mem;
     578        for (j = 0; j < 16; j++, ptr += 80)
     579            *ptr = chr[j + offset];
     580    }
     581
     582    MapMask(15);
     583}
     584
     585#endif /* SUPPORT_GRAPHICS */
  • stage2/graphics.h

    diff -Naur grub-0.97.orig/stage2/graphics.h grub-0.97/stage2/graphics.h
    old new  
     1/* graphics.h - graphics console interface */
     2/*
     3 *  GRUB  --  GRand Unified Bootloader
     4 *  Copyright (C) 2002  Free Software Foundation, Inc.
     5 *
     6 *  This program is free software; you can redistribute it and/or modify
     7 *  it under the terms of the GNU General Public License as published by
     8 *  the Free Software Foundation; either version 2 of the License, or
     9 *  (at your option) any later version.
     10 *
     11 *  This program is distributed in the hope that it will be useful,
     12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 *  GNU General Public License for more details.
     15 *
     16 *  You should have received a copy of the GNU General Public License
     17 *  along with this program; if not, write to the Free Software
     18 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     19 */
     20
     21#ifndef GRAPHICS_H
     22#define GRAPHICS_H
     23
     24/* magic constant */
     25#define VIDEOMEM 0xA0000
     26
     27/* function prototypes */
     28char *graphics_get_splash(void);
     29
     30int read_image(char *s);
     31void graphics_cursor(int set);
     32
     33/* function prototypes for asm functions */
     34void * graphics_get_font();
     35void graphics_set_palette(int idx, int red, int green, int blue);
     36void set_int1c_handler();
     37void unset_int1c_handler();
     38
     39extern short cursorX, cursorY;
     40extern char cursorBuf[16];
     41extern int shade;
     42extern int view_x0, view_y0, view_x1, view_y1;
     43
     44#endif /* GRAPHICS_H */
  • stage2/Makefile.am

    diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
    old new  
    77        fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \
    88        imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \
    99        nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \
    10         terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h
     10        terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h
    1111EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS)
    1212
    1313# For <stage1.h>.
     
    1919        disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \
    2020        fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
    2121        fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
    22         terminfo.c tparm.c
     22        terminfo.c tparm.c graphics.c
    2323libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
    2424        -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
    2525        -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
     
    7979HERCULES_FLAGS =
    8080endif
    8181
     82if GRAPHICS_SUPPORT
     83GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1
     84else
     85GRAPHICS_FLAGS =
     86endif
     87
    8288STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
    83         $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
     89        $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS)
    8490
    8591STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
    8692STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1
     
    9096        cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
    9197        fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \
    9298        fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \
    93         hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
     99        hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \
     100        graphics.c
    94101pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
    95102pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
    96103pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
  • stage2/shared.h

    diff -Naur grub-0.97.orig/stage2/shared.h grub-0.97/stage2/shared.h
    old new  
    499499  unsigned char linear_reserved_field_position;
    500500  unsigned long max_pixel_clock;
    501501
    502   unsigned char reserved3[189];
     502  /* Reserved field to make structure to be 256 bytes long, VESA BIOS
     503     Extension 3.0 Specification says to reserve 189 bytes here but
     504     that doesn't make structure to be 256 bytes.  So additional one is
     505     added here.  */
     506  unsigned char reserved3[189 + 1];
    503507} __attribute__ ((packed));
    504508
    505509
     
    792796/* Set the cursor position. */
    793797void gotoxy (int x, int y);
    794798
     799/* Internal pager
     800   Returns 1 = if pager was used
     801           0 = if pager wasn't used  */
     802int do_more (void);
     803
    795804/* Displays an ASCII character.  IBM displays will translate some
    796805   characters to special graphical ones (see the DISP_* constants). */
    797806void grub_putchar (int c);
     
    871880int grub_tolower (int c);
    872881int grub_isspace (int c);
    873882int grub_strncat (char *s1, const char *s2, int n);
     883void grub_memcpy(void *dest, const void *src, int len);
    874884void *grub_memmove (void *to, const void *from, int len);
    875885void *grub_memset (void *start, int c, int len);
    876886int grub_strncat (char *s1, const char *s2, int n);
     
    911921int nul_terminate (char *str);
    912922int get_based_digit (int c, int base);
    913923int safe_parse_maxint (char **str_ptr, int *myint_ptr);
    914 int memcheck (int start, int len);
     924int memcheck (unsigned long int start, unsigned long int len);
    915925void grub_putstr (const char *str);
    916926
    917927#ifndef NO_DECOMPRESSION
  • stage2/stage2.c

    diff -Naur grub-0.97.orig/stage2/stage2.c grub-0.97/stage2/stage2.c
    old new  
    2020#include <shared.h>
    2121#include <term.h>
    2222
     23#ifdef SUPPORT_GRAPHICS
     24# include <graphics.h>
     25#endif
     26
     27int col_start, col_end, row_start, box_size;
     28
    2329grub_jmp_buf restart_env;
    2430
    2531#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
     
    105111  if (highlight && current_term->setcolorstate)
    106112    current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
    107113
    108   gotoxy (2, y);
     114  gotoxy (2 + col_start, y);
    109115  grub_putchar (' ');
    110   for (x = 3; x < 75; x++)
     116  for (x = 3 + col_start; x < (col_end - 5); x++)
    111117    {
    112       if (*entry && x <= 72)
     118      if (*entry && x <= (col_end - 8))
    113119        {
    114           if (x == 72)
     120          if (x == (col_end - 8))
    115121            grub_putchar (DISP_RIGHT);
    116122          else
    117123            grub_putchar (*entry++);
     
    119125      else
    120126        grub_putchar (' ');
    121127    }
    122   gotoxy (74, y);
     128  gotoxy ((col_end - 6), y);
    123129
    124130  if (current_term->setcolorstate)
    125131    current_term->setcolorstate (COLOR_STATE_STANDARD);
     
    131137{
    132138  int i;
    133139 
    134   gotoxy (77, y + 1);
     140  gotoxy ((col_end - 3), y + 1);
    135141
    136142  if (first)
    137143    grub_putchar (DISP_UP);
     
    151157        menu_entries++;
    152158    }
    153159
    154   gotoxy (77, y + size);
     160  gotoxy ((col_end - 3), y + size);
    155161
    156162  if (*menu_entries)
    157163    grub_putchar (DISP_DOWN);
    158164  else
    159165    grub_putchar (' ');
    160166
    161   gotoxy (74, y + entryno + 1);
     167  gotoxy ((col_end - 6), y + entryno + 1);
    162168}
    163169
    164170static void
     
    196202  if (current_term->setcolorstate)
    197203    current_term->setcolorstate (COLOR_STATE_NORMAL);
    198204 
    199   gotoxy (1, y);
     205  gotoxy (1 + col_start, y);
    200206
    201207  grub_putchar (DISP_UL);
    202   for (i = 0; i < 73; i++)
     208  for (i = col_start; i < (col_end - 7); i++)
    203209    grub_putchar (DISP_HORIZ);
    204210  grub_putchar (DISP_UR);
    205211
    206212  i = 1;
    207213  while (1)
    208214    {
    209       gotoxy (1, y + i);
     215      gotoxy (1 + col_start, y + i);
    210216
    211217      if (i > size)
    212218        break;
    213219     
    214220      grub_putchar (DISP_VERT);
    215       gotoxy (75, y + i);
     221      gotoxy ((col_end - 5), y + i);
    216222      grub_putchar (DISP_VERT);
    217223
    218224      i++;
    219225    }
    220226
    221227  grub_putchar (DISP_LL);
    222   for (i = 0; i < 73; i++)
     228  for (i = col_start; i < (col_end - 7); i++)
    223229    grub_putchar (DISP_HORIZ);
    224230  grub_putchar (DISP_LR);
    225231
     
    233239{
    234240  int c, time1, time2 = -1, first_entry = 0;
    235241  char *cur_entry = 0;
     242  struct term_entry *prev_term = NULL;
    236243
    237244  /*
    238245   *  Main loop for menu UI.
     
    250257        }
    251258    }
    252259
     260  col_start = 0;
     261  col_end = 80;
     262  row_start = 0;
     263  box_size = 12;
     264  /* if we're using viewport we need to make sure to setup
     265     coordinates correctly.  */
     266#ifdef SUPPORT_GRAPHICS
     267  if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - 1) == 0)
     268    {
     269      col_start = view_x0;
     270      col_end = view_x1;
     271      row_start = view_y0;
     272      box_size = (view_y1 - view_y0) - 13;
     273    }
     274#endif
     275
    253276  /* If the timeout was expired or wasn't set, force to show the menu
    254277     interface. */
    255278  if (grub_timeout < 0)
     
    302325      if (current_term->flags & TERM_DUMB)
    303326        print_entries_raw (num_entries, first_entry, menu_entries);
    304327      else
    305         print_border (3, 12);
     328        print_border (3 + row_start, box_size);
    306329
    307330      grub_printf ("\n\
    308       Use the %c and %c keys to select which entry is highlighted.\n",
     331    Use the %c and %c keys to select which entry is highlighted.\n",
    309332                   DISP_UP, DISP_DOWN);
    310333     
    311334      if (! auth && password)
    312335        {
    313336          printf ("\
    314       Press enter to boot the selected OS or \'p\' to enter a\n\
    315       password to unlock the next set of features.");
     337    Press enter to boot the selected OS or \'p\' to enter a\n\
     338    password to unlock the next set of features.");
    316339        }
    317340      else
    318341        {
    319342          if (config_entries)
    320343            printf ("\
    321       Press enter to boot the selected OS, \'e\' to edit the\n\
    322       commands before booting, or \'c\' for a command-line.");
     344    Press enter to boot the selected OS, \'e\' to edit the\n\
     345    commands before booting, or \'c\' for a command-line.");
    323346          else
    324347            printf ("\
    325       Press \'b\' to boot, \'e\' to edit the selected command in the\n\
    326       boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
    327       after (\'O\' for before) the selected line, \'d\' to remove the\n\
    328       selected line, or escape to go back to the main menu.");
     348    Press \'b\' to boot, \'e\' to edit the selected command in the\n\
     349    boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
     350    after (\'O\' for before) the selected line, \'d\' to remove the\n\
     351    selected line, or escape to go back to the main menu.");
    329352        }
    330353
    331354      if (current_term->flags & TERM_DUMB)
    332355        grub_printf ("\n\nThe selected entry is %d ", entryno);
    333356      else
    334         print_entries (3, 12, first_entry, entryno, menu_entries);
     357        print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
    335358    }
    336359
    337360  /* XX using RT clock now, need to initialize value */
     
    358381                           entryno, grub_timeout);
    359382          else
    360383            {
    361               gotoxy (3, 22);
    362               grub_printf ("The highlighted entry will be booted automatically in %d seconds.    ",
     384              gotoxy (3 + col_start, 10 + box_size + row_start);
     385              grub_printf (" The highlighted entry will be booted automatically in %d seconds.   ",
    363386                           grub_timeout);
    364               gotoxy (74, 4 + entryno);
     387              gotoxy ((col_end - 6), 4 + entryno + row_start);
    365388          }
    366389         
    367390          grub_timeout--;
     
    387410              if (current_term->flags & TERM_DUMB)
    388411                grub_putchar ('\r');
    389412              else
    390                 gotoxy (3, 22);
     413                gotoxy (3 + col_start, 10 + box_size + row_start);
    391414              printf ("                                                                    ");
    392415              grub_timeout = -1;
    393416              fallback_entryno = -1;
    394417              if (! (current_term->flags & TERM_DUMB))
    395                 gotoxy (74, 4 + entryno);
     418                gotoxy ((col_end - 6), 4 + entryno + row_start);
    396419            }
    397420
    398421          /* We told them above (at least in SUPPORT_SERIAL) to use
     
    408431                {
    409432                  if (entryno > 0)
    410433                    {
    411                       print_entry (4 + entryno, 0,
     434                      print_entry (4 + entryno + row_start, 0,
    412435                                   get_entry (menu_entries,
    413436                                              first_entry + entryno,
    414437                                              0));
    415438                      entryno--;
    416                       print_entry (4 + entryno, 1,
     439                      print_entry (4 + entryno + row_start, 1,
    417440                                   get_entry (menu_entries,
    418441                                              first_entry + entryno,
    419442                                              0));
     
    421444                  else if (first_entry > 0)
    422445                    {
    423446                      first_entry--;
    424                       print_entries (3, 12, first_entry, entryno,
     447                      print_entries (3 + row_start, box_size, first_entry, entryno,
    425448                                     menu_entries);
    426449                    }
    427450                }
     
    433456                entryno++;
    434457              else
    435458                {
    436                   if (entryno < 11)
     459                  if (entryno < (box_size - 1))
    437460                    {
    438                       print_entry (4 + entryno, 0,
     461                      print_entry (4 + entryno + row_start, 0,
    439462                                   get_entry (menu_entries,
    440463                                              first_entry + entryno,
    441464                                              0));
    442465                      entryno++;
    443                       print_entry (4 + entryno, 1,
     466                      print_entry (4 + entryno + row_start, 1,
    444467                                   get_entry (menu_entries,
    445468                                              first_entry + entryno,
    446469                                              0));
    447470                  }
    448                 else if (num_entries > 12 + first_entry)
     471                else if (num_entries > box_size + first_entry)
    449472                  {
    450473                    first_entry++;
    451                     print_entries (3, 12, first_entry, entryno, menu_entries);
     474                    print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
    452475                  }
    453476                }
    454477            }
    455478          else if (c == 7)
    456479            {
    457480              /* Page Up */
    458               first_entry -= 12;
     481              first_entry -= box_size;
    459482              if (first_entry < 0)
    460483                {
    461484                  entryno += first_entry;
     
    463486                  if (entryno < 0)
    464487                    entryno = 0;
    465488                }
    466               print_entries (3, 12, first_entry, entryno, menu_entries);
     489              print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
    467490            }
    468491          else if (c == 3)
    469492            {
    470493              /* Page Down */
    471               first_entry += 12;
     494              first_entry += box_size;
    472495              if (first_entry + entryno + 1 >= num_entries)
    473496                {
    474                   first_entry = num_entries - 12;
     497                  first_entry = num_entries - box_size;
    475498                  if (first_entry < 0)
    476499                    first_entry = 0;
    477500                  entryno = num_entries - first_entry - 1;
    478501                }
    479               print_entries (3, 12, first_entry, entryno, menu_entries);
     502              print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
    480503            }
    481504
    482505          if (config_entries)
     
    489512              if ((c == 'd') || (c == 'o') || (c == 'O'))
    490513                {
    491514                  if (! (current_term->flags & TERM_DUMB))
    492                     print_entry (4 + entryno, 0,
     515                    print_entry (4 + entryno + row_start, 0,
    493516                                 get_entry (menu_entries,
    494517                                            first_entry + entryno,
    495518                                            0));
     
    537560
    538561                      if (entryno >= num_entries)
    539562                        entryno--;
    540                       if (first_entry && num_entries < 12 + first_entry)
     563                      if (first_entry && num_entries < box_size + first_entry)
    541564                        first_entry--;
    542565                    }
    543566
     
    549572                      grub_printf ("\n");
    550573                    }
    551574                  else
    552                     print_entries (3, 12, first_entry, entryno, menu_entries);
     575                    print_entries (3 + row_start, box_size, first_entry, entryno, menu_entries);
    553576                }
    554577
    555578              cur_entry = menu_entries;
     
    570593                  if (current_term->flags & TERM_DUMB)
    571594                    grub_printf ("\r                                    ");
    572595                  else
    573                     gotoxy (1, 21);
     596                    gotoxy (1 + col_start, 9 + box_size + row_start);
    574597
    575598                  /* Wipe out the previously entered password */
    576599                  grub_memset (entered, 0, sizeof (entered));
     
    651674                  *(new_heap++) = 0;
    652675
    653676                  if (config_entries)
    654                     run_menu (heap, NULL, new_num_entries, new_heap, 0);
     677                    {
     678                      current_entryno = first_entry + entryno;
     679                      run_menu (heap, NULL, new_num_entries, new_heap, 0);
     680                    }
    655681                  else
    656682                    {
    657683                      cls ();
     
    714740 
    715741  cls ();
    716742  setcursor (1);
     743  /* if our terminal needed initialization, we should shut it down
     744   * before booting the kernel, but we want to save what it was so
     745   * we can come back if needed */
     746  prev_term = current_term;
     747  if (current_term->shutdown)
     748    {
     749      current_term->shutdown();
     750      current_term = term_table; /* assumption: console is first */
     751    }
    717752 
    718753  while (1)
    719754    {
     
    727762        cur_entry = get_entry (config_entries, first_entry + entryno, 1);
    728763
    729764      /* Set CURRENT_ENTRYNO for the command "savedefault".  */
    730       current_entryno = first_entry + entryno;
     765      if (config_entries)
     766        current_entryno = first_entry + entryno;
    731767     
    732768      if (run_script (cur_entry, heap))
    733769        {
     
    748784        break;
    749785    }
    750786
     787  /* if we get back here, we should go back to what our term was before */
     788  current_term = prev_term;
     789  if (current_term->startup)
     790      /* if our terminal fails to initialize, fall back to console since
     791       * it should always work */
     792      if (current_term->startup() == 0)
     793          current_term = term_table; /* we know that console is first */
    751794  show_menu = 1;
    752795  goto restart;
    753796}
     
    891934              len = grub_read (buf, sizeof (buf));
    892935              if (len > 0)
    893936                {
     937                  char *tmp;
     938                  char *def;
    894939                  buf[sizeof (buf) - 1] = 0;
    895                   safe_parse_maxint (&p, &saved_entryno);
     940
     941                  if((tmp = grub_strstr(p, ":")) != NULL)
     942                  {
     943                    *tmp++;
     944                    grub_memcpy(&def, &tmp, sizeof(p));
     945                  }else
     946                    grub_memcpy(&def, &p, sizeof(p));
     947                 
     948                  safe_parse_maxint (&def, &saved_entryno);
    896949                }
    897950
    898951              grub_close ();
     
    10501103          while (is_preset);
    10511104        }
    10521105
     1106      /* go ahead and make sure the terminal is setup */
     1107      if (current_term->startup)
     1108        {
     1109          /* If initialization fails, go back to default terminal */
     1110          if (current_term->startup() == 0)
     1111                  {
     1112                      current_term = term_table;
     1113                  }
     1114        }
     1115
    10531116      if (! num_entries)
    10541117        {
    10551118          /* If no acceptable config file, goto command-line, starting
  • stage2/term.h

    diff -Naur grub-0.97.orig/stage2/term.h grub-0.97/stage2/term.h
    old new  
    6060  const char *name;
    6161  /* The feature flags defined above.  */
    6262  unsigned long flags;
     63  /* Default for maximum number of lines if not specified */
     64  unsigned short max_lines;
    6365  /* Put a character.  */
    6466  void (*putchar) (int c);
    6567  /* Check if any input character is available.  */
     
    7981  void (*setcolor) (int normal_color, int highlight_color);
    8082  /* Turn on/off the cursor.  */
    8183  int (*setcursor) (int on);
     84  /* function to start a terminal */
     85  int (*startup) (void);
     86  /* function to use to shutdown a terminal */
     87  void (*shutdown) (void);
    8288};
    8389
    8490/* This lists up available terminals.  */
     
    124130int hercules_setcursor (int on);
    125131#endif
    126132
     133#ifdef SUPPORT_GRAPHICS
     134extern int foreground, background, window_border, graphics_inited, saved_videomode;
     135
     136void graphics_set_splash(char *splashfile);
     137int set_videomode(int mode);
     138int get_videomode(void);
     139void graphics_putchar (int c);
     140int graphics_getxy(void);
     141void graphics_gotoxy(int x, int y);
     142void graphics_cls(void);
     143void graphics_setcolorstate (color_state state);
     144void graphics_setcolor (int normal_color, int highlight_color);
     145int graphics_setcursor (int on);
     146int graphics_init(void);
     147void graphics_end(void);
     148
     149int hex(int v);
     150void graphics_set_palette(int idx, int red, int green, int blue);
     151#endif /* SUPPORT_GRAPHICS */
     152
    127153#endif /* ! GRUB_TERM_HEADER */
  • grub-0.97

    diff -Naur grub-0.97.orig/THANKS grub-0.97/THANKS
    old new  
    121121Yedidyah Bar-David <didi@post.tau.ac.il>
    122122Yury V. Umanets <umka@namesys.com>
    123123Yuri Zaporogets <yuriz@ukr.net>
     124Vitaly Fertman <vitaly@namesys.com>
  • util/grub-install.in

    diff -Naur grub-0.97.orig/util/grub-install.in grub-0.97/util/grub-install.in
    old new  
    8181EOF
    8282}
    8383
     84# Usage: getraid_mdadm mddevice
     85# Routine to find a physical device from an md device
     86# If found, the first grub BIOS device (from device.map) is returned
     87# If no BIOS drives match the RAID devices, the first device returned
     88# from mdadm -D is returned
     89getraid_mdadm() {
     90        device=$1
     91        mdadm=$(mdadm -D "$device") || {
     92                echo "$PROG: mdadm -D $device failed" >&2
     93                exit 1
     94        }
     95        eval "$(
     96                echo "$mdadm" | awk '
     97                        $1 == "Number" && $2 == "Major" { start = 1; next }
     98                        $1 == "UUID" { print "uuid=" $3; start = 0; next }
     99                        !start { next }
     100                        $2 == 0 && $3 == 0 { next }
     101                        { devices = devices "\n" $NF }
     102                        END { print "devices='\''" devices "'\''" }
     103                '
     104        )"
     105
     106        # Convert RAID devices list into a list of disks
     107        tmp_disks=`echo "$devices" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
     108                                         -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
     109                                         -e 's%\(fd[0-9]*\)$%\1%' \
     110                                         -e 's%/part[0-9]*$%/disc%' \
     111                                         -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
     112                                         -e '/^$/d' |
     113                                     sed -n '1h;2,$H;${g;s/\n/|/g;p}'`
     114
     115        # Find first BIOS disk that's a member of the RAID array
     116        # Default to first RAID member if no tmp_disks are BIOS devices
     117        set -- `egrep $tmp_disks $device_map | \
     118                sort | \
     119                sed -n 1p `
     120        device=${2:-${tmp_disks%%|*}}
     121
     122        # Return first partition on BIOS disk that's part of the RAID
     123        echo "$devices" | \
     124                sed -n "\:${device}:p" | \
     125                sed -n 1p
     126}
     127
    84128# Usage: convert os_device
    85129# Convert an OS device to the corresponding GRUB drive.
    86130# This part is OS-specific.
     
    96140    # Break the device name into the disk part and the partition part.
    97141    case "$host_os" in
    98142    linux*)
     143        # Find an actual physical device if we're passed a RAID device
     144        case $1 in
     145                /dev/md*)  set -- `getraid_mdadm $1`
     146        esac
    99147        tmp_disk=`echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
    100148                                  -e 's%\(d[0-9]*\)p[0-9]*$%\1%' \
    101149                                  -e 's%\(fd[0-9]*\)$%\1%' \
     
    112160        tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'`
    113161        tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;;
    114162    freebsd* | kfreebsd*-gnu)
    115         tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \
    116                             | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'`
     163        tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \
     164                            | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'`
    117165        tmp_part=`echo "$1" \
    118166            | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \
    119167            | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"`
     
    131179
    132180    # Get the drive name.
    133181    tmp_drive=`grep -v '^#' $device_map | grep "$tmp_disk *$" \
    134         | sed 's%.*\(([hf]d[0-9][a-g0-9,]*)\).*%\1%'`
     182        | sed 's%.*\(([hf]d[0-9][a-z0-9,]*)\).*%\1%'`
    135183
    136184    # If not found, print an error message and exit.
    137185    if test "x$tmp_drive" = x; then
     
    148196        gnu*)
    149197            if echo $tmp_part | grep "^s" >/dev/null; then
    150198                tmp_pc_slice=`echo $tmp_part \
    151                     | sed "s%s\([0-9]*\)[a-g]*$%\1%"`
     199                    | sed "s%s\([0-9]*\)[a-z]*$%\1%"`
    152200                tmp_drive=`echo "$tmp_drive" \
    153201                    | sed "s%)%,\`expr "$tmp_pc_slice" - 1\`)%"`
    154202            fi
    155             if echo $tmp_part | grep "[a-g]$" >/dev/null; then
     203            if echo $tmp_part | grep "[a-z]$" >/dev/null; then
    156204                tmp_bsd_partition=`echo "$tmp_part" \
    157                     | sed "s%[^a-g]*\([a-g]\)$%\1%"`
     205                    | sed "s%[^a-z]*\([a-z]\)$%\1%"`
    158206                tmp_drive=`echo "$tmp_drive" \
    159207                    | sed "s%)%,$tmp_bsd_partition)%"`
    160208            fi
     
    336384    # Create a safe temporary file.
    337385    test -n "$mklog" && log_file=`$mklog`
    338386
     387    # Before all invocations of the grub shell, call sync to make sure
     388    # the raw device is in sync with any bufferring in filesystems.
     389    sync
     390 
    339391    $grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
    340392quit
    341393EOF
     
    450502# Create a safe temporary file.
    451503test -n "$mklog" && log_file=`$mklog`
    452504
     505# Sync to prevent GRUB from not finding stage files (notably, on XFS)
     506sync
     507
     508# XFS needs special magic
     509xfs_frozen=false
     510if which xfs_freeze > /dev/null ; then
     511  cat << EOF
     512Due to a bug in xfs_freeze, the following command might produce a segmentation
     513fault when ${grubdir} is not in an XFS filesystem. This error is harmless and
     514can be ignored.
     515EOF
     516  if xfs_freeze -f ${grubdir} ; then xfs_frozen=true ; fi
     517fi
     518
     519# Before all invocations of the grub shell, call sync to make sure
     520# the raw device is in sync with any bufferring in filesystems.
     521sync
     522
    453523# Now perform the installation.
    454524$grub_shell --batch $no_floppy --device-map=$device_map <<EOF >$log_file
    455525root $root_drive
     
    457527quit
    458528EOF
    459529
     530if ${xfs_frozen} ; then
     531  xfs_freeze -u ${grubdir}
     532fi
     533
    460534if grep "Error [0-9]*: " $log_file >/dev/null || test $debug = yes; then
    461535    cat $log_file 1>&2
    462536    exit 1
Note: See TracBrowser for help on using the repository browser.