merged with mainline

This commit is contained in:
BVK Chaitanya 2010-04-10 18:09:56 +05:30
commit 20072d3ad5
42 changed files with 1037 additions and 480 deletions

150
ChangeLog
View file

@ -1,3 +1,153 @@
2010-04-10 Vladimir Serbinenko <phcoder@gmail.com>
* loader/multiboot.c (GRUB_MOD_INIT) [GRUB_USE_MULTIBOOT2]:
Rename "module" to "module2".
Reported by: Seth Goldberg.
2010-04-10 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/efi/memory.h (grub_machine_mmap_iterate): Remove
EXPORT_FUNC.
Reported by: Seth Goldberg.
2010-04-10 Vladimir Serbinenko <phcoder@gmail.com>
* lib/posix_wrap/locale.h: Add missing file.
Reported by: Seth Goldberg.
2010-04-10 Vladimir Serbinenko <phcoder@gmail.com>
grub-emu module load support.
* Makefile.in (TARGET_NO_MODULES): New variable. All users of
NO_DYNAMIC_MODULES switched to this.
(TARGET_CFLAGS): Add -DGRUB_TARGET_NO_MODULES=1 if applicable.
(CFLAGS): Likewise.
* conf/any-emu.rmk: Generate symlist.
(kernel_img_HEADERS): Add util/datetime.h.
(kernel_img_HEADERS) [sdl]: Add sdl.h.
(kernel_img_HEADERS) [libusb]: Add libusb.h.
(kernel_img_SOURCES) [TARGET_NO_MODULES = no && !x86]: Add
kern/$(target_cpu)/cache.S.
* configure.ac (grub-emu-modules): New option.
* genmk.rb: Handle multiple source lists.
* include/grub/sdl.h: New file.
* include/grub/libusb.h: Likewise.
* util/grub-emu.c (main): Hanle (host) root.
* util/hostdisk.c (grub_util_biosdisk_get_grub_dev): Error with
GRUB_ERR_UNKNOWN_DEVICE.
* util/misc.c: Move mm functions to ...
* util/mm.c: ... here. All users updated.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.in (RMKFILES): Search in srcdir and not current directory.
(MAINTAINER_CLEANFILES): Don't add $(srcdir) to MKFILES. Add few
missing files.
(maintainer-clean): Remove libgcrypt-grub.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* term/efi/console.c (grub_console_checkkey): Macroify key contants.
2010-04-09 EFI Coder <eficoder@hotmail.com>
* normal/menu_text.c (print_message): Clean up the message and show
the Fn information when on EFI
* term/efi/console.c (grub_console_checkkey): Add F4 support.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* normal/autofs.c (read_fs_list): New parameter 'prefix'.
All users updated.
* normal/crypto.c (read_crypto_list): Likewise.
* normal/dyncmd.c (read_command_list): Likewise.
* normal/term.c (read_terminal_list): Likewise.
* normal/main.c (read_lists): Use explicit prefix.
(read_lists_hook): Use read_lists.
(grub_normal_execute): Likewise.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.in: Fix incorrect path in coreboot part.
Reported by: Thomas Schmitt.
Add -no-emul-boot to grub-mkisofs parameters.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* font/font.c: Indented.
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
Elif support to GRUB script (by Deepak Vankadaru).
* tests/grub_script_if.in: New testcase.
* conf/tests.rmk: Rule for new testcase.
* script/parser.y: Grammar rules for elif.
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
While and until loops support to GRUB script.
* include/grub/script_sh.h (grub_script_cmdwhile): New struct.
(grub_script_create_cmdwhile): New function prototype.
(grub_script_execute_cmdwhile): New function prototype.
* script/execute.c (grub_script_execute_cmdwhile): New function.
* script/parser.y (command): New commands.
(whilecmd): New grammar rule.
(untilcmd): New grammar rule.
* script/script.c (grub_script_create_cmdwhile): New function.
* util/grub-script-check.c (grub_script_execute_cmdwhile): New
function.
* tests/grub_script_while1.in: New testcase.
* conf/tests.rmk: Rule for new testcase.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub.d/00_header.in: Add few missing quotes. Recognise *.jpeg
as *.jpg.
2010-04-09 Mario Vazquez <mariovazq@gmail.com>
GRUB_BACKGROUND support.
* util/grub-mkconfig.in: Export GRUB_BACKGROUND.
* util/grub.d/00_header.in: Parse GRUB_BACKGROUND.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
Load fonts and modules for gfxmenu in grub-mkconfig.
Idea by: Mario Vazquez
* util/grub.d/00_header.in: Load pf2 and image modules.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
grub-mkconfig multiple terminal support.
* util/grub-mkconfig.in: Handle multiple terminals correctly.
* util/grub.d/00_header.in: Likewise.
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.in: Specify files explicitly instead of using $< and $@ since
we use cd $(srcdir).
2010-04-08 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/10_linux.in: Only use the first word of
GRUB_DISTRIBUTOR for --class, to avoid problems if somebody puts
spaces in GRUB_DISTRIBUTOR.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_hurd.in: Likewise.
2010-04-06 BVK Chaitanya <bvk.groups@gmail.com>
Fix unit testing framework for Qemu 0.12.
* tests/util/grub-shell.in: Remove -serial stdio option.
2010-04-06 Vladimir Serbinenko <phcoder@gmail.com> 2010-04-06 Vladimir Serbinenko <phcoder@gmail.com>
POSIX header file wrappers. POSIX header file wrappers.

View file

