1
/* normal.h - prototypes for the normal mode */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
#ifndef GRUB_NORMAL_HEADER
22
#define GRUB_NORMAL_HEADER 1
24
#include <grub/setjmp.h>
25
#include <grub/symbol.h>
29
/* The maximum size of a command-line. */
30
#define GRUB_MAX_CMDLINE 1600
32
/* Can be run in the command-line. */
33
#define GRUB_COMMAND_FLAG_CMDLINE 0x1
34
/* Can be run in the menu. */
35
#define GRUB_COMMAND_FLAG_MENU 0x2
36
/* Can be run in both interfaces. */
37
#define GRUB_COMMAND_FLAG_BOTH 0x3
38
/* Only for the command title. */
39
#define GRUB_COMMAND_FLAG_TITLE 0x4
40
/* Don't print the command on booting. */
41
#define GRUB_COMMAND_FLAG_NO_ECHO 0x8
42
/* Don't print the command on booting. */
43
#define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10
44
/* Not loaded yet. Used for auto-loading. */
45
#define GRUB_COMMAND_FLAG_NOT_LOADED 0x20
47
/* The type of a completion item. */
48
enum grub_completion_type
50
GRUB_COMPLETION_TYPE_COMMAND,
51
GRUB_COMPLETION_TYPE_DEVICE,
52
GRUB_COMPLETION_TYPE_PARTITION,
53
GRUB_COMPLETION_TYPE_FILE,
54
GRUB_COMPLETION_TYPE_ARGUMENT
56
typedef enum grub_completion_type grub_completion_type_t;
58
/* The command description. */
64
/* The callback function. */
65
grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args);
70
/* The summary of the command usage. */
73
/* The description of the command. */
74
const char *description;
76
/* The argument parser optionlist. */
77
const struct grub_arg_option *options;
79
/* The name of a module. Used for auto-loading. */
82
/* The next element. */
83
struct grub_command *next;
85
typedef struct grub_command *grub_command_t;
87
/* The command list. */
88
struct grub_command_list
90
/* The string of a command. */
93
/* The next element. */
94
struct grub_command_list *next;
96
typedef struct grub_command_list *grub_command_list_t;
99
struct grub_menu_entry
101
/* The title name. */
104
/* The number of commands. */
107
/* The list of commands. */
108
grub_command_list_t command_list;
110
/* The next element. */
111
struct grub_menu_entry *next;
113
typedef struct grub_menu_entry *grub_menu_entry_t;
118
/* The default entry number. */
121
/* The fallback entry number. */
124
/* The timeout to boot the default entry automatically. */
127
/* The size of a menu. */
130
/* The list of menu entries. */
131
grub_menu_entry_t entry_list;
133
typedef struct grub_menu *grub_menu_t;
135
/* A list of menus. */
136
struct grub_menu_list
139
struct grub_menu_list *next;
141
typedef struct grub_menu_list *grub_menu_list_t;
143
/* The context. A context holds some global information. */
147
grub_menu_list_t menu_list;
149
typedef struct grub_context *grub_context_t;
151
/* This is used to store the names of filesystem modules for auto-loading. */
152
struct grub_fs_module_list
155
struct grub_fs_module_list *next;
157
typedef struct grub_fs_module_list *grub_fs_module_list_t;
159
/* To exit from the normal mode. */
160
extern grub_jmp_buf grub_exit_env;
162
void grub_enter_normal_mode (const char *config);
163
void grub_normal_execute (const char *config, int nested);
164
void grub_menu_run (grub_menu_t menu, int nested);
165
void grub_menu_entry_run (grub_menu_entry_t entry);
166
void grub_cmdline_run (int nested);
167
int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
168
int echo_char, int readline);
169
grub_command_t grub_register_command (const char *name,
170
grub_err_t (*func) (struct grub_arg_list *state,
175
const char *description,
176
const struct grub_arg_option *parser);
177
void grub_unregister_command (const char *name);
178
grub_command_t grub_command_find (char *cmdline);
179
grub_err_t grub_set_history (int newsize);
180
int grub_iterate_commands (int (*iterate) (grub_command_t));
181
int grub_command_execute (char *cmdline, int interactive);
182
void grub_command_init (void);
183
void grub_normal_init_page (void);
184
void grub_menu_init_page (int nested, int edit);
185
int grub_arg_parse (grub_command_t parser, int argc, char **argv,
186
struct grub_arg_list *usr, char ***args, int *argnum);
187
void grub_arg_show_help (grub_command_t cmd);
188
grub_context_t grub_context_get (void);
189
grub_menu_t grub_context_get_current_menu (void);
190
grub_menu_t grub_context_push_menu (grub_menu_t menu);
191
void grub_context_pop_menu (void);
192
char *grub_normal_do_completion (char *buf, int *restore,
193
void (*hook) (const char *item, grub_completion_type_t type, int count));
194
grub_err_t grub_normal_print_device_info (const char *name);
197
void grub_normal_init (void);
198
void grub_normal_fini (void);
199
void grub_hello_init (void);
200
void grub_hello_fini (void);
201
void grub_ls_init (void);
202
void grub_ls_fini (void);
203
void grub_cat_init (void);
204
void grub_cat_fini (void);
205
void grub_boot_init (void);
206
void grub_boot_fini (void);
207
void grub_cmp_init (void);
208
void grub_cmp_fini (void);
209
void grub_terminal_init (void);
210
void grub_terminal_fini (void);
211
void grub_loop_init (void);
212
void grub_loop_fini (void);
213
void grub_help_init (void);
214
void grub_help_fini (void);
215
void grub_halt_init (void);
216
void grub_halt_fini (void);
217
void grub_reboot_init (void);
218
void grub_reboot_fini (void);
219
void grub_default_init (void);
220
void grub_default_fini (void);
221
void grub_timeout_init (void);
222
void grub_timeout_fini (void);
223
void grub_configfile_init (void);
224
void grub_configfile_fini (void);
225
void grub_search_init (void);
226
void grub_search_fini (void);
227
void grub_test_init (void);
228
void grub_test_fini (void);
231
#endif /* ! GRUB_NORMAL_HEADER */