All of lore.kernel.org
 help / color / mirror / Atom feed
* grub2 efi patches
@ 2007-11-03 23:06 Alexandre Boeglin
  2007-11-04  0:04 ` Alexandre Boeglin
  2007-11-10 15:45 ` Marco Gerards
  0 siblings, 2 replies; 33+ messages in thread
From: Alexandre Boeglin @ 2007-11-03 23:06 UTC (permalink / raw)
  To: grub-devel

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

Hello,

Here are a few patches for grub2, against cvs head:

grub2_arg_doubledash.patch fixes a bug in the handling of the '--'
argument,

grub2_efi_chainloader_options.patch adds support for efi chainload options,
it is not really beautiful (for instance, the ascii to utf16 conversion),
but it works for the MacOSX loader,

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,

grub2_efi_halt_reboot.patch adds support for the reboot and halt commands,
provided by efi runtime services.

Regards,
Alex

P.S.: I sent the patches as attachments, I don't know if they will be
discarded by the list robot or not ...
-- 
Alexandre Boeglin
email: alex (at) boeglin (dot) org
jabber: alex (at) im (dot) apinc (dot) org
website: http://boeglin.org/

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

Index: normal/arg.c
===================================================================
RCS file: /sources/grub/grub2/normal/arg.c,v
retrieving revision 1.7
diff -u -r1.7 arg.c
--- normal/arg.c	21 Jul 2007 23:32:28 -0000	1.7
+++ normal/arg.c	3 Nov 2007 22:44:41 -0000
@@ -313,7 +313,7 @@
 	  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_chainloader_options.patch --]
[-- Type: text/x-patch, Size: 3731 bytes --]

Index: include/grub/efi/chainloader.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
retrieving revision 1.2
diff -u -r1.2 chainloader.h
--- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
+++ include/grub/efi/chainloader.h	3 Nov 2007 22:42:01 -0000
@@ -19,6 +19,6 @@
 #ifndef GRUB_EFI_CHAINLOADER_HEADER
 #define GRUB_EFI_CHAINLOADER_HEADER	1
 
-void grub_chainloader_cmd (const char *filename);
+void grub_chainloader_cmd (int argc, char *argv[]);
 
 #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
Index: loader/efi/chainloader.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader.c
--- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader.c	3 Nov 2007 22:42:47 -0000
@@ -17,8 +17,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* TODO: support load options.  */
-
 #include <grub/loader.h>
 #include <grub/file.h>
 #include <grub/err.h>
@@ -175,7 +173,7 @@
 }
 
 void
-grub_chainloader_cmd (const char *filename)
+grub_chainloader_cmd (int argc, char *argv[])
 {
   grub_file_t file = 0;
   grub_ssize_t size;
@@ -185,6 +183,11 @@
   grub_device_t dev = 0;
   grub_efi_device_path_t *dp = 0;
   grub_efi_loaded_image_t *loaded_image;
+  char *filename = argv[0];
+  grub_efi_char16_t **options = NULL, *p;
+  int i, j, options_len = 0;
+
+  b = grub_efi_system_table->boot_services;
   
   grub_dl_ref (my_mod);
 
@@ -192,6 +195,30 @@
   address = 0;
   image_handle = 0;
   file_path = 0;
+
+  if (argc == 0)
+  {
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+    goto fail;
+  }
+
+  /* copy options */
+  if (argc > 1)
+  {
+    for (i = 1; i < argc; i++)
+      options_len += (grub_strlen (argv[i]) + 1) * sizeof (**options);
+
+    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len + sizeof (**options), options);
+    if (status != GRUB_EFI_SUCCESS)
+      goto fail;
+    p = *options;
+
+    for (i = 1; i < argc; i++){
+      *p++ = ' ';
+      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
+        p[j] = argv[i][j];
+    }
+  }
   
   b = grub_efi_system_table->boot_services;
 
@@ -267,6 +294,10 @@
       goto fail;
     }
   loaded_image->device_handle = dev_handle;
+
+  if (*options)
+    loaded_image->load_options = *options;
+    loaded_image->load_options_size = options_len + 1;
   
   grub_file_close (file);
   grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
@@ -292,10 +323,7 @@
 static void
 grub_rescue_cmd_chainloader (int argc, char *argv[])
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (argv[0]);
+  grub_chainloader_cmd (argc, argv);
 }
 
 static const char loader_name[] = "chainloader";
Index: loader/efi/chainloader_normal.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader_normal.c
--- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader_normal.c	3 Nov 2007 22:42:47 -0000
@@ -26,10 +26,7 @@
 chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
 		     int argc, char **args)
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (args[0]);
+  grub_chainloader_cmd (argc, args);
   return grub_errno;
 }
 

[-- Attachment #4: grub2_efi_grub_prefix.patch --]
[-- Type: text/x-patch, Size: 883 bytes --]

Index: kern/efi/init.c
===================================================================
RCS file: /sources/grub/grub2/kern/efi/init.c,v
retrieving revision 1.5
diff -u -r1.5 init.c
--- kern/efi/init.c	21 Jul 2007 23:32:26 -0000	1.5
+++ kern/efi/init.c	3 Nov 2007 19:05:00 -0000
@@ -53,7 +53,19 @@
       device = grub_efidisk_get_device_name (image->device_handle);
       file = grub_efi_get_filename (image->file_path);
       
-      if (device && file)
+      if (grub_prefix[0] != '\0' && device)
+	{
+	  char *prefix;
+	  prefix = grub_malloc (1 + grub_strlen (device) + 1
+				+ grub_strlen (grub_prefix) + 1);
+	  if (prefix)
+	    {
+	      grub_sprintf (prefix, "(%s)%s", device, grub_prefix);
+	      grub_env_set ("prefix", prefix);
+	      grub_free (prefix);
+	    }
+	}
+      else if (device && file)
 	{
 	  char *p;
 	  char *prefix;

[-- Attachment #5: grub2_efi_halt_reboot.patch --]
[-- Type: text/x-patch, Size: 5623 bytes --]

diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/commands/i386/efi/halt.c grub2/commands/i386/efi/halt.c
--- grub2_orig/commands/i386/efi/halt.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2/commands/i386/efi/halt.c	2007-11-03 19:14:05.905493750 +0100
@@ -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;
+}
+
+
+
+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");
+}
diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/commands/i386/efi/reboot.c grub2/commands/i386/efi/reboot.c
--- grub2_orig/commands/i386/efi/reboot.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2/commands/i386/efi/reboot.c	2007-11-03 19:14:22.850552750 +0100
@@ -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;
+}
+
+
+
+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");
+}
diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/conf/i386-efi.rmk grub2/conf/i386-efi.rmk
--- grub2_orig/conf/i386-efi.rmk	2007-10-22 21:59:32.000000000 +0200
+++ grub2/conf/i386-efi.rmk	2007-11-03 19:15:48.259890500 +0100
@@ -76,7 +76,7 @@
 
 # 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_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
diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/include/grub/efi/efi.h grub2/include/grub/efi/efi.h
--- grub2_orig/include/grub/efi/efi.h	2007-07-22 01:32:23.000000000 +0200
+++ grub2/include/grub/efi/efi.h	2007-11-03 19:12:12.762422750 +0100
@@ -54,6 +54,8 @@
 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);
diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/kern/efi/efi.c grub2/kern/efi/efi.c
--- grub2_orig/kern/efi/efi.c	2007-07-22 01:32:26.000000000 +0200
+++ grub2/kern/efi/efi.c	2007-11-03 19:26:16.879176750 +0100
@@ -162,6 +162,22 @@
 					      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)
 {

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

* Re: grub2 efi patches
  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-10 15:48   ` Marco Gerards
  2007-11-10 15:45 ` Marco Gerards
  1 sibling, 2 replies; 33+ messages in thread
From: Alexandre Boeglin @ 2007-11-04  0:04 UTC (permalink / raw)
  To: The development of GRUB 2

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

On Sun, 4 Nov 2007 00:06:31 +0100, Alexandre Boeglin <alex@boeglin.org>
wrote:
> grub2_efi_chainloader_options.patch adds support for efi chainload
> options,
> it is not really beautiful (for instance, the ascii to utf16 conversion),
> but it works for the MacOSX loader,

Sorry, there was a mistake in the previous one ...

By the way, it's using boot_services->allocate_pool instead of grub_malloc.
I don't know if it's okay, but when I tried using grub_malloc, I was
getting "free magic is broken 0x0" errors.


Alex

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

Index: include/grub/efi/chainloader.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
retrieving revision 1.2
diff -u -r1.2 chainloader.h
--- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
+++ include/grub/efi/chainloader.h	4 Nov 2007 00:00:40 -0000
@@ -19,6 +19,6 @@
 #ifndef GRUB_EFI_CHAINLOADER_HEADER
 #define GRUB_EFI_CHAINLOADER_HEADER	1
 
-void grub_chainloader_cmd (const char *filename);
+void grub_chainloader_cmd (int argc, char *argv[]);
 
 #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
Index: loader/efi/chainloader.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader.c
--- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader.c	4 Nov 2007 00:01:05 -0000
@@ -17,8 +17,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* TODO: support load options.  */
-
 #include <grub/loader.h>
 #include <grub/file.h>
 #include <grub/err.h>
@@ -175,7 +173,7 @@
 }
 
 void
