2005-02-15 Yoshinori K. Okuji <okuji@enbug.org>
* include/grub/normal.h (grub_halt_init): New prototype. (grub_halt_fini): Likewise. (grub_reboot_init): Likewise. (grub_reboot_fini): Likewise. * util/grub-emu.c: Include signal.h. (main_env): New global variable. (grub_machine_init): Ignore SIGINT. Otherwise grub-emu cannot catch C-c. (grub_machine_fini): New function. (main): Call grub_halt_init and grub_reboot_init before grub_main, and grub_reboot_fini and grub_halt_fini after it. Call setjmp with MAIN_ENV to go back afterwards. Call grub_machine_fini right before return. * include/grub/util/misc.h: Include setjmp.h. (main_env): New prototype. * include/grub/kernel.h (grub_machine_fini): New prototype. * include/grub/i386/pc/biosdisk.h (grub_biosdisk_fini): Likewise. * include/grub/i386/pc/console.h (grub_console_fini): Likewise. * disk/i386/pc/biosdisk.c (grub_biosdisk_fini): New function. * kern/i386/pc/init.c (grub_machine_fini): Likewise. * term/i386/pc/console.c (grub_console_fini): Likewise. * util/i386/pc/misc.c: New file. * conf/i386-pc.rmk (grub_emu_SOURCES): Added util/i386/pc/misc.c, commands/i386/pc/halt.c and commands/i386/pc/reboot.c.
This commit is contained in:
parent
c642636f8a
commit
e6b92c8afb
15 changed files with 464 additions and 257 deletions
|
@ -1,7 +1,7 @@
|
|||
/* console.c -- Ncurses console for GRUB. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003,2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -206,3 +206,9 @@ grub_console_init (void)
|
|||
grub_term_register (&grub_ncurses_term);
|
||||
grub_term_set_current (&grub_ncurses_term);
|
||||
}
|
||||
|
||||
void
|
||||
grub_console_fini (void)
|
||||
{
|
||||
grub_ncurses_fini ();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <argp.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/setjmp.h>
|
||||
|
@ -45,6 +46,9 @@
|
|||
|
||||
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
|
||||
|
||||
/* Used for going back to the main function. */
|
||||
jmp_buf main_env;
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
|
@ -71,8 +75,15 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
|||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
signal (SIGINT, SIG_IGN);
|
||||
grub_console_init ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
{
|
||||
grub_console_fini ();
|
||||
}
|
||||
|
||||
|
||||
const char *argp_program_version = PACKAGE_STRING;
|
||||
|
@ -139,7 +150,7 @@ main (int argc, char *argv[])
|
|||
|
||||
argp_parse (&argp, argc, argv, 0, 0, &args);
|
||||
|
||||
/* More sure there is a root device. */
|
||||
/* Make sure that there is a root device. */
|
||||
if (! args.root_dev)
|
||||
{
|
||||
args.root_dev = grub_guess_root_device (args.dir ? : DEFAULT_DIRECTORY);
|
||||
|
@ -177,13 +188,18 @@ main (int argc, char *argv[])
|
|||
grub_terminal_init ();
|
||||
grub_loop_init ();
|
||||
grub_help_init ();
|
||||
grub_halt_init ();
|
||||
grub_reboot_init ();
|
||||
|
||||
/* XXX: Should normal mode be started by default? */
|
||||
grub_normal_init ();
|
||||
|
||||
/* Start GRUB! */
|
||||
grub_main ();
|
||||
if (setjmp (main_env) == 0)
|
||||
grub_main ();
|
||||
|
||||
grub_reboot_fini ();
|
||||
grub_halt_fini ();
|
||||
grub_help_fini ();
|
||||
grub_loop_fini ();
|
||||
grub_util_biosdisk_fini ();
|
||||
|
@ -201,6 +217,8 @@ main (int argc, char *argv[])
|
|||
grub_amiga_partition_map_fini ();
|
||||
grub_pc_partition_map_fini ();
|
||||
grub_apple_partition_map_fini ();
|
||||
|
||||
grub_machine_fini ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
34
util/i386/pc/misc.c
Normal file
34
util/i386/pc/misc.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <grub/util/misc.h>
|
||||
|
||||
void
|
||||
grub_reboot (void)
|
||||
{
|
||||
longjmp (main_env, 1);
|
||||
}
|
||||
|
||||
void
|
||||
grub_halt (int no_apm __attribute__ ((unused)))
|
||||
{
|
||||
grub_reboot ();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue