All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] grub-install for EFI
@ 2007-05-11 16:03 Robert Millan
  2007-05-11 16:11 ` Robert Millan
  2007-05-15 20:16 ` [PATCH] grub-install for EFI Yoshinori K. Okuji
  0 siblings, 2 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-11 16:03 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]


Hi,

Please have a look at this patch that adds grub-install for EFI and tell me
what you think.  I have some doubts/comments myself, and I'll reply to my own
message to use the patch context.

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.

[-- Attachment #2: efi_grub_install.diff --]
[-- Type: text/x-diff, Size: 8916 bytes --]

diff -Nur grub2-1.95+20070507.old/conf/i386-efi.rmk grub2-1.95+20070507/conf/i386-efi.rmk
--- grub2-1.95+20070507.old/conf/i386-efi.rmk	2007-05-11 17:45:18.000000000 +0200
+++ grub2-1.95+20070507/conf/i386-efi.rmk	2007-05-11 17:57:19.000000000 +0200
@@ -6,7 +6,7 @@
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-#sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+sbin_UTILITIES = grub-mkdevicemap grub-probe
 #ifeq ($(enable_grub_emu), yes)
 #sbin_UTILITIES += grub-emu
 #endif
@@ -24,15 +24,16 @@
 #	kern/fs.c kern/env.c fs/fshelp.c
 
 # For grub-mkdevicemap.
-#grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
+grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
 
 # For grub-probe.
-#grub_probe_SOURCES = util/i386/pc/grub-probe.c	\
-#	util/i386/pc/biosdisk.c	util/misc.c util/i386/pc/getroot.c	\
-#	kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c	\
-#	fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c 	\
-#	fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c 	\
-#	fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c
+grub_probe_SOURCES = util/i386/pc/grub-probe.c	\
+	util/i386/pc/biosdisk.c	util/misc.c util/i386/pc/getroot.c	\
+	kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c	\
+	fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c		\
+	partmap/gpt.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c	\
+	kern/env.c fs/fshelp.c fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c	\
+	disk/lvm.c disk/raid.c
 
 # For grub-emu.
 grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h		\
diff -Nur grub2-1.95+20070507.old/util/i386/efi/grub-install.in grub2-1.95+20070507/util/i386/efi/grub-install.in
--- grub2-1.95+20070507.old/util/i386/efi/grub-install.in	1970-01-01 01:00:00.000000000 +0100
+++ grub2-1.95+20070507/util/i386/efi/grub-install.in	2007-05-11 18:00:44.000000000 +0200
@@ -0,0 +1,206 @@
+#! /bin/sh
+
+# Install GRUB on your EFI partition.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St - Suite 330, Boston, MA 02110, USA.
+
+# Initialize some variables.
+transform="@program_transform_name@"
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+bindir=@bindir@
+libdir=@libdir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_TARNAME=@PACKAGE_TARNAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+target_cpu=@target_cpu@
+platform=@platform@
+pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
+
+grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
+grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
+modules=
+
+install_directory=
+no_floppy=
+force_lba=
+recheck=no
+debug=no
+
+# Usage: usage
+# Print the usage.
+usage () {
+    cat <<EOF
+Usage: grub-install [OPTION] install_directory
+Install GRUB on your EFI partition.
+
+  -h, --help              print this message and exit
+  -v, --version           print the version information and exit
+  --modules=MODULES       pre-load specified modules MODULES
+  --grub-mkimage=FILE     use FILE as grub-mkimage
+  --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
+  --grub-probe=FILE       use FILE as grub-probe
+  --no-floppy             do not probe any floppy drive
+  --recheck               probe a device map even if it already exists
+
+INSTALL_DIRECTORY has to be the directory your EFI partition is mounted on.
+
+grub-install copies GRUB images into INSTALL_DIRECTORY.
+
+Report bugs to <bug-grub@gnu.org>.
+EOF
+}
+
+# Check the arguments.
+for option in "$@"; do
+    case "$option" in
+    -h | --help)
+	usage
+	exit 0 ;;
+    -v | --version)
+	echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
+	exit 0 ;;
+    --modules=*)
+	modules=`echo "$option" | sed 's/--modules=//'` ;;
+    --grub-mkimage=*)
+	grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
+    --grub-mkdevicemap=*)
+	grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
+    --grub-probe=*)
+	grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
+    --no-floppy)
+	no_floppy="--no-floppy" ;;
+    --recheck)
+	recheck=yes ;;
+    # This is an undocumented feature...
+    --debug)
+	debug=yes ;;
+    -*)
+	echo "Unrecognized option \`$option'" 1>&2
+	usage
+	exit 1
+	;;
+    *)
+	if test "x$install_directory" != x; then
+	    echo "More than one install_directories?" 1>&2
+	    usage
+	    exit 1
+	fi
+	install_directory="${option}" ;;
+    esac
+done
+
+if test "x$install_directory" = x; then
+    echo "install_directory not specified." 1>&2
+    usage
+    exit 1
+fi
+
+# If the debugging feature is enabled, print commands.
+if test $debug = yes; then
+    set -x
+fi
+
+grubdir=${install_directory}
+device_map=${grubdir}/device.map
+
+# Check if GRUB is installed.
+set $grub_mkimage dummy
+if test -f "$1"; then
+    :
+else
+    echo "$1: Not found." 1>&2
+    exit 1
+fi
+
+set $grub_mkdevicemap dummy
+if test -f "$1"; then
+    :
+else
+    echo "$1: Not found." 1>&2
+    exit 1
+fi
+
+# Create the GRUB directory if it is not present.
+test -d "$grubdir" || mkdir "$grubdir" || exit 1
+
+# If --recheck is specified, remove the device map, if present.
+if test $recheck = yes; then
+    rm -f $device_map
+fi
+
+# Create the device map file if it is not present.
+if test -f "$device_map"; then
+    :
+else
+    # Create a safe temporary file.
+    test -n "$mklog" && log_file=`$mklog`
+
+    $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1
+fi
+
+# Make sure that there is no duplicated entry.
+tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
+    | sort | uniq -d | sed -n 1p`
+if test -n "$tmp"; then
+    echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
+    exit 1
+fi
+
+# Copy the GRUB images to the GRUB directory.
+for file in ${grubdir}/*.mod ${grubdir}/*.lst; do
+    if test -f $file && [ "`basename $file`" != menu.lst ]; then
+	rm -f $file || exit 1
+    fi
+done
+for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
+    cp -f $file ${grubdir} || exit 1
+done
+
+# Create the core image. First, auto-detect the filesystem module.
+fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
+if test "x$fs_module" = xfat; then :; else
+    echo "${grubdir} doesn't look like an EFI partition." 1>&2
+    exit 1
+fi
+
+# Then the partition map module.
+partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir}`
+if test "x$partmap_module" = x -a "x$modules" = x; then
+    echo "Auto-detection of a partition map module failed." 1>&2
+    echo "Please specify the module with the option \`--modules' explicitly." 1>&2
+    exit 1
+fi
+
+# _chain is often useful
+modules="$modules $fs_module $partmap_module _chain"
+
+$grub_mkimage --output=${grubdir}/grub.efi $modules || exit 1
+
+# Prompt the user to check if the device map is correct.
+echo "Installation finished. No error reported."
+echo "This is the contents of the device map $device_map."
+echo "Check if this is correct or not. If any of the lines is incorrect,"
+echo "fix it and re-run the script \`grub-install'."
+echo
+
+cat $device_map
+
+# Bye.
+exit 0
diff -Nur grub2-1.95+20070507.old/util/i386/pc/biosdisk.c grub2-1.95+20070507/util/i386/pc/biosdisk.c
--- grub2-1.95+20070507.old/util/i386/pc/biosdisk.c	2007-05-11 17:45:18.000000000 +0200
+++ grub2-1.95+20070507/util/i386/pc/biosdisk.c	2007-05-11 17:57:19.000000000 +0200
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <grub/machine/biosdisk.h>
+#include <grub/i386/pc/biosdisk.h>
 #include <grub/disk.h>
 #include <grub/partition.h>
 #include <grub/pc_partition.h>
diff -Nur grub2-1.95+20070507.old/util/i386/pc/grub-probe.c grub2-1.95+20070507/util/i386/pc/grub-probe.c
--- grub2-1.95+20070507.old/util/i386/pc/grub-probe.c	2007-05-11 17:45:18.000000000 +0200
+++ grub2-1.95+20070507/util/i386/pc/grub-probe.c	2007-05-11 17:57:19.000000000 +0200
@@ -26,7 +26,7 @@
 #include <grub/fs.h>
 #include <grub/partition.h>
 #include <grub/pc_partition.h>
-#include <grub/machine/util/biosdisk.h>
+#include <grub/i386/pc/util/biosdisk.h>
 #include <grub/util/getroot.h>
 #include <grub/term.h>
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-11 16:03 [PATCH] grub-install for EFI Robert Millan
@ 2007-05-11 16:11 ` Robert Millan
  2007-05-11 16:21   ` Robert Millan
  2007-05-15 20:20   ` Yoshinori K. Okuji
  2007-05-15 20:16 ` [PATCH] grub-install for EFI Yoshinori K. Okuji
  1 sibling, 2 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-11 16:11 UTC (permalink / raw)
  To: grub-devel

On Fri, May 11, 2007 at 06:03:14PM +0200, Robert Millan wrote:
> diff -Nur grub2-1.95+20070507.old/conf/i386-efi.rmk grub2-1.95+20070507/conf/i386-efi.rmk
> --- grub2-1.95+20070507.old/conf/i386-efi.rmk	2007-05-11 17:45:18.000000000 +0200
> +++ grub2-1.95+20070507/conf/i386-efi.rmk	2007-05-11 17:57:19.000000000 +0200
> @@ -6,7 +6,7 @@
>  
>  # Utilities.
>  bin_UTILITIES = grub-mkimage
> -#sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
> +sbin_UTILITIES = grub-mkdevicemap grub-probe

grub-probe is needed to check partmap (so we don't have to assume gpt).

grub-mkdevicemap is needed to create device.map, without which grub-probe
won't work.

> diff -Nur grub2-1.95+20070507.old/util/i386/efi/grub-install.in grub2-1.95+20070507/util/i386/efi/grub-install.in
> --- grub2-1.95+20070507.old/util/i386/efi/grub-install.in	1970-01-01 01:00:00.000000000 +0100
> +++ grub2-1.95+20070507/util/i386/efi/grub-install.in	2007-05-11 18:00:44.000000000 +0200

Note: this grub-install.in is based on the i386/pc version.  I tried to keep
changes minimal, so if you diff them it'll produce readable output.

One thing that I'm not sure about is the CLI inconsistency.  Perhaps it
shouldn't take the directory as a standalone parameter, and instead use
--root-directory?

> diff -Nur grub2-1.95+20070507.old/util/i386/pc/biosdisk.c grub2-1.95+20070507/util/i386/pc/biosdisk.c
> --- grub2-1.95+20070507.old/util/i386/pc/biosdisk.c	2007-05-11 17:45:18.000000000 +0200
> +++ grub2-1.95+20070507/util/i386/pc/biosdisk.c	2007-05-11 17:57:19.000000000 +0200
> @@ -18,7 +18,7 @@
>   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   */
>  
> -#include <grub/machine/biosdisk.h>
> +#include <grub/i386/pc/biosdisk.h>
>  #include <grub/disk.h>
>  #include <grub/partition.h>
>  #include <grub/pc_partition.h>
> diff -Nur grub2-1.95+20070507.old/util/i386/pc/grub-probe.c grub2-1.95+20070507/util/i386/pc/grub-probe.c
> --- grub2-1.95+20070507.old/util/i386/pc/grub-probe.c	2007-05-11 17:45:18.000000000 +0200
> +++ grub2-1.95+20070507/util/i386/pc/grub-probe.c	2007-05-11 17:57:19.000000000 +0200
> @@ -26,7 +26,7 @@
>  #include <grub/fs.h>
>  #include <grub/partition.h>
>  #include <grub/pc_partition.h>
> -#include <grub/machine/util/biosdisk.h>
> +#include <grub/i386/pc/util/biosdisk.h>
>  #include <grub/util/getroot.h>
>  #include <grub/term.h>

Not really sure about these.  Seems ugly, but biosdisk.h has the
grub_util_biosdisk_get_grub_dev definition, which is not really
i386/pc-specific.  Also, note that powerpc needs them as well if we
want update-grub to work there (haven't submitted this part, because it
grub-probe on powerpc has other issues that I cannot debug).

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-11 16:11 ` Robert Millan
@ 2007-05-11 16:21   ` Robert Millan
  2007-05-15 18:23     ` new patch Robert Millan
  2007-05-15 20:22     ` [PATCH] grub-install for EFI Yoshinori K. Okuji
  2007-05-15 20:20   ` Yoshinori K. Okuji
  1 sibling, 2 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-11 16:21 UTC (permalink / raw)
  To: grub-devel

On Fri, May 11, 2007 at 06:11:34PM +0200, Robert Millan wrote:
> 
> One thing that I'm not sure about is the CLI inconsistency.  Perhaps it
> shouldn't take the directory as a standalone parameter, and instead use
> --root-directory?

Or perhaps it should do like powerpc and check that /boot/grub is a mount
point?

# Find the partition at the right mount point.
install_device=`awk '$2 == '"\"$grubdir\""' { print $1 }' < /proc/mounts`
if test "x$install_device" = x; then
    echo "$grubdir must be a mount point."
    exit 1
fi

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* new patch
  2007-05-11 16:21   ` Robert Millan
@ 2007-05-15 18:23     ` Robert Millan
  2007-05-15 20:22     ` [PATCH] grub-install for EFI Yoshinori K. Okuji
  1 sibling, 0 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-15 18:23 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]