-grub_chainloader_cmd (const char *filename)
+grub_chainloader_cmd (int argc, char *argv[])
 {
   grub_file_t file = 0;
   grub_ssize_t size;
@@ -185,6 +183,11 @@
   grub_device_t dev = 0;
   grub_efi_device_path_t *dp = 0;
   grub_efi_loaded_image_t *loaded_image;
+  char *filename = argv[0];
+  grub_efi_char16_t *options = NULL, *p;
+  int i, j, options_len = 0;
+
+  b = grub_efi_system_table->boot_services;
   
   grub_dl_ref (my_mod);
 
@@ -192,6 +195,30 @@
   address = 0;
   image_handle = 0;
   file_path = 0;
+
+  if (argc == 0)
+  {
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+    goto fail;
+  }
+
+  /* copy options */
+  if (argc > 1)
+  {
+    for (i = 1; i < argc; i++)
+      options_len += (grub_strlen (argv[i]) + 1) * sizeof (*options);
+
+    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len + sizeof (*options), &options);
+    if (status != GRUB_EFI_SUCCESS)
+      goto fail;
+    p = options;
+
+    for (i = 1; i < argc; i++){
+      *p++ = ' ';
+      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
+        p[j] = argv[i][j];
+    }
+  }
   
   b = grub_efi_system_table->boot_services;
 
@@ -267,6 +294,10 @@
       goto fail;
     }
   loaded_image->device_handle = dev_handle;
+
+  if (options)
+    loaded_image->load_options = options;
+    loaded_image->load_options_size = options_len + 1;
   
   grub_file_close (file);
   grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
@@ -292,10 +323,7 @@
 static void
 grub_rescue_cmd_chainloader (int argc, char *argv[])
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (argv[0]);
+  grub_chainloader_cmd (argc, argv);
 }
 
 static const char loader_name[] = "chainloader";
Index: loader/efi/chainloader_normal.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader_normal.c
--- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader_normal.c	4 Nov 2007 00:01:05 -0000
@@ -26,10 +26,7 @@
 chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
 		     int argc, char **args)
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (args[0]);
+  grub_chainloader_cmd (argc, args);
   return grub_errno;
 }
 

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

* Re: grub2 efi patches
  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:48   ` Marco Gerards
  1 sibling, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2007-11-04  0:21 UTC (permalink / raw)
  To: The development of GRUB 2

Le Sun, Nov 04, 2007 at 01:04:24AM +0100, Alexandre Boeglin a écrit :
> Sorry, there was a mistake in the previous one ...

Oops, and line 91 of this one should be

+    loaded_image->load_options_size = options_len + sizeof (*options);

instead of

+    loaded_image->load_options_size = options_len + 1;


Alex



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

* Re: grub2 efi patches
  2007-11-04  0:21   ` Alexandre Boeglin
@ 2007-11-05 23:10     ` Alexandre Boeglin
  2007-11-10 15:52       ` Marco Gerards
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2007-11-05 23:10 UTC (permalink / raw)
  To: The development of GRUB 2

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

On Sun, 4 Nov 2007 01:21:24 +0100, Alexandre Boeglin <alex@boeglin.org>
wrote:
> Le Sun, Nov 04, 2007 at 01:04:24AM +0100, Alexandre Boeglin a écrit :
>> Sorry, there was a mistake in the previous one ...
> Oops, and line 91 of this one should be

Hi, here is a "more correct" version of this patch: it also frees the
memory allocated to the options string when appropriate.


Alex

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

Index: include/grub/efi/chainloader.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
retrieving revision 1.2
diff -u -r1.2 chainloader.h
--- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
+++ include/grub/efi/chainloader.h	5 Nov 2007 22:58:51 -0000
@@ -19,6 +19,6 @@
 #ifndef GRUB_EFI_CHAINLOADER_HEADER
 #define GRUB_EFI_CHAINLOADER_HEADER	1
 
-void grub_chainloader_cmd (const char *filename);
+void grub_chainloader_cmd (int argc, char *argv[]);
 
 #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
Index: loader/efi/chainloader.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader.c
--- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader.c	5 Nov 2007 22:58:58 -0000
@@ -17,8 +17,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* TODO: support load options.  */
-
 #include <grub/loader.h>
 #include <grub/file.h>
 #include <grub/err.h>
@@ -38,6 +36,8 @@
 
 static grub_efi_physical_address_t address;
 static grub_efi_uintn_t pages;
+static grub_efi_char16_t *options;
+static grub_efi_uintn_t options_len;
 static grub_efi_device_path_t *file_path;
 static grub_efi_handle_t image_handle;
 
@@ -49,6 +49,8 @@
   b = grub_efi_system_table->boot_services;
   b->unload_image (image_handle);
   b->free_pages (address, pages);
+  if (options)
+    b->free_pool (options);
   grub_free (file_path);
   
   grub_dl_unref (my_mod);
@@ -175,7 +177,7 @@
 }
 
 void
-grub_chainloader_cmd (const char *filename)
+grub_chainloader_cmd (int argc, char *argv[])
 {
   grub_file_t file = 0;
   grub_ssize_t size;
@@ -185,16 +187,47 @@
   grub_device_t dev = 0;
   grub_efi_device_path_t *dp = 0;
   grub_efi_loaded_image_t *loaded_image;
+  char *filename = argv[0];
   
   grub_dl_ref (my_mod);
 
   /* Initialize some global variables.  */
   address = 0;
+  options = 0;
+  options_len = 0;
   image_handle = 0;
   file_path = 0;
   
   b = grub_efi_system_table->boot_services;
 
+  if (argc == 0)
+  {
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+    goto fail;
+  }
+
+  /* copy options */
+  if (argc > 1)
+  {
+    grub_efi_char16_t *p;
+    grub_efi_int16_t i;
+    grub_efi_uint16_t j;
+    for (i = 1; i < argc; i++)
+      options_len += (grub_strlen (argv[i]) + 1) * sizeof (*options);
+    options_len += sizeof (*options); /* \0 */
+
+    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len, (void *) &options);
+    if (status != GRUB_EFI_SUCCESS)
+      goto fail;
+    p = options;
+
+    for (i = 1; i < argc; i++){
+      *p++ = ' ';
+      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
+        p[j] = (grub_efi_char16_t) argv[i][j];
+    }
+  }
+
   file = grub_file_open (filename);
   if (! file)
     goto fail;
@@ -268,6 +301,10 @@
     }
   loaded_image->device_handle = dev_handle;
   
+  if (options_len)
+    loaded_image->load_options = options;
+    loaded_image->load_options_size = options_len;
+
   grub_file_close (file);
   grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
   return;
@@ -286,16 +323,16 @@
   if (address)
     b->free_pages (address, pages);
   
+  if (options)
+    b->free_pool (options);
+
   grub_dl_unref (my_mod);
 }
 
 static void
 grub_rescue_cmd_chainloader (int argc, char *argv[])
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (argv[0]);
+  grub_chainloader_cmd (argc, argv);
 }
 
 static const char loader_name[] = "chainloader";
Index: loader/efi/chainloader_normal.c
===================================================================
RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
retrieving revision 1.2
diff -u -r1.2 chainloader_normal.c
--- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
+++ loader/efi/chainloader_normal.c	5 Nov 2007 22:58:59 -0000
@@ -26,10 +26,7 @@
 chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
 		     int argc, char **args)
 {
-  if (argc == 0)
-    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-  else
-    grub_chainloader_cmd (args[0]);
+  grub_chainloader_cmd (argc, args);
   return grub_errno;
 }
 

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

