All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Boeglin <alex@boeglin.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: grub2 efi patches
Date: Sun, 18 Nov 2007 19:14:03 +0100	[thread overview]
Message-ID: <20071118181403.GA11941@boeglin.org> (raw)
In-Reply-To: <87hcjuhzo8.fsf@xs4all.nl>

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

Hello,

Sorry for not replying earlier, I'm currently busy trying to figure out how to
access the Compatibility Support Module, and possibly enable lecagy boot.

Le Sat, Nov 10, 2007 at 04:45:43PM +0100, Marco Gerards a écrit :
> Alexandre Boeglin <alex@boeglin.org> writes:
> > grub2_efi_grub_prefix.patch uses the grub_prefix variable to set the prefix
> > environment variable, instead of the directory in which grub.efi is. This
> > allows to have grub.efi and the modules in different folders, and the old
> > behaviour should be preserved, if the grub_prefix is an empty string,
> 
> How about passing it as an argument to GRUB 2?  I assume EFI can do
> this?  This is what we do on open firmware, IIRC.

Well, this should also work if grub is the main bootloader of your machine,
but I think it would be a bit harder in the case you have grub on a EFI
bootable CD or USB stick (or that would depend on the primary bootloader in
this case). But actually, I don't know this part very well ...

I also still have to clean the chainloader options patch, but here is the
changelog for the others:

2007-11-18  Alexandre Boeglin  <alex@boeglin.org>

* normal/arg.c (grub_arg_parse): If one of the args is "--", add remaining
  N args, instead of "--" N times.

* commands/i386/efi/halt.c: New file.

* commands/i386/efi/reboot.c: New file.

* conf/i386-efi.rmk (grub_emu_SOURCES): Replace i386/pc/halt.c and reboot.c by
  i386/efi/halt.c and reboot.c.
  (grub_install_SOURCES): Add halt.mod and reboot.mod.
  (halt_mod_SOURCES): New variable.
  (halt_mod_CFLAGS): Likewise.
  (halt_mod_LDFLAGS): Likewise.
  (reboot_mod_SOURCES): Likewise.
  (reboot_mod_CFLAGS): Likewise.
  (reboot_mod_LDFLAGS): Likewise.

* include/grub/efi/efi.h (grub_reboot): New function declaration.
  (grub_halt): Likewise.

* kern/efi/efi.c (grub_reboot): New function.
  (grub_halt): Likewise.


And I just received the copyright assignment papers yesterday. I will post
them on monday.

Regards,
Alex

