diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index ca969632a..e6786cdb8 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -8,10 +8,8 @@ GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200 pkglib_PROGRAMS += kernel.img kernel_img_SOURCES = kern/i386/coreboot/startup.S \ - kern/i386/misc.S \ kern/i386/coreboot/init.c \ kern/i386/coreboot/mmap.c \ - kern/i386/halt.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/term.c \ @@ -35,7 +33,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. -pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod +pkglib_MODULES = linux.mod aout.mod datetime.mod mmap.mod # For mmap.mod. mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c @@ -49,7 +47,8 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. -halt_mod_SOURCES = commands/halt.c +pkglib_MODULES += halt.mod +halt_mod_SOURCES = commands/halt.c lib/i386/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk index b12ddfdda..ba7a26629 100644 --- a/conf/i386-ieee1275.rmk +++ b/conf/i386-ieee1275.rmk @@ -7,7 +7,6 @@ pkglib_PROGRAMS = kernel.img # For kernel.img. kernel_img_SOURCES = kern/i386/ieee1275/startup.S \ - kern/i386/misc.S \ kern/ieee1275/init.c \ kern/ieee1275/mmap.c \ kern/ieee1275/cmain.c kern/ieee1275/openfw.c \ @@ -35,7 +34,7 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/ieee1275/grub-install.in # Modules. -pkglib_MODULES = halt.mod suspend.mod \ +pkglib_MODULES = suspend.mod \ aout.mod linux.mod \ nand.mod datetime.mod \ mmap.mod @@ -57,7 +56,8 @@ suspend_mod_CFLAGS = $(COMMON_CFLAGS) suspend_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod -halt_mod_SOURCES = commands/halt.c +pkglib_MODULES += halt.mod +halt_mod_SOURCES = commands/halt.c lib/ieee1275/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-multiboot.rmk b/conf/i386-multiboot.rmk index 69b8e9a48..1da30dfd9 100644 --- a/conf/i386-multiboot.rmk +++ b/conf/i386-multiboot.rmk @@ -8,10 +8,8 @@ GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200 pkglib_PROGRAMS += kernel.img kernel_img_SOURCES = kern/i386/coreboot/startup.S \ - kern/i386/misc.S \ kern/i386/coreboot/init.c \ kern/i386/multiboot_mmap.c \ - kern/i386/halt.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/term.c \ @@ -35,7 +33,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. -pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod +pkglib_MODULES = linux.mod aout.mod datetime.mod mmap.mod # For mmap.mod. mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c @@ -49,7 +47,8 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. -halt_mod_SOURCES = commands/halt.c +pkglib_MODULES += halt.mod +halt_mod_SOURCES = commands/halt.c lib/i386/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index b50655e9e..1ad32f41d 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -98,7 +98,6 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in pkglib_MODULES = biosdisk.mod chain.mod \ - halt.mod \ vbe.mod vbetest.mod vbeinfo.mod \ vga.mod \ aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod \ @@ -163,6 +162,7 @@ xnu_mod_LDFLAGS = $(COMMON_LDFLAGS) xnu_mod_ASFLAGS = $(COMMON_ASFLAGS) # For halt.mod. +pkglib_MODULES += halt.mod halt_mod_SOURCES = commands/i386/pc/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/i386-qemu.rmk b/conf/i386-qemu.rmk index 664bef12a..6c2e00586 100644 --- a/conf/i386-qemu.rmk +++ b/conf/i386-qemu.rmk @@ -21,10 +21,8 @@ util/grub-mkrawimage.c_DEPENDENCIES = Makefile pkglib_IMAGES += kernel.img kernel_img_SOURCES = kern/i386/qemu/startup.S \ - kern/i386/misc.S \ kern/i386/coreboot/init.c \ kern/i386/qemu/mmap.c \ - kern/i386/halt.c \ kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/term.c \ @@ -49,7 +47,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. -pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod +pkglib_MODULES = linux.mod aout.mod datetime.mod mmap.mod # For mmap.mod. mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c @@ -63,7 +61,8 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. -halt_mod_SOURCES = commands/halt.c +pkglib_MODULES += halt.mod +halt_mod_SOURCES = commands/halt.c lib/i386/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk index d5968ac8e..736fa4394 100644 --- a/conf/powerpc-ieee1275.rmk +++ b/conf/powerpc-ieee1275.rmk @@ -55,7 +55,7 @@ suspend_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod pkglib_MODULES += halt.mod -halt_mod_SOURCES = commands/halt.c +halt_mod_SOURCES = commands/halt.c lib/ieee1275/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk index f0c9b0db7..c6a0d03ec 100644 --- a/conf/sparc64-ieee1275.rmk +++ b/conf/sparc64-ieee1275.rmk @@ -93,7 +93,7 @@ linux_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. pkglib_MODULES += halt.mod -halt_mod_SOURCES = commands/halt.c +halt_mod_SOURCES = commands/halt.c lib/ieee1275/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/x86-efi.rmk b/conf/x86-efi.rmk index e29dad645..1d2221cdf 100644 --- a/conf/x86-efi.rmk +++ b/conf/x86-efi.rmk @@ -17,7 +17,7 @@ grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. pkglib_PROGRAMS = kernel.img pkglib_MODULES = chain.mod appleldr.mod \ - linux.mod halt.mod \ + linux.mod \ datetime.mod loadbios.mod \ fixvideo.mod mmap.mod acpi.mod @@ -77,7 +77,8 @@ linux_mod_LDFLAGS = $(COMMON_LDFLAGS) endif # For halt.mod. -halt_mod_SOURCES = commands/halt.c +pkglib_MODULES += halt.mod +halt_mod_SOURCES = commands/halt.c lib/efi/halt.c halt_mod_CFLAGS = $(COMMON_CFLAGS) halt_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/include/grub/misc.h b/include/grub/misc.h index 44bcfe507..e5635e239 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -305,7 +305,7 @@ void EXPORT_FUNC (grub_reboot) (void); * use APM even if it is available. */ void grub_halt (int no_apm); #else -void EXPORT_FUNC (grub_halt) (void); +void grub_halt (void); #endif #endif /* ! GRUB_MISC_HEADER */ diff --git a/kern/efi/efi.c b/kern/efi/efi.c index d8b225535..6806bb72a 100644 --- a/kern/efi/efi.c +++ b/kern/efi/efi.c @@ -173,14 +173,6 @@ grub_reboot (void) } #endif -void -grub_halt (void) -{ - grub_efi_fini (); - efi_call_4 (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 --git a/kern/i386/coreboot/init.c b/kern/i386/coreboot/init.c index 93d75eced..594986eb8 100644 --- a/kern/i386/coreboot/init.c +++ b/kern/i386/coreboot/init.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/kern/i386/qemu/mmap.c b/kern/i386/qemu/mmap.c index c7fc4f45e..fdc7e191b 100644 --- a/kern/i386/qemu/mmap.c +++ b/kern/i386/qemu/mmap.c @@ -16,7 +16,6 @@ * along with GRUB. If not, see . */ -#include #include #include #include diff --git a/kern/i386/qemu/startup.S b/kern/i386/qemu/startup.S index 7484650b2..22996a394 100644 --- a/kern/i386/qemu/startup.S +++ b/kern/i386/qemu/startup.S @@ -94,6 +94,9 @@ codestart: call EXT_C(grub_main) /* This should never happen. */ - jmp EXT_C(grub_stop) + cli +1: + hlt + jmp 1b #include "../realmode.S" diff --git a/kern/ieee1275/openfw.c b/kern/ieee1275/openfw.c index cf9e1a870..2f15274b6 100644 --- a/kern/ieee1275/openfw.c +++ b/kern/ieee1275/openfw.c @@ -423,13 +423,3 @@ grub_reboot (void) grub_ieee1275_interpret ("reset-all", 0); } #endif - -void -grub_halt (void) -{ - /* Not standardized. We try three known commands. */ - - grub_ieee1275_interpret ("shut-down", 0); - grub_ieee1275_interpret ("power-off", 0); - grub_ieee1275_interpret ("poweroff", 0); -} diff --git a/kern/i386/misc.S b/lib/efi/halt.c similarity index 62% rename from kern/i386/misc.S rename to lib/efi/halt.c index 7d57df9b9..e6fd6d07d 100644 --- a/kern/i386/misc.S +++ b/lib/efi/halt.c @@ -1,6 +1,7 @@ +/* efi.c - generic EFI support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc. + * Copyright (C) 2006,2007,2008,2009,2010 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 @@ -16,14 +17,16 @@ * along with GRUB. If not, see . */ -#include +#include +#include +#include +#include +#include - .text -/* - * This call is special... it never returns... in fact it should simply - * hang at this point! - */ -FUNCTION(grub_stop) - cli -1: hlt - jmp 1b +void +grub_halt (void) +{ + grub_machine_fini (); + efi_call_4 (grub_efi_system_table->runtime_services->reset_system, + GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL); +} diff --git a/kern/i386/halt.c b/lib/i386/halt.c similarity index 83% rename from kern/i386/halt.c rename to lib/i386/halt.c index 10805e42b..74e0c7301 100644 --- a/kern/i386/halt.c +++ b/lib/i386/halt.c @@ -17,11 +17,24 @@ */ #include -#include #include const char bochs_shutdown[] = "Shutdown"; +/* + * This call is special... it never returns... in fact it should simply + * hang at this point! + */ +static inline void __attribute__ ((noreturn)) +stop (void) +{ + asm volatile ("cli"); + while (1) + { + asm volatile ("hlt"); + } +} + void grub_halt (void) { @@ -38,5 +51,5 @@ grub_halt (void) /* In order to return we'd have to check what the previous status of IF flag was. But user most likely doesn't want to return anyway ... */ - grub_stop (); + stop (); } diff --git a/include/grub/i386/coreboot/init.h b/lib/ieee1275/halt.c similarity index 62% rename from include/grub/i386/coreboot/init.h rename to lib/ieee1275/halt.c index e944f9cc8..9453714d3 100644 --- a/include/grub/i386/coreboot/init.h +++ b/lib/ieee1275/halt.c @@ -1,6 +1,7 @@ +/* openfw.c -- Open firmware support functions. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2007,2008,2009 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 @@ -16,13 +17,15 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_INIT_I386_LINUXBIOS_HEADER -#define GRUB_INIT_I386_LINUXBIOS_HEADER 1 +#include +#include -#include -#include -#include +void +grub_halt (void) +{ + /* Not standardized. We try three known commands. */ -void EXPORT_FUNC(grub_stop) (void) __attribute__ ((noreturn)); - -#endif + grub_ieee1275_interpret ("shut-down", 0); + grub_ieee1275_interpret ("power-off", 0); + grub_ieee1275_interpret ("poweroff", 0); +} diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 3c7fe2fee..f9926d114 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include