@ -43,6 +43,7 @@ pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '
# Internationalization library. # Internationalization library.
LIBINTL = @LIBINTL@ LIBINTL = @LIBINTL@
TARGET_NO_MODULES = @TARGET_NO_MODULES@
XGETTEXT = @XGETTEXT@ XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@ MSGMERGE = @MSGMERGE@
@ -136,7 +137,7 @@ enable_efiemu = @enable_efiemu@
### General variables. ### General variables.
RMKFILES = $(wildcard conf/*.rmk) RMKFILES = $(wildcard $(srcdir)/conf/*.rmk)
MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES)) MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
@ -155,7 +156,9 @@ DISTCLEANFILES = config.status config.cache config.log config.h \
gensymlist.sh genkernsyms.sh build_env.mk \ gensymlist.sh genkernsyms.sh build_env.mk \
docs/grub.info docs/version.texi docs/stamp-vti docs/grub.info docs/version.texi docs/stamp-vti
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) \ MAINTAINER_CLEANFILES = $(srcdir)/configure $(srcdir)/aclocal.m4 \
$(MKFILES) $(srcdir)/config.guess \
$(srcdir)/config.sub $(srcdir)/install-sh $(srcdir)/missing \
$(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS) $(srcdir)/DISTLIST $(srcdir)/config.h.in $(srcdir)/stamp-h.in $(INFOS)
# The default target. # The default target.
@ -179,10 +182,15 @@ include $(srcdir)/conf/tests.mk
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk) -include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
endif endif
ifeq ($(TARGET_NO_MODULES), yes)
TARGET_CFLAGS += -DGRUB_TARGET_NO_MODULES=1
CFLAGS += -DGRUB_TARGET_NO_MODULES=1
endif
### General targets. ### General targets.
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
ifneq ($(platform), emu) ifneq ($(TARGET_NO_MODULES), yes)
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst
endif endif
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
@ -427,6 +435,8 @@ distclean: mostlyclean
maintainer-clean: distclean maintainer-clean: distclean
-test -z "$(MAINTAINER_CLEANFILES)" || rm -f $(MAINTAINER_CLEANFILES) -test -z "$(MAINTAINER_CLEANFILES)" || rm -f $(MAINTAINER_CLEANFILES)
-rmdir $(srcdir)/lib/libgcrypt-grub/cipher
-rmdir $(srcdir)/lib/libgcrypt-grub
info: info:
@ -530,8 +540,8 @@ genkernsyms.sh: genkernsyms.sh.in config.status
$(SHELL) ./config.status $(SHELL) ./config.status
$(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell $(srcdir)/po/$(PACKAGE).pot: po/POTFILES po/POTFILES-shell
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f $< --keyword=_ --keyword=N_ cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES --keyword=_ --keyword=N_
cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o $@ -f po/POTFILES-shell -j --language=Shell cd $(srcdir) && $(XGETTEXT) -ctranslate --from-code=utf-8 -o po/$(PACKAGE).pot -f po/POTFILES-shell -j --language=Shell
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot $(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
$(MSGMERGE) -U $@ $^ $(MSGMERGE) -U $@ $^

View file

@ -1,9 +1,7 @@
# -*- makefile -*- # -*- makefile -*-
COMMON_LDFLAGS += -nostdlib COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
kernel_img_RELOCATABLE = yes kernel_img_RELOCATABLE = yes
pkglib_PROGRAMS = kernel.img pkglib_PROGRAMS = kernel.img
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
@ -12,14 +10,25 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
kern/parser.c kern/partition.c kern/term.c \ kern/parser.c kern/partition.c kern/term.c \
kern/rescue_reader.c kern/rescue_parser.c \ kern/rescue_reader.c kern/rescue_parser.c \
\ \
util/console.c util/grub-emu.c util/misc.c util/hostdisk.c \ util/console.c util/grub-emu.c util/misc.c \
util/getroot.c util/time.c \ util/hostdisk.c util/getroot.c util/mm.c util/time.c \
\ \
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c gnulib/progname.c util/hostfs.c disk/host.c
kernel_img_HEADERS += datetime.h
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
TARGET_NO_STRIP = yes TARGET_NO_STRIP = yes
TARGET_NO_DYNAMIC_MODULES = yes
ifneq ($(TARGET_NO_MODULES), yes)
kernel_img_SOURCES += symlist.c kern/$(target_cpu)/dl.c
ifneq ($(target_cpu), i386)
ifneq ($(target_cpu), x86_64)
kernel_img_SOURCES += kern/$(target_cpu)/cache.S
endif
endif
else
kernel_img_SOURCES += grub_emu_init.c
endif
# For halt.mod. # For halt.mod.
pkglib_MODULES += halt.mod pkglib_MODULES += halt.mod
@ -37,6 +46,8 @@ endif
grub_emu_LDFLAGS = $(LIBCURSES) grub_emu_LDFLAGS = $(LIBCURSES)
ifeq ($(enable_grub_emu_usb), yes) ifeq ($(enable_grub_emu_usb), yes)
kernel_img_HEADERS += libusb.h
pkglib_MODULES += libusb.mod pkglib_MODULES += libusb.mod
libusb_mod_SOURCES = util/usb.c libusb_mod_SOURCES = util/usb.c
libusb_mod_CFLAGS = libusb_mod_CFLAGS =
@ -69,6 +80,7 @@ sdl_mod_SOURCES = util/sdl.c
sdl_mod_CFLAGS = sdl_mod_CFLAGS =
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS) sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBSDL) grub_emu_LDFLAGS += $(LIBSDL)
kernel_img_HEADERS += sdl.h
endif endif
ifeq ($(enable_grub_emu_pci), yes) ifeq ($(enable_grub_emu_pci), yes)
@ -84,12 +96,17 @@ grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@ rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.h DISTCLEANFILES += grub_emu_init.h
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES) grub_emu_init.c: genemuinit.sh $(pkglib_MODULES) grub_emu_init.h
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@ rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.c DISTCLEANFILES += grub_emu_init.c
CLEANFILES += grub-emu CLEANFILES += grub-emu
ifneq ($(TARGET_NO_MODULES), yes)
grub-emu: $(pkglib_PROGRAMS)
$(CC) -o $@ $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
else
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS) grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS) $(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
endif
GRUB_EMU=grub-emu GRUB_EMU=grub-emu

View file

@ -25,7 +25,7 @@ util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
sbin_UTILITIES += grub-probe sbin_UTILITIES += grub-probe
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \ grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
util/hostdisk.c util/misc.c util/getroot.c \ util/hostdisk.c util/misc.c util/getroot.c util/mm.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c \ kern/device.c kern/disk.c kern/err.c kern/misc.c \
kern/parser.c kern/partition.c kern/file.c kern/list.c \ kern/parser.c kern/partition.c kern/file.c kern/list.c \
\ \
@ -61,7 +61,7 @@ grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
# For grub-fstest. # For grub-fstest.
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
util/misc.c \ util/misc.c util/mm.c \
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \ kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
disk/host.c disk/loopback.c kern/list.c kern/command.c \ disk/host.c disk/loopback.c kern/list.c kern/command.c \
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \ lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
@ -104,7 +104,7 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
bin_UTILITIES += grub-script-check bin_UTILITIES += grub-script-check
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
util/grub-script-check.c util/misc.c \ util/grub-script-check.c util/misc.c util/mm.c \
script/main.c script/script.c script/function.c script/lexer.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/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 \ kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
@ -116,9 +116,12 @@ DEFSYMFILES += kernel_syms.lst
kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \ partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
machine/memory.h machine/loader.h machine/kernel.h \
list.h handler.h command.h i18n.h env_private.h list.h handler.h command.h i18n.h env_private.h
ifneq ($(platform), emu)
kernel_img_HEADERS += machine/memory.h machine/loader.h machine/kernel.h
endif
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
@ -184,7 +187,7 @@ DISTCLEANFILES += grub_fstest_init.c
# for grub-editenv # for grub-editenv
bin_UTILITIES += grub-editenv bin_UTILITIES += grub-editenv
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/misc.c kern/err.c grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c util/mm.c kern/misc.c kern/err.c
CLEANFILES += grub-editenv CLEANFILES += grub-editenv
# Needed for genmk.rb to work # Needed for genmk.rb to work
@ -852,7 +855,7 @@ boot_mod_CFLAGS = $(COMMON_CFLAGS)
boot_mod_LDFLAGS = $(COMMON_LDFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
bin_UTILITIES += grub-mkpasswd-pbkdf2 bin_UTILITIES += grub-mkpasswd-pbkdf2
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c util/mm.c kern/err.c
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1 grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
include $(srcdir)/conf/gcry.mk include $(srcdir)/conf/gcry.mk

View file

@ -90,7 +90,7 @@ grub_setup_SOURCES = gnulib/progname.c \
partmap/gpt.c \ partmap/gpt.c \
\ \
disk/raid.c disk/mdraid_linux.c disk/lvm.c \ disk/raid.c disk/mdraid_linux.c disk/lvm.c \
util/raid.c util/lvm.c \ util/raid.c util/lvm.c util/mm.c \
grub_setup_init.c grub_setup_init.c
sbin_SCRIPTS += grub-install sbin_SCRIPTS += grub-install

View file

@ -65,7 +65,7 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \ partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
\ \
disk/raid.c disk/mdraid_linux.c disk/lvm.c \ disk/raid.c disk/mdraid_linux.c disk/lvm.c \
util/raid.c util/lvm.c gnulib/progname.c \ util/raid.c util/lvm.c util/mm.c gnulib/progname.c \
grub_setup_init.c grub_setup_init.c
# For grub-ofpathname. # For grub-ofpathname.

View file

@ -53,6 +53,12 @@ grub_script_vars1_SOURCES = tests/grub_script_vars1.in
check_SCRIPTS += grub_script_for1 check_SCRIPTS += grub_script_for1
grub_script_for1_SOURCES = tests/grub_script_for1.in grub_script_for1_SOURCES = tests/grub_script_for1.in
check_SCRIPTS += grub_script_while1
grub_script_while1_SOURCES = tests/grub_script_while1.in
check_SCRIPTS += grub_script_if
grub_script_if_SOURCES = tests/grub_script_if.in
check_SCRIPTS += grub_script_blanklines check_SCRIPTS += grub_script_blanklines
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
@ -69,9 +75,12 @@ SCRIPTED_TESTS = grub_script_echo1
SCRIPTED_TESTS += grub_script_echo_keywords SCRIPTED_TESTS += grub_script_echo_keywords
SCRIPTED_TESTS += grub_script_vars1 SCRIPTED_TESTS += grub_script_vars1
SCRIPTED_TESTS += grub_script_for1 SCRIPTED_TESTS += grub_script_for1
SCRIPTED_TESTS += grub_script_while1
SCRIPTED_TESTS += grub_script_if
SCRIPTED_TESTS += grub_script_blanklines SCRIPTED_TESTS += grub_script_blanklines
SCRIPTED_TESTS += grub_script_final_semicolon SCRIPTED_TESTS += grub_script_final_semicolon
# dependencies between tests and testing-tools # dependencies between tests and testing-tools
$(SCRIPTED_TESTS): grub-shell grub-shell-tester $(SCRIPTED_TESTS): grub-shell grub-shell-tester
$(FUNCTIONAL_TESTS): functional_test.mod $(FUNCTIONAL_TESTS): functional_test.mod

View file

@ -584,6 +584,10 @@ AC_ARG_ENABLE([grub-emu-pci],
[AS_HELP_STRING([--enable-grub-emu-pci], [AS_HELP_STRING([--enable-grub-emu-pci],
[build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])]) [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
AC_ARG_ENABLE([grub-emu-modules],
[AS_HELP_STRING([--enable-grub-emu-modules],
[Support module loading in `grub-emu' debugging utility (default=no)])])
if test "$platform" = emu; then if test "$platform" = emu; then
missing_ncurses= missing_ncurses=
[# Check for curses libraries.] [# Check for curses libraries.]
@ -602,6 +606,13 @@ if test x"$missing_ncurses" = xtrue ; then
AC_MSG_ERROR([grub-emu can't be compiled without ncurses]) AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
fi fi
if test x"$enable_grub_emu_modules" = xyes ; then
TARGET_NO_MODULES=no
else
TARGET_NO_MODULES=yes
fi
AC_SUBST(TARGET_NO_MODULES)
if test x"$enable_grub_emu_usb" = xno ; then if test x"$enable_grub_emu_usb" = xno ; then
grub_emu_usb_excuse="explicitly disabled" grub_emu_usb_excuse="explicitly disabled"
fi fi
@ -779,6 +790,11 @@ echo PCI support for grub-emu: Yes
else else
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)" echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
fi fi
if [ x"$TARGET_NO_MODULES" = xno ]; then
echo Module support for grub-emu: Yes
else
echo Module support for grub-emu: No
fi
fi fi
if [ x"$enable_mm_debug" = xyes ]; then if [ x"$enable_mm_debug" = xyes ]; then
echo With memory debugging: Yes echo With memory debugging: Yes

View file

@ -91,8 +91,7 @@ struct font_file_section
}; };
/* Replace unknown glyphs with a rounded question mark. */ /* Replace unknown glyphs with a rounded question mark. */
static grub_uint8_t unknown_glyph_bitmap[] = static grub_uint8_t unknown_glyph_bitmap[] = {
{
/* 76543210 */ /* 76543210 */
0x7C, /* ooooo */ 0x7C, /* ooooo */
0x82, /* o o */ 0x82, /* o o */
@ -141,8 +140,8 @@ ascii_glyph_lookup (grub_uint32_t code)
int current; int current;
for (current = 0; current < 0x80; current++) for (current = 0; current < 0x80; current++)
{ {
ascii_font_glyph[current] = grub_malloc(sizeof(struct grub_font_glyph) ascii_font_glyph[current] =
+ ASCII_BITMAP_SIZE); grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
ascii_font_glyph[current]->width = 8; ascii_font_glyph[current]->width = 8;
ascii_font_glyph[current]->height = 16; ascii_font_glyph[current]->height = 16;
@ -173,9 +172,9 @@ grub_font_loader_init (void)
return; return;
/* Make glyph for unknown glyph. */ /* Make glyph for unknown glyph. */
unknown_glyph = grub_malloc(sizeof(struct grub_font_glyph) unknown_glyph = grub_malloc (sizeof (struct grub_font_glyph)
+ sizeof(unknown_glyph_bitmap)); + sizeof (unknown_glyph_bitmap));
if (! unknown_glyph) if (!unknown_glyph)
return; return;
unknown_glyph->width = 8; unknown_glyph->width = 8;
@ -183,13 +182,13 @@ grub_font_loader_init (void)
unknown_glyph->offset_x = 0; unknown_glyph->offset_x = 0;
unknown_glyph->offset_y = -3; unknown_glyph->offset_y = -3;
unknown_glyph->device_width = 8; unknown_glyph->device_width = 8;
grub_memcpy(unknown_glyph->bitmap, grub_memcpy (unknown_glyph->bitmap,
unknown_glyph_bitmap, sizeof(unknown_glyph_bitmap)); unknown_glyph_bitmap, sizeof (unknown_glyph_bitmap));
/* Initialize the null font. */ /* Initialize the null font. */
font_init (&null_font); font_init (&null_font);
null_font.name = "<No Font>"; null_font.name = "<No Font>";
null_font.ascent = unknown_glyph->height-3; null_font.ascent = unknown_glyph->height - 3;
null_font.descent = 3; null_font.descent = 3;
null_font.max_char_width = unknown_glyph->width; null_font.max_char_width = unknown_glyph->width;
null_font.max_char_height = unknown_glyph->height; null_font.max_char_height = unknown_glyph->height;
@ -289,7 +288,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
grub_uint32_t last_code; grub_uint32_t last_code;
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("load_font_index(sect_length=%d)\n", sect_length); grub_printf ("load_font_index(sect_length=%d)\n", sect_length);
#endif #endif
/* Sanity check: ensure section length is divisible by the entry size. */ /* Sanity check: ensure section length is divisible by the entry size. */
@ -308,10 +307,10 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
/* Allocate the character index array. */ /* Allocate the character index array. */
font->char_index = grub_malloc (font->num_chars font->char_index = grub_malloc (font->num_chars
* sizeof (struct char_index_entry)); * sizeof (struct char_index_entry));
if (! font->char_index) if (!font->char_index)
return 1; return 1;
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t)); font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
if (! font->bmp_idx) if (!font->bmp_idx)
{ {
grub_free (font->char_index); grub_free (font->char_index);
return 1; return 1;
@ -320,7 +319,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("num_chars=%d)\n", font->num_chars); grub_printf ("num_chars=%d)\n", font->num_chars);
#endif #endif
last_code = 0; last_code = 0;
@ -364,7 +363,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 5 #if FONT_DEBUG >= 5
/* Print the 1st 10 characters. */ /* Print the 1st 10 characters. */
if (i < 10) if (i < 10)
grub_printf("c=%d o=%d\n", entry->code, entry->offset); grub_printf ("c=%d o=%d\n", entry->code, entry->offset);
#endif #endif
} }
@ -380,7 +379,7 @@ read_section_as_string (struct font_file_section *section)
grub_ssize_t ret; grub_ssize_t ret;
str = grub_malloc (section->length + 1); str = grub_malloc (section->length + 1);
if (! str) if (!str)
return 0; return 0;
ret = grub_file_read (section->file, str, section->length); ret = grub_file_read (section->file, str, section->length);
@ -398,7 +397,8 @@ read_section_as_string (struct font_file_section *section)
which is stored into *VALUE. which is stored into *VALUE.
Returns 0 upon success, nonzero upon failure. */ Returns 0 upon success, nonzero upon failure. */
static int static int
read_section_as_short (struct font_file_section *section, grub_int16_t *value) read_section_as_short (struct font_file_section *section,
grub_int16_t * value)
{ {
grub_uint16_t raw_value; grub_uint16_t raw_value;
@ -408,8 +408,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value)
"font file format error: section %c%c%c%c length " "font file format error: section %c%c%c%c length "
"is %d but should be 2", "is %d but should be 2",
section->name[0], section->name[1], section->name[0], section->name[1],
section->name[2], section->name[3], section->name[2], section->name[3], section->length);
section->length);
return 1; return 1;
} }
if (grub_file_read (section->file, &raw_value, 2) != 2) if (grub_file_read (section->file, &raw_value, 2) != 2)
@ -430,7 +429,7 @@ grub_font_load (const char *filename)
grub_font_t font = 0; grub_font_t font = 0;
#if FONT_DEBUG >= 1 #if FONT_DEBUG >= 1
grub_printf("add_font(%s)\n", filename); grub_printf ("add_font(%s)\n", filename);
#endif #endif
file = grub_buffile_open (filename, 1024); file = grub_buffile_open (filename, 1024);
@ -438,7 +437,7 @@ grub_font_load (const char *filename)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("file opened\n"); grub_printf ("file opened\n");
#endif #endif
/* Read the FILE section. It indicates the file format. */ /* Read the FILE section. It indicates the file format. */
@ -446,10 +445,10 @@ grub_font_load (const char *filename)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("opened FILE section\n"); grub_printf ("opened FILE section\n");
#endif #endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE, if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE,
sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0) sizeof (FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0)
{ {
grub_error (GRUB_ERR_BAD_FONT, grub_error (GRUB_ERR_BAD_FONT,
"font file format error: 1st section must be FILE"); "font file format error: 1st section must be FILE");
@ -457,7 +456,7 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("section name ok\n"); grub_printf ("section name ok\n");
#endif #endif
if (section.length != 4) if (section.length != 4)
{ {
@ -468,14 +467,14 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("section length ok\n"); grub_printf ("section length ok\n");
#endif #endif
/* Check the file format type code. */ /* Check the file format type code. */
if (grub_file_read (file, magic, 4) != 4) if (grub_file_read (file, magic, 4) != 4)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("read magic ok\n"); grub_printf ("read magic ok\n");
#endif #endif
if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0) if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
@ -486,19 +485,19 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("compare magic ok\n"); grub_printf ("compare magic ok\n");
#endif #endif
/* Allocate the font object. */ /* Allocate the font object. */
font = (grub_font_t) grub_malloc (sizeof (struct grub_font)); font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
if (! font) if (!font)
goto fail; goto fail;
font_init (font); font_init (font);
font->file = file; font->file = file;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("allocate font ok; loading font info\n"); grub_printf ("allocate font ok; loading font info\n");
#endif #endif
/* Load the font information. */ /* Load the font information. */
@ -513,13 +512,13 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("opened section %c%c%c%c ok\n", grub_printf ("opened section %c%c%c%c ok\n",
section.name[0], section.name[1], section.name[0], section.name[1],
section.name[2], section.name[3]); section.name[2], section.name[3]);
#endif #endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME, if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME,
sizeof(FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
{ {
font->name = read_section_as_string (&section); font->name = read_section_as_string (&section);
if (!font->name) if (!font->name)
@ -527,13 +526,15 @@ grub_font_load (const char *filename)
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_POINT_SIZE, FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
sizeof(FONT_FORMAT_SECTION_NAMES_POINT_SIZE) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
1) == 0)
{ {
if (read_section_as_short (&section, &font->point_size) != 0) if (read_section_as_short (&section, &font->point_size) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
== 0)
{ {
char *wt; char *wt;
wt = read_section_as_string (&section); wt = read_section_as_string (&section);
@ -548,40 +549,45 @@ grub_font_load (const char *filename)
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH, FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
- 1) == 0)
{ {
if (read_section_as_short (&section, &font->max_char_width) != 0) if (read_section_as_short (&section, &font->max_char_width) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT, FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
- 1) == 0)
{ {
if (read_section_as_short (&section, &font->max_char_height) != 0) if (read_section_as_short (&section, &font->max_char_height) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_ASCENT, FONT_FORMAT_SECTION_NAMES_ASCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_ASCENT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
== 0)
{ {
if (read_section_as_short (&section, &font->ascent) != 0) if (read_section_as_short (&section, &font->ascent) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_DESCENT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
== 0)
{ {
if (read_section_as_short (&section, &font->descent) != 0) if (read_section_as_short (&section, &font->descent) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX, FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
1) == 0)
{ {
if (load_font_index (file, section.length, font) != 0) if (load_font_index (file, section.length, font) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA,
sizeof(FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
{ {
/* When the DATA section marker is reached, we stop reading. */ /* When the DATA section marker is reached, we stop reading. */
break; break;
@ -590,7 +596,7 @@ grub_font_load (const char *filename)
{ {
/* Unhandled section type, simply skip past it. */ /* Unhandled section type, simply skip past it. */
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("Unhandled section type, skipping.\n"); grub_printf ("Unhandled section type, skipping.\n");
#endif #endif
grub_off_t section_end = grub_file_tell (file) + section.length; grub_off_t section_end = grub_file_tell (file) + section.length;
if ((int) grub_file_seek (file, section_end) == -1) if ((int) grub_file_seek (file, section_end) == -1)
@ -598,7 +604,7 @@ grub_font_load (const char *filename)
} }
} }
if (! font->name) if (!font->name)
{ {
grub_printf ("Note: Font has no name.\n"); grub_printf ("Note: Font has no name.\n");
font->name = grub_strdup ("Unknown"); font->name = grub_strdup ("Unknown");
@ -609,16 +615,13 @@ grub_font_load (const char *filename)
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n", "Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
font->name, font->name,
font->ascent, font->descent, font->ascent, font->descent,
font->max_char_width, font->max_char_height, font->max_char_width, font->max_char_height, font->num_chars);
font->num_chars);
#endif #endif
if (font->max_char_width == 0 if (font->max_char_width == 0
|| font->max_char_height == 0 || font->max_char_height == 0
|| font->num_chars == 0 || font->num_chars == 0
|| font->char_index == 0 || font->char_index == 0 || font->ascent == 0 || font->descent == 0)
|| font->ascent == 0
|| font->descent == 0)
{ {
grub_error (GRUB_ERR_BAD_FONT, grub_error (GRUB_ERR_BAD_FONT,
"invalid font file: missing some required data"); "invalid font file: missing some required data");
@ -679,7 +682,7 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
lo = 0; lo = 0;
hi = font->num_chars - 1; hi = font->num_chars - 1;
if (! table) if (!table)
return 0; return 0;
while (lo <= hi) while (lo <= hi)
@ -719,7 +722,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
/* Return cached glyph. */ /* Return cached glyph. */
return index_entry->glyph; return index_entry->glyph;
if (! font->file) if (!font->file)
/* No open file, can't load any glyphs. */ /* No open file, can't load any glyphs. */
return 0; return 0;
@ -730,11 +733,11 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
grub_file_seek (font->file, index_entry->offset); grub_file_seek (font->file, index_entry->offset);
/* Read the glyph width, height, and baseline. */ /* Read the glyph width, height, and baseline. */
if (read_be_uint16(font->file, &width) != 0 if (read_be_uint16 (font->file, &width) != 0
|| read_be_uint16(font->file, &height) != 0 || read_be_uint16 (font->file, &height) != 0
|| read_be_int16(font->file, &xoff) != 0 || read_be_int16 (font->file, &xoff) != 0
|| read_be_int16(font->file, &yoff) != 0 || read_be_int16 (font->file, &yoff) != 0
|| read_be_int16(font->file, &dwidth) != 0) || read_be_int16 (font->file, &dwidth) != 0)
{ {
remove_font (font); remove_font (font);
return 0; return 0;
@ -742,7 +745,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
len = (width * height + 7) / 8; len = (width * height + 7) / 8;
glyph = grub_malloc (sizeof (struct grub_font_glyph) + len); glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
if (! glyph) if (!glyph)
{ {
remove_font (font); remove_font (font);
return 0; return 0;
@ -804,7 +807,7 @@ register_font (grub_font_t font)
struct grub_font_node *node = 0; struct grub_font_node *node = 0;
node = grub_malloc (sizeof (struct grub_font_node)); node = grub_malloc (sizeof (struct grub_font_node));
if (! node) if (!node)
return 1; return 1;
node->value = font; node->value = font;
@ -822,8 +825,7 @@ remove_font (grub_font_t font)
struct grub_font_node **nextp, *cur; struct grub_font_node **nextp, *cur;
for (nextp = &grub_font_list, cur = *nextp; for (nextp = &grub_font_list, cur = *nextp;
cur; cur; nextp = &cur->next, cur = cur->next)
nextp = &cur->next, cur = cur->next)
{ {
if (cur->value == font) if (cur->value == font)
{ {
@ -927,7 +929,7 @@ grub_font_get_string_width (grub_font_t font, const char *str)
const grub_uint8_t *ptr; const grub_uint8_t *ptr;
for (ptr = (const grub_uint8_t *) str, width = 0; for (ptr = (const grub_uint8_t *) str, width = 0;
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; ) grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
{ {
glyph = grub_font_get_glyph_with_fallback (font, code); glyph = grub_font_get_glyph_with_fallback (font, code);
width += glyph->device_width; width += glyph->device_width;
@ -961,7 +963,7 @@ grub_font_get_glyph (grub_font_t font, grub_uint32_t code)
sizes are used so that tiny 8 point glyphs are not mixed into a string sizes are used so that tiny 8 point glyphs are not mixed into a string
of 24 point text unless there is no other choice. */ of 24 point text unless there is no other choice. */
static int static int
get_font_diversity(grub_font_t a, grub_font_t b) get_font_diversity (grub_font_t a, grub_font_t b)
{ {
int d; int d;
@ -1052,9 +1054,8 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
baseline of the character, while the x coordinate designates the left baseline of the character, while the x coordinate designates the left
side location of the character. */ side location of the character. */
grub_err_t grub_err_t
grub_font_draw_glyph (struct grub_font_glyph *glyph, grub_font_draw_glyph (struct grub_font_glyph * glyph,
grub_video_color_t color, grub_video_color_t color, int left_x, int baseline_y)
int left_x, int baseline_y)
{ {
struct grub_video_bitmap glyph_bitmap; struct grub_video_bitmap glyph_bitmap;
@ -1065,8 +1066,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
glyph_bitmap.mode_info.width = glyph->width; glyph_bitmap.mode_info.width = glyph->width;
glyph_bitmap.mode_info.height = glyph->height; glyph_bitmap.mode_info.height = glyph->height;
glyph_bitmap.mode_info.mode_type = glyph_bitmap.mode_info.mode_type =
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
glyph_bitmap.mode_info.bpp = 1; glyph_bitmap.mode_info.bpp = 1;
@ -1081,7 +1081,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
glyph_bitmap.mode_info.bg_green = 0; glyph_bitmap.mode_info.bg_green = 0;
glyph_bitmap.mode_info.bg_blue = 0; glyph_bitmap.mode_info.bg_blue = 0;
glyph_bitmap.mode_info.bg_alpha = 0; glyph_bitmap.mode_info.bg_alpha = 0;
grub_video_unmap_color(color, grub_video_unmap_color (color,
&glyph_bitmap.mode_info.fg_red, &glyph_bitmap.mode_info.fg_red,
&glyph_bitmap.mode_info.fg_green, &glyph_bitmap.mode_info.fg_green,
&glyph_bitmap.mode_info.fg_blue, &glyph_bitmap.mode_info.fg_blue,
@ -1094,8 +1094,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND, return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
bitmap_left, bitmap_top, bitmap_left, bitmap_top,
0, 0, 0, 0, glyph->width, glyph->height);
glyph->width, glyph->height);
} }
/* Draw a UTF-8 string of text on the current video render target. /* Draw a UTF-8 string of text on the current video render target.
@ -1105,8 +1104,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
a glyph from another loaded font may be used instead. */ a glyph from another loaded font may be used instead. */
grub_err_t grub_err_t
grub_font_draw_string (const char *str, grub_font_t font, grub_font_draw_string (const char *str, grub_font_t font,
grub_video_color_t color, grub_video_color_t color, int left_x, int baseline_y)
int left_x, int baseline_y)
{ {
int x; int x;
struct grub_font_glyph *glyph; struct grub_font_glyph *glyph;
@ -1114,15 +1112,13 @@ grub_font_draw_string (const char *str, grub_font_t font,
const grub_uint8_t *ptr; const grub_uint8_t *ptr;
for (ptr = (const grub_uint8_t *) str, x = left_x; for (ptr = (const grub_uint8_t *) str, x = left_x;
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; ) grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
{ {
glyph = grub_font_get_glyph_with_fallback (font, code); glyph = grub_font_get_glyph_with_fallback (font, code);
if (grub_font_draw_glyph (glyph, color, x, baseline_y) if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE)
!= GRUB_ERR_NONE)
return grub_errno; return grub_errno;
x += glyph->device_width; x += glyph->device_width;
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }

View file

@ -143,7 +143,7 @@ mostlyclean-module-#{@name}.#{@rule_count}:
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count} MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
UNDSYMFILES += #{undsym} UNDSYMFILES += #{undsym}
ifeq ($(TARGET_NO_DYNAMIC_MODULES), yes) ifeq ($(TARGET_NO_MODULES), yes)
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF) #{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
-rm -f $@ -rm -f $@
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
@ -322,28 +322,32 @@ class Program
end end
attr_reader :dir, :name attr_reader :dir, :name
def print_tail()
prefix = @name.to_var
print "CLEANFILES += #{@name} $(#{prefix}_OBJECTS)
ifeq ($(#{prefix}_RELOCATABLE),yes)
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
$(TARGET_CC) -Wl,-r,-d -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
else
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
$(TARGET_CC) -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
endif
"
end
def rule(sources) def rule(sources)
prefix = @name.to_var prefix = @name.to_var
objs = sources.collect do |src| objs = sources.collect do |src|
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
prefix + '-' + src.to_obj prefix + '-' + src.to_obj
end end
objs_str = objs.join(' ');
deps = objs.collect {|obj| obj.suffix('d')} deps = objs.collect {|obj| obj.suffix('d')}
deps_str = deps.join(' '); deps_str = deps.join(' ');
"CLEANFILES += #{@name} #{objs_str} "MOSTLYCLEANFILES += #{deps_str}
MOSTLYCLEANFILES += #{deps_str}
ifeq ($(#{prefix}_RELOCATABLE),yes)
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
else
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
endif
" + objs.collect_with_index do |obj, i| " + objs.collect_with_index do |obj, i|
src = sources[i] src = sources[i]
@ -358,6 +362,7 @@ endif
-include #{dep} -include #{dep}
#{prefix}_OBJECTS += #{obj}
" "
end.join('') end.join('')
end end
@ -466,4 +471,5 @@ while l = gets
end end
utils.each {|util| util.print_tail()} utils.each {|util| util.print_tail()}
programs.each {|program| program.print_tail()}

View file

@ -91,7 +91,7 @@ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod); int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
void grub_dl_unload_unneeded (void); void grub_dl_unload_unneeded (void);
void grub_dl_unload_all (void); void grub_dl_unload_all (void);
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) #if defined (GRUB_UTIL) || defined (GRUB_TARGET_NO_MODULES)
#define GRUB_NO_MODULES 1 #define GRUB_NO_MODULES 1
#else #else
#define GRUB_NO_MODULES 0 #define GRUB_NO_MODULES 0
@ -121,7 +121,7 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr,
grub_err_t grub_arch_dl_check_header (void *ehdr); grub_err_t grub_arch_dl_check_header (void *ehdr);
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
#if defined (_mips) && ! defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) #if defined (_mips) && ! GRUB_NO_MODULES
#define GRUB_LINKER_HAVE_INIT 1 #define GRUB_LINKER_HAVE_INIT 1
void grub_arch_dl_init_linker (void); void grub_arch_dl_init_linker (void);
#endif #endif

View file

@ -34,9 +34,9 @@
by firmware. */ by firmware. */
#define GRUB_MACHINE_MEMORY_HOLE 6 #define GRUB_MACHINE_MEMORY_HOLE 6
grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) grub_uint64_t,
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)); grub_uint32_t));
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size, grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, int handle); int type, int handle);
grub_err_t grub_machine_mmap_unregister (int handle); grub_err_t grub_machine_mmap_unregister (int handle);

29
include/grub/libusb.h Normal file
View file

@ -0,0 +1,29 @@
/*
* 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/>.
*/
void EXPORT_FUNC (usb_bulk_write) (void);
void EXPORT_FUNC (usb_find_busses) (void);
void EXPORT_FUNC (usb_init) (void);
void EXPORT_FUNC (usb_find_devices) (void);
void EXPORT_FUNC (usb_open) (void);
void EXPORT_FUNC (usb_get_busses) (void);
void EXPORT_FUNC (usb_control_msg) (void);
void EXPORT_FUNC (usb_release_interface) (void);
void EXPORT_FUNC (usb_close) (void);
void EXPORT_FUNC (usb_bulk_read) (void);
void EXPORT_FUNC (usb_claim_interface) (void);

View file

@ -96,17 +96,17 @@ void read_handler_list (void);
void free_handler_list (void); void free_handler_list (void);
/* Defined in `dyncmd.c'. */ /* Defined in `dyncmd.c'. */
void read_command_list (void); void read_command_list (const char *prefix);
/* Defined in `autofs.c'. */ /* Defined in `autofs.c'. */
void read_fs_list (void); void read_fs_list (const char *prefix);
void grub_context_init (void); void grub_context_init (void);
void grub_context_fini (void); void grub_context_fini (void);
void read_crypto_list (void); void read_crypto_list (const char *prefix);
void read_terminal_list (void); void read_terminal_list (const char *prefix);
void grub_set_more (int onoff); void grub_set_more (int onoff);

View file

@ -121,6 +121,21 @@ struct grub_script_cmdfor
struct grub_script_cmd *list; struct grub_script_cmd *list;
}; };
/* A while/until command. */
struct grub_script_cmdwhile
{
struct grub_script_cmd cmd;
/* The command list used as condition. */
struct grub_script_cmd *cond;
/* The command list executed in each loop. */
struct grub_script_cmd *list;
/* The flag to indicate this as "until" loop. */
int until;
};
/* A menu entry generate statement. */ /* A menu entry generate statement. */
struct grub_script_cmd_menuentry struct grub_script_cmd_menuentry
{ {
@ -234,6 +249,12 @@ grub_script_create_cmdfor (struct grub_parser_param *state,
struct grub_script_arglist *words, struct grub_script_arglist *words,
struct grub_script_cmd *list); struct grub_script_cmd *list);
struct grub_script_cmd *
grub_script_create_cmdwhile (struct grub_parser_param *state,
struct grub_script_cmd *cond,
struct grub_script_cmd *list,
int is_an_until_loop);
struct grub_script_cmd * struct grub_script_cmd *
grub_script_create_cmdmenu (struct grub_parser_param *state, grub_script_create_cmdmenu (struct grub_parser_param *state,
struct grub_script_arglist *arglist, struct grub_script_arglist *arglist,
@ -283,6 +304,7 @@ grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd); grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd); grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd); grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd); grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
/* Execute any GRUB pre-parsed command or script. */ /* Execute any GRUB pre-parsed command or script. */

24
include/grub/sdl.h Normal file
View file

@ -0,0 +1,24 @@
/*
* 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/>.
*/
void EXPORT_FUNC (SDL_Quit) (void);
void EXPORT_FUNC (SDL_SetColors) (void);
void EXPORT_FUNC (SDL_Init) (void);
void EXPORT_FUNC (SDL_GetError) (void);
void EXPORT_FUNC (SDL_Flip) (void);
void EXPORT_FUNC (SDL_SetVideoMode) (void);

0
lib/posix_wrap/locale.h Normal file
View file

View file

@ -335,14 +335,16 @@ GRUB_MOD_INIT(multiboot)
#ifdef GRUB_USE_MULTIBOOT2 #ifdef GRUB_USE_MULTIBOOT2
grub_register_command ("multiboot2", grub_cmd_multiboot, grub_register_command ("multiboot2", grub_cmd_multiboot,
0, N_("Load a multiboot 2 kernel.")); 0, N_("Load a multiboot 2 kernel."));
cmd_module =
grub_register_command ("module2", grub_cmd_module,
0, N_("Load a multiboot 2 module."));
#else #else
grub_register_command ("multiboot", grub_cmd_multiboot, grub_register_command ("multiboot", grub_cmd_multiboot,
0, N_("Load a multiboot kernel.")); 0, N_("Load a multiboot kernel."));
#endif
cmd_module = cmd_module =
grub_register_command ("module", grub_cmd_module, grub_register_command ("module", grub_cmd_module,
0, N_("Load a multiboot module.")); 0, N_("Load a multiboot module."));
#endif
my_mod = mod; my_mod = mod;
} }

View file

@ -51,11 +51,8 @@ autoload_fs_module (void)
/* Read the file fs.lst for auto-loading. */ /* Read the file fs.lst for auto-loading. */
void void
read_fs_list (void) read_fs_list (const char *prefix)
{ {
const char *prefix;
prefix = grub_env_get ("prefix");
if (prefix) if (prefix)
{ {
char *filename; char *filename;

View file

@ -66,14 +66,12 @@ grub_crypto_spec_free (void)
/* Read the file crypto.lst for auto-loading. */ /* Read the file crypto.lst for auto-loading. */
void void
read_crypto_list (void) read_crypto_list (const char *prefix)
{ {
const char *prefix;
char *filename; char *filename;
grub_file_t file; grub_file_t file;
char *buf = NULL; char *buf = NULL;
prefix = grub_env_get ("prefix");
if (!prefix) if (!prefix)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;

View file

@ -60,11 +60,8 @@ grub_dyncmd_dispatcher (struct grub_command *cmd,
/* Read the file command.lst for auto-loading. */ /* Read the file command.lst for auto-loading. */
void void
read_command_list (void) read_command_list (const char *prefix)
{ {
const char *prefix;
prefix = grub_env_get ("prefix");
if (prefix) if (prefix)
{ {
char *filename; char *filename;

View file

@ -434,14 +434,20 @@ grub_normal_init_page (struct grub_term_output *term)
grub_free (unicode_msg); grub_free (unicode_msg);
} }
static void
read_lists (const char *val)
{
read_command_list (val);
read_fs_list (val);
read_crypto_list (val);
read_terminal_list (val);
}
static char * static char *
read_lists (struct grub_env_var *var __attribute__ ((unused)), read_lists_hook (struct grub_env_var *var __attribute__ ((unused)),
const char *val) const char *val)
{ {
read_command_list (); read_lists (val);
read_fs_list ();
read_crypto_list ();
read_terminal_list ();
return val ? grub_strdup (val) : NULL; return val ? grub_strdup (val) : NULL;
} }
@ -451,10 +457,11 @@ void
grub_normal_execute (const char *config, int nested, int batch) grub_normal_execute (const char *config, int nested, int batch)
{ {
grub_menu_t menu = 0; grub_menu_t menu = 0;
const char *prefix = grub_env_get ("prefix");
read_lists (NULL, NULL); read_lists (prefix);
read_handler_list (); read_handler_list ();
grub_register_variable_hook ("prefix", NULL, read_lists); grub_register_variable_hook ("prefix", NULL, read_lists_hook);
grub_command_execute ("parser.grub", 0, 0); grub_command_execute ("parser.grub", 0, 0);
if (config) if (config)

View file

@ -176,10 +176,17 @@ print_message (int nested, int edit, struct grub_term_output *term)
if (edit) if (edit)
{ {
grub_putcode ('\n', term); grub_putcode ('\n', term);
#ifdef GRUB_MACHINE_EFI
grub_print_message_indented (_("Minimum Emacs-like screen editing is \
supported. TAB lists completions. Press F1 to boot, F2=Ctrl-a, F3=Ctrl-e, \
F4 for a command-line or ESC to discard edits and return to the GRUB menu."),
STANDARD_MARGIN, STANDARD_MARGIN, term);
#else
grub_print_message_indented (_("Minimum Emacs-like screen editing is \ grub_print_message_indented (_("Minimum Emacs-like screen editing is \
supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \ supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \
command-line or ESC to return menu."), STANDARD_MARGIN, STANDARD_MARGIN, command-line or ESC to discard edits and return to the GRUB menu."),
term); STANDARD_MARGIN, STANDARD_MARGIN, term);
#endif
} }
else else
{ {

View file

@ -167,14 +167,12 @@ grub_terminal_autoload_free (void)
/* Read the file terminal.lst for auto-loading. */ /* Read the file terminal.lst for auto-loading. */
void void
read_terminal_list (void) read_terminal_list (const char *prefix)
{ {
const char *prefix;
char *filename; char *filename;
grub_file_t file; grub_file_t file;
char *buf = NULL; char *buf = NULL;
prefix = grub_env_get ("prefix");
if (!prefix) if (!prefix)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;

View file

@ -26,13 +26,24 @@
#include <grub/lib/arg.h> #include <grub/lib/arg.h>
#include <grub/normal.h> #include <grub/normal.h>
/* Max digits for a char is 3 (0xFF is 255), similarly for an int it
is sizeof (int) * 3, and one extra for a possible -ve sign. */
#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
static grub_err_t static grub_err_t
grub_script_execute_cmd (struct grub_script_cmd *cmd) grub_script_execute_cmd (struct grub_script_cmd *cmd)
{ {
int ret;
char errnobuf[ERRNO_DIGITS_MAX + 1];
if (cmd == 0) if (cmd == 0)
return 0; return 0;
return cmd->exec (cmd); ret = cmd->exec (cmd);
grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
grub_env_set ("?", errnobuf);
return ret;
} }
#define ARG_ALLOCATION_UNIT (32 * sizeof (char)) #define ARG_ALLOCATION_UNIT (32 * sizeof (char))
@ -260,13 +271,14 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
grub_err_t grub_err_t
grub_script_execute_cmdblock (struct grub_script_cmd *cmd) grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
{ {
int ret = 0;
struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd; struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd;
/* Loop over every command and execute it. */ /* Loop over every command and execute it. */
for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next) for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next)
grub_script_execute_cmd (cmd); ret = grub_script_execute_cmd (cmd);
return 0; return ret;
} }
/* Execute an if statement. */ /* Execute an if statement. */
@ -317,6 +329,26 @@ grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
return result; return result;
} }
/* Execute a "while" or "until" command. */
grub_err_t
grub_script_execute_cmdwhile (struct grub_script_cmd *cmd)
{
int cond;
int result;
struct grub_script_cmdwhile *cmdwhile = (struct grub_script_cmdwhile *) cmd;
result = 0;
do {
cond = grub_script_execute_cmd (cmdwhile->cond);
if (cmdwhile->until ? !cond : cond)
break;
result = grub_script_execute_cmd (cmdwhile->list);
} while (1); /* XXX Put a check for ^C here */
return result;
}
/* Execute the menu entry generate statement. */ /* Execute the menu entry generate statement. */
grub_err_t grub_err_t
grub_script_execute_menuentry (struct grub_script_cmd *cmd) grub_script_execute_menuentry (struct grub_script_cmd *cmd)

View file

@ -74,8 +74,10 @@
%token <arg> GRUB_PARSER_TOKEN_WORD "word" %token <arg> GRUB_PARSER_TOKEN_WORD "word"
%type <arglist> word argument arguments0 arguments1 %type <arglist> word argument arguments0 arguments1
%type <cmd> script_init script grubcmd ifcmd forcmd command
%type <cmd> commands1 menuentry statement %type <cmd> script_init script
%type <cmd> grubcmd ifclause ifcmd forcmd whilecmd untilcmd
%type <cmd> command commands1 menuentry statement
%pure-parser %pure-parser
%lex-param { struct grub_parser_param *state }; %lex-param { struct grub_parser_param *state };
@ -174,6 +176,8 @@ grubcmd: word arguments0
command: grubcmd { $$ = $1; } command: grubcmd { $$ = $1; }
| ifcmd { $$ = $1; } | ifcmd { $$ = $1; }
| forcmd { $$ = $1; } | forcmd { $$ = $1; }
| whilecmd { $$ = $1; }
| untilcmd { $$ = $1; }
; ;
/* A list of commands. */ /* A list of commands. */
@ -224,17 +228,27 @@ menuentry: "menuentry"
} }
; ;
if: "if" { grub_script_lexer_ref (state->lexerstate); } ifcmd: "if"
;
ifcmd: if commands1 delimiters1 "then" commands1 delimiters1 "fi"
{ {
$$ = grub_script_create_cmdif (state, $2, $5, 0); grub_script_lexer_ref (state->lexerstate);
}
ifclause "fi"
{
$$ = $3;
grub_script_lexer_deref (state->lexerstate); grub_script_lexer_deref (state->lexerstate);
} }
| if commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1 "fi" ;
ifclause: commands1 delimiters1 "then" commands1 delimiters1
{ {
$$ = grub_script_create_cmdif (state, $2, $5, $8); $$ = grub_script_create_cmdif (state, $1, $4, 0);
grub_script_lexer_deref (state->lexerstate); }
| commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1
{
$$ = grub_script_create_cmdif (state, $1, $4, $7);
}
| commands1 delimiters1 "then" commands1 delimiters1 "elif" ifclause
{
$$ = grub_script_create_cmdif (state, $1, $4, $7);
} }
; ;
@ -248,3 +262,25 @@ forcmd: "for" "name"
grub_script_lexer_deref (state->lexerstate); grub_script_lexer_deref (state->lexerstate);
} }
; ;
whilecmd: "while"
{
grub_script_lexer_ref (state->lexerstate);
}
commands1 delimiters1 "do" commands1 delimiters1 "done"
{
$$ = grub_script_create_cmdwhile (state, $3, $6, 0);
grub_script_lexer_deref (state->lexerstate);
}
;
untilcmd: "until"
{
grub_script_lexer_ref (state->lexerstate);
}
commands1 delimiters1 "do" commands1 delimiters1 "done"
{
$$ = grub_script_create_cmdwhile (state, $3, $6, 1);
grub_script_lexer_deref (state->lexerstate);
}
;

View file

@ -245,6 +245,28 @@ grub_script_create_cmdfor (struct grub_parser_param *state,
return (struct grub_script_cmd *) cmd; return (struct grub_script_cmd *) cmd;
} }
/* Create a "while" or "until" command. */
struct grub_script_cmd *
grub_script_create_cmdwhile (struct grub_parser_param *state,
struct grub_script_cmd *cond,
struct grub_script_cmd *list,
int is_an_until_loop)
{
struct grub_script_cmdwhile *cmd;
cmd = grub_script_malloc (state, sizeof (*cmd));
if (! cmd)
return 0;
cmd->cmd.exec = grub_script_execute_cmdwhile;
cmd->cmd.next = 0;
cmd->cond = cond;
cmd->list = list;
cmd->until = is_an_until_loop;
return (struct grub_script_cmd *) cmd;
}
/* Create a command that adds a menu entry to the menu. Title is an /* Create a command that adds a menu entry to the menu. Title is an
argument that is parsed to generate a string that can be used as argument that is parsed to generate a string that can be used as
the title. The sourcecode for this entry is passed in SOURCECODE. the title. The sourcecode for this entry is passed in SOURCECODE.

View file

@ -159,27 +159,27 @@ grub_console_checkkey (void)
read_key = key.unicode_char; read_key = key.unicode_char;
break; break;
case 0x01: case 0x01:
read_key = 16; read_key = GRUB_TERM_UP;
break; break;
case 0x02: case 0x02:
read_key = 14; read_key = GRUB_TERM_DOWN;
break; break;
case 0x03: case 0x03:
read_key = 6; read_key = GRUB_TERM_RIGHT;
break; break;
case 0x04: case 0x04:
read_key = 2; read_key = GRUB_TERM_LEFT;
break; break;
case 0x05: case 0x05:
read_key = 1; read_key = GRUB_TERM_HOME;
break; break;
case 0x06: case 0x06:
read_key = 5; read_key = GRUB_TERM_END;
break; break;
case 0x07: case 0x07:
break; break;
case 0x08: case 0x08:
read_key = 4; read_key = GRUB_TERM_DC;
break; break;
case 0x09: case 0x09:
break; break;
@ -194,6 +194,9 @@ grub_console_checkkey (void)
case 0x0d: case 0x0d:
read_key = 5; read_key = 5;
break; break;
case 0x0e:
read_key = 3;
break;
case 0x17: case 0x17:
read_key = '\e'; read_key = '\e';
break; break;

31
tests/grub_script_if.in Normal file
View file

@ -0,0 +1,31 @@
#! @builddir@/grub-shell-tester
#basic if, execute
if true; then echo yes; fi
#basic if, no execution
if false; then echo no; fi
#if else, execute if path
if true; then echo yes; else echo no; fi
#if else, execute else path
if false; then echo no; else echo yes; fi
#if elif, execute elif
if false; then echo no; elif true; then echo yes; fi
#if elif else, execute else
if false; then echo no; elif false; then echo no; else echo yes; fi
#if elif(1) elif(2), execute elif(2)
if false; then echo no; elif false; then echo no; elif true; then echo yes; fi
#if elif(1) elif(2) else, execute else
if false; then echo no; elif false; then echo no; elif false; then echo no; else echo yes; fi
#if {if elif else}, execute elif
if true; then if false; then echo no; elif true; then echo yes; else echo no; fi; fi
#if {if elif} else, execute elif. ofcourse no dangling-else problem due to "fi"
if true; then if false; then echo no; elif true; then echo yes; fi; else echo no; fi

View file

@ -0,0 +1,32 @@
#! @builddir@/grub-shell-tester
echo one
foo=""
while test "$foo" != "1111"; do foo="${foo}1"; echo "$foo"; done
echo two
foo=""
while test "$foo" != "aaaa"
do
foo="${foo}a"
echo $foo
done
foo=""
until test "$foo" = "1111"; do foo="${foo}1"; echo $foo; done
foo=""
until test "$foo" = "aaaa"
do
foo="${foo}a"
echo $foo
done
# check "$?" in condition gets its value from while body commands
foo=""
false
while test "$?" != "0"
do
echo $foo
foo="${foo}1"
test "$foo" = "111111"
done

View file

@ -135,7 +135,7 @@ fdafile=`mktemp`
cp ${isofile} ${fdafile} cp ${isofile} ${fdafile}
outfile=`mktemp` outfile=`mktemp`
qemu-system-i386 ${qemuopts} -nographic -serial stdio -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile} qemu-system-i386 ${qemuopts} -nographic -hda ${hdafile} -fda ${fdafile} -cdrom ${isofile} -boot ${bootdev} | tr -d "\r" >${outfile}
cat $outfile cat $outfile

View file

@ -38,8 +38,6 @@
#include <grub/partition.h> #include <grub/partition.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub_emu_init.h>
#define ENABLE_RELOCATABLE 0 #define ENABLE_RELOCATABLE 0
#include "progname.h" #include "progname.h"
@ -55,6 +53,7 @@ grub_arch_modules_addr (void)
return 0; return 0;
} }
#if GRUB_NO_MODULES
grub_err_t grub_err_t
grub_arch_dl_check_header (void *ehdr) grub_arch_dl_check_header (void *ehdr)
{ {
@ -71,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
return GRUB_ERR_BAD_MODULE; return GRUB_ERR_BAD_MODULE;
} }
#endif
void void
grub_reboot (void) grub_reboot (void)
@ -150,6 +150,10 @@ void grub_hostfs_init (void);
void grub_hostfs_fini (void); void grub_hostfs_fini (void);
void grub_host_init (void); void grub_host_init (void);
void grub_host_fini (void); void grub_host_fini (void);
#if GRUB_NO_MODULES
void grub_init_all (void);
void grub_fini_all (void);
#endif
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
@ -215,7 +219,9 @@ main (int argc, char *argv[])
/* XXX: This is a bit unportable. */ /* XXX: This is a bit unportable. */
grub_util_biosdisk_init (dev_map); grub_util_biosdisk_init (dev_map);
#if GRUB_NO_MODULES
grub_init_all (); grub_init_all ();
#endif
/* Make sure that there is a root device. */ /* Make sure that there is a root device. */
if (! root_dev) if (! root_dev)
@ -233,6 +239,9 @@ main (int argc, char *argv[])
} }
} }
if (strcmp (root_dev, "host") == 0)
dir = xstrdup (dir);
else
dir = grub_get_prefix (dir); dir = grub_get_prefix (dir);
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1); prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
sprintf (prefix, "(%s)%s", root_dev, dir); sprintf (prefix, "(%s)%s", root_dev, dir);
@ -242,7 +251,9 @@ main (int argc, char *argv[])
if (setjmp (main_env) == 0) if (setjmp (main_env) == 0)
grub_main (); grub_main ();
#if GRUB_NO_MODULES
grub_fini_all (); grub_fini_all ();
#endif
grub_hostfs_fini (); grub_hostfs_fini ();
grub_host_fini (); grub_host_fini ();

View file

@ -140,27 +140,31 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}" GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
fi fi
case x${GRUB_TERMINAL_OUTPUT} in termoutdefault=0
x | xgfxterm) if [ "x${GRUB_TERMINAL_OUTPUT}" == x ]; then
GRUB_TERMINAL_OUTPUT=gfxterm;
termoutdefault=1;
fi
for x in ${GRUB_TERMINAL_OUTPUT}; do
if [ x${x} == xgfxterm ]; then
# If this platform supports gfxterm, try to use it. # If this platform supports gfxterm, try to use it.
if test -e ${grub_prefix}/gfxterm.mod ; then if ! test -e ${grub_prefix}/gfxterm.mod ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "gfxterm isn't available on your platform" >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
break;
fi
# FIXME: this should do something smarter than just loading first # FIXME: this should do something smarter than just loading first
# video backend. # video backend.
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true) GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
GRUB_TERMINAL_OUTPUT=gfxterm if [ "x$termoutdefault" != "x1" ]; then
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1 echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
fi fi
GRUB_TERMINAL_OUTPUT=
fi fi
;;
xconsole | xserial | xofconsole) ;;
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
esac
# check for terminals that require fonts
case ${GRUB_TERMINAL_OUTPUT} in
gfxterm)
if [ -n "$GRUB_FONT" ] ; then if [ -n "$GRUB_FONT" ] ; then
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
GRUB_FONT_PATH=${GRUB_FONT} GRUB_FONT_PATH=${GRUB_FONT}
@ -186,14 +190,23 @@ case ${GRUB_TERMINAL_OUTPUT} in
done done
fi fi
if [ -z "${GRUB_FONT_PATH}" ] ; then if [ -z "${GRUB_FONT_PATH}" ] ; then
# fallback to the native terminal for this platform if [ "x$termoutdefault" != "x1" ]; then
unset GRUB_TERMINAL_OUTPUT echo "No font for gfxterm found." >&2 ; exit 1
fi fi
;; GRUB_TERMINAL_OUTPUT=
*) fi
fi
done
for x in ${GRUB_TERMINAL_OUTPUT}; do
case "x${x}" in
xgfxterm) ;;
xconsole | xserial | xofconsole)
# make sure all our children behave in conformance with ascii.. # make sure all our children behave in conformance with ascii..
export LANG=C export LANG=C;;
esac *) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
esac
done
# These are defined in this script, export them here so that user can # These are defined in this script, export them here so that user can
# override them. # override them.
@ -220,6 +233,7 @@ export GRUB_DEFAULT \
GRUB_DISABLE_LINUX_UUID \ GRUB_DISABLE_LINUX_UUID \
GRUB_DISABLE_LINUX_RECOVERY \ GRUB_DISABLE_LINUX_RECOVERY \
GRUB_GFXMODE \ GRUB_GFXMODE \
GRUB_BACKGROUND \
GRUB_THEME \ GRUB_THEME \
GRUB_GFXPAYLOAD_LINUX \ GRUB_GFXPAYLOAD_LINUX \
GRUB_DISABLE_OS_PROBER \ GRUB_DISABLE_OS_PROBER \

View file

@ -156,7 +156,7 @@ EOF
echo "insmod $i" echo "insmod $i"
done ; \ done ; \
echo "source /boot/grub/grub.cfg") \ echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg > ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg
tar -C ${memdisk_dir} -cf ${memdisk_img} boot tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir} rm -rf ${memdisk_dir}
@ -187,7 +187,7 @@ if test -e "${pc_dir}" ; then
echo "source /boot/grub/grub.cfg") \ echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-pc/grub.cfg > ${iso9660_dir}/boot/grub/i386-pc/grub.cfg
grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -boot-info-table \ grub_mkisofs_arguments="${grub_mkisofs_arguments} -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-info-table \
--embedded-boot ${embed_img}" --embedded-boot ${embed_img}"
fi fi

View file

@ -87,6 +87,12 @@ grub_script_execute_cmdfor (struct grub_script_cmd *cmd __attribute__ ((unused))
return 0; return 0;
} }
grub_err_t
grub_script_execute_cmdwhile (struct grub_script_cmd *cmd __attribute__ ((unused)))
{
return 0;
}
grub_err_t grub_err_t
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused))) grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
{ {

View file

@ -59,8 +59,18 @@ function savedefault {
} }
EOF EOF
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in serial=0;
serial:* | *:serial) gfxterm=0;
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
if [ xserial = "x$x" ]; then
serial=1;
fi
if [ xgfxterm = "x$x" ]; then
gfxterm=1;
fi
done
if [ "x$serial" = x1 ]; then
if ! test -e ${grub_prefix}/serial.mod ; then if ! test -e ${grub_prefix}/serial.mod ; then
echo "Serial terminal not available on this platform." >&2 ; exit 1 echo "Serial terminal not available on this platform." >&2 ; exit 1
fi fi
@ -70,8 +80,71 @@ case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
GRUB_SERIAL_COMMAND=serial GRUB_SERIAL_COMMAND=serial
fi fi
echo "${GRUB_SERIAL_COMMAND}" echo "${GRUB_SERIAL_COMMAND}"
;; fi
esac
if [ "x$gfxterm" = x1 ]; then
# Make the font accessible
prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`
cat << EOF
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
set gfxmode=${GRUB_GFXMODE}
insmod gfxterm
insmod ${GRUB_VIDEO_BACKEND}
EOF
if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
&& is_path_readable_by_grub "$GRUB_THEME"; then
echo "Found theme: $GRUB_THEME" >&2
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"` | sed -e "s/^/ /"
cat << EOF
insmod gfxmenu
EOF
themedir="`dirname "$GRUB_THEME"`"
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
if [ -f "$x" ]; then
cat << EOF
loadfont (\$root)`make_system_path_relative_to_its_root $x`
EOF
fi
done
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
cat << EOF
insmod jpeg
EOF
fi
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
cat << EOF
insmod png
EOF
fi
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
cat << EOF
insmod tga
EOF
fi
cat << EOF
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
EOF
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
echo "Found background: $GRUB_BACKGROUND" >&2
case "$GRUB_BACKGROUND" in
*.png) reader=png ;;
*.tga) reader=tga ;;
*.jpg|*.jpeg) reader=jpeg ;;
*) echo "Unsupported image format" >&2; exit 1 ;;
esac
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"` | sed -e "s/^/ /"
cat << EOF
insmod $reader
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
EOF
fi
cat << EOF
fi
EOF
fi
case x${GRUB_TERMINAL_INPUT} in case x${GRUB_TERMINAL_INPUT} in
x) x)
@ -89,35 +162,6 @@ EOF
esac esac
case x${GRUB_TERMINAL_OUTPUT} in case x${GRUB_TERMINAL_OUTPUT} in
xgfxterm)
# Make the font accessible
prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
cat << EOF
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
set gfxmode=${GRUB_GFXMODE}
insmod gfxterm
insmod ${GRUB_VIDEO_BACKEND}
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
EOF
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
&& is_path_readable_by_grub $GRUB_THEME; then
echo "Found theme: $GRUB_THEME" >&2
prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /"
cat << EOF
insmod gfxmenu
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
set menuviewer=gfxmenu
EOF
fi
cat << EOF
fi
EOF
;;
x) x)
# Just use the native terminal # Just use the native terminal
;; ;;