New patch.  Fixed a few errors, enabled grub-install in sbin_SCRIPTS, and made
the CLI consistent with the other grub-installs.

The patch works in my qemu environment [1], so I've added it in Debian already.
If nobody objects, or reports that the patch is wrong whatsoever, I'll add it
to CVS in a few days.

Btw, since my new grub-install is based on the PC version and they're very
similar, I've also attached a diff between both versions so you can't check
more easily.

[1] Still, grub boots but can't access my filesystems.  But this seems
completely unrelated to grub-install, and probably caused by firmware bugs.

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.

[-- Attachment #2: efi.diff --]
[-- Type: text/x-diff, Size: 9607 bytes --]

diff -Nur grub2-1.95+20070507.old/conf/i386-efi.rmk grub2-1.95+20070507/conf/i386-efi.rmk
--- grub2-1.95+20070507.old/conf/i386-efi.rmk	2007-05-15 19:45:29.000000000 +0200
+++ grub2-1.95+20070507/conf/i386-efi.rmk	2007-05-15 19:45:48.000000000 +0200
@@ -6,7 +6,7 @@
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-#sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+sbin_UTILITIES = grub-mkdevicemap grub-probe
 #ifeq ($(enable_grub_emu), yes)
 #sbin_UTILITIES += grub-emu
 #endif
@@ -24,15 +24,16 @@
 #	kern/fs.c kern/env.c fs/fshelp.c
 
 # For grub-mkdevicemap.
-#grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
+grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
 
 # For grub-probe.
-#grub_probe_SOURCES = util/i386/pc/grub-probe.c	\
-#	util/i386/pc/biosdisk.c	util/misc.c util/i386/pc/getroot.c	\
-#	kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c	\
-#	fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c 	\
-#	fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c 	\
-#	fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c
+grub_probe_SOURCES = util/i386/pc/grub-probe.c	\
+	util/i386/pc/biosdisk.c	util/misc.c util/i386/pc/getroot.c	\
+	kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c	\
+	fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c		\
+	partmap/gpt.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c	\
+	kern/env.c fs/fshelp.c fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c	\
+	disk/lvm.c disk/raid.c
 
 # For grub-emu.
 grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h		\
@@ -63,10 +64,10 @@
 grub_emu_LDFLAGS = $(LIBCURSES)
 
 # Scripts.
-#sbin_SCRIPTS = grub-install
+sbin_SCRIPTS = grub-install
 
 # For grub-install.
-#grub_install_SOURCES = util/efi/pc/grub-install.in
+grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
 pkgdata_MODULES = kernel.mod normal.mod _chain.mod chain.mod \
diff -Nur grub2-1.95+20070507.old/util/i386/efi/grub-install.in grub2-1.95+20070507/util/i386/efi/grub-install.in
--- grub2-1.95+20070507.old/util/i386/efi/grub-install.in	1970-01-01 01:00:00.000000000 +0100
+++ grub2-1.95+20070507/util/i386/efi/grub-install.in	2007-05-15 19:45:40.000000000 +0200
@@ -0,0 +1,212 @@
+#! /bin/sh
+
+# Install GRUB on your EFI partition.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St - Suite 330, Boston, MA 02110, USA.
+
+# Initialize some variables.
+transform="@program_transform_name@"
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+bindir=@bindir@
+libdir=@libdir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_TARNAME=@PACKAGE_TARNAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+target_cpu=@target_cpu@
+platform=@platform@
+pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
+
+grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
+grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
+rootdir=
+grub_prefix=`echo /boot/grub | sed ${transform}`
+modules=
+
+no_floppy=
+force_lba=
+recheck=no
+debug=no
+
+# Usage: usage
+# Print the usage.
+usage () {
+    cat <<EOF
+Usage: grub-install [OPTION]
+Install GRUB on your EFI partition.
+
+  -h, --help              print this message and exit
+  -v, --version           print the version information and exit
+  --modules=MODULES       pre-load specified modules MODULES
+  --root-directory=DIR    install GRUB images under the directory DIR
+                          instead of the root directory
+  --grub-mkimage=FILE     use FILE as grub-mkimage
+  --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
+  --grub-probe=FILE       use FILE as grub-probe
+  --no-floppy             do not probe any floppy drive
+  --recheck               probe a device map even if it already exists
+
+grub-install copies GRUB images into the DIR/boot directory specfied by
+--root-directory.
+
+Report bugs to <bug-grub@gnu.org>.
+EOF
+}
+
+# Check the arguments.
+for option in "$@"; do
+    case "$option" in
+    -h | --help)
+	usage
+	exit 0 ;;
+    -v | --version)
+	echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
+	exit 0 ;;
+    --modules=*)
+	modules=`echo "$option" | sed 's/--modules=//'` ;;
+    --root-directory=*)
+	rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
+    --grub-mkimage=*)
+	grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
+    --grub-mkdevicemap=*)
+	grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
+    --grub-probe=*)
+	grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
+    --no-floppy)
+	no_floppy="--no-floppy" ;;
+    --recheck)
+	recheck=yes ;;
+    # This is an undocumented feature...
+    --debug)
+	debug=yes ;;
+    *)
+	echo "Unrecognized option \`$option'" 1>&2
+	usage
+	exit 1
+	;;
+    esac
+done
+
+# If the debugging feature is enabled, print commands.
+if test $debug = yes; then
+    set -x
+fi
+
+# Initialize these directories here, since ROOTDIR was initialized.
+case "$host_os" in
+netbsd* | openbsd*)
+    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
+    # instead of /boot/grub.
+    grub_prefix=`echo /grub | sed ${transform}`
+    bootdir=${rootdir}
+    ;;
+*)
+    # Use /boot/grub by default.
+    bootdir=${rootdir}/boot
+    ;;
+esac
+
+grubdir=${bootdir}/`echo grub | sed ${transform}`
+device_map=${grubdir}/device.map
+
+# Check if GRUB is installed.
+set $grub_mkimage dummy
+if test -f "$1"; then
+    :
+else
+    echo "$1: Not found." 1>&2
+    exit 1
+fi
+
+set $grub_mkdevicemap dummy
+if test -f "$1"; then
+    :
+else
+    echo "$1: Not found." 1>&2
+    exit 1
+fi
+
+# Create the GRUB directory if it is not present.
+test -d "$bootdir" || mkdir "$bootdir" || exit 1
+test -d "$grubdir" || mkdir "$grubdir" || exit 1
+
+# If --recheck is specified, remove the device map, if present.
+if test $recheck = yes; then
+    rm -f $device_map
+fi
+
+# Create the device map file if it is not present.
+if test -f "$device_map"; then
+    :
+else
+    # Create a safe temporary file.
+    test -n "$mklog" && log_file=`$mklog`
+
+    $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1
+fi
+
+# Make sure that there is no duplicated entry.
+tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
+    | sort | uniq -d | sed -n 1p`
+if test -n "$tmp"; then
+    echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
+    exit 1
+fi
+
+# Copy the GRUB images to the GRUB directory.
+for file in ${grubdir}/*.mod ${grubdir}/*.lst; do
+    if test -f $file && [ "`basename $file`" != menu.lst ]; then
+	rm -f $file || exit 1
+    fi
+done
+for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
+    cp -f $file ${grubdir} || exit 1
+done
+
+# Create the core image. First, auto-detect the filesystem module.
+fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
+if test "x$fs_module" = xfat; then :; else
+    echo "${grubdir} doesn't look like an EFI partition." 1>&2
+    exit 1
+fi
+
+# Then the partition map module.
+partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir}`
+if test "x$partmap_module" = x -a "x$modules" = x; then
+    echo "Auto-detection of a partition map module failed." 1>&2
+    echo "Please specify the module with the option \`--modules' explicitly." 1>&2
+    exit 1
+fi
+
+# _chain is often useful
+modules="$modules $fs_module $partmap_module _chain"
+
+$grub_mkimage --output=${grubdir}/grub.efi $modules || exit 1
+
+# Prompt the user to check if the device map is correct.
+echo "Installation finished. No error reported."
+echo "This is the contents of the device map $device_map."
+echo "Check if this is correct or not. If any of the lines is incorrect,"
+echo "fix it and re-run the script \`grub-install'."
+echo
+
+cat $device_map
+
+# Bye.
+exit 0
diff -Nur grub2-1.95+20070507.old/util/i386/pc/biosdisk.c grub2-1.95+20070507/util/i386/pc/biosdisk.c
--- grub2-1.95+20070507.old/util/i386/pc/biosdisk.c	2007-05-15 19:45:19.000000000 +0200
+++ grub2-1.95+20070507/util/i386/pc/biosdisk.c	2007-05-15 19:45:40.000000000 +0200
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <grub/machine/biosdisk.h>
+#include <grub/i386/pc/biosdisk.h>
 #include <grub/disk.h>
 #include <grub/partition.h>
 #include <grub/pc_partition.h>
diff -Nur grub2-1.95+20070507.old/util/i386/pc/grub-probe.c grub2-1.95+20070507/util/i386/pc/grub-probe.c
--- grub2-1.95+20070507.old/util/i386/pc/grub-probe.c	2007-05-15 19:45:19.000000000 +0200
+++ grub2-1.95+20070507/util/i386/pc/grub-probe.c	2007-05-15 19:45:40.000000000 +0200
@@ -26,7 +26,7 @@
 #include <grub/fs.h>
 #include <grub/partition.h>
 #include <grub/pc_partition.h>
-#include <grub/machine/util/biosdisk.h>
+#include <grub/i386/pc/util/biosdisk.h>
 #include <grub/util/getroot.h>
 #include <grub/term.h>
 

[-- Attachment #3: diff_between_pc_and_efi.diff --]
[-- Type: text/x-diff, Size: 4646 bytes --]

--- util/i386/pc/grub-install.in	2007-05-07 21:54:46.000000000 +0200
+++ util/i386/efi/grub-install.in	2007-05-15 20:22:05.000000000 +0200
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# Install GRUB on your drive.
+# Install GRUB on your EFI partition.
 # Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
 grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
@@ -40,7 +39,6 @@
 grub_prefix=`echo /boot/grub | sed ${transform}`
 modules=
 
-install_device=
 no_floppy=
 force_lba=
 recheck=no
@@ -50,26 +48,22 @@
 # Print the usage.
 usage () {
     cat <<EOF
-Usage: grub-install [OPTION] install_device
-Install GRUB on your drive.
+Usage: grub-install [OPTION]
+Install GRUB on your EFI partition.
 
   -h, --help              print this message and exit
   -v, --version           print the version information and exit
   --modules=MODULES       pre-load specified modules MODULES
   --root-directory=DIR    install GRUB images under the directory DIR
                           instead of the root directory
-  --grub-setup=FILE       use FILE as grub-setup
   --grub-mkimage=FILE     use FILE as grub-mkimage
   --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
   --grub-probe=FILE       use FILE as grub-probe
   --no-floppy             do not probe any floppy drive
   --recheck               probe a device map even if it already exists
 
-INSTALL_DEVICE can be a GRUB device name or a system device filename.
-
 grub-install copies GRUB images into the DIR/boot directory specfied by
---root-directory, and uses grub-setup to install grub into the boot
-sector.
+--root-directory.
 
 Report bugs to <bug-grub@gnu.org>.
 EOF
@@ -88,8 +82,6 @@
 	modules=`echo "$option" | sed 's/--modules=//'` ;;
     --root-directory=*)
 	rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
-    --grub-setup=*)
-	grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
     --grub-mkimage=*)
 	grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
     --grub-mkdevicemap=*)