[-- Attachment #2: grub2_arg_doubledash.patch --]
[-- Type: text/x-diff, Size: 523 bytes --]

Index: normal/arg.c
===================================================================
RCS file: /sources/grub/grub2/normal/arg.c,v
retrieving revision 1.7
diff -u -p -r1.7 arg.c
--- normal/arg.c	21 Jul 2007 23:32:28 -0000	1.7
+++ normal/arg.c	18 Nov 2007 15:12:05 -0000
@@ -313,7 +313,7 @@ grub_arg_parse (grub_command_t cmd, int 
 	  if (grub_strlen (arg) == 2)
 	    {
 	      for (curarg++; curarg < argc; curarg++)
-		if (add_arg (arg) != 0)
+		if (add_arg (argv[curarg]) != 0)
 		  goto fail;
 	      break;
 	    }

[-- Attachment #3: grub2_efi_halt_reboot.patch --]
[-- Type: text/x-diff, Size: 6227 bytes --]

Index: commands/i386/efi/halt.c
===================================================================
RCS file: commands/i386/efi/halt.c
diff -N commands/i386/efi/halt.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ commands/i386/efi/halt.c	18 Nov 2007 17:49:37 -0000
@@ -0,0 +1,47 @@
+/* halt.c - command to halt the computer.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2007  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/efi/efi.h>
+
+static grub_err_t
+grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
+	       int argc __attribute__ ((unused)),
+	       char **args __attribute__ ((unused)))
+
+{
+  grub_halt ();
+  return 0;
+}
+
+
+\f
+GRUB_MOD_INIT(halt)
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
+			 "halt", "Halt the computer", 0);
+}
+
+GRUB_MOD_FINI(halt)
+{
+  grub_unregister_command ("halt");
+}
Index: commands/i386/efi/reboot.c
===================================================================
RCS file: commands/i386/efi/reboot.c
diff -N commands/i386/efi/reboot.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ commands/i386/efi/reboot.c	18 Nov 2007 17:49:37 -0000
@@ -0,0 +1,47 @@
+/* reboot.c - command to reboot the computer.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2007  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/efi/efi.h>
+
+static grub_err_t
+grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
+		 int argc __attribute__ ((unused)),
+		 char **args __attribute__ ((unused)))
+
+{
+  grub_reboot ();
+  return 0;
+}
+
+
+\f
+GRUB_MOD_INIT(reboot)
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
+			 "reboot", "Reboot the computer", 0);
+}
+
+GRUB_MOD_FINI(reboot)
+{
+  grub_unregister_command ("reboot");
+}
Index: conf/i386-efi.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-efi.rmk,v
retrieving revision 1.24
diff -u -p -r1.24 i386-efi.rmk
--- conf/i386-efi.rmk	18 Nov 2007 06:41:45 -0000	1.24
+++ conf/i386-efi.rmk	18 Nov 2007 17:49:37 -0000
@@ -45,7 +45,7 @@ grub_emu_SOURCES = commands/boot.c comma
 	commands/configfile.c commands/help.c				\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/hexdump.c				\
-	commands/i386/pc/halt.c commands/i386/pc/reboot.c		\
+	commands/i386/efi/halt.c commands/i386/efi/reboot.c		\
 	commands/i386/cpuid.c						\
 	disk/loopback.c							\
 	fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c	\
@@ -76,7 +76,7 @@ grub_install_SOURCES = util/i386/efi/gru
 
 # Modules.
 pkgdata_MODULES = kernel.mod normal.mod _chain.mod chain.mod \
-	_linux.mod linux.mod cpuid.mod
+	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod
 
 # For kernel.mod.
 kernel_mod_EXPORTS = no
@@ -140,4 +140,14 @@ cpuid_mod_SOURCES = commands/i386/cpuid.
 cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
 cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For halt.mod.
+halt_mod_SOURCES = commands/i386/efi/halt.c
+halt_mod_CFLAGS = $(COMMON_CFLAGS)
+halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For reboot.mod.
+reboot_mod_SOURCES = commands/i386/efi/reboot.c
+reboot_mod_CFLAGS = $(COMMON_CFLAGS)
+reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
Index: include/grub/efi/efi.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/efi/efi.h,v
retrieving revision 1.8
diff -u -p -r1.8 efi.h
--- include/grub/efi/efi.h	21 Jul 2007 23:32:23 -0000	1.8
+++ include/grub/efi/efi.h	18 Nov 2007 17:49:37 -0000
@@ -54,6 +54,8 @@ char *EXPORT_FUNC(grub_efi_get_filename)
 grub_efi_device_path_t *
 EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
 int EXPORT_FUNC(grub_efi_exit_boot_services) (grub_efi_uintn_t map_key);
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
 
 void grub_efi_mm_init (void);
 void grub_efi_mm_fini (void);
Index: kern/efi/efi.c
===================================================================
RCS file: /sources/grub/grub2/kern/efi/efi.c,v
retrieving revision 1.9
diff -u -p -r1.9 efi.c
--- kern/efi/efi.c	21 Jul 2007 23:32:26 -0000	1.9
+++ kern/efi/efi.c	18 Nov 2007 17:49:37 -0000
@@ -162,6 +162,22 @@ grub_exit (void)
 					      0, 0);
 }
 
+void
+grub_reboot (void)
+{
+  grub_efi_fini ();
+  grub_efi_system_table->runtime_services->
+    reset_system (GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL);
+}
+
+void
+grub_halt (void)
+{
+  grub_efi_fini ();
+  grub_efi_system_table->runtime_services->
+    reset_system (GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
+}
+
 int
 grub_efi_exit_boot_services (grub_efi_uintn_t map_key)
 {

  reply	other threads:[~2007-11-18 18:14 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-03 23:06 grub2 efi patches Alexandre Boeglin
2007-11-04  0:04 ` Alexandre Boeglin
2007-11-04  0:21   ` Alexandre Boeglin
2007-11-05 23:10     ` Alexandre Boeglin
2007-11-10 15:52       ` Marco Gerards
2007-11-10 15:48   ` Marco Gerards
2007-11-10 15:45 ` Marco Gerards
2007-11-18 18:14   ` Alexandre Boeglin [this message]
2007-12-18 20:16     ` Alexandre Boeglin
2008-01-23 11:39       ` Marco Gerards
2008-01-23 11:44         ` Robert Millan
2008-01-23 12:21           ` Marco Gerards
2008-01-24  8:35           ` Yoshinori K. Okuji
2008-01-24  9:12             ` Marco Gerards
2008-02-05 21:34         ` Alexandre Boeglin
2008-02-05 22:11           ` Robert Millan
2008-02-05 23:11             ` Alexandre Boeglin
2008-02-06  0:11               ` Robert Millan
2008-02-08 11:38                 ` Alexandre Boeglin
2008-02-08 12:04                   ` Robert Millan
2008-01-23 11:43     ` Robert Millan
2008-02-05 21:39       ` Alexandre Boeglin
2008-02-05 22:10         ` Robert Millan
2008-02-10 16:37           ` Generic halt and reboot commands (was: Re: grub2 efi patches) Alexandre Boeglin
2008-02-10 16:56             ` Robert Millan
2008-02-10 19:54               ` Alexandre Boeglin
2008-02-10 21:05                 ` Robert Millan
2008-02-10 21:58                   ` Alexandre Boeglin
2008-02-11 14:11                     ` Robert Millan
2008-02-11 22:15                       ` Alexandre Boeglin
2008-02-12 10:47                         ` Robert Millan
2008-02-12 11:37                           ` Alexandre Boeglin
2008-02-12 11:49                             ` Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071118181403.GA11941@boeglin.org \
    --to=alex@boeglin.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.