Resync with trunk
This commit is contained in:
commit
3d8b4e4e26
97 changed files with 3461 additions and 1012 deletions
411
ChangeLog
411
ChangeLog
|
@ -1,3 +1,414 @@
|
|||
2010-01-18 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* commands/terminal.c (grub_cmd_terminal_input)
|
||||
(grub_cmd_terminal_output): Check return of terminal init()
|
||||
routines, and abort if errors are raised.
|
||||
|
||||
2010-01-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/i386/bsd.h: Fix include pathes.
|
||||
|
||||
2010-01-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add missing *BSD copyright headers.
|
||||
|
||||
* include/grub/aout.h: Add BSD licence.
|
||||
* include/grub/i386/bsd.h: Parts under different licences moved to ...
|
||||
* include/grub/i386/freebsd_linker.h: ... here,
|
||||
* include/grub/i386/freebsd_reboot.h: ... here,
|
||||
* include/grub/i386/netbsd_bootinfo.h: ... here,
|
||||
* include/grub/i386/netbsd_reboot.h: ... here,
|
||||
* include/grub/i386/openbsd_bootarg.h: ... here,
|
||||
* include/grub/i386/openbsd_reboot.h: ... and here. Added appropriate
|
||||
licence to each file.
|
||||
|
||||
2010-01-18 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* acinclude.m4: Remove `nop' assembly instruction; it's not
|
||||
implemented by all architectures.
|
||||
|
||||
2010-01-18 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* loader/i386/efi/linux.c (grub_cmd_linux): Stop pretending we're
|
||||
ELILO. This is no longer necessary.
|
||||
|
||||
2010-01-18 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
Added new tool, grub-scrit-check to verify grub.cfg syntax.
|
||||
|
||||
* util/grub-script-check.c: grub-script-check tool.
|
||||
* conf/common.rmk: Make rules for grub-script-check.
|
||||
|
||||
2010-01-18 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
Fix annoying UI bug in rescue mode. Thanks to Tristan Gingold for
|
||||
spotting it back in 2008. Shame on me for forgetting he did.
|
||||
|
||||
* kern/rescue_reader.c (grub_rescue_run): Skip zero-length lines.
|
||||
|
||||
2010-01-18 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* include/grub/i386/linux.h (GRUB_VIDEO_TYPE_TEXT): Rename to ...
|
||||
(GRUB_VIDEO_LINUX_TYPE_TEXT): ... this. Update all users.
|
||||
(GRUB_VIDEO_TYPE_VLFB): Rename to ...
|
||||
(GRUB_VIDEO_LINUX_TYPE_VESA): ... this. Update all users.
|
||||
(GRUB_VIDEO_TYPE_EFI): Rename to ...
|
||||
(GRUB_VIDEO_LINUX_TYPE_SIMPLE): ... this. Update all users.
|
||||
|
||||
2010-01-17 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* include/grub/test.h: Add license header.
|
||||
* tests/example_functional_test.c: Likewise.
|
||||
* tests/example_unit_test.c: Likewise.
|
||||
* tests/lib/functional_test.c: Likewise.
|
||||
* tests/lib/test.c: Likewise.
|
||||
* tests/lib/unit_test.c: Likewise.
|
||||
|
||||
2010-01-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Use flag-based instead of hook-based video mode selection and "auto"
|
||||
keyword.
|
||||
|
||||
* include/grub/video.h (grub_video_adapter): Changed 'setup' member.
|
||||
(grub_video_set_mode): Changed prototype. All users updated.
|
||||
(grub_video_check_mode_flag): New inline function.
|
||||
* video/video.c (parse_modespec): New function.
|
||||
(grub_video_set_mode): Parse flags and keywords.
|
||||
|
||||
2010-01-17 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* util/misc.c (grub_util_info): Fix the order of the parameters in a
|
||||
fprintf call.
|
||||
|
||||
2010-01-16 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||
|
||||
* genmk.rb (class SCRIPT): Replace option -i of sed by a pipe.
|
||||
|
||||
2010-01-16 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* util/grub-editenv.c (usage): Use `program_name' instead of hardcoded
|
||||
string.
|
||||
* util/grub-emu.c (usage): Likewise.
|
||||
* util/grub-mkpasswd-pbkdf2.c (usage): Likewise.
|
||||
* util/i386/efi/grub-mkimage.c (usage): Likewise.
|
||||
* util/i386/pc/grub-mkimage.c (usage): Likewise.
|
||||
* util/i386/pc/grub-setup.c (usage): Likewise.
|
||||
|
||||
2010-01-16 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* util/misc.c (grub_util_warn): Gettextizze, print full stop after
|
||||
the message.
|
||||
(grub_util_info): Likewise.
|
||||
(grub_util_error): Likewise.
|
||||
* util/elf/grub-mkimage.c: Fix capitalisation, quotes, full stops
|
||||
and/or new lines in `grub_util_warna', `grub_util_info',
|
||||
`grub_util_error' calls.
|
||||
* util/getroot.c: Likewise.
|
||||
* util/grub-editenv.c: Likewise.
|
||||
* util/grub-emu.c: Likewise.
|
||||
* util/grub-fstest.c: Likewise.
|
||||
* util/grub-mkdevicemap.c: Likewise.
|
||||
* util/grub-mkfont.c: Likewise.
|
||||
* util/grub-mkpasswd-pbkdf2.c: Likewise.
|
||||
* util/grub-mkrelpath.c: Likewise.
|
||||
* util/grub-pe2elf.c: Likewise.
|
||||
* util/grub-probe.c: Likewise.
|
||||
* util/hostdisk.c: Likewise.
|
||||
* util/i386/efi/grub-mkimage.c: Likewise.
|
||||
* util/i386/pc/grub-mkimage.c: Likewise.
|
||||
* util/i386/pc/grub-setup.c: Likewise.
|
||||
* util/ieee1275/ofpath.c: Likewise.
|
||||
* util/mkisofs/eltorito.c: Likewise.
|
||||
* util/mkisofs/rock.c: Likewise.
|
||||
* util/mkisofs/write.c: Likewise.
|
||||
* util/raid.c: Likewise.
|
||||
* util/sparc64/ieee1275/grub-mkimage.c: Likewise.
|
||||
* util/sparc64/ieee1275/grub-setup.c: Likewise.
|
||||
|
||||
2010-01-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Enable multiboot on non-pc.
|
||||
|
||||
* conf/i386-coreboot.rmk, conf/i386-pc.rmk (pkglib_MODULES): Move
|
||||
multiboot.mod and multiboot2.mod to ...
|
||||
* conf/i386.rmk (pkglib_MODULES): ... here.
|
||||
* conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_SOURCES):
|
||||
Moved to ...
|
||||
* conf/i386.rmk (multiboot_mod_SOURCES): .. here.
|
||||
* conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_CFLAGS):
|
||||
Moved to ...
|
||||
* conf/i386.rmk (multiboot_mod_CFLAGS): .. here.
|
||||
* conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_ASFLAGS):
|
||||
Moved to ...
|
||||
* conf/i386.rmk (multiboot_mod_ASFLAGS): .. here.
|
||||
* conf/i386-coreboot.rmk, conf/i386-pc.rmk (multiboot_mod_LDFLAGS):
|
||||
Moved to ...
|
||||
* conf/i386.rmk (multiboot_mod_LDFLAGS): .. here.
|
||||
* conf/x86_64-efi.rmk (pkglib_MODULES): Remove ata.mod and
|
||||
relocator.mod.
|
||||
(ata_mod_SOURCES): Removed.
|
||||
(ata_mod_CFLAGS): Likewise.
|
||||
(ata_mod_LDFLAGS): Likewise.
|
||||
(relocator_mod_SOURCES): Removed.
|
||||
(relocator_mod_CFLAGS): Likewise.
|
||||
(relocator_mod_ASFLAGS): Likewise.
|
||||
(relocator_mod_LDFLAGS): Likewise.
|
||||
Include i386.mk.
|
||||
* include/grub/x86_64/multiboot.h: New file.
|
||||
* loader/i386/multiboot.c (grub_multiboot_boot) [GRUB_MACHINE_EFI]:
|
||||
Terminate EFI.
|
||||
|
||||
2010-01-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Video multiboot support.
|
||||
|
||||
* include/grub/multiboot.h (grub_multiboot_set_accepts_video):
|
||||
New prototype.
|
||||
* include/multiboot.h: Resynced with multiboot specification.
|
||||
* include/multiboot2.h: Likewise.
|
||||
* loader/i386/multiboot.c (UNSUPPORTED_FLAGS): Support video flags.
|
||||
(grub_multiboot): Parse MULTIBOOT_VIDEO_MODE fields.
|
||||
* loader/i386/multiboot_mbi.c (DEFAULT_VIDEO_MODE): New constant.
|
||||
(HAS_VGA_TEXT): Likewise.
|
||||
(accepts_video): New variable.
|
||||
(grub_multiboot_set_accepts_video): New function.
|
||||
(grub_multiboot_get_mbi_size): Account for video structures.
|
||||
(set_video_mode): New function.
|
||||
(retrieve_video_parameters): Likewise.
|
||||
(grub_multiboot_make_mbi): Fill video fields.
|
||||
|
||||
2010-01-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Video driver ids.
|
||||
|
||||
* include/grub/video.h (grub_video_driver_id): New type.
|
||||
(grub_video_adapter): New member 'id'. All users updated.
|
||||
(grub_video_get_driver_id): New proto.
|
||||
* video/video.c (grub_video_get_driver_id): New function.
|
||||
|
||||
2010-01-14 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* util/grub.d/30_os-prober.in: Use `set var=val' rather than plain
|
||||
`var=val'.
|
||||
|
||||
2010-01-14 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* normal/cmdline.c (print_completion): Gettextizze.
|
||||
|
||||
2001-01-14 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* loader/i386/pc/chainloader.c: Include `<grub/mm.h>'.
|
||||
|
||||
2010-01-14 Carles Pina i Estany <carles@pina.cat>
|
||||
|
||||
* gettext/gettext.c (grub_gettext_translate): Push and pop
|
||||
grub_errno.
|
||||
(grub_gettext_delete_list): Change comment style.
|
||||
* kern/err.c (grub_error): Gettextizze.
|
||||
(grub_fatal): Gettextizze.
|
||||
|
||||
2010-01-14 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* include/grub/i386/loader.h (grub_linux16_boot): Renamed to ...
|
||||
(grub_linux16_real_boot): ... this.
|
||||
* kern/i386/loader.S: Likewise.
|
||||
* loader/i386/pc/linux.c: Include `<grub/video.h>' and `<grub/mm.h>'.
|
||||
(grub_linux16_boot): New function. Switches to text mode and calls
|
||||
grub_linux16_real_boot().
|
||||
|
||||
* loader/i386/bsd.c: Include `<grub/video.h>'.
|
||||
(grub_freebsd_boot, grub_openbsd_boot, grub_netbsd_boot): Switch to
|
||||
text mode before calling grub_unix_real_boot().
|
||||
|
||||
* loader/i386/multiboot.c: Include `<grub/video.h>'.
|
||||
(grub_multiboot_boot): Switch to text mode before calling
|
||||
grub_relocator32_boot().
|
||||
|
||||
* loader/i386/pc/chainloader.c: Include `<grub/video.h>'.
|
||||
(grub_chainloader_boot): Switch to text mode before calling
|
||||
grub_chainloader_real_boot().
|
||||
|
||||
2010-01-05 Jordan Uggla <jordan.uggla@gmail.com>
|
||||
2010-01-05 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-reboot.in: Make sure prev_saved_entry always gets a
|
||||
non-empty value.
|
||||
|
||||
2010-01-05 Jordan Uggla <jordan.uggla@gmail.com>
|
||||
2010-01-05 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/00_header.in: Define a "savedefault" function for use
|
||||
in menu entries.
|
||||
* util/grub-mkconfig_lib.in (save_default_entry): Use it.
|
||||
|
||||
2010-01-05 Jordan Uggla <jordan.uggla@gmail.com>
|
||||
2010-01-05 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-mkconfig_lib.in (save_default_entry): Only set
|
||||
saved_entry if boot_once is unset.
|
||||
* util/grub.d/00_header.in: Set boot_once to "true" if there was a
|
||||
previous saved entry (i.e. grub-reboot).
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/30_os-prober.in: Call save_default_entry for hurd.
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/00_header.in: Use `set var=val' rather than plain
|
||||
`var=val'.
|
||||
* util/grub-mkconfig_lib.in (save_default_entry): Likewise.
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-reboot.in: Fix --version output.
|
||||
* util/grub-set-default.in: Likewise.
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/00_header.in: Silently ignore zero-sized environment
|
||||
blocks.
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/00_header.in: Quote the value assigned to `default',
|
||||
in case it contains spaces.
|
||||
|
||||
2009-12-08 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub.d/30_os-prober.in: Fix merge error that moved a
|
||||
`save_default_entry' call from the macosx case to the linux case.
|
||||
|
||||
2009-10-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
2009-10-25 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* normal/menu.c (grub_menu_execute_entry): Save selected entry title
|
||||
in `chosen' environment variable.
|
||||
* normal/menu_text.c (get_entry_number): Check if the variable
|
||||
matches the title of a menu entry.
|
||||
(run_menu): Pass menu to get_entry_number.
|
||||
|
||||
* util/grub-reboot.in: New file.
|
||||
* util/grub-set-default.in: New file.
|
||||
* conf/common.rmk (grub-reboot): New utility.
|
||||
(grub-set-default): New utility.
|
||||
|
||||
* util/grub-mkconfig_lib.in (save_default_entry): New function.
|
||||
* util/grub.d/00_header.in: If GRUB_DEFAULT is `saved', set
|
||||
default to `${saved_entry}'. If `${prev_saved_entry}' is non-empty,
|
||||
move it to `saved_entry' for the next boot. Load environment on
|
||||
initialisation.
|
||||
* util/grub.d/10_kfreebsd.in: Call save_default_entry.
|
||||
* util/grub.d/10_hurd.in: Likewise.
|
||||
* util/grub.d/10_linux.in (linux_entry): Likewise.
|
||||
* util/grub.d/10_windows.in: Likewise.
|
||||
* util/grub.d/30_os-prober.in: Likewise.
|
||||
|
||||
* util/grub-install.in: Create environment block.
|
||||
* util/i386/efi/grub-install.in: Likewise.
|
||||
* util/ieee1275/grub-install.in: Likewise.
|
||||
* util/sparc64/ieee1275/grub-install.in: Likewise.
|
||||
|
||||
2010-01-14 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
Unit testing framework for GRUB.
|
||||
|
||||
* Makefile.in: Test framework build rules for 'make check'.
|
||||
* conf/tests.rmk: Build rules for individual tests and framework.
|
||||
|
||||
* include/grub/test.h: Header file for whitebox tests.
|
||||
* tests/lib/functional_test.c: Framework support for whitebox
|
||||
functional tests.
|
||||
* tests/lib/test.c: Common whitebox testing code for unit and
|
||||
functional tests.
|
||||
* tests/lib/unit_test.c: Framework support for whitebox unit
|
||||
tests.
|
||||
|
||||
* tests/util/grub-shell-tester.in: Support utility for grub-script
|
||||
tests.
|
||||
* tests/util/grub-shell.in: Utility to execute grub-script
|
||||
commands in a Qemu instance.
|
||||
|
||||
* tests/example_functional_test.c: Example whitebox functional
|
||||
test.
|
||||
* tests/example_grub_script_test.in: Example grub-script test.
|
||||
* tests/example_scripted_test.in: Example scripted test.
|
||||
* tests/example_unit_test.c: Example whitebox unit test.
|
||||
|
||||
2010-01-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* conf/i386-coreboot.rmk (multiboot_mod_SOURCES):
|
||||
Add loader/i386/multiboot_mbi.c.
|
||||
(multiboot2_mod_SOURCES): Likewise.
|
||||
* conf/i386-pc.rmk (multiboot_mod_SOURCES): Likewise.
|
||||
(multiboot2_mod_SOURCES): Likewise.
|
||||
* include/grub/multiboot.h (grub_multiboot_get_mbi_size): New proto.
|
||||
(grub_multiboot_make_mbi): Likewise.
|
||||
(grub_multiboot_free_mbi): Likewise.
|
||||
(grub_multiboot_init_mbi): Likewise.
|
||||
(grub_multiboot_add_module): Likewise.
|
||||
(grub_multiboot_set_bootdev): Likewise.
|
||||
* loader/i386/multiboot.c (mbi): Removed.
|
||||
(mbi_dest): Likewise.
|
||||
(alloc_mbi): New variable.
|
||||
(grub_multiboot_payload_size): Removed. All users updated.
|
||||
(grub_multiboot_pure_size): New variable.
|
||||
(grub_multiboot_boot): Use grub_multiboot_make_mbi.
|
||||
(grub_multiboot_unload): Use grub_multiboot_free_mbi.
|
||||
(grub_get_multiboot_mmap_len): Moved to loader/i386/multiboot_mbi.c.
|
||||
(grub_fill_multiboot_mmap): Likewise.
|
||||
(grub_multiboot_get_bootdev): Likewise.
|
||||
(grub_multiboot): Use multiboot_mbi functions.
|
||||
* loader/i386/multiboot_mbi.c: New file.
|
||||
|
||||
2010-01-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/efi/init.c (grub_efi_fini): Don't call grub_efi_mm_fini as
|
||||
it would result in module crash.
|
||||
|
||||
2010-01-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* term/ieee1275/ofconsole.c (grub_ofconsole_putchar): Handle '\r'.
|
||||
(grub_ofconsole_getwh): Split to ...
|
||||
(grub_ofconsole_getwh): ... this.
|
||||
(grub_ofconsole_dimensions): ...and this.
|
||||
(grub_ofconsole_init_output): Call grub_ofconsole_dimensions.
|
||||
|
||||
2010-01-13 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* util/mkisofs/rock.c (generate_rock_ridge_attributes): Fix a typo.
|
||||
|
||||
2010-01-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* loader/i386/pc/multiboot2.c: Removed stalled file.
|
||||
|
||||
2010-01-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkpasswd-pbkdf2.c (main): Use grub_util_init_nls.
|
||||
Reported by: Grégoire Sutre
|
||||
|
||||
2010-01-11 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* util/misc.c (canonicalize_file_name): New function.
|
||||
(make_system_path_relative_to_its_root): Use canonicalize_file_name()
|
||||
instead of realpath().
|
||||
|
||||
2010-01-11 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-install.in (usage): Clarify meaning of --root-directory,
|
||||
and make it clearer that it's optional. Based on confusion
|
||||
witnessed on IRC.
|
||||
|
||||
2010-01-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* term/i386/pc/vga_text.c (inc_y): Fix off-by-one error which resulted
|
||||
in premature implicit newline.
|
||||
|
||||
2010-01-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* normal/cmdline.c (grub_cmdline_get): Fix off-by-one error
|
||||
which resulted in garbled command line at the end of screen.
|
||||
|
||||
2010-01-10 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* loader/i386/ieee1275/linux.c (grub_linux_boot): Rework video position
|
||||
|
|
23
Makefile.in
23
Makefile.in
|
@ -167,6 +167,8 @@ ifeq ($(platform), emu)
|
|||
include $(srcdir)/conf/any-emu.mk
|
||||
else
|
||||
include $(srcdir)/conf/$(target_cpu)-$(platform).mk
|
||||
# For tests.
|
||||
include $(srcdir)/conf/tests.mk
|
||||
# For external modules.
|
||||
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
|
||||
endif
|
||||
|
@ -469,7 +471,26 @@ distcheck: dist
|
|||
@echo "$(distdir).tar.gz is ready for distribution" | \
|
||||
sed 'h;s/./=/g;p;x;p;x'
|
||||
|
||||
check:
|
||||
check: all $(UNIT_TESTS) $(FUNCTIONAL_TESTS) $(SCRIPTED_TESTS)
|
||||
@list="$(UNIT_TESTS)"; \
|
||||
for file in $$list; do \
|
||||
$(builddir)/$$file; \
|
||||
done
|
||||
@list="$(FUNCTIONAL_TESTS)"; \
|
||||
for file in $$list; do \
|
||||
mod=`basename $$file .mod`; \
|
||||
echo "insmod functional_test; insmod $$mod; functional_test" \
|
||||
| $(builddir)/grub-shell; \
|
||||
done
|
||||
@list="$(SCRIPTED_TESTS)"; \
|
||||
for file in $$list; do \
|
||||
echo "$$file:"; \
|
||||
if $(builddir)/$$file; then \
|
||||
echo "$$file: PASS"; \
|
||||
else \
|
||||
echo "$$file: FAIL"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
.SUFFIX:
|
||||
.SUFFIX: .c .o .S .d
|
||||
|
|
|
@ -18,7 +18,7 @@ AC_DEFUN(grub_PROG_TARGET_CC,
|
|||
[AC_MSG_CHECKING([whether target compiler is working])
|
||||
AC_CACHE_VAL(grub_cv_prog_target_cc,
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
asm (".globl start; start: nop");
|
||||
asm (".globl start; start:");
|
||||
int main (void);
|
||||
]], [[]])],
|
||||
[grub_cv_prog_target_cc=yes],
|
||||
|
|
|
@ -112,10 +112,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
@ -152,10 +153,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
@ -269,10 +271,11 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
@ -310,10 +313,11 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
|||
break;
|
||||
if (term)
|
||||
{
|
||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
|
|
@ -31,9 +31,7 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
if (grub_video_set_mode ("1024x768;800x600;640x480", 0) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_err_t err;
|
||||
grub_video_color_t color;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
|
@ -50,6 +48,10 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
const char *str;
|
||||
int texty;
|
||||
|
||||
err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
grub_video_get_viewport (&x, &y, &width, &height);
|
||||
|
||||
grub_video_create_render_target (&text_layer, width, height,
|
||||
|
@ -153,12 +155,13 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
|
||||
for (i = 0; i < 255; i++)
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
color = grub_video_map_rgb (i, 33, 77);
|
||||
grub_video_fill_rect (color, 0, 0, width, height);
|
||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, 0, 0,
|
||||
0, 0, width, height);
|
||||
grub_video_swap_buffers ();
|
||||
}
|
||||
|
||||
grub_getkey ();
|
||||
|
|
|
@ -91,11 +91,32 @@ grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
|||
bin_UTILITIES += grub-bin2h
|
||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||
|
||||
# For grub-script-check.
|
||||
bin_UTILITIES += grub-script-check
|
||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||
grub_script_check_SOURCES = gnulib/progname.c util/grub-script-check.c util/misc.c \
|
||||
script/main.c script/script.c script/function.c script/lexer.c \
|
||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c
|
||||
|
||||
# For the parser.
|
||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
||||
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
|
||||
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
|
||||
|
||||
# For grub-script-check.
|
||||
grub_script_check_init.lst: geninit.sh $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES))
|
||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
||||
DISTCLEANFILES += grub_script_check_init.lst
|
||||
|
||||
grub_script_check_init.h: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninitheader.sh
|
||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
||||
DISTCLEANFILES += grub_script_check_init.h
|
||||
|
||||
grub_script_check_init.c: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninit.sh
|
||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
||||
DISTCLEANFILES += grub_script_check_init.c
|
||||
|
||||
# For grub-probe.
|
||||
grub_probe_init.lst: geninit.sh $(filter-out grub_probe_init.c,$(grub_probe_SOURCES))
|
||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
||||
|
@ -188,6 +209,20 @@ CLEANFILES += $(grub-mkconfig_SCRIPTS)
|
|||
|
||||
grub-mkconfig_DATA += util/grub.d/README
|
||||
|
||||
# For grub-set-default.
|
||||
grub-set-default: util/grub-set-default.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
sbin_SCRIPTS += grub-set-default
|
||||
CLEANFILES += grub-set-default
|
||||
|
||||
# For grub-reboot.
|
||||
grub-reboot: util/grub-reboot.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
sbin_SCRIPTS += grub-reboot
|
||||
CLEANFILES += grub-reboot
|
||||
|
||||
# Filing systems.
|
||||
pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \
|
||||
ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \
|
||||
|
|
|
@ -140,20 +140,6 @@ serial_mod_SOURCES = term/i386/pc/serial.c
|
|||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot.mod
|
||||
multiboot_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot2.mod
|
||||
multiboot2_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For aout.mod.
|
||||
aout_mod_SOURCES = loader/aout.c
|
||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
|
|
@ -201,20 +201,6 @@ serial_mod_SOURCES = term/i386/pc/serial.c
|
|||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot.mod
|
||||
multiboot_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot2.mod
|
||||
multiboot2_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
# For vbe.mod.
|
||||
vbe_mod_SOURCES = video/i386/pc/vbe.c
|
||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
|
|
@ -25,3 +25,19 @@ pkglib_MODULES += ata.mod
|
|||
ata_mod_SOURCES = disk/ata.c
|
||||
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot.mod
|
||||
multiboot_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/i386/multiboot_mbi.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += multiboot2.mod
|
||||
multiboot2_mod_SOURCES = loader/i386/multiboot.c \
|
||||
loader/i386/multiboot_mbi.c \
|
||||
loader/multiboot_loader.c
|
||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
|
50
conf/tests.rmk
Normal file
50
conf/tests.rmk
Normal file
|
@ -0,0 +1,50 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
# For grub-shell
|
||||
grub-shell: tests/util/grub-shell.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
check_SCRIPTS += grub-shell
|
||||
CLEANFILES += grub-shell
|
||||
|
||||
# For grub-shell-tester
|
||||
grub-shell-tester: tests/util/grub-shell-tester.in config.status
|
||||
./config.status --file=$@:$<
|
||||
chmod +x $@
|
||||
check_SCRIPTS += grub-shell-tester
|
||||
CLEANFILES += grub-shell-tester
|
||||
|
||||
pkglib_MODULES += functional_test.mod
|
||||
functional_test_mod_SOURCES = tests/lib/functional_test.c tests/lib/test.c
|
||||
functional_test_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# Rules for unit tests
|
||||
check_UTILITIES += example_unit_test
|
||||
example_unit_test_SOURCES = tests/example_unit_test.c kern/list.c kern/misc.c tests/lib/test.c tests/lib/unit_test.c
|
||||
example_unit_test_CFLAGS = -Wno-format
|
||||
|
||||
# Rules for functional tests
|
||||
pkglib_MODULES += example_functional_test.mod
|
||||
example_functional_test_mod_SOURCES = tests/example_functional_test.c
|
||||
example_functional_test_mod_CFLAGS = -Wno-format $(COMMON_CFLAGS)
|
||||
example_functional_test_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# Rules for scripted tests
|
||||
check_SCRIPTS += example_scripted_test
|
||||
example_scripted_test_SOURCES = tests/example_scripted_test.in
|
||||
|
||||
check_SCRIPTS += example_grub_script_test
|
||||
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
||||
|
||||
|
||||
# List of tests to execute on "make check"
|
||||
SCRIPTED_TESTS = example_scripted_test
|
||||
SCRIPTED_TESTS += example_grub_script_test
|
||||
UNIT_TESTS = example_unit_test
|
||||
FUNCTIONAL_TESTS = example_functional_test.mod
|
||||
|
||||
# dependencies between tests and testing-tools
|
||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
||||
$(FUNCTIONAL_TESTS): functional_test.mod
|
||||
|
|
@ -32,7 +32,7 @@ grub_install_SOURCES = util/i386/efi/grub-install.in
|
|||
pkglib_MODULES = kernel.img chain.mod appleldr.mod \
|
||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
||||
fixvideo.mod mmap.mod acpi.mod ata.mod
|
||||
fixvideo.mod mmap.mod acpi.mod
|
||||
|
||||
# For kernel.img.
|
||||
kernel_img_EXPORTS = no
|
||||
|
@ -77,11 +77,6 @@ acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
|||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For ata.mod
|
||||
ata_mod_SOURCES = disk/ata.c
|
||||
ata_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For mmap.mod.
|
||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
||||
mmap/efi/mmap.c
|
||||
|
@ -166,10 +161,5 @@ xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
|
||||
pkglib_MODULES += relocator.mod
|
||||
relocator_mod_SOURCES = lib/i386/relocator.c lib/i386/relocator_asm.S lib/i386/relocator_backward.S
|
||||
relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/i386.mk
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
3
genmk.rb
3
genmk.rb
|
@ -370,8 +370,7 @@ class Script
|
|||
"CLEANFILES += #{@name}
|
||||
|
||||
#{@name}: #{src} $(#{src}_DEPENDENCIES) config.status
|
||||
./config.status --file=#{name}:#{src}
|
||||
sed -i -e 's,@pkglib_DATA@,$(pkglib_DATA),g' $@
|
||||
./config.status --file=-:#{src} | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@
|
||||
chmod +x $@
|
||||
|
||||
"
|
||||
|
|
|
@ -148,14 +148,24 @@ grub_gettext_translate (const char *orig)
|
|||
|
||||
struct grub_gettext_msg *cur;
|
||||
|
||||
/* Make sure we can use grub_gettext_translate for error messages. Push
|
||||
active error message to error stack and reset error message. */
|
||||
grub_error_push ();
|
||||
|
||||
cur = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_gettext_msg_list),
|
||||
orig);
|
||||
|
||||
if (cur)
|
||||
{
|
||||
grub_error_pop ();
|
||||
return cur->translated;
|
||||
}
|
||||
|
||||
if (fd_mo == 0)
|
||||
{
|
||||
grub_error_pop ();
|
||||
return orig;
|
||||
}
|
||||
|
||||
min = 0;
|
||||
max = grub_gettext_max;
|
||||
|
@ -205,6 +215,7 @@ grub_gettext_translate (const char *orig)
|
|||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_error_pop ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -308,7 +319,7 @@ grub_gettext_delete_list (void)
|
|||
char *original = (char *) ((struct grub_gettext_msg *) item)->name;
|
||||
grub_free (original);
|
||||
|
||||
// Don't delete the translated message because could be in use.
|
||||
/* Don't delete the translated message because could be in use. */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,38 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)exec.h 8.1 (Berkeley) 6/11/93
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef GRUB_AOUT_HEADER
|
||||
#define GRUB_AOUT_HEADER 1
|
||||
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
#define GRUB_BSD_CPU_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/i386/freebsd_reboot.h>
|
||||
#include <grub/i386/netbsd_reboot.h>
|
||||
#include <grub/i386/openbsd_reboot.h>
|
||||
#include <grub/i386/freebsd_linker.h>
|
||||
#include <grub/i386/netbsd_bootinfo.h>
|
||||
#include <grub/i386/openbsd_bootarg.h>
|
||||
|
||||
|
||||
enum bsd_kernel_types
|
||||
{
|
||||
|
@ -31,62 +38,15 @@ enum bsd_kernel_types
|
|||
|
||||
#define GRUB_BSD_TEMP_BUFFER 0x80000
|
||||
|
||||
#define FREEBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define FREEBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define FREEBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define FREEBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define FREEBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define FREEBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
|
||||
#define FREEBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define FREEBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define FREEBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define FREEBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define FREEBSD_RB_CONFIG (1 << 10) /* invoke user configuration routing */
|
||||
#define FREEBSD_RB_VERBOSE (1 << 11) /* print all potentially useful info */
|
||||
#define FREEBSD_RB_SERIAL (1 << 12) /* user serial port as console */
|
||||
#define FREEBSD_RB_CDROM (1 << 13) /* use cdrom as root */
|
||||
#define FREEBSD_RB_GDB (1 << 15) /* use GDB remote debugger instead of DDB */
|
||||
#define FREEBSD_RB_MUTE (1 << 16) /* Come up with the console muted */
|
||||
#define FREEBSD_RB_PAUSE (1 << 20)
|
||||
#define FREEBSD_RB_QUIET (1 << 21)
|
||||
#define FREEBSD_RB_NOINTR (1 << 28)
|
||||
#define FREENSD_RB_MULTIPLE (1 << 29) /* Use multiple consoles */
|
||||
#define FREEBSD_RB_DUAL FREENSD_RB_MULTIPLE
|
||||
#define FREEBSD_RB_BOOTINFO (1 << 31) /* have `struct bootinfo *' arg */
|
||||
|
||||
#define FREEBSD_B_DEVMAGIC 0xa0000000
|
||||
#define FREEBSD_B_SLICESHIFT 20
|
||||
#define FREEBSD_B_UNITSHIFT 16
|
||||
#define FREEBSD_B_PARTSHIFT 8
|
||||
#define FREEBSD_B_TYPESHIFT 0
|
||||
#define FREEBSD_B_DEVMAGIC OPENBSD_B_DEVMAGIC
|
||||
#define FREEBSD_B_SLICESHIFT OPENBSD_B_CTRLSHIFT
|
||||
#define FREEBSD_B_UNITSHIFT OPENBSD_B_UNITSHIFT
|
||||
#define FREEBSD_B_PARTSHIFT OPENBSD_B_PARTSHIFT
|
||||
#define FREEBSD_B_TYPESHIFT OPENBSD_B_TYPESHIFT
|
||||
|
||||
#define FREEBSD_BOOTINFO_VERSION 1
|
||||
#define FREEBSD_N_BIOS_GEOM 8
|
||||
|
||||
#define FREEBSD_MODINFO_END 0x0000 /* End of list */
|
||||
#define FREEBSD_MODINFO_NAME 0x0001 /* Name of module (string) */
|
||||
#define FREEBSD_MODINFO_TYPE 0x0002 /* Type of module (string) */
|
||||
#define FREEBSD_MODINFO_ADDR 0x0003 /* Loaded address */
|
||||
#define FREEBSD_MODINFO_SIZE 0x0004 /* Size of module */
|
||||
#define FREEBSD_MODINFO_EMPTY 0x0005 /* Has been deleted */
|
||||
#define FREEBSD_MODINFO_ARGS 0x0006 /* Parameters string */
|
||||
#define FREEBSD_MODINFO_METADATA 0x8000 /* Module-specfic */
|
||||
|
||||
#define FREEBSD_MODINFOMD_AOUTEXEC 0x0001 /* a.out exec header */
|
||||
#define FREEBSD_MODINFOMD_ELFHDR 0x0002 /* ELF header */
|
||||
#define FREEBSD_MODINFOMD_SSYM 0x0003 /* start of symbols */
|
||||
#define FREEBSD_MODINFOMD_ESYM 0x0004 /* end of symbols */
|
||||
#define FREEBSD_MODINFOMD_DYNAMIC 0x0005 /* _DYNAMIC pointer */
|
||||
#define FREEBSD_MODINFOMD_ENVP 0x0006 /* envp[] */
|
||||
#define FREEBSD_MODINFOMD_HOWTO 0x0007 /* boothowto */
|
||||
#define FREEBSD_MODINFOMD_KERNEND 0x0008 /* kernend */
|
||||
#define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */
|
||||
#define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */
|
||||
|
||||
#define FREEBSD_MODINFOMD_SMAP 0x1001
|
||||
|
||||
#define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */
|
||||
|
||||
#define FREEBSD_MODTYPE_KERNEL "elf kernel"
|
||||
#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel"
|
||||
#define FREEBSD_MODTYPE_ELF_MODULE "elf module"
|
||||
|
@ -113,44 +73,6 @@ struct grub_freebsd_bootinfo
|
|||
grub_uint32_t bi_modulep;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define OPENBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define OPENBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define OPENBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define OPENBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define OPENBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define OPENBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
|
||||
#define OPENBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define OPENBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define OPENBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define OPENBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define OPENBSD_RB_CONFIG (1 << 10) /* change configured devices */
|
||||
#define OPENBSD_RB_TIMEBAD (1 << 11) /* don't call resettodr() in boot() */
|
||||
#define OPENBSD_RB_POWERDOWN (1 << 12) /* attempt to power down machine */
|
||||
#define OPENBSD_RB_SERCONS (1 << 13) /* use serial console if available */
|
||||
#define OPENBSD_RB_USERREQ (1 << 14) /* boot() called at user request (e.g. ddb) */
|
||||
|
||||
#define OPENBSD_B_DEVMAGIC 0xa0000000
|
||||
#define OPENBSD_B_ADAPTORSHIFT 24
|
||||
#define OPENBSD_B_CTRLSHIFT 20
|
||||
#define OPENBSD_B_UNITSHIFT 16
|
||||
#define OPENBSD_B_PARTSHIFT 8
|
||||
#define OPENBSD_B_TYPESHIFT 0
|
||||
|
||||
#define OPENBSD_BOOTARG_APIVER (OPENBSD_BAPIV_VECTOR | \
|
||||
OPENBSD_BAPIV_ENV | \
|
||||
OPENBSD_BAPIV_BMEMMAP)
|
||||
|
||||
#define OPENBSD_BAPIV_ANCIENT 0x0 /* MD old i386 bootblocks */
|
||||
#define OPENBSD_BAPIV_VARS 0x1 /* MD structure w/ add info passed */
|
||||
#define OPENBSD_BAPIV_VECTOR 0x2 /* MI vector of MD structures passed */
|
||||
#define OPENBSD_BAPIV_ENV 0x4 /* MI environment vars vector */
|
||||
#define OPENBSD_BAPIV_BMEMMAP 0x8 /* MI memory map passed is in bytes */
|
||||
|
||||
#define OPENBSD_BOOTARG_ENV 0x1000
|
||||
#define OPENBSD_BOOTARG_END -1
|
||||
|
||||
#define OPENBSD_BOOTARG_MMAP 0
|
||||
|
||||
struct grub_openbsd_bios_mmap
|
||||
{
|
||||
grub_uint64_t addr;
|
||||
|
@ -162,97 +84,6 @@ struct grub_openbsd_bios_mmap
|
|||
grub_uint32_t type;
|
||||
};
|
||||
|
||||
struct grub_openbsd_bootargs
|
||||
{
|
||||
int ba_type;
|
||||
int ba_size;
|
||||
struct grub_openbsd_bootargs *ba_next;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define NETBSD_RB_AUTOBOOT 0 /* flags for system auto-booting itself */
|
||||
|
||||
#define NETBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define NETBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define NETBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define NETBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define NETBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define NETBSD_RB_UNUSED1 (1 << 5) /* was RB_DFLTROOT, obsolete */
|
||||
#define NETBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define NETBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define NETBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define NETBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define NETBSD_RB_STRING (1 << 10) /* use provided bootstr */
|
||||
#define NETBSD_RB_POWERDOWN ((1 << 11) | RB_HALT) /* turn power off (or at least halt) */
|
||||
#define NETBSD_RB_USERCONFIG (1 << 12) /* change configured devices */
|
||||
|
||||
#define NETBSD_AB_NORMAL 0 /* boot normally (default) */
|
||||
|
||||
#define NETBSD_AB_QUIET (1 << 16) /* boot quietly */
|
||||
#define NETBSD_AB_VERBOSE (1 << 17) /* boot verbosely */
|
||||
#define NETBSD_AB_SILENT (1 << 18) /* boot silently */
|
||||
#define NETBSD_AB_DEBUG (1 << 19) /* boot with debug messages */
|
||||
#define NETBSD_AB_NOSMP (1 << 28) /* Boot without SMP support. */
|
||||
#define NETBSD_AB_NOACPI (1 << 29) /* Boot without ACPI support. */
|
||||
|
||||
struct grub_netbsd_bootinfo
|
||||
{
|
||||
grub_uint32_t bi_count;
|
||||
void *bi_data[1];
|
||||
};
|
||||
|
||||
#define NETBSD_BTINFO_BOOTPATH 0
|
||||
#define NETBSD_BTINFO_ROOTDEVICE 1
|
||||
#define NETBSD_BTINFO_BOOTDISK 3
|
||||
#define NETBSD_BTINFO_MEMMAP 9
|
||||
|
||||
struct grub_netbsd_btinfo_common
|
||||
{
|
||||
int len;
|
||||
int type;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_mmap_header
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
grub_uint32_t count;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_mmap_entry
|
||||
{
|
||||
grub_uint64_t addr;
|
||||
grub_uint64_t len;
|
||||
#define NETBSD_MMAP_AVAILABLE 1
|
||||
#define NETBSD_MMAP_RESERVED 2
|
||||
#define NETBSD_MMAP_ACPI 3
|
||||
#define NETBSD_MMAP_NVS 4
|
||||
grub_uint32_t type;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_bootpath
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
char bootpath[80];
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_rootdevice
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
char devname[16];
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_bootdisk
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
int labelsector; /* label valid if != -1 */
|
||||
struct
|
||||
{
|
||||
grub_uint16_t type, checksum;
|
||||
char packname[16];
|
||||
} label;
|
||||
int biosdev;
|
||||
int partition;
|
||||
};
|
||||
|
||||
void grub_unix_real_boot (grub_addr_t entry, ...)
|
||||
__attribute__ ((cdecl,noreturn));
|
||||
grub_err_t grub_freebsd_load_elfmodule32 (grub_file_t file, int argc,
|
||||
|
|
74
include/grub/i386/freebsd_linker.h
Normal file
74
include/grub/i386/freebsd_linker.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2000 Doug Rabson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: stable/8/sys/sys/linker.h 199583 2009-11-20 15:27:52Z jhb $
|
||||
*/
|
||||
|
||||
#ifndef GRUB_FREEBSD_LINKER_CPU_HEADER
|
||||
#define GRUB_FREEBSD_LINKER_CPU_HEADER 1
|
||||
|
||||
#define FREEBSD_MODINFO_END 0x0000 /* End of list */
|
||||
#define FREEBSD_MODINFO_NAME 0x0001 /* Name of module (string) */
|
||||
#define FREEBSD_MODINFO_TYPE 0x0002 /* Type of module (string) */
|
||||
#define FREEBSD_MODINFO_ADDR 0x0003 /* Loaded address */
|
||||
#define FREEBSD_MODINFO_SIZE 0x0004 /* Size of module */
|
||||
#define FREEBSD_MODINFO_EMPTY 0x0005 /* Has been deleted */
|
||||
#define FREEBSD_MODINFO_ARGS 0x0006 /* Parameters string */
|
||||
#define FREEBSD_MODINFO_METADATA 0x8000 /* Module-specfic */
|
||||
|
||||
#define FREEBSD_MODINFOMD_AOUTEXEC 0x0001 /* a.out exec header */
|
||||
#define FREEBSD_MODINFOMD_ELFHDR 0x0002 /* ELF header */
|
||||
#define FREEBSD_MODINFOMD_SSYM 0x0003 /* start of symbols */
|
||||
#define FREEBSD_MODINFOMD_ESYM 0x0004 /* end of symbols */
|
||||
#define FREEBSD_MODINFOMD_DYNAMIC 0x0005 /* _DYNAMIC pointer */
|
||||
#define FREEBSD_MODINFOMD_ENVP 0x0006 /* envp[] */
|
||||
#define FREEBSD_MODINFOMD_HOWTO 0x0007 /* boothowto */
|
||||
#define FREEBSD_MODINFOMD_KERNEND 0x0008 /* kernend */
|
||||
#define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */
|
||||
#define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */
|
||||
|
||||
#define FREEBSD_MODINFOMD_SMAP 0x1001
|
||||
|
||||
#define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */
|
||||
|
||||
#endif
|
77
include/grub/i386/freebsd_reboot.h
Normal file
77
include/grub/i386/freebsd_reboot.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1988, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)reboot.h 8.3 (Berkeley) 12/13/94
|
||||
* $FreeBSD: stable/8/sys/sys/reboot.h 199583 2009-11-20 15:27:52Z jhb $
|
||||
*/
|
||||
|
||||
#ifndef GRUB_FREEBSD_REBOOT_CPU_HEADER
|
||||
#define GRUB_FREEBSD_REBOOT_CPU_HEADER 1
|
||||
|
||||
#define FREEBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define FREEBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define FREEBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define FREEBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define FREEBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define FREEBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
|
||||
#define FREEBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define FREEBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define FREEBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define FREEBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define FREEBSD_RB_CONFIG (1 << 10) /* invoke user configuration routing */
|
||||
#define FREEBSD_RB_VERBOSE (1 << 11) /* print all potentially useful info */
|
||||
#define FREEBSD_RB_SERIAL (1 << 12) /* user serial port as console */
|
||||
#define FREEBSD_RB_CDROM (1 << 13) /* use cdrom as root */
|
||||
#define FREEBSD_RB_GDB (1 << 15) /* use GDB remote debugger instead of DDB */
|
||||
#define FREEBSD_RB_MUTE (1 << 16) /* Come up with the console muted */
|
||||
#define FREEBSD_RB_PAUSE (1 << 20)
|
||||
#define FREEBSD_RB_QUIET (1 << 21)
|
||||
#define FREEBSD_RB_NOINTR (1 << 28)
|
||||
#define FREENSD_RB_MULTIPLE (1 << 29) /* Use multiple consoles */
|
||||
#define FREEBSD_RB_DUAL FREENSD_RB_MULTIPLE
|
||||
#define FREEBSD_RB_BOOTINFO (1 << 31) /* have `struct bootinfo *' arg */
|
||||
|
||||
#endif
|
|
@ -79,9 +79,9 @@ struct grub_e820_mmap
|
|||
grub_uint32_t type;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define GRUB_VIDEO_TYPE_TEXT 0x01
|
||||
#define GRUB_VIDEO_TYPE_VLFB 0x23 /* VESA VGA in graphic mode */
|
||||
#define GRUB_VIDEO_TYPE_EFI 0x70
|
||||
#define GRUB_VIDEO_LINUX_TYPE_TEXT 0x01
|
||||
#define GRUB_VIDEO_LINUX_TYPE_VESA 0x23 /* VESA VGA in graphic mode. */
|
||||
#define GRUB_VIDEO_LINUX_TYPE_SIMPLE 0x70 /* Linear framebuffer without any additional functions. */
|
||||
|
||||
/* For the Linux/i386 boot protocol version 2.03. */
|
||||
struct linux_kernel_header
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2003,2004,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,7 +31,7 @@ extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
|
|||
extern char *EXPORT_VAR(grub_linux_tmp_addr);
|
||||
extern char *EXPORT_VAR(grub_linux_real_addr);
|
||||
extern grub_int32_t EXPORT_VAR(grub_linux_is_bzimage);
|
||||
grub_err_t EXPORT_FUNC(grub_linux16_boot) (void);
|
||||
grub_err_t EXPORT_FUNC(grub_linux16_real_boot) (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_LOADER_CPU_HEADER */
|
||||
|
|
112
include/grub/i386/netbsd_bootinfo.h
Normal file
112
include/grub/i386/netbsd_bootinfo.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* $NetBSD: bootinfo.h,v 1.16 2009/08/24 02:15:46 jmcneill Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
* Matthias Drochner. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GRUB_NETBSD_BOOTINFO_CPU_HEADER
|
||||
#define GRUB_NETBSD_BOOTINFO_CPU_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
|
||||
#define NETBSD_BTINFO_BOOTPATH 0
|
||||
#define NETBSD_BTINFO_ROOTDEVICE 1
|
||||
#define NETBSD_BTINFO_BOOTDISK 3
|
||||
#define NETBSD_BTINFO_MEMMAP 9
|
||||
|
||||
struct grub_netbsd_btinfo_common
|
||||
{
|
||||
int len;
|
||||
int type;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_mmap_header
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
grub_uint32_t count;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_mmap_entry
|
||||
{
|
||||
grub_uint64_t addr;
|
||||
grub_uint64_t len;
|
||||
#define NETBSD_MMAP_AVAILABLE 1
|
||||
#define NETBSD_MMAP_RESERVED 2
|
||||
#define NETBSD_MMAP_ACPI 3
|
||||
#define NETBSD_MMAP_NVS 4
|
||||
grub_uint32_t type;
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_bootpath
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
char bootpath[80];
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_rootdevice
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
char devname[16];
|
||||
};
|
||||
|
||||
struct grub_netbsd_btinfo_bootdisk
|
||||
{
|
||||
struct grub_netbsd_btinfo_common common;
|
||||
int labelsector; /* label valid if != -1 */
|
||||
struct
|
||||
{
|
||||
grub_uint16_t type, checksum;
|
||||
char packname[16];
|
||||
} label;
|
||||
int biosdev;
|
||||
int partition;
|
||||
};
|
||||
|
||||
struct grub_netbsd_bootinfo
|
||||
{
|
||||
grub_uint32_t bi_count;
|
||||
void *bi_data[1];
|
||||
};
|
||||
|
||||
#endif
|
81
include/grub/i386/netbsd_reboot.h
Normal file
81
include/grub/i386/netbsd_reboot.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* $NetBSD: reboot.h,v 1.25 2007/12/25 18:33:48 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)reboot.h 8.3 (Berkeley) 12/13/94
|
||||
*/
|
||||
|
||||
#ifndef GRUB_NETBSD_REBOOT_CPU_HEADER
|
||||
#define GRUB_NETBSD_REBOOT_CPU_HEADER 1
|
||||
|
||||
#define NETBSD_RB_AUTOBOOT 0 /* flags for system auto-booting itself */
|
||||
|
||||
#define NETBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define NETBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define NETBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define NETBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define NETBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define NETBSD_RB_UNUSED1 (1 << 5) /* was RB_DFLTROOT, obsolete */
|
||||
#define NETBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define NETBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define NETBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define NETBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define NETBSD_RB_STRING (1 << 10) /* use provided bootstr */
|
||||
#define NETBSD_RB_POWERDOWN ((1 << 11) | RB_HALT) /* turn power off (or at least halt) */
|
||||
#define NETBSD_RB_USERCONFIG (1 << 12) /* change configured devices */
|
||||
|
||||
#define NETBSD_AB_NORMAL 0 /* boot normally (default) */
|
||||
|
||||
#define NETBSD_AB_QUIET (1 << 16) /* boot quietly */
|
||||
#define NETBSD_AB_VERBOSE (1 << 17) /* boot verbosely */
|
||||
#define NETBSD_AB_SILENT (1 << 18) /* boot silently */
|
||||
#define NETBSD_AB_DEBUG (1 << 19) /* boot with debug messages */
|
||||
#define NETBSD_AB_NOSMP (1 << 28) /* Boot without SMP support. */
|
||||
#define NETBSD_AB_NOACPI (1 << 29) /* Boot without ACPI support. */
|
||||
|
||||
|
||||
#endif
|
72
include/grub/i386/openbsd_bootarg.h
Normal file
72
include/grub/i386/openbsd_bootarg.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* $OpenBSD: bootarg.h,v 1.11 2003/06/02 20:20:54 mickey Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1999 Michael Shalayeff
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_OPENBSD_BOOTARG_CPU_HEADER
|
||||
#define GRUB_OPENBSD_BOOTARG_CPU_HEADER 1
|
||||
|
||||
#define OPENBSD_BOOTARG_APIVER (OPENBSD_BAPIV_VECTOR | \
|
||||
OPENBSD_BAPIV_ENV | \
|
||||
OPENBSD_BAPIV_BMEMMAP)
|
||||
|
||||
#define OPENBSD_BAPIV_ANCIENT 0x0 /* MD old i386 bootblocks */
|
||||
#define OPENBSD_BAPIV_VARS 0x1 /* MD structure w/ add info passed */
|
||||
#define OPENBSD_BAPIV_VECTOR 0x2 /* MI vector of MD structures passed */
|
||||
#define OPENBSD_BAPIV_ENV 0x4 /* MI environment vars vector */
|
||||
#define OPENBSD_BAPIV_BMEMMAP 0x8 /* MI memory map passed is in bytes */
|
||||
|
||||
#define OPENBSD_BOOTARG_ENV 0x1000
|
||||
#define OPENBSD_BOOTARG_END -1
|
||||
|
||||
#define OPENBSD_BOOTARG_MMAP 0
|
||||
|
||||
struct grub_openbsd_bootargs
|
||||
{
|
||||
int ba_type;
|
||||
int ba_size;
|
||||
struct grub_openbsd_bootargs *ba_next;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif
|
79
include/grub/i386/openbsd_reboot.h
Normal file
79
include/grub/i386/openbsd_reboot.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* $OpenBSD: reboot.h,v 1.13 2004/03/10 23:02:53 tom Exp $ */
|
||||
/* $NetBSD: reboot.h,v 1.9 1996/04/22 01:23:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)reboot.h 8.2 (Berkeley) 7/10/94
|
||||
*/
|
||||
|
||||
#ifndef GRUB_OPENBSD_REBOOT_CPU_HEADER
|
||||
#define GRUB_OPENBSD_REBOOT_CPU_HEADER 1
|
||||
|
||||
#define OPENBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
|
||||
#define OPENBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
|
||||
#define OPENBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
|
||||
#define OPENBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
|
||||
#define OPENBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
|
||||
#define OPENBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
|
||||
#define OPENBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
|
||||
#define OPENBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
|
||||
#define OPENBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
|
||||
#define OPENBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
|
||||
#define OPENBSD_RB_CONFIG (1 << 10) /* change configured devices */
|
||||
#define OPENBSD_RB_TIMEBAD (1 << 11) /* don't call resettodr() in boot() */
|
||||
#define OPENBSD_RB_POWERDOWN (1 << 12) /* attempt to power down machine */
|
||||
#define OPENBSD_RB_SERCONS (1 << 13) /* use serial console if available */
|
||||
#define OPENBSD_RB_USERREQ (1 << 14) /* boot() called at user request (e.g. ddb) */
|
||||
|
||||
#define OPENBSD_B_DEVMAGIC 0xa0000000
|
||||
#define OPENBSD_B_ADAPTORSHIFT 24
|
||||
#define OPENBSD_B_CTRLSHIFT 20
|
||||
#define OPENBSD_B_UNITSHIFT 16
|
||||
#define OPENBSD_B_PARTSHIFT 8
|
||||
#define OPENBSD_B_TYPESHIFT 0
|
||||
|
||||
#endif
|
|
@ -29,7 +29,22 @@
|
|||
#include <multiboot.h>
|
||||
#endif
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
|
||||
void grub_multiboot (int argc, char *argv[]);
|
||||
void grub_module (int argc, char *argv[]);
|
||||
|
||||
void grub_multiboot_set_accepts_video (int val);
|
||||
|
||||
grub_size_t grub_multiboot_get_mbi_size (void);
|
||||
grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest,
|
||||
grub_off_t buf_off, grub_size_t bufsize);
|
||||
void grub_multiboot_free_mbi (void);
|
||||
grub_err_t grub_multiboot_init_mbi (int argc, char *argv[]);
|
||||
grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||
int argc, char *argv[]);
|
||||
void grub_multiboot_set_bootdev (void);
|
||||
|
||||
|
||||
#endif /* ! GRUB_MULTIBOOT_HEADER */
|
||||
|
|
85
include/grub/test.h
Normal file
85
include/grub/test.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_TEST_HEADER
|
||||
#define GRUB_TEST_HEADER
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
struct grub_test
|
||||
{
|
||||
/* The next test. */
|
||||
struct grub_test *next;
|
||||
|
||||
/* The test name. */
|
||||
char *name;
|
||||
|
||||
/* The test main function. */
|
||||
void (*main) (void);
|
||||
};
|
||||
typedef struct grub_test *grub_test_t;
|
||||
|
||||
extern grub_test_t grub_test_list;
|
||||
|
||||
void grub_test_register (const char *name, void (*test) (void));
|
||||
void grub_test_unregister (const char *name);
|
||||
|
||||
/* Execute a test and print results. */
|
||||
int grub_test_run (grub_test_t test);
|
||||
|
||||
/* Test `cond' for nonzero; log failure otherwise. */
|
||||
void grub_test_nonzero (int cond, const char *file,
|
||||
const char *func, grub_uint32_t line,
|
||||
const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 5, 6)));
|
||||
|
||||
/* Macro to fill in location details and an optional error message. */
|
||||
#define grub_test_assert(cond, ...) \
|
||||
grub_test_nonzero(cond, __FILE__, __FUNCTION__, __LINE__, \
|
||||
## __VA_ARGS__, \
|
||||
"assert failed: %s", #cond)
|
||||
|
||||
/* Macro to define a unit test. */
|
||||
#define GRUB_UNIT_TEST(name, funp) \
|
||||
void grub_unit_test_init (void) \
|
||||
{ \
|
||||
grub_test_register (name, funp); \
|
||||
} \
|
||||
\
|
||||
void grub_unit_test_fini (void) \
|
||||
{ \
|
||||
grub_test_unregister (name); \
|
||||
}
|
||||
|
||||
/* Macro to define a functional test. */
|
||||
#define GRUB_FUNCTIONAL_TEST(name, funp) \
|
||||
GRUB_MOD_INIT(functional_test_##funp) \
|
||||
{ \
|
||||
grub_test_register (name, funp); \
|
||||
} \
|
||||
\
|
||||
GRUB_MOD_FINI(functional_test_##funp) \
|
||||
{ \
|
||||
grub_test_unregister (name); \
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_TEST_HEADER */
|
|
@ -159,10 +159,19 @@ struct grub_video_palette_data
|
|||
grub_uint8_t a; /* Reserved bits value (0-255). */
|
||||
};
|
||||
|
||||
typedef enum grub_video_driver_id
|
||||
{
|
||||
GRUB_VIDEO_DRIVER_NONE,
|
||||
GRUB_VIDEO_DRIVER_VBE,
|
||||
GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||
GRUB_VIDEO_DRIVER_EFI_GOP
|
||||
} grub_video_driver_id_t;
|
||||
|
||||
struct grub_video_adapter
|
||||
{
|
||||
/* The video adapter name. */
|
||||
const char *name;
|
||||
grub_video_driver_id_t id;
|
||||
|
||||
/* Initialize the video adapter. */
|
||||
grub_err_t (*init) (void);
|
||||
|
@ -171,7 +180,7 @@ struct grub_video_adapter
|
|||
grub_err_t (*fini) (void);
|
||||
|
||||
grub_err_t (*setup) (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type);
|
||||
unsigned int mode_type, unsigned int mode_mask);
|
||||
|
||||
grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
|
||||
|
||||
|
@ -307,7 +316,17 @@ grub_err_t grub_video_set_active_render_target (struct grub_video_render_target
|
|||
grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
|
||||
|
||||
grub_err_t grub_video_set_mode (const char *modestring,
|
||||
int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
|
||||
struct grub_video_mode_info *mode_info));
|
||||
unsigned int modemask,
|
||||
unsigned int modevalue);
|
||||
|
||||
static inline int
|
||||
grub_video_check_mode_flag (unsigned int flags, unsigned int mask,
|
||||
unsigned int flag, int def)
|
||||
{
|
||||
return (flag & mask) ? !! (flags & flag) : def;
|
||||
}
|
||||
|
||||
grub_video_driver_id_t
|
||||
grub_video_get_driver_id (void);
|
||||
|
||||
#endif /* ! GRUB_VIDEO_HEADER */
|
||||
|
|
1
include/grub/x86_64/multiboot.h
Normal file
1
include/grub/x86_64/multiboot.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include <grub/i386/multiboot.h>
|
|
@ -85,10 +85,12 @@
|
|||
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
|
||||
|
||||
/* Is there video information? */
|
||||
#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800
|
||||
#define MULTIBOOT_INFO_VBE_INFO 0x00000800
|
||||
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
typedef unsigned char multiboot_uint8_t;
|
||||
typedef unsigned short multiboot_uint16_t;
|
||||
typedef unsigned int multiboot_uint32_t;
|
||||
typedef unsigned long long multiboot_uint64_t;
|
||||
|
@ -187,9 +189,43 @@ struct multiboot_info
|
|||
multiboot_uint16_t vbe_interface_seg;
|
||||
multiboot_uint16_t vbe_interface_off;
|
||||
multiboot_uint16_t vbe_interface_len;
|
||||
|
||||
multiboot_uint64_t framebuffer_addr;
|
||||
multiboot_uint32_t framebuffer_pitch;
|
||||
multiboot_uint32_t framebuffer_width;
|
||||
multiboot_uint32_t framebuffer_height;
|
||||
multiboot_uint8_t framebuffer_bpp;
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||
multiboot_uint8_t framebuffer_type;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
multiboot_uint32_t framebuffer_palette_addr;
|
||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||
};
|
||||
struct
|
||||
{
|
||||
multiboot_uint8_t framebuffer_red_field_position;
|
||||
multiboot_uint8_t framebuffer_red_mask_size;
|
||||
multiboot_uint8_t framebuffer_green_field_position;
|
||||
multiboot_uint8_t framebuffer_green_mask_size;
|
||||
multiboot_uint8_t framebuffer_blue_field_position;
|
||||
multiboot_uint8_t framebuffer_blue_mask_size;
|
||||
};
|
||||
};
|
||||
};
|
||||
typedef struct multiboot_info multiboot_info_t;
|
||||
|
||||
struct multiboot_color
|
||||
{
|
||||
multiboot_uint8_t red;
|
||||
multiboot_uint8_t green;
|
||||
multiboot_uint8_t blue;
|
||||
};
|
||||
|
||||
struct multiboot_mmap_entry
|
||||
{
|
||||
multiboot_uint32_t size;
|
||||
|
|
|
@ -85,10 +85,12 @@
|
|||
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
|
||||
|
||||
/* Is there video information? */
|
||||
#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800
|
||||
#define MULTIBOOT_INFO_VBE_INFO 0x00000800
|
||||
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
typedef unsigned char multiboot_uint8_t;
|
||||
typedef unsigned short multiboot_uint16_t;
|
||||
typedef unsigned int multiboot_uint32_t;
|
||||
typedef unsigned long long multiboot_uint64_t;
|
||||
|
@ -187,9 +189,43 @@ struct multiboot_info
|
|||
multiboot_uint16_t vbe_interface_seg;
|
||||
multiboot_uint16_t vbe_interface_off;
|
||||
multiboot_uint16_t vbe_interface_len;
|
||||
|
||||
multiboot_uint64_t framebuffer_addr;
|
||||
multiboot_uint32_t framebuffer_pitch;
|
||||
multiboot_uint32_t framebuffer_width;
|
||||
multiboot_uint32_t framebuffer_height;
|
||||
multiboot_uint8_t framebuffer_bpp;
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||
multiboot_uint8_t framebuffer_type;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
multiboot_uint32_t framebuffer_palette_addr;
|
||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||
};
|
||||
struct
|
||||
{
|
||||
multiboot_uint8_t framebuffer_red_field_position;
|
||||
multiboot_uint8_t framebuffer_red_mask_size;
|
||||
multiboot_uint8_t framebuffer_green_field_position;
|
||||
multiboot_uint8_t framebuffer_green_mask_size;
|
||||
multiboot_uint8_t framebuffer_blue_field_position;
|
||||
multiboot_uint8_t framebuffer_blue_mask_size;
|
||||
};
|
||||
};
|
||||
};
|
||||
typedef struct multiboot_info multiboot_info_t;
|
||||
|
||||
struct multiboot_color
|
||||
{
|
||||
multiboot_uint8_t red;
|
||||
multiboot_uint8_t green;
|
||||
multiboot_uint8_t blue;
|
||||
};
|
||||
|
||||
struct multiboot_mmap_entry
|
||||
{
|
||||
multiboot_uint32_t size;
|
||||
|
|
|
@ -82,6 +82,5 @@ void
|
|||
grub_efi_fini (void)
|
||||
{
|
||||
grub_efidisk_fini ();
|
||||
grub_efi_mm_fini ();
|
||||
grub_console_fini ();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ grub_error (grub_err_t n, const char *fmt, ...)
|
|||
grub_errno = n;
|
||||
|
||||
va_start (ap, fmt);
|
||||
grub_vsprintf (grub_errmsg, fmt, ap);
|
||||
grub_vsprintf (grub_errmsg, _(fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
return n;
|
||||
|
@ -57,7 +57,7 @@ grub_fatal (const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
grub_vprintf (fmt, ap);
|
||||
grub_vprintf (_(fmt), ap);
|
||||
va_end (ap);
|
||||
|
||||
grub_abort ();
|
||||
|
|
|
@ -59,7 +59,7 @@ VARIABLE(grub_linux_real_addr)
|
|||
VARIABLE(grub_linux_is_bzimage)
|
||||
.long 0
|
||||
|
||||
FUNCTION(grub_linux16_boot)
|
||||
FUNCTION(grub_linux16_real_boot)
|
||||
/* Must be done before zImage copy. */
|
||||
call EXT_C(grub_dl_unload_all)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* rescue_reader.c - rescue mode reader */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -83,7 +83,7 @@ grub_rescue_run (void)
|
|||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
grub_rescue_read_line (&line, 0);
|
||||
if (! line)
|
||||
if (! line || line[0] == '\0')
|
||||
continue;
|
||||
|
||||
grub_parser_get_current ()->parse_line (line, grub_rescue_read_line);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,7 +35,7 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#include <grub/video.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#endif
|
||||
|
@ -509,6 +509,8 @@ grub_freebsd_boot (void)
|
|||
|
||||
bi.bi_kernend = kern_end;
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
if (is_64bit)
|
||||
{
|
||||
grub_uint32_t *gdt;
|
||||
|
@ -617,6 +619,8 @@ grub_openbsd_boot (void)
|
|||
pa->ba_type = OPENBSD_BOOTARG_END;
|
||||
pa++;
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
grub_unix_real_boot (entry, bootflags, openbsd_root, OPENBSD_BOOTARG_APIVER,
|
||||
0, (grub_uint32_t) (grub_mmap_get_upper () >> 10),
|
||||
(grub_uint32_t) (grub_mmap_get_lower () >> 10),
|
||||
|
@ -713,6 +717,8 @@ grub_netbsd_boot (void)
|
|||
bootinfo->bi_data[0] = mmap;
|
||||
}
|
||||
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
grub_unix_real_boot (entry, bootflags, 0, bootinfo,
|
||||
0, (grub_uint32_t) (grub_mmap_get_upper () >> 10),
|
||||
(grub_uint32_t) (grub_mmap_get_lower () >> 10));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -587,7 +587,7 @@ grub_linux_setup_video (struct linux_kernel_params *params)
|
|||
params->reserved_mask_size = 8;
|
||||
params->reserved_field_pos = 24;
|
||||
|
||||
params->have_vga = GRUB_VIDEO_TYPE_VLFB;
|
||||
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
|
||||
params->vid_mode = 0x338; /* 1024x768x32 */
|
||||
|
||||
return 0;
|
||||
|
@ -676,8 +676,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
|
||||
/* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
|
||||
params->type_of_loader = (LINUX_LOADER_ID_ELILO << 4);
|
||||
params->type_of_loader = (LINUX_LOADER_ID_GRUB << 4);
|
||||
|
||||
params->cl_magic = GRUB_LINUX_CL_MAGIC;
|
||||
params->cl_offset = 0x1000;
|
||||
|
@ -852,7 +851,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
else if (grub_memcmp (argv[i], "video=efifb", 11) == 0)
|
||||
{
|
||||
if (params->have_vga)
|
||||
params->have_vga = GRUB_VIDEO_TYPE_EFI;
|
||||
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
|
||||
}
|
||||
|
||||
/* Specify the boot file. */
|
||||
|
|
|
@ -524,11 +524,11 @@ grub_linux_boot (void)
|
|||
if (! tmp)
|
||||
return grub_errno;
|
||||
grub_sprintf (tmp, "%s;text", modevar);
|
||||
err = grub_video_set_mode (tmp, 0);
|
||||
err = grub_video_set_mode (tmp, 0, 0);
|
||||
grub_free (tmp);
|
||||
}
|
||||
else
|
||||
err = grub_video_set_mode ("text", 0);
|
||||
err = grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
if (err)
|
||||
{
|
||||
|
@ -538,16 +538,16 @@ grub_linux_boot (void)
|
|||
}
|
||||
|
||||
if (! grub_linux_setup_video (params))
|
||||
params->have_vga = GRUB_VIDEO_TYPE_VLFB;
|
||||
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
|
||||
else
|
||||
{
|
||||
params->have_vga = GRUB_VIDEO_TYPE_TEXT;
|
||||
params->have_vga = GRUB_VIDEO_LINUX_TYPE_TEXT;
|
||||
params->video_width = 80;
|
||||
params->video_height = 25;
|
||||
}
|
||||
|
||||
/* Initialize these last, because terminal position could be affected by printfs above. */
|
||||
if (params->have_vga == GRUB_VIDEO_TYPE_TEXT)
|
||||
if (params->have_vga == GRUB_VIDEO_LINUX_TYPE_TEXT)
|
||||
{
|
||||
grub_term_output_t term;
|
||||
int found = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* multiboot.c - boot a multiboot OS image. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,13 +28,11 @@
|
|||
*/
|
||||
|
||||
/* The bits in the required part of flags field we don't support. */
|
||||
#define UNSUPPORTED_FLAGS 0x0000fffc
|
||||
#define UNSUPPORTED_FLAGS 0x0000fff8
|
||||
|
||||
#include <grub/loader.h>
|
||||
#include <grub/machine/loader.h>
|
||||
#include <grub/multiboot.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/cpu/multiboot.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/aout.h>
|
||||
|
@ -45,31 +43,29 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/gzio.h>
|
||||
#include <grub/env.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/partition.h>
|
||||
#endif
|
||||
#include <grub/i386/relocator.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
#include <grub/efi/efi.h>
|
||||
#endif
|
||||
|
||||
extern grub_dl_t my_mod;
|
||||
static struct multiboot_info *mbi, *mbi_dest;
|
||||
|
||||
static grub_size_t code_size;
|
||||
static grub_size_t code_size, alloc_mbi;
|
||||
|
||||
char *grub_multiboot_payload_orig;
|
||||
grub_addr_t grub_multiboot_payload_dest;
|
||||
grub_size_t grub_multiboot_payload_size;
|
||||
grub_size_t grub_multiboot_pure_size;
|
||||
grub_uint32_t grub_multiboot_payload_eip;
|
||||
|
||||
static grub_err_t
|
||||
grub_multiboot_boot (void)
|
||||
{
|
||||
grub_size_t mbi_size;
|
||||
grub_err_t err;
|
||||
struct grub_relocator32_state state =
|
||||
{
|
||||
.eax = MULTIBOOT_BOOTLOADER_MAGIC,
|
||||
.ebx = PTR_TO_UINT32 (mbi_dest),
|
||||
.ecx = 0,
|
||||
.edx = 0,
|
||||
.eip = grub_multiboot_payload_eip,
|
||||
|
@ -78,6 +74,29 @@ grub_multiboot_boot (void)
|
|||
.esp = 0x7ff00
|
||||
};
|
||||
|
||||
mbi_size = grub_multiboot_get_mbi_size ();
|
||||
if (alloc_mbi < mbi_size)
|
||||
{
|
||||
grub_multiboot_payload_orig
|
||||
= grub_relocator32_realloc (grub_multiboot_payload_orig,
|
||||
grub_multiboot_pure_size + mbi_size);
|
||||
if (!grub_multiboot_payload_orig)
|
||||
return grub_errno;
|
||||
alloc_mbi = mbi_size;
|
||||
}
|
||||
|
||||
state.ebx = grub_multiboot_payload_dest + grub_multiboot_pure_size;
|
||||
err = grub_multiboot_make_mbi (grub_multiboot_payload_orig,
|
||||
grub_multiboot_payload_dest,
|
||||
grub_multiboot_pure_size, mbi_size);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
if (! grub_efi_finish_boot_services ())
|
||||
grub_fatal ("cannot exit boot services");
|
||||
#endif
|
||||
|
||||
grub_relocator32_boot (grub_multiboot_payload_orig,
|
||||
grub_multiboot_payload_dest,
|
||||
state);
|
||||
|
@ -89,69 +108,18 @@ grub_multiboot_boot (void)
|
|||
static grub_err_t
|
||||
grub_multiboot_unload (void)
|
||||
{
|
||||
if (mbi)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < mbi->mods_count; i++)
|
||||
{
|
||||
grub_free ((void *)
|
||||
((struct multiboot_mod_list *) mbi->mods_addr)[i].mod_start);
|
||||
grub_free ((void *)
|
||||
((struct multiboot_mod_list *) mbi->mods_addr)[i].cmdline);
|
||||
}
|
||||
grub_free ((void *) mbi->mods_addr);
|
||||
}
|
||||
grub_multiboot_free_mbi ();
|
||||
|
||||
grub_relocator32_free (grub_multiboot_payload_orig);
|
||||
|
||||
mbi = NULL;
|
||||
alloc_mbi = 0;
|
||||
|
||||
grub_multiboot_payload_orig = NULL;
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Return the length of the Multiboot mmap that will be needed to allocate
|
||||
our platform's map. */
|
||||
static grub_uint32_t
|
||||
grub_get_multiboot_mmap_len (void)
|
||||
{
|
||||
grub_size_t count = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
{
|
||||
count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
|
||||
return count * sizeof (struct multiboot_mmap_entry);
|
||||
}
|
||||
|
||||
/* Fill previously allocated Multiboot mmap. */
|
||||
static void
|
||||
grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry)
|
||||
{
|
||||
struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry;
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
{
|
||||
mmap_entry->addr = addr;
|
||||
mmap_entry->len = size;
|
||||
mmap_entry->type = type;
|
||||
mmap_entry->size = sizeof (struct multiboot_mmap_entry) - sizeof (mmap_entry->size);
|
||||
mmap_entry++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
}
|
||||
|
||||
#define MULTIBOOT_LOAD_ELF64
|
||||
#include "multiboot_elfxx.c"
|
||||
#undef MULTIBOOT_LOAD_ELF64
|
||||
|
@ -172,58 +140,13 @@ grub_multiboot_load_elf (grub_file_t file, void *buffer)
|
|||
return grub_error (GRUB_ERR_UNKNOWN_OS, "unknown ELF class");
|
||||
}
|
||||
|
||||
static int
|
||||
grub_multiboot_get_bootdev (grub_uint32_t *bootdev)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
char *p;
|
||||
grub_uint32_t biosdev, slice = ~0, part = ~0;
|
||||
grub_device_t dev;
|
||||
|
||||
biosdev = grub_get_root_biosnumber ();
|
||||
|
||||
dev = grub_device_open (0);
|
||||
if (dev && dev->disk && dev->disk->partition)
|
||||
{
|
||||
|
||||
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
|
||||
if (p)
|
||||
{
|
||||
if ((p[0] >= '0') && (p[0] <= '9'))
|
||||
{
|
||||
slice = grub_strtoul (p, &p, 0) - 1;
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p++;
|
||||
}
|
||||
|
||||
if ((p[0] >= 'a') && (p[0] <= 'z'))
|
||||
part = p[0] - 'a';
|
||||
}
|
||||
}
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
*bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16)
|
||||
| ((part & 0xff) << 8) | 0xff;
|
||||
return (biosdev != ~0UL);
|
||||
#else
|
||||
*bootdev = 0xffffffff;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
grub_multiboot (int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file = 0;
|
||||
char buffer[MULTIBOOT_SEARCH], *cmdline = 0, *p;
|
||||
char buffer[MULTIBOOT_SEARCH];
|
||||
struct multiboot_header *header;
|
||||
grub_ssize_t len, cmdline_length, boot_loader_name_length;
|
||||
grub_uint32_t mmap_length;
|
||||
int i;
|
||||
int cmdline_argc;
|
||||
char **cmdline_argv;
|
||||
grub_ssize_t len;
|
||||
|
||||
grub_loader_unset ();
|
||||
|
||||
|
@ -274,31 +197,8 @@ grub_multiboot (int argc, char *argv[])
|
|||
grub_relocator32_free (grub_multiboot_payload_orig);
|
||||
grub_multiboot_payload_orig = NULL;
|
||||
|
||||
mmap_length = grub_get_multiboot_mmap_len ();
|
||||
|
||||
/* Figure out cmdline length. */
|
||||
/* Skip filename. */
|
||||
cmdline_argc = argc - 1;
|
||||
cmdline_argv = argv + 1;
|
||||
|
||||
for (i = 0, cmdline_length = 0; i < cmdline_argc; i++)
|
||||
cmdline_length += grub_strlen (cmdline_argv[i]) + 1;
|
||||
|
||||
if (cmdline_length == 0)
|
||||
cmdline_length = 1;
|
||||
|
||||
boot_loader_name_length = sizeof(PACKAGE_STRING);
|
||||
|
||||
#define cmdline_addr(x) ((void *) ((x) + code_size))
|
||||
#define boot_loader_name_addr(x) \
|
||||
((void *) ((x) + code_size + cmdline_length))
|
||||
#define mbi_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length))
|
||||
#define mmap_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length + sizeof (struct multiboot_info)))
|
||||
|
||||
grub_multiboot_payload_size = cmdline_length
|
||||
/* boot_loader_name_length might need to grow for mbi,etc to be aligned (see below) */
|
||||
+ boot_loader_name_length + 3
|
||||
+ sizeof (struct multiboot_info) + mmap_length;
|
||||
grub_multiboot_init_mbi (argc - 1, argv + 1);
|
||||
|
||||
if (header->flags & MULTIBOOT_AOUT_KLUDGE)
|
||||
{
|
||||
|
@ -313,10 +213,12 @@ grub_multiboot (int argc, char *argv[])
|
|||
code_size = load_size;
|
||||
grub_multiboot_payload_dest = header->load_addr;
|
||||
|
||||
grub_multiboot_payload_size += code_size;
|
||||
grub_multiboot_pure_size += code_size;
|
||||
|
||||
/* Allocate a bit more to avoid relocations in most cases. */
|
||||
alloc_mbi = grub_multiboot_get_mbi_size () + 65536;
|
||||
grub_multiboot_payload_orig
|
||||
= grub_relocator32_alloc (grub_multiboot_payload_size);
|
||||
= grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi);
|
||||
|
||||
if (! grub_multiboot_payload_orig)
|
||||
goto fail;
|
||||
|
@ -338,53 +240,37 @@ grub_multiboot (int argc, char *argv[])
|
|||
else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
|
||||
/* This provides alignment for the MBI, the memory map and the backward relocator. */
|
||||
boot_loader_name_length += (0x04 - ((unsigned long) mbi_addr (grub_multiboot_payload_dest) & 0x03));
|
||||
|
||||
mbi = mbi_addr (grub_multiboot_payload_orig);
|
||||
mbi_dest = mbi_addr (grub_multiboot_payload_dest);
|
||||
grub_memset (mbi, 0, sizeof (struct multiboot_info));
|
||||
mbi->mmap_length = mmap_length;
|
||||
|
||||
grub_fill_multiboot_mmap (mmap_addr (grub_multiboot_payload_orig));
|
||||
|
||||
/* FIXME: grub_uint32_t will break for addresses above 4 GiB, but is mandated
|
||||
by the spec. Is there something we can do about it? */
|
||||
mbi->mmap_addr = (grub_uint32_t) mmap_addr (grub_multiboot_payload_dest);
|
||||
mbi->flags |= MULTIBOOT_INFO_MEM_MAP;
|
||||
|
||||
/* Convert from bytes to kilobytes. */
|
||||
mbi->mem_lower = grub_mmap_get_lower () / 1024;
|
||||
mbi->mem_upper = grub_mmap_get_upper () / 1024;
|
||||
mbi->flags |= MULTIBOOT_INFO_MEMORY;
|
||||
|
||||
cmdline = p = cmdline_addr (grub_multiboot_payload_orig);
|
||||
if (! cmdline)
|
||||
goto fail;
|
||||
|
||||
for (i = 0; i < cmdline_argc; i++)
|
||||
if (header->flags & MULTIBOOT_VIDEO_MODE)
|
||||
{
|
||||
p = grub_stpcpy (p, cmdline_argv[i]);
|
||||
*(p++) = ' ';
|
||||
switch (header->mode_type)
|
||||
{
|
||||
case 1:
|
||||
grub_env_set ("gfxpayload", "text");
|
||||
break;
|
||||
|
||||
case 0:
|
||||
{
|
||||
char buf[sizeof ("XXXXXXXXXXxXXXXXXXXXXxXXXXXXXXXX,XXXXXXXXXXxXXXXXXXXXX,auto")];
|
||||
if (header->depth && header->width && header->height)
|
||||
grub_sprintf (buf, "%dx%dx%d,%dx%d,auto", header->width,
|
||||
header->height, header->depth, header->width,
|
||||
header->height);
|
||||
else if (header->width && header->height)
|
||||
grub_sprintf (buf, "%dx%d,auto", header->width, header->height);
|
||||
else
|
||||
grub_sprintf (buf, "auto");
|
||||
|
||||
grub_env_set ("gfxpayload", buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the space after the last word. */
|
||||
if (p != cmdline)
|
||||
p--;
|
||||
*p = 0;
|
||||
grub_multiboot_set_accepts_video (!!(header->flags & MULTIBOOT_VIDEO_MODE));
|
||||
|
||||
mbi->flags |= MULTIBOOT_INFO_CMDLINE;
|
||||
mbi->cmdline = (grub_uint32_t) cmdline_addr (grub_multiboot_payload_dest);
|
||||
grub_multiboot_set_bootdev ();
|
||||
|
||||
|
||||
grub_strcpy (boot_loader_name_addr (grub_multiboot_payload_orig), PACKAGE_STRING);
|
||||
mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME;
|
||||
mbi->boot_loader_name = (grub_uint32_t) boot_loader_name_addr (grub_multiboot_payload_dest);
|
||||
|
||||
if (grub_multiboot_get_bootdev (&mbi->boot_device))
|
||||
mbi->flags |= MULTIBOOT_INFO_BOOTDEV;
|
||||
|
||||
grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 1);
|
||||
grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0);
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
|
@ -392,22 +278,18 @@ grub_multiboot (int argc, char *argv[])
|
|||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_free (cmdline);
|
||||
grub_free (mbi);
|
||||
grub_relocator32_free (grub_multiboot_payload_orig);
|
||||
grub_dl_unref (my_mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_module (int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file = 0;
|
||||
grub_ssize_t size, len = 0;
|
||||
char *module = 0, *cmdline = 0, *p;
|
||||
int i;
|
||||
int cmdline_argc;
|
||||
char **cmdline_argv;
|
||||
grub_ssize_t size;
|
||||
char *module = 0;
|
||||
grub_err_t err;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
|
@ -415,7 +297,7 @@ grub_module (int argc, char *argv[])
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (!mbi)
|
||||
if (!grub_multiboot_payload_orig)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"you need to load the multiboot kernel first");
|
||||
|
@ -431,73 +313,19 @@ grub_module (int argc, char *argv[])
|
|||
if (! module)
|
||||
goto fail;
|
||||
|
||||
err = grub_multiboot_add_module ((grub_addr_t) module, size,
|
||||
argc - 1, argv + 1);
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
if (grub_file_read (file, module, size) != size)
|
||||
{
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "couldn't read file");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Skip module name. */
|
||||
cmdline_argc = argc - 1;
|
||||
cmdline_argv = argv + 1;
|
||||
|
||||
for (i = 0; i < cmdline_argc; i++)
|
||||
len += grub_strlen (cmdline_argv[i]) + 1;
|
||||
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
|
||||
cmdline = p = grub_malloc (len);
|
||||
if (! cmdline)
|
||||
goto fail;
|
||||
|
||||
for (i = 0; i < cmdline_argc; i++)
|
||||
{
|
||||
p = grub_stpcpy (p, cmdline_argv[i]);
|
||||
*(p++) = ' ';
|
||||
}
|
||||
|
||||
/* Remove the space after the last word. */
|
||||
if (p != cmdline)
|
||||
p--;
|
||||
*p = '\0';
|
||||
|
||||
if (mbi->flags & MULTIBOOT_INFO_MODS)
|
||||
{
|
||||
struct multiboot_mod_list *modlist = (struct multiboot_mod_list *) mbi->mods_addr;
|
||||
|
||||
modlist = grub_realloc (modlist, (mbi->mods_count + 1)
|
||||
* sizeof (struct multiboot_mod_list));
|
||||
if (! modlist)
|
||||
goto fail;
|
||||
mbi->mods_addr = (grub_uint32_t) modlist;
|
||||
modlist += mbi->mods_count;
|
||||
modlist->mod_start = (grub_uint32_t) module;
|
||||
modlist->mod_end = (grub_uint32_t) module + size;
|
||||
modlist->cmdline = (grub_uint32_t) cmdline;
|
||||
modlist->pad = 0;
|
||||
mbi->mods_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct multiboot_mod_list *modlist = grub_zalloc (sizeof (struct multiboot_mod_list));
|
||||
if (! modlist)
|
||||
goto fail;
|
||||
modlist->mod_start = (grub_uint32_t) module;
|
||||
modlist->mod_end = (grub_uint32_t) module + size;
|
||||
modlist->cmdline = (grub_uint32_t) cmdline;
|
||||
mbi->mods_count = 1;
|
||||
mbi->mods_addr = (grub_uint32_t) modlist;
|
||||
mbi->flags |= MULTIBOOT_INFO_MODS;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_free (module);
|
||||
grub_free (cmdline);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,10 +100,11 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
|||
code_size = (phdr(highest_segment)->p_paddr + phdr(highest_segment)->p_memsz) - phdr(lowest_segment)->p_paddr;
|
||||
grub_multiboot_payload_dest = phdr(lowest_segment)->p_paddr;
|
||||
|
||||
grub_multiboot_payload_size += code_size;
|
||||
grub_multiboot_pure_size += code_size;
|
||||
|
||||
alloc_mbi = grub_multiboot_get_mbi_size ();
|
||||
grub_multiboot_payload_orig
|
||||
= grub_relocator32_alloc (grub_multiboot_payload_size);
|
||||
= grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi + 65536);
|
||||
|
||||
if (!grub_multiboot_payload_orig)
|
||||
return grub_errno;
|
||||
|
|
463
loader/i386/multiboot_mbi.c
Normal file
463
loader/i386/multiboot_mbi.c
Normal file
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/machine/memory.h>
|
||||
#include <grub/memory.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#endif
|
||||
#include <grub/multiboot.h>
|
||||
#include <grub/cpu/multiboot.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||
#include <grub/i386/pc/vbe.h>
|
||||
#define DEFAULT_VIDEO_MODE "text"
|
||||
#define HAS_VGA_TEXT 1
|
||||
#else
|
||||
#define DEFAULT_VIDEO_MODE "auto"
|
||||
#define HAS_VGA_TEXT 0
|
||||
#endif
|
||||
|
||||
struct module
|
||||
{
|
||||
struct module *next;
|
||||
grub_addr_t start;
|
||||
grub_size_t size;
|
||||
char *cmdline;
|
||||
int cmdline_size;
|
||||
};
|
||||
|
||||
struct module *modules, *modules_last;
|
||||
static grub_size_t cmdline_size;
|
||||
static grub_size_t total_modcmd;
|
||||
static unsigned modcnt;
|
||||
static char *cmdline = NULL;
|
||||
static grub_uint32_t bootdev;
|
||||
static int bootdev_set;
|
||||
static int accepts_video;
|
||||
|
||||
void
|
||||
grub_multiboot_set_accepts_video (int val)
|
||||
{
|
||||
accepts_video = val;
|
||||
}
|
||||
|
||||
/* Return the length of the Multiboot mmap that will be needed to allocate
|
||||
our platform's map. */
|
||||
static grub_uint32_t
|
||||
grub_get_multiboot_mmap_len (void)
|
||||
{
|
||||
grub_size_t count = 0;
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr __attribute__ ((unused)),
|
||||
grub_uint64_t size __attribute__ ((unused)),
|
||||
grub_uint32_t type __attribute__ ((unused)))
|
||||
{
|
||||
count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
|
||||
return count * sizeof (struct multiboot_mmap_entry);
|
||||
}
|
||||
|
||||
grub_size_t
|
||||
grub_multiboot_get_mbi_size (void)
|
||||
{
|
||||
return sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4)
|
||||
+ modcnt * sizeof (struct multiboot_mod_list) + total_modcmd
|
||||
+ ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len ()
|
||||
+ 256 * sizeof (struct multiboot_color);
|
||||
}
|
||||
|
||||
/* Fill previously allocated Multiboot mmap. */
|
||||
static void
|
||||
grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry)
|
||||
{
|
||||
struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry;
|
||||
|
||||
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
|
||||
{
|
||||
mmap_entry->addr = addr;
|
||||
mmap_entry->len = size;
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_MACHINE_MEMORY_AVAILABLE:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
mmap_entry->type = MULTIBOOT_MEMORY_RESERVED;
|
||||
break;
|
||||
}
|
||||
mmap_entry->size = sizeof (struct multiboot_mmap_entry) - sizeof (mmap_entry->size);
|
||||
mmap_entry++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_mmap_iterate (hook);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
set_video_mode (void)
|
||||
{
|
||||
grub_err_t err;
|
||||
const char *modevar;
|
||||
|
||||
if (accepts_video || !HAS_VGA_TEXT)
|
||||
{
|
||||
modevar = grub_env_get ("gfxpayload");
|
||||
if (! modevar || *modevar == 0)
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, 0, 0);
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
if (! tmp)
|
||||
return grub_errno;
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, 0, 0);
|
||||
grub_free (tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
err = grub_video_set_mode ("text", 0, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
retrieve_video_parameters (struct multiboot_info *mbi,
|
||||
grub_uint8_t *ptrorig, grub_uint32_t ptrdest)
|
||||
{
|
||||
grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
void *framebuffer;
|
||||
grub_video_driver_id_t driv_id;
|
||||
struct grub_video_palette_data palette[256];
|
||||
|
||||
err = set_video_mode ();
|
||||
if (err)
|
||||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_video_get_palette (0, ARRAY_SIZE (palette), palette);
|
||||
|
||||
driv_id = grub_video_get_driver_id ();
|
||||
if (driv_id == GRUB_VIDEO_DRIVER_NONE)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mbi->framebuffer_addr = (grub_addr_t) framebuffer;
|
||||
mbi->framebuffer_pitch = mode_info.pitch;
|
||||
|
||||
mbi->framebuffer_width = mode_info.width;
|
||||
mbi->framebuffer_height = mode_info.height;
|
||||
|
||||
mbi->framebuffer_bpp = mode_info.bpp;
|
||||
|
||||
if (mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
|
||||
{
|
||||
struct multiboot_color *mb_palette;
|
||||
unsigned i;
|
||||
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED;
|
||||
mbi->framebuffer_palette_addr = ptrdest;
|
||||
mbi->framebuffer_palette_num_colors = mode_info.number_of_colors;
|
||||
if (mbi->framebuffer_palette_num_colors > ARRAY_SIZE (palette))
|
||||
mbi->framebuffer_palette_num_colors = ARRAY_SIZE (palette);
|
||||
mb_palette = (struct multiboot_color *) ptrorig;
|
||||
for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
|
||||
{
|
||||
mb_palette[i].red = palette[i].r;
|
||||
mb_palette[i].green = palette[i].g;
|
||||
mb_palette[i].blue = palette[i].b;
|
||||
}
|
||||
ptrorig += mbi->framebuffer_palette_num_colors
|
||||
* sizeof (struct multiboot_color);
|
||||
ptrdest += mbi->framebuffer_palette_num_colors
|
||||
* sizeof (struct multiboot_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_RGB;
|
||||
mbi->framebuffer_red_field_position = mode_info.green_field_pos;
|
||||
mbi->framebuffer_red_mask_size = mode_info.green_mask_size;
|
||||
mbi->framebuffer_green_field_position = mode_info.green_field_pos;
|
||||
mbi->framebuffer_green_mask_size = mode_info.green_mask_size;
|
||||
mbi->framebuffer_blue_field_position = mode_info.blue_field_pos;
|
||||
mbi->framebuffer_blue_mask_size = mode_info.blue_mask_size;
|
||||
}
|
||||
|
||||
mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_multiboot_make_mbi (void *orig, grub_uint32_t dest, grub_off_t buf_off,
|
||||
grub_size_t bufsize)
|
||||
{
|
||||
grub_uint8_t *ptrorig = (grub_uint8_t *) orig + buf_off;
|
||||
grub_uint32_t ptrdest = dest + buf_off;
|
||||
struct multiboot_info *mbi;
|
||||
struct multiboot_mod_list *modlist;
|
||||
unsigned i;
|
||||
struct module *cur;
|
||||
grub_size_t mmap_size;
|
||||
grub_err_t err;
|
||||
|
||||
if (bufsize < grub_multiboot_get_mbi_size ())
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "mbi buffer is too small");
|
||||
|
||||
mbi = (struct multiboot_info *) ptrorig;
|
||||
ptrorig += sizeof (*mbi);
|
||||
ptrdest += sizeof (*mbi);
|
||||
grub_memset (mbi, 0, sizeof (*mbi));
|
||||
|
||||
grub_memcpy (ptrorig, cmdline, cmdline_size);
|
||||
mbi->flags |= MULTIBOOT_INFO_CMDLINE;
|
||||
mbi->cmdline = ptrdest;
|
||||
ptrorig += ALIGN_UP (cmdline_size, 4);
|
||||
ptrdest += ALIGN_UP (cmdline_size, 4);
|
||||
|
||||
grub_memcpy (ptrorig, PACKAGE_STRING, sizeof(PACKAGE_STRING));
|
||||
mbi->flags |= MULTIBOOT_INFO_BOOT_LOADER_NAME;
|
||||
mbi->boot_loader_name = ptrdest;
|
||||
ptrorig += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
|
||||
ptrdest += ALIGN_UP (sizeof(PACKAGE_STRING), 4);
|
||||
|
||||
if (modcnt)
|
||||
{
|
||||
mbi->flags |= MULTIBOOT_INFO_MODS;
|
||||
mbi->mods_addr = ptrdest;
|
||||
mbi->mods_count = modcnt;
|
||||
modlist = (struct multiboot_mod_list *) ptrorig;
|
||||
ptrorig += modcnt * sizeof (struct multiboot_mod_list);
|
||||
ptrdest += modcnt * sizeof (struct multiboot_mod_list);
|
||||
|
||||
for (i = 0, cur = modules; i < modcnt; i++, cur = cur->next)
|
||||
{
|
||||
modlist[i].mod_start = cur->start;
|
||||
modlist[i].mod_end = modlist[i].mod_start + cur->size;
|
||||
modlist[i].cmdline = ptrdest;
|
||||
grub_memcpy (ptrorig, cur->cmdline, cur->cmdline_size);
|
||||
ptrorig += ALIGN_UP (cur->cmdline_size, 4);
|
||||
ptrdest += ALIGN_UP (cur->cmdline_size, 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mbi->mods_addr = 0;
|
||||
mbi->mods_count = 0;
|
||||
}
|
||||
|
||||
mmap_size = grub_get_multiboot_mmap_len ();
|
||||
grub_fill_multiboot_mmap ((struct multiboot_mmap_entry *) ptrorig);
|
||||
mbi->mmap_length = mmap_size;
|
||||
mbi->mmap_addr = ptrdest;
|
||||
mbi->flags |= MULTIBOOT_INFO_MEM_MAP;
|
||||
ptrorig += mmap_size;
|
||||
ptrdest += mmap_size;
|
||||
|
||||
/* Convert from bytes to kilobytes. */
|
||||
mbi->mem_lower = grub_mmap_get_lower () / 1024;
|
||||
mbi->mem_upper = grub_mmap_get_upper () / 1024;
|
||||
mbi->flags |= MULTIBOOT_INFO_MEMORY;
|
||||
|
||||
if (bootdev_set)
|
||||
{
|
||||
mbi->boot_device = bootdev;
|
||||
mbi->flags |= MULTIBOOT_INFO_BOOTDEV;
|
||||
}
|
||||
|
||||
err = retrieve_video_parameters (mbi, ptrorig, ptrdest);
|
||||
if (err)
|
||||
{
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
grub_multiboot_free_mbi (void)
|
||||
{
|
||||
struct module *cur, *next;
|
||||
|
||||
cmdline_size = 0;
|
||||
total_modcmd = 0;
|
||||
modcnt = 0;
|
||||
grub_free (cmdline);
|
||||
cmdline = NULL;
|
||||
bootdev_set = 0;
|
||||
|
||||
for (cur = modules; cur; cur = next)
|
||||
{
|
||||
next = cur->next;
|
||||
grub_free (cur->cmdline);
|
||||
grub_free (cur);
|
||||
}
|
||||
modules = NULL;
|
||||
modules_last = NULL;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_multiboot_init_mbi (int argc, char *argv[])
|
||||
{
|
||||
grub_ssize_t len = 0;
|
||||
char *p;
|
||||
int i;
|
||||
|
||||
grub_multiboot_free_mbi ();
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
len += grub_strlen (argv[i]) + 1;
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
|
||||
cmdline = p = grub_malloc (len);
|
||||
if (! cmdline)
|
||||
return grub_errno;
|
||||
cmdline_size = len;
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
p = grub_stpcpy (p, argv[i]);
|
||||
*(p++) = ' ';
|
||||
}
|
||||
|
||||
/* Remove the space after the last word. */
|
||||
if (p != cmdline)
|
||||
p--;
|
||||
*p = '\0';
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
struct module *newmod;
|
||||
char *p;
|
||||
grub_ssize_t len = 0;
|
||||
int i;
|
||||
|
||||
newmod = grub_malloc (sizeof (*newmod));
|
||||
if (!newmod)
|
||||
return grub_errno;
|
||||
newmod->start = start;
|
||||
newmod->size = size;
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
len += grub_strlen (argv[i]) + 1;
|
||||
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
|
||||
newmod->cmdline = p = grub_malloc (len);
|
||||
if (! newmod->cmdline)
|
||||
{
|
||||
grub_free (newmod);
|
||||
return grub_errno;
|
||||
}
|
||||
newmod->cmdline_size = len;
|
||||
total_modcmd += ALIGN_UP (len, 4);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
p = grub_stpcpy (p, argv[i]);
|
||||
*(p++) = ' ';
|
||||
}
|
||||
|
||||
/* Remove the space after the last word. */
|
||||
if (p != newmod->cmdline)
|
||||
p--;
|
||||
*p = '\0';
|
||||
|
||||
if (modules_last)
|
||||
modules_last->next = newmod;
|
||||
else
|
||||
{
|
||||
modules = newmod;
|
||||
modules_last->next = NULL;
|
||||
}
|
||||
modules_last = newmod;
|
||||
|
||||
modcnt++;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
grub_multiboot_set_bootdev (void)
|
||||
{
|
||||
char *p;
|
||||
grub_uint32_t biosdev, slice = ~0, part = ~0;
|
||||
grub_device_t dev;
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
biosdev = grub_get_root_biosnumber ();
|
||||
#else
|
||||
biosdev = 0xffffffff;
|
||||
#endif
|
||||
|
||||
dev = grub_device_open (0);
|
||||
if (dev && dev->disk && dev->disk->partition)
|
||||
{
|
||||
|
||||
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
|
||||
if (p)
|
||||
{
|
||||
if ((p[0] >= '0') && (p[0] <= '9'))
|
||||
{
|
||||
slice = grub_strtoul (p, &p, 0) - 1;
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p++;
|
||||
}
|
||||
|
||||
if ((p[0] >= 'a') && (p[0] <= 'z'))
|
||||
part = p[0] - 'a';
|
||||
}
|
||||
}
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16)
|
||||
| ((part & 0xff) << 8) | 0xff;
|
||||
bootdev_set = 1;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/* chainloader.c - boot another boot loader */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,2007,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2004,2007,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,6 +33,8 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
static int boot_drive;
|
||||
|
@ -41,6 +43,7 @@ static void *boot_part_addr;
|
|||
static grub_err_t
|
||||
grub_chainloader_boot (void)
|
||||
{
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
grub_chainloader_real_boot (boot_drive, boot_part_addr);
|
||||
|
||||
/* Never reach here. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* linux.c - boot Linux zImage or bzImage */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,6 +31,8 @@
|
|||
#include <grub/cpu/linux.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/video.h>
|
||||
|
||||
#define GRUB_LINUX_CL_OFFSET 0x9000
|
||||
#define GRUB_LINUX_CL_END_OFFSET 0x90FF
|
||||
|
@ -48,6 +50,16 @@ grub_linux_unload (void)
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_linux16_boot (void)
|
||||
{
|
||||
grub_video_set_mode ("text", 0, 0);
|
||||
grub_linux16_real_boot ();
|
||||
|
||||
/* Not reached. */
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
/* multiboot2.c - boot a multiboot 2 OS image. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/multiboot2.h>
|
||||
#include <multiboot2.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/machine/loader.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/multiboot.h>
|
||||
#include <grub/cpu/multiboot.h>
|
||||
|
||||
grub_err_t
|
||||
grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr,
|
||||
grub_addr_t *addr __attribute__ ((unused)),
|
||||
int *do_load)
|
||||
{
|
||||
Elf32_Addr paddr = phdr->p_paddr;
|
||||
|
||||
if (phdr->p_type != PT_LOAD)
|
||||
{
|
||||
*do_load = 0;
|
||||
return 0;
|
||||
}
|
||||
*do_load = 1;
|
||||
|
||||
if ((paddr < grub_os_area_addr)
|
||||
|| (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size))
|
||||
return grub_error(GRUB_ERR_OUT_OF_RANGE,"address 0x%x is out of range",
|
||||
paddr);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr,
|
||||
grub_addr_t *addr __attribute__ ((unused)),
|
||||
int *do_load)
|
||||
{
|
||||
Elf64_Addr paddr = phdr->p_paddr;
|
||||
|
||||
if (phdr->p_type != PT_LOAD)
|
||||
{
|
||||
*do_load = 0;
|
||||
return 0;
|
||||
}
|
||||
*do_load = 1;
|
||||
|
||||
if ((paddr < grub_os_area_addr)
|
||||
|| (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size))
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "address 0x%x is out of range",
|
||||
paddr);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr)
|
||||
{
|
||||
grub_addr_t modaddr;
|
||||
|
||||
modaddr = (grub_addr_t) grub_memalign (MULTIBOOT2_MOD_ALIGN, size);
|
||||
if (! modaddr)
|
||||
return grub_errno;
|
||||
|
||||
*addr = modaddr;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_mb2_arch_module_free (grub_addr_t addr,
|
||||
grub_size_t size __attribute__ ((unused)))
|
||||
{
|
||||
grub_free((void *) addr);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
grub_mb2_arch_boot (grub_addr_t entry, void *tags)
|
||||
{
|
||||
grub_multiboot2_real_boot (entry, tags);
|
||||
}
|
||||
|
||||
void
|
||||
grub_mb2_arch_unload (struct multiboot2_tag_header *tags)
|
||||
{
|
||||
struct multiboot2_tag_header *tag;
|
||||
|
||||
/* Free all module memory in the tag list. */
|
||||
for_each_tag (tag, tags)
|
||||
{
|
||||
if (tag->key == MULTIBOOT2_TAG_MODULE)
|
||||
{
|
||||
struct multiboot2_tag_module *module =
|
||||
(struct multiboot2_tag_module *) tag;
|
||||
grub_free((void *) module->addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_mb2_tags_arch_create (void)
|
||||
{
|
||||
/* XXX Create boot device et al. */
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
|
@ -26,16 +26,7 @@
|
|||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#define DEFAULT_VIDEO_MODE "1024x768x32,800x600x32,640x480x32"
|
||||
|
||||
static int NESTED_FUNC_ATTR video_hook (grub_video_adapter_t p __attribute__ ((unused)),
|
||||
struct grub_video_mode_info *info)
|
||||
{
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#define DEFAULT_VIDEO_MODE "auto"
|
||||
|
||||
/* Setup video for xnu. */
|
||||
grub_err_t
|
||||
|
@ -48,8 +39,12 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
grub_err_t err;
|
||||
|
||||
modevar = grub_env_get ("gfxpayload");
|
||||
/* Consider only graphical 32-bit deep modes. */
|
||||
if (! modevar || *modevar == 0)
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, video_hook);
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
|
||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
||||
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
||||
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
||||
else
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
|
@ -58,7 +53,10 @@ grub_xnu_set_video (struct grub_xnu_boot_params *params)
|
|||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't allocate temporary storag");
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, video_hook);
|
||||
err = grub_video_set_mode (tmp,
|
||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT
|
||||
| GRUB_VIDEO_MODE_TYPE_DEPTH_MASK,
|
||||
32 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS);
|
||||
grub_free (tmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,31 +166,30 @@ print_completion (const char *item, grub_completion_type_t type, int count)
|
|||
if (count == 0)
|
||||
{
|
||||
/* If this is the first time, print a label. */
|
||||
const char *what;
|
||||
|
||||
grub_puts ("");
|
||||
switch (type)
|
||||
{
|
||||
case GRUB_COMPLETION_TYPE_COMMAND:
|
||||
what = "commands";
|
||||
grub_puts_ (N_("Possible commands are:"));
|
||||
break;
|
||||
case GRUB_COMPLETION_TYPE_DEVICE:
|
||||
what = "devices";
|
||||
grub_puts_ (N_("Possible devices are:"));
|
||||
break;
|
||||
case GRUB_COMPLETION_TYPE_FILE:
|
||||
what = "files";
|
||||
grub_puts_ (N_("Possible files are:"));
|
||||
break;
|
||||
case GRUB_COMPLETION_TYPE_PARTITION:
|
||||
what = "partitions";
|
||||
grub_puts_ (N_("Possible partitions are:"));
|
||||
break;
|
||||
case GRUB_COMPLETION_TYPE_ARGUMENT:
|
||||
what = "arguments";
|
||||
grub_puts_ (N_("Possible arguments are:"));
|
||||
break;
|
||||
default:
|
||||
what = "things";
|
||||
grub_puts_ (N_("Possible things are:"));
|
||||
break;
|
||||
}
|
||||
|
||||
grub_printf ("\nPossible %s are:\n", what);
|
||||
grub_puts ("");
|
||||
}
|
||||
|
||||
if (type == GRUB_COMPLETION_TYPE_PARTITION)
|
||||
|
@ -254,21 +253,20 @@ grub_cmdline_get (const char *prompt)
|
|||
|
||||
for (p = buf + pos; p < buf + llen; p++)
|
||||
{
|
||||
if (cl_term->xpos++ > cl_term->width - 2)
|
||||
{
|
||||
grub_putcode ('\n', cl_term->term);
|
||||
|
||||
cl_term->xpos = 1;
|
||||
if (cl_term->ypos == (unsigned) (cl_term->height))
|
||||
cl_term->ystart--;
|
||||
else
|
||||
cl_term->ypos++;
|
||||
}
|
||||
|
||||
if (c)
|
||||
grub_putcode (c, cl_term->term);
|
||||
else
|
||||
grub_putcode (*p, cl_term->term);
|
||||
cl_term->xpos++;
|
||||
if (cl_term->xpos >= cl_term->width - 1)
|
||||
{
|
||||
cl_term->xpos = 0;
|
||||
if (cl_term->ypos >= (unsigned) (cl_term->height - 1))
|
||||
cl_term->ystart--;
|
||||
else
|
||||
cl_term->ypos++;
|
||||
grub_putcode ('\n', cl_term->term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,8 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
|
|||
return;
|
||||
}
|
||||
|
||||
grub_env_set ("chosen", entry->title);
|
||||
|
||||
grub_parser_execute ((char *) entry->sourcecode);
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
|
||||
|
@ -273,7 +275,7 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
|
|||
|
||||
/* Get the entry number from the variable NAME. */
|
||||
static int
|
||||
get_entry_number (const char *name)
|
||||
get_entry_number (grub_menu_t menu, const char *name)
|
||||
{
|
||||
char *val;
|
||||
int entry;
|
||||
|
@ -286,6 +288,28 @@ get_entry_number (const char *name)
|
|||
|
||||
entry = (int) grub_strtoul (val, 0, 0);
|
||||
|
||||
if (grub_errno == GRUB_ERR_BAD_NUMBER)
|
||||
{
|
||||
/* See if the variable matches the title of a menu entry. */
|
||||
grub_menu_entry_t e = menu->entry_list;
|
||||
int i;
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
for (i = 0; e; i++)
|
||||
{
|
||||
if (grub_strcmp (e->title, val) == 0)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
e = e->next;
|
||||
}
|
||||
|
||||
if (! e)
|
||||
entry = -1;
|
||||
}
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -312,7 +336,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||
int default_entry, current_entry;
|
||||
int timeout;
|
||||
|
||||
default_entry = get_entry_number ("default");
|
||||
default_entry = get_entry_number (menu, "default");
|
||||
|
||||
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
|
||||
the first entry. */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <grub/bitmap.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
#define DEFAULT_VIDEO_MODE "1024x768,800x600,640x480"
|
||||
#define DEFAULT_VIDEO_MODE "auto"
|
||||
#define DEFAULT_BORDER_WIDTH 10
|
||||
|
||||
#define DEFAULT_STANDARD_COLOR 0x07
|
||||
|
@ -244,12 +244,6 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static int NESTED_FUNC_ATTR video_hook (grub_video_adapter_t p __attribute__ ((unused)),
|
||||
struct grub_video_mode_info *info)
|
||||
{
|
||||
return ! (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_gfxterm_init (void)
|
||||
{
|
||||
|
@ -269,13 +263,15 @@ grub_gfxterm_init (void)
|
|||
/* Parse gfxmode environment variable if set. */
|
||||
modevar = grub_env_get ("gfxmode");
|
||||
if (! modevar || *modevar == 0)
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE, video_hook);
|
||||
err = grub_video_set_mode (DEFAULT_VIDEO_MODE,
|
||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
else
|
||||
{
|
||||
tmp = grub_malloc (grub_strlen (modevar)
|
||||
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
|
||||
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
|
||||
err = grub_video_set_mode (tmp, video_hook);
|
||||
err = grub_video_set_mode (tmp,
|
||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
grub_free (tmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ inc_y (void)
|
|||
static void
|
||||
inc_x (void)
|
||||
{
|
||||
if (grub_curr_x >= COLS - 2)
|
||||
if (grub_curr_x >= COLS - 1)
|
||||
inc_y ();
|
||||
else
|
||||
grub_curr_x++;
|
||||
|
|
|
@ -83,12 +83,17 @@ grub_ofconsole_putchar (grub_uint32_t c)
|
|||
grub_curr_y++;
|
||||
grub_curr_x = 0;
|
||||
}
|
||||
else if (c == '\r')
|
||||
{
|
||||
grub_curr_x = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_curr_x++;
|
||||
if (grub_curr_x > grub_ofconsole_width)
|
||||
if (grub_curr_x >= grub_ofconsole_width)
|
||||
{
|
||||
grub_ofconsole_putchar ('\n');
|
||||
grub_ofconsole_putchar ('\r');
|
||||
grub_curr_x++;
|
||||
}
|
||||
}
|
||||
|
@ -234,16 +239,13 @@ grub_ofconsole_getxy (void)
|
|||
return ((grub_curr_x - 1) << 8) | grub_curr_y;
|
||||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_ofconsole_getwh (void)
|
||||
static void
|
||||
grub_ofconsole_dimensions (void)
|
||||
{
|
||||
grub_ieee1275_ihandle_t options;
|
||||
char *val;
|
||||
grub_ssize_t lval;
|
||||
|
||||
if (grub_ofconsole_width && grub_ofconsole_height)
|
||||
return (grub_ofconsole_width << 8) | grub_ofconsole_height;
|
||||
|
||||
if (! grub_ieee1275_finddevice ("/options", &options)
|
||||
&& options != (grub_ieee1275_ihandle_t) -1)
|
||||
{
|
||||
|
@ -280,7 +282,11 @@ grub_ofconsole_getwh (void)
|
|||
grub_ofconsole_width = 80;
|
||||
if (! grub_ofconsole_height)
|
||||
grub_ofconsole_height = 24;
|
||||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_ofconsole_getwh (void)
|
||||
{
|
||||
return (grub_ofconsole_width << 8) | grub_ofconsole_height;
|
||||
}
|
||||
|
||||
|
@ -379,6 +385,8 @@ grub_ofconsole_init_output (void)
|
|||
grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
||||
}
|
||||
|
||||
grub_ofconsole_dimensions ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
35
tests/example_functional_test.c
Normal file
35
tests/example_functional_test.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* All tests need to include test.h for GRUB testing framework. */
|
||||
#include <grub/test.h>
|
||||
|
||||
/* Functional test main method. */
|
||||
static void
|
||||
example_test (void)
|
||||
{
|
||||
/* Check if 1st argument is true and report with default error message. */
|
||||
grub_test_assert (1 == 1);
|
||||
|
||||
/* Check if 1st argument is true and report with custom error message. */
|
||||
grub_test_assert (2 == 2, "2 equal 2 expected");
|
||||
grub_test_assert (2 == 3, "2 is not equal to %d", 3);
|
||||
}
|
||||
|
||||
/* Register example_test method as a functional test. */
|
||||
GRUB_FUNCTIONAL_TEST ("example_functional_test", example_test);
|
3
tests/example_grub_script_test.in
Normal file
3
tests/example_grub_script_test.in
Normal file
|
@ -0,0 +1,3 @@
|
|||
#! @builddir@/grub-shell-tester --modules=echo
|
||||
|
||||
echo "hello world"
|
3
tests/example_scripted_test.in
Normal file
3
tests/example_scripted_test.in
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
true
|
38
tests/example_unit_test.c
Normal file
38
tests/example_unit_test.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* Unit tests are normal programs, so they can include C library. */
|
||||
#include <string.h>
|
||||
|
||||
/* All tests need to include test.h for GRUB testing framework. */
|
||||
#include <grub/test.h>
|
||||
|
||||
/* Unit test main method. */
|
||||
static void
|
||||
example_test (void)
|
||||
{
|
||||
/* Check if 1st argument is true and report with default error message. */
|
||||
grub_test_assert (1 == 1);
|
||||
|
||||
/* Check if 1st argument is true and report with custom error message. */
|
||||
grub_test_assert (2 == 2, "2 equal 2 expected");
|
||||
grub_test_assert (2 == 3, "2 is not equal to %d", 3);
|
||||
}
|
||||
|
||||
/* Register example_test method as a unit test. */
|
||||
GRUB_UNIT_TEST ("example_unit_test", example_test);
|
53
tests/lib/functional_test.c
Normal file
53
tests/lib/functional_test.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/test.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
auto int run_test (grub_test_t test);
|
||||
int run_test (grub_test_t test)
|
||||
{
|
||||
grub_test_run (test);
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_list_iterate (GRUB_AS_LIST (grub_test_list),
|
||||
(grub_list_hook_t) run_test);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd;
|
||||
|
||||
GRUB_MOD_INIT (functional_test)
|
||||
{
|
||||
cmd = grub_register_extcmd ("functional_test", grub_functional_test,
|
||||
GRUB_COMMAND_FLAG_CMDLINE, 0,
|
||||
"Run all functional tests.", 0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (functional_test)
|
||||
{
|
||||
grub_unregister_extcmd (cmd);
|
||||
}
|
164
tests/lib/test.c
Normal file
164
tests/lib/test.c
Normal file
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/test.h>
|
||||
|
||||
struct grub_test_failure
|
||||
{
|
||||
/* The next failure. */
|
||||
struct grub_test_failure *next;
|
||||
|
||||
/* The test source file name. */
|
||||
char *file;
|
||||
|
||||
/* The test function name. */
|
||||
char *funp;
|
||||
|
||||
/* The test call line number. */
|
||||
grub_uint32_t line;
|
||||
|
||||
/* The test failure message. */
|
||||
char *message;
|
||||
};
|
||||
typedef struct grub_test_failure *grub_test_failure_t;
|
||||
|
||||
grub_test_t grub_test_list;
|
||||
static grub_test_failure_t failure_list;
|
||||
|
||||
static void
|
||||
add_failure (const char *file,
|
||||
const char *funp,
|
||||
grub_uint32_t line, const char *fmt, va_list args)
|
||||
{
|
||||
char buf[1024];
|
||||
grub_test_failure_t failure;
|
||||
|
||||
failure = (grub_test_failure_t) grub_malloc (sizeof (*failure));
|
||||
if (!failure)
|
||||
return;
|
||||
|
||||
grub_vsprintf (buf, fmt, args);
|
||||
|
||||
failure->file = grub_strdup (file ? : "<unknown_file>");
|
||||
failure->funp = grub_strdup (funp ? : "<unknown_function>");
|
||||
failure->line = line;
|
||||
failure->message = grub_strdup (buf);
|
||||
|
||||
grub_list_push (GRUB_AS_LIST_P (&failure_list), GRUB_AS_LIST (failure));
|
||||
}
|
||||
|
||||
static void
|
||||
free_failures (void)
|
||||
{
|
||||
grub_test_failure_t item;
|
||||
|
||||
while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0)
|
||||
{
|
||||
if (item->message)
|
||||
grub_free (item->message);
|
||||
|
||||
if (item->funp)
|
||||
grub_free (item->funp);
|
||||
|
||||
if (item->file)
|
||||
grub_free (item->file);
|
||||
|
||||
grub_free (item);
|
||||
}
|
||||
failure_list = 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_test_nonzero (int cond,
|
||||
const char *file,
|
||||
const char *funp, grub_uint32_t line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (cond)
|
||||
return;
|
||||
|
||||
va_start (ap, fmt);
|
||||
add_failure (file, funp, line, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
grub_test_register (const char *name, void (*test_main) (void))
|
||||
{
|
||||
grub_test_t test;
|
||||
|
||||
test = (grub_test_t) grub_malloc (sizeof (*test));
|
||||
if (!test)
|
||||
return;
|
||||
|
||||
test->name = grub_strdup (name);
|
||||
test->main = test_main;
|
||||
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
|
||||
}
|
||||
|
||||
void
|
||||
grub_test_unregister (const char *name)
|
||||
{
|
||||
grub_test_t test;
|
||||
|
||||
test = (grub_test_t) grub_named_list_find
|
||||
(GRUB_AS_NAMED_LIST (grub_test_list), name);
|
||||
|
||||
if (test)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
|
||||
|
||||
if (test->name)
|
||||
grub_free (test->name);
|
||||
|
||||
grub_free (test);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
grub_test_run (grub_test_t test)
|
||||
{
|
||||
auto int print_failure (grub_test_failure_t item);
|
||||
int print_failure (grub_test_failure_t item)
|
||||
{
|
||||
grub_test_failure_t failure = (grub_test_failure_t) item;
|
||||
|
||||
grub_printf (" %s:%s:%u: %s\n",
|
||||
(failure->file ? : "<unknown_file>"),
|
||||
(failure->funp ? : "<unknown_function>"),
|
||||
failure->line, (failure->message ? : "<no message>"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
test->main ();
|
||||
|
||||
grub_printf ("%s:\n", test->name);
|
||||
grub_list_iterate (GRUB_AS_LIST (failure_list),
|
||||
(grub_list_hook_t) print_failure);
|
||||
if (!failure_list)
|
||||
grub_printf ("%s: PASS\n", test->name);
|
||||
else
|
||||
grub_printf ("%s: FAIL\n", test->name);
|
||||
|
||||
free_failures ();
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
109
tests/lib/unit_test.c
Normal file
109
tests/lib/unit_test.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <grub/list.h>
|
||||
#include <grub/test.h>
|
||||
#include <grub/handler.h>
|
||||
|
||||
int
|
||||
main (int argc __attribute__ ((unused)),
|
||||
char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
extern void grub_unit_test_init (void);
|
||||
extern void grub_unit_test_fini (void);
|
||||
|
||||
auto int run_test (grub_test_t test);
|
||||
int run_test (grub_test_t test)
|
||||
{
|
||||
status = grub_test_run (test) ? : status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_unit_test_init ();
|
||||
grub_list_iterate (GRUB_AS_LIST (grub_test_list),
|
||||
(grub_list_hook_t) run_test);
|
||||
grub_unit_test_fini ();
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Other misc. functions necessary for successful linking. */
|
||||
|
||||
void
|
||||
grub_free (void *ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
char *
|
||||
grub_env_get (const char *name __attribute__ ((unused)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_error (grub_err_t n, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stderr, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_malloc (grub_size_t size)
|
||||
{
|
||||
return malloc (size);
|
||||
}
|
||||
|
||||
void
|
||||
grub_refresh (void)
|
||||
{
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
void
|
||||
grub_putchar (int c)
|
||||
{
|
||||
putchar (c);
|
||||
}
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
{
|
||||
exit (1);
|
||||
}
|
||||
|
||||
struct grub_handler_class grub_term_input_class;
|
||||
struct grub_handler_class grub_term_output_class;
|
109
tests/util/grub-shell-tester.in
Normal file
109
tests/util/grub-shell-tester.in
Normal file
|
@ -0,0 +1,109 @@
|
|||
#! /bin/bash -e
|
||||
|
||||
# Compares GRUB script output with BASH output.
|
||||
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
builddir=@builddir@
|
||||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
|
||||
# Force build directory components
|
||||
PATH=${builddir}:$PATH
|
||||
export PATH
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION] [SOURCE]
|
||||
Compares GRUB script output with BASH shell output.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--modules=MODULES pre-load specified modules MODULES
|
||||
--qemu-opts=OPTIONS extra options to pass to Qemu instance
|
||||
|
||||
$0 compares GRUB script output with BASH shell output and prints their
|
||||
differences.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
|
||||
exit 0 ;;
|
||||
--modules=*)
|
||||
ms=`echo "$option" | sed -e 's/--modules=//'`
|
||||
modules="$modules,$ms" ;;
|
||||
--qemu-opts=*)
|
||||
qs=`echo "$option" | sed -e 's/--qemu-opts=//'`
|
||||
qemuopts="$qemuopts $qs" ;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ "x${source}" != x ] ; then
|
||||
echo "too many parameters at the end" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
source="${option}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "x${source}" = x ] ; then
|
||||
tmpfile=`mktemp`
|
||||
while read; do
|
||||
echo $REPLY >> ${tmpfile}
|
||||
done
|
||||
source=${tmpfile}
|
||||
fi
|
||||
|
||||
outfile1=`mktemp`
|
||||
@builddir@/grub-shell --qemu-opts="${qemuopts}" --modules=${modules} ${source} >${outfile1}
|
||||
|
||||
outfile2=`mktemp`
|
||||
bash ${source} >${outfile2}
|
||||
|
||||
if ! diff -q ${outfile1} ${outfile2} >/dev/null
|
||||
then
|
||||
echo "${source}: GRUB and BASH outputs did not match (see diff -u ${outfile1} ${outfile2})"
|
||||
status=1
|
||||
else
|
||||
rm -f ${outfile1} ${outfile2}
|
||||
fi
|
||||
|
||||
exit $status
|
||||
|
||||
|
145
tests/util/grub-shell.in
Normal file
145
tests/util/grub-shell.in
Normal file
|
@ -0,0 +1,145 @@
|
|||
#! /bin/bash -e
|
||||
|
||||
# Run GRUB script in a Qemu instance
|
||||
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
builddir=@builddir@
|
||||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
|
||||
# Force build directory components
|
||||
PATH=${builddir}:$PATH
|
||||
export PATH
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION] [SOURCE]
|
||||
Run GRUB script in a Qemu instance.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--boot=[fd|hd|cd] boot method for Qemu instance
|
||||
--modules=MODULES pre-load specified modules MODULES
|
||||
--qemu-opts=OPTIONS extra options to pass to Qemu instance
|
||||
|
||||
$0 runs input GRUB script or SOURCE file in a Qemu instance and prints
|
||||
its output.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
|
||||
exit 0 ;;
|
||||
--modules=*)
|
||||
ms=`echo "$option" | sed -e 's/--modules=//' -e 's/,/ /g'`
|
||||
modules="$modules $ms" ;;
|
||||
--qemu-opts=*)
|
||||
qs=`echo "$option" | sed -e 's/--qemu-opts=//'`
|
||||
qemuopts="$qemuopts $qs" ;;
|
||||
--boot=*)
|
||||
dev=`echo "$option" | sed -e 's/--boot=//'`
|
||||
if [ "$dev" = "fd" ] ; then bootdev=a;
|
||||
elif [ "$dev" = "hd" ] ; then bootdev=c;
|
||||
elif [ "$dev" = "cd" ] ; then bootdev=d;
|
||||
else
|
||||
echo "Unrecognized boot method \`$dev'" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi ;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
exit 1 ;;
|
||||
*)
|
||||
if [ "x${source}" != x ] ; then
|
||||
echo "too many parameters at the end" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
source="${option}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "x${source}" = x ] ; then
|
||||
tmpfile=`mktemp`
|
||||
while read; do
|
||||
echo $REPLY >> ${tmpfile}
|
||||
done
|
||||
source=${tmpfile}
|
||||
fi
|
||||
|
||||
if [ "x${bootdev}" = x ] ; then
|
||||
bootdev=c # default is boot as disk image
|
||||
fi
|
||||
|
||||
cfgfile=`mktemp`
|
||||
cat <<EOF >${cfgfile}
|
||||
grubshell=yes
|
||||
insmod serial
|
||||
serial
|
||||
terminal_input serial
|
||||
terminal_output serial
|
||||
EOF
|
||||
|
||||
for mod in ${modules}
|
||||
do
|
||||
echo "insmod ${mod}" >> ${cfgfile}
|
||||
done
|
||||
|
||||
cat <<EOF >>${cfgfile}
|
||||
source /boot/grub/testcase.cfg
|
||||
halt
|
||||
EOF
|
||||
|
||||
isofile=`mktemp`
|
||||
grub-mkrescue --output=${isofile} --override-directory=${builddir} \
|
||||
/boot/grub/grub.cfg=${cfgfile} /boot/grub/testcase.cfg=${source} \
|
||||
>/dev/null 2>&1
|
||||
|
||||
hdafile=`mktemp`
|
||||
cp ${isofile} ${hdafile}
|
||||
|
||||
fdafile=`mktemp`
|
||||
cp ${isofile} ${fdafile}
|
||||
|
||||
outfile=`mktemp`
|
||||
qemu-system-i386 ${qemuopts} -nographic -serial stdio -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile}
|
||||
|
||||
cat $outfile
|
||||
|
||||
rm -f ${tmpfile} ${outfile} ${cfgfile} ${isofile} ${hdafile} ${fdafile}
|
||||
exit 0
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s -o FILE [OPTION]... [MODULES]\n\
|
||||
|
|
|
@ -115,14 +115,14 @@ grub_get_prefix (const char *dir)
|
|||
saved_cwd = xgetcwd ();
|
||||
|
||||
if (chdir (dir) < 0)
|
||||
grub_util_error ("Cannot change directory to `%s'", dir);
|
||||
grub_util_error ("cannot change directory to `%s'", dir);
|
||||
|
||||
abs_dir = xgetcwd ();
|
||||
strip_extra_slashes (abs_dir);
|
||||
prev_dir = xstrdup (abs_dir);
|
||||
|
||||
if (stat (".", &prev_st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", dir);
|
||||
grub_util_error ("cannot stat `%s'", dir);
|
||||
|
||||
if (! S_ISDIR (prev_st.st_mode))
|
||||
grub_util_error ("`%s' is not a directory", dir);
|
||||
|
@ -130,13 +130,13 @@ grub_get_prefix (const char *dir)
|
|||
while (1)
|
||||
{
|
||||
if (chdir ("..") < 0)
|
||||
grub_util_error ("Cannot change directory to the parent");
|
||||
grub_util_error ("cannot change directory to the parent");
|
||||
|
||||
if (stat (".", &st) < 0)
|
||||
grub_util_error ("Cannot stat current directory");
|
||||
grub_util_error ("cannot stat current directory");
|
||||
|
||||
if (! S_ISDIR (st.st_mode))
|
||||
grub_util_error ("Current directory is not a directory???");
|
||||
grub_util_error ("current directory is not a directory???");
|
||||
|
||||
if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino)
|
||||
break;
|
||||
|
@ -153,7 +153,7 @@ grub_get_prefix (const char *dir)
|
|||
strip_extra_slashes (prefix);
|
||||
|
||||
if (chdir (saved_cwd) < 0)
|
||||
grub_util_error ("Cannot change directory to `%s'", dir);
|
||||
grub_util_error ("cannot change directory to `%s'", dir);
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||
|
@ -236,7 +236,7 @@ find_root_device (const char *dir, dev_t dev)
|
|||
if (res)
|
||||
{
|
||||
if (chdir (saved_cwd) < 0)
|
||||
grub_util_error ("Cannot restore the original directory");
|
||||
grub_util_error ("cannot restore the original directory");
|
||||
|
||||
free (saved_cwd);
|
||||
closedir (dp);
|
||||
|
@ -279,7 +279,7 @@ find_root_device (const char *dir, dev_t dev)
|
|||
continue;
|
||||
|
||||
if (chdir (saved_cwd) < 0)
|
||||
grub_util_error ("Cannot restore the original directory");
|
||||
grub_util_error ("cannot restore the original directory");
|
||||
|
||||
free (saved_cwd);
|
||||
closedir (dp);
|
||||
|
@ -288,7 +288,7 @@ find_root_device (const char *dir, dev_t dev)
|
|||
}
|
||||
|
||||
if (chdir (saved_cwd) < 0)
|
||||
grub_util_error ("Cannot restore the original directory");
|
||||
grub_util_error ("cannot restore the original directory");
|
||||
|
||||
free (saved_cwd);
|
||||
closedir (dp);
|
||||
|
@ -445,7 +445,7 @@ grub_guess_root_device (const char *dir)
|
|||
struct stat st;
|
||||
|
||||
if (stat (dir, &st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", dir);
|
||||
grub_util_error ("cannot stat `%s'", dir);
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/* Cygwin specific function. */
|
||||
|
@ -591,7 +591,7 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
free (p);
|
||||
}
|
||||
else
|
||||
grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
|
||||
grub_util_error ("unknown kind of RAID device `%s'", os_dev);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -608,7 +608,7 @@ grub_util_check_block_device (const char *blk_dev)
|
|||
struct stat st;
|
||||
|
||||
if (stat (blk_dev, &st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", blk_dev);
|
||||
grub_util_error ("cannot stat `%s'", blk_dev);
|
||||
|
||||
if (S_ISBLK (st.st_mode))
|
||||
return (blk_dev);
|
||||
|
@ -622,7 +622,7 @@ grub_util_check_char_device (const char *blk_dev)
|
|||
struct stat st;
|
||||
|
||||
if (stat (blk_dev, &st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", blk_dev);
|
||||
grub_util_error ("cannot stat `%s'", blk_dev);
|
||||
|
||||
if (S_ISCHR (st.st_mode))
|
||||
return (blk_dev);
|
||||
|
|
|
@ -69,10 +69,10 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``grub-editenv --help'' for more information.\n");
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: grub-editenv [OPTIONS] [FILENAME] COMMAND\n\
|
||||
Usage: %s [OPTIONS] [FILENAME] COMMAND\n\
|
||||
\n\
|
||||
Tool to edit environment block.\n\
|
||||
\nCommands:\n\
|
||||
|
@ -88,7 +88,7 @@ Tool to edit environment block.\n\
|
|||
If not given explicitly, FILENAME defaults to %s.\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n",
|
||||
DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT);
|
||||
program_name, DEFAULT_DIRECTORY "/" GRUB_ENVBLK_DEFCFG, PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
|
|
@ -129,10 +129,10 @@ usage (int status)
|
|||
{
|
||||
if (status)
|
||||
fprintf (stderr,
|
||||
"Try ``grub-emu --help'' for more information.\n");
|
||||
"Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf (
|
||||
"Usage: grub-emu [OPTION]...\n"
|
||||
"Usage: %s [OPTION]...\n"
|
||||
"\n"
|
||||
"GRUB emulator.\n"
|
||||
"\n"
|
||||
|
@ -144,7 +144,7 @@ usage (int status)
|
|||
" -h, --help display this message and exit\n"
|
||||
" -V, --version print version information and exit\n"
|
||||
"\n"
|
||||
"Report bugs to <%s>.\n", DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
"Report bugs to <%s>.\n", program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -220,14 +220,14 @@ main (int argc, char *argv[])
|
|||
{
|
||||
char *device_name = grub_guess_root_device (dir);
|
||||
if (! device_name)
|
||||
grub_util_error ("cannot find a device for %s.\n", dir);
|
||||
grub_util_error ("cannot find a device for %s", dir);
|
||||
|
||||
root_dev = grub_util_get_grub_dev (device_name);
|
||||
if (! root_dev)
|
||||
{
|
||||
grub_util_info ("guessing the root device failed, because of `%s'",
|
||||
grub_errmsg);
|
||||
grub_util_error ("Cannot guess the root device. Specify the option ``--root-device''.");
|
||||
grub_util_error ("cannot guess the root device. Specify the option `--root-device'");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ execute_command (char *name, int n, char **args)
|
|||
|
||||
cmd = grub_command_find (name);
|
||||
if (! cmd)
|
||||
grub_util_error ("Can\'t find command %s", name);
|
||||
grub_util_error ("can\'t find command %s", name);
|
||||
|
||||
return (cmd->func) (cmd, n, args);
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
|
||||
dev = grub_device_open (0);
|
||||
if ((! dev) || (! dev->disk))
|
||||
grub_util_error ("Can\'t open device.");
|
||||
grub_util_error ("can\'t open device");
|
||||
|
||||
grub_util_info ("total sectors : %lld.",
|
||||
grub_util_info ("total sectors : %lld",
|
||||
(unsigned long long) dev->disk->total_sectors);
|
||||
|
||||
if (! leng)
|
||||
|
@ -115,7 +115,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
len = (leng > BUF_SIZE) ? BUF_SIZE : leng;
|
||||
|
||||
if (grub_disk_read (dev->disk, 0, skip, len, buf))
|
||||
grub_util_error ("Disk read fails at offset %lld, length %d.",
|
||||
grub_util_error ("disk read fails at offset %lld, length %d",
|
||||
skip, len);
|
||||
|
||||
if (hook (skip, buf, len))
|
||||
|
@ -132,15 +132,15 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
file = grub_file_open (pathname);
|
||||
if (!file)
|
||||
{
|
||||
grub_util_error ("cannot open file %s.", pathname);
|
||||
grub_util_error ("cannot open file %s", pathname);
|
||||
return;
|
||||
}
|
||||
|
||||
grub_util_info ("file size : %lld.", (unsigned long long) file->size);
|
||||
grub_util_info ("file size : %lld", (unsigned long long) file->size);
|
||||
|
||||
if (skip > file->size)
|
||||
{
|
||||
grub_util_error ("invalid skip value %lld.", (unsigned long long) skip);
|
||||
grub_util_error ("invalid skip value %lld", (unsigned long long) skip);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
sz = grub_file_read (file, buf, (len > BUF_SIZE) ? BUF_SIZE : len);
|
||||
if (sz < 0)
|
||||
{
|
||||
grub_util_error ("read error at offset %llu.", ofs);
|
||||
grub_util_error ("read error at offset %llu", ofs);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ cmd_cp (char *src, char *dest)
|
|||
|
||||
if ((int) fwrite (buf, 1, len, ff) != len)
|
||||
{
|
||||
grub_util_error ("write error.");
|
||||
grub_util_error ("write error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ cmd_cp (char *src, char *dest)
|
|||
ff = fopen (dest, "wb");
|
||||
if (ff == NULL)
|
||||
{
|
||||
grub_util_error ("open error.");
|
||||
grub_util_error ("open error");
|
||||
return;
|
||||
}
|
||||
read_file (src, cp_hook);
|
||||
|
@ -212,7 +212,7 @@ cmd_cmp (char *src, char *dest)
|
|||
{
|
||||
if ((int) fread (buf_1, 1, len, ff) != len)
|
||||
{
|
||||
grub_util_error ("read error at offset %llu.", ofs);
|
||||
grub_util_error ("read error at offset %llu", ofs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ cmd_cmp (char *src, char *dest)
|
|||
for (i = 0; i < len; i++, ofs++)
|
||||
if (buf_1[i] != buf[i])
|
||||
{
|
||||
grub_util_error ("compare fail at offset %llu.", ofs);
|
||||
grub_util_error ("compare fail at offset %llu", ofs);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -233,12 +233,12 @@ cmd_cmp (char *src, char *dest)
|
|||
ff = fopen (dest, "rb");
|
||||
if (ff == NULL)
|
||||
{
|
||||
grub_util_error ("open error.");
|
||||
grub_util_error ("open error");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((skip) && (fseeko (ff, skip, SEEK_SET)))
|
||||
grub_util_error ("seek error.");
|
||||
grub_util_error ("seek error");
|
||||
|
||||
read_file (src, cmp_hook);
|
||||
fclose (ff);
|
||||
|
@ -286,13 +286,13 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
|
|||
for (i = 0; i < num_disks; i++)
|
||||
{
|
||||
if (grub_strlen (images[i]) + 7 > sizeof (host_file))
|
||||
grub_util_error ("Pathname %s too long.", images[i]);
|
||||
grub_util_error ("pathname %s too long", images[i]);
|
||||
|
||||
grub_sprintf (loop_name, "loop%d", i);
|
||||
grub_sprintf (host_file, "(host)%s", images[i]);
|
||||
|
||||
if (execute_command ("loopback", 3, argv))
|
||||
grub_util_error ("loopback command fails.");
|
||||
grub_util_error ("loopback command fails");
|
||||
}
|
||||
|
||||
grub_lvm_fini ();
|
||||
|
@ -349,7 +349,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... IMAGE_PATH COMMANDS\n\
|
||||
|
|
|
@ -40,6 +40,7 @@ else
|
|||
fi
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
||||
modules=
|
||||
|
@ -87,9 +88,11 @@ fi
|
|||
|
||||
INSTALL_DEVICE can be a GRUB device name or a system device filename.
|
||||
|
||||
grub-install copies GRUB images into the DIR/boot directory specified by
|
||||
--root-directory, and uses grub-setup to install grub into the boot
|
||||
sector.
|
||||
grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and
|
||||
OpenBSD), and uses grub-setup to install grub into the boot sector.
|
||||
|
||||
If the --root-directory option is used, then grub-install will copy
|
||||
images into the operating system installation rooted at that directory.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
|
@ -261,6 +264,10 @@ done
|
|||
# Write device to a variable so we don't have to traverse /dev every time.
|
||||
grub_device=`$grub_probe --target=device ${grubdir}`
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
fi
|
||||
|
||||
# Create the core image. First, auto-detect the filesystem module.
|
||||
fs_module=`$grub_probe --target=fs --device ${grub_device}`
|
||||
if test "x$fs_module" = x -a "x$modules" = x; then
|
||||
|
|
|
@ -94,6 +94,15 @@ convert_system_path_to_grub_path ()
|
|||
echo ${drive}${relative_path}
|
||||
}
|
||||
|
||||
save_default_entry ()
|
||||
{
|
||||
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
|
||||
cat << EOF
|
||||
savedefault
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_grub_to_access_device ()
|
||||
{
|
||||
device=$1
|
||||
|
|
|
@ -84,7 +84,7 @@ usage (int status)
|
|||
{
|
||||
if (status)
|
||||
fprintf (stderr,
|
||||
"Try ``%s --help'' for more information.\n", program_name);
|
||||
"Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]...\n\
|
||||
|
|
|
@ -103,7 +103,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTIONS] FONT_FILES\n\
|
||||
|
@ -387,7 +387,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
|||
|
||||
file = fopen (output_file, "wb");
|
||||
if (! file)
|
||||
grub_util_error ("Can\'t write to file %s.", output_file);
|
||||
grub_util_error ("can\'t write to file %s.", output_file);
|
||||
|
||||
offset = 0;
|
||||
|
||||
|
@ -584,7 +584,7 @@ main (int argc, char *argv[])
|
|||
|
||||
a = strtoul (p, &p, 0);
|
||||
if (*p != '-')
|
||||
grub_util_error ("Invalid font range");
|
||||
grub_util_error ("invalid font range");
|
||||
b = strtoul (p + 1, &p, 0);
|
||||
if ((font_info.num_range & (GRUB_FONT_RANGE_BLOCK - 1)) == 0)
|
||||
font_info.ranges = xrealloc (font_info.ranges,
|
||||
|
@ -599,7 +599,7 @@ main (int argc, char *argv[])
|
|||
if (*p)
|
||||
{
|
||||
if (*p != ',')
|
||||
grub_util_error ("Invalid font range");
|
||||
grub_util_error ("invalid font range");
|
||||
else
|
||||
p++;
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (! output_file)
|
||||
grub_util_error ("No output file is specified.");
|
||||
grub_util_error ("no output file is specified");
|
||||
|
||||
if (FT_Init_FreeType (&ft_lib))
|
||||
grub_util_error ("FT_Init_FreeType fails");
|
||||
|
@ -669,7 +669,7 @@ main (int argc, char *argv[])
|
|||
|
||||
if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face))
|
||||
{
|
||||
grub_util_info ("Can't open file %s, index %d\n", argv[optind],
|
||||
grub_util_info ("can't open file %s, index %d", argv[optind],
|
||||
font_index);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -74,16 +74,16 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``grub-scrypt --help'' for more information.\n");
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: grub-scrypt [OPTIONS]\n\
|
||||
Usage: %s [OPTIONS]\n\
|
||||
\nOptions:\n\
|
||||
-c number, --iteration-count=number Number of PBKDF2 iterations\n\
|
||||
-l number, --buflen=number Length of generated hash\n\
|
||||
-s number, --salt=number Length of salt\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
|
||||
Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
@ -123,9 +123,8 @@ main (int argc, char *argv[])
|
|||
int tty_changed;
|
||||
|
||||
set_program_name (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
grub_util_init_nls ();
|
||||
|
||||
/* Check for options. */
|
||||
while (1)
|
||||
|
@ -166,12 +165,12 @@ main (int argc, char *argv[])
|
|||
|
||||
bufhex = malloc (buflen * 2 + 1);
|
||||
if (!bufhex)
|
||||
grub_util_error ("Out of memory");
|
||||
grub_util_error ("out of memory");
|
||||
buf = malloc (buflen);
|
||||
if (!buf)
|
||||
{
|
||||
free (bufhex);
|
||||
grub_util_error ("Out of memory");
|
||||
grub_util_error ("out of memory");
|
||||
}
|
||||
|
||||
salt = malloc (saltlen);
|
||||
|
@ -179,7 +178,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
free (bufhex);
|
||||
free (buf);
|
||||
grub_util_error ("Out of memory");
|
||||
grub_util_error ("out of memory");
|
||||
}
|
||||
salthex = malloc (saltlen * 2 + 1);
|
||||
if (!salthex)
|
||||
|
@ -187,7 +186,7 @@ main (int argc, char *argv[])
|
|||
free (salt);
|
||||
free (bufhex);
|
||||
free (buf);
|
||||
grub_util_error ("Out of memory");
|
||||
grub_util_error ("out of memory");
|
||||
}
|
||||
|
||||
/* Disable echoing. Based on glibc. */
|
||||
|
@ -226,7 +225,7 @@ main (int argc, char *argv[])
|
|||
/* Restore the original setting. */
|
||||
if (tty_changed)
|
||||
(void) tcsetattr (fileno (in), TCSAFLUSH, &s);
|
||||
grub_util_error ("Failure to read password");
|
||||
grub_util_error ("failure to read password");
|
||||
}
|
||||
if (nr >= 1 && pass1[nr-1] == '\n')
|
||||
pass1[nr-1] = 0;
|
||||
|
@ -250,7 +249,7 @@ main (int argc, char *argv[])
|
|||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
grub_util_error ("Failure to read password");
|
||||
grub_util_error ("failure to read password");
|
||||
}
|
||||
if (nr >= 1 && pass2[nr-1] == '\n')
|
||||
pass2[nr-1] = 0;
|
||||
|
@ -265,7 +264,7 @@ main (int argc, char *argv[])
|
|||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
grub_util_error ("Passwords don't match");
|
||||
grub_util_error ("passwords don't match");
|
||||
}
|
||||
memset (pass2, 0, strlen (pass2));
|
||||
free (pass2);
|
||||
|
@ -287,7 +286,7 @@ main (int argc, char *argv[])
|
|||
free (salthex);
|
||||
free (salt);
|
||||
fclose (f);
|
||||
grub_util_error ("Couldn't retrieve random data for salt");
|
||||
grub_util_error ("couldn't retrieve random data for salt");
|
||||
}
|
||||
rd = fread (salt, 1, saltlen, f);
|
||||
if (rd != saltlen)
|
||||
|
@ -300,7 +299,7 @@ main (int argc, char *argv[])
|
|||
free (salthex);
|
||||
free (salt);
|
||||
fclose (f);
|
||||
grub_util_error ("Couldn't retrieve random data for salt");
|
||||
grub_util_error ("couldn't retrieve random data for salt");
|
||||
}
|
||||
fclose (f);
|
||||
}
|
||||
|
@ -322,7 +321,7 @@ main (int argc, char *argv[])
|
|||
memset (salthex, 0, 2 * saltlen);
|
||||
free (salt);
|
||||
free (salthex);
|
||||
grub_util_error ("Cryptographic error number %d", gcry_err);
|
||||
grub_util_error ("cryptographic error number %d", gcry_err);
|
||||
}
|
||||
|
||||
hexify (bufhex, buf, buflen);
|
||||
|
|
|
@ -34,7 +34,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTIONS] PATH\n\
|
||||
|
|
|
@ -40,7 +40,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTIONS] input [output]\n\
|
||||
|
@ -182,7 +182,7 @@ write_section_data (FILE* fp, char *image,
|
|||
char name[5 + strlen (pe_shdr->name)];
|
||||
|
||||
if (num_sections >= MAX_SECTIONS)
|
||||
grub_util_error ("Too many sections");
|
||||
grub_util_error ("too many sections");
|
||||
|
||||
sprintf (name, ".rel%s", pe_shdr->name);
|
||||
|
||||
|
@ -230,14 +230,14 @@ write_reloc_section (FILE* fp, char *image,
|
|||
|
||||
if ((pe_rel->symtab_index >= pe_chdr->num_symbols) ||
|
||||
(symtab_map[pe_rel->symtab_index] == -1))
|
||||
grub_util_error ("Invalid symbol");
|
||||
grub_util_error ("invalid symbol");
|
||||
|
||||
if (pe_rel->type == GRUB_PE32_REL_I386_DIR32)
|
||||
type = R_386_32;
|
||||
else if (pe_rel->type == GRUB_PE32_REL_I386_REL32)
|
||||
type = R_386_PC32;
|
||||
else
|
||||
grub_util_error ("Unknown pe relocation type %d\n", pe_rel->type);
|
||||
grub_util_error ("unknown pe relocation type %d\n", pe_rel->type);
|
||||
|
||||
ofs = pe_rel->offset - pe_sec->virtual_address;
|
||||
addr = (grub_uint32_t *)(image + pe_sec->raw_data_offset + ofs);
|
||||
|
@ -248,14 +248,14 @@ write_reloc_section (FILE* fp, char *image,
|
|||
code = image[pe_sec->raw_data_offset + ofs - 1];
|
||||
|
||||
if (((code != 0xe8) && (code != 0xe9)) || (*addr))
|
||||
grub_util_error ("Invalid relocation (%x %x)", code, *addr);
|
||||
grub_util_error ("invalid relocation (%x %x)", code, *addr);
|
||||
|
||||
modified = 1;
|
||||
if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx)
|
||||
{
|
||||
if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx
|
||||
!= shdr[i].sh_info)
|
||||
grub_util_error ("Cross section call is not allowed");
|
||||
grub_util_error ("cross section call is not allowed");
|
||||
|
||||
*addr = (symtab[symtab_map[pe_rel->symtab_index]].st_value
|
||||
- ofs - 4);
|
||||
|
@ -440,7 +440,7 @@ convert_pe (FILE* fp, char *image)
|
|||
|
||||
pe_chdr = (struct grub_pe32_coff_header *) image;
|
||||
if (grub_le_to_cpu16 (pe_chdr->machine) != GRUB_PE32_MACHINE_I386)
|
||||
grub_util_error ("Invalid coff image");
|
||||
grub_util_error ("invalid coff image");
|
||||
|
||||
strtab = xmalloc (STRTAB_BLOCK);
|
||||
strtab_max = STRTAB_BLOCK;
|
||||
|
|
|
@ -84,7 +84,7 @@ probe_partmap (grub_disk_t disk)
|
|||
{
|
||||
if (disk->partition == NULL)
|
||||
{
|
||||
grub_util_info ("No partition map found for %s", disk->name);
|
||||
grub_util_info ("no partition map found for %s", disk->name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,17 +113,17 @@ probe (const char *path, char *device_name)
|
|||
{
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if (! grub_util_check_char_device (device_name))
|
||||
grub_util_error ("%s is not a character device.\n", device_name);
|
||||
grub_util_error ("%s is not a character device", device_name);
|
||||
#else
|
||||
if (! grub_util_check_block_device (device_name))
|
||||
grub_util_error ("%s is not a block device.\n", device_name);
|
||||
grub_util_error ("%s is not a block device", device_name);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
device_name = grub_guess_root_device (path);
|
||||
|
||||
if (! device_name)
|
||||
grub_util_error ("cannot find a device for %s (is /dev mounted?).\n", path);
|
||||
grub_util_error ("cannot find a device for %s (is /dev mounted?)", path);
|
||||
|
||||
if (print == PRINT_DEVICE)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ probe (const char *path, char *device_name)
|
|||
|
||||
drive_name = grub_util_get_grub_dev (device_name);
|
||||
if (! drive_name)
|
||||
grub_util_error ("Cannot find a GRUB drive for %s. Check your device.map.\n", device_name);
|
||||
grub_util_error ("cannot find a GRUB drive for %s. Check your device.map", device_name);
|
||||
|
||||
if (print == PRINT_DRIVE)
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ usage (int status)
|
|||
{
|
||||
if (status)
|
||||
fprintf (stderr,
|
||||
"Try ``%s --help'' for more information.\n", program_name);
|
||||
"Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... [PATH|DEVICE]\n\
|
||||
|
|
108
util/grub-reboot.in
Normal file
108
util/grub-reboot.in
Normal file
|
@ -0,0 +1,108 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Set a default boot entry for GRUB, for the next boot only.
|
||||
# Copyright (C) 2004,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION] entry
|
||||
Set the default boot entry for GRUB, for the next boot only.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--root-directory=DIR expect GRUB images under the directory DIR
|
||||
instead of the root directory
|
||||
|
||||
ENTRY is a number or a menu item title.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "grub-reboot (GNU GRUB ${PACKAGE_VERSION})"
|
||||
exit 0 ;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if test "x$entry" != x; then
|
||||
echo "More than one entry?" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
entry="${option}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test "x$entry" = x; then
|
||||
echo "entry not specified." 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=`echo /grub | sed ${transform}`
|
||||
bootdir=${rootdir}
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
bootdir=${rootdir}/boot
|
||||
;;
|
||||
esac
|
||||
|
||||
grubdir=${bootdir}/`echo grub | sed ${transform}`
|
||||
|
||||
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
|
||||
if [ "$prev_saved_entry" ]; then
|
||||
$grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
|
||||
else
|
||||
# We need some non-empty value for prev_saved_entry so that GRUB will
|
||||
# recognise that grub-reboot has been used and restore the previous
|
||||
# saved entry. "0" is the same as an empty value, i.e. the first menu
|
||||
# entry.
|
||||
$grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
|
||||
fi
|
||||
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
||||
|
||||
# Bye.
|
||||
exit 0
|
250
util/grub-script-check.c
Normal file
250
util/grub-script-check.c
Normal file
|
@ -0,0 +1,250 @@
|
|||
/* grub-script-check.c - check grub script file for syntax errors */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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 <config.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/script_sh.h>
|
||||
|
||||
#include <grub_script_check_init.h>
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
void
|
||||
grub_putchar (int c)
|
||||
{
|
||||
putchar (c);
|
||||
}
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
grub_refresh (void)
|
||||
{
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
char *
|
||||
grub_script_execute_argument_to_string (struct grub_script_arg *arg __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_cmdline (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_cmdblock (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_cmdif (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
||||
{
|
||||
struct grub_script_cmd_menuentry *menu;
|
||||
menu = (struct grub_script_cmd_menuentry *)cmd;
|
||||
|
||||
if (menu->sourcecode)
|
||||
{
|
||||
grub_free (menu->sourcecode);
|
||||
menu->sourcecode = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute (struct grub_script *script)
|
||||
{
|
||||
if (script == 0 || script->cmd == 0)
|
||||
return 0;
|
||||
|
||||
return script->cmd->exec (script->cmd);
|
||||
}
|
||||
|
||||
static struct option options[] =
|
||||
{
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr,
|
||||
"Try ``%s --help'' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [PATH]\n\
|
||||
\n\
|
||||
Checks GRUB script configuration file for syntax errors.\n\
|
||||
\n\
|
||||
-h, --help display this message and exit\n\
|
||||
-V, --version print version information and exit\n\
|
||||
-v, --verbose print script being processed\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
", program_name,
|
||||
PACKAGE_BUGREPORT);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *argument;
|
||||
char *input;
|
||||
FILE *file = 0;
|
||||
int verbose = 0;
|
||||
struct grub_script *script;
|
||||
|
||||
auto grub_err_t get_config_line (char **line, int cont);
|
||||
grub_err_t get_config_line (char **line, int cont __attribute__ ((unused)))
|
||||
{
|
||||
char *cmdline = 0;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
||||
read = getline(&cmdline, &len, (file ?: stdin));
|
||||
if (read == -1)
|
||||
{
|
||||
*line = 0;
|
||||
grub_errno = GRUB_ERR_READ_ERROR;
|
||||
|
||||
if (cmdline)
|
||||
free (cmdline);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
grub_printf("%s", cmdline);
|
||||
|
||||
*line = grub_strdup (cmdline);
|
||||
|
||||
free (cmdline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_program_name (argv[0]);
|
||||
grub_util_init_nls ();
|
||||
|
||||
/* Check for options. */
|
||||
while (1)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "hvV", options, 0);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
else
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
usage (0);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
|
||||
return 0;
|
||||
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Obtain ARGUMENT. */
|
||||
if (optind >= argc)
|
||||
{
|
||||
file = 0; /* read from stdin */
|
||||
}
|
||||
else if (optind + 1 != argc)
|
||||
{
|
||||
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
|
||||
usage (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
argument = argv[optind];
|
||||
file = fopen (argument, "r");
|
||||
if (! file)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: %s\n", program_name, argument, strerror(errno));
|
||||
usage (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
|
||||
do
|
||||
{
|
||||
input = 0;
|
||||
get_config_line(&input, 0);
|
||||
if (! input)
|
||||
break;
|
||||
|
||||
script = grub_script_parse (input, get_config_line);
|
||||
if (script)
|
||||
{
|
||||
grub_script_execute (script);
|
||||
grub_script_free (script);
|
||||
}
|
||||
|
||||
grub_free (input);
|
||||
} while (script != 0);
|
||||
|
||||
/* Free resources. */
|
||||
grub_fini_all ();
|
||||
if (file) fclose (file);
|
||||
|
||||
return (script == 0);
|
||||
}
|
99
util/grub-set-default.in
Normal file
99
util/grub-set-default.in
Normal file
|
@ -0,0 +1,99 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Set a default boot entry for GRUB.
|
||||
# Copyright (C) 2004,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION] entry
|
||||
Set the default boot entry for GRUB.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--root-directory=DIR expect GRUB images under the directory DIR
|
||||
instead of the root directory
|
||||
|
||||
ENTRY is a number or a menu item title.
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
for option in "$@"; do
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "grub-set-default (GNU GRUB ${PACKAGE_VERSION})"
|
||||
exit 0 ;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
-*)
|
||||
echo "Unrecognized option \`$option'" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if test "x$entry" != x; then
|
||||
echo "More than one entry?" 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
entry="${option}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test "x$entry" = x; then
|
||||
echo "entry not specified." 1>&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize these directories here, since ROOTDIR was initialized.
|
||||
case "$host_os" in
|
||||
netbsd* | openbsd*)
|
||||
# Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
|
||||
# instead of /boot/grub.
|
||||
grub_prefix=`echo /grub | sed ${transform}`
|
||||
bootdir=${rootdir}
|
||||
;;
|
||||
*)
|
||||
# Use /boot/grub by default.
|
||||
bootdir=${rootdir}/boot
|
||||
;;
|
||||
esac
|
||||
|
||||
grubdir=${bootdir}/`echo grub | sed ${transform}`
|
||||
|
||||
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
||||
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
||||
|
||||
# Bye.
|
||||
exit 0
|
|
@ -34,11 +34,29 @@ for i in ${GRUB_PRELOAD_MODULES} ; do
|
|||
done
|
||||
|
||||
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
|
||||
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
|
||||
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
|
||||
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
|
||||
|
||||
cat << EOF
|
||||
set default=${GRUB_DEFAULT}
|
||||
if [ -s \$prefix/grubenv ]; then
|
||||
load_env
|
||||
fi
|
||||
set default="${GRUB_DEFAULT}"
|
||||
if [ \${prev_saved_entry} ]; then
|
||||
set saved_entry=\${prev_saved_entry}
|
||||
save_env saved_entry
|
||||
set prev_saved_entry=
|
||||
save_env prev_saved_entry
|
||||
set boot_once=true
|
||||
fi
|
||||
|
||||
function savedefault {
|
||||
if [ -z \${boot_once} ]; then
|
||||
saved_entry=\${chosen}
|
||||
save_env saved_entry
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
|
||||
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
|
||||
|
|
|
@ -76,6 +76,7 @@ cat << EOF
|
|||
echo $(gettext "Loading GNU Mach ...")
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
echo $(gettext "Loading the Hurd ...")
|
||||
|
|
|
@ -39,6 +39,7 @@ kfreebsd_entry ()
|
|||
args="$4" # not used yet
|
||||
title="$(gettext "%s, with kFreeBSD %s")"
|
||||
printf "menuentry \"${title}\" {\n" "${os}" "${version}"
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
|
|
|
@ -59,6 +59,7 @@ linux_entry ()
|
|||
title="$(gettext "%s, with Linux %s")"
|
||||
fi
|
||||
printf "menuentry \"${title}\" {\n" "${os}" "${version}"
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
|
|
|
@ -73,6 +73,7 @@ for dir in $dirlist ; do
|
|||
menuentry "$OS" {
|
||||
EOF
|
||||
|
||||
save_default_entry | sed -e 's,^,\t,'
|
||||
prepare_grub_to_access_device "$dev" | sed 's,^,\t,'
|
||||
|
||||
cat << EOF
|
||||
|
|
|
@ -41,13 +41,14 @@ osx_entry() {
|
|||
cat << EOF
|
||||
menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
cat << EOF
|
||||
insmod ${GRUB_VIDEO_BACKEND}
|
||||
do_resume=0
|
||||
set do_resume=0
|
||||
if [ /var/vm/sleepimage -nt10 / ]; then
|
||||
if xnu_resume /var/vm/sleepimage; then
|
||||
do_resume=1
|
||||
set do_resume=1
|
||||
fi
|
||||
fi
|
||||
if [ \$do_resume == 0 ]; then
|
||||
|
@ -105,6 +106,7 @@ for OS in ${OSPROBED} ; do
|
|||
cat << EOF
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
||||
case ${LONGNAME} in
|
||||
|
@ -146,6 +148,7 @@ EOF
|
|||
cat << EOF
|
||||
menuentry "${LLABEL} (on ${DEVICE})" {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
|
@ -172,6 +175,7 @@ EOF
|
|||
cat << EOF
|
||||
menuentry "${LONGNAME} (on ${DEVICE})" {
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
|
||||
mach_device="`echo "${grub_device}" | tr -d '()' | tr , s`"
|
||||
|
|
|
@ -568,7 +568,7 @@ read_device_map (const char *dev_map)
|
|||
fp = fopen (dev_map, "r");
|
||||
if (! fp)
|
||||
{
|
||||
grub_util_info (_("Cannot open `%s'"), dev_map);
|
||||
grub_util_info (_("cannot open `%s'"), dev_map);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -639,7 +639,7 @@ read_device_map (const char *dev_map)
|
|||
symbolic links. */
|
||||
map[drive].device = xmalloc (PATH_MAX);
|
||||
if (! realpath (p, map[drive].device))
|
||||
grub_util_error ("Cannot get the real path of `%s'", p);
|
||||
grub_util_error ("cannot get the real path of `%s'", p);
|
||||
#else
|
||||
map[drive].device = xstrdup (p);
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t
|
|||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
||||
modules=
|
||||
|
@ -179,6 +180,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
|
|||
cp -f $file ${grubdir} || exit 1
|
||||
done
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
fi
|
||||
|
||||
# Create the core image. First, auto-detect the filesystem module.
|
||||
fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
|
||||
if test "x$fs_module" = xfat; then :; else
|
||||
|
|
|
@ -778,7 +778,7 @@ make_reloc_section (FILE *out, Elf_Addr current_address, Elf_Ehdr *e,
|
|||
if ((ELF_R_TYPE (info) == R_X86_64_32) ||
|
||||
(ELF_R_TYPE (info) == R_X86_64_32S))
|
||||
{
|
||||
grub_util_error ("Can\'t add fixup entry for R_X86_64_32(S)");
|
||||
grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)");
|
||||
}
|
||||
else if (ELF_R_TYPE (info) == R_X86_64_64)
|
||||
{
|
||||
|
@ -1029,10 +1029,10 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``grub-mkimage --help'' for more information.\n");
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: grub-mkimage -o FILE [OPTION]... [MODULES]\n\
|
||||
Usage: %s -o FILE [OPTION]... [MODULES]\n\
|
||||
\n\
|
||||
Make a bootable image of GRUB.\n\
|
||||
\n\
|
||||
|
@ -1044,7 +1044,7 @@ Make a bootable image of GRUB.\n\
|
|||
-v, --verbose print verbose messages\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
", GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
", program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
|
|
@ -289,7 +289,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
|
||||
grub_util_error (_("Core image is too big (%p > %p)\n"),
|
||||
grub_util_error (_("core image is too big (%p > %p)"),
|
||||
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size, GRUB_MEMORY_MACHINE_UPPER);
|
||||
#endif
|
||||
|
||||
|
@ -326,10 +326,10 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name);
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
|
||||
else
|
||||
printf (_("\
|
||||
Usage: grub-mkimage [OPTION]... [MODULES]\n\
|
||||
Usage: %s [OPTION]... [MODULES]\n\
|
||||
\n\
|
||||
Make a bootable image of GRUB.\n\
|
||||
\n\
|
||||
|
@ -343,7 +343,7 @@ Make a bootable image of GRUB.\n\
|
|||
-v, --verbose print verbose messages\n\
|
||||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
"), GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
"), program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ setup (const char *dir,
|
|||
sector, offset, length);
|
||||
|
||||
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("The first sector of the core file is not sector-aligned"));
|
||||
grub_util_error (_("the first sector of the core file is not sector-aligned"));
|
||||
|
||||
first_sector = sector;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ setup (const char *dir,
|
|||
sector, offset, length, (unsigned) current_segment);
|
||||
|
||||
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("Non-sector-aligned data is found in the core file"));
|
||||
grub_util_error (_("non-sector-aligned data is found in the core file"));
|
||||
|
||||
if (block != first_block
|
||||
&& (grub_le_to_cpu64 (prev->start)
|
||||
|
@ -184,7 +184,7 @@ setup (const char *dir,
|
|||
|
||||
block--;
|
||||
if (block->len)
|
||||
grub_util_error (_("The sectors of the core file are too fragmented"));
|
||||
grub_util_error (_("the sectors of the core file are too fragmented"));
|
||||
}
|
||||
|
||||
last_length = length;
|
||||
|
@ -195,7 +195,7 @@ setup (const char *dir,
|
|||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("The size of `%s' is not %u"),
|
||||
grub_util_error (_("the size of `%s' is not %u"),
|
||||
boot_path, GRUB_DISK_SECTOR_SIZE);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
free (boot_path);
|
||||
|
@ -212,9 +212,9 @@ setup (const char *dir,
|
|||
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
if (core_size < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("The size of `%s' is too small"), core_path);
|
||||
grub_util_error (_("the size of `%s' is too small"), core_path);
|
||||
else if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("The size of `%s' is too large"), core_path);
|
||||
grub_util_error (_("the size of `%s' is too large"), core_path);
|
||||
|
||||
core_img = grub_util_read_image (core_path);
|
||||
|
||||
|
@ -251,7 +251,7 @@ setup (const char *dir,
|
|||
grub_fs_t fs;
|
||||
fs = grub_fs_probe (dest_dev);
|
||||
if (! fs)
|
||||
grub_util_error (_("Unable to identify a filesystem in %s; safety check can't be performed"),
|
||||
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
|
||||
dest_dev->disk->name);
|
||||
|
||||
if (! fs->reserved_first_sector)
|
||||
|
@ -304,7 +304,7 @@ setup (const char *dir,
|
|||
bsd_part = -1;
|
||||
}
|
||||
else
|
||||
grub_util_error (_("No DOS-style partitions found"));
|
||||
grub_util_error (_("no DOS-style partitions found"));
|
||||
}
|
||||
else
|
||||
dos_part = bsd_part = -1;
|
||||
|
@ -413,14 +413,14 @@ setup (const char *dir,
|
|||
unable_to_embed:
|
||||
|
||||
if (must_embed)
|
||||
grub_util_error (_("Embedding is not possible, but this is required when "
|
||||
"the root device is on a RAID array or LVM volume."));
|
||||
grub_util_error (_("embedding is not possible, but this is required when "
|
||||
"the root device is on a RAID array or LVM volume"));
|
||||
|
||||
grub_util_warn (_("Embedding is not possible. GRUB can only be installed in this "
|
||||
"setup by using blocklists. However, blocklists are UNRELIABLE and "
|
||||
"its use is discouraged."));
|
||||
if (! force)
|
||||
grub_util_error (_("If you really want blocklists, use --force."));
|
||||
grub_util_error (_("if you really want blocklists, use --force"));
|
||||
|
||||
/* Make sure that GRUB reads the identical image as the OS. */
|
||||
tmp_img = xmalloc (core_size);
|
||||
|
@ -495,7 +495,7 @@ unable_to_embed:
|
|||
}
|
||||
|
||||
if (i == MAX_TRIES)
|
||||
grub_util_error (_("Cannot read `%s' correctly"), core_path_dev);
|
||||
grub_util_error (_("cannot read `%s' correctly"), core_path_dev);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
block = first_block;
|
||||
|
@ -508,7 +508,7 @@ unable_to_embed:
|
|||
block--;
|
||||
|
||||
if ((char *) block <= core_img)
|
||||
grub_util_error (_("No terminator in the core image"));
|
||||
grub_util_error (_("no terminator in the core image"));
|
||||
}
|
||||
|
||||
/* Now read the core image to determine where the sectors are. */
|
||||
|
@ -519,13 +519,13 @@ unable_to_embed:
|
|||
file->read_hook = save_first_sector;
|
||||
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
|
||||
!= GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("Failed to read the first sector of the core image"));
|
||||
grub_util_error (_("failed to read the first sector of the core image"));
|
||||
|
||||
block = first_block;
|
||||
file->read_hook = save_blocklists;
|
||||
if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE)
|
||||
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("Failed to read the rest sectors of the core image"));
|
||||
grub_util_error (_("failed to read the rest sectors of the core image"));
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
|
@ -544,7 +544,7 @@ unable_to_embed:
|
|||
grub_util_info ("opening the core image `%s'", core_path);
|
||||
fp = fopen (core_path, "r+b");
|
||||
if (! fp)
|
||||
grub_util_error (_("Cannot open `%s'"), core_path);
|
||||
grub_util_error (_("cannot open `%s'"), core_path);
|
||||
|
||||
grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp);
|
||||
fclose (fp);
|
||||
|
@ -584,13 +584,13 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name);
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
|
||||
else
|
||||
printf (_("\
|
||||
Usage: grub-setup [OPTION]... DEVICE\n\
|
||||
Usage: %s [OPTION]... DEVICE\n\
|
||||
\n\
|
||||
Set up images to boot from DEVICE.\n\
|
||||
DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
|
||||
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
|
||||
\n\
|
||||
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
|
||||
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
|
||||
|
@ -605,6 +605,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
|
|||
\n\
|
||||
Report bugs to <%s>.\n\
|
||||
"),
|
||||
program_name,
|
||||
DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
|
||||
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
|
||||
|
||||
|
@ -751,7 +752,7 @@ main (int argc, char *argv[])
|
|||
char *tmp = get_device_name (root_dev);
|
||||
|
||||
if (! tmp)
|
||||
grub_util_error (_("Invalid root device `%s'"), root_dev);
|
||||
grub_util_error (_("invalid root device `%s'"), root_dev);
|
||||
|
||||
tmp = xstrdup (tmp);
|
||||
free (root_dev);
|
||||
|
@ -764,7 +765,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
grub_util_info ("guessing the root device failed, because of `%s'",
|
||||
grub_errmsg);
|
||||
grub_util_error (_("Cannot guess the root device. Specify the option ``--root-device''."));
|
||||
grub_util_error (_("cannot guess the root device. Specify the option `--root-device'"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${t
|
|||
grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
rootdir=
|
||||
grub_prefix=`echo /boot/grub | sed ${transform}`
|
||||
modules=
|
||||
|
@ -163,6 +164,10 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst ; do
|
|||
cp -f $file ${grubdir} || exit 1
|
||||
done
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
fi
|
||||
|
||||
# Create the core image. First, auto-detect the filesystem module.
|
||||
fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}`
|
||||
if test "x$fs_module" = x -a "x$modules" = x; then
|
||||
|
|
|
@ -131,12 +131,12 @@ block_device_get_sysfs_path_and_link(const char *devicenode,
|
|||
snprintf(sysfs_path, sysfs_path_len, "/sys/block/%s", devicenode);
|
||||
|
||||
if (!realpath (sysfs_path, rpath))
|
||||
grub_util_error ("Cannot get the real path of `%s'", sysfs_path);
|
||||
grub_util_error ("cannot get the real path of `%s'", sysfs_path);
|
||||
|
||||
strcat(rpath, "/device");
|
||||
|
||||
if (!realpath (rpath, sysfs_path))
|
||||
grub_util_error ("Cannot get the real path of `%s'", rpath);
|
||||
grub_util_error ("cannot get the real path of `%s'", rpath);
|
||||
|
||||
free (rpath);
|
||||
}
|
||||
|
@ -247,12 +247,12 @@ vendor_is_ATA(const char *path)
|
|||
snprintf(buf, PATH_MAX, "%s/vendor", path);
|
||||
fd = open(buf, O_RDONLY);
|
||||
if (fd < 0)
|
||||
grub_util_error ("Cannot open 'vendor' node of `%s'", path);
|
||||
grub_util_error ("cannot open 'vendor' node of `%s'", path);
|
||||
|
||||
memset(buf, 0, PATH_MAX);
|
||||
err = read(fd, buf, PATH_MAX);
|
||||
if (err < 0)
|
||||
grub_util_error ("Cannot read 'vendor' node of `%s'", path);
|
||||
grub_util_error ("cannot read 'vendor' node of `%s'", path);
|
||||
|
||||
close(fd);
|
||||
|
||||
|
@ -288,7 +288,7 @@ check_sas (char *sysfs_path, int *tgt)
|
|||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
grub_util_error("Cannot open SAS PHY ID '%s'\n", path);
|
||||
grub_util_error("cannot open SAS PHY ID `%s'\n", path);
|
||||
|
||||
memset (phy, 0, sizeof (phy));
|
||||
read (fd, phy, sizeof (phy));
|
||||
|
@ -375,7 +375,7 @@ grub_util_devname_to_ofpath (char *devname)
|
|||
name_buf = xmalloc (PATH_MAX);
|
||||
name_buf = realpath (devname, name_buf);
|
||||
if (! name_buf)
|
||||
grub_util_error ("Cannot get the real path of `%s'", devname);
|
||||
grub_util_error ("cannot get the real path of `%s'", devname);
|
||||
|
||||
device = get_basename (devname);
|
||||
devnode = strip_trailing_digits (devname);
|
||||
|
|
38
util/misc.c
38
util/misc.c
|
@ -60,11 +60,12 @@ grub_util_warn (const char *fmt, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf (stderr, "%s: warn: ", program_name);
|
||||
fprintf (stderr, _("%s: warn:"), program_name);
|
||||
fprintf (stderr, " ");
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stderr, fmt, ap);
|
||||
va_end (ap);
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, ".\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
|
@ -75,11 +76,12 @@ grub_util_info (const char *fmt, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf (stderr, "%s: info: ", program_name);
|
||||
fprintf (stderr, _("%s: info:"), program_name);
|
||||
fprintf (stderr, " ");
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stderr, fmt, ap);
|
||||
va_end (ap);
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, ".\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +91,12 @@ grub_util_error (const char *fmt, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf (stderr, "%s: error: ", program_name);
|
||||
fprintf (stderr, _("%s: error:"), program_name);
|
||||
fprintf (stderr, " ");
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stderr, fmt, ap);
|
||||
va_end (ap);
|
||||
fputc ('\n', stderr);
|
||||
fprintf (stderr, ".\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
@ -479,6 +482,19 @@ fail:
|
|||
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
char *
|
||||
canonicalize_file_name (const char *path)
|
||||
{
|
||||
char *ret;
|
||||
#ifdef PATH_MAX
|
||||
ret = xmalloc (PATH_MAX);
|
||||
(void) realpath (path, ret);
|
||||
#else
|
||||
ret = realpath (path, NULL);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This function never prints trailing slashes (so that its output
|
||||
can be appended a slash unconditionally). */
|
||||
char *
|
||||
|
@ -491,15 +507,11 @@ make_system_path_relative_to_its_root (const char *path)
|
|||
size_t len;
|
||||
|
||||
/* canonicalize. */
|
||||
p = realpath (path, NULL);
|
||||
p = canonicalize_file_name (path);
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
if (errno != EINVAL)
|
||||
grub_util_error ("failed to get realpath of %s", path);
|
||||
else
|
||||
grub_util_error ("realpath not supporting (path, NULL)");
|
||||
}
|
||||
grub_util_error ("failed to get canonical path of %s", path);
|
||||
|
||||
len = strlen (p) + 1;
|
||||
buf = strdup (p);
|
||||
free (p);
|
||||
|
|
|
@ -288,7 +288,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
|
|||
struct eltorito_boot_info bi_table;
|
||||
bootimage = fopen (de->whole_name, "r+b");
|
||||
if (bootimage == NULL)
|
||||
error (1, errno, _("Error opening boot image file '%s' for update"),
|
||||
error (1, errno, _("Error opening boot image file `%s' for update"),
|
||||
de->whole_name);
|
||||
/* Compute checksum of boot image, sans 64 bytes */
|
||||
total_len = 0;
|
||||
|
@ -296,7 +296,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
|
|||
while ((len = fread (csum_buffer, 1, SECTOR_SIZE, bootimage)) > 0)
|
||||
{
|
||||
if (total_len & 3)
|
||||
error (1, 0, _("Odd alignment at non-end-of-file in boot image '%s'"),
|
||||
error (1, 0, _("Odd alignment at non-end-of-file in boot image `%s'"),
|
||||
de->whole_name);
|
||||
if (total_len < 64)
|
||||
memset (csum_buffer, 0, 64 - total_len);
|
||||
|
@ -308,7 +308,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc)
|
|||
}
|
||||
|
||||
if (total_len != de->size)
|
||||
error (1, 0, _("Boot image file '%s' changed unexpectedly"),
|
||||
error (1, 0, _("Boot image file `%s' changed unexpectedly"),
|
||||
de->whole_name);
|
||||
/* End of file, set position to byte 8 */
|
||||
fseeko (bootimage, (off_t) 8, SEEK_SET);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
Copyright 1993 Yggdrasil Computing, Incorporated
|
||||
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009,2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -306,7 +306,7 @@ int deep_opt;
|
|||
* the symbolic link won't fit into one SL System Use Field
|
||||
* print an error message and continue with splited one
|
||||
*/
|
||||
fprintf(stderr, _("symbolic link ``%s'' to long for one SL System Use Field, splitting"), cpnt);
|
||||
fprintf (stderr, _("symbolic link `%s' too long for one SL System Use Field, splitting"), cpnt);
|
||||
}
|
||||
if(MAYBE_ADD_CE_ENTRY(SL_SIZE + sl_bytes)) add_CE_entry();
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ void FDECL4(xfwrite, void *, buffer, uint64_t, count, uint64_t, size, FILE *, fi
|
|||
sprintf(nbuf, "%s_%02d", outfile, idx++);
|
||||
file = freopen(nbuf, "wb", file);
|
||||
if (file == NULL)
|
||||
error (1, errno, _("Cannot open '%s'"), nbuf);
|
||||
error (1, errno, _("Cannot open `%s'"), nbuf);
|
||||
|
||||
}
|
||||
while(count)
|
||||
|
|
|
@ -50,7 +50,7 @@ grub_util_getdiskname (int major, int minor)
|
|||
else if (major == SCSI_DISK0_MAJOR)
|
||||
sprintf (name, "/dev/sd%c", 'a' + minor / 16);
|
||||
else
|
||||
grub_util_error ("Unknown device number: %d, %d", major, minor);
|
||||
grub_util_error ("unknown device number: %d, %d", major, minor);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ grub_util_raid_getmembers (char *name)
|
|||
fd = open (devname, O_RDONLY);
|
||||
|
||||
if (fd == -1)
|
||||
grub_util_error ("Can't open %s: %s", devname, strerror (errno));
|
||||
grub_util_error ("can't open %s: %s", devname, strerror (errno));
|
||||
|
||||
free (devname);
|
||||
|
||||
|
@ -81,7 +81,7 @@ grub_util_raid_getmembers (char *name)
|
|||
grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno));
|
||||
|
||||
if (version.major != 0 || version.minor != 90)
|
||||
grub_util_error ("Unsupported RAID version: %d.%d",
|
||||
grub_util_error ("unsupported RAID version: %d.%d",
|
||||
version.major, version.minor);
|
||||
|
||||
ret = ioctl (fd, GET_ARRAY_INFO, &info);
|
||||
|
|
|
@ -191,7 +191,7 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... [MODULES]\n\
|
||||
|
|
|
@ -161,7 +161,7 @@ setup (const char *prefix, const char *dir,
|
|||
grub_util_info ("first sector is <%llu,%u,%u>", sector, offset, length);
|
||||
|
||||
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("The first sector of the core file "
|
||||
grub_util_error ("the first sector of the core file "
|
||||
"is not sector-aligned");
|
||||
|
||||
first_sector = sector;
|
||||
|
@ -176,7 +176,7 @@ setup (const char *prefix, const char *dir,
|
|||
grub_util_info ("saving <%llu,%u,%u>", sector, offset, length);
|
||||
|
||||
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("Non-sector-aligned data is found in the core file");
|
||||
grub_util_error ("non-sector-aligned data is found in the core file");
|
||||
|
||||
if (block != first_block
|
||||
&& (grub_be_to_cpu64 (prev->start)
|
||||
|
@ -189,7 +189,7 @@ setup (const char *prefix, const char *dir,
|
|||
|
||||
block--;
|
||||
if (block->len)
|
||||
grub_util_error ("The sectors of the core file are too fragmented");
|
||||
grub_util_error ("the sectors of the core file are too fragmented");
|
||||
}
|
||||
|
||||
last_length = length;
|
||||
|
@ -201,7 +201,7 @@ setup (const char *prefix, const char *dir,
|
|||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("The size of `%s' is not %d",
|
||||
grub_util_error ("the size of `%s' is not %d",
|
||||
boot_path, GRUB_DISK_SECTOR_SIZE);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
free (boot_path);
|
||||
|
@ -219,7 +219,7 @@ setup (const char *prefix, const char *dir,
|
|||
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
if (core_size < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("The size of `%s' is too small", core_path);
|
||||
grub_util_error ("the size of `%s' is too small", core_path);
|
||||
|
||||
core_img = grub_util_read_image (core_path);
|
||||
free (core_path);
|
||||
|
@ -229,7 +229,7 @@ setup (const char *prefix, const char *dir,
|
|||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*block));
|
||||
|
||||
grub_util_info ("root is '%s', dest is '%s', and dest_ofpath is '%s'",
|
||||
grub_util_info ("root is `%s', dest is `%s', and dest_ofpath is `%s'",
|
||||
root, dest, dest_ofpath);
|
||||
|
||||
/* Open the root device and the destination device. */
|
||||
|
@ -320,7 +320,7 @@ setup (const char *prefix, const char *dir,
|
|||
}
|
||||
|
||||
if (i == MAX_TRIES)
|
||||
grub_util_error ("Cannot read `%s' correctly", core_path);
|
||||
grub_util_error ("cannot read `%s' correctly", core_path);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
block = first_block;
|
||||
|
@ -332,7 +332,7 @@ setup (const char *prefix, const char *dir,
|
|||
block--;
|
||||
|
||||
if ((char *) block <= core_img)
|
||||
grub_util_error ("No terminator in the core image");
|
||||
grub_util_error ("no terminator in the core image");
|
||||
}
|
||||
|
||||
/* Now read the core image to determine where the sectors are. */
|
||||
|
@ -343,13 +343,13 @@ setup (const char *prefix, const char *dir,
|
|||
file->read_hook = save_first_sector;
|
||||
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
|
||||
!= GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("Failed to read the first sector of the core image");
|
||||
grub_util_error ("failed to read the first sector of the core image");
|
||||
|
||||
block = first_block;
|
||||
file->read_hook = save_blocklists;
|
||||
if (grub_file_read (file, tmp_img, core_size - GRUB_DISK_SECTOR_SIZE)
|
||||
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("Failed to read the rest sectors of the core image");
|
||||
grub_util_error ("failed to read the rest sectors of the core image");
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
|
@ -368,7 +368,7 @@ setup (const char *prefix, const char *dir,
|
|||
grub_util_info ("opening the core image `%s'", core_path);
|
||||
fp = fopen (core_path, "r+b");
|
||||
if (! fp)
|
||||
grub_util_error ("Cannot open `%s'", core_path);
|
||||
grub_util_error ("cannot open `%s'", core_path);
|
||||
|
||||
grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE, fp);
|
||||
fclose (fp);
|
||||
|
@ -404,13 +404,13 @@ static void
|
|||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTION]... DEVICE\n\
|
||||
\n\
|
||||
Set up images to boot from DEVICE.\n\
|
||||
DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\
|
||||
DEVICE must be a GRUB device (e.g. `(hd0,1)').\n\
|
||||
\n\
|
||||
-b, --boot-image=FILE use FILE as the boot image [default=%s]\n\
|
||||
-c, --core-image=FILE use FILE as the core image [default=%s]\n\
|
||||
|
@ -559,14 +559,14 @@ find_dest_dev (struct grub_setup_info *gp, char *argv[])
|
|||
fprintf (stderr, "Invalid device `%s'.\n", argv[optind]);
|
||||
usage (1);
|
||||
}
|
||||
grub_util_info ("transformed OS device '%s' into GRUB device '%s'",
|
||||
grub_util_info ("transformed OS device `%s' into GRUB device `%s'",
|
||||
argv[optind], gp->dest_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For simplicity. */
|
||||
gp->dest_dev = xstrdup (gp->dest_dev);
|
||||
grub_util_info ("Using '%s' as GRUB device", gp->dest_dev);
|
||||
grub_util_info ("Using `%s' as GRUB device", gp->dest_dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ check_root_dev (struct grub_setup_info *gp)
|
|||
char *tmp = get_device_name (gp->root_dev);
|
||||
|
||||
if (! tmp)
|
||||
grub_util_error ("Invalid root device `%s'", gp->root_dev);
|
||||
grub_util_error ("invalid root device `%s'", gp->root_dev);
|
||||
|
||||
tmp = xstrdup (tmp);
|
||||
free (gp->root_dev);
|
||||
|
@ -594,11 +594,11 @@ check_root_dev (struct grub_setup_info *gp)
|
|||
{
|
||||
grub_util_info ("guessing the root device failed, because of `%s'",
|
||||
grub_errmsg);
|
||||
grub_util_error ("Cannot guess the root device. "
|
||||
"Specify the option ``--root-device''.");
|
||||
grub_util_error ("cannot guess the root device. "
|
||||
"Specify the option `--root-device'");
|
||||
}
|
||||
grub_util_info ("Guessed root device '%s' and root_dev '%s' from "
|
||||
"dir '%s'", root_device, gp->root_dev, dir);
|
||||
grub_util_info ("guessed root device `%s' and root_dev `%s' from "
|
||||
"dir `%s'", root_device, gp->root_dev, dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ grub_video_gop_fill_mode_info (struct grub_efi_gop_mode_info *in,
|
|||
|
||||
static grub_err_t
|
||||
grub_video_gop_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type)
|
||||
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
|
||||
{
|
||||
unsigned int depth;
|
||||
struct grub_efi_gop_mode_info *info = NULL;
|
||||
|
@ -353,6 +353,7 @@ grub_video_gop_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
|||
static struct grub_video_adapter grub_video_gop_adapter =
|
||||
{
|
||||
.name = "EFI GOP driver",
|
||||
.id = GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||
|
||||
.init = grub_video_gop_init,
|
||||
.fini = grub_video_gop_fini,
|
||||
|
|
|
@ -198,7 +198,7 @@ grub_video_uga_fini (void)
|
|||
|
||||
static grub_err_t
|
||||
grub_video_uga_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type)
|
||||
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
|
||||
{
|
||||
unsigned int depth;
|
||||
int found = 0;
|
||||
|
@ -300,6 +300,7 @@ grub_video_uga_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
|||
static struct grub_video_adapter grub_video_uga_adapter =
|
||||
{
|
||||
.name = "EFI UGA driver",
|
||||
.id = GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||
|
||||
.init = grub_video_uga_init,
|
||||
.fini = grub_video_uga_fini,
|
||||
|
|
|
@ -369,7 +369,7 @@ grub_video_vbe_fini (void)
|
|||
|
||||
static grub_err_t
|
||||
grub_video_vbe_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type)
|
||||
unsigned int mode_type, unsigned int mode_mask)
|
||||
{
|
||||
grub_uint16_t *p;
|
||||
struct grub_vbe_mode_info_block vbe_mode_info;
|
||||
|
@ -415,22 +415,27 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
/* Not compatible memory model. */
|
||||
continue;
|
||||
|
||||
if ((vbe_mode_info.x_resolution != width)
|
||||
|| (vbe_mode_info.y_resolution != height))
|
||||
if (((vbe_mode_info.x_resolution != width)
|
||||
|| (vbe_mode_info.y_resolution != height)) && width != 0 && height != 0)
|
||||
/* Non matching resolution. */
|
||||
continue;
|
||||
|
||||
/* Check if user requested RGB or index color mode. */
|
||||
if ((mode_type & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0)
|
||||
if ((mode_mask & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0)
|
||||
{
|
||||
if (((mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||
&& (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL))
|
||||
/* Requested only index color modes. */
|
||||
continue;
|
||||
unsigned my_mode_type = 0;
|
||||
|
||||
if (((mode_type & GRUB_VIDEO_MODE_TYPE_RGB) != 0)
|
||||
&& (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR))
|
||||
/* Requested only RGB modes. */
|
||||
if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
|
||||
my_mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
|
||||
if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
|
||||
my_mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
|
||||
if ((my_mode_type & mode_mask
|
||||
& (GRUB_VIDEO_MODE_TYPE_RGB | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR))
|
||||
!= (mode_type & mode_mask
|
||||
& (GRUB_VIDEO_MODE_TYPE_RGB
|
||||
| GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -438,9 +443,12 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
if ((depth != 0) && (vbe_mode_info.bits_per_pixel != depth))
|
||||
continue;
|
||||
|
||||
/* Select mode with most number of bits per pixel. */
|
||||
/* Select mode with most of "volume" (size of framebuffer in bits). */
|
||||
if (best_vbe_mode != 0)
|
||||
if (vbe_mode_info.bits_per_pixel < best_vbe_mode_info.bits_per_pixel)
|
||||
if ((grub_uint64_t) vbe_mode_info.bits_per_pixel
|
||||
* vbe_mode_info.x_resolution * vbe_mode_info.y_resolution
|
||||
< (grub_uint64_t) best_vbe_mode_info.bits_per_pixel
|
||||
* best_vbe_mode_info.x_resolution * best_vbe_mode_info.y_resolution)
|
||||
continue;
|
||||
|
||||
/* Save so far best mode information for later use. */
|
||||
|
@ -557,6 +565,7 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
|||
static struct grub_video_adapter grub_video_vbe_adapter =
|
||||
{
|
||||
.name = "VESA BIOS Extension Video Driver",
|
||||
.id = GRUB_VIDEO_DRIVER_VBE,
|
||||
|
||||
.init = grub_video_vbe_init,
|
||||
.fini = grub_video_vbe_fini,
|
||||
|
|
249
video/video.c
249
video/video.c
|
@ -93,6 +93,14 @@ grub_video_get_info (struct grub_video_mode_info *mode_info)
|
|||
return grub_video_adapter_active->get_info (mode_info);
|
||||
}
|
||||
|
||||
grub_video_driver_id_t
|
||||
grub_video_get_driver_id (void)
|
||||
{
|
||||
if (! grub_video_adapter_active)
|
||||
return GRUB_VIDEO_DRIVER_NONE;
|
||||
return grub_video_adapter_active->id;
|
||||
}
|
||||
|
||||
/* Get information about active video mode. */
|
||||
grub_err_t
|
||||
grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
||||
|
@ -399,21 +407,81 @@ grub_video_get_active_render_target (struct grub_video_render_target **target)
|
|||
return grub_video_adapter_active->get_active_render_target (target);
|
||||
}
|
||||
|
||||
/* Parse <width>x<height>[x<depth>]*/
|
||||
static grub_err_t
|
||||
parse_modespec (const char *current_mode, int *width, int *height, int *depth)
|
||||
{
|
||||
const char *value;
|
||||
const char *param = current_mode;
|
||||
|
||||
*width = *height = *depth = -1;
|
||||
|
||||
if (grub_strcmp (param, "auto") == 0)
|
||||
{
|
||||
*width = *height = 0;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Find width value. */
|
||||
value = param;
|
||||
param = grub_strchr(param, 'x');
|
||||
if (param == NULL)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Invalid mode: %s\n",
|
||||
current_mode);
|
||||
|
||||
param++;
|
||||
|
||||
*width = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Invalid mode: %s\n",
|
||||
current_mode);
|
||||
|
||||
/* Find height value. */
|
||||
value = param;
|
||||
param = grub_strchr(param, 'x');
|
||||
if (param == NULL)
|
||||
{
|
||||
*height = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Invalid mode: %s\n",
|
||||
current_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have optional color depth value. */
|
||||
param++;
|
||||
|
||||
*height = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Invalid mode: %s\n",
|
||||
current_mode);
|
||||
|
||||
/* Convert color depth value. */
|
||||
value = param;
|
||||
*depth = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"Invalid mode: %s\n",
|
||||
current_mode);
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_video_set_mode (const char *modestring,
|
||||
int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
|
||||
struct grub_video_mode_info *mode_info))
|
||||
unsigned int modemask,
|
||||
unsigned int modevalue)
|
||||
{
|
||||
char *tmp;
|
||||
char *next_mode;
|
||||
char *current_mode;
|
||||
char *param;
|
||||
char *value;
|
||||
char *modevar;
|
||||
int width = -1;
|
||||
int height = -1;
|
||||
int depth = -1;
|
||||
int flags = 0;
|
||||
|
||||
modevalue &= modemask;
|
||||
|
||||
/* Take copy of env.var. as we don't want to modify that. */
|
||||
modevar = grub_strdup (modestring);
|
||||
|
@ -429,26 +497,26 @@ grub_video_set_mode (const char *modestring,
|
|||
|| grub_memcmp (next_mode, "keep,", sizeof ("keep,") - 1) == 0
|
||||
|| grub_memcmp (next_mode, "keep;", sizeof ("keep;") - 1) == 0)
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
int suitable = 1;
|
||||
grub_err_t err;
|
||||
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
|
||||
if (grub_video_adapter_active)
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
err = grub_video_get_info (&mode_info);
|
||||
if (err)
|
||||
{
|
||||
suitable = 0;
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
if ((mode_info.mode_type & modemask) != modevalue)
|
||||
suitable = 0;
|
||||
}
|
||||
else
|
||||
mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_PURE_TEXT;
|
||||
else if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
|
||||
&& ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
|
||||
suitable = 0;
|
||||
|
||||
if (suitable && hook)
|
||||
suitable = hook (grub_video_adapter_active, &mode_info);
|
||||
if (suitable)
|
||||
{
|
||||
grub_free (modevar);
|
||||
|
@ -482,15 +550,16 @@ grub_video_set_mode (const char *modestring,
|
|||
/* Loop until all modes has been tested out. */
|
||||
while (next_mode != NULL)
|
||||
{
|
||||
int width = -1;
|
||||
int height = -1;
|
||||
int depth = -1;
|
||||
grub_err_t err;
|
||||
unsigned int flags = modevalue;
|
||||
unsigned int flagmask = modemask;
|
||||
|
||||
/* Use last next_mode as current mode. */
|
||||
tmp = next_mode;
|
||||
|
||||
/* Reset video mode settings. */
|
||||
width = -1;
|
||||
height = -1;
|
||||
depth = -1;
|
||||
flags = 0;
|
||||
|
||||
/* Save position of next mode and separate modes. */
|
||||
for (; *next_mode; next_mode++)
|
||||
if (*next_mode == ',' || *next_mode == ';')
|
||||
|
@ -509,19 +578,16 @@ grub_video_set_mode (const char *modestring,
|
|||
|
||||
/* Initialize token holders. */
|
||||
current_mode = tmp;
|
||||
param = tmp;
|
||||
value = NULL;
|
||||
|
||||
/* XXX: we assume that we're in pure text mode if
|
||||
no video mode is initialized. Is it always true? */
|
||||
if (grub_strcmp (param, "text") == 0)
|
||||
if (grub_strcmp (current_mode, "text") == 0)
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_PURE_TEXT;
|
||||
|
||||
if (! hook || hook (0, &mode_info))
|
||||
if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) == 0)
|
||||
|| ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) != 0))
|
||||
{
|
||||
/* Valid mode found from adapter, and it has been activated.
|
||||
Specify it as active adapter. */
|
||||
|
@ -534,121 +600,31 @@ grub_video_set_mode (const char *modestring,
|
|||
}
|
||||
}
|
||||
|
||||
/* Parse <width>x<height>[x<depth>]*/
|
||||
|
||||
/* Find width value. */
|
||||
value = param;
|
||||
param = grub_strchr(param, 'x');
|
||||
if (param == NULL)
|
||||
err = parse_modespec (current_mode, &width, &height, &depth);
|
||||
if (err)
|
||||
{
|
||||
grub_err_t rc;
|
||||
|
||||
/* First setup error message. */
|
||||
rc = grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid mode: %s",
|
||||
current_mode);
|
||||
|
||||
/* Free memory before returning. */
|
||||
grub_free (modevar);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
*param = 0;
|
||||
param++;
|
||||
|
||||
width = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_err_t rc;
|
||||
|
||||
/* First setup error message. */
|
||||
rc = grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid mode: %s",
|
||||
current_mode);
|
||||
|
||||
/* Free memory before returning. */
|
||||
grub_free (modevar);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Find height value. */
|
||||
value = param;
|
||||
param = grub_strchr(param, 'x');
|
||||
if (param == NULL)
|
||||
{
|
||||
height = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_err_t rc;
|
||||
|
||||
/* First setup error message. */
|
||||
rc = grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid mode: %s",
|
||||
current_mode);
|
||||
|
||||
/* Free memory before returning. */
|
||||
grub_free (modevar);
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have optional color depth value. */
|
||||
*param = 0;
|
||||
param++;
|
||||
|
||||
height = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_err_t rc;
|
||||
|
||||
/* First setup error message. */
|
||||
rc = grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid mode: %s",
|
||||
current_mode);
|
||||
|
||||
/* Free memory before returning. */
|
||||
grub_free (modevar);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Convert color depth value. */
|
||||
value = param;
|
||||
depth = grub_strtoul (value, 0, 0);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_err_t rc;
|
||||
|
||||
/* First setup error message. */
|
||||
rc = grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid mode: %s",
|
||||
current_mode);
|
||||
|
||||
/* Free memory before returning. */
|
||||
grub_free (modevar);
|
||||
|
||||
return rc;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Try out video mode. */
|
||||
|
||||
/* If we have 8 or less bits, then assume that it is indexed color mode. */
|
||||
if ((depth <= 8) && (depth != -1))
|
||||
flags |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
/* If user requested specific depth check if this depth is supported. */
|
||||
if (depth != -1 && (flagmask & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
&&
|
||||
(((flags & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
!= ((depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
|
||||
& GRUB_VIDEO_MODE_TYPE_DEPTH_MASK))))
|
||||
continue;
|
||||
|
||||
/* We have more than 8 bits, then assume that it is RGB color mode. */
|
||||
if (depth > 8)
|
||||
flags |= GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
|
||||
/* If user requested specific depth, forward that information to driver. */
|
||||
if (depth != -1)
|
||||
{
|
||||
flags |= (depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
|
||||
& GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
|
||||
flagmask |= GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
|
||||
}
|
||||
|
||||
/* Try to initialize requested mode. Ignore any errors. */
|
||||
grub_video_adapter_t p;
|
||||
|
@ -656,7 +632,6 @@ grub_video_set_mode (const char *modestring,
|
|||
/* Loop thru all possible video adapter trying to find requested mode. */
|
||||
for (p = grub_video_adapter_list; p; p = p->next)
|
||||
{
|
||||
grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
grub_memset (&mode_info, 0, sizeof (mode_info));
|
||||
|
@ -670,7 +645,7 @@ grub_video_set_mode (const char *modestring,
|
|||
}
|
||||
|
||||
/* Try to initialize video mode. */
|
||||
err = p->setup (width, height, flags);
|
||||
err = p->setup (width, height, flags, flagmask);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
{
|
||||
p->fini ();
|
||||
|
@ -686,7 +661,15 @@ grub_video_set_mode (const char *modestring,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hook && ! hook (p, &mode_info))
|
||||
flags = mode_info.mode_type & ~GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
|
||||
flags |= (mode_info.bpp << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
|
||||
& GRUB_VIDEO_MODE_TYPE_DEPTH_MASK;
|
||||
|
||||
/* Check that mode is suitable for upper layer. */
|
||||
if ((flags & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
|
||||
? (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
|
||||
&& ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
|
||||
: ((flags & modemask) != modevalue))
|
||||
{
|
||||
p->fini ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
|
Loading…
Reference in a new issue