View file

@ -27,7 +27,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU OS=GNU
else else
OS="${GRUB_DISTRIBUTOR} GNU/Hurd" OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
fi fi
at_least_one=false at_least_one=false

View file

@ -30,7 +30,7 @@ CLASS="--class os"
case "${GRUB_DISTRIBUTOR}" in case "${GRUB_DISTRIBUTOR}" in
Debian) Debian)
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') --class gnu-kfreebsd --class gnu ${CLASS}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
;; ;;
*) *)
OS="FreeBSD" OS="FreeBSD"

View file

@ -31,7 +31,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux OS=GNU/Linux
else else
OS="${GRUB_DISTRIBUTOR} GNU/Linux" OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') ${CLASS}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
fi fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but # loop-AES arranges things so that /dev/loop/X can be our root device, but

View file

@ -1042,7 +1042,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
drive = find_system_device (os_dev); drive = find_system_device (os_dev);
if (drive < 0) if (drive < 0)
{ {
grub_error (GRUB_ERR_BAD_DEVICE, grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"no mapping exists for `%s'", os_dev); "no mapping exists for `%s'", os_dev);
return 0; return 0;
} }

View file

@ -35,6 +35,7 @@
#endif #endif
#include <grub/kernel.h> #include <grub/kernel.h>
#include <grub/dl.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/cache.h> #include <grub/cache.h>
#include <grub/util/misc.h> #include <grub/util/misc.h>
@ -262,56 +263,6 @@ grub_util_write_image (const char *img, size_t size, FILE *out)
grub_util_error ("write failed"); grub_util_error ("write failed");
} }
void *
grub_malloc (grub_size_t size)
{
return xmalloc (size);
}
void *
grub_zalloc (grub_size_t size)
{
void *ret;
ret = xmalloc (size);
memset (ret, 0, size);
return ret;
}
void
grub_free (void *ptr)
{
free (ptr);
}
void *
grub_realloc (void *ptr, grub_size_t size)
{
return xrealloc (ptr, size);
}
void *
grub_memalign (grub_size_t align, grub_size_t size)
{
void *p;
#if defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign (&p, align, size) != 0)
p = 0;
#elif defined(HAVE_MEMALIGN)
p = memalign (align, size);
#else
(void) align;
(void) size;
grub_util_error ("grub_memalign is not supported");
#endif
if (! p)
grub_util_error ("out of memory");
return p;
}
/* Some functions that we don't use. */ /* Some functions that we don't use. */
void void
grub_mm_init_region (void *addr __attribute__ ((unused)), grub_mm_init_region (void *addr __attribute__ ((unused)),
@ -319,10 +270,12 @@ grub_mm_init_region (void *addr __attribute__ ((unused)),
{ {
} }
#if GRUB_NO_MODULES
void void
grub_register_exported_symbols (void) grub_register_exported_symbols (void)
{ {
} }
#endif
void void
grub_exit (void) grub_exit (void)
@ -374,7 +327,7 @@ grub_millisleep (grub_uint32_t ms)
#endif #endif
#if !(defined (__i386__) || defined (__x86_64__)) #if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES
void void
grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_arch_sync_caches (void *address __attribute__ ((unused)),
grub_size_t len __attribute__ ((unused))) grub_size_t len __attribute__ ((unused)))

85
util/mm.c Normal file
View file

@ -0,0 +1,85 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,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 <grub/types.h>
#include <grub/err.h>
#include <grub/mm.h>
#include <stdlib.h>
#include <string.h>
void *
grub_malloc (grub_size_t size)
{
void *ret;
ret = malloc (size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
return ret;
}
void *
grub_zalloc (grub_size_t size)
{
void *ret;
ret = grub_malloc (size);
if (!ret)
return NULL;
memset (ret, 0, size);
return ret;
}
void
grub_free (void *ptr)
{
free (ptr);
}
void *
grub_realloc (void *ptr, grub_size_t size)
{
void *ret;
ret = realloc (ptr, size);
if (!ret)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
return ret;
}
void *
grub_memalign (grub_size_t align, grub_size_t size)
{
void *p;
#if defined(HAVE_POSIX_MEMALIGN)
if (align < sizeof (void *))
align = sizeof (void *);
if (posix_memalign (&p, align, size) != 0)
p = 0;
#elif defined(HAVE_MEMALIGN)
p = memalign (align, size);
#else
(void) align;
(void) size;
grub_util_error ("grub_memalign is not supported");
#endif
if (!p)
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
return p;
}