2009-12-02 Robert Millan <rmh.grub@aybabtu.com>

Use the same reboot approach on i386 coreboot and qemu as we do on
        BIOS.

        * conf/i386-coreboot.rmk (kernel_img_HEADERS): Add `cpu/reboot.h'.
        (reboot_mod_SOURCES): Remove `kern/i386/reboot.c'.
        * kern/i386/reboot.c: Remove.
        * include/grub/i386/reboot.h (grub_reboot): Export function.
        * kern/i386/pc/startup.S (grub_reboot): Move from here ...
        * kern/i386/realmode.S (grub_reboot): ... to here.  Jump to
        0xf000:0xfff0 instead of 0xffff:0x0000.
        [!GRUB_MACHINE_PCBIOS] (prot_to_real): Do not restore interrupts.
        * kern/i386/qemu/startup.S: Include `"../realmode.S"'.
This commit is contained in:
Robert Millan 2009-12-02 22:48:02 +00:00
parent ef34cbd4fa
commit 5239348f18
7 changed files with 38 additions and 49 deletions

View file

@ -1,3 +1,18 @@
2009-12-02 Robert Millan <rmh.grub@aybabtu.com>
Use the same reboot approach on i386 coreboot and qemu as we do on
BIOS.
* conf/i386-coreboot.rmk (kernel_img_HEADERS): Add `cpu/reboot.h'.
(reboot_mod_SOURCES): Remove `kern/i386/reboot.c'.
* kern/i386/reboot.c: Remove.
* include/grub/i386/reboot.h (grub_reboot): Export function.
* kern/i386/pc/startup.S (grub_reboot): Move from here ...
* kern/i386/realmode.S (grub_reboot): ... to here. Jump to
0xf000:0xfff0 instead of 0xffff:0x0000.
[!GRUB_MACHINE_PCBIOS] (prot_to_real): Do not restore interrupts.
* kern/i386/qemu/startup.S: Include `"../realmode.S"'.
2009-11-30 Robert Millan <rmh.grub@aybabtu.com> 2009-11-30 Robert Millan <rmh.grub@aybabtu.com>
Fix $srcdir != $objdir build. Fix $srcdir != $objdir build.

View file

@ -33,6 +33,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
cpu/reboot.h \
machine/boot.h machine/console.h machine/init.h \ machine/boot.h machine/console.h machine/init.h \
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h machine/memory.h machine/loader.h list.h handler.h command.h i18n.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_CFLAGS = $(COMMON_CFLAGS)
@ -76,6 +77,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
cpu/reboot.h \
machine/boot.h machine/console.h machine/init.h \ machine/boot.h machine/console.h machine/init.h \
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h machine/memory.h machine/loader.h list.h handler.h command.h i18n.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR) kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
@ -124,7 +126,7 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For reboot.mod. # For reboot.mod.
reboot_mod_SOURCES = commands/reboot.c kern/i386/reboot.c reboot_mod_SOURCES = commands/reboot.c
reboot_mod_CFLAGS = $(COMMON_CFLAGS) reboot_mod_CFLAGS = $(COMMON_CFLAGS)
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS) reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)

View file

@ -16,4 +16,4 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/ */
extern void grub_reboot (void); extern void EXPORT_FUNC(grub_reboot) (void);

View file

@ -484,21 +484,6 @@ FUNCTION(grub_exit)
jmp cold_reboot jmp cold_reboot
.code32 .code32
/*
* grub_reboot()
*
* Reboot the system. At the moment, rely on BIOS.
*/
FUNCTION(grub_reboot)
call prot_to_real
.code16
cold_reboot:
/* cold boot */
movw $0x0472, %di
movw %ax, (%di)
ljmp $0xFFFF, $0x0000
.code32
/* /*
* grub_halt(int no_apm) * grub_halt(int no_apm)
* *

View file

@ -95,3 +95,5 @@ codestart:
/* This should never happen. */ /* This should never happen. */
jmp EXT_C(grub_stop) jmp EXT_C(grub_stop)
#include "../realmode.S"

View file

@ -215,10 +215,27 @@ realcseg:
movw %ax, %gs movw %ax, %gs
movw %ax, %ss movw %ax, %ss
#ifdef GRUB_MACHINE_PCBIOS
/* restore interrupts */ /* restore interrupts */
sti sti
#endif
/* return on new stack! */ /* return on new stack! */
DATA32 ret DATA32 ret
.code32 .code32
/*
* grub_reboot()
*
* Reboot the system. At the moment, rely on BIOS.
*/
FUNCTION(grub_reboot)
call prot_to_real
.code16
cold_reboot:
/* set 0x472 to 0x0000 for cold boot (0x1234 for warm boot) */
movw $0x0472, %di
movw %ax, (%di)
ljmp $0xf000, $0xfff0
.code32

View file

@ -1,32 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/cpu/io.h>
#include <grub/cpu/at_keyboard.h>
#include <grub/cpu/reboot.h>
#include <grub/misc.h>
void
grub_reboot (void)
{
/* Use the keyboard controller to reboot. That's what keyboards were
designed for, isn't it? */
grub_outb (KEYBOARD_COMMAND_REBOOT, KEYBOARD_REG_STATUS);
grub_printf ("GRUB doesn't know how to reboot this machine yet!\n");
}