2008-02-19 16:40:45 +00:00
|
|
|
/*
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
2010-01-14 21:08:31 +00:00
|
|
|
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
|
2008-02-19 16:40:45 +00:00
|
|
|
*
|
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <grub/loader.h>
|
2010-01-13 20:00:46 +00:00
|
|
|
#include <grub/i386/bsd.h>
|
2009-10-09 17:57:02 +00:00
|
|
|
#include <grub/i386/cpuid.h>
|
2009-05-03 09:03:31 +00:00
|
|
|
#include <grub/memory.h>
|
2010-09-04 15:10:10 +00:00
|
|
|
#include <grub/i386/memory.h>
|
2008-02-19 16:40:45 +00:00
|
|
|
#include <grub/file.h>
|
|
|
|
#include <grub/err.h>
|
|
|
|
#include <grub/dl.h>
|
|
|
|
#include <grub/mm.h>
|
|
|
|
#include <grub/elfload.h>
|
|
|
|
#include <grub/env.h>
|
|
|
|
#include <grub/misc.h>
|
|
|
|
#include <grub/aout.h>
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
#include <grub/command.h>
|
2009-08-23 11:46:25 +00:00
|
|
|
#include <grub/extcmd.h>
|
2010-01-03 18:24:22 +00:00
|
|
|
#include <grub/i18n.h>
|
2010-08-25 01:25:18 +00:00
|
|
|
#include <grub/ns8250.h>
|
2011-09-28 21:45:57 +00:00
|
|
|
#include <grub/bsdlabel.h>
|
|
|
|
#include <grub/crypto.h>
|
2009-08-23 11:46:25 +00:00
|
|
|
|
2011-04-11 21:01:51 +00:00
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
|
2010-01-14 21:08:31 +00:00
|
|
|
#include <grub/video.h>
|
2009-06-11 16:13:39 +00:00
|
|
|
#ifdef GRUB_MACHINE_PCBIOS
|
|
|
|
#include <grub/machine/biosnum.h>
|
2009-08-25 23:18:48 +00:00
|
|
|
#endif
|
2010-01-13 20:04:19 +00:00
|
|
|
#ifdef GRUB_MACHINE_EFI
|
|
|
|
#include <grub/efi/efi.h>
|
2010-01-15 12:40:37 +00:00
|
|
|
#define NETBSD_DEFAULT_VIDEO_MODE "800x600"
|
|
|
|
#else
|
|
|
|
#define NETBSD_DEFAULT_VIDEO_MODE "text"
|
|
|
|
#include <grub/i386/pc/vbe.h>
|
2010-01-13 20:04:19 +00:00
|
|
|
#endif
|
2010-01-15 12:40:37 +00:00
|
|
|
#include <grub/video.h>
|
|
|
|
|
2009-06-11 16:13:39 +00:00
|
|
|
#include <grub/disk.h>
|
|
|
|
#include <grub/device.h>
|
|
|
|
#include <grub/partition.h>
|
2010-01-11 21:54:40 +00:00
|
|
|
#include <grub/relocator.h>
|
2010-01-13 20:00:46 +00:00
|
|
|
#include <grub/i386/relocator.h>
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
#define ALIGN_DWORD(a) ALIGN_UP (a, 4)
|
2009-05-03 09:03:31 +00:00
|
|
|
#define ALIGN_QWORD(a) ALIGN_UP (a, 8)
|
|
|
|
#define ALIGN_VAR(a) ((is_64bit) ? (ALIGN_QWORD(a)) : (ALIGN_DWORD(a)))
|
2008-02-19 16:40:45 +00:00
|
|
|
#define ALIGN_PAGE(a) ALIGN_UP (a, 4096)
|
|
|
|
|
2009-08-10 15:42:39 +00:00
|
|
|
static int kernel_type = KERNEL_TYPE_NONE;
|
2008-02-19 16:40:45 +00:00
|
|
|
static grub_dl_t my_mod;
|
2009-05-03 09:03:31 +00:00
|
|
|
static grub_addr_t entry, entry_hi, kern_start, kern_end;
|
2010-01-11 21:54:40 +00:00
|
|
|
static void *kern_chunk_src;
|
2008-02-19 16:40:45 +00:00
|
|
|
static grub_uint32_t bootflags;
|
2009-05-03 09:03:31 +00:00
|
|
|
static int is_elf_kernel, is_64bit;
|
2009-10-16 20:21:12 +00:00
|
|
|
static grub_uint32_t openbsd_root;
|
2011-03-23 11:05:13 +00:00
|
|
|
static struct grub_relocator *relocator = NULL;
|
2010-08-26 00:46:30 +00:00
|
|
|
static struct grub_openbsd_ramdisk_descriptor openbsd_ramdisk;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
struct bsd_tag
|
|
|
|
{
|
|
|
|
struct bsd_tag *next;
|
|
|
|
grub_size_t len;
|
|
|
|
grub_uint32_t type;
|
|
|
|
union {
|
|
|
|
grub_uint8_t a;
|
|
|
|
grub_uint16_t b;
|
|
|
|
grub_uint32_t c;
|
|
|
|
} data[0];
|
|
|
|
};
|
|
|
|
|
2010-08-29 19:58:58 +00:00
|
|
|
static struct bsd_tag *tags, *tags_last;
|
2010-01-15 10:39:05 +00:00
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
struct netbsd_module
|
|
|
|
{
|
|
|
|
struct netbsd_module *next;
|
|
|
|
struct grub_netbsd_btinfo_module mod;
|
|
|
|
};
|
|
|
|
|
2010-08-29 19:58:58 +00:00
|
|
|
static struct netbsd_module *netbsd_mods, *netbsd_mods_last;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2009-08-23 11:46:25 +00:00
|
|
|
static const struct grub_arg_option freebsd_opts[] =
|
|
|
|
{
|
2010-01-03 18:24:22 +00:00
|
|
|
{"dual", 'D', 0, N_("Display output on all consoles."), 0, 0},
|
|
|
|
{"serial", 'h', 0, N_("Use serial console."), 0, 0},
|
|
|
|
{"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
|
2010-01-03 18:50:51 +00:00
|
|
|
{"cdrom", 'C', 0, N_("Use CDROM as root."), 0, 0},
|
2010-01-03 18:24:22 +00:00
|
|
|
{"config", 'c', 0, N_("Invoke user configuration routing."), 0, 0},
|
|
|
|
{"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
|
|
|
|
{"gdb", 'g', 0, N_("Use GDB remote debugger instead of DDB."), 0, 0},
|
|
|
|
{"mute", 'm', 0, N_("Disable all boot output."), 0, 0},
|
2009-08-23 11:46:25 +00:00
|
|
|
{"nointr", 'n', 0, "", 0, 0},
|
2010-01-03 18:24:22 +00:00
|
|
|
{"pause", 'p', 0, N_("Wait for keypress after every line of output."), 0, 0},
|
2009-08-23 11:46:25 +00:00
|
|
|
{"quiet", 'q', 0, "", 0, 0},
|
2010-01-03 18:24:22 +00:00
|
|
|
{"dfltroot", 'r', 0, N_("Use compiled-in rootdev."), 0, 0},
|
|
|
|
{"single", 's', 0, N_("Boot into single mode."), 0, 0},
|
|
|
|
{"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0},
|
2009-08-23 11:46:25 +00:00
|
|
|
{0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static const grub_uint32_t freebsd_flags[] =
|
|
|
|
{
|
|
|
|
FREEBSD_RB_DUAL, FREEBSD_RB_SERIAL, FREEBSD_RB_ASKNAME,
|
|
|
|
FREEBSD_RB_CDROM, FREEBSD_RB_CONFIG, FREEBSD_RB_KDB,
|
|
|
|
FREEBSD_RB_GDB, FREEBSD_RB_MUTE, FREEBSD_RB_NOINTR,
|
|
|
|
FREEBSD_RB_PAUSE, FREEBSD_RB_QUIET, FREEBSD_RB_DFLTROOT,
|
2009-08-23 11:46:25 +00:00
|
|
|
FREEBSD_RB_SINGLE, FREEBSD_RB_VERBOSE, 0
|
2008-02-19 16:40:45 +00:00
|
|
|
};
|
|
|
|
|
2009-08-23 11:46:25 +00:00
|
|
|
static const struct grub_arg_option openbsd_opts[] =
|
|
|
|
{
|
2010-01-03 18:24:22 +00:00
|
|
|
{"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
|
|
|
|
{"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0},
|
|
|
|
{"config", 'c', 0, N_("Change configured devices."), 0, 0},
|
|
|
|
{"single", 's', 0, N_("Boot into single mode."), 0, 0},
|
|
|
|
{"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
|
|
|
|
{"root", 'r', 0, N_("Set root device."), "wdXY", ARG_TYPE_STRING},
|
2010-01-19 13:29:02 +00:00
|
|
|
{"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
|
|
|
|
N_("Use serial console."), N_("comUNIT[,SPEED]"), ARG_TYPE_STRING},
|
2009-08-23 11:46:25 +00:00
|
|
|
{0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static const grub_uint32_t openbsd_flags[] =
|
|
|
|
{
|
|
|
|
OPENBSD_RB_ASKNAME, OPENBSD_RB_HALT, OPENBSD_RB_CONFIG,
|
2009-08-23 11:46:25 +00:00
|
|
|
OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0
|
2008-02-19 16:40:45 +00:00
|
|
|
};
|
|
|
|
|
2009-10-16 20:21:12 +00:00
|
|
|
#define OPENBSD_ROOT_ARG (ARRAY_SIZE (openbsd_flags) - 1)
|
2010-01-19 13:29:02 +00:00
|
|
|
#define OPENBSD_SERIAL_ARG (ARRAY_SIZE (openbsd_flags))
|
2009-10-16 20:21:12 +00:00
|
|
|
|
2009-08-23 11:46:25 +00:00
|
|
|
static const struct grub_arg_option netbsd_opts[] =
|
|
|
|
{
|
2010-01-03 18:24:22 +00:00
|
|
|
{"no-smp", '1', 0, N_("Disable SMP."), 0, 0},
|
|
|
|
{"no-acpi", '2', 0, N_("Disable ACPI."), 0, 0},
|
|
|
|
{"askname", 'a', 0, N_("Ask for file name to reboot from."), 0, 0},
|
|
|
|
{"halt", 'b', 0, N_("Don't reboot, just halt."), 0, 0},
|
|
|
|
{"config", 'c', 0, N_("Change configured devices."), 0, 0},
|
|
|
|
{"kdb", 'd', 0, N_("Enter in KDB on boot."), 0, 0},
|
2009-08-23 11:46:25 +00:00
|
|
|
{"miniroot", 'm', 0, "", 0, 0},
|
2010-01-03 18:24:22 +00:00
|
|
|
{"quiet", 'q', 0, N_("Don't display boot diagnostic messages."), 0, 0},
|
|
|
|
{"single", 's', 0, N_("Boot into single mode."), 0, 0},
|
|
|
|
{"verbose", 'v', 0, N_("Boot with verbose messages."), 0, 0},
|
|
|
|
{"debug", 'x', 0, N_("Boot with debug messages."), 0, 0},
|
|
|
|
{"silent", 'z', 0, N_("Supress normal output (warnings remain)."), 0, 0},
|
|
|
|
{"root", 'r', 0, N_("Set root device."), N_("DEVICE"), ARG_TYPE_STRING},
|
2010-01-15 10:39:05 +00:00
|
|
|
{"serial", 'h', GRUB_ARG_OPTION_OPTIONAL,
|
2010-01-15 10:48:15 +00:00
|
|
|
N_("Use serial console."), N_("[ADDR|comUNIT][,SPEED]"), ARG_TYPE_STRING},
|
2009-08-23 11:46:25 +00:00
|
|
|
{0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static const grub_uint32_t netbsd_flags[] =
|
|
|
|
{
|
2009-08-24 12:55:19 +00:00
|
|
|
NETBSD_AB_NOSMP, NETBSD_AB_NOACPI, NETBSD_RB_ASKNAME,
|
|
|
|
NETBSD_RB_HALT, NETBSD_RB_USERCONFIG, NETBSD_RB_KDB,
|
|
|
|
NETBSD_RB_MINIROOT, NETBSD_AB_QUIET, NETBSD_RB_SINGLE,
|
|
|
|
NETBSD_AB_VERBOSE, NETBSD_AB_DEBUG, NETBSD_AB_SILENT, 0
|
2008-02-19 16:40:45 +00:00
|
|
|
};
|
|
|
|
|
2009-08-24 13:10:12 +00:00
|
|
|
#define NETBSD_ROOT_ARG (ARRAY_SIZE (netbsd_flags) - 1)
|
2010-01-15 10:39:05 +00:00
|
|
|
#define NETBSD_SERIAL_ARG (ARRAY_SIZE (netbsd_flags))
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static void
|
|
|
|
grub_bsd_get_device (grub_uint32_t * biosdev,
|
|
|
|
grub_uint32_t * unit,
|
|
|
|
grub_uint32_t * slice, grub_uint32_t * part)
|
|
|
|
{
|
2009-12-23 16:41:32 +00:00
|
|
|
grub_device_t dev;
|
2009-06-11 16:13:39 +00:00
|
|
|
|
2009-08-25 23:18:48 +00:00
|
|
|
#ifdef GRUB_MACHINE_PCBIOS
|
2009-06-11 16:13:39 +00:00
|
|
|
*biosdev = grub_get_root_biosnumber () & 0xff;
|
2009-08-25 23:18:48 +00:00
|
|
|
#else
|
|
|
|
*biosdev = 0xff;
|
|
|
|
#endif
|
2009-06-11 16:13:39 +00:00
|
|
|
*unit = (*biosdev & 0x7f);
|
|
|
|
*slice = 0xff;
|
|
|
|
*part = 0xff;
|
|
|
|
dev = grub_device_open (0);
|
|
|
|
if (dev && dev->disk && dev->disk->partition)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-02-06 17:43:37 +00:00
|
|
|
if (dev->disk->partition->parent)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-02-06 17:43:37 +00:00
|
|
|
*part = dev->disk->partition->number;
|
|
|
|
*slice = dev->disk->partition->parent->number + 1;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
2010-02-06 17:43:37 +00:00
|
|
|
else
|
|
|
|
*slice = dev->disk->partition->number + 1;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
2009-06-11 16:13:39 +00:00
|
|
|
if (dev)
|
|
|
|
grub_device_close (dev);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_err_t
|
2011-11-30 15:20:13 +00:00
|
|
|
grub_bsd_add_meta (grub_uint32_t type, const void *data, grub_uint32_t len)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
struct bsd_tag *newtag;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
newtag = grub_malloc (len + sizeof (struct bsd_tag));
|
|
|
|
if (!newtag)
|
|
|
|
return grub_errno;
|
|
|
|
newtag->len = len;
|
|
|
|
newtag->type = type;
|
|
|
|
newtag->next = NULL;
|
2008-02-19 16:40:45 +00:00
|
|
|
if (len)
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_memcpy (newtag->data, data, len);
|
2010-01-18 12:32:56 +00:00
|
|
|
|
|
|
|
if (kernel_type == KERNEL_TYPE_FREEBSD
|
|
|
|
&& type == (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_SMAP))
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-18 12:32:56 +00:00
|
|
|
struct bsd_tag *p;
|
|
|
|
for (p = tags;
|
|
|
|
p->type != (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND);
|
|
|
|
p = p->next);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-18 12:32:56 +00:00
|
|
|
if (p)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-18 12:32:56 +00:00
|
|
|
newtag->next = p->next;
|
|
|
|
p->next = newtag;
|
|
|
|
if (newtag->next == NULL)
|
|
|
|
tags_last = newtag;
|
|
|
|
return GRUB_ERR_NONE;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
if (tags_last)
|
|
|
|
tags_last->next = newtag;
|
|
|
|
else
|
|
|
|
tags = newtag;
|
|
|
|
tags_last = newtag;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
2009-05-03 09:03:31 +00:00
|
|
|
struct grub_e820_mmap
|
|
|
|
{
|
|
|
|
grub_uint64_t addr;
|
|
|
|
grub_uint64_t size;
|
|
|
|
grub_uint32_t type;
|
|
|
|
} __attribute__((packed));
|
|
|
|
#define GRUB_E820_RAM 1
|
|
|
|
#define GRUB_E820_RESERVED 2
|
|
|
|
#define GRUB_E820_ACPI 3
|
|
|
|
#define GRUB_E820_NVS 4
|
2011-01-05 00:14:32 +00:00
|
|
|
#define GRUB_E820_BADRAM 5
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
static void
|
|
|
|
generate_e820_mmap (grub_size_t *len, grub_size_t *cnt, void *buf)
|
2009-05-03 09:03:31 +00:00
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
int count = 0;
|
|
|
|
struct grub_e820_mmap *mmap = buf;
|
|
|
|
struct grub_e820_mmap prev, cur;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-09-04 15:10:10 +00:00
|
|
|
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t,
|
|
|
|
grub_memory_type_t);
|
2009-05-03 09:03:31 +00:00
|
|
|
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
|
2010-09-04 15:10:10 +00:00
|
|
|
grub_memory_type_t type)
|
2009-05-03 09:03:31 +00:00
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
cur.addr = addr;
|
|
|
|
cur.size = size;
|
|
|
|
switch (type)
|
2009-05-03 09:03:31 +00:00
|
|
|
{
|
2010-09-04 15:10:10 +00:00
|
|
|
case GRUB_MEMORY_AVAILABLE:
|
2010-01-15 10:39:05 +00:00
|
|
|
cur.type = GRUB_E820_RAM;
|
|
|
|
break;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-09-04 15:10:10 +00:00
|
|
|
case GRUB_MEMORY_ACPI:
|
2010-01-15 10:39:05 +00:00
|
|
|
cur.type = GRUB_E820_ACPI;
|
|
|
|
break;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-09-04 15:10:10 +00:00
|
|
|
case GRUB_MEMORY_NVS:
|
2010-01-15 10:39:05 +00:00
|
|
|
cur.type = GRUB_E820_NVS;
|
|
|
|
break;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
default:
|
2010-09-04 15:10:10 +00:00
|
|
|
case GRUB_MEMORY_CODE:
|
|
|
|
case GRUB_MEMORY_RESERVED:
|
2010-01-15 10:39:05 +00:00
|
|
|
cur.type = GRUB_E820_RESERVED;
|
|
|
|
break;
|
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
/* Merge regions if possible. */
|
|
|
|
if (count && cur.type == prev.type && cur.addr == prev.addr + prev.size)
|
|
|
|
{
|
|
|
|
prev.size += cur.size;
|
|
|
|
if (mmap)
|
2010-05-02 14:26:00 +00:00
|
|
|
mmap[-1] = prev;
|
2009-05-03 09:03:31 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
|
|
|
if (mmap)
|
|
|
|
*mmap++ = cur;
|
|
|
|
prev = cur;
|
|
|
|
count++;
|
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-05-02 14:26:00 +00:00
|
|
|
if (kernel_type == KERNEL_TYPE_OPENBSD && prev.addr < 0x100000
|
|
|
|
&& prev.addr + prev.size > 0x100000)
|
|
|
|
{
|
|
|
|
cur.addr = 0x100000;
|
|
|
|
cur.size = prev.addr + prev.size - 0x100000;
|
|
|
|
cur.type = prev.type;
|
|
|
|
prev.size = 0x100000 - prev.addr;
|
|
|
|
if (mmap)
|
|
|
|
{
|
|
|
|
mmap[-1] = prev;
|
|
|
|
mmap[0] = cur;
|
|
|
|
mmap++;
|
|
|
|
}
|
|
|
|
prev = cur;
|
|
|
|
count++;
|
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
grub_mmap_iterate (hook);
|
2010-01-15 10:39:05 +00:00
|
|
|
|
|
|
|
if (len)
|
|
|
|
*len = count * sizeof (struct grub_e820_mmap);
|
|
|
|
*cnt = count;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_bsd_add_mmap (void)
|
|
|
|
{
|
|
|
|
grub_size_t len, cnt;
|
|
|
|
void *buf = NULL, *buf0;
|
|
|
|
|
|
|
|
generate_e820_mmap (&len, &cnt, buf);
|
|
|
|
|
|
|
|
if (kernel_type == KERNEL_TYPE_NETBSD)
|
|
|
|
len += sizeof (grub_uint32_t);
|
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
if (kernel_type == KERNEL_TYPE_OPENBSD)
|
|
|
|
len += sizeof (struct grub_e820_mmap);
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
buf = grub_malloc (len);
|
|
|
|
if (!buf)
|
2009-05-03 09:03:31 +00:00
|
|
|
return grub_errno;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
buf0 = buf;
|
|
|
|
if (kernel_type == KERNEL_TYPE_NETBSD)
|
|
|
|
{
|
|
|
|
*(grub_uint32_t *) buf = cnt;
|
|
|
|
buf = ((grub_uint32_t *) buf + 1);
|
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
generate_e820_mmap (NULL, &cnt, buf);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
if (kernel_type == KERNEL_TYPE_OPENBSD)
|
|
|
|
grub_memset ((grub_uint8_t *) buf + len - sizeof (struct grub_e820_mmap), 0,
|
|
|
|
sizeof (struct grub_e820_mmap));
|
|
|
|
|
2010-01-18 11:01:13 +00:00
|
|
|
grub_dprintf ("bsd", "%u entries in smap\n", (unsigned) cnt);
|
2010-01-15 10:39:05 +00:00
|
|
|
if (kernel_type == KERNEL_TYPE_NETBSD)
|
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_MEMMAP, buf0, len);
|
2010-01-19 09:32:57 +00:00
|
|
|
else if (kernel_type == KERNEL_TYPE_OPENBSD)
|
|
|
|
grub_bsd_add_meta (OPENBSD_BOOTARG_MMAP, buf0, len);
|
2010-01-15 10:39:05 +00:00
|
|
|
else
|
|
|
|
grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
|
|
|
|
FREEBSD_MODINFOMD_SMAP, buf0, len);
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_free (buf0);
|
2009-05-03 09:03:31 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_err_t
|
2011-11-30 15:20:13 +00:00
|
|
|
grub_freebsd_add_meta_module (const char *filename, const char *type,
|
|
|
|
int argc, char **argv,
|
2008-02-19 16:40:45 +00:00
|
|
|
grub_addr_t addr, grub_uint32_t size)
|
|
|
|
{
|
2011-11-30 15:20:13 +00:00
|
|
|
const char *name;
|
2009-06-21 15:48:10 +00:00
|
|
|
name = grub_strrchr (filename, '/');
|
2008-02-19 16:40:45 +00:00
|
|
|
if (name)
|
|
|
|
name++;
|
|
|
|
else
|
2009-06-21 15:48:10 +00:00
|
|
|
name = filename;
|
2009-07-15 22:51:47 +00:00
|
|
|
if (grub_strcmp (type, "/boot/zfs/zpool.cache") == 0)
|
|
|
|
name = "/boot/zfs/zpool.cache";
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
if (grub_bsd_add_meta (FREEBSD_MODINFO_NAME, name, grub_strlen (name) + 1))
|
2008-02-19 16:40:45 +00:00
|
|
|
return grub_errno;
|
|
|
|
|
2009-05-03 09:03:31 +00:00
|
|
|
if (is_64bit)
|
|
|
|
{
|
2009-06-10 21:04:23 +00:00
|
|
|
grub_uint64_t addr64 = addr, size64 = size;
|
2010-01-15 10:39:05 +00:00
|
|
|
if (grub_bsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)
|
|
|
|
|| grub_bsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64, sizeof (addr64))
|
|
|
|
|| grub_bsd_add_meta (FREEBSD_MODINFO_SIZE, &size64, sizeof (size64)))
|
2009-05-03 09:03:31 +00:00
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
if (grub_bsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)
|
|
|
|
|| grub_bsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, sizeof (addr))
|
|
|
|
|| grub_bsd_add_meta (FREEBSD_MODINFO_SIZE, &size, sizeof (size)))
|
2009-05-03 09:03:31 +00:00
|
|
|
return grub_errno;
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (argc)
|
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
n += grub_strlen (argv[i]) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
char cmdline[n], *p;
|
|
|
|
|
|
|
|
p = cmdline;
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
grub_strcpy (p, argv[i]);
|
|
|
|
p += grub_strlen (argv[i]);
|
|
|
|
*(p++) = ' ';
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
if (grub_bsd_add_meta (FREEBSD_MODINFO_ARGS, cmdline, n))
|
2008-02-19 16:40:45 +00:00
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
grub_freebsd_list_modules (void)
|
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
struct bsd_tag *tag;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2011-11-11 23:34:14 +00:00
|
|
|
grub_printf (" %-18s %-18s%14s%14s\n", _("name"), _("type"), _("addr"),
|
|
|
|
_("size"));
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
for (tag = tags; tag; tag = tag->next)
|
|
|
|
{
|
|
|
|
switch (tag->type)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
case FREEBSD_MODINFO_NAME:
|
|
|
|
case FREEBSD_MODINFO_TYPE:
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_printf (" %-18s", (char *) tag->data);
|
2008-02-19 16:40:45 +00:00
|
|
|
break;
|
|
|
|
case FREEBSD_MODINFO_ADDR:
|
|
|
|
{
|
2010-01-13 20:00:46 +00:00
|
|
|
grub_uint32_t addr;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
addr = *((grub_uint32_t *) tag->data);
|
2008-02-19 16:40:45 +00:00
|
|
|
grub_printf (" 0x%08x", addr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FREEBSD_MODINFO_SIZE:
|
|
|
|
{
|
|
|
|
grub_uint32_t len;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
len = *((grub_uint32_t *) tag->data);
|
2008-02-19 16:40:45 +00:00
|
|
|
grub_printf (" 0x%08x\n", len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_netbsd_add_meta_module (char *filename, grub_uint32_t type,
|
|
|
|
grub_addr_t addr, grub_uint32_t size)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
struct netbsd_module *mod;
|
|
|
|
name = grub_strrchr (filename, '/');
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
name++;
|
|
|
|
else
|
|
|
|
name = filename;
|
|
|
|
|
|
|
|
mod = grub_zalloc (sizeof (*mod));
|
|
|
|
if (!mod)
|
|
|
|
return grub_errno;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
grub_strncpy (mod->mod.name, name, sizeof (mod->mod.name) - 1);
|
|
|
|
mod->mod.addr = addr;
|
|
|
|
mod->mod.type = type;
|
|
|
|
mod->mod.size = size;
|
|
|
|
|
|
|
|
if (netbsd_mods_last)
|
|
|
|
netbsd_mods_last->next = mod;
|
|
|
|
else
|
|
|
|
netbsd_mods = mod;
|
|
|
|
netbsd_mods_last = mod;
|
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
grub_netbsd_list_modules (void)
|
2009-05-03 09:03:31 +00:00
|
|
|
{
|
2010-01-16 10:47:12 +00:00
|
|
|
struct netbsd_module *mod;
|
|
|
|
|
2011-11-11 23:34:14 +00:00
|
|
|
grub_printf (" %-18s%14s%14s%14s\n", _("name"), _("type"), _("addr"),
|
|
|
|
_("size"));
|
2010-01-16 10:47:12 +00:00
|
|
|
|
|
|
|
for (mod = netbsd_mods; mod; mod = mod->next)
|
|
|
|
grub_printf (" %-18s 0x%08x 0x%08x 0x%08x", mod->mod.name,
|
|
|
|
mod->mod.type, mod->mod.addr, mod->mod.size);
|
|
|
|
}
|
|
|
|
|
2009-05-04 20:06:05 +00:00
|
|
|
/* This function would be here but it's under different license. */
|
2009-05-03 09:03:31 +00:00
|
|
|
#include "bsd_pagetable.c"
|
|
|
|
|
2010-12-27 06:06:41 +00:00
|
|
|
static grub_uint32_t freebsd_bootdev, freebsd_biosdev;
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_freebsd_boot (void)
|
|
|
|
{
|
|
|
|
struct grub_freebsd_bootinfo bi;
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_uint8_t *p, *p0;
|
|
|
|
grub_addr_t p_target;
|
|
|
|
grub_size_t p_size = 0;
|
|
|
|
grub_err_t err;
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_size_t tag_buf_len = 0;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
auto int iterate_env (struct grub_env_var *var);
|
|
|
|
int iterate_env (struct grub_env_var *var)
|
|
|
|
{
|
2009-10-14 16:49:22 +00:00
|
|
|
if ((!grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1)) && (var->name[sizeof("kFreeBSD.") - 1]))
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_strcpy ((char *) p, &var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
|
p += grub_strlen ((char *) p);
|
2008-02-19 16:40:45 +00:00
|
|
|
*(p++) = '=';
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_strcpy ((char *) p, var->value);
|
|
|
|
p += grub_strlen ((char *) p) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto int iterate_env_count (struct grub_env_var *var);
|
|
|
|
int iterate_env_count (struct grub_env_var *var)
|
|
|
|
{
|
|
|
|
if ((!grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1)) && (var->name[sizeof("kFreeBSD.") - 1]))
|
|
|
|
{
|
|
|
|
p_size += grub_strlen (&var->name[sizeof("kFreeBSD.") - 1]);
|
|
|
|
p_size++;
|
|
|
|
p_size += grub_strlen (var->value) + 1;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
grub_memset (&bi, 0, sizeof (bi));
|
2010-01-21 16:35:14 +00:00
|
|
|
bi.version = FREEBSD_BOOTINFO_VERSION;
|
|
|
|
bi.length = sizeof (bi);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-12-27 06:06:41 +00:00
|
|
|
bi.boot_device = freebsd_biosdev;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
p_size = 0;
|
|
|
|
grub_env_iterate (iterate_env_count);
|
2010-01-15 10:39:05 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
if (p_size)
|
|
|
|
p_size = ALIGN_PAGE (kern_end + p_size + 1) - kern_end;
|
2010-01-15 10:39:05 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
if (is_elf_kernel)
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
|
|
|
struct bsd_tag *tag;
|
|
|
|
|
|
|
|
err = grub_bsd_add_mmap ();
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = grub_bsd_add_meta (FREEBSD_MODINFO_END, 0, 0);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
tag_buf_len = 0;
|
|
|
|
for (tag = tags; tag; tag = tag->next)
|
|
|
|
tag_buf_len = ALIGN_VAR (tag_buf_len
|
|
|
|
+ sizeof (struct freebsd_tag_header)
|
|
|
|
+ tag->len);
|
|
|
|
p_size = ALIGN_PAGE (kern_end + p_size + tag_buf_len) - kern_end;
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
|
|
|
|
if (is_64bit)
|
2010-01-12 16:50:11 +00:00
|
|
|
p_size += 4096 * 3;
|
2010-01-11 21:54:40 +00:00
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
|
|
|
kern_end, p_size);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
p = get_virtual_current_address (ch);
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
p_target = kern_end;
|
2010-01-12 16:50:11 +00:00
|
|
|
p0 = p;
|
|
|
|
kern_end += p_size;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
grub_env_iterate (iterate_env);
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
if (p != p0)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
*(p++) = 0;
|
|
|
|
|
2010-01-30 15:46:16 +00:00
|
|
|
bi.environment = p_target;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_elf_kernel)
|
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_uint8_t *p_tag = p;
|
|
|
|
struct bsd_tag *tag;
|
|
|
|
|
|
|
|
for (tag = tags; tag; tag = tag->next)
|
|
|
|
{
|
|
|
|
struct freebsd_tag_header *head
|
|
|
|
= (struct freebsd_tag_header *) p_tag;
|
|
|
|
head->type = tag->type;
|
|
|
|
head->len = tag->len;
|
|
|
|
p_tag += sizeof (struct freebsd_tag_header);
|
|
|
|
switch (tag->type)
|
|
|
|
{
|
|
|
|
case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_HOWTO:
|
|
|
|
if (is_64bit)
|
|
|
|
*(grub_uint64_t *) p_tag = bootflags;
|
|
|
|
else
|
|
|
|
*(grub_uint32_t *) p_tag = bootflags;
|
|
|
|
break;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ENVP:
|
|
|
|
if (is_64bit)
|
2010-01-30 15:46:16 +00:00
|
|
|
*(grub_uint64_t *) p_tag = bi.environment;
|
2010-01-15 10:39:05 +00:00
|
|
|
else
|
2010-01-30 15:46:16 +00:00
|
|
|
*(grub_uint32_t *) p_tag = bi.environment;
|
2010-01-15 10:39:05 +00:00
|
|
|
break;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND:
|
|
|
|
if (is_64bit)
|
|
|
|
*(grub_uint64_t *) p_tag = kern_end;
|
|
|
|
else
|
|
|
|
*(grub_uint32_t *) p_tag = kern_end;
|
|
|
|
break;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
default:
|
|
|
|
grub_memcpy (p_tag, tag->data, tag->len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p_tag += tag->len;
|
|
|
|
p_tag = ALIGN_VAR (p_tag - p) + p;
|
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-30 15:46:16 +00:00
|
|
|
bi.tags = (p - p0) + p_target;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
p = (ALIGN_PAGE ((p_tag - p0) + p_target) - p_target) + p0;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2010-01-21 16:35:14 +00:00
|
|
|
bi.kern_end = kern_end;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-17 16:52:01 +00:00
|
|
|
grub_video_set_mode ("text", 0, 0);
|
2010-01-14 21:08:31 +00:00
|
|
|
|
2009-05-03 09:03:31 +00:00
|
|
|
if (is_64bit)
|
|
|
|
{
|
2010-01-12 16:50:11 +00:00
|
|
|
struct grub_relocator64_state state;
|
2009-05-03 09:03:31 +00:00
|
|
|
grub_uint8_t *pagetable;
|
2010-01-12 16:50:11 +00:00
|
|
|
grub_uint32_t *stack;
|
|
|
|
grub_addr_t stack_target;
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_align (relocator, &ch,
|
|
|
|
0x10000, 0x90000,
|
|
|
|
3 * sizeof (grub_uint32_t)
|
|
|
|
+ sizeof (bi), 4,
|
|
|
|
GRUB_RELOCATOR_PREFERENCE_NONE);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
stack = get_virtual_current_address (ch);
|
|
|
|
stack_target = get_physical_target_address (ch);
|
|
|
|
}
|
2010-01-12 16:50:11 +00:00
|
|
|
|
2010-01-14 18:12:24 +00:00
|
|
|
#ifdef GRUB_MACHINE_EFI
|
2010-04-20 16:08:26 +00:00
|
|
|
err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-14 18:12:24 +00:00
|
|
|
#endif
|
2010-01-13 20:04:19 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
pagetable = p;
|
2010-01-12 16:50:11 +00:00
|
|
|
fill_bsd64_pagetable (pagetable, (pagetable - p0) + p_target);
|
2009-05-03 09:03:31 +00:00
|
|
|
|
2010-01-12 16:50:11 +00:00
|
|
|
state.cr3 = (pagetable - p0) + p_target;
|
|
|
|
state.rsp = stack_target;
|
|
|
|
state.rip = (((grub_uint64_t) entry_hi) << 32) | entry;
|
|
|
|
|
|
|
|
stack[0] = entry;
|
2010-01-30 15:46:16 +00:00
|
|
|
stack[1] = bi.tags;
|
2010-01-12 16:50:11 +00:00
|
|
|
stack[2] = kern_end;
|
|
|
|
return grub_relocator64_boot (relocator, state, 0, 0x40000000);
|
2009-05-03 09:03:31 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-11 21:54:40 +00:00
|
|
|
{
|
|
|
|
struct grub_relocator32_state state;
|
|
|
|
grub_uint32_t *stack;
|
|
|
|
grub_addr_t stack_target;
|
2010-04-21 17:13:45 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_align (relocator, &ch,
|
|
|
|
0x10000, 0x90000,
|
|
|
|
9 * sizeof (grub_uint32_t)
|
|
|
|
+ sizeof (bi), 4,
|
|
|
|
GRUB_RELOCATOR_PREFERENCE_NONE);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
stack = get_virtual_current_address (ch);
|
|
|
|
stack_target = get_physical_target_address (ch);
|
|
|
|
}
|
2010-01-13 20:00:46 +00:00
|
|
|
|
2010-01-14 18:12:24 +00:00
|
|
|
#ifdef GRUB_MACHINE_EFI
|
2010-04-20 16:08:26 +00:00
|
|
|
err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-14 18:12:24 +00:00
|
|
|
#endif
|
2010-01-13 20:04:19 +00:00
|
|
|
|
2010-01-18 11:45:28 +00:00
|
|
|
grub_memcpy (&stack[9], &bi, sizeof (bi));
|
2010-01-11 21:54:40 +00:00
|
|
|
state.eip = entry;
|
|
|
|
state.esp = stack_target;
|
2010-09-03 12:05:19 +00:00
|
|
|
state.ebp = stack_target;
|
2010-01-11 21:54:40 +00:00
|
|
|
stack[0] = entry; /* "Return" address. */
|
|
|
|
stack[1] = bootflags | FREEBSD_RB_BOOTINFO;
|
2010-12-27 06:06:41 +00:00
|
|
|
stack[2] = freebsd_bootdev;
|
2010-01-11 21:54:40 +00:00
|
|
|
stack[3] = 0;
|
|
|
|
stack[4] = 0;
|
|
|
|
stack[5] = 0;
|
|
|
|
stack[6] = stack_target + 9 * sizeof (grub_uint32_t);
|
2010-01-30 15:46:16 +00:00
|
|
|
stack[7] = bi.tags;
|
2010-01-11 21:54:40 +00:00
|
|
|
stack[8] = kern_end;
|
|
|
|
return grub_relocator32_boot (relocator, state);
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
/* Not reached. */
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_openbsd_boot (void)
|
|
|
|
{
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_uint32_t *stack;
|
|
|
|
struct grub_relocator32_state state;
|
2010-01-19 09:32:57 +00:00
|
|
|
void *curarg, *buf0, *arg0;
|
|
|
|
grub_addr_t buf_target;
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_err_t err;
|
2010-01-19 09:32:57 +00:00
|
|
|
grub_size_t tag_buf_len;
|
2009-08-24 13:20:24 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
err = grub_bsd_add_mmap ();
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-05-02 21:46:34 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
{
|
2010-01-19 09:32:57 +00:00
|
|
|
struct bsd_tag *tag;
|
|
|
|
tag_buf_len = 0;
|
|
|
|
for (tag = tags; tag; tag = tag->next)
|
|
|
|
tag_buf_len = ALIGN_VAR (tag_buf_len
|
|
|
|
+ sizeof (struct grub_openbsd_bootargs)
|
|
|
|
+ tag->len);
|
2010-01-11 21:54:40 +00:00
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
buf_target = GRUB_BSD_TEMP_BUFFER - 9 * sizeof (grub_uint32_t);
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch, buf_target,
|
|
|
|
tag_buf_len
|
|
|
|
+ sizeof (struct grub_openbsd_bootargs)
|
|
|
|
+ 9 * sizeof (grub_uint32_t));
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
buf0 = get_virtual_current_address (ch);
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
stack = (grub_uint32_t *) buf0;
|
|
|
|
arg0 = curarg = stack + 9;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
{
|
|
|
|
struct bsd_tag *tag;
|
|
|
|
struct grub_openbsd_bootargs *head;
|
2009-08-24 13:20:24 +00:00
|
|
|
|
2010-01-19 09:32:57 +00:00
|
|
|
for (tag = tags; tag; tag = tag->next)
|
|
|
|
{
|
|
|
|
head = curarg;
|
|
|
|
head->ba_type = tag->type;
|
|
|
|
head->ba_size = tag->len + sizeof (*head);
|
|
|
|
curarg = head + 1;
|
|
|
|
grub_memcpy (curarg, tag->data, tag->len);
|
|
|
|
curarg = (grub_uint8_t *) curarg + tag->len;
|
|
|
|
head->ba_next = (grub_uint8_t *) curarg - (grub_uint8_t *) buf0
|
|
|
|
+ buf_target;
|
|
|
|
}
|
|
|
|
head = curarg;
|
|
|
|
head->ba_type = OPENBSD_BOOTARG_END;
|
|
|
|
head->ba_size = 0;
|
|
|
|
head->ba_next = 0;
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-17 16:52:01 +00:00
|
|
|
grub_video_set_mode ("text", 0, 0);
|
2010-01-14 21:08:31 +00:00
|
|
|
|
2010-01-14 18:12:24 +00:00
|
|
|
#ifdef GRUB_MACHINE_EFI
|
2010-04-20 16:08:26 +00:00
|
|
|
err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-14 18:12:24 +00:00
|
|
|
#endif
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
state.eip = entry;
|
2010-09-03 12:05:19 +00:00
|
|
|
state.ebp = state.esp
|
|
|
|
= ((grub_uint8_t *) stack - (grub_uint8_t *) buf0) + buf_target;
|
2010-01-11 21:54:40 +00:00
|
|
|
stack[0] = entry;
|
|
|
|
stack[1] = bootflags;
|
|
|
|
stack[2] = openbsd_root;
|
|
|
|
stack[3] = OPENBSD_BOOTARG_APIVER;
|
|
|
|
stack[4] = 0;
|
|
|
|
stack[5] = grub_mmap_get_upper () >> 10;
|
|
|
|
stack[6] = grub_mmap_get_lower () >> 10;
|
2010-01-19 09:32:57 +00:00
|
|
|
stack[7] = (grub_uint8_t *) curarg - (grub_uint8_t *) arg0;
|
|
|
|
stack[8] = ((grub_uint8_t *) arg0 - (grub_uint8_t *) buf0) + buf_target;
|
2010-01-15 23:05:33 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
return grub_relocator32_boot (relocator, state);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
2010-01-15 12:40:37 +00:00
|
|
|
grub_netbsd_setup_video (void)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-15 12:40:37 +00:00
|
|
|
struct grub_video_mode_info mode_info;
|
|
|
|
void *framebuffer;
|
|
|
|
const char *modevar;
|
|
|
|
struct grub_netbsd_btinfo_framebuf params;
|
|
|
|
grub_err_t err;
|
2010-01-15 23:31:24 +00:00
|
|
|
grub_video_driver_id_t driv_id;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
modevar = grub_env_get ("gfxpayload");
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
/* Now all graphical modes are acceptable.
|
|
|
|
May change in future if we have modes without framebuffer. */
|
|
|
|
if (modevar && *modevar != 0)
|
|
|
|
{
|
|
|
|
char *tmp;
|
2010-01-20 10:48:36 +00:00
|
|
|
tmp = grub_xasprintf ("%s;" NETBSD_DEFAULT_VIDEO_MODE, modevar);
|
2010-01-15 12:40:37 +00:00
|
|
|
if (! tmp)
|
|
|
|
return grub_errno;
|
|
|
|
err = grub_video_set_mode (tmp, 0, 0);
|
|
|
|
grub_free (tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
err = grub_video_set_mode (NETBSD_DEFAULT_VIDEO_MODE, 0, 0);
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 23:31:24 +00:00
|
|
|
driv_id = grub_video_get_driver_id ();
|
|
|
|
if (driv_id == GRUB_VIDEO_DRIVER_NONE)
|
|
|
|
return GRUB_ERR_NONE;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
params.width = mode_info.width;
|
|
|
|
params.height = mode_info.height;
|
|
|
|
params.bpp = mode_info.bpp;
|
|
|
|
params.pitch = mode_info.pitch;
|
|
|
|
params.flags = 0;
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
params.fbaddr = (grub_addr_t) framebuffer;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
params.red_mask_size = mode_info.red_mask_size;
|
|
|
|
params.red_field_pos = mode_info.red_field_pos;
|
|
|
|
params.green_mask_size = mode_info.green_mask_size;
|
|
|
|
params.green_field_pos = mode_info.green_field_pos;
|
|
|
|
params.blue_mask_size = mode_info.blue_mask_size;
|
|
|
|
params.blue_field_pos = mode_info.blue_field_pos;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
#ifdef GRUB_MACHINE_PCBIOS
|
|
|
|
/* VESA packed modes may come with zeroed mask sizes, which need
|
|
|
|
to be set here according to DAC Palette width. If we don't,
|
|
|
|
this results in Linux displaying a black screen. */
|
2010-01-15 23:31:24 +00:00
|
|
|
if (mode_info.bpp <= 8 && driv_id == GRUB_VIDEO_DRIVER_VBE)
|
2009-08-24 13:10:12 +00:00
|
|
|
{
|
2010-01-15 12:40:37 +00:00
|
|
|
struct grub_vbe_info_block controller_info;
|
|
|
|
int status;
|
|
|
|
int width = 8;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
status = grub_vbe_bios_get_controller_info (&controller_info);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
if (status == GRUB_VBE_STATUS_OK &&
|
|
|
|
(controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH))
|
|
|
|
status = grub_vbe_bios_set_dac_palette_width (&width);
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
if (status != GRUB_VBE_STATUS_OK)
|
|
|
|
/* 6 is default after mode reset. */
|
|
|
|
width = 6;
|
|
|
|
|
|
|
|
params.red_mask_size = params.green_mask_size
|
|
|
|
= params.blue_mask_size = width;
|
2009-08-24 13:10:12 +00:00
|
|
|
}
|
2010-01-15 12:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
err = grub_bsd_add_meta (NETBSD_BTINFO_FRAMEBUF, ¶ms, sizeof (params));
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_netbsd_add_modules (void)
|
|
|
|
{
|
|
|
|
struct netbsd_module *mod;
|
|
|
|
unsigned modcnt = 0;
|
|
|
|
struct grub_netbsd_btinfo_modules *mods;
|
|
|
|
unsigned i;
|
|
|
|
grub_err_t err;
|
|
|
|
|
|
|
|
for (mod = netbsd_mods; mod; mod = mod->next)
|
2010-01-16 11:55:52 +00:00
|
|
|
modcnt++;
|
2010-01-16 10:47:12 +00:00
|
|
|
|
|
|
|
mods = grub_malloc (sizeof (*mods) + sizeof (mods->mods[0]) * modcnt);
|
|
|
|
if (!mods)
|
|
|
|
return grub_errno;
|
|
|
|
|
|
|
|
mods->num = modcnt;
|
2010-01-16 11:55:52 +00:00
|
|
|
mods->last_addr = kern_end;
|
2010-01-16 10:47:12 +00:00
|
|
|
for (mod = netbsd_mods, i = 0; mod; i++, mod = mod->next)
|
|
|
|
mods->mods[i] = mod->mod;
|
|
|
|
|
|
|
|
err = grub_bsd_add_meta (NETBSD_BTINFO_MODULES, mods,
|
|
|
|
sizeof (*mods) + sizeof (mods->mods[0]) * modcnt);
|
|
|
|
grub_free (mods);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-09-28 21:45:57 +00:00
|
|
|
/*
|
|
|
|
* Adds NetBSD bootinfo bootdisk and bootwedge. The partition identified
|
|
|
|
* in these bootinfo fields is the root device.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
grub_netbsd_add_boot_disk_and_wedge (void)
|
|
|
|
{
|
|
|
|
grub_device_t dev;
|
|
|
|
grub_disk_t disk;
|
|
|
|
grub_partition_t part;
|
|
|
|
grub_uint32_t biosdev;
|
|
|
|
grub_uint32_t partmapsector;
|
2011-10-25 16:20:39 +00:00
|
|
|
union {
|
|
|
|
grub_uint64_t raw[GRUB_DISK_SECTOR_SIZE / 8];
|
|
|
|
struct grub_partition_bsd_disk_label label;
|
|
|
|
} buf;
|
2011-09-28 21:45:57 +00:00
|
|
|
grub_uint8_t *hash;
|
|
|
|
grub_uint64_t ctx[(GRUB_MD_MD5->contextsize + 7) / 8];
|
|
|
|
|
|
|
|
dev = grub_device_open (0);
|
|
|
|
if (! (dev && dev->disk && dev->disk->partition))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
disk = dev->disk;
|
|
|
|
part = disk->partition;
|
|
|
|
|
|
|
|
if (disk->dev && disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
|
|
|
|
biosdev = (grub_uint32_t) disk->id & 0xff;
|
|
|
|
else
|
|
|
|
biosdev = 0xff;
|
|
|
|
|
|
|
|
/* Absolute sector of the partition map describing this partition. */
|
|
|
|
partmapsector = grub_partition_get_start (part->parent) + part->offset;
|
|
|
|
|
|
|
|
disk->partition = part->parent;
|
2011-10-25 16:20:39 +00:00
|
|
|
if (grub_disk_read (disk, part->offset, 0, GRUB_DISK_SECTOR_SIZE, buf.raw)
|
|
|
|
!= GRUB_ERR_NONE)
|
2011-09-28 21:45:57 +00:00
|
|
|
goto fail;
|
|
|
|
disk->partition = part;
|
|
|
|
|
|
|
|
/* Fill bootwedge. */
|
|
|
|
{
|
|
|
|
struct grub_netbsd_btinfo_bootwedge biw;
|
|
|
|
|
|
|
|
grub_memset (&biw, 0, sizeof (biw));
|
|
|
|
biw.biosdev = biosdev;
|
|
|
|
biw.startblk = grub_partition_get_start (part);
|
|
|
|
biw.nblks = part->len;
|
|
|
|
biw.matchblk = partmapsector;
|
|
|
|
biw.matchnblks = 1;
|
|
|
|
|
|
|
|
GRUB_MD_MD5->init (&ctx);
|
2011-10-25 16:20:39 +00:00
|
|
|
GRUB_MD_MD5->write (&ctx, buf.raw, GRUB_DISK_SECTOR_SIZE);
|
2011-09-28 21:45:57 +00:00
|
|
|
GRUB_MD_MD5->final (&ctx);
|
|
|
|
hash = GRUB_MD_MD5->read (&ctx);
|
|
|
|
memcpy (biw.matchhash, hash, 16);
|
|
|
|
|
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill bootdisk if this a NetBSD disk label. */
|
|
|
|
if (part->partmap != NULL &&
|
|
|
|
(grub_strcmp (part->partmap->name, "netbsd") == 0) &&
|
2011-10-25 16:20:39 +00:00
|
|
|
buf.label.magic == grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
|
2011-09-28 21:45:57 +00:00
|
|
|
{
|
|
|
|
struct grub_netbsd_btinfo_bootdisk bid;
|
|
|
|
|
|
|
|
grub_memset (&bid, 0, sizeof (bid));
|
|
|
|
bid.labelsector = partmapsector;
|
2011-10-25 16:20:39 +00:00
|
|
|
bid.label.type = buf.label.type;
|
|
|
|
bid.label.checksum = buf.label.checksum;
|
|
|
|
memcpy (bid.label.packname, buf.label.packname, 16);
|
2011-09-28 21:45:57 +00:00
|
|
|
bid.biosdev = biosdev;
|
|
|
|
bid.partition = part->number;
|
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_BOOTDISK, &bid, sizeof (bid));
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (dev)
|
|
|
|
grub_device_close (dev);
|
|
|
|
}
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_netbsd_boot (void)
|
|
|
|
{
|
|
|
|
struct grub_netbsd_bootinfo *bootinfo;
|
2010-01-11 21:54:40 +00:00
|
|
|
void *curarg, *arg0;
|
|
|
|
grub_addr_t arg_target, stack_target;
|
|
|
|
grub_uint32_t *stack;
|
|
|
|
grub_err_t err;
|
|
|
|
struct grub_relocator32_state state;
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_size_t tag_buf_len = 0;
|
|
|
|
int tag_count = 0;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
err = grub_bsd_add_mmap ();
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
err = grub_netbsd_setup_video ();
|
|
|
|
if (err)
|
2009-08-24 13:10:12 +00:00
|
|
|
{
|
2010-01-15 12:40:37 +00:00
|
|
|
grub_print_error ();
|
2011-11-11 23:34:14 +00:00
|
|
|
grub_puts_ (N_("Booting in blind mode"));
|
2010-01-15 12:40:37 +00:00
|
|
|
grub_errno = GRUB_ERR_NONE;
|
2009-08-24 13:10:12 +00:00
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
err = grub_netbsd_add_modules ();
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-14 21:08:31 +00:00
|
|
|
|
2009-08-26 00:32:57 +00:00
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
struct bsd_tag *tag;
|
|
|
|
tag_buf_len = 0;
|
|
|
|
for (tag = tags; tag; tag = tag->next)
|
2009-08-26 00:32:57 +00:00
|
|
|
{
|
2010-01-19 09:32:57 +00:00
|
|
|
tag_buf_len = ALIGN_VAR (tag_buf_len
|
|
|
|
+ sizeof (struct grub_netbsd_btinfo_common)
|
2010-01-15 10:39:05 +00:00
|
|
|
+ tag->len);
|
|
|
|
tag_count++;
|
2009-08-26 00:32:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
arg_target = kern_end;
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
|
|
|
arg_target, tag_buf_len
|
|
|
|
+ sizeof (struct grub_netbsd_bootinfo)
|
|
|
|
+ tag_count * sizeof (grub_uint32_t));
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
curarg = get_virtual_current_address (ch);
|
|
|
|
}
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
arg0 = curarg;
|
2010-01-15 10:39:05 +00:00
|
|
|
bootinfo = (void *) ((grub_uint8_t *) arg0 + tag_buf_len);
|
2009-08-26 00:32:57 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
|
|
|
struct bsd_tag *tag;
|
|
|
|
unsigned i;
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
bootinfo->bi_count = tag_count;
|
|
|
|
for (tag = tags, i = 0; tag; i++, tag = tag->next)
|
|
|
|
{
|
|
|
|
struct grub_netbsd_btinfo_common *head = curarg;
|
|
|
|
bootinfo->bi_data[i] = ((grub_uint8_t *) curarg - (grub_uint8_t *) arg0)
|
|
|
|
+ arg_target;
|
|
|
|
head->type = tag->type;
|
|
|
|
head->len = tag->len + sizeof (*head);
|
|
|
|
curarg = head + 1;
|
|
|
|
grub_memcpy (curarg, tag->data, tag->len);
|
|
|
|
curarg = (grub_uint8_t *) curarg + tag->len;
|
|
|
|
}
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x10000, 0x90000,
|
|
|
|
7 * sizeof (grub_uint32_t), 4,
|
|
|
|
GRUB_RELOCATOR_PREFERENCE_NONE);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
stack = get_virtual_current_address (ch);
|
|
|
|
stack_target = get_physical_target_address (ch);
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
|
2010-01-14 18:12:24 +00:00
|
|
|
#ifdef GRUB_MACHINE_EFI
|
2010-04-20 16:08:26 +00:00
|
|
|
err = grub_efi_finish_boot_services (NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-14 18:12:24 +00:00
|
|
|
#endif
|
2010-01-13 20:04:19 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
state.eip = entry;
|
|
|
|
state.esp = stack_target;
|
2010-09-03 12:05:19 +00:00
|
|
|
state.ebp = stack_target;
|
2010-01-11 21:54:40 +00:00
|
|
|
stack[0] = entry;
|
|
|
|
stack[1] = bootflags;
|
|
|
|
stack[2] = 0;
|
|
|
|
stack[3] = ((grub_uint8_t *) bootinfo - (grub_uint8_t *) arg0) + arg_target;
|
|
|
|
stack[4] = 0;
|
|
|
|
stack[5] = grub_mmap_get_upper () >> 10;
|
|
|
|
stack[6] = grub_mmap_get_lower () >> 10;
|
|
|
|
|
|
|
|
return grub_relocator32_boot (relocator, state);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_bsd_unload (void)
|
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
struct bsd_tag *tag, *next;
|
|
|
|
for (tag = tags; tag; tag = next)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-15 10:39:05 +00:00
|
|
|
next = tag->next;
|
|
|
|
grub_free (tag);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
2010-01-15 10:39:05 +00:00
|
|
|
tags = NULL;
|
|
|
|
tags_last = NULL;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
kernel_type = KERNEL_TYPE_NONE;
|
|
|
|
grub_dl_unref (my_mod);
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_relocator_unload (relocator);
|
|
|
|
relocator = NULL;
|
2009-08-24 13:10:12 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_bsd_load_aout (grub_file_t file)
|
|
|
|
{
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_addr_t load_addr, load_end;
|
2008-02-19 16:40:45 +00:00
|
|
|
int ofs, align_page;
|
|
|
|
union grub_aout_header ah;
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_err_t err;
|
|
|
|
grub_size_t bss_size;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if ((grub_file_seek (file, 0)) == (grub_off_t) - 1)
|
|
|
|
return grub_errno;
|
|
|
|
|
2009-06-10 23:47:49 +00:00
|
|
|
if (grub_file_read (file, &ah, sizeof (ah)) != sizeof (ah))
|
2009-12-24 22:53:05 +00:00
|
|
|
return grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (grub_aout_get_type (&ah) != AOUT_TYPE_AOUT32)
|
2009-12-24 22:53:05 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "invalid a.out header");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
entry = ah.aout32.a_entry & 0xFFFFFF;
|
|
|
|
|
|
|
|
if (AOUT_GETMAGIC (ah.aout32) == AOUT32_ZMAGIC)
|
|
|
|
{
|
|
|
|
load_addr = entry;
|
|
|
|
ofs = 0x1000;
|
|
|
|
align_page = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
load_addr = entry & 0xF00000;
|
|
|
|
ofs = sizeof (struct grub_aout32_header);
|
|
|
|
align_page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (load_addr < 0x100000)
|
2009-12-24 22:53:05 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "load address below 1M");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
kern_start = load_addr;
|
2010-01-11 21:54:40 +00:00
|
|
|
load_end = kern_end = load_addr + ah.aout32.a_text + ah.aout32.a_data;
|
2008-02-19 16:40:45 +00:00
|
|
|
if (align_page)
|
|
|
|
kern_end = ALIGN_PAGE (kern_end);
|
|
|
|
|
|
|
|
if (ah.aout32.a_bss)
|
|
|
|
{
|
|
|
|
kern_end += ah.aout32.a_bss;
|
|
|
|
if (align_page)
|
|
|
|
kern_end = ALIGN_PAGE (kern_end);
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
bss_size = kern_end - load_end;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-11 21:54:40 +00:00
|
|
|
bss_size = 0;
|
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
|
|
|
kern_start, kern_end - kern_start);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
kern_chunk_src = get_virtual_current_address (ch);
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
return grub_aout_load (file, ofs, kern_chunk_src,
|
|
|
|
ah.aout32.a_text + ah.aout32.a_data,
|
|
|
|
bss_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int NESTED_FUNC_ATTR
|
|
|
|
grub_bsd_elf32_size_hook (grub_elf_t elf __attribute__ ((unused)),
|
|
|
|
Elf32_Phdr *phdr, void *arg __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
Elf32_Addr paddr;
|
|
|
|
|
|
|
|
if (phdr->p_type != PT_LOAD
|
|
|
|
&& phdr->p_type != PT_DYNAMIC)
|
2010-01-12 16:50:11 +00:00
|
|
|
return 0;
|
2010-01-11 21:54:40 +00:00
|
|
|
|
|
|
|
paddr = phdr->p_paddr & 0xFFFFFF;
|
|
|
|
|
|
|
|
if (paddr < kern_start)
|
|
|
|
kern_start = paddr;
|
|
|
|
|
|
|
|
if (paddr + phdr->p_memsz > kern_end)
|
|
|
|
kern_end = paddr + phdr->p_memsz;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-12 16:50:11 +00:00
|
|
|
return 0;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_bsd_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr, int *do_load)
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
Elf32_Addr paddr;
|
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
if (phdr->p_type != PT_LOAD
|
|
|
|
&& phdr->p_type != PT_DYNAMIC)
|
|
|
|
{
|
|
|
|
*do_load = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*do_load = 1;
|
2008-02-19 16:40:45 +00:00
|
|
|
phdr->p_paddr &= 0xFFFFFF;
|
|
|
|
paddr = phdr->p_paddr;
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
*addr = (grub_addr_t) (paddr - kern_start + (grub_uint8_t *) kern_chunk_src);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int NESTED_FUNC_ATTR
|
|
|
|
grub_bsd_elf64_size_hook (grub_elf_t elf __attribute__ ((unused)),
|
|
|
|
Elf64_Phdr *phdr, void *arg __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
Elf64_Addr paddr;
|
|
|
|
|
|
|
|
if (phdr->p_type != PT_LOAD
|
|
|
|
&& phdr->p_type != PT_DYNAMIC)
|
2010-01-12 16:50:11 +00:00
|
|
|
return 0;
|
2010-01-11 21:54:40 +00:00
|
|
|
|
|
|
|
paddr = phdr->p_paddr & 0xffffff;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
if (paddr < kern_start)
|
2008-02-19 16:40:45 +00:00
|
|
|
kern_start = paddr;
|
|
|
|
|
|
|
|
if (paddr + phdr->p_memsz > kern_end)
|
|
|
|
kern_end = paddr + phdr->p_memsz;
|
|
|
|
|
2010-01-12 16:50:11 +00:00
|
|
|
return 0;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 09:03:31 +00:00
|
|
|
static grub_err_t
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_bsd_elf64_hook (Elf64_Phdr * phdr, grub_addr_t * addr, int *do_load)
|
2009-05-03 09:03:31 +00:00
|
|
|
{
|
|
|
|
Elf64_Addr paddr;
|
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
if (phdr->p_type != PT_LOAD
|
|
|
|
&& phdr->p_type != PT_DYNAMIC)
|
|
|
|
{
|
|
|
|
*do_load = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*do_load = 1;
|
2009-05-03 09:03:31 +00:00
|
|
|
paddr = phdr->p_paddr & 0xffffff;
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
*addr = (grub_addr_t) (paddr - kern_start + (grub_uint8_t *) kern_chunk_src);
|
2009-05-03 09:03:31 +00:00
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_bsd_load_elf (grub_elf_t elf)
|
|
|
|
{
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_err_t err;
|
|
|
|
|
|
|
|
kern_end = 0;
|
|
|
|
kern_start = ~0;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (grub_elf_is_elf32 (elf))
|
|
|
|
{
|
2010-04-21 17:13:45 +00:00
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF;
|
2010-01-11 21:54:40 +00:00
|
|
|
err = grub_elf32_phdr_iterate (elf, grub_bsd_elf32_size_hook, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-04-21 17:13:45 +00:00
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
2010-01-11 21:54:40 +00:00
|
|
|
kern_start, kern_end - kern_start);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
kern_chunk_src = get_virtual_current_address (ch);
|
|
|
|
|
2010-08-26 00:46:30 +00:00
|
|
|
err = grub_elf32_load (elf, grub_bsd_elf32_hook, 0, 0);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
if (kernel_type != KERNEL_TYPE_OPENBSD)
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
return grub_openbsd_find_ramdisk32 (elf->file, kern_start,
|
|
|
|
kern_chunk_src, &openbsd_ramdisk);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
2009-05-03 09:03:31 +00:00
|
|
|
else if (grub_elf_is_elf64 (elf))
|
|
|
|
{
|
|
|
|
is_64bit = 1;
|
2009-08-24 12:59:48 +00:00
|
|
|
|
2009-10-09 17:57:02 +00:00
|
|
|
if (! grub_cpuid_has_longmode)
|
2009-12-24 22:53:05 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "your CPU does not implement AMD64 architecture");
|
2009-10-09 17:57:02 +00:00
|
|
|
|
2009-08-24 12:59:48 +00:00
|
|
|
/* FreeBSD has 64-bit entry point. */
|
|
|
|
if (kernel_type == KERNEL_TYPE_FREEBSD)
|
|
|
|
{
|
|
|
|
entry = elf->ehdr.ehdr64.e_entry & 0xffffffff;
|
|
|
|
entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry = elf->ehdr.ehdr64.e_entry & 0x0fffffff;
|
|
|
|
entry_hi = 0;
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
|
|
|
|
err = grub_elf64_phdr_iterate (elf, grub_bsd_elf64_size_hook, NULL);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-01-12 16:50:11 +00:00
|
|
|
|
2010-01-13 20:00:46 +00:00
|
|
|
grub_dprintf ("bsd", "kern_start = %lx, kern_end = %lx\n",
|
|
|
|
(unsigned long) kern_start, (unsigned long) kern_end);
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start,
|
|
|
|
kern_end - kern_start);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
kern_chunk_src = get_virtual_current_address (ch);
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
|
2010-08-26 00:46:30 +00:00
|
|
|
err = grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
if (kernel_type != KERNEL_TYPE_OPENBSD)
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
return grub_openbsd_find_ramdisk64 (elf->file, kern_start,
|
|
|
|
kern_chunk_src, &openbsd_ramdisk);
|
2009-05-03 09:03:31 +00:00
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
else
|
2010-01-06 22:00:57 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "invalid ELF");
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_bsd_load (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
grub_file_t file;
|
|
|
|
grub_elf_t elf;
|
|
|
|
|
|
|
|
grub_dl_ref (my_mod);
|
|
|
|
|
|
|
|
grub_loader_unset ();
|
|
|
|
|
2010-08-26 00:46:30 +00:00
|
|
|
grub_memset (&openbsd_ramdisk, 0, sizeof (openbsd_ramdisk));
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2009-12-24 22:53:05 +00:00
|
|
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
2008-02-19 16:40:45 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2008-02-19 16:40:45 +00:00
|
|
|
if (!file)
|
|
|
|
goto fail;
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
relocator = grub_relocator_new ();
|
2011-06-27 11:57:03 +00:00
|
|
|
if (!relocator)
|
|
|
|
{
|
|
|
|
grub_file_close (file);
|
|
|
|
goto fail;
|
|
|
|
}
|
2010-01-11 21:54:40 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
elf = grub_elf_file (file);
|
|
|
|
if (elf)
|
|
|
|
{
|
|
|
|
is_elf_kernel = 1;
|
|
|
|
grub_bsd_load_elf (elf);
|
|
|
|
grub_elf_close (elf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_elf_kernel = 0;
|
|
|
|
grub_errno = 0;
|
|
|
|
grub_bsd_load_aout (file);
|
|
|
|
grub_file_close (file);
|
|
|
|
}
|
|
|
|
|
2010-01-19 08:16:26 +00:00
|
|
|
kern_end = ALIGN_PAGE (kern_end);
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
fail:
|
|
|
|
|
|
|
|
if (grub_errno != GRUB_ERR_NONE)
|
2011-06-27 11:57:03 +00:00
|
|
|
grub_dl_unref (my_mod);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_uint32_t
|
2009-08-23 11:46:25 +00:00
|
|
|
grub_bsd_parse_flags (const struct grub_arg_list *state,
|
2008-02-19 16:40:45 +00:00
|
|
|
const grub_uint32_t * flags)
|
|
|
|
{
|
|
|
|
grub_uint32_t result = 0;
|
2009-08-23 11:46:25 +00:00
|
|
|
unsigned i;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2009-08-23 11:46:25 +00:00
|
|
|
for (i = 0; flags[i]; i++)
|
|
|
|
if (state[i].set)
|
|
|
|
result |= flags[i];
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_err_t
|
2010-06-10 06:42:03 +00:00
|
|
|
grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
kernel_type = KERNEL_TYPE_FREEBSD;
|
2010-06-10 06:42:03 +00:00
|
|
|
bootflags = grub_bsd_parse_flags (ctxt->state, freebsd_flags);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
|
|
|
|
{
|
2010-12-27 06:06:41 +00:00
|
|
|
grub_uint32_t unit, slice, part;
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
kern_end = ALIGN_PAGE (kern_end);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (is_elf_kernel)
|
|
|
|
{
|
|
|
|
grub_err_t err;
|
|
|
|
grub_uint64_t data = 0;
|
|
|
|
grub_file_t file;
|
|
|
|
int len = is_64bit ? 8 : 4;
|
|
|
|
|
|
|
|
err = grub_freebsd_add_meta_module (argv[0], is_64bit
|
|
|
|
? FREEBSD_MODTYPE_KERNEL64
|
|
|
|
: FREEBSD_MODTYPE_KERNEL,
|
|
|
|
argc - 1, argv + 1,
|
|
|
|
kern_start,
|
|
|
|
kern_end - kern_start);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (! file)
|
|
|
|
return grub_errno;
|
|
|
|
|
|
|
|
if (is_64bit)
|
2010-01-12 16:50:11 +00:00
|
|
|
err = grub_freebsd_load_elf_meta64 (relocator, file, &kern_end);
|
2009-06-21 15:48:10 +00:00
|
|
|
else
|
2010-01-12 16:50:11 +00:00
|
|
|
err = grub_freebsd_load_elf_meta32 (relocator, file, &kern_end);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
|
|
|
|
FREEBSD_MODINFOMD_HOWTO, &data, 4);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
|
2009-06-21 15:48:10 +00:00
|
|
|
FREEBSD_MODINFOMD_ENVP, &data, len);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
|
|
|
|
FREEBSD_MODINFOMD_KERNEND, &data, len);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
2010-12-27 06:06:41 +00:00
|
|
|
grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part);
|
|
|
|
freebsd_bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) +
|
|
|
|
(unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT));
|
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_loader_set (grub_freebsd_boot, grub_bsd_unload, 0);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_err_t
|
2010-06-10 06:42:03 +00:00
|
|
|
grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2009-10-16 20:21:12 +00:00
|
|
|
grub_uint32_t bootdev;
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
kernel_type = KERNEL_TYPE_OPENBSD;
|
2010-06-10 06:42:03 +00:00
|
|
|
bootflags = grub_bsd_parse_flags (ctxt->state, openbsd_flags);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-06-10 06:42:03 +00:00
|
|
|
if (ctxt->state[OPENBSD_ROOT_ARG].set)
|
2009-10-16 20:21:12 +00:00
|
|
|
{
|
2010-06-10 06:42:03 +00:00
|
|
|
const char *arg = ctxt->state[OPENBSD_ROOT_ARG].arg;
|
2009-10-16 20:21:12 +00:00
|
|
|
int unit, part;
|
|
|
|
if (*(arg++) != 'w' || *(arg++) != 'd')
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2009-12-24 22:53:05 +00:00
|
|
|
"only device specifications of form "
|
|
|
|
"wd<number><lowercase letter> are supported");
|
2009-10-16 20:21:12 +00:00
|
|
|
|
|
|
|
unit = grub_strtoul (arg, (char **) &arg, 10);
|
|
|
|
if (! (arg && *arg >= 'a' && *arg <= 'z'))
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2009-12-24 22:53:05 +00:00
|
|
|
"only device specifications of form "
|
|
|
|
"wd<number><lowercase letter> are supported");
|
2009-10-16 20:21:12 +00:00
|
|
|
|
|
|
|
part = *arg - 'a';
|
|
|
|
|
|
|
|
bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
|
|
|
|
(part << OPENBSD_B_PARTSHIFT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bootdev = 0;
|
|
|
|
|
2010-09-04 03:35:21 +00:00
|
|
|
if (ctxt->state[OPENBSD_SERIAL_ARG].set)
|
2010-01-19 13:29:02 +00:00
|
|
|
{
|
|
|
|
struct grub_openbsd_bootarg_console serial;
|
|
|
|
char *ptr;
|
|
|
|
unsigned port = 0;
|
|
|
|
unsigned speed = 9600;
|
|
|
|
|
|
|
|
grub_memset (&serial, 0, sizeof (serial));
|
|
|
|
|
2010-09-04 03:35:21 +00:00
|
|
|
if (ctxt->state[OPENBSD_SERIAL_ARG].arg)
|
2010-01-19 13:29:02 +00:00
|
|
|
{
|
2010-09-04 03:35:21 +00:00
|
|
|
ptr = ctxt->state[OPENBSD_SERIAL_ARG].arg;
|
2010-01-19 13:29:02 +00:00
|
|
|
if (grub_memcmp (ptr, "com", sizeof ("com") - 1) != 0)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
|
"only com0-com3 are supported");
|
|
|
|
ptr += sizeof ("com") - 1;
|
|
|
|
port = grub_strtoul (ptr, &ptr, 0);
|
|
|
|
if (port >= 4)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
|
"only com0-com3 are supported");
|
|
|
|
if (*ptr == ',')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
speed = grub_strtoul (ptr, &ptr, 0);
|
|
|
|
if (grub_errno)
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
serial.device = (GRUB_OPENBSD_COM_MAJOR << 8) | port;
|
|
|
|
serial.speed = speed;
|
|
|
|
|
|
|
|
grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
|
|
|
|
bootflags |= OPENBSD_RB_SERCONS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct grub_openbsd_bootarg_console serial;
|
|
|
|
|
|
|
|
grub_memset (&serial, 0, sizeof (serial));
|
|
|
|
serial.device = (GRUB_OPENBSD_VGA_MAJOR << 8);
|
|
|
|
grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
|
|
|
|
bootflags &= ~OPENBSD_RB_SERCONS;
|
|
|
|
}
|
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
|
2009-10-16 20:21:12 +00:00
|
|
|
{
|
2010-05-02 14:26:00 +00:00
|
|
|
grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 0);
|
2009-10-16 20:21:12 +00:00
|
|
|
openbsd_root = bootdev;
|
|
|
|
}
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_err_t
|
2010-06-10 06:42:03 +00:00
|
|
|
grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
2010-01-15 11:31:06 +00:00
|
|
|
grub_err_t err;
|
2008-02-19 16:40:45 +00:00
|
|
|
kernel_type = KERNEL_TYPE_NETBSD;
|
2010-06-10 06:42:03 +00:00
|
|
|
bootflags = grub_bsd_parse_flags (ctxt->state, netbsd_flags);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
|
2009-08-24 13:10:12 +00:00
|
|
|
{
|
2010-01-15 11:31:06 +00:00
|
|
|
if (is_elf_kernel)
|
|
|
|
{
|
|
|
|
grub_file_t file;
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2010-01-15 11:31:06 +00:00
|
|
|
if (! file)
|
|
|
|
return grub_errno;
|
|
|
|
|
|
|
|
if (is_64bit)
|
|
|
|
err = grub_netbsd_load_elf_meta64 (relocator, file, &kern_end);
|
|
|
|
else
|
|
|
|
err = grub_netbsd_load_elf_meta32 (relocator, file, &kern_end);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
2010-01-15 10:39:05 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
char bootpath[GRUB_NETBSD_MAX_BOOTPATH_LEN];
|
|
|
|
char *name;
|
|
|
|
name = grub_strrchr (argv[0], '/');
|
|
|
|
if (name)
|
|
|
|
name++;
|
|
|
|
else
|
|
|
|
name = argv[0];
|
|
|
|
grub_memset (bootpath, 0, sizeof (bootpath));
|
|
|
|
grub_strncpy (bootpath, name, sizeof (bootpath) - 1);
|
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_BOOTPATH, bootpath, sizeof (bootpath));
|
|
|
|
}
|
|
|
|
|
2010-06-10 06:42:03 +00:00
|
|
|
if (ctxt->state[NETBSD_ROOT_ARG].set)
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
|
|
|
char root[GRUB_NETBSD_MAX_ROOTDEVICE_LEN];
|
|
|
|
grub_memset (root, 0, sizeof (root));
|
2010-09-04 03:35:21 +00:00
|
|
|
grub_strncpy (root, ctxt->state[NETBSD_ROOT_ARG].arg,
|
2010-01-15 10:39:05 +00:00
|
|
|
sizeof (root) - 1);
|
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_ROOTDEVICE, root, sizeof (root));
|
|
|
|
}
|
2010-09-04 03:35:21 +00:00
|
|
|
if (ctxt->state[NETBSD_SERIAL_ARG].set)
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
|
|
|
struct grub_netbsd_btinfo_serial serial;
|
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
grub_memset (&serial, 0, sizeof (serial));
|
|
|
|
grub_strcpy (serial.devname, "com");
|
|
|
|
|
2010-09-29 20:51:12 +00:00
|
|
|
serial.addr = grub_ns8250_hw_get_port (0);
|
|
|
|
serial.speed = 9600;
|
|
|
|
|
2010-09-04 03:35:21 +00:00
|
|
|
if (ctxt->state[NETBSD_SERIAL_ARG].arg)
|
2010-01-15 10:39:05 +00:00
|
|
|
{
|
2010-09-04 03:35:21 +00:00
|
|
|
ptr = ctxt->state[NETBSD_SERIAL_ARG].arg;
|
2010-01-15 10:48:15 +00:00
|
|
|
if (grub_memcmp (ptr, "com", sizeof ("com") - 1) == 0)
|
|
|
|
{
|
|
|
|
ptr += sizeof ("com") - 1;
|
|
|
|
serial.addr
|
2010-08-25 01:25:18 +00:00
|
|
|
= grub_ns8250_hw_get_port (grub_strtoul (ptr, &ptr, 0));
|
2010-01-15 10:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
serial.addr = grub_strtoul (ptr, &ptr, 0);
|
2010-01-15 10:39:05 +00:00
|
|
|
if (grub_errno)
|
|
|
|
return grub_errno;
|
2010-01-15 10:48:15 +00:00
|
|
|
|
|
|
|
if (*ptr == ',')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
serial.speed = grub_strtoul (ptr, &ptr, 0);
|
|
|
|
if (grub_errno)
|
|
|
|
return grub_errno;
|
|
|
|
}
|
2010-01-15 10:39:05 +00:00
|
|
|
}
|
2010-09-29 20:51:12 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &serial, sizeof (serial));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct grub_netbsd_btinfo_serial cons;
|
|
|
|
|
|
|
|
grub_memset (&cons, 0, sizeof (cons));
|
|
|
|
grub_strcpy (cons.devname, "pc");
|
|
|
|
|
2010-01-15 12:40:37 +00:00
|
|
|
grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &cons, sizeof (cons));
|
2010-01-15 10:39:05 +00:00
|
|
|
}
|
2010-01-15 11:31:06 +00:00
|
|
|
|
2011-09-28 21:45:57 +00:00
|
|
|
grub_netbsd_add_boot_disk_and_wedge ();
|
|
|
|
|
2010-01-15 11:31:06 +00:00
|
|
|
grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 0);
|
2009-08-24 13:10:12 +00:00
|
|
|
}
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
|
|
|
|
int argc, char *argv[])
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
grub_file_t file = 0;
|
|
|
|
char *buf = 0, *curr, *next;
|
|
|
|
int len;
|
|
|
|
|
2010-11-30 18:33:12 +00:00
|
|
|
if (! grub_loader_is_loaded ())
|
2009-08-10 15:42:39 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2009-12-24 22:53:05 +00:00
|
|
|
"you need to load the kernel first");
|
2009-08-10 15:42:39 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
if (kernel_type != KERNEL_TYPE_FREEBSD)
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2010-01-06 22:00:57 +00:00
|
|
|
"only FreeBSD supports environment");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (argc == 0)
|
|
|
|
{
|
2009-12-24 22:53:05 +00:00
|
|
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "no filename");
|
2008-02-19 16:40:45 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2008-02-19 16:40:45 +00:00
|
|
|
if ((!file) || (!file->size))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
len = file->size;
|
|
|
|
buf = grub_malloc (len + 1);
|
|
|
|
if (!buf)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (grub_file_read (file, buf, len) != len)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
buf[len] = 0;
|
|
|
|
|
|
|
|
next = buf;
|
|
|
|
while (next)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
curr = next;
|
|
|
|
next = grub_strchr (curr, '\n');
|
|
|
|
if (next)
|
|
|
|
{
|
|
|
|
|
|
|
|
p = next - 1;
|
|
|
|
while (p > curr)
|
|
|
|
{
|
|
|
|
if ((*p != '\r') && (*p != ' ') && (*p != '\t'))
|
|
|
|
break;
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((p > curr) && (*p == '"'))
|
|
|
|
p--;
|
|
|
|
|
|
|
|
*(p + 1) = 0;
|
|
|
|
next++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*curr == '#')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p = grub_strchr (curr, '=');
|
|
|
|
if (!p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*(p++) = 0;
|
|
|
|
|
|
|
|
if (*curr)
|
|
|
|
{
|
2009-12-29 09:04:06 +00:00
|
|
|
char *name;
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (*p == '"')
|
|
|
|
p++;
|
|
|
|
|
2010-01-20 08:12:47 +00:00
|
|
|
name = grub_xasprintf ("kFreeBSD.%s", curr);
|
2009-12-29 09:04:06 +00:00
|
|
|
if (!name)
|
2008-02-19 16:40:45 +00:00
|
|
|
goto fail;
|
2009-12-29 09:04:06 +00:00
|
|
|
if (grub_env_set (name, p))
|
|
|
|
{
|
|
|
|
grub_free (name);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
grub_free (name);
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
|
|
|
grub_free (buf);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
grub_file_close (file);
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
|
|
|
|
int argc, char *argv[])
|
2008-02-19 16:40:45 +00:00
|
|
|
{
|
|
|
|
grub_file_t file = 0;
|
2009-06-21 15:48:10 +00:00
|
|
|
int modargc;
|
|
|
|
char **modargv;
|
2011-11-30 15:20:13 +00:00
|
|
|
const char *type;
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_err_t err;
|
|
|
|
void *src;
|
2009-08-10 15:42:39 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
if (kernel_type != KERNEL_TYPE_FREEBSD)
|
2010-01-16 10:47:12 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
if (!is_elf_kernel)
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2010-01-06 22:00:57 +00:00
|
|
|
"only ELF kernel supports module");
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
/* List the current modules if no parameter. */
|
|
|
|
if (!argc)
|
|
|
|
{
|
|
|
|
grub_freebsd_list_modules ();
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
return 0;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2008-02-19 16:40:45 +00:00
|
|
|
if ((!file) || (!file->size))
|
|
|
|
goto fail;
|
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_end,
|
|
|
|
file->size);
|
|
|
|
if (err)
|
2008-02-19 16:40:45 +00:00
|
|
|
goto fail;
|
2010-04-21 17:13:45 +00:00
|
|
|
src = get_virtual_current_address (ch);
|
|
|
|
}
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
|
2010-01-11 21:54:40 +00:00
|
|
|
grub_file_read (file, src, file->size);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (grub_errno)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
modargc = argc - 1;
|
|
|
|
modargv = argv + 1;
|
|
|
|
|
|
|
|
if (modargc && (! grub_memcmp (modargv[0], "type=", 5)))
|
|
|
|
{
|
|
|
|
type = &modargv[0][5];
|
|
|
|
modargc--;
|
|
|
|
modargv++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
type = FREEBSD_MODTYPE_RAW;
|
|
|
|
|
|
|
|
err = grub_freebsd_add_meta_module (argv[0], type, modargc, modargv,
|
|
|
|
kern_end, file->size);
|
|
|
|
if (err)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
kern_end = ALIGN_PAGE (kern_end + file->size);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
|
|
|
fail:
|
|
|
|
if (file)
|
|
|
|
grub_file_close (file);
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
|
|
|
return grub_errno;
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 10:47:12 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_netbsd_module_load (char *filename, grub_uint32_t type)
|
|
|
|
{
|
|
|
|
grub_file_t file = 0;
|
|
|
|
void *src;
|
|
|
|
grub_err_t err;
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (filename);
|
2010-01-16 10:47:12 +00:00
|
|
|
if ((!file) || (!file->size))
|
|
|
|
goto fail;
|
|
|
|
|
2010-04-21 17:13:45 +00:00
|
|
|
{
|
|
|
|
grub_relocator_chunk_t ch;
|
|
|
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_end,
|
|
|
|
file->size);
|
|
|
|
if (err)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
src = get_virtual_current_address (ch);
|
|
|
|
}
|
2010-01-16 10:47:12 +00:00
|
|
|
|
|
|
|
grub_file_read (file, src, file->size);
|
|
|
|
if (grub_errno)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
err = grub_netbsd_add_meta_module (filename, type, kern_end, file->size);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
kern_end = ALIGN_PAGE (kern_end + file->size);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (file)
|
|
|
|
grub_file_close (file);
|
|
|
|
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_netbsd_module (grub_command_t cmd,
|
|
|
|
int argc, char *argv[])
|
|
|
|
{
|
|
|
|
grub_uint32_t type;
|
|
|
|
|
|
|
|
if (kernel_type != KERNEL_TYPE_NETBSD)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded");
|
|
|
|
|
|
|
|
if (!is_elf_kernel)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
|
|
"only ELF kernel supports module");
|
|
|
|
|
|
|
|
/* List the current modules if no parameter. */
|
|
|
|
if (!argc)
|
|
|
|
{
|
|
|
|
grub_netbsd_list_modules ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grub_strcmp (cmd->name, "knetbsd_module_elf") == 0)
|
|
|
|
type = GRUB_NETBSD_MODULE_ELF;
|
|
|
|
else
|
|
|
|
type = GRUB_NETBSD_MODULE_RAW;
|
|
|
|
|
|
|
|
return grub_netbsd_module_load (argv[0], type);
|
|
|
|
}
|
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)),
|
|
|
|
int argc, char *argv[])
|
|
|
|
{
|
|
|
|
grub_file_t file = 0;
|
|
|
|
grub_err_t err;
|
|
|
|
|
2010-11-30 18:33:12 +00:00
|
|
|
if (! grub_loader_is_loaded ())
|
2009-08-10 15:42:39 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2009-12-24 22:53:05 +00:00
|
|
|
"you need to load the kernel first");
|
2009-08-10 15:42:39 +00:00
|
|
|
|
2009-06-21 15:48:10 +00:00
|
|
|
if (kernel_type != KERNEL_TYPE_FREEBSD)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2010-01-06 22:00:57 +00:00
|
|
|
"only FreeBSD supports module");
|
2009-06-21 15:48:10 +00:00
|
|
|
|
|
|
|
if (! is_elf_kernel)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
2010-01-06 22:00:57 +00:00
|
|
|
"only ELF kernel supports module");
|
2009-06-21 15:48:10 +00:00
|
|
|
|
|
|
|
/* List the current modules if no parameter. */
|
|
|
|
if (! argc)
|
|
|
|
{
|
|
|
|
grub_freebsd_list_modules ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (argv[0]);
|
2009-06-21 15:48:10 +00:00
|
|
|
if (!file)
|
|
|
|
return grub_errno;
|
|
|
|
if (!file->size)
|
|
|
|
{
|
|
|
|
grub_file_close (file);
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_64bit)
|
2010-01-11 21:54:40 +00:00
|
|
|
err = grub_freebsd_load_elfmodule_obj64 (relocator, file,
|
|
|
|
argc, argv, &kern_end);
|
2009-06-21 15:48:10 +00:00
|
|
|
else
|
2010-01-11 21:54:40 +00:00
|
|
|
err = grub_freebsd_load_elfmodule32 (relocator, file,
|
|
|
|
argc, argv, &kern_end);
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_file_close (file);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-08-26 00:46:30 +00:00
|
|
|
static grub_err_t
|
|
|
|
grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
|
|
|
|
int argc, char *args[])
|
|
|
|
{
|
|
|
|
grub_file_t file;
|
|
|
|
grub_size_t size;
|
|
|
|
|
|
|
|
if (argc != 1)
|
|
|
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
|
|
|
|
|
|
|
if (kernel_type != KERNEL_TYPE_OPENBSD)
|
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded");
|
|
|
|
|
|
|
|
if (!openbsd_ramdisk.max_size)
|
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD doesn't support ramdisk");
|
|
|
|
|
2010-09-05 11:05:36 +00:00
|
|
|
file = grub_file_open (args[0]);
|
2010-08-26 00:46:30 +00:00
|
|
|
if (! file)
|
|
|
|
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
|
|
|
"couldn't load ramdisk");
|
|
|
|
|
|
|
|
size = grub_file_size (file);
|
|
|
|
|
|
|
|
if (size > openbsd_ramdisk.max_size)
|
|
|
|
{
|
|
|
|
grub_file_close (file);
|
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "your kOpenBSD supports ramdisk only"
|
|
|
|
" up to %u bytes, however you supplied a %u bytes one",
|
|
|
|
openbsd_ramdisk.max_size, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grub_file_read (file, openbsd_ramdisk.target, size)
|
|
|
|
!= (grub_ssize_t) (size))
|
|
|
|
{
|
|
|
|
grub_file_close (file);
|
|
|
|
grub_error_push ();
|
|
|
|
return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", args[0]);
|
|
|
|
}
|
|
|
|
grub_memset (openbsd_ramdisk.target + size, 0,
|
|
|
|
openbsd_ramdisk.max_size - size);
|
|
|
|
*openbsd_ramdisk.size = ALIGN_UP (size, 512);
|
|
|
|
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
2009-06-21 15:48:10 +00:00
|
|
|
|
2009-08-23 11:46:25 +00:00
|
|
|
static grub_extcmd_t cmd_freebsd, cmd_openbsd, cmd_netbsd;
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
static grub_command_t cmd_freebsd_loadenv, cmd_freebsd_module;
|
2010-01-16 10:47:12 +00:00
|
|
|
static grub_command_t cmd_netbsd_module, cmd_freebsd_module_elf;
|
2010-08-26 00:46:30 +00:00
|
|
|
static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk;
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
GRUB_MOD_INIT (bsd)
|
|
|
|
{
|
2010-09-05 11:05:36 +00:00
|
|
|
/* Net and OpenBSD kernels are often compressed. */
|
|
|
|
grub_dl_load ("gzio");
|
|
|
|
|
2010-09-14 21:06:01 +00:00
|
|
|
cmd_freebsd = grub_register_extcmd ("kfreebsd", grub_cmd_freebsd, 0,
|
2010-01-03 18:24:22 +00:00
|
|
|
N_("FILE"), N_("Load kernel of FreeBSD."),
|
2009-08-23 11:46:25 +00:00
|
|
|
freebsd_opts);
|
2010-09-14 21:06:01 +00:00
|
|
|
cmd_openbsd = grub_register_extcmd ("kopenbsd", grub_cmd_openbsd, 0,
|
2010-01-03 18:24:22 +00:00
|
|
|
N_("FILE"), N_("Load kernel of OpenBSD."),
|
2009-08-23 11:46:25 +00:00
|
|
|
openbsd_opts);
|
2010-09-14 21:06:01 +00:00
|
|
|
cmd_netbsd = grub_register_extcmd ("knetbsd", grub_cmd_netbsd, 0,
|
2010-01-03 18:24:22 +00:00
|
|
|
N_("FILE"), N_("Load kernel of NetBSD."),
|
2009-08-23 11:46:25 +00:00
|
|
|
netbsd_opts);
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
cmd_freebsd_loadenv =
|
2009-10-14 16:49:22 +00:00
|
|
|
grub_register_command ("kfreebsd_loadenv", grub_cmd_freebsd_loadenv,
|
2010-01-03 18:24:22 +00:00
|
|
|
0, N_("Load FreeBSD env."));
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
cmd_freebsd_module =
|
2009-10-14 16:49:22 +00:00
|
|
|
grub_register_command ("kfreebsd_module", grub_cmd_freebsd_module,
|
2010-01-03 18:24:22 +00:00
|
|
|
0, N_("Load FreeBSD kernel module."));
|
2010-01-16 10:47:12 +00:00
|
|
|
cmd_netbsd_module =
|
|
|
|
grub_register_command ("knetbsd_module", grub_cmd_netbsd_module,
|
|
|
|
0, N_("Load NetBSD kernel module."));
|
|
|
|
cmd_netbsd_module_elf =
|
|
|
|
grub_register_command ("knetbsd_module_elf", grub_cmd_netbsd_module,
|
|
|
|
0, N_("Load NetBSD kernel module (ELF)."));
|
2009-06-21 15:48:10 +00:00
|
|
|
cmd_freebsd_module_elf =
|
2009-10-14 16:49:22 +00:00
|
|
|
grub_register_command ("kfreebsd_module_elf", grub_cmd_freebsd_module_elf,
|
2010-01-03 18:24:22 +00:00
|
|
|
0, N_("Load FreeBSD kernel module (ELF)."));
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-08-26 00:46:30 +00:00
|
|
|
cmd_openbsd_ramdisk = grub_register_command ("kopenbsd_ramdisk",
|
|
|
|
grub_cmd_openbsd_ramdisk, 0,
|
2011-11-11 23:34:14 +00:00
|
|
|
N_("Load kOpenBSD ramdisk."));
|
2010-08-26 00:46:30 +00:00
|
|
|
|
2008-02-19 16:40:45 +00:00
|
|
|
my_mod = mod;
|
|
|
|
}
|
|
|
|
|
|
|
|
GRUB_MOD_FINI (bsd)
|
|
|
|
{
|
2009-08-23 11:46:25 +00:00
|
|
|
grub_unregister_extcmd (cmd_freebsd);
|
|
|
|
grub_unregister_extcmd (cmd_openbsd);
|
|
|
|
grub_unregister_extcmd (cmd_netbsd);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2009-03-21 Bean <bean123ch@gmail.com>
* commands/blocklist.c: Add include file <grub/command.h>, remove
<grub/normal.h> and <grub/arg.h>.
(grub_cmd_blocklist): Use the new command interface.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* commands/boot.c: Likewise.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/configfile.c: Likewise.
* commands/crc.c: Likewise.
* commands/echo.c: Likewise.
* commands/halt.c: Likewise.
* commands/handler.c: Likewise.
* commands/hdparm.c: Likewise.
* commands/help.c: Likewise.
* commands/hexdump.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/ls.c: Likewise.
* commands/lsmmap.c: Likewise.
* commands/lspci.c: Likewise.
* commands/loadenv.c: Likewise.
* commands/read.c: Likewise.
* commands/reboot.c: Likewise.
* commands/search.c: Likewise.
* commands/sleep.c: Likewise.
* commands/test.c: Likewise.
* commands/usbtest.c: Likewise.
* commands/videotest.c: Likewise.
* commands/i386/cpuid.c: Likewise.
* commands/i386/pc/halt.c: Likewise.
* commands/i386/pc/play.c: Likewise.
* commands/i386/pc/pxecmd.c: Likewise.
* commands/i386/pc/vbeinfo.c: Likewise.
* commands/i386/pc/vbetest.c: Likewise.
* commands/ieee1275/suspend.c: Likewise.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* hello/hello.c: Likewise.
* loader/efi/appleloader.c: Likewise.
* loader/efi/chainloader.c: Likewise.
* loader/i386/bsd.c: Likewise.
* loader/i386/efi/linux.c: Likewise.
* loader/i386/ieee1275/linux.c: Likewise.
* loader/i386/linux.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* loader/i386/pc/linux.c: Likewise.
* loader/powerpc/ieee1275/linux.c: Likewise.
* loader/multiboot_loader.c: Likewise.
* term/gfxterm.c: Likewise.
* term/i386/pc/serial.c: Likewise.
* term/terminfo.c: Likewise.
* term/i386/pc/vesafb.c: Removed <grub/arg.h>.
* term/i386/pc/vga.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* util/grub-fstest (cmd_loopback): Removed.
(cmd_blocklist): Likewise.
(cmd_ls): Likewise.
(grub_register_command): Likewise.
(grub_unregister_command): Likewise.
(execute_command): Use grub_command_find to locate command and execute
it.
* include/grub/efi/chainloader.h: Removed.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/bsd_normal.c: Likewise.
* loader/i386/pc/chainloader_normal.c: Likewise.
* loader/i386/pc/multiboot_normal.c: Likewise.
* loader/linux_normal.c: Likewise.
* loader/multiboot_loader_normal.c: Likewise.
* loader/powerpc/ieee1275/linux_normal.c: Likewise.
* gencmdlist.sh: Scan new registration command grub_register_extcmd
and grub_register_command_p1.
* conf/common.rmk (grub_fstest_SOURCES): Add kern/list.c,
kern/command.c, lib/arg.c and commands/extcmd.c.
(pkglib_MODULES): Remove boot.mod, and minicmd.mod and extcmd.mod.
(minicmd_mod_SOURCES): New variable.
(minicmd_mod_CFLAGS): Likewise.
(minicmd_mod_LDFLAGS): Likewise.
(extcmd_mod_SOURCES): Likewise.
(extcmd_mod_CFLAGS): Likewise.
(extcmd_mod_LDFLAGS): Likewise.
(boot_mod_SOURCES): Removed.
(boot_mod_CFLAGS): Likewise.
(boot_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/command.c and
kern/corecmd.c.
(kernel_img_HEADERS): Add command.h.
(grub_emu_SOURCES): Remove commands/boot.c and normal/arg.c, add
commands/minicmd.c, kern/command.c, kern/corecmd.c, commands/extcmd.c
and lib/arg.c.
(pkglib_MODULES): Change _linux.mod, _chain.mod, _bsd.mod and
_multiboot.mod as linux.mod, chain.mod, bsd.mod and multiboot.mod,
remove the corresponding normal mode command.
(normal_mod_SOURCES): Remove normal/arg.c.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/arg.h: Move from here ...
* include/grub/lib/arg.h: ... to here.
* normal/arg.c: Move from here ...
* lib/arg.c: ... to here.
* commands/extcmd.c: New file.
* commands/minicmd.c: Likewise.
* include/grub/command.h: Likewise.
* include/grub/extcmd.h: Likewise.
* kern/command.c: Likewise.
* kern/corecmd.c: Likewise.
* kern/list.c (grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(grub_prio_list_insert): Likewise.
* kern/rescue.c (grub_rescue_command): Removed.
(grub_rescue_command_list): Likewise.
(grub_rescue_register_command): Likewise.
(grub_rescue_unregister_command): Likewise.
(grub_rescue_cmd_boot): Move to minicmd.c
(grub_rescue_cmd_help): Likewise.
(grub_rescue_cmd_info): Likewise.
(grub_rescue_cmd_boot): Likewise.
(grub_rescue_cmd_testload): Likewise.
(grub_rescue_cmd_dump): Likewise.
(grub_rescue_cmd_rmmod): Likewise.
(grub_rescue_cmd_lsmod): Likewise.
(grub_rescue_cmd_exit): Likewise.
(grub_rescue_print_devices): Moved to corecmd.c.
(grub_rescue_print_files): Likewise.
(grub_rescue_cmd_ls): Likewise.
(grub_rescue_cmd_insmod): Likewise.
(grub_rescue_cmd_set): Likewise.
(grub_rescue_cmd_unset): Likewise.
(attemp_normal_mode): Use grub_command_find to get normal module.
(grub_enter_rescue_mode): Use grub_register_core_commands to register
commands, remove grub_rescue_regiter_command calls.
* normal/command.c (grub_regiser_command): Removed.
(grub_unregister_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(rescue_command): Likewise.
(export_command): Moved to corecmd.c.
(set_command): Removed.
(unset_command): Likewise.
(insmod_command): Likewise.
(rmmod_command): Likewise.
(lsmod_command): Likewise.
(grub_command_init): Likewise.
* normal/completion.c (iterate_command): Use cmd->prio to check for
active command.
(complete_arguments): Use grub_extcmd_t structure to find options.
(grub_normal_do_completion): Change function grub_iterate_commands to
grub_command_iterate.
* normal/execute.c (grub_script_execute_cmd): No need to parse
argument here.
* normal/main.c (grub_dyncmd_dispatcher): New function.
(read_command_list): Register unload commands as dyncmd.
(grub_cmd_normal): Use new command interface, register rescue,
unregister normal at entry, register normal, unregister rescue at exit.
* include/grub/list.h (grub_list_test_t): New type.
(grub_list_iterate): Return int instead of void.
(grub_list_insert): New function.
(GRUB_AS_NAMED_LIST_P): New macro.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
(GRUB_PRIO_LIST_PRIO_MASK): New constant.
(GRUB_PRIO_LIST_FLAG_ACTIVE): Likewise.
(grub_prio_list): New structure.
(grub_prio_list_insert): New function.
(grub_prio_list_remove): New inline function.
* include/grub/normal.h: Remove <grub/arg.h>, add <grub/command.h>.
(GRUB_COMMAND_FLAG_CMDLINE): Moved to command.h.
(GRUB_COMMAND_FLAG_MENU): Likewise.
(GRUB_COMMAND_FLAG_BOTH): Likewise.
(GRUB_COMMAND_FLAG_TITLE): Likewise.
(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
(GRUB_COMMAND_FLAG_NO_ARG_PARSE): Removed.
(GRUB_COMMAND_FLAG_NOT_LOADED): Likewise.
(grub_command): Likewise.
(grub_register_command): Likewise.
(grub_command_find): Likewise.
(grub_iterate_commands): Likewise.
(grub_command_init): Likewise.
(grub_arg_parse): Likewise.
(grub_arg_show_help): Likewise.
* include/grub/rescue.h (grub_rescue_register_command): Removed.
(grub_rescue_unregister_command): Likewise.
* include/grub/i386/bsd.h: Remove grub_rescue_cmd_freebsd,
grub_rescue_cmd_openbsd, grub_rescue_cmd_netbsd,
grub_rescue_cmd_freebsd_loadenv and grub_rescue_cmd_freebsd_module.
* include/grub/i386/efi/loader.h: Remove grub_rescue_cmd_linux and
grub_rescue_cmd_initrd.
* include/grub/i386/loader.h: Likewise.
* include/grub/x86_64/loader.h: Likewise.
* include/grub/i386/pc/chainloader.h: Remove grub_chainloader_cmd.
2009-03-21 08:39:59 +00:00
|
|
|
grub_unregister_command (cmd_freebsd_loadenv);
|
|
|
|
grub_unregister_command (cmd_freebsd_module);
|
2010-01-16 10:47:12 +00:00
|
|
|
grub_unregister_command (cmd_netbsd_module);
|
2009-06-21 15:48:10 +00:00
|
|
|
grub_unregister_command (cmd_freebsd_module_elf);
|
2010-01-16 10:47:12 +00:00
|
|
|
grub_unregister_command (cmd_netbsd_module_elf);
|
2010-08-26 00:46:30 +00:00
|
|
|
grub_unregister_command (cmd_openbsd_ramdisk);
|
2008-02-19 16:40:45 +00:00
|
|
|
|
2010-01-15 10:39:05 +00:00
|
|
|
grub_bsd_unload ();
|
2008-02-19 16:40:45 +00:00
|
|
|
}
|