* include/grub/normal.h: Include <grub/script.h>.
(grub_command_list): Removed struct.
(grub_command_list_t): Removed type.
(grub_menu_entry): Remove members `num' and `command_list'. Add
members `commands' and `sourcecode'.
* include/grub/script.h: Add inclusion guards.
(grub_script_cmd_menuentry): New struct.
(grub_script_execute_menuentry): New prototype.
(grub_script_lexer_record_start): Likewise.
(grub_script_lexer_record_stop): Likewise.
* normal/execute.c (grub_script_execute_menuentry): New function.
* normal/lexer.c (record, recording, recordpos, recordlen): New
variables.
(grub_script_lexer_record_start): New function.
(grub_script_lexer_record_stop): Likewise.
(recordchar): Likewise.
(nextchar): Likewise.
(grub_script_yylex): Use `nextchar' to fetch new characters. Use
2048 as the buffer size. Add the tokens `menuentry' and `@'.
* normal/main.c: Include <grub/parser.h> and <grub/script.h>
(current_menu): New variable.
(free_menu): Mainly rewritten.
(grub_normal_menu_addentry): New function.
(read_config_file): Rewritten.
* normal/menu.c (run_menu_entry): Mainly rewritten.
* normal/menu_entry.c (make_screen): Rewritten te code to insert
the menu entry.
(run): Mainly rewritten.
* normal/parser.y (menu_entry): New variable.
(GRUB_PARSER_TOKEN_MENUENTRY): New token.
(menuentry): New rule.
(command): Add `menuentry'.
(if_statement): Allow additional returns before `fi'.
* normal/script.c (grub_script_create_cmdmenu): New function.
* include/grub/parser.h: New file.
* kern/parser.c: Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add `kern/parser.c'.
(grub_setup_SOURCES): Likewise.
(grub_probefs_SOURCES): Likewise.
(grub_emu_SOURCES): Likewise.
(kernel_img_HEADERS): Add `parser.h'.
* conf/powerpc-ieee1275.rmk (grubof_HEADERS): Add `parser.h'.
(grub_emu_SOURCES): Add `kern/parser.c'.
(grubof_SOURCES): Likewise.
* conf/sparc64-ieee1275.rmk (grubof_HEADERS): Add `parser.h'.
(grubof_SOURCES): Add `kern/parser.c'.
* include/grub/misc.h (grub_split_cmdline): Removed prototype.
* kern/misc.c (grub_split_cmdline): Removed function.
* kern/rescue.c: Include <grub/parser.h>.
(grub_enter_rescue_mode): Use `grub_parser_split_cmdline' instead
of `grub_split_cmdline'.
* normal/command.c: Include <grub/parser.h>.
(grub_command_execute): Use `grub_parser_split_cmdline' instead
of `grub_split_cmdline'.
* normal/completion.c: Include <grub/parser.h>.
(cmdline_state): New variable.
(iterate_dir): End the filename with a quote depending on the
command line state.
(get_state): new function.
(grub_normal_do_completion): Use `grub_parser_split_cmdline' to
split the arguments and determine the current argument. When the
argument string is not quoted, escape all spaces.
* include/grub/normal.h (enum grub_completion_type): Added
`GRUB_COMPLETION_TYPE_ARGUMENT'.
* normal/cmdline.c (print_completion): Handle
the `GRUB_COMPLETION_TYPE_ARGUMENT' type.
* normal/menu_entry.c (store_completion): Likewise.
* normal/completion.c (complete_arguments): New function.
(grub_normal_do_completion): Call `complete_arguments' when the
current words start with a dash.
* util/console.c (grub_ncurses_putchar): If C is greater than
0x7f, set C to a question mark.
(grub_ncurses_getcharwidth): New function.
(grub_ncurses_term): Specify grub_ncurses_getcharwidth as
getcharwidth.
* normal/menu.c (print_entry): Made aware of Unicode. First,
convert TITLE to UCS-4, and predict the cursor position by
grub_getcharwidth.
* include/grub/misc.h (grub_utf8_to_ucs4): Specify the qualifier
const to SRC.
* kern/misc.c (grub_utf16_to_utf8): Likewise.
* DISTLIST: Replace commands/i386/pc/vbe_list_modes.c and
commands/i386/pc/vbe_test.c with commands/i386/pc/vbeinfo.c and
commands/i386/pc/vbetest.c.
* video/i386/pc/vbe.c (grub_vbe_probe): If INFOBLOCK is not NULL,
call grub_vbe_get_controller_info again, because the returned
information is volatile.
(grub_vbe_set_video_mode): Mostly rewritten.
(grub_vbe_get_video_mode): Use grub_vbe_probe and use
grub_vbe_status_t correctly.
(grub_vbe_get_video_mode_info): Likewise.
(grub_vbe_set_pixel_rgb): Use a switch statement rather than
several if statements.
* commands/i386/pc/vbe_list_modes.c: Renamed to ...
* commands/i386/pc/vbeinfo.c: ... this.
* commands/i386/pc/vbe_test.c: Renamed to ...
* commands/i386/pc/vbetest.c: ... this.
* commands/i386/pc/vbeinfo.c (grub_cmd_vbe_list_modes): Renamed to
...
(grub_cmd_vbeinfo): ... this. Save video modes before
iterating. Skip a video mode, if it is not available, not enough
information is given or it is monochrome. Show the memory
model. Leave the interpretation of MODEVAR to grub_strtoul
completely.
(GRUB_MOD_INIT): Rename vbe_list_modes to vbeinfo.
(GRUB_MOD_FINI): Likewise.
* commands/i386/pc/vbetest.c (grub_cmd_vbe_test): Renamed to ...
(grub_cmd_vbetest): ... this. Don't print unnecessarily. Use
grub_err_t instead of grub_uint32_t. Don't use SPTR. Remove a
duplicated grub_env_get. Leave the interpretation of MODEVAR to
grub_strtoul completely.
(real2pm): Removed.
(GRUB_MOD_INIT): Rename vbe_test to vbetest.
(GRUB_MOD_FINI): Likewise.
* normal/misc.c: Include grub/mm.h.
* conf/i386-pc.rmk (pkgdata_MODULES): Replaced vbe_test.mod and
vbe_list_modes with vbetest.mod and vbeinfo.mod.
(vbe_list_modes_mod_SOURCES): Removed.
(vbe_list_modes_mod_CFLAGS): Likewise.
(vbe_test_mod_SOURCES): Likewise.
(vbe_test_mod_CFLAGS): Likewise.
(vbeinfo_mod_SOURCES): New variable.
(vbeinfo_mod_CFLAGS): Likewise.
(vbetest_mod_SOURCES): Likewise.
(vbetest_mod_CFLAGS): Likewise.
* normal/misc.c: New file.
* DISTLIST: Added normal/misc.c.
* partmap/amiga.c (amiga_partition_map_iterate): Add an argument
DISK to HOOK. Call HOOK with DISK.
* partmap/apple.c (apple_partition_map_iterate): Likewise.
* partmap/pc.c (pc_partition_map_iterate): Likewise.
* partmap/sun.c (sun_partition_map_iterate): Likewise.
* normal/menu_entry.c (struct screen): Added a new member
"completion_shown".
(completion_buffer): New global variable.
(make_screen): Set SCREEN->COMPLETION_SHOWN to zero.
(store_completion): New function.
(complete): Likewise.
(clear_completions): Likewise.
(grub_menu_entry_run): If SCREEN->COMPLETION_SHOWN is non-zero,
call clear_completions and reset SCREEN->COMPLETION_SHOWN. If C is
a tab, call complete.
* normal/completion.c (disk_dev): Removed.
(print_simple_completion): Likewise.
(print_partition_completion): Likewise.
(print_func): New global variable.
(add_completion): Do not take the arguments WHAT or PRINT any
longer. Added a new argument TYPE. Instead of printing directly,
call PRINT_FUNC if not NULL.
All callers changed.
(complete_device): Use a local variable DEV instead of
DISK_DEV. Do not move CURRENT_WORD to the end of a device name.
(grub_normal_do_completion): Take a new argument HOOK. Do not
initialize DISK_DEV. Initialize PRINT_FUNC to HOOK. If RET is an
empty string, return NULL instead.
All callers changed.
* normal/cmdline.c (print_completion): New function.
* kern/partition.c (grub_partition_iterate): Add an argument DISK
to HOOK.
All callers changed.
* kern/disk.c (grub_print_partinfo): Removed.
* include/grub/partition.h (struct grub_partition_map): Add a new
argument DISK into HOOK of ITERATE.
(grub_partition_iterate): Add a new argument DISK to HOOK.
* include/grub/normal.h (enum grub_completion_type): New enum.
(grub_completion_type_t): New type.
(GRUB_COMPLETION_TYPE_COMMAND): New constant.
(GRUB_COMPLETION_TYPE_DEVICE): Likewise.
(GRUB_COMPLETION_TYPE_PARTITION): Likewise.
(GRUB_COMPLETION_TYPE_FILE): Likewise.
(grub_normal_do_completion): Added a new argument HOOK.
(grub_normal_print_device_info): New prototype.
* include/grub/disk.h (grub_print_partinfo): Removed.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added normal/misc.c.
(normal_mod_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* commands/ls.c (grub_ls_list_disks): Use
grub_normal_print_device_info instead of grub_print_partinfo. Free
PNAME.
(grub_ls_list_files): Use grub_normal_print_device_info instead of
duplicating the code.
* normal/menu.c (run_menu_entry):
* normal/command.c (grub_command_execute): If INTERACTIVE is
false and GRUB_COMMAND_FLAG_NO_ECHO is not specified, print
CMDLINE. Disable the pager if INTERACTIVE is true.
All callers are changed.
* normal/main.c (grub_normal_execute): Read command.lst and fs.lst
before reading a config file.
* normal/main.c (read_config_file): Even if a command is not
found, register it if it is within an entry.
* util/grub-emu.c: Include sys/types.h and unistd.h.
(options): Added --hold.
(struct arguments): Added a new member "hold".
(parse_opt): If KEY is 'H', set ARGS->HOLD to ARG or -1 if ARG is
missing.
(main): Initialize ARGS.HOLD to zero. Wait until ARGS.HOLD is
cleared by a debugger, if it is not zero.
* include/grub/normal.h (grub_command_execute): Add an argument
INTERACTIVE.
* DISTLIST: Added normal/completion.c.
* normal/completion.c: New file.
* term/i386/pc/console.c (grub_console_getwh): New function.
(grub_console_term): Assign grub_console_getwh to getwh.
* normal/cmdline.c (grub_tab_complete): Removed. Now the same
function is defined in normal/completion.c as
grub_normal_do_completion.
(grub_cmdline_get): Use grub_normal_do_completion instead of
grub_tab_complete.
* kern/partition.c (grub_partition_map_iterate): Return 1 if HOOK
returns non-zero, otherwise return 0.
(grub_partition_iterate): First, probe the partition map. Then,
call ITERATE only for this partition map.
* kern/misc.c (grub_strncmp): Rewritten.
* kern/disk.c (grub_disk_dev_iterate): Return 1 if P->ITERATE
returns non-zero. Otherwise return 0.
* include/grub/partition.h (grub_partition_map_iterate): Return
int instead of void.
* include/grub/normal.h (grub_normal_do_completion): New prototype.
* include/grub/misc.h (grub_strncmp): Change the type of N to
grub_size_t.
* include/grub/disk.h (grub_disk_dev_iterate): Return int instead
of void.
* normal/menu.c (draw_border): Cast GRUB_TERM_BORDER_WIDTH to
unsigned explictly before comparing it with I.
* kern/main.c (grub_env_write_root): Add the attribute unused into
VAR.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added
normal/completion.c.
(normal_mod_SOURCES): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* normal/command.c (grub_iterate_commands): If ITERATE returns
non-zero, return one immediately.
* commands/ls.c (grub_ls_list_disks): Print the filesystem
information on each device, if it does not have partitions. Print
"Device" instead of "Disk", because this function is not specific
to disk devices.
* normal/main.c (grub_rescue_cmd_normal): Make the variable CONFIG
static to ensure that it is put on the memory rather than a
register.
* commands/cat.c (GRUB_MOD_INIT): Use better documentation.
(grub_cat_init): Likewise.
* loader/i386/pc/chainloader_normal.c (GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/configfile.c (GRUB_MOD_INIT): Likewise.
(grub_configfile_init): Likewise.
* font/manager.c (GRUB_MOD_INIT): Likewise.
* commands/help.c (GRUB_MOD_INIT): Likewise.
(grub_help_init): Likewise.
* normal/command.c (grub_command_init): Likewise.
* loader/i386/pc/linux_normal.c (GRUB_MOD_INIT): Likewise.
* disk/loopback.c (grub_loop_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/ls.c (grub_ls_init): Likewise.
(GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/boot.c (grub_boot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* loader/i386/pc/multiboot_normal.c (GRUB_MOD_INIT): Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/cmp.c (grub_cmp_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* normal/arg.c: Use <> instead of "" to include header files.
(SHORT_ARG_HELP): New macro.
(SHORT_ARG_USAGE): Likewise.
(help_options): Specify SHORT_ARG_HELP and SHORT_ARG_USAGE instead
of 'h' and 'u' for help and usage, respectively. Use more GNU-like
descriptions.
(find_short): Check if C is 'h' or 'u' explicitly.
(grub_arg_show_help): Use space characters instead of tabs. Treat
SHORT_ARG_HELP and SHORT_ARG_USAGE exceptionally so that -h and -u
are shown with --help and --usage only if they are not used for
the command itself.
(parse_option): Use SHORT_ARG_HELP and SHORT_ARG_USAGE instead of
'h' and 'u'.
* include/grub/arg.h (struct grub_arg_option): Add the qualifier
const into "longarg". Change the type of "shortarg" to int.
* DISTLIST: Added genfslist.sh.
* normal/main.c (fs_module_list): New variable.
(autoload_fs_module): New function.
(read_fs_list): Likewise.
(grub_normal_execute): Call read_fs_list.
* kern/fs.c (grub_fs_autoload_hook): New variable.
(grub_fs_probe): Added support for auto-loading.
* include/grub/normal.h (struct grub_fs_module_list): New struct.
(grub_fs_module_list_t): New type.
* include/grub/fs.h (grub_fs_autoload_hook_t): New type.
(grub_fs_autoload_hook): New prototype.
* genfslist.sh: New file.
* genmk.rb: Added a rule to generate a filesystem list.
Automatic loading of commands is supported.
* normal/main.c (read_command_list): New function.
(grub_normal_execute): Call read_command_list.
* normal/command.c (grub_register_command): Return zero or CMD.
Allocate CMD->NAME from the heap.
Initialize CMD->MODULE_NAME to zero.
Find the same name as well. If the same command is found and it is
a dummy command, overwrite members. If it is not a dummy command,
return zero.
(grub_unregister_command): Free Q->NAME and Q->MODULE_NAME.
(grub_command_find): If a dummy command is found, load a module
and retry to find a command only once.
* normal/cmdline.c (grub_tab_complete): Call grub_command_find to
make sure that each command is loaded.
* include/grub/normal.h (GRUB_COMMAND_FLAG_NOT_LOADED): New
macro.
(struct grub_command): Remove const from the member `name'.
Add a new member `module_name'.
(grub_register_command): Return grub_command_t.
* commands/help.c (grub_cmd_help): Call grub_command_find to make
sure that each command is loaded.
* genmk.rb (PModule::rule): Specify a module name without the
suffix ".mod" to gencmdlist.sh.
* normal/arg.c (grub_arg_show_help): Do not show the bug report
address.
* commands/help.c (grub_cmd_help): Do not print newlines after
the last command in print_command_help.
* commands/default.h: New file.
* commands/timeout.h: Likewise.
* normal/context.c: Likewise.
* util/misc.c: Do not include sys/times.h.
Include sys/time.h and grub/machine/time.h.
(grub_get_rtc): Rewritten with gettimeofday.
* util/grub-emu.c (main): Call grub_default_init and
grub_timeout_init before grub_normal_init, and call
grub_timeout_fini and grub_default_fini after grub_main.
* util/console.c (grub_ncurses_checkkey): Return the read
character or -1.
* normal/menu.c (run_menu): Set MENU->TIMEOUT to -1 once it
timeouts.
* normal/main.c (read_config_file): Push MENU. If this fails,
print an error and wait for a user input.
Print an error only if GRUB_ERRNO is not GRUB_ERR_NONE.
If a menu is empty or an error occurs, pop MENU.
(grub_normal_execute): Pop and free MENU after grub_menu_run
returns.
* kern/loader.c (grub_loader_boot): Call grub_machine_fini.
* include/grub/powerpc/ieee1275/time.h [GRUB_UTIL]: Do not
include time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/i386/pc/time.h [GRUB_UTIL]: Do not include
time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/normal.h (struct grub_menu_list): New struct.
(grub_menu_list_t): New type.
(struct grub_context): New struct.
(grub_context_t): New type.
(grub_register_command): Got rid of EXPORT_FUNC.
(grub_unregister_command): Likewise.
(grub_context_get): New prototype.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
[GRUB_UTIL] (grub_default_init): Likewise.
[GRUB_UTIL] (grub_default_fini): Likewise.
[GRUB_UTIL] (grub_timeout_init): Likewise.
[GRUB_UTIL] (grub_timeout_fini): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/default.c,
commands/timeout.c and normal/context.c.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Copied from
conf/i386-pc.rmk.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* Makefile.in (all-local): Added $(MKFILES).
* normal/menu.c (TERM_WIDTH): Macro redefined.
(TERM_TOP_BORDER_Y): Likewise.
(draw_border): Replaced while-loop by a for-loop. Make the number
of lines consistent with the number of lines displayed in
print_entries. Added a margin below the rectangle.
(print_entry): Make the entry fit in the rectangle.
(print_entries): Display the scroll arrows next to the right
border.
* normal/cmdline.c (grub_cmdline_get): Redone logic so no empty
lines are inserted and make it work like readline. Reported by
Vincent Pelletier <subdino2004@yahoo.fr>.
* fs/ext2.c (grub_ext2_open): Don't use data after freeing it.
(grub_ext2_dir): Likewise. Don't return in case of an error, jump
to fail instead. Reported by Vincent Pelletier
<subdino2004@yahoo.fr>.
* fs/fshelp.c (grub_fshelp_find_file): Don't free `oldnode' when
it is not allocated. Reported by Vincent Pelletier
<subdino2004@yahoo.fr>.
* normal/cmdline.c (grub_tab_complete): Add a blank line to the
output so the output looks better.
Modulize the partition map support and add support for the amiga
partition map.
* commands/ls.c: Include <grub/partition.h> instead of
<grub/machine/partition.h>.
* kern/disk.c: Likewise.
* kern/rescue.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* normal/cmdline.c: Likewise.
* kern/powerpc/ieee1275/init.c: Likewise.
(grub_machine_init): Call `grub_pc_partition_map_init',
`grub_amiga_partition_map_init' and
`grub_apple_partition_map_init'.
* conf/i386-pc.rmk (kernel_img_SOURCES): Remove
`disk/i386/pc/partition.c'. Add `kern/partition.c'.
(kernel_img_HEADERS): Remove `machine/partition.h'. Add
`partition.h' and `pc_partition.h'.
(grub_setup_SOURCES): Remove
`disk/i386/pc/partition.c'. Add `kern/partition.c',
`partmap/amiga.c', `partmap/apple.c' and `partmap/pc.c'.
(grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add `amiga.mod', `apple.mod' and `pc.mod'.
(amiga_mod_SOURCES, amiga_mod_CFLAGS, apple_mod_SOURCES)
(apple_mod_CFLAGS, pc_mod_SOURCES, pc_mod_CFLAGS): New variables.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Remove
`disk/powerpc/ieee1275/partition.c'. Add `kern/partition.c',
`partmap/amiga.c', `partmap/apple.c' and `partmap/pc.c'.
(grubof_SOURCES): Likewise.
* disk/i386/pc/partition.c: File removed.
* disk/powerpc/ieee1275/partition.c: Likewise.
* include/grub/powerpc/ieee1275/partition.h: Likewise.
* include/grub/i386/pc/partition.h: Likewise.
* kern/partition.c: New file.
* partmap/amiga.c: Likewise.
* partmap/apple.c: Likewise.
* partmap/pc.c: Likewise.
* include/grub/partition.h: Likewise..
* include/grub/pc_partition.h: Likewise.
* util/grub-emu.c: Include <grub/partition.h> instead of
<grub/machine/partition.h>.
(main): Call `grub_pc_partition_map_init',
`grub_amiga_partition_map_init' and
`grub_apple_partition_map_init' and deinitialize afterwards.
* util/i386/pc/biosdisk.c: Include `#include
<grub/partition.h>' and `include <grub/pc_partition.h>' instead of
`<grub/machine/partition.h>'.
* util/i386/pc/grub-setup.c: Likewise.
* util/i386/pc/biosdisk.c: Likewise.
(grub_util_biosdisk_get_grub_dev): Only access the PC specific
partition information in case of a PC partition.
* util/i386/pc/grub-setup.c: Include `#include
<grub/partition.h>' and `include <grub/pc_partition.h>' instead of
`<grub/machine/partition.h>'.
(setup): Only access the PC specific partition information in case
of a PC partition.
Make the source code of the menu interface more readable.
* normal/menu.c: Include grub/mm.h.
(TERM_WIDTH): New macro.
(TERM_HEIGHT): Likewise.
(TERM_INFO_HEIGHT): Likewise.
(TERM_MARGIN): Likewise.
(TERM_SCROLL_WIDTH): Likewise.
(TERM_TOP_BORDER_Y): Likewise.
(TERM_LEFT_BORDER_X): Likewise.
(TERM_BORDER_WIDTH): Likewise.
(TERM_MESSAGE_HEIGHT): Likewise.
(TERM_BORDER_HEIGHT): Likewise.
(TERM_NUM_ENTRIES): Likewise.
(TERM_FIRST_ENTRY_Y): Likewise.
(TERM_ENTRY_WIDTH): Likewise.
(TERM_CURSOR_X): Likewise.
(draw_border): Use macros instead of magic numbers.
(print_entry): Likewise.
(print_entries): Likewise.
(run_menu): Likewise. Also, handle the key 'e'.
(run_menu_entry): Ignore empty command lines.
(print_message): Added a new argument EDIT. If EDIT is true,
print a different message.
(init_page): Likewise.
(edit_menu_entry): New function. Not implemented yet.
Add `linux.mod' and `multiboot.mod' so linux and multiboot kernels
can be loaded from normal mode.
* conf/i386-pc.rmk (pkgdata_MODULES): Add `linux.mod' and
`multiboot.mod'.
(linux_mod_SOURCES, linux_mod_CFLAGS, multiboot_mod_SOURCES)
(multiboot_mod_CFLAGS): New variables.
* loader/i386/pc/linux_normal.c: New file.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Don't use the
attribute `unused'.
* fs/ext2.c (grub_ext2_iterate_dir): Fix typos in inode type. Use
`fdiro' to read the mode information from instead of `diro'.
* fs/fshelp.c (grub_fshelp_find_file): Set type to foundtype after
looking up a symlink.
* include/grub/normal.h (GRUB_COMMAND_FLAG_NO_ARG_PARSE): New
macro.
* normal/command.c (grub_command_execute): Don't parse the
arguments when `GRUB_COMMAND_FLAG_NO_ARG_PARSE' is set in the
flags of the command.
* normal/menu.c (grub_menu_run): Fix typo.
* normal/menu.c: Include grub/loader.h and grub/machine/time.h.
(print_message): Add a missing newline.
(run_menu): Added timeout support.
(run_menu_entry): New local function.
(grub_menu_run): Added support for booting.
* kern/loader.c (grub_loader_is_loaded): New function.
* include/grub/powerpc/ieee1275/time.h: Include grub/symbol.h.
(grub_get_rtc): Exported.
* include/grub/i386/pc/time.h: Include grub/symbol.h.
(grub_get_rtc): Exported.
* include/grub/normal.h (struct grub_command_list): Remove
constant from the member `command'.
* include/grub/loader.h (grub_loader_is_loaded): Declared.
* include/grub/err.h (GRUB_ERR_INVALID_COMMAND): New constant.
* conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/time.h.
Each disk device has its own id now. This is useful to make use
of multiple disk devices.
* include/grub/disk.h (grub_disk_dev_id): New enum.
(GRUB_DISK_DEVICE_BIOSDISK_ID): New constant.
(GRUB_DISK_DEVICE_OFDISK_ID): Likewise.
* disk/i386/pc/biosdisk.c (grub_biosdisk_dev): Specify
GRUB_DISK_DEVICE_BIOSDISK_ID as an id.
* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_dev): Specify
GRUB_DISK_DEVICE_OFDISK_ID as an id.
* util/i386/pc/biosdisk.c (grub_util_biosdisk_dev): Specify
GRUB_DISK_DEVICE_BIOSDISK_ID as an id.
* include/grub/disk.h (struct grub_disk_dev): Added a new member
"id" which is used by the cache manager.
* normal/main.c (grub_normal_init_page): Use "GNU GRUB" instead
of just "GRUB".
* normal/arg.c (grub_arg_parse): Correct error handling after
reallocating the argumentlist (check if `argl' is not null instead
of checking if `args' is not null).
* kern/mm.c (grub_realloc): Return the same pointer when using the
same region, instead of returning the header address.
All symbols prefixed with PUPA_ and pupa_ are renamed to GRUB_
and grub_, respectively. Because the conversion is trivial and
mechanical, I omit the details here. Please refer to the CVS
if you need more information.
Add support for the newworld apple macintosh (PPC). This has been
tested on the powerbook 2000 only. It only adds support for
generic ieee1275 functions, console and disk support. This should
be easy to port to other architectures with support for Open
Firmware.
* configure.ac: Accept the powerpc as host_cpu. In the case of
the powerpc cpu set the host_vendor to ieee1275. Make sure the i386
specific tests are only executed while building for the i386.
Inverse test for crosscompile.
* genmk.rb (Utility): Allow assembler files.
* normal/cmdline.c (pupa_tab_complete): Reset pupa_errno.
* conf/powerpc-ieee1275.rmk: New file.
* disk/powerpc/ieee1275/ofdisk.c: Likewise.
* disk/powerpc/ieee1275/partition.c: Likewise.
* include/pupa/powerpc/ieee1275/biosdisk.h: Likewise.
* include/pupa/powerpc/ieee1275/console.h: Likewise.
* include/pupa/powerpc/ieee1275/partition.h: Likewise.
* include/pupa/powerpc/ieee1275/time.h: Likewise.
* include/pupa/powerpc/ieee1275/util/biosdisk.h: Likewise.
* include/pupa/powerpc/ieee1275/multiboot.h: Likewise.
* include/pupa/powerpc/ieee1275/loader.h
* include/pupa/powerpc/setjmp.h: Likewise.
* include/pupa/powerpc/types.h: Likewise.
* kern/powerpc/ieee1275/init.c: Likewise.
* kern/powerpc/ieee1275/openfw.c: Likewise.
* term/powerpc/ieee1275/ofconsole.c: Likewise.
These files were written by Johan Rydberg
(jrydberg@night.trouble.net) and I only modified them slightly.
* boot/powerpc/ieee1275/cmain.c: New file.
* boot/powerpc/ieee1275/crt0.S: Likewise.
* boot/powerpc/ieee1275/ieee1275.c: Likewise.
* include/pupa/powerpc/ieee1275/ieee1275.h: Likewise.
* commands/boot.c: New file.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/ls.c: Likewise.
* commands/terminal.c: Likewise.
* normal/command.c: Include <pupa/env.h> and <pupa/dl.h>.
(pupa_register_command): Changed interface to match the new
argument parser.
(pupa_command_execute): Changed (almost rewritten) so it uses
pupa_split_command. Added support for setting variables using the
syntax `foo=bar'.
(rescue_command): Changed to work with the new argument parser.
(terminal_command): Moved from here to commands/terminal.c.
(set_command): New function.
(unset_command): New function.
(insmod_command): New function.
(rmmod_command): New function.
(lsmod_command): New function.
(pupa_command_init): Don't initialize the command terminal
anymore. Initialize the commands set, unset, insmod, rmmod and
lsmod.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/env.c.
(kernel_img_HEADERS): Add arg.h and env.h.
(pupa_mkimage_LDFLAGS): Add kern/env.c.
(pupa_emu_SOURCES): Add kern/env.c, commands/ls.c,
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c,
normal/arg.c.
(pkgdata_MODULES): Add ls.mod, boot.mod, cmp.mod, cat.mod and
terminal.mod.
(normal_mod_SOURCES): Add normal/arg.c and normal/arg.c.
(boot_mod_SOURCES): New variable.
(terminal_mod_SOURCES): Likewise.
(ls_mod_SOURCES): Likewise.
(cmp_mod_SOURCES): Likewise.
(cat_mod_SOURCES): Likewise.
* normal/arg.c: New file.
* kern/env.c: Likewise.
* include/pupa/arg.h: Likewise.
* include/pupa/env.h: Likewise.
* font/manager.c (font_command): Changed to match argument parsing
interface changes.
(PUPA_MOD_INIT): Likewise.
* hello/hello.c (pupa_cmd_hello): Likewise.
(PUPA_MOD_INIT): Likewise.
* include/pupa/disk.h: Include <pupa/device.h>.
(pupa_print_partinfo): New prototype.
* include/pupa/dl.h (pupa_dl_set_prefix): Prototype removed.
(pupa_dl_get_prefix): Likewise.
* include/pupa/misc.h: Include <pupa/err.h>.
(pupa_isgraph): New prototype.
(pupa_isdigit): Likewise.
(pupa_split_cmdline): Likewise.
* include/pupa/normal.h: Include <pupa/arg.h>.
(pupa_command): Changed the prototype of the member `func' to
match the argument parsing interface. Added member `options'.
(pupa_register_command): Updated to match function.
(pupa_arg_parse): New prototype.
(pupa_hello_init) [PUPA_UTIL]: New prototype.
(pupa_hello_fini) [PUPA_UTIL]: Likewise.
(pupa_ls_init) [PUPA_UTIL]: Likewise.
(pupa_ls_fini) [PUPA_UTIL]: Likewise.
(pupa_cat_init) [PUPA_UTIL]: Likewise.
(pupa_cat_fini) [PUPA_UTIL]: Likewise.
(pupa_boot_init) [PUPA_UTIL]: Likewise.
(pupa_boot_fini) [PUPA_UTIL]: Likewise.
(pupa_cmp_init) [PUPA_UTIL]: Likewise.
(pupa_cmp_fini) [PUPA_UTIL]: Likewise.
(pupa_terminal_init) [PUPA_UTIL]: Likewise.
(pupa_terminal_fini) [PUPA_UTIL]: Likewise.
* kern/disk.c: Include <pupa/file.h>.
(pupa_print_partinfo): New function.
* kern/dl.c: Include <pupa/env.h>.
(pupa_dl_dir): Variable removed.
(pupa_dl_load): Use the environment variable `prefix' instead of
the variable pupa_dl_dir.
(pupa_dl_set_prefix): Function removed.
(pupa_dl_get_prefix): Likewise.
* kern/i386/pc/init.c: Include <pupa/env.h>.
(pupa_machine_init): Use the environment variable `prefix' instead of
using pupa_dl_set_prefix to set the prefix.
* kern/main.c: Include <pupa/env.h>.
(pupa_set_root_dev): Use the environment variable `prefix' instead of
using pupa_dl_get_prefix to get the prefix.
* kern/misc.c: Include <pupa/env.h>.
(pupa_isdigit): New function.
(pupa_isgraph): Likewise.
(pupa_ftoa): Likewise.
(pupa_vsprintf): Added support for printing values of the type
`double'. Make it possible to format variable output when using
formatting like `%1.2%f'.
(pupa_split_cmdline): New function.
* kern/rescue.c: Include <pupa/env.h>.
(next_word): Removed function.
(pupa_rescue_cmd_prefix): Likewise.
(pupa_rescue_cmd_set): New function.
(pupa_rescue_cmd_unset): New function.
(pupa_enter_rescue_mode): Use the `pupa_split_cmdline' function to
split the command line instead of splitting it here. Added
support for setting variables using the syntax `foo=bar'. Don't
initialize the prefix command anymore. Initialized the set and
unset commands.
* normal/cmdline.c: Include <pupa/env.h>.
(pupa_tab_complete): Added prototypes for print_simple_completion,
print_partition_completion, add_completion, iterate_commands,
iterate_dev, iterate_part and iterate_dir. Moved code to print
partition information from here to kern/disk.c.
(pupa_cmdline_run): Don't check if the funtion exists anymore.
* normal/main.c: Include <pupa/env.h>.
(pupa_rescue_cmd_normal): Use the environment variable `prefix'
instead of using pupa_dl_get_prefix to get the prefix.
* term/i386/pc/vga.c: Include <pupa/arg.h>.
(check_vga_mem): Cast pointers to `void *' to silence a gcc
warning.
(pupa_vga_putchar) [! DEBUG_VGA]: Removed for this case.
(pupa_vga_setcolor): Declare unused variables with `__attribute__
((unused))' to silence a gcc warning.
(pupa_vga_setcolor): Likewise.
(debug_command): Changed to match argument parsing
interface changes.
* util/pupa-emu.c: Include <pupa/env.h>.
(options): Added 0's for unused fields to silence a gcc warning.
(argp): Likewise.
(main): Use the environment variable `prefix' instead of using
pupa_dl_set_prefix to set the prefix. Initialize the commands ls,
boot, cmp, cat and terminal. Finish the commands boot, cmp, cat
and terminal.
* util/i386/pc/getroot.c: Include <pupa/i386/pc/util/biosdisk.h>.
* util/misc.c: Include <malloc.h>.
(pupa_malloc): Rewritten so errors are correctly reported.
(pupa_realloc): Likewise.
(pupa_memalign): Likewise.
(pupa_mm_init_region): Declare unused variables with
`__attribute__ ((unused))' to silence a gcc warning.
* normal/i386/setjmp.S: Remove tab at the end of the file to
silence a gcc warning.
* loader/i386/pc/linux.c (pupa_rescue_cmd_initrd): Declare unused
variables with `__attribute__ ((unused))' to silence a gcc
warning.
* loader/i386/pc/multiboot.c (pupa_multiboot_unload): Make the
local variable i unsigned to silence a gcc warning.
* kern/term.c: Include <pupa/misc.h>.
(pupa_more_lines): New variable.
(pupa_more): Likewise.
(pupa_putcode): When the pager is active pause at the end of every
screen.
(pupa_set_more): New function.
* include/pupa/term.h (pupa_set_more): New prototype.
I forgot to check in these changes for a long time. This adds
incomplete support for VGA console, and this is still very
buggy. Also, a lot of consideration is required for I18N,
UNICODE, and VGA font issues. Therefore, assume that this is
such that "better than nothing".
* font/manager.c: New file.
* include/pupa/font.h: Likewise.
* include/pupa/i386/pc/vga.h: Likewise.
* term/i386/pc/vga.c: Likewise.
* util/unifont2pff.rb: Likewise.
* conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h.
(pkgdata_MODULES): Added vga.mod and font.mod.
(vga_mod_SOURCES): New variables.
(vga_mod_CFLAGS): Likewise.
(font_mod_SOURCES): Likewise.
(font_mod_CFLAGS): Likewise.
* include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant.
* include/pupa/term.h: Include pupa/err.h.
(struct pupa_term): Added init and fini.
Changed the argument of putchar to pupa_uint32_t.
* include/pupa/i386/pc/console.h: Include pupa/symbol.h.
(pupa_console_real_putchar): New prototype.
(pupa_console_putchar): Removed.
(pupa_console_checkkey): Exported.
(pupa_console_getkey): Likewise.
* kern/misc.c (pupa_vsprintf): Add support for UNICODE
characters.
* kern/term.c (pupa_term_set_current): Rewritten.
(pupa_putchar): Likewise.
(pupa_putcode): New function.
* kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ...
(pupa_console_real_putchar): ... this.
(pupa_vga_set_mode): New function.
(pupa_vga_get_font): Likewise.
* normal/command.c: Include pupa/term.h.
(terminal_command): New function.
(pupa_command_init): Register the command "terminal".
* normal/menu.c (DISP_LEFT): Changed to a UNICODE value.
(DISP_UP): Likewise.
(DISP_RIGHT): Likewise.
(DISP_DOWN): Likewise.
(DISP_HLINE): Likewise.
(DISP_VLINE): Likewise.
(DISP_UL): Likewise.
(DISP_UR): Likewise.
(DISP_LL): Likewise.
(DISP_LR): Likewise.
* term/i386/pc/console.c (pupa_console_putchar): New function.
* include/pupa/normal.h: New file.
* include/pupa/setjmp.h: Likewise.
* include/pupa/i386/setjmp.h: Likewise.
* normal/cmdline.c: Likewise.
* normal/command.c: Likewise.
* normal/main.c: Likewise.
* normal/menu.c: Likewise.
* normal/i386/setjmp.S: Likewise.
* loader/i386/pc/linux.c (pupa_rescue_cmd_linux): Made global.
(pupa_rescue_cmd_initrd): Likewise.
* loader/i386/pc/chainloader.c (pupa_rescue_cmd_chainloader):
Likewise.
* kern/i386/pc/startup.S (translation_table): New variable.
(translate_keycode): New function.
(pupa_console_getkey): Call translate_keycode.
* kern/rescue.c (attempt_normal_mode): New function.
(pupa_enter_rescue_mode): Attempt to execute the normal mode. If
it failed, print a message.
* kern/mm.c (pupa_real_malloc): Print more information when a
free magic is broken.
(pupa_free): If the first free header is not free actually, set
it to P.
* kern/main.c (pupa_load_normal_mode): Just load the module
"normal".
(pupa_main): Don't print the message
"Entering into rescue mode..." here.
* include/pupa/i386/pc/loader.h (pupa_rescue_cmd_initrd):
Declared.
(pupa_rescue_cmd_initrd): Likewise.
(pupa_rescue_cmd_initrd): Likewise.
* include/pupa/symbol.h (FUNCTION): Specify the type.
(VARIABLE): Likewise.
* include/pupa/err.h (pupa_err_t): Added
PUPA_ERR_UNKNOWN_COMMAND.
* include/pupa/dl.h (pupa_dl_set_prefix): Exported.
(pupa_dl_get_prefix): Likewise.
* conf/i386-pc.rmk (pkgdata_MODULES): Added normal.mod.
Added _chain.mod and _linux.mod instead of chain.mod and
linux.mod.
(chain_mod_SOURCES): Renamed to ...
(_chain_mod_SOURCES): ... this.
(chain_mod_CFLAGS): Renamed to ...
(_chain_mod_CFLAGS): ... this.
(linux_mod_SOURCES): Renamed to ...
(_linux_mod_SOURCES): ... this.
(linux_mod_CFLAGS): Renamed to ...
(_linux_mod_CFLAGS): ... this.
(normal_mod_SOURCES): New variable.
(normal_mod_CFLAGS): Likewise.
(normal_mod_ASFLAGS): Likewise.
2003-01-18 Yoshinori K. Okuji <okuji@enbug.org>
* kern/rescue.c (pupa_rescue_cmd_rmmod): Call pupa_dl_unload, if
possible.
* kern/dl.c (pupa_dl_ref): Refer dependending modules
recursively.
(pupa_dl_unref): Unrefer depending modules recursively.
Don't call pupa_dl_unload implicitly, because PUPA can crash if
a module is unloaded before one depending on that module is
unloaded.
(pupa_dl_unload): Unload depending modules explicitly,
if possible.