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
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;
+}
+
+
+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;
-}
-
-
-
-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;
-}
-
-
-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;
-}
-
-
-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;
+}
+
+
+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)
 {
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to