* Re: grub2 efi patches
  2007-11-03 23:06 grub2 efi patches Alexandre Boeglin
  2007-11-04  0:04 ` Alexandre Boeglin
@ 2007-11-10 15:45 ` Marco Gerards
  2007-11-18 18:14   ` Alexandre Boeglin
  1 sibling, 1 reply; 33+ messages in thread
From: Marco Gerards @ 2007-11-10 15:45 UTC (permalink / raw)
  To: The development of GRUB 2

Alexandre Boeglin <alex@boeglin.org> writes:

Hi,

> Here are a few patches for grub2, against cvs head:

Great!  Thanks for working on this!  Can you please send in ChangeLog
entries for these patches?

> grub2_arg_doubledash.patch fixes a bug in the handling of the '--'
> argument,
>
> grub2_efi_chainloader_options.patch adds support for efi chainload options,
> it is not really beautiful (for instance, the ascii to utf16 conversion),
> but it works for the MacOSX loader,
>
> 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.

> grub2_efi_halt_reboot.patch adds support for the reboot and halt commands,
> provided by efi runtime services.
>
> Regards,
> Alex
>
> P.S.: I sent the patches as attachments, I don't know if they will be
> discarded by the list robot or not ...

No, this is even preferred.  Could you use "diff -up" for future
patches?

> Alexandre Boeglin
> email: alex (at) boeglin (dot) org
> jabber: alex (at) im (dot) apinc (dot) org
> website: http://boeglin.org/
>
> Index: normal/arg.c
> ===================================================================
> RCS file: /sources/grub/grub2/normal/arg.c,v
> retrieving revision 1.7
> diff -u -r1.7 arg.c
> --- normal/arg.c	21 Jul 2007 23:32:28 -0000	1.7
> +++ normal/arg.c	3 Nov 2007 22:44:41 -0000
> @@ -313,7 +313,7 @@
>  	  if (grub_strlen (arg) == 2)
>  	    {
>  	      for (curarg++; curarg < argc; curarg++)
> -		if (add_arg (arg) != 0)
> +		if (add_arg (argv[curarg]) != 0)
>  		  goto fail;
>  	      break;
>  	    }

Looks fine to me.

> Index: include/grub/efi/chainloader.h
> ===================================================================
> RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.h
> --- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
> +++ include/grub/efi/chainloader.h	3 Nov 2007 22:42:01 -0000
> @@ -19,6 +19,6 @@
>  #ifndef GRUB_EFI_CHAINLOADER_HEADER
>  #define GRUB_EFI_CHAINLOADER_HEADER	1
>  
> -void grub_chainloader_cmd (const char *filename);
> +void grub_chainloader_cmd (int argc, char *argv[]);
>  
>  #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
> Index: loader/efi/chainloader.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.c
> --- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader.c	3 Nov 2007 22:42:47 -0000
> @@ -17,8 +17,6 @@
>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -/* TODO: support load options.  */
> -
>  #include <grub/loader.h>
>  #include <grub/file.h>
>  #include <grub/err.h>
> @@ -175,7 +173,7 @@
>  }
>  
>  void
> -grub_chainloader_cmd (const char *filename)
> +grub_chainloader_cmd (int argc, char *argv[])
>  {
>    grub_file_t file = 0;
>    grub_ssize_t size;
> @@ -185,6 +183,11 @@
>    grub_device_t dev = 0;
>    grub_efi_device_path_t *dp = 0;
>    grub_efi_loaded_image_t *loaded_image;
> +  char *filename = argv[0];
> +  grub_efi_char16_t **options = NULL, *p;
> +  int i, j, options_len = 0;
> +
> +  b = grub_efi_system_table->boot_services;
>    
>    grub_dl_ref (my_mod);
>  
> @@ -192,6 +195,30 @@
>    address = 0;
>    image_handle = 0;
>    file_path = 0;
> +
> +  if (argc == 0)
> +  {
> +    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> +    goto fail;
> +  }

This indentation doesn't look right.  Same for the other "if"s.

> +  /* copy options */
> +  if (argc > 1)
> +  {
> +    for (i = 1; i < argc; i++)
> +      options_len += (grub_strlen (argv[i]) + 1) * sizeof (**options);
> +
> +    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len + sizeof (**options), options);

Do you deallocate when an error occurs?

> +    if (status != GRUB_EFI_SUCCESS)
> +      goto fail;
> +    p = *options;
> +
> +    for (i = 1; i < argc; i++){
> +      *p++ = ' ';
> +      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
> +        p[j] = argv[i][j];
> +    }

This indentation is not right.

> +  }
>    
>    b = grub_efi_system_table->boot_services;
>  
> @@ -267,6 +294,10 @@
>        goto fail;
>      }
>    loaded_image->device_handle = dev_handle;
> +
> +  if (*options)
> +    loaded_image->load_options = *options;
> +    loaded_image->load_options_size = options_len + 1;

This indentation is weird.  Did you forget { and }?  That's what this
indentation suggests.
    
>    grub_file_close (file);
>    grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
> @@ -292,10 +323,7 @@
>  static void
>  grub_rescue_cmd_chainloader (int argc, char *argv[])
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (argv[0]);
> +  grub_chainloader_cmd (argc, argv);
>  }
>  
>  static const char loader_name[] = "chainloader";
> Index: loader/efi/chainloader_normal.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader_normal.c
> --- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader_normal.c	3 Nov 2007 22:42:47 -0000
> @@ -26,10 +26,7 @@
>  chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
>  		     int argc, char **args)
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (args[0]);
> +  grub_chainloader_cmd (argc, args);
>    return grub_errno;
>  }

Did you have a look at GRUB_COMMAND_FLAG_NO_ARG_PARSE?  I think it
might be useful in your case.  It disables the argument parser so you
do not have to use "--".


> Index: kern/efi/init.c
> ===================================================================
> RCS file: /sources/grub/grub2/kern/efi/init.c,v
> retrieving revision 1.5
> diff -u -r1.5 init.c
> --- kern/efi/init.c	21 Jul 2007 23:32:26 -0000	1.5
> +++ kern/efi/init.c	3 Nov 2007 19:05:00 -0000
> @@ -53,7 +53,19 @@
>        device = grub_efidisk_get_device_name (image->device_handle);
>        file = grub_efi_get_filename (image->file_path);
>        
> -      if (device && file)
> +      if (grub_prefix[0] != '\0' && device)
> +	{
> +	  char *prefix;
> +	  prefix = grub_malloc (1 + grub_strlen (device) + 1
> +				+ grub_strlen (grub_prefix) + 1);
> +	  if (prefix)
> +	    {
> +	      grub_sprintf (prefix, "(%s)%s", device, grub_prefix);
> +	      grub_env_set ("prefix", prefix);
> +	      grub_free (prefix);
> +	    }
> +	}
> +      else if (device && file)
>  	{
>  	  char *p;
>  	  char *prefix;
>
> diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/commands/i386/efi/halt.c grub2/commands/i386/efi/halt.c
> --- grub2_orig/commands/i386/efi/halt.c	1970-01-01 01:00:00.000000000 +0100
> +++ grub2/commands/i386/efi/halt.c	2007-11-03 19:14:05.905493750 +0100
> @@ -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;
> +}
> +
> +
> +
> +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");
> +}
> diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/commands/i386/efi/reboot.c grub2/commands/i386/efi/reboot.c
> --- grub2_orig/commands/i386/efi/reboot.c	1970-01-01 01:00:00.000000000 +0100
> +++ grub2/commands/i386/efi/reboot.c	2007-11-03 19:14:22.850552750 +0100
> @@ -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;
> +}
> +
> +
> +
> +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");
> +}
> diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/conf/i386-efi.rmk grub2/conf/i386-efi.rmk
> --- grub2_orig/conf/i386-efi.rmk	2007-10-22 21:59:32.000000000 +0200
> +++ grub2/conf/i386-efi.rmk	2007-11-03 19:15:48.259890500 +0100
> @@ -76,7 +76,7 @@
>  
>  # 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_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
> diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/include/grub/efi/efi.h grub2/include/grub/efi/efi.h
> --- grub2_orig/include/grub/efi/efi.h	2007-07-22 01:32:23.000000000 +0200
> +++ grub2/include/grub/efi/efi.h	2007-11-03 19:12:12.762422750 +0100
> @@ -54,6 +54,8 @@
>  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);
> diff -ruNa -x CVS -x '*.mk' -x grub.efi -x '*.d' grub2_orig/kern/efi/efi.c grub2/kern/efi/efi.c
> --- grub2_orig/kern/efi/efi.c	2007-07-22 01:32:26.000000000 +0200
> +++ grub2/kern/efi/efi.c	2007-11-03 19:26:16.879176750 +0100
> @@ -162,6 +162,22 @@
>  					      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);

Please move the "(" to the next line.

> +}
> +
> +void
> +grub_halt (void)
> +{
> +  grub_efi_fini ();
> +  grub_efi_system_table->runtime_services->reset_system (
> +      GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
> +}

Same here.

--
Marco




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

* Re: grub2 efi patches
  2007-11-04  0:04 ` Alexandre Boeglin
  2007-11-04  0:21   ` Alexandre Boeglin
@ 2007-11-10 15:48   ` Marco Gerards
  1 sibling, 0 replies; 33+ messages in thread
From: Marco Gerards @ 2007-11-10 15:48 UTC (permalink / raw)
  To: The development of GRUB 2

Alexandre Boeglin <alex@boeglin.org> writes:

> On Sun, 4 Nov 2007 00:06:31 +0100, Alexandre Boeglin <alex@boeglin.org>
> wrote:
>> grub2_efi_chainloader_options.patch adds support for efi chainload
>> options,
>> it is not really beautiful (for instance, the ascii to utf16 conversion),
>> but it works for the MacOSX loader,
>
> Sorry, there was a mistake in the previous one ...

Ok :-)

> By the way, it's using boot_services->allocate_pool instead of grub_malloc.
> I don't know if it's okay, but when I tried using grub_malloc, I was
> getting "free magic is broken 0x0" errors.

Please use grub_malloc.  If you get this error, something is most
likely writing to unallocated memory or something like that...

