Make GRUB's kernel compliant to Multiboot Specification.
* kern/i386/pc/startup.S (multiboot_header): New label.
(multiboot_entry): Likewise.
(multiboot_trampoline): Likewise.
* include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_RAW_SIZE):
Increased to 0x4A0.
* fs/xfs.c (grub_xfs_iterate_dir): Fix a syntax error. You may not
put parentheses after a question mark.
[!GRUB_UTIL] (my_mod): New variable.
* util/grub-emu.c (main): Call grub_xfs_init and grub_xfs_fini.
* 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.
* partmap/pc.c (pc_partition_map_iterate): Include the value of an
invalid magic in thre error.
* commands/search.c: New file.
* util/grub-emu.c (main): Call grub_search_init and
grub_search_fini.
* kern/rescue.c (grub_rescue_print_disks): Removed.
(grub_rescue_print_devices): New function.
(grub_rescue_cmd_ls): Use grub_device_iterate with
grub_rescue_print_devices instead of grub_disk_dev_iterate with
grub_rescue_print_disks.
* kern/partition.c (grub_partition_iterate): Return the result of
PARTMAP->ITERATE instead of GRUB_ERRNO.
* kern/device.c: Include grub/partition.h.
(grub_device_iterate): New function.
* include/grub/partition.h (grub_partition_iterate): Return int
instead of grub_err_t.
* include/grub/normal.h [GRUB_UTIL] (grub_search_init): New
prototype.
[GRUB_UTIL] (grub_search_fini): Likewise.
* include/grub/device.h (grub_device_iterate): New prototype.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added
commands/search.c.
(pkgdata_MODULES): Added search.mod.
(search_mod_SOURCES): New variable.
(search_mod_CFLAGS): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/search.c.
(pkgdata_MODULES): Added search.mod.
(search_mod_SOURCES): New variable.
(search_mod_CFLAGS): Likewise.
* commands/ls.c (grub_ls_list_disks): Renamed to ...
(grub_ls_list_devices): ... this, and use grub_device_iterate.
All callers changed.
* DISTLIST: Added commands/search.c.
* 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.
* Makefile.in (LIBLZO): New variable.
* configure.ac: Check for LZO version 2.
* util/i386/pc/grub-mkimage.c [HAVE_LZO_LZO1X_H]: Include
lzo/lzo1x.h instead of lzo1x.h.
* conf/i386-pc.rmk (grub_mkimage_LDFLAGS): Use $(LIBLZO) instead
of -llzo.
* util/i386/pc/grub-setup.c (main): Do not free PREFIX
twice. Reported by Vladimir Serbinenko <phcoder@gmail.com>.
* partmap/pc.c (pc_partition_map_probe): Restore P->DATA after
copying the data from PARTITION to P.
* kern/rescue.c (grub_rescue_cmd_rmmod): If the reference count is
negative, unload the module.
* util/i386/pc/grub-setup.c (setup): The name of the PC partition
map is "pc_partition_map" but not "pc".
(usage): Fix the description. The options are --boot-image and
--core-image but not --boot-file or --core-file.
(main): If not specified explicitly, make BOOT_FILE and CORE_FILE
based on DEFAULT_BOOT_FILE and DEFAULT_CORE_FILE with DIR or
DEFAULT_DIRECTORY.
* util/i386/pc/grub-install.in: Do not specify --boot-file or
--core-file. Specify INSTALL_DEVICE as an argument.
* util/console.c: Include config.h.
[HAVE_NCURSeS_CURSES_H]: Include ncurses/curses.h.
[HAVE_NCURSES_H]: Include ncurses.h.
[HAVE_CURSES_H]: Include curses.h.
[!A_NORMAL] (A_NORMAL): Defined as zero.
[!A_STANDOUT] (A_STANDOUT): Likewise.
* conf/i386-pc.rmk (grub_emu_LDFLAGS): Use $(LIBCURSES) instead of
-lncurses.
* conf/powerpc-ieee1275.rmk (grub_emu_LDFLAGS): Likewise.
* configure.ac: Check for curses libraries and headers.
* Makefile.in (LIBCURSES): New variable.
* genmk.rb (Script::rule): Set the executable bits.
* util/i386/pc/biosdisk.c (grub_util_biosdisk_get_grub_dev): The
name of the PC partition map is "pc_partition_map" but not "pc".
* util/i386/pc/grub-install.in (grub_probefs): New variable.
(modules): Likewise.
(usage): Added descriptions for --modules and --grub-probefs.
Handle --modules and --grub-probefs. Save the arguments in MODULES
and GRUB_PROBEFS, respectively.
Auto-detect a filesystem module against GRUBDIR. If the result is
empty and modules are not specified explicitly, abort the
installation. Add the result to MODULES.
* DISTLIST: Removed boot/powerpc/ieee1275/ieee1275.c,
disk/powerpc/ieee1275/ofdisk.c,
include/grub/powerpc/ieee1275/init.h and
term/powerpc/ieee1275/ofconsole.c.
Added disk/ieee1275/ofdisk.c, kern/ieee1275/of.c and
term/ieee1275/ofconsole.c.
* include/grub/powerpc/ieee1275/console.h: Resurrected.
* COPYING: Upgraded to the latest version. Only the address of the
FSF office has changed.
* conf/i386-pc.rmk (kernel_img_HEADERS): Reordered for
readablity.
* config.guess: Updated to the latest version from gnulib.
* config.sub: Likewise.
* install.sh: Likewise.
* mkinstalldirs: Likewise.
* include/grub/console.h: Removed. This file is arch-specific. Do
not put this in include/grub.
* include/grub/i386/pc/console.h: Resurrected.
* util/console.c: Include grub/machine/console.h instead of
grub/console.h.
* util/grub-emu.c: Likewise.
* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
* include/grub/ieee1275/ieee1275.h: ... to here. All users updated.
Move `abort', `grub_reboot', and `grub_halt' prototypes ...
* include/grub/powerpc/ieee1275/kernel.h: ... to here.
* commands/ieee1275/halt.c: Include <grub/machine/kernel.h> instead
of <grub/machine/ieee1275.h>.
* commands/ieee1275/reboot.c: Likewise.
* boot/powerpc/ieee1275/ieee1275.c: Move ...
* kern/ieee1275.c: ... to here. All users updated. Change all
parameter structs to use new type `grub_ieee1275_cell_t'.
* term/powerpc/ieee1275/ofconsole.c: Move ...
* term/ieee1275/ofconsole.c: ... to here. All users updated.
* disk/powerpc/ieee1275/ofdisk.c: Move ...
* disk/ieee1275/ofdisk.c: ... to here. All users updated.
* boot/powerpc/ieee1275/cmain.c: Change `grub_ieee1275_entry_fn' type
to return int.
* include/grub/i386/pc/console.h: Move to include/grub/console.h.
Remove unused prototypes. All users updated.
* include/grub/powerpc/ieee1275/console.h: Removed.
* include/grub/powerpc/ieee1275/ieee1275.h: Define
`grub_ieee1275_cell_t'.
* kern/powerpc/ieee1275/openfw.c: Include <grub/machine/kernel.h>.
Cast comparisons with -1 to the correct type.
* loader/powerpc/ieee1275/linux.c (kernel_entry_t): Change parameter
type to match `grub_ieee1275_entry_fn'.
* DISTLIST: Added util/i386/pc/grub-install.in.
* util/i386/pc/grub-install.in: New file.
* conf/i386-pc.rmk (sbin_SCRIPTS): New variable.
(grub_install_SOURCES): Likewise.
* genmk.rb: Added support for scripts.
(Script): New class.
(scripts): New variable.
* Makefile.in (install-local): Install sbin_SCRIPTS by
INSTALL_SCRIPT.
(uninstall): Remove sbin_SCRIPTS.
* util/i386/pc/grub-setup.c (main): If the argument is not a GRUB
device, try to get a GRUB device by
grub_util_biosdisk_get_grub_dev.
Free DEST_DEV.
* util/i386/pc/grub-mkdevicemap.c (usage): Remove a duplicated
description for --device-map.
Change the semantics of variable hooks. They now return strings
instead of error values.
* util/i386/pc/grub-setup.c: Include grub/env.h.
(setup): Use grub_device_set_root instead of grub_env_set.
* kern/rescue.c (grub_rescue_cmd_root): Use grub_env_set and
grub_env_get instead of grub_device_set_root and
grub_device_get_root, respectively.
* kern/main.c (grub_env_write_root): New function.
(grub_set_root_dev): Register grub_env_write_hook for "root". Use
grub_env_set instead of grub_device_set_root.
* kern/env.c (HASHSZ): Reduced to 13, because GRUB does not need
many variables.
(grub_env_set): Set ENV->VALUE to the result of ENV->WRITE_HOOK
rather than calling ENV->WRITE_HOOK afterwards.
(grub_env_get): Return the result of ENV->READ_HOOK rather than
passing a pointer of a pointer.
(grub_register_variable_hook): Change the types of "read_hook" and
"write_hook" to grub_env_read_hook_t and grub_env_write_hook_t,
respectively.
Allocate the default empty string on the heap, because this string
may be freed later.
* kern/device.c: Include grub/env.h.
(grub_device_set_root): Removed.
(grub_device_get_root): Likewise.
(grub_device_open): Use grub_env_get instead of
grub_device_get_root.
* include/grub/env.h (grub_env_read_hook_t): New type.
(grub_env_write_hook_t): Likewise.
(grub_env_var): Change the types of "read_hook" and "write_hook"
to grub_env_read_hook_t and grub_env_write_hook_t, respectively.
(grub_register_variable_hook): Likewise.
* include/grub/device.h (grub_device_set_root): Removed.
(grub_device_set_root): Likewise.
* fs/fat.c (grub_fat_dir): Make a copy of PATH in DIRNAME, and
make sure that DIRNAME terminates with '/', so that
grub_fat_find_dir will fail if PATH is not a directory.
* commands/ls.c (grub_ls_list_files): Remove the qualifier const
from DIRNAME.
Use the qualifier auto for print_files and print_files_long.
If FS->DIR sets GRUB_ERRNO to GRUB_ERR_BAD_FILE_TYPE, try DIRNAME
as a regular file.
Put a newline only if there is no error.
(grub_cmd_ls): Remove grub_ls_print_files, because this is not
used.
* boot/i386/pc/boot.S (boot_drive_check): New label.
* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_DRIVE_CHECK): New
macro.
* util/i386/pc/grub-setup.c (setup): Added a workaround for BIOSes
which do not pass a boot drive correctly. Copied from GRUB Legacy.
* configure.ac: Fix the test for cross-compiling.
* genmk.rb (Program): Use `$(CC)' instead of `$(BUILD_CC)'. Don't
define GRUB_UTIL anymore.
* util/powerpc/ieee1275/grub-mkimage.c (load_note): Endian fixes
so this function works on other systems than just big endian.
(load_modules): Likewise.
(add_segments): Likewise.
* 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).
* 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.
* include/grub/dl.h (grub_dl_check_header): New prototype.
(grub_arch_dl_check_header): Change return type to grub_err_t,
remove size parameter and export function. Update all callers.
* kern/dl.c (grub_dl_check_header): New function.
(grub_dl_load_core): Use `grub_dl_check_header' instead of
`grub_arch_dl_check_header'. Check ELF type. Check if sections
are inside the core.
* kern/i386/dl.c (grub_arch_dl_check_header): Remove arch
independent ELF header checks.
* kern/powerpc/dl.c (grub_arch_dl_check_header): Likewise.
* loader/i386/pc/multiboot.c (grub_rescue_cmd_multiboot): Use
`grub_dl_check_header' instead of explicit checks. Check for the
ELF type.
* loader/powerpc/ieee1275/linux.c (grub_rescue_cmd_linux): Use
`grub_dl_check_header' instead of explicit checks. Remove arch
specific ELF header checks.
Add the loopback device, a device via which files can be accessed
as devices.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `disk/loopback.c'.
(pkgdata_MODULES): Add loopback.mod.
(loopback_mod_SOURCES): New variable.
(loopback_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add
`disk/loopback.c'.
(pkgdata_MODULES): Add loopback.mod.
(loopback_mod_SOURCES): New variable.
(loopback_mod_CFLAGS): Likewise.
* disk/loopback.c: new file.
* include/grub/normal.h (grub_loop_init): New prototype.
(grub_loop_fini): New prototype.
* util/grub-emu.c (main): Initialize and de-initialize loopback
support.
* include/grub/disk.h (grub_disk_dev_id): Add
`GRUB_DISK_DEVICE_LOOPBACK_ID'.
* include/grub/mm.h (grub_mm_init_region): Change the type of the
`unsigned' arguments to `grub_size_t'.
(grub_malloc): Likewise.
(grub_realloc): Likewise.
(grub_memalign): Likewise.
* kern/i386/dl.c (grub_arch_dl_check_header): Likewise.
* kern/powerpc/dl.c (grub_arch_dl_check_header): Likewise.
* util/misc.c (grub_malloc): Likewise.
(grub_realloc): Likewise.
* kern/mm.c (get_header_from_pointer): Change the casts to
`unsigned' into a cast to `grub_size_t'.
* fs/fshelp.c (grub_fshelp_find_file): The `oldnode' should always
point to `currnode' when `currnode' is changed.
* util/grub-emu.c (main): Initialize `progname'. Reported by Nico
Schottelius <nico-linux@schottelius.org>.
* util/powerpc/ieee1275/grub-mkimage.c: Include <string.h>.
(note_path): Remove variable.
(GRUB_IEEE1275_NOTE_NAME): New macro.
(GRUB_IEEE1275_NOTE_TYPE): Likewise.
(grub_ieee1275_note_hdr): New structure.
(grub_ieee1275_note_desc): Likewise.
(grub_ieee1275_note): Likewise.
(load_note): Remove `dir' argument. All callers updated. Remove
`note_img' and `path'. Do not load a file from `note_path'.
Initialize a struct grub_ieee1275_note and write that to `out'.
Use GRUB_IEEE1275_MODULE_BASE instead of MODULE_BASE.
* genmk.rb: Handle the `Program' class in the main loop. Written
by Johan Rydberg <jrydberg@gnu.org>.
(Program): New class.
(programs): New variable.
* boot/powerpc/ieee1275/cmain.c: Include <grub/machine/ieee1275.h>
instead of "grub/machine/ieee1275.h". Include <grub/kernel.h>
instead of "grub/kernel.h". Include <grub/machine/init.h>.
(help_arch): Function removed.
* conf/powerpc-ieee1275.rmk (grubof_HEADERS): Add
`powerpc/libgcc.h' and `loader.h'.
(pkgdata_PROGRAMS): New variable.
(sbin_UTILITIES): Variable removed.
(grub_emu_SOURCES): Added kern/powerpc/cache.S.
(grubof_SOURCES): Variable re-defined so it only includes the
core functionality.
(grubof_CFLAGS): Remove `-DGRUBOF'.
(pkgdata_MODULES, fshelp_mod_SOURCES, fshelp_mod_CFLAGS,
(fat_mod_SOURCES, fat_mod_CFLAGS, ext2_mod_SOURCES)
(ext2_mod_CFLAGS, ufs_mod_SOURCES, ufs_mod_CFLAGS)
(minix_mod_SOURCES, minix_mod_CFLAGS, hfs_mod_SOURCES)
(hfs_mod_CFLAGS, jfs_mod_SOURCES, jfs_mod_CFLAGS)
(iso9660_mod_SOURCES, iso9660_mod_CFLAGS, _linux_mod_SOURCES)
(_linux_mod_CFLAGS, linux_mod_SOURCES, linux_mod_CFLAGS)
(normal_mod_SOURCES, normal_mod_CFLAGS, normal_mod_ASFLAGS)
(hello_mod_SOURCES, hello_mod_CFLAGS, boot_mod_SOURCES)
(boot_mod_CFLAGS, terminal_mod_SOURCES, terminal_mod_CFLAGS)
(ls_mod_SOURCES, ls_mod_CFLAGS, cmp_mod_SOURCES, cmp_mod_CFLAGS)
(cat_mod_SOURCES, cat_mod_CFLAGS, font_mod_SOURCES)
(font_mod_CFLAGS, amiga_mod_SOURCES, amiga_mod_CFLAGS)
(apple_mod_SOURCES, apple_mod_CFLAGS, pc_mod_SOURCES)
(pc_mod_CFLAGS): New variables.
* disk/powerpc/ieee1275/ofdisk.c: Include <grub/machine/init.h>.
(grub_ofdisk_iterate): Add a prototype for `dev_iterate'.
* include/grub/dl.h (grub_arch_dl_sync_caches): New prototype.
* include/grub/loader.h (grub_os_area_addr, grub_os_area_size):
Moved from here...
* include/grub/i386/pc/init.h (grub_os_area_addr)
(rub_os_area_size): ... to here.
* include/grub/powerpc/ieee1275/ieee1275.h
(grub_ieee1275_entry_fn): Export symbol.
* include/grub/powerpc/ieee1275/init.h: New file.
* include/grub/powerpc/libgcc.h: Likewise.
* include/grub/cache.h: Likewise.
* kern/powerpc/cache.S: Likewise. Written by Hollis Blanchard
<hollis@penguinppc.org>.
* kern/dl.c: Include <grub/cache.h>.
(grub_dl_flush_cache): New function.
(grub_dl_load_core): Call `grub_dl_flush_cache' to flush the cache
for this module.
* kern/powerpc/ieee1275/init.c (grub_ofdisk_init)
(grub_console_init): Removed prototypes.
(grub_machine_init): Don't initialize the modules anymore.
* kern/powerpc/ieee1275/openfw.c (grub_map): Make the function
static.
* include/grub/powerpc/types.h (GRUB_HOST_WORDS_LITTLEENDIAN):
Macro undef removed.
(GRUB_HOST_WORDS_BIGENDIAN): New macro.
* kern/powerpc/dl.c (grub_arch_dl_relocate_symbols): Add
relocation `R_PPC_REL32'. Return an error when the relocation is
unknown.
* Makefile.in (DATA): Add `$(pkgdata_PROGRAMS)'.
* kern/i386/pc/init.c (grub_arch_sync_caches): New function.
* util/misc.c (grub_arch_sync_caches): Likewise.
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.
Add support for the JFS filesystem.
* fs/jfs.c: New file.
* include/grub/fs.h (grub_jfs_init): New prototype.
(grub_jfs_fini): New prototype.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add fs/jfs.c.
(grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add jfs.mod.
(jfs_mod_SOURCES): New variable.
(jfs_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add fs.jfs.c.
(grubof_SOURCES): Likewise.
* util/grub-emu.c (main): Initialize and deinitialize JFS support.
* fs/fat.c (grub_fat_find_dir): Convert the filename little
endian to the host endian.
(grub_fat_utf16_to_utf8): Move function from there...
* kern/misc.c (grub_utf16_to_utf8): ...to here. Do not convert
the endianess of the source string anymore.
* include/grub/misc.h (grub_utf16_to_utf8): New prototype.
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".
Add support for UFS version 1 and 2. Add support for the minix
filesystem version 1 and 2, both the variants with 14 and 30 long
filenames.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add fs/ufs.c and
fs/minix.c.
(grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add ufs.mod and minix.mod.
(ufs_mod_SOURCES): New variable.
(ufs_mod_CFLAGS): Likewise.
(minix_mod_SOURCES): Likewise.
(minix_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add fs/ufs.c and
fs/minix.c.
(grubof_SOURCES): Likewise.
* fs/ufs.c: New file.
* fs/minix.c: New file.
* include/grub/fs.h (grub_ufs_init): New prototype.
(grub_ufs_fini): Likewise.
(grub_minix_init): Likewise.
(grub_minix_fini): Likewise.
* util/grub-emu.c (main): Initialize and deinitialize UFS and
minix fs.
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.
* 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.
* disk/i386/pc/biosdisk.c (pupa_biosdisk_open): Correctly check
for available extensions.
* include/pupa/i386/pc/time.h: New file.
* kern/disk.c: Include <pupa/machine/time.h>.
(PUPA_CACHE_TIMEOUT): New macro.
(pupa_last_time): New variable.
(pupa_disk_open): Flush the cache when there was a timeout.
(pupa_disk_close): Reset the timer.
* kern/i386/pc/startup.S (pupa_get_rtc): Renamed from
pupa_currticks.
* util/misc.c: Include <sys/times.h>
(pupa_get_rtc): New function.
* README: In the pupa-mkimage example use _chain instead of chain
and ext2 instead of fat.
* TODO: Replace ext2fs with jfs as an example. Add an item for
adding journal playback for ext2fs.
* conf/i386-pc.rmk (pupa_setup_SOURCES): Added fs/ext2.c.
(pkgdata_MODULES): Added ext2.mod.
(ext2_mod_SOURCES): New variable.
(ext2_mod_CFLAGS): Likewise.
* include/pupa/err.h (pupa_err_t): Added PUPA_ERR_SYMLINK_LOOP.
* include/pupa/misc.h (pupa_strncpy): New prototype.
(pupa_strcat): Likewise.
(pupa_strncmp): Likewise.
* kern/misc.c (pupa_strcat): Enable function.
(pupa_strncpy): New function.
(pupa_strncmp): Likewise.
* kern/disk.c (pupa_disk_read): Set pupa_errno to PUPA_ERR_NONE
when the read failed before retrying.
* util/i386/pc/biosdisk.c (_LARGEFILE_SOURCE): Removed.
(_FILE_OFFSET_BITS): Likewise.
* configure.ac: Added AC_SYS_LARGEFILE.
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.
* kern/i386/pc/lzo1x.S: New file.
* util/i386/pc/pupa-mkimage.c: Include lzo1x.h.
(compress_kernel): New variable.
(generate_image): Heavily modified to support compressing a
large part of the core image.
* util/misc.c (pupa_util_read_image): Fix a file descriptor
leak.
(pupa_util_load_image): New function.
* kern/i386/pc/startup.S: Include pupa/machine/kernel.h.
(pupa_compressed_size): New variable.
(codestart): Enable Gate A20 here.
Decompress the compressed part of the core image.
Rearrange the code to put functions and variables which are
required for initialization in the non-compressed part.
Include lzo1x.S.
* kern/i386/pc/init.c (pupa_machine_init): Don't enable Gate A20
here.
* include/pupa/util/misc.h (pupa_util_write_image): Declared.
* include/pupa/i386/pc/kernel.h
(PUPA_KERNEL_MACHINE_COMPRESSED_SIZE): New macro.
(PUPA_KERNEL_MACHINE_INSTALL_DOS_PART): Increased by 4.
(PUPA_KERNEL_MACHINE_INSTALL_BSD_PART): Likewise.
(PUPA_KERNEL_MACHINE_PREFIX): Likewise.
(PUPA_KERNEL_MACHINE_RAW_SIZE): New macro.
* conf/i386-pc.rmk (pupa_mkimage_LDFLAGS): New variable.
* genmk.rb (Image#rule): Put LDFLAGS at the end of a line.
(Utility#rule): Likewise.
* configure.ac: Check if LZO is available.
* util/i386/pc/pupa-setup.c (setup): Convert the endianness of
the length of a blocklist correctly.
* util/i386/pc/biosdisk.c (pupa_util_biosdisk_open) [__linux__]:
Use ioctl only if the OS file is a block device.
(pupa_util_biosdisk_open): Don't use ST.ST_BLOCKS, because it is
not very useful for normal files.
* kern/main.c (pupa_set_root_dev): New function.
(pupa_load_normal_mode): Likewise.
(pupa_main): Call those above.
* include/pupa/types.h (pupa_swap_bytes16): Cast the result to
pupa_uint16_t.
* include/pupa/kernel.h (pupa_enter_normal_mode): Removed.
* util/i386/pc/pupa-setup.c: Include pupa/machine/kernel.h.
(setup): Configure the installed partition information and the
dl prefix.
* loader/i386/pc/chainloader.c (my_mod): New variable.
(pupa_chainloader_unload): New function.
(pupa_rescue_cmd_chainloader): Refer itself.
(PUPA_MOD_INIT): Save its own module in MY_MOD.
* kern/i386/pc/startup.S (install_partition): Removed.
(version_string): Likewise.
(config_file): Likewise.
(pupa_install_dos_part): New variable.
(pupa_install_bsd_part): Likewise.
(pupa_prefix): Likewise.
(pupa_chainloader_real_boot): Call pupa_dl_unload_all.
* kern/i386/pc/init.c: Include pupa/machine/kernel.h, pupa/dl.h
and pupa/misc.h.
(make_install_device): New function.
(pupa_machine_init): Set the dl prefix.
* kern/rescue.c: Include pupa/rescue.h and pupa/dl.h.
(buf): Renamed to ...
(linebuf): ... this.
(pupa_rescue_cmd_prefix): New function.
(pupa_rescue_cmd_insmod): Likewise.
(pupa_rescue_cmd_rmmod): Likewise.
(pupa_rescue_cmd_lsmod): Likewise.
(pupa_enter_rescue_mode): Register new commands: prefix, insmod,
rmmod and lsmod.
* kern/mm.c (pupa_memalign): If failed even after invalidating
disk caches, unload unneeded modules and retry.
* kern/misc.c (pupa_memmove): New function.
(pupa_memcpy): Removed.
(pupa_strcpy): New function.
(pupa_itoa): Made static.
* kern/dl.c (pupa_dl_iterate): New function.
(pupa_dl_ref): Likewise.
(pupa_dl_unref): Likewise.
(pupa_dl_unload): Return if succeeded or not.
(pupa_dl_unload_unneeded): New function.
(pupa_dl_unload_all): Likewise.
(pupa_dl_init): Renamed to ...
(pupa_dl_set_prefix): ... this.
(pupa_dl_get_prefix): New function.
* include/pupa/i386/pc/kernel.h: Include pupa/types.h.
(PUPA_KERNEL_MACHINE_INSTALL_DOS_PART): New macro.
(PUPA_KERNEL_MACHINE_INSTALL_BSD_PART): Likewise.
(PUPA_KERNEL_MACHINE_PREFIX): Likewise.
(pupa_install_dos_part): Declared.
(pupa_install_bsd_part): Likewise.
(pupa_prefix): Likewise.
(pupa_boot_drive): Likewise.
* include/pupa/types.h: Fix a typo.
* include/pupa/misc.h (pupa_memcpy): New macro. Just an alias to
pupa_memmove.
(pupa_memmove): Declared.
(pupa_strcpy): Likewise.
* include/pupa/dl.h (PUPA_MOD_INIT): Change the prototype. Now
pupa_mod_init takes one argument, its own module.
(pupa_dl_unload_unneeded): Declared.
(pupa_dl_unload_all): Likewise.
(pupa_dl_ref): Likewise.
(pupa_dl_unref): Likewise.
(pupa_dl_iterate): Likewise.
(pupa_dl_init): Renamed to ...
(pupa_dl_set_prefix): ... this.
(pupa_dl_get_prefix): Declared.
* fs/fat.c [!PUPA_UTIL] (my_mod): New variable.
(pupa_fat_dir) [!PUPA_UTIL]: Prevent the fat module from being
unloaded.
(pupa_fat_open) [!PUPA_UTIL]: Refer itself if succeeded.
(pupa_fat_close) [!PUPA_UTIL]: Unrefer itself.
* configure.ac (tmp_CFLAGS): Added -Wshadow, -Wpointer-arith,
-Wmissing-prototypes, -Wundef and -Wstrict-prototypes.
* util/i386/pc/pupa-setup.c (setup): Define the internal
function find_first_partition_start at the top level, because GCC
3.0.x cannot compile internal functions in deeper scopes
correctly.
(find_root_device): Use lstat instead of stat.
Don't follow symbolic links.
Fix the path-constructing code.
* util/i386/pc/biosdisk.c [__linux__] (BLKFLSBUF): New macro.
(pupa_util_biosdisk_open) [__linux__]: Get the size of a device
by a BLKGETSIZE ioctl first, because block devices don't fill
the member st_mode of the structure stat on Linux.
[__linux__] (linux_find_partition): Use a temporary buffer
REAL_DEV for the working space. Copy it to DEV before returning.
(open_device) [__linux__]: Call ioctl with BLKFLSBUF to make the
buffer cache consistent.
(get_os_disk) [__linux__]: Use the length 5 instead of 4 for
strncmp. The previous value was merely wrong.
(pupa_util_biosdisk_get_pupa_dev): Use stat instead of lstat.
* fs/fat.c (pupa_fat_read_data): Shift 4 instead of 12 when the
FAT size is 12. The previous value was merely wrong.
* kern/main.c (pupa_main): Don't split the starting message from
newlines.
* kern/term.c (pupa_putchar): Put CR after LF instead of before
LF, because BIOS goes crazy about character attributes in this
case.
* include/i386/pc/util/biosdisk.h: New file.
* util/i386/pc/biosdisk.c: Likewise.
* util/i386/pc/pupa-setup.c: Likewise.
* Makefile.in (INCLUDE_DISTFILES): Added
include/pupa/i386/pc/util/biosdisk.h.
(UTIL_DISTFILES): Added biosdisk.c and pupa-setup.c under the
directory util/i386/pc.
(install-local): Added a rule for sbin_UTILITIES.
(uninstall): Likewise.
* util/i386/pc/pupa-mkimage.c (usage): Fix a typo in the doc.
* util/misc.c (xrealloc): New function.
(pupa_malloc): Likewise.
(pupa_free): Likewise.
(pupa_realloc): Likewise.
(pupa_stop): Likewise.
(pupa_putchar): Likewise.
* kern/disk.c (pupa_disk_read): Prevent L from underflowing.
* include/pupa/util/misc.h (xrealloc): Declared.
* include/pupa/i386/pc/boot.h (PUPA_BOOT_MACHINE_BPB_START): New
macro.
(PUPA_BOOT_MACHINE_BPBEND): Renamed to ...
(PUPA_BOOT_MACHINE_BPB_END): ... this.
* include/pupa/fs.h [PUPA_UTIL] (pupa_fat_init): Declared.
[PUPA_UTIL] (pupa_fat_fini): Likewise.
* fs/fat.c [PUPA_UTIL] (pupa_fat_init): Defined. Maybe a better
way should be implemented.
[PUPA_UTIL] (pupa_fat_fini): Likewise.
* disk/i386/pc/biosdisk.c (pupa_biosdisk_call_hook): Increase
the size of NAME for safety.
(pupa_biosdisk_iterate): Search hard disks to 0x90 instead of
0x88.
* conf/i386-pc.rmk (sbin_UTILITIES): New variable.
(pupa_setup_SOURCES): Likewise.
* genmk.rb (Utility#rule): Add $(BUILD_CFLAGS) into the rules.