move grub_halt out of kernel on most platforms

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-05-04 17:15:36 +02:00
parent 4dff488793
commit 8496927478
18 changed files with 65 additions and 65 deletions

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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 */

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

View 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>

View 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>

View 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"

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

View 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
@ -16,14 +17,16 @@
* 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);
}

View file

@ -17,11 +17,24 @@
*/
#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 ();
}

View file

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

View 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>