> Index: include/grub/efi/chainloader.h
> ===================================================================
> RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.h
> --- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
> +++ include/grub/efi/chainloader.h	4 Nov 2007 00:00:40 -0000
> @@ -19,6 +19,6 @@
>  #ifndef GRUB_EFI_CHAINLOADER_HEADER
>  #define GRUB_EFI_CHAINLOADER_HEADER	1
>  
> -void grub_chainloader_cmd (const char *filename);
> +void grub_chainloader_cmd (int argc, char *argv[]);
>  
>  #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
> Index: loader/efi/chainloader.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.c
> --- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader.c	4 Nov 2007 00:01:05 -0000
> @@ -17,8 +17,6 @@
>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -/* TODO: support load options.  */
> -
>  #include <grub/loader.h>
>  #include <grub/file.h>
>  #include <grub/err.h>
> @@ -175,7 +173,7 @@
>  }
>  
>  void
> -grub_chainloader_cmd (const char *filename)
> +grub_chainloader_cmd (int argc, char *argv[])
>  {
>    grub_file_t file = 0;
>    grub_ssize_t size;
> @@ -185,6 +183,11 @@
>    grub_device_t dev = 0;
>    grub_efi_device_path_t *dp = 0;
>    grub_efi_loaded_image_t *loaded_image;
> +  char *filename = argv[0];
> +  grub_efi_char16_t *options = NULL, *p;
> +  int i, j, options_len = 0;
> +
> +  b = grub_efi_system_table->boot_services;
>    
>    grub_dl_ref (my_mod);
>  
> @@ -192,6 +195,30 @@
>    address = 0;
>    image_handle = 0;
>    file_path = 0;
> +
> +  if (argc == 0)
> +  {
> +    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> +    goto fail;
> +  }
> +
> +  /* copy options */

/* Copy options.  */

> +  if (argc > 1)
> +  {
> +    for (i = 1; i < argc; i++)
> +      options_len += (grub_strlen (argv[i]) + 1) * sizeof (*options);
> +
> +    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len + sizeof (*options), &options);
> +    if (status != GRUB_EFI_SUCCESS)
> +      goto fail;

Please use grub_malloc.

There are several ways to debug mm.c...

> +    p = options;
> +
> +    for (i = 1; i < argc; i++){
> +      *p++ = ' ';
> +      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
> +        p[j] = argv[i][j];
> +    }
> +  }
>    
>    b = grub_efi_system_table->boot_services;
>  
> @@ -267,6 +294,10 @@
>        goto fail;
>      }
>    loaded_image->device_handle = dev_handle;
> +
> +  if (options)
> +    loaded_image->load_options = options;
> +    loaded_image->load_options_size = options_len + 1;
>    
>    grub_file_close (file);
>    grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
> @@ -292,10 +323,7 @@
>  static void
>  grub_rescue_cmd_chainloader (int argc, char *argv[])
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (argv[0]);
> +  grub_chainloader_cmd (argc, argv);
>  }
>  
>  static const char loader_name[] = "chainloader";
> Index: loader/efi/chainloader_normal.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader_normal.c
> --- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader_normal.c	4 Nov 2007 00:01:05 -0000
> @@ -26,10 +26,7 @@
>  chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
>  		     int argc, char **args)
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (args[0]);
> +  grub_chainloader_cmd (argc, args);
>    return grub_errno;
>  }
>  
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel




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

* Re: grub2 efi patches
  2007-11-05 23:10     ` Alexandre Boeglin
@ 2007-11-10 15:52       ` Marco Gerards
  0 siblings, 0 replies; 33+ messages in thread
From: Marco Gerards @ 2007-11-10 15:52 UTC (permalink / raw)
  To: The development of GRUB 2

Alexandre Boeglin <alex@boeglin.org> writes:

> On Sun, 4 Nov 2007 01:21:24 +0100, Alexandre Boeglin <alex@boeglin.org>
> wrote:
>> Le Sun, Nov 04, 2007 at 01:04:24AM +0100, Alexandre Boeglin a écrit :
>>> Sorry, there was a mistake in the previous one ...
>> Oops, and line 91 of this one should be
>
> Hi, here is a "more correct" version of this patch: it also frees the
> memory allocated to the options string when appropriate.

I should've started with this patch ;-)

I can better do a full review again for clarity :-)

> Index: include/grub/efi/chainloader.h
> ===================================================================
> RCS file: /sources/grub/grub2/include/grub/efi/chainloader.h,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.h
> --- include/grub/efi/chainloader.h	21 Jul 2007 23:32:22 -0000	1.2
> +++ include/grub/efi/chainloader.h	5 Nov 2007 22:58:51 -0000
> @@ -19,6 +19,6 @@
>  #ifndef GRUB_EFI_CHAINLOADER_HEADER
>  #define GRUB_EFI_CHAINLOADER_HEADER	1
>  
> -void grub_chainloader_cmd (const char *filename);
> +void grub_chainloader_cmd (int argc, char *argv[]);
>  
>  #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
> Index: loader/efi/chainloader.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader.c
> --- loader/efi/chainloader.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader.c	5 Nov 2007 22:58:58 -0000
> @@ -17,8 +17,6 @@
>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> -/* TODO: support load options.  */
> -
>  #include <grub/loader.h>
>  #include <grub/file.h>
>  #include <grub/err.h>
> @@ -38,6 +36,8 @@
>  
>  static grub_efi_physical_address_t address;
>  static grub_efi_uintn_t pages;
> +static grub_efi_char16_t *options;
> +static grub_efi_uintn_t options_len;
>  static grub_efi_device_path_t *file_path;
>  static grub_efi_handle_t image_handle;
>  
> @@ -49,6 +49,8 @@
>    b = grub_efi_system_table->boot_services;
>    b->unload_image (image_handle);
>    b->free_pages (address, pages);
> +  if (options)
> +    b->free_pool (options);
>    grub_free (file_path);
>    
>    grub_dl_unref (my_mod);
> @@ -175,7 +177,7 @@
>  }
>  
>  void
> -grub_chainloader_cmd (const char *filename)
> +grub_chainloader_cmd (int argc, char *argv[])
>  {
>    grub_file_t file = 0;
>    grub_ssize_t size;
> @@ -185,16 +187,47 @@
>    grub_device_t dev = 0;
>    grub_efi_device_path_t *dp = 0;
>    grub_efi_loaded_image_t *loaded_image;
> +  char *filename = argv[0];
>    
>    grub_dl_ref (my_mod);
>  
>    /* Initialize some global variables.  */
>    address = 0;
> +  options = 0;
> +  options_len = 0;
>    image_handle = 0;
>    file_path = 0;
>    
>    b = grub_efi_system_table->boot_services;
>  
> +  if (argc == 0)
> +  {
> +    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> +    goto fail;
> +  }

The indentation is not right.

> +  /* copy options */

/* Copy options.  */

> +  if (argc > 1)
> +  {

The indentation is not right.

> +    grub_efi_char16_t *p;
> +    grub_efi_int16_t i;
> +    grub_efi_uint16_t j;
> +    for (i = 1; i < argc; i++)
> +      options_len += (grub_strlen (argv[i]) + 1) * sizeof (*options);
> +    options_len += sizeof (*options); /* \0 */
> +
> +    status = b->allocate_pool (GRUB_EFI_LOADER_DATA, options_len, (void *) &options);
> +    if (status != GRUB_EFI_SUCCESS)
> +      goto fail;
> +    p = options;

Please use grub_malloc here, I think it should work for what you are
doing, right?

> +    for (i = 1; i < argc; i++){
> +      *p++ = ' ';
> +      for (j = 0; j < grub_strlen (argv[i]) + 1; j++)
> +        p[j] = (grub_efi_char16_t) argv[i][j];
> +    }
> +  }
> +
>    file = grub_file_open (filename);
>    if (! file)
>      goto fail;
> @@ -268,6 +301,10 @@
>      }
>    loaded_image->device_handle = dev_handle;
>    
> +  if (options_len)
> +    loaded_image->load_options = options;
> +    loaded_image->load_options_size = options_len;

The second loaded_image... line seems to be incorrectly indented.

>    grub_file_close (file);
>    grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
>    return;
> @@ -286,16 +323,16 @@
>    if (address)
>      b->free_pages (address, pages);
>    
> +  if (options)
> +    b->free_pool (options);
> +
>    grub_dl_unref (my_mod);
>  }
>  
>  static void
>  grub_rescue_cmd_chainloader (int argc, char *argv[])
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (argv[0]);
> +  grub_chainloader_cmd (argc, argv);
>  }
>  
>  static const char loader_name[] = "chainloader";
> Index: loader/efi/chainloader_normal.c
> ===================================================================
> RCS file: /sources/grub/grub2/loader/efi/chainloader_normal.c,v
> retrieving revision 1.2
> diff -u -r1.2 chainloader_normal.c
> --- loader/efi/chainloader_normal.c	21 Jul 2007 23:32:28 -0000	1.2
> +++ loader/efi/chainloader_normal.c	5 Nov 2007 22:58:59 -0000
> @@ -26,10 +26,7 @@
>  chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
>  		     int argc, char **args)
>  {
> -  if (argc == 0)
> -    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
> -  else
> -    grub_chainloader_cmd (args[0]);
> +  grub_chainloader_cmd (argc, args);
>    return grub_errno;
>  }




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

* Re: grub2 efi patches
  2007-11-10 15:45 ` Marco Gerards
@ 2007-11-18 18:14   ` Alexandre Boeglin
  2007-12-18 20:16     ` Alexandre Boeglin
  2008-01-23 11:43     ` Robert Millan
  0 siblings, 2 replies; 33+ messages in thread
From: Alexandre Boeglin @ 2007-11-18 18:14 UTC (permalink / raw)
  To: The development of GRUB 2

