mirror of
https://git.proxmox.com/git/grub2
synced 2025-05-17 21:38:44 +00:00

This implements an Emacs-like menu entry editor. * normal/menu_entry.c: New file. * util/console.c (grub_ncurses_putchar): Translate some Unicode characters to ASCII. (saved_char): New variable. (grub_ncurses_checkkey): Rewritten completely. (grub_ncurses_getkey): Likewise. (grub_ncurses_init): Call raw instead of cbreak. * normal/menu.c (print_entry): Do not put a space. (init_page): Renamed to ... (grub_menu_init_page): ... this. All callers changed. (edit_menu_entry): Removed. (run_menu): Call grub_menu_entry_run instead of edit_menu_entry. * normal/cmdline.c (grub_cmdline_run): Call grub_setcursor. * kern/misc.c (grub_vprintf): Call grub_refresh. * normal/menu.c (DISP_LEFT): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_LEFT): ... this. * normal/menu.c (DISP_UP): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_UP): ... this. * normal/menu.c (DISP_RIGHT): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_RIGHT): ... this. * normal/menu.c (DISP_DOWN): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_DOWN): ... this. * normal/menu.c (DISP_HLINE): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_HLINE): ... this. * normal/menu.c (DISP_VLINE): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_VLINE): ... this. * normal/menu.c (DISP_UL): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_UL): ... this. * normal/menu.c (DISP_UR): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_UR): ... this. * normal/menu.c (DISP_LL): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_LL): ... this. * normal/menu.c (DISP_LR): Renamed to ... * include/grub/term.h (GRUB_TERM_DISP_LR): ... this. * normal/menu.c (TERM_WIDTH): Renamed to ... * include/grub/term.h (GRUB_TERM_WIDTH): ... this. * normal/menu.c (TERM_HEIGHT): Renamed to ... * include/grub/term.h (GRUB_TERM_HEIGHT): ... this. * normal/menu.c (TERM_INFO_HEIGHT): Renamed to ... * include/grub/term.h (GRUB_TERM_INFO_HEIGHT): ... this. * normal/menu.c (TERM_MARGIN): Renamed to ... * include/grub/term.h (GRUB_TERM_MARGIN): ... this. * normal/menu.c (TERM_SCROLL_WIDTH): Renamed to ... * include/grub/term.h (GRUB_TERM_SCROLL_WIDTH): ... this. * normal/menu.c (TERM_TOP_BORDER_Y): Renamed to ... * include/grub/term.h (GRUB_TERM_TOP_BORDER_Y): ... this. * normal/menu.c (TERM_LEFT_BORDER_X): Renamed to ... * include/grub/term.h (GRUB_TERM_LEFT_BORDER_X): ... this. * normal/menu.c (TERM_BORDER_WIDTH): Renamed to ... * include/grub/term.h (GRUB_TERM_BORDER_WIDTH): ... this. * normal/menu.c (TERM_MESSAGE_HEIGHT): Renamed to ... * include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): ... this. * normal/menu.c (TERM_BORDER_HEIGHT): Renamed to ... * include/grub/term.h (GRUB_TERM_BORDER_HEIGHT): ... this. * normal/menu.c (TERM_NUM_ENTRIES): Renamed to ... * include/grub/term.h (GRUB_TERM_NUM_ENTRIES): ... this. * normal/menu.c (TERM_FIRST_ENTRY_Y): Renamed to ... * include/grub/term.h (GRUB_TERM_FIRST_ENTRY_Y): ... this. * normal/menu.c (TERM_ENTRY_WIDTH): Renamed to ... * include/grub/term.h (GRUB_TERM_ENTRY_WIDTH): ... this. * normal/menu.c (TERM_CURSOR_X): Renamed to ... * include/grub/term.h (GRUB_TERM_CURSOR_X): ... this. All callers changed. * include/grub/normal.h: New prototype. * conf/i386-pc.rmk (grub_emu_SOURCES): Added normal/menu_entry.c. (normal_mod_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. (normal_mod_SOURCES): Likewise. 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.
175 lines
4.9 KiB
C
175 lines
4.9 KiB
C
/* normal.h - prototypes for the normal mode */
|
|
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2002,2003 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
|
|
* 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 this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
#ifndef GRUB_NORMAL_HEADER
|
|
#define GRUB_NORMAL_HEADER 1
|
|
|
|
#include <grub/setjmp.h>
|
|
#include <grub/symbol.h>
|
|
#include <grub/err.h>
|
|
#include <grub/arg.h>
|
|
|
|
/* The maximum size of a command-line. */
|
|
#define GRUB_MAX_CMDLINE 1600
|
|
|
|
/* Can be run in the command-line. */
|
|
#define GRUB_COMMAND_FLAG_CMDLINE 0x1
|
|
/* Can be run in the menu. */
|
|
#define GRUB_COMMAND_FLAG_MENU 0x2
|
|
/* Can be run in both interfaces. */
|
|
#define GRUB_COMMAND_FLAG_BOTH 0x3
|
|
/* Only for the command title. */
|
|
#define GRUB_COMMAND_FLAG_TITLE 0x4
|
|
/* Don't print the command on booting. */
|
|
#define GRUB_COMMAND_FLAG_NO_ECHO 0x8
|
|
/* Don't print the command on booting. */
|
|
#define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10
|
|
|
|
/* The command description. */
|
|
struct grub_command
|
|
{
|
|
/* The name. */
|
|
const char *name;
|
|
|
|
/* The callback function. */
|
|
grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args);
|
|
|
|
/* The flags. */
|
|
unsigned flags;
|
|
|
|
/* The summary of the command usage. */
|
|
const char *summary;
|
|
|
|
/* The description of the command. */
|
|
const char *description;
|
|
|
|
/* The argument parser optionlist. */
|
|
const struct grub_arg_option *options;
|
|
|
|
/* The next element. */
|
|
struct grub_command *next;
|
|
};
|
|
typedef struct grub_command *grub_command_t;
|
|
|
|
/* The command list. */
|
|
struct grub_command_list
|
|
{
|
|
/* The string of a command. */
|
|
char *command;
|
|
|
|
/* The next element. */
|
|
struct grub_command_list *next;
|
|
};
|
|
typedef struct grub_command_list *grub_command_list_t;
|
|
|
|
/* The menu entry. */
|
|
struct grub_menu_entry
|
|
{
|
|
/* The title name. */
|
|
const char *title;
|
|
|
|
/* The number of commands. */
|
|
int num;
|
|
|
|
/* The list of commands. */
|
|
grub_command_list_t command_list;
|
|
|
|
/* The next element. */
|
|
struct grub_menu_entry *next;
|
|
};
|
|
typedef struct grub_menu_entry *grub_menu_entry_t;
|
|
|
|
/* The menu. */
|
|
struct grub_menu
|
|
{
|
|
/* The default entry number. */
|
|
int default_entry;
|
|
|
|
/* The fallback entry number. */
|
|
int fallback_entry;
|
|
|
|
/* The timeout to boot the default entry automatically. */
|
|
int timeout;
|
|
|
|
/* The size of a menu. */
|
|
int size;
|
|
|
|
/* The list of menu entries. */
|
|
grub_menu_entry_t entry_list;
|
|
};
|
|
typedef struct grub_menu *grub_menu_t;
|
|
|
|
/* To exit from the normal mode. */
|
|
extern grub_jmp_buf grub_exit_env;
|
|
|
|
void grub_enter_normal_mode (const char *config);
|
|
void grub_normal_execute (const char *config, int nested);
|
|
void grub_menu_run (grub_menu_t menu, int nested);
|
|
void grub_menu_entry_run (grub_menu_entry_t entry);
|
|
void grub_cmdline_run (int nested);
|
|
int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
|
|
int echo_char, int readline);
|
|
void EXPORT_FUNC(grub_register_command) (const char *name,
|
|
grub_err_t (*func) (struct grub_arg_list *state,
|
|
int argc, char **args),
|
|
unsigned flags,
|
|
const char *summary,
|
|
const char *description,
|
|
const struct grub_arg_option *parser);
|
|
void EXPORT_FUNC(grub_unregister_command) (const char *name);
|
|
grub_command_t grub_command_find (char *cmdline);
|
|
grub_err_t grub_set_history (int newsize);
|
|
int grub_iterate_commands (int (*iterate) (grub_command_t));
|
|
int grub_command_execute (char *cmdline);
|
|
void grub_command_init (void);
|
|
void grub_normal_init_page (void);
|
|
void grub_menu_init_page (int nested, int edit);
|
|
int grub_arg_parse (grub_command_t parser, int argc, char **argv,
|
|
struct grub_arg_list *usr, char ***args, int *argnum);
|
|
void grub_arg_show_help (grub_command_t cmd);
|
|
|
|
|
|
#ifdef GRUB_UTIL
|
|
void grub_normal_init (void);
|
|
void grub_normal_fini (void);
|
|
void grub_hello_init (void);
|
|
void grub_hello_fini (void);
|
|
void grub_ls_init (void);
|
|
void grub_ls_fini (void);
|
|
void grub_cat_init (void);
|
|
void grub_cat_fini (void);
|
|
void grub_boot_init (void);
|
|
void grub_boot_fini (void);
|
|
void grub_cmp_init (void);
|
|
void grub_cmp_fini (void);
|
|
void grub_terminal_init (void);
|
|
void grub_terminal_fini (void);
|
|
void grub_loop_init (void);
|
|
void grub_loop_fini (void);
|
|
void grub_help_init (void);
|
|
void grub_help_fini (void);
|
|
void grub_halt_init (void);
|
|
void grub_halt_fini (void);
|
|
void grub_reboot_init (void);
|
|
void grub_reboot_fini (void);
|
|
#endif
|
|
|
|
#endif /* ! GRUB_NORMAL_HEADER */
|