]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
move grub_halt out of kernel on most platforms
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 4 May 2010 15:15:36 +0000 (17:15 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 4 May 2010 15:15:36 +0000 (17:15 +0200)
18 files changed:
conf/i386-coreboot.rmk
conf/i386-ieee1275.rmk
conf/i386-multiboot.rmk
conf/i386-pc.rmk
conf/i386-qemu.rmk
conf/powerpc-ieee1275.rmk
conf/sparc64-ieee1275.rmk
conf/x86-efi.rmk
include/grub/misc.h
kern/efi/efi.c
kern/i386/coreboot/init.c
kern/i386/qemu/mmap.c
kern/i386/qemu/startup.S
kern/ieee1275/openfw.c
lib/efi/halt.c [moved from kern/i386/misc.S with 62% similarity]
lib/i386/halt.c [moved from kern/i386/halt.c with 83% similarity]
lib/ieee1275/halt.c [moved from include/grub/i386/coreboot/init.h with 62% similarity]
loader/i386/bsd.c

index ca969632a8a6b8824c4c73cd1a091fdf2d3ec767..e6786cdb824025aac2041e3ddd79c5df75cc8ea4 100644 (file)
@@ -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)
 
index b12ddfddab2aa38f0b132754163599c923716671..ba7a2662944573f205c5cb9ca7f9c9b6f5f20e12 100644 (file)
@@ -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)
 
index 69b8e9a488723773a319f2346bfb2543542980df..1da30dfd915d857c3410d2d778f9e729faf3c9a9 100644 (file)
@@ -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)
 
index b50655e9e597b40067423a1af90e2f8b0bf7a8fc..1ad32f41d95080e5e36cfffe3c99f9b572a4ccf9 100644 (file)
@@ -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)
index 664bef12a3d8bbf4da0865f2ad96cb5643efc621..6c2e005869b3f83b9fad748a4db5500f064655b2 100644 (file)
@@ -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)
 
index d5968ac8e3e2b44bb22baf1c598b82331505830b..736fa4394b50a11886fad4c5e0f03769ec54d091 100644 (file)
@@ -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)
 
index f0c9b0db79842924d5bc0c05c0e11a86e37a7ffb..c6a0d03ec9b31d485f190d60bdb78e1d9b3cb75f 100644 (file)
@@ -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)
 
index e29dad64539a183c0a495e9ad369cd3b998394f3..1d2221cdf7ca907999eac837e3c1aadf52f10dc0 100644 (file)
@@ -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)
 
index 44bcfe507979581489ed8bdbdacb898099e03f16..e5635e2398eb003b006b7920d632794072a5f4bc 100644 (file)
@@ -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 */
index d8b22553545ee4afdd1d32a9f444da15f337ba5b..6806bb72a5219bd5e6d0532edbd86c5ca08e7c19 100644 (file)
@@ -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)
 {
index 93d75eced04c72946dd016e1fa24cbe9c275cca2..594986eb8747baaf7fd51529f84e6d910b78a928 100644 (file)
@@ -19,7 +19,6 @@
 #include <grub/kernel.h>
 #include <grub/mm.h>
 #include <grub/machine/time.h>
-#include <grub/machine/init.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
@@ -33,6 +32,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/floppy.h>
 #include <grub/cpu/kernel.h>
 #include <grub/cpu/tsc.h>
 
index c7fc4f45e936bcadc7e18b08c494cdd8f4139bc3..fdc7e191b20b67672bca5bc40da9e589ee288522 100644 (file)
@@ -16,7 +16,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/machine/init.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/boot.h>
 #include <grub/types.h>
index 7484650b2c6e0a9db451158bb156c5768433b64c..22996a3946410a9a43300d39e83e956558931a44 100644 (file)
@@ -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"
index cf9e1a870d3d2d5b624736a724c6de76a437fb31..2f15274b694a70b51b1f751dae6653f5cf205087 100644 (file)
@@ -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);
-}
similarity index 62%
rename from kern/i386/misc.S
rename to lib/efi/halt.c
index 7d57df9b9541f4d9a77beba52b30dd63c30c8c43..e6fd6d07d0f5fbe61e35cc0ad78ce5ed5b283495 100644 (file)
@@ -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
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/symbol.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/kernel.h>
 
-       .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);
+}
similarity index 83%
rename from kern/i386/halt.c
rename to lib/i386/halt.c
index 10805e42b325e7c876a989121bc92d471b2b03d7..74e0c73019c3e7dde4df17b07b4b615a5b4ec8e8 100644 (file)
  */
 
 #include <grub/cpu/io.h>
-#include <grub/machine/init.h>
 #include <grub/misc.h>
 
 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 ();
 }
similarity index 62%
rename from include/grub/i386/coreboot/init.h
rename to lib/ieee1275/halt.c
index e944f9cc86a6f1b0d97bcf0ad912065f5ffb4c29..9453714d330b65434d0b6bea7964c8f6fa1b6727 100644 (file)
@@ -1,6 +1,7 @@
+/*  openfw.c -- Open firmware support functions.  */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 200 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
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GRUB_INIT_I386_LINUXBIOS_HEADER
-#define GRUB_INIT_I386_LINUXBIOS_HEADER                1
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/misc.h>
 
-#include <grub/symbol.h>
-#include <grub/i386/pc/memory.h>
-#include <grub/i386/floppy.h>
+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);
+}
index 3c7fe2feec4b39437368788122d6c42eeb68ce94..f9926d1144c72955f999fad9bfc9f376859de260 100644 (file)
@@ -20,7 +20,6 @@
 #include <grub/cpu/loader.h>
 #include <grub/cpu/bsd.h>
 #include <grub/i386/cpuid.h>
-#include <grub/machine/init.h>
 #include <grub/machine/memory.h>
 #include <grub/memory.h>
 #include <grub/file.h>