[-- 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)
 {

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

* Re: grub2 efi patches
  2007-11-18 18:14   ` Alexandre Boeglin
@ 2007-12-18 20:16     ` Alexandre Boeglin
  2008-01-23 11:39       ` Marco Gerards
  2008-01-23 11:43     ` Robert Millan
  1 sibling, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2007-12-18 20:16 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin <alex@boeglin.org>
wrote:
> I also still have to clean the chainloader options patch, but here is the
> changelog for the others:

Hi,

As Marco finally received my copyright application papers, could someone
have a look at these patches ?


Regards,
Alex




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

* Re: grub2 efi patches
  2007-12-18 20:16     ` Alexandre Boeglin
@ 2008-01-23 11:39       ` Marco Gerards
  2008-01-23 11:44         ` Robert Millan
  2008-02-05 21:34         ` Alexandre Boeglin
  0 siblings, 2 replies; 33+ messages in thread
From: Marco Gerards @ 2008-01-23 11:39 UTC (permalink / raw)
  To: The development of GRUB 2

Alexandre Boeglin <alex@boeglin.org> writes:

> On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin <alex@boeglin.org>
> wrote:
>> I also still have to clean the chainloader options patch, but here is the
>> changelog for the others:
>
> Hi,
>
> As Marco finally received my copyright application papers, could someone
> have a look at these patches ?

Just to be very sure: did this happen?

--
Marco




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

* Re: grub2 efi patches
  2007-11-18 18:14   ` Alexandre Boeglin
  2007-12-18 20:16     ` Alexandre Boeglin
@ 2008-01-23 11:43     ` Robert Millan
  2008-02-05 21:39       ` Alexandre Boeglin
  1 sibling, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-01-23 11:43 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Nov 18, 2007 at 07:14:03PM +0100, Alexandre Boeglin wrote:
> Index: commands/i386/efi/halt.c
> ===================================================================
> RCS file: commands/i386/efi/halt.c
> diff -N commands/i386/efi/halt.c

> [...]

> +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");
> +}

commands/ieee1275/halt.c looks like the same thing to me.  Perhaps it'd make
more sense to move that to commands/halt.c and use it as the "generic" version
of halt command?

> 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

Possibly the same applies here.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: grub2 efi patches
  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-02-05 21:34         ` Alexandre Boeglin
  1 sibling, 2 replies; 33+ messages in thread
From: Robert Millan @ 2008-01-23 11:44 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Jan 23, 2008 at 12:39:35PM +0100, Marco Gerards wrote:
> Alexandre Boeglin <alex@boeglin.org> writes:
> 
> > On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin <alex@boeglin.org>
> > wrote:
> >> I also still have to clean the chainloader options patch, but here is the
> >> changelog for the others:
> >
> > Hi,
> >
> > As Marco finally received my copyright application papers, could someone
> > have a look at these patches ?
> 
> Just to be very sure: did this happen?

I don't know about this particular question, but Okuji added him to CVS
group.  This should mean the paperwork is sorted out?

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: grub2 efi patches
  2008-01-23 11:44         ` Robert Millan
@ 2008-01-23 12:21           ` Marco Gerards
  2008-01-24  8:35           ` Yoshinori K. Okuji
  1 sibling, 0 replies; 33+ messages in thread
From: Marco Gerards @ 2008-01-23 12:21 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan <rmh@aybabtu.com> writes:

> On Wed, Jan 23, 2008 at 12:39:35PM +0100, Marco Gerards wrote:
>> Alexandre Boeglin <alex@boeglin.org> writes:
>> 
>> > On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin <alex@boeglin.org>
>> > wrote:
>> >> I also still have to clean the chainloader options patch, but here is the
>> >> changelog for the others:
>> >
>> > Hi,
>> >
>> > As Marco finally received my copyright application papers, could someone
>> > have a look at these patches ?
>> 
>> Just to be very sure: did this happen?
>
> I don't know about this particular question, but Okuji added him to CVS
> group.  This should mean the paperwork is sorted out?

Yes.

--
Marco




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

* Re: grub2 efi patches
  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
  1 sibling, 1 reply; 33+ messages in thread
From: Yoshinori K. Okuji @ 2008-01-24  8:35 UTC (permalink / raw)
  To: The development of GRUB 2

On Wednesday 23 January 2008 12:44, Robert Millan wrote:
> On Wed, Jan 23, 2008 at 12:39:35PM +0100, Marco Gerards wrote:
> > Alexandre Boeglin <alex@boeglin.org> writes:
> > > On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin
> > > <alex@boeglin.org>
> > >
> > > wrote:
> > >> I also still have to clean the chainloader options patch, but here is
> > >> the changelog for the others:
> > >
> > > Hi,
> > >
> > > As Marco finally received my copyright application papers, could
> > > someone have a look at these patches ?
> >
> > Just to be very sure: did this happen?
>
> I don't know about this particular question, but Okuji added him to CVS
> group.  This should mean the paperwork is sorted out?

His name is already in the copyright.list on fencepost. This means that it has 
been done (although I even didn't know that Marco had ask him to do so).

Okuji



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

* Re: grub2 efi patches
  2008-01-24  8:35           ` Yoshinori K. Okuji
@ 2008-01-24  9:12             ` Marco Gerards
  0 siblings, 0 replies; 33+ messages in thread
From: Marco Gerards @ 2008-01-24  9:12 UTC (permalink / raw)
  To: The development of GRUB 2

"Yoshinori K. Okuji" <okuji@enbug.org> writes:

> On Wednesday 23 January 2008 12:44, Robert Millan wrote:
>> On Wed, Jan 23, 2008 at 12:39:35PM +0100, Marco Gerards wrote:
>> > Alexandre Boeglin <alex@boeglin.org> writes:
>> > > On Sun, 18 Nov 2007 19:14:03 +0100, Alexandre Boeglin
>> > > <alex@boeglin.org>
>> > >
>> > > wrote:
>> > >> I also still have to clean the chainloader options patch, but here is
>> > >> the changelog for the others:
>> > >
>> > > Hi,
>> > >
>> > > As Marco finally received my copyright application papers, could
>> > > someone have a look at these patches ?
>> >
>> > Just to be very sure: did this happen?
>>
>> I don't know about this particular question, but Okuji added him to CVS
>> group.  This should mean the paperwork is sorted out?
>
> His name is already in the copyright.list on fencepost. This means that it has 
> been done (although I even didn't know that Marco had ask him to do so).

Hopefully I didn't forget to CC you when I mailed him?  If so, it was
not intentionally and I am sorry.

--
Marco




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

* Re: grub2 efi patches
  2008-01-23 11:39       ` Marco Gerards
  2008-01-23 11:44         ` Robert Millan
@ 2008-02-05 21:34         ` Alexandre Boeglin
  2008-02-05 22:11           ` Robert Millan
  1 sibling, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-05 21:34 UTC (permalink / raw)
  To: The development of GRUB 2

Le mer 23 jan 2008 à 12:39:35 +0100, Marco Gerards a écrit :
> Alexandre Boeglin <alex@boeglin.org> writes:
> > As Marco finally received my copyright application papers, could someone
> > have a look at these patches ?
> 
> Just to be very sure: did this happen?

Hi,

I'm sorry, I've been a bit busy recently. So, here's a recap of the four
initial patches I posted:

- "--" handling is trivial, I think this can be commited.

- loader/efi/chainloader options support needs to be fixed.

- efi halt and reboot support is trivial too, but as Robert proposed halt.c
  and maybe reboot.c could be reused between different platforms.

- about prefix handling, more discussion is needed, I think.

I also have a "few" mails to catch up with...


Alex



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

* Re: grub2 efi patches
  2008-01-23 11:43     ` Robert Millan
@ 2008-02-05 21:39       ` Alexandre Boeglin
  2008-02-05 22:10         ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-05 21:39 UTC (permalink / raw)
  To: The development of GRUB 2

Le mer 23 jan 2008 à 12:43:31 +0100, Robert Millan a écrit :
> commands/ieee1275/halt.c looks like the same thing to me.  Perhaps it'd make
> more sense to move that to commands/halt.c and use it as the "generic" version
> of halt command?

Ok, is there any objection ?



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

* Re: grub2 efi patches
  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
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-05 22:10 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Feb 05, 2008 at 10:39:29PM +0100, Alexandre Boeglin wrote:
> Le mer 23 jan 2008 à 12:43:31 +0100, Robert Millan a écrit :
> > commands/ieee1275/halt.c looks like the same thing to me.  Perhaps it'd make
> > more sense to move that to commands/halt.c and use it as the "generic" version
> > of halt command?
> 
> Ok, is there any objection ?

Please post a patch first;  it'd be preferred if someone (maybe me!) tests it
on ieee1275 to make sure it didn't break anything.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: grub2 efi patches
  2008-02-05 21:34         ` Alexandre Boeglin
@ 2008-02-05 22:11           ` Robert Millan
  2008-02-05 23:11             ` Alexandre Boeglin
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-05 22:11 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Feb 05, 2008 at 10:34:09PM +0100, Alexandre Boeglin wrote:
> 
> Hi,
> 
> I'm sorry, I've been a bit busy recently. So, here's a recap of the four
> initial patches I posted:
> 
> - "--" handling is trivial, I think this can be commited.

Please can you add a follow-up in the relevant thread(s) ?  I get easily
confused in this gazillon of mails.  Not to mention those who check the
list less frequently...

Thanks

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: grub2 efi patches
  2008-02-05 22:11           ` Robert Millan
@ 2008-02-05 23:11             ` Alexandre Boeglin
  2008-02-06  0:11               ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-05 23:11 UTC (permalink / raw)
  To: The development of GRUB 2

Le mar 05 fév 2008 à 23:11:52 +0100, Robert Millan a écrit :
> On Tue, Feb 05, 2008 at 10:34:09PM +0100, Alexandre Boeglin wrote:
> > - "--" handling is trivial, I think this can be commited.
> 
> Please can you add a follow-up in the relevant thread(s) ?  I get easily
> confused in this gazillon of mails.  Not to mention those who check the
> list less frequently...

This was just a one line fix:

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;
            }



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

* Re: grub2 efi patches
  2008-02-05 23:11             ` Alexandre Boeglin
@ 2008-02-06  0:11               ` Robert Millan
  2008-02-08 11:38                 ` Alexandre Boeglin
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-06  0:11 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Feb 06, 2008 at 12:11:41AM +0100, Alexandre Boeglin wrote:
> Le mar 05 fév 2008 à 23:11:52 +0100, Robert Millan a écrit :
> > On Tue, Feb 05, 2008 at 10:34:09PM +0100, Alexandre Boeglin wrote:
> > > - "--" handling is trivial, I think this can be commited.
> > 
> > Please can you add a follow-up in the relevant thread(s) ?  I get easily
> > confused in this gazillon of mails.  Not to mention those who check the
> > list less frequently...
> 
> This was just a one line fix:
> 
> 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;
>             }

No idea what this is about.  Is there a thread that explains it?  :-)

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: grub2 efi patches
  2008-02-06  0:11               ` Robert Millan
@ 2008-02-08 11:38                 ` Alexandre Boeglin
  2008-02-08 12:04                   ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-08 11:38 UTC (permalink / raw)
  To: The development of GRUB 2