@@ -103,27 +95,14 @@
     # This is an undocumented feature...
     --debug)
 	debug=yes ;;
-    -*)
+    *)
 	echo "Unrecognized option \`$option'" 1>&2
 	usage
 	exit 1
 	;;
-    *)
-	if test "x$install_device" != x; then
-	    echo "More than one install_devices?" 1>&2
-	    usage
-	    exit 1
-	fi
-	install_device="${option}" ;;
     esac
 done
 
-if test "x$install_device" = x; then
-    echo "install_device not specified." 1>&2
-    usage
-    exit 1
-fi
-
 # If the debugging feature is enabled, print commands.
 if test $debug = yes; then
     set -x
@@ -147,14 +126,6 @@
 device_map=${grubdir}/device.map
 
 # Check if GRUB is installed.
-set $grub_setup dummy
-if test -f "$1"; then
-    :
-else
-    echo "$1: Not found." 1>&2
-    exit 1
-fi
-
 set $grub_mkimage dummy
 if test -f "$1"; then
     :
@@ -199,20 +170,19 @@
 fi
 
 # Copy the GRUB images to the GRUB directory.
-for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img; do
+for file in ${grubdir}/*.mod ${grubdir}/*.lst; do
     if test -f $file && [ "`basename $file`" != menu.lst ]; then
 	rm -f $file || exit 1
     fi
 done
-for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst ${pkglibdir}/*.img; do
+for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
     cp -f $file ${grubdir} || exit 1
 done
 
 # Create the core image. First, auto-detect the filesystem module.
 fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
-if test "x$fs_module" = x -a "x$modules" = x; then
-    echo "Auto-detection of a filesystem module failed." 1>&2
-    echo "Please specify the module with the option \`--modules' explicitly." 1>&2
+if test "x$fs_module" = xfat; then :; else
+    echo "${grubdir} doesn't look like an EFI partition." 1>&2
     exit 1
 fi
 
@@ -227,11 +197,7 @@
 # _chain is often useful
 modules="$modules $fs_module $partmap_module _chain"
 
-$grub_mkimage --output=${grubdir}/core.img $modules || exit 1
-
-# Now perform the installation.
-$grub_setup --directory=${grubdir} --device-map=${device_map} \
-    ${install_device} || exit 1
+$grub_mkimage --output=${grubdir}/grub.efi $modules || exit 1
 
 # Prompt the user to check if the device map is correct.
 echo "Installation finished. No error reported."

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-11 16:03 [PATCH] grub-install for EFI Robert Millan
  2007-05-11 16:11 ` Robert Millan
@ 2007-05-15 20:16 ` Yoshinori K. Okuji
  2007-05-16  6:25   ` Robert Millan
  1 sibling, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-15 20:16 UTC (permalink / raw)
  To: The development of GRUB 2

On Friday 11 May 2007 18:03, Robert Millan wrote:
> Please have a look at this patch that adds grub-install for EFI and tell me
> what you think.  I have some doubts/comments myself, and I'll reply to my
> own message to use the patch context.

In my opinion, grub-install is not very useful without grub-setup. As I 
haven't reverse-engineered "bless" yet, I don't know how to implement it. I 
guess it just modifies some bytes in a superblock or somewhere, though.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-11 16:11 ` Robert Millan
  2007-05-11 16:21   ` Robert Millan
@ 2007-05-15 20:20   ` Yoshinori K. Okuji
  2007-05-16  6:31     ` Robert Millan
  1 sibling, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-15 20:20 UTC (permalink / raw)
  To: The development of GRUB 2

On Friday 11 May 2007 18:11, Robert Millan wrote:
> grub-probe is needed to check partmap (so we don't have to assume gpt).

Yes.

> grub-mkdevicemap is needed to create device.map, without which grub-probe
> won't work.

Right.

> Note: this grub-install.in is based on the i386/pc version.  I tried to
> keep changes minimal, so if you diff them it'll produce readable output.
>
> One thing that I'm not sure about is the CLI inconsistency.  Perhaps it
> shouldn't take the directory as a standalone parameter, and instead use
> --root-directory?

Consistency is important, but it is not a must, as long as the user can easily 
guess the difference. In principle, you should respect consistency, but 
should not blindly believe in it. So if you think it is reasonable to make 
difference, you can. Otherwise, don't.

> Not really sure about these.  Seems ugly, but biosdisk.h has the
> grub_util_biosdisk_get_grub_dev definition, which is not really
> i386/pc-specific.  Also, note that powerpc needs them as well if we
> want update-grub to work there (haven't submitted this part, because it
> grub-probe on powerpc has other issues that I cannot debug).

If it is not specific to i386-pc, it should be moved to somewhere else.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-11 16:21   ` Robert Millan
  2007-05-15 18:23     ` new patch Robert Millan
@ 2007-05-15 20:22     ` Yoshinori K. Okuji
  2007-05-16  6:17       ` Robert Millan
  1 sibling, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-15 20:22 UTC (permalink / raw)
  To: The development of GRUB 2

On Friday 11 May 2007 18:21, Robert Millan wrote:
> On Fri, May 11, 2007 at 06:11:34PM +0200, Robert Millan wrote:
> > One thing that I'm not sure about is the CLI inconsistency.  Perhaps it
> > shouldn't take the directory as a standalone parameter, and instead use
> > --root-directory?
>
> Or perhaps it should do like powerpc and check that /boot/grub is a mount
> point?
>
> # Find the partition at the right mount point.
> install_device=`awk '$2 == '"\"$grubdir\""' { print $1 }' < /proc/mounts`
> if test "x$install_device" = x; then
>     echo "$grubdir must be a mount point."
>     exit 1
> fi

It is a bad idea to use /proc, at least without checking the operating system. 
This makes the script unportable among host operating systems.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-15 20:22     ` [PATCH] grub-install for EFI Yoshinori K. Okuji
@ 2007-05-16  6:17       ` Robert Millan
  2007-05-17 19:17         ` Yoshinori K. Okuji
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Millan @ 2007-05-16  6:17 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, May 15, 2007 at 10:22:06PM +0200, Yoshinori K. Okuji wrote:
> > Or perhaps it should do like powerpc and check that /boot/grub is a mount
> > point?
> >
> > # Find the partition at the right mount point.
> > install_device=`awk '$2 == '"\"$grubdir\""' { print $1 }' < /proc/mounts`
> > if test "x$install_device" = x; then
> >     echo "$grubdir must be a mount point."
> >     exit 1
> > fi
> 
> It is a bad idea to use /proc, at least without checking the operating system. 
> This makes the script unportable among host operating systems.

Note that this code is in powerpc/../grub-install.in already, and in my version
of i386/efi/grub-install.in it didn't made in.  Instead, sanity check there is:

  fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
  if test "x$fs_module" = xfat; then :; else
      echo "${grubdir} doesn't look like an EFI partition." 1>&2
      exit 1
  fi

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-15 20:16 ` [PATCH] grub-install for EFI Yoshinori K. Okuji
@ 2007-05-16  6:25   ` Robert Millan
  2007-05-17 19:18     ` Yoshinori K. Okuji
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Millan @ 2007-05-16  6:25 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, May 15, 2007 at 10:16:11PM +0200, Yoshinori K. Okuji wrote:
> On Friday 11 May 2007 18:03, Robert Millan wrote:
> > Please have a look at this patch that adds grub-install for EFI and tell me
> > what you think.  I have some doubts/comments myself, and I'll reply to my
> > own message to use the patch context.
> 
> In my opinion, grub-install is not very useful without grub-setup.

It saves a pair of things to the user (figuring out which modules are needed,
and what to do with the resulting grub.efi image).  From Debian POV, it's very
important so that grub installs can be automated from debian-installer (without
duplicating code, that is).

> As I 
> haven't reverse-engineered "bless" yet, I don't know how to implement it. I 
> guess it just modifies some bytes in a superblock or somewhere, though.

What is bless needed for?  In my environment (Debian GNU/Linux on a qemu
sandbox with EFI firmware), it was not necessary to get grub.efi booting
(although later it had issues accessing filesystems other than the EFI
partition, but I suppose this might be a qemu/firmware bug).

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-15 20:20   ` Yoshinori K. Okuji
@ 2007-05-16  6:31     ` Robert Millan
  2007-05-16 15:38       ` grub-install for EFI (please test) Robert Millan
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Millan @ 2007-05-16  6:31 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, May 15, 2007 at 10:20:41PM +0200, Yoshinori K. Okuji wrote:
> >
> > One thing that I'm not sure about is the CLI inconsistency.  Perhaps it
> > shouldn't take the directory as a standalone parameter, and instead use
> > --root-directory?
> 
> Consistency is important, but it is not a must, as long as the user can easily 
> guess the difference. In principle, you should respect consistency, but 
> should not blindly believe in it. So if you think it is reasonable to make 
> difference, you can. Otherwise, don't.

Ok.  My last version is mostly consistent (/boot/grub path is a default, and
can be overriden the same way), the difference being that it doesn't take any
non-flag argument.  But I think this difference is reasonable, specially
considering that i386/pc/grub-install and powerpc/grub-install already differ
on this part.

> > Not really sure about these.  Seems ugly, but biosdisk.h has the
> > grub_util_biosdisk_get_grub_dev definition, which is not really
> > i386/pc-specific.  Also, note that powerpc needs them as well if we
> > want update-grub to work there (haven't submitted this part, because it
> > grub-probe on powerpc has other issues that I cannot debug).
> 
> If it is not specific to i386-pc, it should be moved to somewhere else.

Will do.

Thanks,

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* grub-install for EFI (please test)
  2007-05-16  6:31     ` Robert Millan
@ 2007-05-16 15:38       ` Robert Millan
  0 siblings, 0 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-16 15:38 UTC (permalink / raw)
  To: The development of GRUB 2


My grub-install for EFI is in CVS now.  I would appreciate if someone can
test it on real hardware, since it's only known to work in qemu. :-)

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-16  6:17       ` Robert Millan
@ 2007-05-17 19:17         ` Yoshinori K. Okuji
  0 siblings, 0 replies; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-17 19:17 UTC (permalink / raw)
  To: The development of GRUB 2

On Wednesday 16 May 2007 08:17, Robert Millan wrote:
> Note that this code is in powerpc/../grub-install.in already, and in my
> version of i386/efi/grub-install.in it didn't made in.  Instead, sanity
> check there is:

This means that I was not careful enough to review the powerpc-specific code. 
This must be fixed.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-16  6:25   ` Robert Millan
@ 2007-05-17 19:18     ` Yoshinori K. Okuji
  2007-05-18  6:37       ` Robert Millan
  0 siblings, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-17 19:18 UTC (permalink / raw)
  To: The development of GRUB 2

On Wednesday 16 May 2007 08:25, Robert Millan wrote:
> On Tue, May 15, 2007 at 10:16:11PM +0200, Yoshinori K. Okuji wrote:
> > On Friday 11 May 2007 18:03, Robert Millan wrote:
> > > Please have a look at this patch that adds grub-install for EFI and
> > > tell me what you think.  I have some doubts/comments myself, and I'll
> > > reply to my own message to use the patch context.
> >
> > In my opinion, grub-install is not very useful without grub-setup.
>
> It saves a pair of things to the user (figuring out which modules are
> needed, and what to do with the resulting grub.efi image).  From Debian
> POV, it's very important so that grub installs can be automated from
> debian-installer (without duplicating code, that is).

Providing a rudimentary tool rather harms the user.

>
> > As I
> > haven't reverse-engineered "bless" yet, I don't know how to implement it.
> > I guess it just modifies some bytes in a superblock or somewhere, though.
>
> What is bless needed for?  In my environment (Debian GNU/Linux on a qemu
> sandbox with EFI firmware), it was not necessary to get grub.efi booting
> (although later it had issues accessing filesystems other than the EFI
> partition, but I suppose this might be a qemu/firmware bug).

http://www.hmug.org/man/8/bless.php

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-17 19:18     ` Yoshinori K. Okuji
@ 2007-05-18  6:37       ` Robert Millan
  2007-05-18 18:27         ` Yoshinori K. Okuji
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Millan @ 2007-05-18  6:37 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, May 17, 2007 at 09:18:41PM +0200, Yoshinori K. Okuji wrote:
> On Wednesday 16 May 2007 08:25, Robert Millan wrote:
> > On Tue, May 15, 2007 at 10:16:11PM +0200, Yoshinori K. Okuji wrote:
> > > On Friday 11 May 2007 18:03, Robert Millan wrote:
> > > > Please have a look at this patch that adds grub-install for EFI and
> > > > tell me what you think.  I have some doubts/comments myself, and I'll
> > > > reply to my own message to use the patch context.
> > >
> > > In my opinion, grub-install is not very useful without grub-setup.
> >
> > It saves a pair of things to the user (figuring out which modules are
> > needed, and what to do with the resulting grub.efi image).  From Debian
> > POV, it's very important so that grub installs can be automated from
> > debian-installer (without duplicating code, that is).
> 
> Providing a rudimentary tool rather harms the user.

What do you mean?  It's almost the same that the powerpc version does.

> > > As I
> > > haven't reverse-engineered "bless" yet, I don't know how to implement it.
> > > I guess it just modifies some bytes in a superblock or somewhere, though.
> >
> > What is bless needed for?  In my environment (Debian GNU/Linux on a qemu
> > sandbox with EFI firmware), it was not necessary to get grub.efi booting
> > (although later it had issues accessing filesystems other than the EFI
> > partition, but I suppose this might be a qemu/firmware bug).
> 
> http://www.hmug.org/man/8/bless.php

I see.. but user still can boot grub.efi manualy via EFI shell, right?

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-18  6:37       ` Robert Millan
@ 2007-05-18 18:27         ` Yoshinori K. Okuji
  2007-05-19  9:43           ` Robert Millan
  0 siblings, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-18 18:27 UTC (permalink / raw)
  To: The development of GRUB 2

On Friday 18 May 2007 08:37, Robert Millan wrote:
> > Providing a rudimentary tool rather harms the user.
>
> What do you mean?  It's almost the same that the powerpc version does.

The powerpc version is not a good reference. From my point of view, it is far 
from user-friendly. When the user invokes grub-install, she expects that she 
can "install" GRUB, as the name stands for.

The best reference in GRUB is still the i386-pc version. The others should 
follow it as much as possible.

> > http://www.hmug.org/man/8/bless.php
>
> I see.. but user still can boot grub.efi manualy via EFI shell, right?

If an EFI shell is available, yes. On Intel Mac, the shell is not available by 
default, because of the graphics mode. For now, the only way to boot GRUB is 
to start Mac OS X and bless a boot image, or use a small program to switch to 
text mode and boot GRUB from a shell.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-18 18:27         ` Yoshinori K. Okuji
@ 2007-05-19  9:43           ` Robert Millan
  2007-05-19 17:21             ` Yoshinori K. Okuji
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Millan @ 2007-05-19  9:43 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, May 18, 2007 at 08:27:57PM +0200, Yoshinori K. Okuji wrote:
> On Friday 18 May 2007 08:37, Robert Millan wrote:
> > > Providing a rudimentary tool rather harms the user.
> >
> > What do you mean?  It's almost the same that the powerpc version does.
> 
> The powerpc version is not a good reference. From my point of view, it is far 
> from user-friendly. When the user invokes grub-install, she expects that she 
> can "install" GRUB, as the name stands for.
> 
> The best reference in GRUB is still the i386-pc version. The others should 
> follow it as much as possible.

Ok.  So, what interface we should provide to the user?  I've been told that the
files shouldn't be in the root of EFI partition, but in a subdirectory like
/efi/grub.  Should this directory be specified by the user?  We could make it
something like:

  $ sudo grub-install /something/efi/grub
  doesn't look like an EFI partition.
  $ mount /dev/sda1 /something
  $ sudo grub-install /something/efi/grub

OTOH, making it like:

  $ sudo grub-install "(hd0)"
  # /efi/grub being implicit here

forces us to mount/umount and opens a can of worms wrt portability.

What do you think?

> > > http://www.hmug.org/man/8/bless.php
> >
> > I see.. but user still can boot grub.efi manualy via EFI shell, right?
> 
> If an EFI shell is available, yes. On Intel Mac, the shell is not available by 
> default, because of the graphics mode. For now, the only way to boot GRUB is 
> to start Mac OS X and bless a boot image, or use a small program to switch to 
> text mode and boot GRUB from a shell.

Perhaps we should look at the refit source and see how bless-like functionality
is implemented?

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-19  9:43           ` Robert Millan
@ 2007-05-19 17:21             ` Yoshinori K. Okuji
  2007-05-20  7:19               ` Robert Millan
  0 siblings, 1 reply; 24+ messages in thread
From: Yoshinori K. Okuji @ 2007-05-19 17:21 UTC (permalink / raw)
  To: The development of GRUB 2

On Saturday 19 May 2007 11:43, Robert Millan wrote:
> Ok.  So, what interface we should provide to the user?  I've been told that
> the files shouldn't be in the root of EFI partition, but in a subdirectory
> like /efi/grub.  Should this directory be specified by the user?  We could
> make it something like:
>
>   $ sudo grub-install /something/efi/grub
>   doesn't look like an EFI partition.
>   $ mount /dev/sda1 /something
>   $ sudo grub-install /something/efi/grub
>
> OTOH, making it like:
>
>   $ sudo grub-install "(hd0)"
>   # /efi/grub being implicit here
>
> forces us to mount/umount and opens a can of worms wrt portability.
>
> What do you think?

Not bad. The prefix can be anything. It can be even /boot/grub. On EFI, the 
prefix is dynamically passed to GRUB, so the decision is very flexible.

> Perhaps we should look at the refit source and see how bless-like
> functionality is implemented?

When I looked at it at the last time, the documentation only said that you 
would write it to somewhere, and execute bless on Mac OS X. Things might have 
changed, but I don't know.

Okuji



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] grub-install for EFI
  2007-05-19 17:21             ` Yoshinori K. Okuji
@ 2007-05-20  7:19               ` Robert Millan
  0 siblings, 0 replies; 24+ messages in thread
From: Robert Millan @ 2007-05-20  7:19 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, May 19, 2007 at 07:21:24PM +0200, Yoshinori K. Okuji wrote:
> On Saturday 19 May 2007 11:43, Robert Millan wrote:
> > Ok.  So, what interface we should provide to the user?  I've been told that
> > the files shouldn't be in the root of EFI partition, but in a subdirectory
> > like /efi/grub.  Should this directory be specified by the user?  We could
> > make it something like:
> >
> >   $ sudo grub-install /something/efi/grub
> >   doesn't look like an EFI partition.
> >   $ mount /dev/sda1 /something
> >   $ sudo grub-install /something/efi/grub
> >
> > OTOH, making it like:
> >
> >   $ sudo grub-install "(hd0)"
> >   # /efi/grub being implicit here
> >
> > forces us to mount/umount and opens a can of worms wrt portability.
> >
> > What do you think?
> 
> Not bad. The prefix can be anything. It can be even /boot/grub. On EFI, the 
> prefix is dynamically passed to GRUB, so the decision is very flexible.

You mean the first one?  Note that in the current version (i.e. no arguments),
--root-directory still works, so it's still possible to override this path.

> > Perhaps we should look at the refit source and see how bless-like
> > functionality is implemented?
> 
> When I looked at it at the last time, the documentation only said that you 
> would write it to somewhere, and execute bless on Mac OS X. Things might have 
> changed, but I don't know.

I'll have a look later..

-- 
Robert Millan

My spam trap is honeypot@aybabtu.com.  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: new patch
  2023-03-16  0:24     ` Ira Weiny
@ 2023-03-19 11:24       ` Menna Mahmoud
  0 siblings, 0 replies; 24+ messages in thread
From: Menna Mahmoud @ 2023-03-19 11:24 UTC (permalink / raw)
  To: Ira Weiny, Outreachy Linux Kernel


On ١٦‏/٣‏/٢٠٢٣ ٠٢:٢٤, Ira Weiny wrote:
> Menna Mahmoud wrote:
>> On ١٥‏/٣‏/٢٠٢٣ ٢٠:٣٧, Ira Weiny wrote:
>>> Menna Mahmoud wrote:
> [...]
>
>>>> Is it okay to work on this error reported by checkpatch script:
>>>>
>>>>
>>>> ```
>>>>
>>>> drivers/staging/iio/frequency/ad9832.c
>>>> --------------------------------------
>>>> ERROR: Use 4 digit octal (0777) not decimal permissions
>>> This error is trying to flag a mode permission which is not in Octal form.
>>> Are you familiar with decimal vs octal vs hex notations?
>>
>> yes, I am familiar with them.
> Awesome!
>
>>>> #256: FILE: drivers/staging/iio/frequency/ad9832.c:256:
>>>> +static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9832_write, AD9832_FREQ1HM);
>>> What do you think is wrong with this line?
>>>
>>> Hint: I'm not sure I see the problem.
>>>
>>> So your email should have had a subject which reflects this question.
>>> Perhaps a subject like:
>>>
>>> "Is this a valid checkpatch error?"
>>>
>>> FWIW I'm concerned this is some corner case checkpatch bug.  But I'm not
>>> seeing the issue in checkpatch (My perl is very rusty).
>>>
>>> Do you see the error checkpatch is flagging?  Or do you think this may be
>>> a bug in checkpatch?
>>>
>>> Ira
>>
>> I'mn't sure too, I sent this because I submit previous patches but I got
>> comments from mentors that no need to fix them so
>>
>> I asked if these errors need to fix or should I ignore them.
> I've just caught up with the other thread on this.
>
> https://lore.kernel.org/all/48571e97-8766-e67d-c263-29fd67a31f06@metafoo.de/
>
> Do follow up there.  I think we should stop posting on this thread.
>
> Do notice how your subject of 'Outreachy' and 'new patch' become
> meaningless for these 2 threads.
>
> I suspect you had some issue with the mail client and that is why you
> emailed this question 2 times?
>
> Anyway, I'm caught up.  :-D
> Ira

yes, you are right i had some issue but fixed, thanks a lot and 
appreciate your help.

Menna


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: new patch
  2023-03-15 19:29   ` Menna Mahmoud
@ 2023-03-16  0:24     ` Ira Weiny
  2023-03-19 11:24       ` Menna Mahmoud
  0 siblings, 1 reply; 24+ messages in thread
From: Ira Weiny @ 2023-03-16  0:24 UTC (permalink / raw)
  To: Menna Mahmoud, Ira Weiny, Outreachy Linux Kernel

Menna Mahmoud wrote:
> 
> On ١٥‏/٣‏/٢٠٢٣ ٢٠:٣٧, Ira Weiny wrote:
> > Menna Mahmoud wrote:

[...]

> >
> >> Is it okay to work on this error reported by checkpatch script:
> >>
> >>
> >> ```
> >>
> >> drivers/staging/iio/frequency/ad9832.c
> >> --------------------------------------
> >> ERROR: Use 4 digit octal (0777) not decimal permissions
> > This error is trying to flag a mode permission which is not in Octal form.
> > Are you familiar with decimal vs octal vs hex notations?
> 
> 
> yes, I am familiar with them.

Awesome!

> 
> >
> >> #256: FILE: drivers/staging/iio/frequency/ad9832.c:256:
> >> +static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9832_write, AD9832_FREQ1HM);
> > What do you think is wrong with this line?
> >
> > Hint: I'm not sure I see the problem.
> >
> > So your email should have had a subject which reflects this question.
> > Perhaps a subject like:
> >
> > "Is this a valid checkpatch error?"
> >
> > FWIW I'm concerned this is some corner case checkpatch bug.  But I'm not
> > seeing the issue in checkpatch (My perl is very rusty).
> >
> > Do you see the error checkpatch is flagging?  Or do you think this may be
> > a bug in checkpatch?
> >
> > Ira
> 
> 
> I'mn't sure too, I sent this because I submit previous patches but I got 
> comments from mentors that no need to fix them so
> 
> I asked if these errors need to fix or should I ignore them.

I've just caught up with the other thread on this.

https://lore.kernel.org/all/48571e97-8766-e67d-c263-29fd67a31f06@metafoo.de/

Do follow up there.  I think we should stop posting on this thread.

Do notice how your subject of 'Outreachy' and 'new patch' become
meaningless for these 2 threads.

I suspect you had some issue with the mail client and that is why you
emailed this question 2 times?

Anyway, I'm caught up.  :-D

Ira

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: new patch
  2023-03-15 18:37 ` Ira Weiny
@ 2023-03-15 19:29   ` Menna Mahmoud
  2023-03-16  0:24     ` Ira Weiny
  0 siblings, 1 reply; 24+ messages in thread
From: Menna Mahmoud @ 2023-03-15 19:29 UTC (permalink / raw)
  To: Ira Weiny, Outreachy Linux Kernel


On ١٥‏/٣‏/٢٠٢٣ ٢٠:٣٧, Ira Weiny wrote:
> Menna Mahmoud wrote:
>> Hi Mentors,
>>
> Hey Menna, welcome to Outreachy!
>
> First I'll make a small comment on your email subject.  Remember that when
> posting to a mailing list the folks getting the emails may be looking at
> 100's or even 1000's of emails on the list each day.
>
> A subject of 'new patch' is pretty generic and is unlikely to result in
> any interest in reading your post.
>
> With that in mind lets look through the below errors.

I see, I will do that.


>
>> Is it okay to work on this error reported by checkpatch script:
>>
>>
>> ```
>>
>> drivers/staging/iio/frequency/ad9832.c
>> --------------------------------------
>> ERROR: Use 4 digit octal (0777) not decimal permissions
> This error is trying to flag a mode permission which is not in Octal form.
> Are you familiar with decimal vs octal vs hex notations?


yes, I am familiar with them.

>
>> #256: FILE: drivers/staging/iio/frequency/ad9832.c:256:
>> +static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9832_write, AD9832_FREQ1HM);
> What do you think is wrong with this line?
>
> Hint: I'm not sure I see the problem.
>
> So your email should have had a subject which reflects this question.
> Perhaps a subject like:
>
> "Is this a valid checkpatch error?"
>
> FWIW I'm concerned this is some corner case checkpatch bug.  But I'm not
> seeing the issue in checkpatch (My perl is very rusty).
>
> Do you see the error checkpatch is flagging?  Or do you think this may be
> a bug in checkpatch?
>
> Ira


I'mn't sure too, I sent this because I submit previous patches but I got 
comments from mentors that no need to fix them so

I asked if these errors need to fix or should I ignore them.


Thanks,

Menna


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: new patch
  2023-03-15  9:18 new patch Menna Mahmoud
@ 2023-03-15 18:37 ` Ira Weiny
  2023-03-15 19:29   ` Menna Mahmoud
  0 siblings, 1 reply; 24+ messages in thread
From: Ira Weiny @ 2023-03-15 18:37 UTC (permalink / raw)
  To: Menna Mahmoud, Outreachy Linux Kernel

Menna Mahmoud wrote:
> Hi Mentors,
> 

Hey Menna, welcome to Outreachy!

First I'll make a small comment on your email subject.  Remember that when
posting to a mailing list the folks getting the emails may be looking at
100's or even 1000's of emails on the list each day.

A subject of 'new patch' is pretty generic and is unlikely to result in
any interest in reading your post.

With that in mind lets look through the below errors.

> 
> Is it okay to work on this error reported by checkpatch script:
> 
> 
> ```
> 
> drivers/staging/iio/frequency/ad9832.c
> --------------------------------------
> ERROR: Use 4 digit octal (0777) not decimal permissions

This error is trying to flag a mode permission which is not in Octal form.
Are you familiar with decimal vs octal vs hex notations?

> #256: FILE: drivers/staging/iio/frequency/ad9832.c:256:
> +static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9832_write, AD9832_FREQ1HM);

What do you think is wrong with this line?

Hint: I'm not sure I see the problem.

So your email should have had a subject which reflects this question.
Perhaps a subject like:

"Is this a valid checkpatch error?"

FWIW I'm concerned this is some corner case checkpatch bug.  But I'm not
seeing the issue in checkpatch (My perl is very rusty).

Do you see the error checkpatch is flagging?  Or do you think this may be
a bug in checkpatch?

Ira

^ permalink raw reply	[flat|nested] 24+ messages in thread

* new patch
@ 2023-03-15  9:18 Menna Mahmoud
  2023-03-15 18:37 ` Ira Weiny
  0 siblings, 1 reply; 24+ messages in thread
From: Menna Mahmoud @ 2023-03-15  9:18 UTC (permalink / raw)
  To: Outreachy Linux Kernel

Hi Mentors,


Is it okay to work on this error reported by checkpatch script:


```

drivers/staging/iio/frequency/ad9832.c
--------------------------------------
ERROR: Use 4 digit octal (0777) not decimal permissions
#256: FILE: drivers/staging/iio/frequency/ad9832.c:256:
+static IIO_DEV_ATTR_FREQ(0, 1, 0200, NULL, ad9832_write, AD9832_FREQ1HM);
ERROR: Use 4 digit octal (0777) not decimal permissions
#257: FILE: drivers/staging/iio/frequency/ad9832.c:257:
+static IIO_DEV_ATTR_FREQSYMBOL(0, 0200, NULL, ad9832_write, 
AD9832_FREQ_SYM);
ERROR: Use 4 digit octal (0777) not decimal permissions
#260: FILE: drivers/staging/iio/frequency/ad9832.c:260:
+static IIO_DEV_ATTR_PHASE(0, 0, 0200, NULL, ad9832_write, AD9832_PHASE0H);
ERROR: Use 4 digit octal (0777) not decimal permissions
#261: FILE: drivers/staging/iio/frequency/ad9832.c:261:
+static IIO_DEV_ATTR_PHASE(0, 1, 0200, NULL, ad9832_write, AD9832_PHASE1H);
ERROR: Use 4 digit octal (0777) not decimal permissions
#262: FILE: drivers/staging/iio/frequency/ad9832.c:262:
+static IIO_DEV_ATTR_PHASE(0, 2, 0200, NULL, ad9832_write, AD9832_PHASE2H);
ERROR: Use 4 digit octal (0777) not decimal permissions
#263: FILE: drivers/staging/iio/frequency/ad9832.c:263:
+static IIO_DEV_ATTR_PHASE(0, 3, 0200, NULL, ad9832_write, AD9832_PHASE3H);
ERROR: Use 4 digit octal (0777) not decimal permissions
#264: FILE: drivers/staging/iio/frequency/ad9832.c:264:
+static IIO_DEV_ATTR_PHASESYMBOL(0, 0200, NULL,
+                ad9832_write, AD9832_PHASE_SYM);
ERROR: Use 4 digit octal (0777) not decimal permissions
#268: FILE: drivers/staging/iio/frequency/ad9832.c:268:
+static IIO_DEV_ATTR_PINCONTROL_EN(0, 0200, NULL,
+                ad9832_write, AD9832_PINCTRL_EN);
ERROR: Use 4 digit octal (0777) not decimal permissions
#270: FILE: drivers/staging/iio/frequency/ad9832.c:270:
+static IIO_DEV_ATTR_OUT_ENABLE(0, 0200, NULL,
+                ad9832_write, AD9832_OUTPUT_EN);
total: 9 errors, 0 warnings, 0 checks, 462 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
       mechanically convert to the typical style using --fix or 
--fix-inplace.

```


Thanks and regards,

Menna


^ permalink raw reply	[flat|nested] 24+ messages in thread

* New patch
@ 2005-08-04 14:04 Vladimir Serbinenko
  0 siblings, 0 replies; 24+ messages in thread
From: Vladimir Serbinenko @ 2005-08-04 14:04 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 798 bytes --]

I send a new version of my patch. I added parttype and hide/unhide commands.
Can someone have a look at it?
(I haven't tested it a lot but it works fine for me )
                                                                        
Vladimir

2005-08-02  Vladimir Serbinenko <phcoder@gmail.com>

    Sendkey, activate and parttype modules(pc) and preboots
   
    * commands/boot.c: Added support for preboot functions
    * conf/i386.rmk (sendkey): new module
    (activate): Likewise
    (parttype): Likewise
    * commands/i386/pc/sendkey.c: New file
    * commands/i386/pc/parttype.c: Likewise
    * commands/i386/pc/activate.c: Likewise
    * kern/misc.c (grub_split_cmdline): more bash-like quotes and
    doublequotes handle
    * include/grub/normal.h: new headers and types for preboots

[-- Attachment #2: key.patch --]
[-- Type: text/x-patch, Size: 35153 bytes --]

diff -urpN grub2um/ChangeLog grub2m/ChangeLog
--- grub2um/ChangeLog	2005-08-01 11:44:43.000000000 +0200
+++ grub2m/ChangeLog	2005-08-02 18:39:10.000000000 +0200
@@ -1,3 +1,18 @@
+2005-08-02  Vladimir Serbinenko <phcoder@gmail.com>
+
+	Sendkey, activate and parttype modules(pc) and preboots
+	
+	* commands/boot.c: Added support for preboot functions
+	* conf/i386.rmk (sendkey): new module
+	(activate): Likewise
+	(parttype): Likewise
+	* commands/i386/pc/sendkey.c: New file
+	* commands/i386/pc/parttype.c: Likewise
+	* commands/i386/pc/activate.c: Likewise
+	* kern/misc.c (grub_split_cmdline): more bash-like quotes and
+	doublequotes handle
+	* include/grub/normal.h: new headers and types for preboots
+
 2005-07-31  Yoshinori K. Okuji  <okuji@enbug.org>
 
 	* loader/i386/pc/multiboot.c (grub_multiboot_is_elf32): New
diff -urpN grub2um/commands/boot.c grub2m/commands/boot.c
--- grub2um/commands/boot.c	2005-07-25 15:23:26.000000000 +0200
+++ grub2m/commands/boot.c	2005-07-25 16:58:11.000000000 +0200
@@ -23,13 +23,23 @@
 #include <grub/arg.h>
 #include <grub/misc.h>
 #include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+
+static grub_prebootfn_t *grub_preboots = 0;
+static int grub_preboot_cnt = 0;
 
 static grub_err_t
 grub_cmd_boot (struct grub_arg_list *state __attribute__ ((unused)),
 	       int argc, char **args __attribute__ ((unused)))
 {
+  int i;
+
   if (argc)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
+
+  for (i = 0; i < grub_preboot_cnt; i++)
+    grub_preboots[i] ();
   
   grub_loader_boot ();
   
@@ -38,6 +48,46 @@ grub_cmd_boot (struct grub_arg_list *sta
 
 \f
 
+grub_err_t
+grub_preboot_add (grub_prebootfn_t fn)
+{
+  grub_prebootfn_t *tmp;
+  tmp = (grub_prebootfn_t *) grub_realloc (grub_preboots, (grub_preboot_cnt + 1) * sizeof(grub_prebootfn_t));
+  if (!tmp)
+    return grub_errno;
+  grub_preboots = tmp;
+  grub_preboots[grub_preboot_cnt] = fn;
+  grub_preboot_cnt++;
+
+  return 0;
+}
+
+\f
+
+grub_err_t
+grub_preboot_remove (grub_prebootfn_t fn)
+{
+  int i;
+  for (i = 0; i < grub_preboot_cnt; i++)
+    if (grub_preboots[i] == fn)
+      break;
+
+  if (i == grub_preboot_cnt)
+    {
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "fn not found");
+    }
+
+  for (; i < grub_preboot_cnt - 1; i++)
+    grub_preboots[i] = grub_preboots[i + 1];
+
+  grub_preboots = (grub_prebootfn_t *) grub_realloc (grub_preboots, (--grub_preboot_cnt) * sizeof(grub_prebootfn_t));
+
+  return 0;
+
+}
+
+\f
+
 #ifdef GRUB_UTIL
 void
 grub_boot_init (void)
diff -urpN grub2um/commands/i386/pc/activate.c grub2m/commands/i386/pc/activate.c
--- grub2um/commands/i386/pc/activate.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2m/commands/i386/pc/activate.c	2005-08-01 18:55:15.000000000 +0200
@@ -0,0 +1,114 @@
+/* activate.c - activate pc partition */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003  NIIBE Yutaka <gniibe@m17n.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/pc_partition.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+static grub_err_t
+grub_cmd_activate (struct grub_arg_list *state __attribute__ ((unused)),
+		int argc, char **args)
+{
+
+  grub_device_t dev;
+  struct grub_pc_partition_mbr mbr;
+  grub_partition_t part;
+  
+  int i, index;
+
+  if (argc > 1)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
+
+  if (!argc)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments");
+
+  dev = grub_device_open (args[0]); 
+
+  if (!dev)
+    return grub_errno;
+
+  if (!dev->disk)
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a disk");
+    }
+
+  if (!dev->disk->partition)
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a partition");
+    }
+
+  if (grub_strcmp (dev->disk->partition->partmap->name, "pc_partition_map"))
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a pc partition");
+    }
+
+  if (dev->disk->partition->offset)
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a primary partition");
+    }
+
+  index = dev->disk->partition->index;
+  part = dev->disk->partition;
+  dev->disk->partition = 0;
+
+  /* Read the MBR.  */
+  if (grub_disk_read (dev->disk, 0, 0, sizeof (mbr), (char *) &mbr))
+    {
+      dev->disk->partition = part;
+      grub_device_close (dev);
+      return grub_errno;
+    }
+
+  for (i = 0; i < 4; i++)
+    mbr.entries[i].flag = 0x0;
+
+  mbr.entries[index].flag = 0x80;  
+
+   /* Write the MBR.  */
+  grub_disk_write (dev->disk, 0, 0, sizeof (mbr), (char *) &mbr);
+  dev->disk->partition = part;
+  grub_device_close (dev);
+  return grub_errno;
+  
+}
+
+GRUB_MOD_INIT
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("activate", grub_cmd_activate, GRUB_COMMAND_FLAG_BOTH,
+			 "activate PARTITION", "set active flag to PARTITION", 0);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("activate");
+}
diff -urpN grub2um/commands/i386/pc/parttype.c grub2m/commands/i386/pc/parttype.c
--- grub2um/commands/i386/pc/parttype.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2m/commands/i386/pc/parttype.c	2005-08-02 18:25:09.000000000 +0200
@@ -0,0 +1,165 @@
+/* activate.c - activate pc partition */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003  NIIBE Yutaka <gniibe@m17n.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/pc_partition.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+
+/* Set the partition type. Special values of PARTTYPE:
+ -1 - set hidden flag
+ -2 - unset hidden flag*/
+static grub_err_t
+grub_setparttype (int parttype, int argc, char **args)
+{
+
+  grub_device_t dev;
+  struct grub_pc_partition_mbr pmap;
+  grub_partition_t part;
+  
+  int index;
+  unsigned long offset;
+
+  if (argc > 1)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
+
+  if (!argc)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments");
+
+  dev = grub_device_open (args[0]); 
+
+  if (!dev)
+    return grub_errno;
+
+  if (!dev->disk)
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a disk");
+    }
+
+  if (!dev->disk->partition)
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a partition");
+    }
+
+  if (grub_strcmp (dev->disk->partition->partmap->name, "pc_partition_map"))
+    {
+      grub_device_close (dev);
+      return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a pc partition");
+    }
+
+  offset = dev->disk->partition->offset;
+
+  index = dev->disk->partition->index;
+  part = dev->disk->partition;
+  dev->disk->partition = 0;
+
+  /* Read the partition map.  */
+  if (grub_disk_read (dev->disk, offset, 0, sizeof (pmap), (char *) &pmap))
+    {
+      dev->disk->partition = part;
+      grub_device_close (dev);
+      return grub_errno;
+    }
+
+  switch (parttype)
+    {
+    case -1:
+      pmap.entries[index].type |= GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG;
+      break;
+
+    case -2:
+      pmap.entries[index].type &= ~GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG;
+      break;
+      
+    default:
+      pmap.entries[index].type = parttype;
+      break;
+    }
+      
+
+   /* Write the partition map.  */
+  grub_disk_write (dev->disk, offset, 0, sizeof (pmap), (char *) &pmap);
+  dev->disk->partition = part;
+  grub_device_close (dev);
+  return grub_errno;
+  
+}
+
+static grub_err_t
+grub_cmd_hide (struct grub_arg_list *state __attribute__ ((unused)),
+	       int argc, char **args)
+{
+  return grub_setparttype (-1, argc, args);
+}
+
+static grub_err_t
+grub_cmd_unhide (struct grub_arg_list *state __attribute__ ((unused)),
+		 int argc, char **args)
+{
+  return grub_setparttype (-2, argc, args);
+}
+
+static grub_err_t
+grub_cmd_parttype (struct grub_arg_list *state __attribute__ ((unused)),
+		   int argc, char **args)
+{
+  char *rest = 0;
+  int type;
+
+  if (argc < 2)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments");
+ if (argc > 2)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
+
+ type = grub_strtoul (args[0], &rest, 0);
+ if (rest && *rest)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "second argument must be integer");
+
+ return grub_setparttype (type, 1, args + 1);
+}
+  
+
+GRUB_MOD_INIT
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("hide", grub_cmd_hide, GRUB_COMMAND_FLAG_BOTH,
+			 "hide PARTITION", "hide PARTITION from OS (set hidden flag)", 0);
+  grub_register_command ("unhide", grub_cmd_unhide, GRUB_COMMAND_FLAG_BOTH,
+			 "unhide PARTITION", "unhide PARTITION from OS (unset hidden flag)", 0);
+  grub_register_command ("parttype", grub_cmd_parttype, GRUB_COMMAND_FLAG_BOTH,
+			 "parttype PARTITION TYPE", "set PARTITION type to TYPE", 0);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("hide");
+  grub_unregister_command ("unhide");
+  grub_unregister_command ("parttype");
+}
diff -urpN grub2um/commands/i386/pc/sendkey.c grub2m/commands/i386/pc/sendkey.c
--- grub2um/commands/i386/pc/sendkey.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2m/commands/i386/pc/sendkey.c	2005-08-02 14:21:38.000000000 +0200
@@ -0,0 +1,394 @@
+/* sendkey.c - test module for dynamic loading */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *  Copyright (C) 2005  Vladimir Serbinenko serbinenko.vova@bk.ru
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/arg.h>
+#include <grub/env.h>
+
+#define RAW_ADDR(a) ((void *)(a))
+struct 
+keysym
+{
+  char *unshifted_name;			/* the name in unshifted state */
+  char *shifted_name;			/* the name in shifted state */
+  unsigned char unshifted_ascii;	/* the ascii code in unshifted state */
+  unsigned char shifted_ascii;		/* the ascii code in shifted state */
+  unsigned char keycode;		/* keyboard scancode */
+};
+
+/* The table for key symbols. If the "shifted" member of an entry is
+   NULL, the entry does not have shifted state. Copied from GRUB Legacy setkey fuction  */
+static struct keysym keysym_table[] =
+{
+  {"escape",		0,		0x1b,	0,	0x01},
+  {"1",			"exclam",	'1',	'!',	0x02},
+  {"2",			"at",		'2',	'@',	0x03},
+  {"3",			"numbersign",	'3',	'#',	0x04},
+  {"4",			"dollar",	'4',	'$',	0x05},
+  {"5",			"percent",	'5',	'%',	0x06},
+  {"6",			"caret",	'6',	'^',	0x07},
+  {"7",			"ampersand",	'7',	'&',	0x08},
+  {"8",			"asterisk",	'8',	'*',	0x09},
+  {"9",			"parenleft",	'9',	'(',	0x0a},
+  {"0",			"parenright",	'0',	')',	0x0b},
+  {"minus",		"underscore",	'-',	'_',	0x0c},
+  {"equal",		"plus",		'=',	'+',	0x0d},
+  {"backspace",		0,		'\b',	0,	0x0e},
+  {"tab",		0,		'\t',	0,	0x0f},
+  {"q",			"Q",		'q',	'Q',	0x10},
+  {"w",			"W",		'w',	'W',	0x11},
+  {"e",			"E",		'e',	'E',	0x12},
+  {"r",			"R",		'r',	'R',	0x13},
+  {"t",			"T",		't',	'T',	0x14},
+  {"y",			"Y",		'y',	'Y',	0x15},
+  {"u",			"U",		'u',	'U',	0x16},
+  {"i",			"I",		'i',	'I',	0x17},
+  {"o",			"O",		'o',	'O',	0x18},
+  {"p",			"P",		'p',	'P',	0x19},
+  {"bracketleft",	"braceleft",	'[',	'{',	0x1a},
+  {"bracketright",	"braceright",	']',	'}',	0x1b},
+  {"enter",		0,		'\r',	0,	0x1c},
+  {"control",		0,		0,	0,	0x1d},
+  {"a",			"A",		'a',	'A',	0x1e},
+  {"s",			"S",		's',	'S',	0x1f},
+  {"d",			"D",		'd',	'D',	0x20},
+  {"f",			"F",		'f',	'F',	0x21},
+  {"g",			"G",		'g',	'G',	0x22},
+  {"h",			"H",		'h',	'H',	0x23},
+  {"j",			"J",		'j',	'J',	0x24},
+  {"k",			"K",		'k',	'K',	0x25},
+  {"l",			"L",		'l',	'L',	0x26},
+  {"semicolon",		"colon",	';',	':',	0x27},
+  {"quote",		"doublequote",	'\'',	'"',	0x28},
+  {"backquote",		"tilde",	'`',	'~',	0x29},
+  {"shift",		0,		0,	0,	0x2a},
+  {"backslash",		"bar",		'\\',	'|',	0x2b},
+  {"z",			"Z",		'z',	'Z',	0x2c},
+  {"x",			"X",		'x',	'X',	0x2d},
+  {"c",			"C",		'c',	'C',	0x2e},
+  {"v",			"V",		'v',	'V',	0x2f},
+  {"b",			"B",		'b',	'B',	0x30},
+  {"n",			"N",		'n',	'N',	0x31},
+  {"m",			"M",		'm',	'M',	0x32},
+  {"comma",		"less",		',',	'<',	0x33},
+  {"period",		"greater",	'.',	'>',	0x34},
+  {"slash",		"question",	'/',	'?',	0x35},
+  {"rshift",		0,		0,	0,	0x36},
+  {"numasterisk",		0,		'*',	0,	0x37},
+  {"alt",		0,		0,	0,	0x38},
+  {"space",		0,		' ',	0,	0x39},
+  {"capslock",		0,		0,	0,	0x3a},
+  {"F1",		0,		0,	0,	0x3b},
+  {"F2",		0,		0,	0,	0x3c},
+  {"F3",		0,		0,	0,	0x3d},
+  {"F4",		0,		0,	0,	0x3e},
+  {"F5",		0,		0,	0,	0x3f},
+  {"F6",	 	0,		0,	0,	0x40},
+  {"F7",		0,		0,	0,	0x41},
+  {"F8",		0,		0,	0,	0x42},
+  {"F9",		0,		0,	0,	0x43},
+  {"F10",		0,		0,	0,	0x44},
+  {"num7",		"numhome",		'7',	0,	0x47},
+  {"num8",		"numup",		'8',	0,	0x48},
+  {"num9",		"numpgup",		'9',	0,	0x49},
+  {"numminus",		0,		'-',	0,	0x4a},
+  {"num4",		"numleft",		'4',	0,	0x4b},
+  {"num5",		"num5numlock",		'5',	0,	0x4c},
+  {"num6",		"numright",		'6',	0,	0x4d},
+  {"numplus",		0,		'-',	0,	0x4e},
+  {"num1",		"numend",		'1',	0,	0x4f},
+  {"num2",		"numdown",		'2',	0,	0x50},
+  {"num3",		"numpgdown",		'3',	0,	0x51},
+  {"num0",		"numinsert",		'0',	0,	0x52},
+  {"numperiod",	"numdelete", 0,	0x7f,		0x53},
+  {"F11",		0,		0,	0,	0x57},
+  {"F12",		0,		0,	0,	0x58},
+  {"numenter",		0,		'\r',	0,	0xe0},
+  {"numslash",		0,		'/',	0,	0xe0},
+  {"delete",		0,		0x7f,	0,	0xe0},
+  {"insert",		0,		0xe0,	0,	0x52},
+  {"home",		0,		0xe0,	0,	0x47},
+  {"end",		0,		0xe0,	0,	0x4f},
+  {"pgdown",		0,		0xe0,	0,	0x51},
+  {"pgup",		0,		0xe0,	0,	0x49},
+  {"down",		0,		0xe0,	0,	0x50},
+  {"up",		0,		0xe0,	0,	0x48},
+  {"left",		0,		0xe0,	0,	0x4b},
+  {"right",		0,		0xe0,	0,	0x4d}
+};
+
+/* Send a character VALUE to port PORT  */
+static void 
+outportb (char value, int port) {
+  asm volatile ("outb %%al,%%dx": :"a" (value),"d" (port));
+  return;
+}
+
+/* Read a byte from port PORT  */
+static unsigned char 
+inb (unsigned int port)
+{
+  unsigned char ret;
+  asm volatile ("inb %%dx,%%al":"=a" (ret):"d" (port));
+  return ret;
+
+}
+
+/* Set a simple flag in flags variable  
+   FLAGS - where to set,
+   OUTOFFSET - offset of flag in FLAGS,
+   OP - action id
+*/
+static void
+grub_sendkey_set_simple_flag (unsigned long *flags, int outoffset, int op)
+{
+  /* previous state of flag  */
+  int prevstat = (*flags >> outoffset) & 1;
+  /* new state */
+  int newstat = (op == 1) || (op == 2 && prevstat);
+  /* Set new state  */
+  *flags = (*flags & (~(1 << outoffset))) | (newstat << outoffset);
+}
+
+/* Set a double flag (ctrl/alt) in flags variable  
+   FLAGS - where to set,
+   OUTOFFSETR - offset of common flag in FLAGS,
+   OUTOFFSETL - offset of "left" flag in FLAGS,
+   OPR - operation for "right" flag,
+   OPL - operation for  "left" flag
+*/
+static void
+grub_sendkey_set_double_flag (unsigned long *flags, int outoffsetc, int outoffsetl, int opr, int opl)
+{
+  /* previous state of flag  */
+  int prevstatc = (*flags >> outoffsetc) & 1;
+  int prevstatl = (*flags >> outoffsetl) & 1;
+  int prevstatr = prevstatc && (!prevstatl);
+  /* new state */
+  int newstatl = (opl == 1) || (opl == 2 && prevstatl);
+  int newstatr = (opr == 1) || (opr == 2 && prevstatr);
+  int newstatc = newstatr || newstatr;
+  /* Set new state  */
+  *flags = (*flags & (~(1 << outoffsetl))) | (newstatl << outoffsetl);
+  *flags = (*flags & (~(1 << outoffsetc))) | (newstatc << outoffsetc);
+}
+
+static int
+grub_sendkey_parse_op (char *name)
+{
+  char *var;
+
+  var = grub_env_get (name);
+
+  if (!var)
+    return 2;
+
+  if (!grub_strcmp (var, "off") || !grub_strcmp (var, "0") || !grub_strcmp (var, "unpress"))
+    return 0;
+
+  if (!grub_strcmp (var, "on") || !grub_strcmp (var, "1") || !grub_strcmp (var, "press"))
+    return 1;
+
+  return 2;
+}
+
+/* Set keyboard buffer to our sendkey  */
+static void
+grub_sendkey_preboot (void)
+{
+
+  /* Length of sendkey  */
+  int keylen = 0;
+  char sendkey[0x20];
+  /* For convenion: pointer to flags  */
+  unsigned long *flags = (unsigned long *) RAW_ADDR (0x417);
+  char *next, ch, *sendkeyvar;
+  int noled = 0;
+
+  /* To stop warning  */ 
+  auto int find_key_code (char *key); 
+  auto int find_ascii_code (char *key);
+
+  auto int find_key_code (char *key)
+    {
+      unsigned i;
+
+      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+	{
+	  if (keysym_table[i].unshifted_name && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
+	    return keysym_table[i].keycode;
+	  else if (keysym_table[i].shifted_name && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
+	    return keysym_table[i].keycode;
+	}
+
+      return 0;
+    }
+
+  auto int find_ascii_code (char *key)
+    {
+      unsigned i;
+
+      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+	{
+	  if (keysym_table[i].unshifted_name && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
+	    return keysym_table[i].unshifted_ascii;
+	  else if (keysym_table[i].shifted_name && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
+	    return keysym_table[i].shifted_ascii;
+	}
+
+      return 0;
+    }
+
+  sendkeyvar = grub_env_get ("sendkey");
+
+  if (sendkeyvar)
+    do
+      {
+	next = grub_strchr (sendkeyvar, ' ');
+	if (next)
+	  {
+	    ch = *next;
+	    *next = 0;
+	  }
+	if (find_key_code (sendkeyvar))
+	  {
+	    sendkey[keylen++] = find_ascii_code (sendkeyvar);
+	    sendkey[keylen++] = find_key_code (sendkeyvar);
+	  }
+	if (next)
+	  {
+	    *next = ch;
+	    sendkeyvar = next + 1;
+	  }
+      }
+    while (next && keylen < 0x20);
+  
+  {
+    int i;
+    /* Set the sendkey  */
+    *((char *) RAW_ADDR (0x41a)) = 0x1e;
+    *((char *) RAW_ADDR (0x41c)) = keylen + 0x1e;
+    for(i = 0; i < 0x20; i++)
+      ((char *) RAW_ADDR (0x41e))[i] = sendkey[i];
+  }
+
+  /* Set the flags. For more information reffer to technical specification*/
+  grub_sendkey_set_simple_flag (flags,  5, grub_sendkey_parse_op("kb_num")); // numlock mode
+  grub_sendkey_set_simple_flag (flags,  6, grub_sendkey_parse_op("kb_caps")); // capslock mode
+  grub_sendkey_set_simple_flag (flags,  4, grub_sendkey_parse_op("kb_scroll")); // scrolllock mode
+  grub_sendkey_set_simple_flag (flags,  7, grub_sendkey_parse_op("kb_insert")); // insert mode
+  grub_sendkey_set_simple_flag (flags, 11, grub_sendkey_parse_op("kb_wait")); // wait mode
+  grub_sendkey_set_simple_flag (flags,  1, grub_sendkey_parse_op("kb_lshift")); // left shift
+  grub_sendkey_set_simple_flag (flags,  0, grub_sendkey_parse_op("kb_rshift")); // right shift
+  grub_sendkey_set_simple_flag (flags, 10, grub_sendkey_parse_op("kb_sysreq")); // sysreq
+  grub_sendkey_set_simple_flag (flags, 13, grub_sendkey_parse_op("kb_numkey")); // numlock key
+  grub_sendkey_set_simple_flag (flags, 14, grub_sendkey_parse_op("kb_capskey")); // capslock key
+  grub_sendkey_set_simple_flag (flags, 12, grub_sendkey_parse_op("kb_scrollkey")); // scrolllock key
+  grub_sendkey_set_simple_flag (flags, 15, grub_sendkey_parse_op("kb_insertkey")); // insert key
+
+  /*Set ctrl and alt*/
+  grub_sendkey_set_double_flag (flags, 2, 8, grub_sendkey_parse_op("kb_rctrl"), grub_sendkey_parse_op("kb_lctrl")); //Ctrl
+  grub_sendkey_set_double_flag (flags, 3, 9, grub_sendkey_parse_op("kb_ralt"),  grub_sendkey_parse_op("kb_lalt")); //Alt
+
+
+  /* Set noled */
+  {
+    char *var;
+
+    /* set 1 if set explicitely  */
+    if ((var = grub_env_get ("kb_noled")) && grub_strcmp (var, "0"))
+      noled = 1;
+    
+    /* implicit: when LEDs haven't changed  */
+    if (!var && grub_sendkey_parse_op("kb_num") == 2 && grub_sendkey_parse_op("kb_caps") == 2
+	&& grub_sendkey_parse_op("kb_scroll") == 2)
+      noled = 1;
+  }
+
+  /* Write new LED state  */
+  if (!noled)
+    {
+      int value = 0;
+      int failed;
+      /* Try 5 times  */
+      for (failed = 0; failed < 5; failed++)
+	{
+	  value = 0;
+	  /* Send command change LEDs  */
+	  outportb (0xed, 0x60);
+
+	  /* Wait */
+	  while ((value != 0xfa) && (value != 0xfe))
+	    value = inb (0x60);
+
+	  if (value == 0xfa)
+	    {
+	      /* Set new LEDs*/
+	      outportb ((flags[0] >> 4) & 7, 0x60);
+	      break;
+	    }
+	}
+    }
+
+}
+
+GRUB_MOD_INIT
+{
+  (void)mod;			/* To stop warning. */
+  unsigned i;
+  /* List of variables to set to "keep"  */
+  char list[16][12] = 
+    {
+      "kb_num", "kb_caps", "kb_scroll", "kb_insert", "kb_wait", "kb_lshift", "kb_rshift", "kb_sysreq", 
+      "kb_numkey", "kb_capskey", "kb_scrollkey", "kb_insertkey", "kb_lalt", "kb_ralt", "kb_lctrl", "kb_rctrl"
+    };
+
+  grub_env_set ("sendkey", "");
+  grub_env_set ("kb_noled", "0");
+
+  for (i = 0; i < sizeof (list) / sizeof (list[0]); i++)
+    grub_env_set (list[i], "keep");
+
+  grub_preboot_add (grub_sendkey_preboot);
+}
+
+GRUB_MOD_FINI
+{
+
+  unsigned i;
+  /* List of variables to unset  */
+  char list[19][12] = 
+    {
+      "kb_num", "kb_caps", "kb_scroll", "kb_insert", "kb_wait", "kb_lshift", "kb_rshift", "kb_sysreq", 
+      "kb_numkey", "kb_capskey", "kb_scrollkey", "kb_insertkey", "kb_lalt", "kb_ralt", "kb_lctrl", "kb_rctrl",
+      "sendkey", "kb_noled"
+    };
+
+  for (i = 0; i < sizeof (list) / sizeof (list[0]); i++)
+    grub_env_unset (list[i]);  
+  
+  grub_preboot_remove (grub_sendkey_preboot);
+}
diff -urpN grub2um/conf/i386-pc.mk grub2m/conf/i386-pc.mk
--- grub2um/conf/i386-pc.mk	2005-07-25 15:23:26.000000000 +0200
+++ grub2m/conf/i386-pc.mk	2005-08-02 14:03:45.000000000 +0200
@@ -989,7 +989,8 @@ pkgdata_MODULES = _chain.mod _linux.mod 
 	font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod		\
 	terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod	\
 	apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod	\
-	help.mod default.mod timeout.mod configfile.mod
+	help.mod default.mod timeout.mod configfile.mod sendkey.mod     \
+	activate.mod parttype.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -1781,6 +1782,156 @@ fs-hello.lst: hello/hello.c genfslist.sh
 
 hello_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For sendkey.mod.
+sendkey_mod_SOURCES = commands/i386/pc/sendkey.c
+CLEANFILES += sendkey.mod mod-sendkey.o mod-sendkey.c pre-sendkey.o sendkey_mod-commands_i386_pc_sendkey.o def-sendkey.lst und-sendkey.lst
+MOSTLYCLEANFILES += sendkey_mod-commands_i386_pc_sendkey.d
+DEFSYMFILES += def-sendkey.lst
+UNDSYMFILES += und-sendkey.lst
+
+sendkey.mod: pre-sendkey.o mod-sendkey.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-sendkey.o: sendkey_mod-commands_i386_pc_sendkey.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+
+mod-sendkey.o: mod-sendkey.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(sendkey_mod_CFLAGS) -c -o $@ $<
+
+mod-sendkey.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'sendkey' $< > $@ || (rm -f $@; exit 1)
+
+def-sendkey.lst: pre-sendkey.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 sendkey/' > $@
+
+und-sendkey.lst: pre-sendkey.o
+	echo 'sendkey' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+sendkey_mod-commands_i386_pc_sendkey.o: commands/i386/pc/sendkey.c
+	$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(sendkey_mod_CFLAGS) -c -o $@ $<
+
+sendkey_mod-commands_i386_pc_sendkey.d: commands/i386/pc/sendkey.c
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(sendkey_mod_CFLAGS) -M $< 	  | sed 's,sendkey\.o[ :]*,sendkey_mod-commands_i386_pc_sendkey.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include sendkey_mod-commands_i386_pc_sendkey.d
+
+CLEANFILES += cmd-sendkey.lst fs-sendkey.lst
+COMMANDFILES += cmd-sendkey.lst
+FSFILES += fs-sendkey.lst
+
+cmd-sendkey.lst: commands/i386/pc/sendkey.c gencmdlist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(sendkey_mod_CFLAGS) -E $< 	  | sh $(srcdir)/gencmdlist.sh sendkey > $@ || (rm -f $@; exit 1)
+
+fs-sendkey.lst: commands/i386/pc/sendkey.c genfslist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(sendkey_mod_CFLAGS) -E $< 	  | sh $(srcdir)/genfslist.sh sendkey > $@ || (rm -f $@; exit 1)
+
+
+sendkey_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For activate.mod.
+activate_mod_SOURCES = commands/i386/pc/activate.c
+CLEANFILES += activate.mod mod-activate.o mod-activate.c pre-activate.o activate_mod-commands_i386_pc_activate.o def-activate.lst und-activate.lst
+MOSTLYCLEANFILES += activate_mod-commands_i386_pc_activate.d
+DEFSYMFILES += def-activate.lst
+UNDSYMFILES += und-activate.lst
+
+activate.mod: pre-activate.o mod-activate.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-activate.o: activate_mod-commands_i386_pc_activate.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+
+mod-activate.o: mod-activate.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(activate_mod_CFLAGS) -c -o $@ $<
+
+mod-activate.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'activate' $< > $@ || (rm -f $@; exit 1)
+
+def-activate.lst: pre-activate.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 activate/' > $@
+
+und-activate.lst: pre-activate.o
+	echo 'activate' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+activate_mod-commands_i386_pc_activate.o: commands/i386/pc/activate.c
+	$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(activate_mod_CFLAGS) -c -o $@ $<
+
+activate_mod-commands_i386_pc_activate.d: commands/i386/pc/activate.c
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(activate_mod_CFLAGS) -M $< 	  | sed 's,activate\.o[ :]*,activate_mod-commands_i386_pc_activate.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include activate_mod-commands_i386_pc_activate.d
+
+CLEANFILES += cmd-activate.lst fs-activate.lst
+COMMANDFILES += cmd-activate.lst
+FSFILES += fs-activate.lst
+
+cmd-activate.lst: commands/i386/pc/activate.c gencmdlist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(activate_mod_CFLAGS) -E $< 	  | sh $(srcdir)/gencmdlist.sh activate > $@ || (rm -f $@; exit 1)
+
+fs-activate.lst: commands/i386/pc/activate.c genfslist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(activate_mod_CFLAGS) -E $< 	  | sh $(srcdir)/genfslist.sh activate > $@ || (rm -f $@; exit 1)
+
+
+activate_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For parttype.mod.
+parttype_mod_SOURCES = commands/i386/pc/parttype.c
+CLEANFILES += parttype.mod mod-parttype.o mod-parttype.c pre-parttype.o parttype_mod-commands_i386_pc_parttype.o def-parttype.lst und-parttype.lst
+MOSTLYCLEANFILES += parttype_mod-commands_i386_pc_parttype.d
+DEFSYMFILES += def-parttype.lst
+UNDSYMFILES += und-parttype.lst
+
+parttype.mod: pre-parttype.o mod-parttype.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-parttype.o: parttype_mod-commands_i386_pc_parttype.o
+	-rm -f $@
+	$(LD) -r -d -o $@ $^
+
+mod-parttype.o: mod-parttype.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(parttype_mod_CFLAGS) -c -o $@ $<
+
+mod-parttype.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'parttype' $< > $@ || (rm -f $@; exit 1)
+
+def-parttype.lst: pre-parttype.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 parttype/' > $@
+
+und-parttype.lst: pre-parttype.o
+	echo 'parttype' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+parttype_mod-commands_i386_pc_parttype.o: commands/i386/pc/parttype.c
+	$(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(parttype_mod_CFLAGS) -c -o $@ $<
+
+parttype_mod-commands_i386_pc_parttype.d: commands/i386/pc/parttype.c
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(parttype_mod_CFLAGS) -M $< 	  | sed 's,parttype\.o[ :]*,parttype_mod-commands_i386_pc_parttype.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include parttype_mod-commands_i386_pc_parttype.d
+
+CLEANFILES += cmd-parttype.lst fs-parttype.lst
+COMMANDFILES += cmd-parttype.lst
+FSFILES += fs-parttype.lst
+
+cmd-parttype.lst: commands/i386/pc/parttype.c gencmdlist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(parttype_mod_CFLAGS) -E $< 	  | sh $(srcdir)/gencmdlist.sh parttype > $@ || (rm -f $@; exit 1)
+
+fs-parttype.lst: commands/i386/pc/parttype.c genfslist.sh
+	set -e; 	  $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(parttype_mod_CFLAGS) -E $< 	  | sh $(srcdir)/genfslist.sh parttype > $@ || (rm -f $@; exit 1)
+
+
+parttype_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For boot.mod.
 boot_mod_SOURCES = commands/boot.c
 CLEANFILES += boot.mod mod-boot.o mod-boot.c pre-boot.o boot_mod-commands_boot.o def-boot.lst und-boot.lst
diff -urpN grub2um/conf/i386-pc.rmk grub2m/conf/i386-pc.rmk
--- grub2um/conf/i386-pc.rmk	2005-07-25 15:23:26.000000000 +0200
+++ grub2m/conf/i386-pc.rmk	2005-08-02 14:03:32.000000000 +0200
@@ -102,7 +102,8 @@ pkgdata_MODULES = _chain.mod _linux.mod 
 	font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod		\
 	terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod	\
 	apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod	\
-	help.mod default.mod timeout.mod configfile.mod
+	help.mod default.mod timeout.mod configfile.mod sendkey.mod     \
+	activate.mod parttype.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -163,6 +164,18 @@ normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
 hello_mod_SOURCES = hello/hello.c
 hello_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For sendkey.mod.
+sendkey_mod_SOURCES = commands/i386/pc/sendkey.c
+sendkey_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For activate.mod.
+activate_mod_SOURCES = commands/i386/pc/activate.c
+activate_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For parttype.mod.
+parttype_mod_SOURCES = commands/i386/pc/parttype.c
+parttype_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For boot.mod.
 boot_mod_SOURCES = commands/boot.c
 boot_mod_CFLAGS = $(COMMON_CFLAGS)
diff -urpN grub2um/include/grub/normal.h grub2m/include/grub/normal.h
--- grub2um/include/grub/normal.h	2005-07-25 15:23:26.000000000 +0200
+++ grub2m/include/grub/normal.h	2005-07-25 15:25:29.000000000 +0200
@@ -44,6 +44,9 @@
 /* Not loaded yet. Used for auto-loading.  */
 #define GRUB_COMMAND_FLAG_NOT_LOADED	0x20
 
+/* Preboot function declaration.  */
+typedef void (*grub_prebootfn_t) (void); 
+
 /* The command description.  */
 struct grub_command
 {
@@ -178,6 +181,8 @@ grub_context_t grub_context_get (void);
 grub_menu_t grub_context_get_current_menu (void);
 grub_menu_t grub_context_push_menu (grub_menu_t menu);
 void grub_context_pop_menu (void);
+grub_err_t grub_preboot_add (grub_prebootfn_t fn);
+grub_err_t grub_preboot_remove (grub_prebootfn_t fn);
 
 #ifdef GRUB_UTIL
 void grub_normal_init (void);
diff -urpN grub2um/kern/misc.c grub2m/kern/misc.c
--- grub2um/kern/misc.c	2005-07-25 15:23:26.000000000 +0200
+++ grub2m/kern/misc.c	2005-08-01 19:01:39.000000000 +0200
@@ -911,41 +911,6 @@ grub_split_cmdline (const char *cmdline,
       do {
 	switch (c)
 	  {
-	  case '"':
-	    /* Double quote.  */
-	    while ((c = getchar ()))
-	      {
-		if (grub_errno)
-		  return 1;
-		/* Read in an escaped character.  */
-		if (c == '\\')
-		  {
-		    c = getchar ();
-		    *(bp++) = c;
-		    continue;
-		  }
-		else if (c == '"')
-		  break;
-		/* Read a variable.  */
-		if (c == '$')
-		  {
-		    getenvvar ();
-		    continue;
-		  }
-		*(bp++) = c;
-	      }
-	    break;
-
-	  case '\'':
-	    /* Single quote.  */
-	    while ((c = getchar ()) != '\'')
-	      {
-		if (grub_errno)
-		  return 1;
-
-		*(bp++) = c;
-	      }
-	    break;
 
 	  case '\n':
 	    /* This was not a argument afterall.  */
@@ -971,7 +936,43 @@ grub_split_cmdline (const char *cmdline,
 		    c = getchar ();
 		    continue;
 		  }
-		*(bp++) = c;
+
+		if (c == '\'')
+		  /* Single quote.  */
+		  while ((c = getchar ()) != '\'')
+		    {
+		      if (grub_errno)
+			return 1;
+
+		      *(bp++) = c;
+		    }
+
+		if (c == '"')
+		  /* Double quote.  */
+		  while ((c = getchar ()))
+		    {
+		      if (grub_errno)
+			return 1;
+		      /* Read in an escaped character.  */
+		      if (c == '\\')
+			{
+			  c = getchar ();
+			  *(bp++) = c;
+			  continue;
+			}
+		      else if (c == '"')
+			break;
+		      /* Read a variable.  */
+		      if (c == '$')
+			{
+			  getenvvar ();
+			  continue;
+			}
+		      *(bp++) = c;
+		    }
+
+		if (c != '"' && c != '\'')
+		  *(bp++) = c;
 		c = getchar ();
 	      }
 	    unputc (c);

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-03-19 11:24 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-11 16:03 [PATCH] grub-install for EFI Robert Millan
2007-05-11 16:11 ` Robert Millan
2007-05-11 16:21   ` Robert Millan
2007-05-15 18:23     ` new patch Robert Millan
2007-05-15 20:22     ` [PATCH] grub-install for EFI Yoshinori K. Okuji
2007-05-16  6:17       ` Robert Millan
2007-05-17 19:17         ` Yoshinori K. Okuji
2007-05-15 20:20   ` Yoshinori K. Okuji
2007-05-16  6:31     ` Robert Millan
2007-05-16 15:38       ` grub-install for EFI (please test) Robert Millan
2007-05-15 20:16 ` [PATCH] grub-install for EFI Yoshinori K. Okuji
2007-05-16  6:25   ` Robert Millan
2007-05-17 19:18     ` Yoshinori K. Okuji
2007-05-18  6:37       ` Robert Millan
2007-05-18 18:27         ` Yoshinori K. Okuji
2007-05-19  9:43           ` Robert Millan
2007-05-19 17:21             ` Yoshinori K. Okuji
2007-05-20  7:19               ` Robert Millan
  -- strict thread matches above, loose matches on Subject: below --
2023-03-15  9:18 new patch Menna Mahmoud
2023-03-15 18:37 ` Ira Weiny
2023-03-15 19:29   ` Menna Mahmoud
2023-03-16  0:24     ` Ira Weiny
2023-03-19 11:24       ` Menna Mahmoud
2005-08-04 14:04 New patch Vladimir Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.