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 . + */ + +#include +#include +#include +#include + +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 . + */ + +#include +#include +#include +#include + +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) {