Le mer 06 fév 2008 à 01:11:04 +0100, Robert Millan a écrit :
> On Wed, Feb 06, 2008 at 12:11:41AM +0100, Alexandre Boeglin wrote:
> > This was just a one line fix:
> > 
> > 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;
> >             }
> 
> No idea what this is about.  Is there a thread that explains it?  :-)

Sorry, I should have been more verbose ... This is discussed in the beginning
of this thread. Basically, when you type in the grub console
"echo -- a b", it will echo "-- --" instead of "a b"

Alex



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

* Re: grub2 efi patches
  2008-02-08 11:38                 ` Alexandre Boeglin
@ 2008-02-08 12:04                   ` Robert Millan
  0 siblings, 0 replies; 33+ messages in thread
From: Robert Millan @ 2008-02-08 12:04 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Feb 08, 2008 at 12:38:06PM +0100, Alexandre Boeglin wrote:
> Le mer 06 fév 2008 à 01:11:04 +0100, Robert Millan a écrit :
> > On Wed, Feb 06, 2008 at 12:11:41AM +0100, Alexandre Boeglin wrote:
> > > This was just a one line fix:
> > > 
> > > 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;
> > >             }
> > 
> > No idea what this is about.  Is there a thread that explains it?  :-)
> 
> Sorry, I should have been more verbose ... This is discussed in the beginning
> of this thread. Basically, when you type in the grub console
> "echo -- a b", it will echo "-- --" instead of "a b"

Looks fine to me.  Since nobody seems to object, I suggest you check that in.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-05 22:10         ` Robert Millan
@ 2008-02-10 16:37           ` Alexandre Boeglin
  2008-02-10 16:56             ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-10 16:37 UTC (permalink / raw)
  To: The development of GRUB 2

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

Le mar 05 fév 2008 à 23:10:23 +0100, Robert Millan a écrit :
> On Tue, Feb 05, 2008 at 10:39:29PM +0100, Alexandre Boeglin wrote:
> > Le mer 23 jan 2008 à 12:43:31 +0100, Robert Millan a écrit :
> > > commands/ieee1275/halt.c looks like the same thing to me.  Perhaps it'd make
> > > more sense to move that to commands/halt.c and use it as the "generic" version
> > > of halt command?
> > 
> > Ok, is there any objection ?
> 
> Please post a patch first;  it'd be preferred if someone (maybe me!) tests it
> on ieee1275 to make sure it didn't break anything.

Here is the Changelog, patch is attached.

* conf/i386-efi.rmk (grub_emu_SOURCES): Replace commands/i386/pc/halt.c and
  reboot.c by commands/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.

* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Replace commands/ieee1275/halt.c
  and reboot.c by commands/halt.c and reboot.c.
  (halt_mod_SOURCES): Likewise.
  (reboot_mod_SOURCES): Likewise.

* conf/i386-pc.rmk (grub_emu_SOURCES): Replace commands/i386/pc/reboot.c by
  commands/reboot.c.
  (reboot_mod_SOURCES): Likewise.

* commands/i386/pc/reboot.c: merge this file ...

* commands/ieee1275/reboot.c: ... and this file ...

* commands/reboot.c: ... to this file.
  Add some precompiler directive to include the correct header for each
  machine.

* commands/ieee1275/halt.c: move this file ...

* commands/halt.c: ... to here.
  Add some precompiler directive to include the correct header for each
  machine.

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

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


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

diff -ruNap -x CVS -x '*.mk' grub2_commit/conf/i386-efi.rmk grub2_clean/conf/i386-efi.rmk
--- grub2_commit/conf/i386-efi.rmk	2008-02-01 16:45:16.000000000 +0100
+++ grub2_clean/conf/i386-efi.rmk	2008-02-10 17:13:45.178021500 +0100
@@ -37,7 +37,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/halt.c commands/reboot.c		\
 	commands/i386/cpuid.c						\
 	disk/loopback.c							\
 	\
@@ -72,7 +72,7 @@ grub_install_SOURCES = util/i386/efi/gru
 
 # Modules.
 pkglib_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
@@ -135,4 +135,14 @@ cpuid_mod_SOURCES = commands/i386/cpuid.
 cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
 cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For halt.mod.
+halt_mod_SOURCES = commands/halt.c
+halt_mod_CFLAGS = $(COMMON_CFLAGS)
+halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For reboot.mod.
+reboot_mod_SOURCES = commands/reboot.c
+reboot_mod_CFLAGS = $(COMMON_CFLAGS)
+reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
diff -ruNap -x CVS -x '*.mk' grub2_commit/conf/i386-ieee1275.rmk grub2_clean/conf/i386-ieee1275.rmk
--- grub2_commit/conf/i386-ieee1275.rmk	2008-02-01 16:45:16.000000000 +0100
+++ grub2_clean/conf/i386-ieee1275.rmk	2008-02-10 17:13:26.908879750 +0100
@@ -62,7 +62,7 @@ grub_emu_SOURCES = commands/boot.c comma
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/ieee1275/halt.c commands/ieee1275/reboot.c		\
+	commands/halt.c commands/reboot.c		\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c	disk/raid.c disk/lvm.c		\
 	\
@@ -122,12 +122,12 @@ suspend_mod_CFLAGS = $(COMMON_CFLAGS)
 suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For reboot.mod
-reboot_mod_SOURCES = commands/ieee1275/reboot.c
+reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For halt.mod
-halt_mod_SOURCES = commands/ieee1275/halt.c
+halt_mod_SOURCES = commands/halt.c
 halt_mod_CFLAGS = $(COMMON_CFLAGS)
 halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
diff -ruNap -x CVS -x '*.mk' grub2_commit/conf/i386-pc.rmk grub2_clean/conf/i386-pc.rmk
--- grub2_commit/conf/i386-pc.rmk	2008-02-03 09:27:15.000000000 +0100
+++ grub2_clean/conf/i386-pc.rmk	2008-02-10 17:14:05.655301250 +0100
@@ -103,7 +103,7 @@ grub_emu_SOURCES = commands/boot.c comma
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/i386/pc/halt.c commands/i386/pc/reboot.c		\
+	commands/i386/pc/halt.c commands/reboot.c		\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c	disk/raid.c disk/lvm.c		\
 	fs/fshelp.c 	\
@@ -185,7 +185,7 @@ normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
 normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For reboot.mod.
-reboot_mod_SOURCES = commands/i386/pc/reboot.c
+reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
diff -ruNap -x CVS grub2_commit/commands/halt.c grub2_clean/commands/halt.c
--- grub2_commit/commands/halt.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_clean/commands/halt.c	2008-02-10 17:07:47.847689750 +0100
@@ -0,0 +1,51 @@
+/* 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/machine/machine.h>
+
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/machine/kernel.h>
+#elif defined GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#endif
+
+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", "halts the computer.  This command does not"
+			 " work on all firmware.", 0);
+}
+
+GRUB_MOD_FINI(halt)
+{
+  grub_unregister_command ("halt");
+}
diff -ruNap -x CVS grub2_commit/commands/i386/pc/reboot.c grub2_clean/commands/i386/pc/reboot.c
--- grub2_commit/commands/i386/pc/reboot.c	2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/i386/pc/reboot.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,47 +0,0 @@
-/* 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/machine/init.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");
-}
diff -ruNap -x CVS grub2_commit/commands/ieee1275/halt.c grub2_clean/commands/ieee1275/halt.c
--- grub2_commit/commands/ieee1275/halt.c	2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/ieee1275/halt.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,46 +0,0 @@
-/* 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/misc.h>
-#include <grub/machine/kernel.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(ieee1275_halt)
-{
-  (void)mod;			/* To stop warning. */
-  grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
-			 "halt", "halts the computer.  This command does not"
-			 " work on all firmware.", 0);
-}
-
-GRUB_MOD_FINI(ieee1275_halt)
-{
-  grub_unregister_command ("halt");
-}
diff -ruNap -x CVS grub2_commit/commands/ieee1275/reboot.c grub2_clean/commands/ieee1275/reboot.c
--- grub2_commit/commands/ieee1275/reboot.c	2007-07-22 01:32:20.000000000 +0200
+++ grub2_clean/commands/ieee1275/reboot.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-/* 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/misc.h>
-#include <grub/machine/kernel.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(ieee1275_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(ieee1275_reboot)
-{
-  grub_unregister_command ("reboot");
-}
diff -ruNap -x CVS grub2_commit/commands/reboot.c grub2_clean/commands/reboot.c
--- grub2_commit/commands/reboot.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_clean/commands/reboot.c	2008-02-10 17:04:14.486355500 +0100
@@ -0,0 +1,53 @@
+/* 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/machine/machine.h>
+
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/machine/kernel.h>
+#elif defined GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#elif defined GRUB_MACHINE_PCBIOS
+#include <grub/machine/init.h>
+#endif
+
+
+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");
+}
diff -ruNap -x CVS grub2_commit/kern/efi/efi.c grub2_clean/kern/efi/efi.c
--- grub2_commit/kern/efi/efi.c	2007-07-22 01:32:26.000000000 +0200
+++ grub2_clean/kern/efi/efi.c	2008-02-10 16:16:49.908580500 +0100
@@ -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)
 {
diff -ruNap -x CVS grub2_commit/include/grub/efi/efi.h grub2_clean/include/grub/efi/efi.h
--- grub2_commit/include/grub/efi/efi.h	2007-07-22 01:32:23.000000000 +0200
+++ grub2_clean/include/grub/efi/efi.h	2008-02-10 16:16:49.884579000 +0100
@@ -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);

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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  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
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-10 16:56 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Feb 10, 2008 at 05:37:27PM +0100, Alexandre Boeglin wrote:
> 
> * commands/halt.c: ... to here.
>   Add some precompiler directive to include the correct header for each
>   machine.

Can we simplify this?  Since grub_halt() is put in kernel anyway, why not
always export it from kernel.h ?

Also, could you provide the diff after you have issued
"mv commands/ieee1275/halt.c commands/halt.c" or so?  That will make it much
easier to read than comparing files by hand.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-10 16:56             ` Robert Millan
@ 2008-02-10 19:54               ` Alexandre Boeglin
  2008-02-10 21:05                 ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-10 19:54 UTC (permalink / raw)
  To: The development of GRUB 2

Le dim 10 fév 2008 à 17:56:12 +0100, Robert Millan a écrit :
> On Sun, Feb 10, 2008 at 05:37:27PM +0100, Alexandre Boeglin wrote:
> > 
> > * commands/halt.c: ... to here.
> >   Add some precompiler directive to include the correct header for each
> >   machine.
> 
> Can we simplify this?  Since grub_halt() is put in kernel anyway, why not
> always export it from kernel.h ?

Well, efi, for instance, is not machine dependant, and so the header is not
located in include/grub/i386/efi but in include/grub/efi

> Also, could you provide the diff after you have issued
> "mv commands/ieee1275/halt.c commands/halt.c" or so?  That will make it much
> easier to read than comparing files by hand.

Ok, here are the diffs.

================================================================================
--- grub2_commit/commands/ieee1275/halt.c       2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/halt.c 2008-02-10 17:07:47.847689750 +0100
@@ -19,8 +19,13 @@
 
 #include <grub/normal.h>
 #include <grub/dl.h>
-#include <grub/misc.h>
+#include <grub/machine/machine.h>
+
+#ifdef GRUB_MACHINE_IEEE1275
 #include <grub/machine/kernel.h>
+#elif defined GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#endif
 
 static grub_err_t
 grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
@@ -32,7 +37,7 @@ grub_cmd_halt (struct grub_arg_list *sta
 }
 
 

-GRUB_MOD_INIT(ieee1275_halt)
+GRUB_MOD_INIT(halt)
 {
   (void)mod;                   /* To stop warning. */
   grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
@@ -40,7 +45,7 @@ GRUB_MOD_INIT(ieee1275_halt)
                         " work on all firmware.", 0);
 }
 
-GRUB_MOD_FINI(ieee1275_halt)
+GRUB_MOD_FINI(halt)
 {
   grub_unregister_command ("halt");
 }
================================================================================
--- grub2_commit/commands/ieee1275/reboot.c     2007-07-22 01:32:20.000000000 +0200
+++ grub2_clean/commands/reboot.c       2008-02-10 17:04:14.486355500 +0100
@@ -19,8 +19,16 @@
 
 #include <grub/normal.h>
 #include <grub/dl.h>
-#include <grub/misc.h>
+#include <grub/machine/machine.h>
+
+#ifdef GRUB_MACHINE_IEEE1275
 #include <grub/machine/kernel.h>
+#elif defined GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#elif defined GRUB_MACHINE_PCBIOS
+#include <grub/machine/init.h>
+#endif
+
 
 static grub_err_t
 grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
@@ -32,14 +40,14 @@ grub_cmd_reboot (struct grub_arg_list *s
 }
 
 

-GRUB_MOD_INIT(ieee1275_reboot)
+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(ieee1275_reboot)
+GRUB_MOD_FINI(reboot)
 {
   grub_unregister_command ("reboot");
 }
================================================================================
--- grub2_commit/commands/i386/pc/reboot.c      2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/reboot.c       2008-02-10 17:04:14.486355500 +0100
@@ -19,20 +19,26 @@
 
 #include <grub/normal.h>
 #include <grub/dl.h>
-#include <grub/arg.h>
+#include <grub/machine/machine.h>
+
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/machine/kernel.h>
+#elif defined GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#elif defined GRUB_MACHINE_PCBIOS
 #include <grub/machine/init.h>
+#endif
+
 
 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;
 }
 
-
 

 GRUB_MOD_INIT(reboot)
 {
================================================================================



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-10 19:54               ` Alexandre Boeglin
@ 2008-02-10 21:05                 ` Robert Millan
  2008-02-10 21:58                   ` Alexandre Boeglin
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-10 21:05 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Feb 10, 2008 at 08:54:08PM +0100, Alexandre Boeglin wrote:
> +#ifdef GRUB_MACHINE_IEEE1275
>  #include <grub/machine/kernel.h>
> +#elif defined GRUB_MACHINE_EFI
> +#include <grub/efi/efi.h>
> +#endif

For consistency with similar code elsewhere in GRUB, I think it's better if
you made this:

#if defined(foo)
#elif defined(bar)
#endif

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-10 21:05                 ` Robert Millan
@ 2008-02-10 21:58                   ` Alexandre Boeglin
  2008-02-11 14:11                     ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-10 21:58 UTC (permalink / raw)
  To: The development of GRUB 2

Le dim 10 fév 2008 à 22:05:46 +0100, Robert Millan a écrit :
> For consistency with similar code elsewhere in GRUB, I think it's better if
> you made this:
> 
> #if defined(foo)
> #elif defined(bar)
> #endif

No whitespace before the opening bracket in this case ?

By the way, this case is a good example of when it's 10 times easier to
produce a patch with SVN than with CVS ;)


Alex



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-10 21:58                   ` Alexandre Boeglin
@ 2008-02-11 14:11                     ` Robert Millan
  2008-02-11 22:15                       ` Alexandre Boeglin
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-11 14:11 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Feb 10, 2008 at 10:58:02PM +0100, Alexandre Boeglin wrote:
> Le dim 10 fév 2008 à 22:05:46 +0100, Robert Millan a écrit :
> > For consistency with similar code elsewhere in GRUB, I think it's better if
> > you made this:
> > 
> > #if defined(foo)
> > #elif defined(bar)
> > #endif
> 
> No whitespace before the opening bracket in this case ?

No.  See how other parts of GRUB do it.

> By the way, this case is a good example of when it's 10 times easier to
> produce a patch with SVN than with CVS ;)

I know...

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-11 14:11                     ` Robert Millan
@ 2008-02-11 22:15                       ` Alexandre Boeglin
  2008-02-12 10:47                         ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-11 22:15 UTC (permalink / raw)
  To: The development of GRUB 2

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

Le lun 11 fév 2008 à 15:11:44 +0100, Robert Millan a écrit :
> No.  See how other parts of GRUB do it.

Ok, here's the patch. I also added 2008 to the copyright statement of modified
files.


Alex

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

diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/commands/halt.c grub2_clean/commands/halt.c
--- grub2_commit/commands/halt.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_clean/commands/halt.c	2008-02-11 22:45:26.919392000 +0100
@@ -0,0 +1,51 @@
+/* halt.c - command to halt the computer.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2007,2008  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/machine/machine.h>
+
+#if defined(GRUB_MACHINE_IEEE1275)
+#include <grub/machine/kernel.h>
+#elif defined(GRUB_MACHINE_EFI)
+#include <grub/efi/efi.h>
+#endif
+
+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", "halts the computer.  This command does not"
+			 " work on all firmware.", 0);
+}
+
+GRUB_MOD_FINI(halt)
+{
+  grub_unregister_command ("halt");
+}
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/commands/i386/pc/reboot.c grub2_clean/commands/i386/pc/reboot.c
--- grub2_commit/commands/i386/pc/reboot.c	2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/i386/pc/reboot.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,47 +0,0 @@
-/* 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/machine/init.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");
-}
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/commands/ieee1275/halt.c grub2_clean/commands/ieee1275/halt.c
--- grub2_commit/commands/ieee1275/halt.c	2007-07-22 01:32:19.000000000 +0200
+++ grub2_clean/commands/ieee1275/halt.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,46 +0,0 @@
-/* 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/misc.h>
-#include <grub/machine/kernel.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(ieee1275_halt)
-{
-  (void)mod;			/* To stop warning. */
-  grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
-			 "halt", "halts the computer.  This command does not"
-			 " work on all firmware.", 0);
-}
-
-GRUB_MOD_FINI(ieee1275_halt)
-{
-  grub_unregister_command ("halt");
-}
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/commands/ieee1275/reboot.c grub2_clean/commands/ieee1275/reboot.c
--- grub2_commit/commands/ieee1275/reboot.c	2007-07-22 01:32:20.000000000 +0200
+++ grub2_clean/commands/ieee1275/reboot.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-/* 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/misc.h>
-#include <grub/machine/kernel.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(ieee1275_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(ieee1275_reboot)
-{
-  grub_unregister_command ("reboot");
-}
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/commands/reboot.c grub2_clean/commands/reboot.c
--- grub2_commit/commands/reboot.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_clean/commands/reboot.c	2008-02-11 22:45:15.102653500 +0100
@@ -0,0 +1,53 @@
+/* reboot.c - command to reboot the computer.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2007,2008  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/machine/machine.h>
+
+#if defined(GRUB_MACHINE_IEEE1275)
+#include <grub/machine/kernel.h>
+#elif defined(GRUB_MACHINE_EFI)
+#include <grub/efi/efi.h>
+#elif defined(GRUB_MACHINE_PCBIOS)
+#include <grub/machine/init.h>
+#endif
+
+
+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");
+}
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/conf/i386-efi.rmk grub2_clean/conf/i386-efi.rmk
--- grub2_commit/conf/i386-efi.rmk	2008-02-10 23:02:18.825042750 +0100
+++ grub2_clean/conf/i386-efi.rmk	2008-02-11 23:06:45.571302750 +0100
@@ -37,7 +37,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/halt.c commands/reboot.c				\
 	commands/i386/cpuid.c						\
 	disk/loopback.c							\
 	\
@@ -75,7 +75,7 @@ grub_install_SOURCES = util/i386/efi/gru
 
 # Modules.
 pkglib_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
@@ -138,4 +138,14 @@ cpuid_mod_SOURCES = commands/i386/cpuid.
 cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
 cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For halt.mod.
+halt_mod_SOURCES = commands/halt.c
+halt_mod_CFLAGS = $(COMMON_CFLAGS)
+halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For reboot.mod.
+reboot_mod_SOURCES = commands/reboot.c
+reboot_mod_CFLAGS = $(COMMON_CFLAGS)
+reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/conf/i386-ieee1275.rmk grub2_clean/conf/i386-ieee1275.rmk
--- grub2_commit/conf/i386-ieee1275.rmk	2008-02-10 23:02:18.861045000 +0100
+++ grub2_clean/conf/i386-ieee1275.rmk	2008-02-11 23:07:07.156651750 +0100
@@ -62,7 +62,7 @@ grub_emu_SOURCES = commands/boot.c comma
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/ieee1275/halt.c commands/ieee1275/reboot.c		\
+	commands/halt.c commands/reboot.c				\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c					\
 	\
@@ -125,12 +125,12 @@ suspend_mod_CFLAGS = $(COMMON_CFLAGS)
 suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For reboot.mod
-reboot_mod_SOURCES = commands/ieee1275/reboot.c
+reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For halt.mod
-halt_mod_SOURCES = commands/ieee1275/halt.c
+halt_mod_SOURCES = commands/halt.c
 halt_mod_CFLAGS = $(COMMON_CFLAGS)
 halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/conf/i386-pc.rmk grub2_clean/conf/i386-pc.rmk
--- grub2_commit/conf/i386-pc.rmk	2008-02-10 23:02:18.869045500 +0100
+++ grub2_clean/conf/i386-pc.rmk	2008-02-11 23:06:30.974390500 +0100
@@ -106,7 +106,7 @@ grub_emu_SOURCES = commands/boot.c comma
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/i386/pc/halt.c commands/i386/pc/reboot.c		\
+	commands/i386/pc/halt.c commands/reboot.c			\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c					\
 	fs/fshelp.c 	\
@@ -191,7 +191,7 @@ normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
 normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For reboot.mod.
-reboot_mod_SOURCES = commands/i386/pc/reboot.c
+reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/include/grub/efi/efi.h grub2_clean/include/grub/efi/efi.h
--- grub2_commit/include/grub/efi/efi.h	2007-07-22 01:32:23.000000000 +0200
+++ grub2_clean/include/grub/efi/efi.h	2008-02-11 22:56:02.283099750 +0100
@@ -1,7 +1,7 @@
 /* efi.h - declare variables and functions for EFI support */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2006,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2006,2007,2008  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
@@ -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);
diff -ruNap -x CVS -x '*.lst' -x '*.mk' -x '.*' -x '*.d' -x '*.o' grub2_commit/kern/efi/efi.c grub2_clean/kern/efi/efi.c
--- grub2_commit/kern/efi/efi.c	2007-07-22 01:32:26.000000000 +0200
+++ grub2_clean/kern/efi/efi.c	2008-02-11 22:55:46.770130250 +0100
@@ -1,7 +1,7 @@
 /* efi.c - generic EFI support */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2006,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2006,2007,2008  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
@@ -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)
 {

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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-11 22:15                       ` Alexandre Boeglin
@ 2008-02-12 10:47                         ` Robert Millan
  2008-02-12 11:37                           ` Alexandre Boeglin
  0 siblings, 1 reply; 33+ messages in thread
From: Robert Millan @ 2008-02-12 10:47 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Feb 11, 2008 at 11:15:50PM +0100, Alexandre Boeglin wrote:
> Le lun 11 fév 2008 à 15:11:44 +0100, Robert Millan a écrit :
> > No.  See how other parts of GRUB do it.
> 
> Ok, here's the patch. I also added 2008 to the copyright statement of modified
> files.

You forgot the changelog entry ;-)

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-12 10:47                         ` Robert Millan
@ 2008-02-12 11:37                           ` Alexandre Boeglin
  2008-02-12 11:49                             ` Robert Millan
  0 siblings, 1 reply; 33+ messages in thread
From: Alexandre Boeglin @ 2008-02-12 11:37 UTC (permalink / raw)
  To: The development of GRUB 2

Le mar 12 fév 2008 à 11:47:26 +0100, Robert Millan a écrit :
> On Mon, Feb 11, 2008 at 11:15:50PM +0100, Alexandre Boeglin wrote:
> > Le lun 11 fév 2008 à 15:11:44 +0100, Robert Millan a écrit :
> > > No.  See how other parts of GRUB do it.
> > 
> > Ok, here's the patch. I also added 2008 to the copyright statement of modified
> > files.
> 
> You forgot the changelog entry ;-)

Yes, but it's the same as the one I provided a few emails back, I think.

Alex



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

* Re: Generic halt and reboot commands (was: Re: grub2 efi patches)
  2008-02-12 11:37                           ` Alexandre Boeglin
@ 2008-02-12 11:49                             ` Robert Millan
  0 siblings, 0 replies; 33+ messages in thread
From: Robert Millan @ 2008-02-12 11:49 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Feb 12, 2008 at 12:37:45PM +0100, Alexandre Boeglin wrote:
> Le mar 12 fév 2008 à 11:47:26 +0100, Robert Millan a écrit :
> > On Mon, Feb 11, 2008 at 11:15:50PM +0100, Alexandre Boeglin wrote:
> > > Le lun 11 fév 2008 à 15:11:44 +0100, Robert Millan a écrit :
> > > > No.  See how other parts of GRUB do it.
> > > 
> > > Ok, here's the patch. I also added 2008 to the copyright statement of modified
> > > files.
> > 
> > You forgot the changelog entry ;-)
> 
> Yes, but it's the same as the one I provided a few emails back, I think.

Ah, ok.  You forgot to tab-indent it, and also added two extra spaces in
"non-*" lines.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

end of thread, other threads:[~2008-02-12 11:51 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.