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>
POSIX header file wrappers.

View File

@ -43,6 +43,7 @@ pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '
# Internationalization library.
LIBINTL = @LIBINTL@
TARGET_NO_MODULES = @TARGET_NO_MODULES@
XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@
@ -136,7 +137,7 @@ enable_efiemu = @enable_efiemu@
### General variables.
RMKFILES = $(wildcard conf/*.rmk)
RMKFILES = $(wildcard $(srcdir)/conf/*.rmk)
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 \
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)
# The default target.
@ -179,10 +182,15 @@ include $(srcdir)/conf/tests.mk
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
endif
ifeq ($(TARGET_NO_MODULES), yes)
TARGET_CFLAGS += -DGRUB_TARGET_NO_MODULES=1
CFLAGS += -DGRUB_TARGET_NO_MODULES=1
endif
### General targets.
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
endif
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
@ -427,6 +435,8 @@ distclean: mostlyclean
maintainer-clean: distclean
-test -z "$(MAINTAINER_CLEANFILES)" || rm -f $(MAINTAINER_CLEANFILES)
-rmdir $(srcdir)/lib/libgcrypt-grub/cipher
-rmdir $(srcdir)/lib/libgcrypt-grub
info:
@ -530,8 +540,8 @@ genkernsyms.sh: genkernsyms.sh.in config.status
$(SHELL) ./config.status
$(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 $@ -f po/POTFILES-shell -j --language=Shell
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 po/$(PACKAGE).pot -f po/POTFILES-shell -j --language=Shell
$(foreach lang, $(LINGUAS), $(srcdir)/po/$(lang).po): po/$(PACKAGE).pot
$(MSGMERGE) -U $@ $^

View File

@ -1,9 +1,7 @@
# -*- makefile -*-
COMMON_LDFLAGS += -nostdlib
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
kernel_img_RELOCATABLE = yes
pkglib_PROGRAMS = kernel.img
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
@ -11,15 +9,26 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
kern/parser.c kern/partition.c kern/term.c \
kern/rescue_reader.c kern/rescue_parser.c \
\
util/console.c util/grub-emu.c util/misc.c util/hostdisk.c \
util/getroot.c util/time.c \
\
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c
\
util/console.c util/grub-emu.c util/misc.c \
util/hostdisk.c util/getroot.c util/mm.c util/time.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_LDFLAGS = $(COMMON_LDFLAGS)
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.
pkglib_MODULES += halt.mod
@ -37,6 +46,8 @@ endif
grub_emu_LDFLAGS = $(LIBCURSES)
ifeq ($(enable_grub_emu_usb), yes)
kernel_img_HEADERS += libusb.h
pkglib_MODULES += libusb.mod
libusb_mod_SOURCES = util/usb.c
libusb_mod_CFLAGS =
@ -69,6 +80,7 @@ sdl_mod_SOURCES = util/sdl.c
sdl_mod_CFLAGS =
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBSDL)
kernel_img_HEADERS += sdl.h
endif
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) > $@
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) > $@
DISTCLEANFILES += grub_emu_init.c
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)
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
endif
GRUB_EMU=grub-emu

View File

@ -25,7 +25,7 @@ util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
sbin_UTILITIES += grub-probe
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
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/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.
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
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 \
disk/host.c disk/loopback.c kern/list.c kern/command.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
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
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 \
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 \
@ -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 \
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 \
machine/memory.h machine/loader.h machine/kernel.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
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
@ -184,7 +187,7 @@ DISTCLEANFILES += grub_fstest_init.c
# for 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
# Needed for genmk.rb to work
@ -852,7 +855,7 @@ boot_mod_CFLAGS = $(COMMON_CFLAGS)
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
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
include $(srcdir)/conf/gcry.mk

View File

@ -90,7 +90,7 @@ grub_setup_SOURCES = gnulib/progname.c \
partmap/gpt.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
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 \
\
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
# For grub-ofpathname.

View File

@ -53,6 +53,12 @@ grub_script_vars1_SOURCES = tests/grub_script_vars1.in
check_SCRIPTS += grub_script_for1
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
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_vars1
SCRIPTED_TESTS += grub_script_for1
SCRIPTED_TESTS += grub_script_while1
SCRIPTED_TESTS += grub_script_if
SCRIPTED_TESTS += grub_script_blanklines
SCRIPTED_TESTS += grub_script_final_semicolon
# dependencies between tests and testing-tools
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
$(FUNCTIONAL_TESTS): functional_test.mod

View File

@ -584,6 +584,10 @@ AC_ARG_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)])])
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
missing_ncurses=
[# 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])
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
grub_emu_usb_excuse="explicitly disabled"
fi
@ -779,6 +790,11 @@ echo PCI support for grub-emu: Yes
else
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
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
if [ x"$enable_mm_debug" = xyes ]; then
echo With memory debugging: Yes

View File

@ -91,25 +91,24 @@ struct font_file_section
};
/* Replace unknown glyphs with a rounded question mark. */
static grub_uint8_t unknown_glyph_bitmap[] =
{
/* 76543210 */
0x7C, /* ooooo */
0x82, /* o o */
0xBA, /* o ooo o */
0xAA, /* o o o o */
0xAA, /* o o o o */
0x8A, /* o o o */
0x9A, /* o oo o */
0x92, /* o o o */
0x92, /* o o o */
0x92, /* o o o */
0x92, /* o o o */
0x82, /* o o */
0x92, /* o o o */
0x82, /* o o */
0x7C, /* ooooo */
0x00 /* */
static grub_uint8_t unknown_glyph_bitmap[] = {
/* 76543210 */
0x7C, /* ooooo */
0x82, /* o o */
0xBA, /* o ooo o */
0xAA, /* o o o o */
0xAA, /* o o o o */
0x8A, /* o o o */
0x9A, /* o oo o */
0x92, /* o o o */
0x92, /* o o o */
0x92, /* o o o */
0x92, /* o o o */
0x82, /* o o */
0x92, /* o o o */
0x82, /* o o */
0x7C, /* ooooo */
0x00 /* */
};
/* The "unknown glyph" glyph, used as a last resort. */
@ -130,7 +129,7 @@ static struct grub_font_glyph *ascii_font_glyph[0x80];
static struct grub_font_glyph *
ascii_glyph_lookup (grub_uint32_t code)
{
#ifdef USE_ASCII_FAILBACK
#ifdef USE_ASCII_FAILBACK
static int ascii_failback_initialized = 0;
if (code >= 0x80)
@ -140,14 +139,14 @@ ascii_glyph_lookup (grub_uint32_t code)
{
int current;
for (current = 0; current < 0x80; current++)
{
ascii_font_glyph[current] = grub_malloc(sizeof(struct grub_font_glyph)
+ ASCII_BITMAP_SIZE);
{
ascii_font_glyph[current] =
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
ascii_font_glyph[current]->width = 8;
ascii_font_glyph[current]->height = 16;
ascii_font_glyph[current]->offset_x = 0;
ascii_font_glyph[current]->offset_y = -2;
ascii_font_glyph[current]->width = 8;
ascii_font_glyph[current]->height = 16;
ascii_font_glyph[current]->offset_x = 0;
ascii_font_glyph[current]->offset_y = -2;
ascii_font_glyph[current]->device_width = 8;
grub_memcpy (ascii_font_glyph[current]->bitmap,
@ -173,9 +172,9 @@ grub_font_loader_init (void)
return;
/* Make glyph for unknown glyph. */
unknown_glyph = grub_malloc(sizeof(struct grub_font_glyph)
+ sizeof(unknown_glyph_bitmap));
if (! unknown_glyph)
unknown_glyph = grub_malloc (sizeof (struct grub_font_glyph)
+ sizeof (unknown_glyph_bitmap));
if (!unknown_glyph)
return;
unknown_glyph->width = 8;
@ -183,13 +182,13 @@ grub_font_loader_init (void)
unknown_glyph->offset_x = 0;
unknown_glyph->offset_y = -3;
unknown_glyph->device_width = 8;
grub_memcpy(unknown_glyph->bitmap,
unknown_glyph_bitmap, sizeof(unknown_glyph_bitmap));
grub_memcpy (unknown_glyph->bitmap,
unknown_glyph_bitmap, sizeof (unknown_glyph_bitmap));
/* Initialize the null font. */
font_init (&null_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.max_char_width = unknown_glyph->width;
null_font.max_char_height = unknown_glyph->height;
@ -247,7 +246,7 @@ open_section (grub_file_t file, struct font_file_section *section)
else if (retval < 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"font format error: can't read section name");
"font format error: can't read section name");
return 1;
}
@ -262,7 +261,7 @@ open_section (grub_file_t file, struct font_file_section *section)
else if (retval < 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"font format error: can't read section length");
"font format error: can't read section length");
return 1;
}
@ -283,22 +282,22 @@ open_section (grub_file_t file, struct font_file_section *section)
grub_errno is set appropriately). */
static int
load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
grub_font *font)
grub_font *font)
{
unsigned i;
grub_uint32_t last_code;
#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
/* Sanity check: ensure section length is divisible by the entry size. */
if ((sect_length % FONT_CHAR_INDEX_ENTRY_SIZE) != 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"font file format error: character index length %d "
"is not a multiple of the entry size %d",
sect_length, FONT_CHAR_INDEX_ENTRY_SIZE);
"font file format error: character index length %d "
"is not a multiple of the entry size %d",
sect_length, FONT_CHAR_INDEX_ENTRY_SIZE);
return 1;
}
@ -307,11 +306,11 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
/* Allocate the character index array. */
font->char_index = grub_malloc (font->num_chars
* sizeof (struct char_index_entry));
if (! font->char_index)
* sizeof (struct char_index_entry));
if (!font->char_index)
return 1;
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
if (! font->bmp_idx)
if (!font->bmp_idx)
{
grub_free (font->char_index);
return 1;
@ -320,7 +319,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 2
grub_printf("num_chars=%d)\n", font->num_chars);
grub_printf ("num_chars=%d)\n", font->num_chars);
#endif
last_code = 0;
@ -332,17 +331,17 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
/* Read code point value; convert to native byte order. */
if (grub_file_read (file, &entry->code, 4) != 4)
return 1;
return 1;
entry->code = grub_be_to_cpu32 (entry->code);
/* Verify that characters are in ascending order. */
if (i != 0 && entry->code <= last_code)
{
grub_error (GRUB_ERR_BAD_FONT,
"font characters not in ascending order: %u <= %u",
entry->code, last_code);
return 1;
}
{
grub_error (GRUB_ERR_BAD_FONT,
"font characters not in ascending order: %u <= %u",
entry->code, last_code);
return 1;
}
if (entry->code < 0x10000)
font->bmp_idx[entry->code] = i;
@ -351,11 +350,11 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
/* Read storage flags byte. */
if (grub_file_read (file, &entry->storage_flags, 1) != 1)
return 1;
return 1;
/* Read glyph data offset; convert to native byte order. */
if (grub_file_read (file, &entry->offset, 4) != 4)
return 1;
return 1;
entry->offset = grub_be_to_cpu32 (entry->offset);
/* No glyph loaded. Will be loaded on demand and cached thereafter. */
@ -364,7 +363,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 5
/* Print the 1st 10 characters. */
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
}
@ -380,7 +379,7 @@ read_section_as_string (struct font_file_section *section)
grub_ssize_t ret;
str = grub_malloc (section->length + 1);
if (! str)
if (!str)
return 0;
ret = grub_file_read (section->file, str, section->length);
@ -398,18 +397,18 @@ read_section_as_string (struct font_file_section *section)
which is stored into *VALUE.
Returns 0 upon success, nonzero upon failure. */
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;
if (section->length != 2)
{
grub_error (GRUB_ERR_BAD_FONT,
"font file format error: section %c%c%c%c length "
"is %d but should be 2",
section->name[0], section->name[1],
section->name[2], section->name[3],
section->length);
"font file format error: section %c%c%c%c length "
"is %d but should be 2",
section->name[0], section->name[1],
section->name[2], section->name[3], section->length);
return 1;
}
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;
#if FONT_DEBUG >= 1
grub_printf("add_font(%s)\n", filename);
grub_printf ("add_font(%s)\n", filename);
#endif
file = grub_buffile_open (filename, 1024);
@ -438,7 +437,7 @@ grub_font_load (const char *filename)
goto fail;
#if FONT_DEBUG >= 3
grub_printf("file opened\n");
grub_printf ("file opened\n");
#endif
/* Read the FILE section. It indicates the file format. */
@ -446,159 +445,166 @@ grub_font_load (const char *filename)
goto fail;
#if FONT_DEBUG >= 3
grub_printf("opened FILE section\n");
grub_printf ("opened FILE section\n");
#endif
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,
"font file format error: 1st section must be FILE");
"font file format error: 1st section must be FILE");
goto fail;
}
#if FONT_DEBUG >= 3
grub_printf("section name ok\n");
grub_printf ("section name ok\n");
#endif
if (section.length != 4)
{
grub_error (GRUB_ERR_BAD_FONT,
"font file format error (file type ID length is %d "
"but should be 4)", section.length);
"font file format error (file type ID length is %d "
"but should be 4)", section.length);
goto fail;
}
#if FONT_DEBUG >= 3
grub_printf("section length ok\n");
grub_printf ("section length ok\n");
#endif
/* Check the file format type code. */
if (grub_file_read (file, magic, 4) != 4)
goto fail;
#if FONT_DEBUG >= 3
grub_printf("read magic ok\n");
grub_printf ("read magic ok\n");
#endif
if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
{
grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x",
magic[0], magic[1], magic[2], magic[3]);
magic[0], magic[1], magic[2], magic[3]);
goto fail;
}
#if FONT_DEBUG >= 3
grub_printf("compare magic ok\n");
grub_printf ("compare magic ok\n");
#endif
/* Allocate the font object. */
font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
if (! font)
if (!font)
goto fail;
font_init (font);
font->file = file;
#if FONT_DEBUG >= 3
grub_printf("allocate font ok; loading font info\n");
grub_printf ("allocate font ok; loading font info\n");
#endif
/* Load the font information. */
while (1)
{
if (open_section (file, &section) != 0)
{
if (section.eof)
break; /* Done reading the font file. */
else
goto fail;
}
{
if (section.eof)
break; /* Done reading the font file. */
else
goto fail;
}
#if FONT_DEBUG >= 2
grub_printf("opened section %c%c%c%c ok\n",
section.name[0], section.name[1],
section.name[2], section.name[3]);
grub_printf ("opened section %c%c%c%c ok\n",
section.name[0], section.name[1],
section.name[2], section.name[3]);
#endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME,
sizeof(FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
{
font->name = read_section_as_string (&section);
if (!font->name)
goto fail;
}
sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
{
font->name = read_section_as_string (&section);
if (!font->name)
goto fail;
}
else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
sizeof(FONT_FORMAT_SECTION_NAMES_POINT_SIZE) - 1) == 0)
{
if (read_section_as_short (&section, &font->point_size) != 0)
goto fail;
}
FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
1) == 0)
{
if (read_section_as_short (&section, &font->point_size) != 0)
goto fail;
}
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1) == 0)
{
char *wt;
wt = read_section_as_string (&section);
if (!wt)
continue;
/* Convert the weight string 'normal' or 'bold' into a number. */
if (grub_strcmp (wt, "normal") == 0)
font->weight = FONT_WEIGHT_NORMAL;
else if (grub_strcmp (wt, "bold") == 0)
font->weight = FONT_WEIGHT_BOLD;
grub_free (wt);
}
sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
== 0)
{
char *wt;
wt = read_section_as_string (&section);
if (!wt)
continue;
/* Convert the weight string 'normal' or 'bold' into a number. */
if (grub_strcmp (wt, "normal") == 0)
font->weight = FONT_WEIGHT_NORMAL;
else if (grub_strcmp (wt, "bold") == 0)
font->weight = FONT_WEIGHT_BOLD;
grub_free (wt);
}
else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH) - 1) == 0)
{
if (read_section_as_short (&section, &font->max_char_width) != 0)
goto fail;
}
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
- 1) == 0)
{
if (read_section_as_short (&section, &font->max_char_width) != 0)
goto fail;
}
else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT) - 1) == 0)
{
if (read_section_as_short (&section, &font->max_char_height) != 0)
goto fail;
}
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
- 1) == 0)
{
if (read_section_as_short (&section, &font->max_char_height) != 0)
goto fail;
}
else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_ASCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_ASCENT) - 1) == 0)
{
if (read_section_as_short (&section, &font->ascent) != 0)
goto fail;
}
FONT_FORMAT_SECTION_NAMES_ASCENT,
sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
== 0)
{
if (read_section_as_short (&section, &font->ascent) != 0)
goto fail;
}
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_DESCENT) - 1) == 0)
{
if (read_section_as_short (&section, &font->descent) != 0)
goto fail;
}
sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
== 0)
{
if (read_section_as_short (&section, &font->descent) != 0)
goto fail;
}
else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1) == 0)
{
if (load_font_index (file, section.length, font) != 0)
goto fail;
}
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
1) == 0)
{
if (load_font_index (file, section.length, font) != 0)
goto fail;
}
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA,
sizeof(FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
{
/* When the DATA section marker is reached, we stop reading. */
break;
}
sizeof (FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
{
/* When the DATA section marker is reached, we stop reading. */
break;
}
else
{
/* Unhandled section type, simply skip past it. */
{
/* Unhandled section type, simply skip past it. */
#if FONT_DEBUG >= 3
grub_printf("Unhandled section type, skipping.\n");
grub_printf ("Unhandled section type, skipping.\n");
#endif
grub_off_t section_end = grub_file_tell (file) + section.length;
if ((int) grub_file_seek (file, section_end) == -1)
goto fail;
}
grub_off_t section_end = grub_file_tell (file) + section.length;
if ((int) grub_file_seek (file, section_end) == -1)
goto fail;
}
}
if (! font->name)
if (!font->name)
{
grub_printf ("Note: Font has no name.\n");
font->name = grub_strdup ("Unknown");
@ -606,22 +612,19 @@ grub_font_load (const char *filename)
#if FONT_DEBUG >= 1
grub_printf ("Loaded font `%s'.\n"
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
font->name,
font->ascent, font->descent,
font->max_char_width, font->max_char_height,
font->num_chars);
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
font->name,
font->ascent, font->descent,
font->max_char_width, font->max_char_height, font->num_chars);
#endif
if (font->max_char_width == 0
|| font->max_char_height == 0
|| font->num_chars == 0
|| font->char_index == 0
|| font->ascent == 0
|| font->descent == 0)
|| font->char_index == 0 || font->ascent == 0 || font->descent == 0)
{
grub_error (GRUB_ERR_BAD_FONT,
"invalid font file: missing some required data");
"invalid font file: missing some required data");
goto fail;
}
@ -679,18 +682,18 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
lo = 0;
hi = font->num_chars - 1;
if (! table)
if (!table)
return 0;
while (lo <= hi)
{
mid = lo + (hi - lo) / 2;
if (code < table[mid].code)
hi = mid - 1;
hi = mid - 1;
else if (code > table[mid].code)
lo = mid + 1;
lo = mid + 1;
else
return &table[mid];
return &table[mid];
}
return 0;
@ -716,12 +719,12 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
int len;
if (index_entry->glyph)
/* Return cached glyph. */
return index_entry->glyph;
/* Return cached glyph. */
return index_entry->glyph;
if (! font->file)
/* No open file, can't load any glyphs. */
return 0;
if (!font->file)
/* No open file, can't load any glyphs. */
return 0;
/* Make sure we can find glyphs for error messages. Push active
error message to error stack and reset error message. */
@ -730,23 +733,23 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
grub_file_seek (font->file, index_entry->offset);
/* Read the glyph width, height, and baseline. */
if (read_be_uint16(font->file, &width) != 0
|| read_be_uint16(font->file, &height) != 0
|| read_be_int16(font->file, &xoff) != 0
|| read_be_int16(font->file, &yoff) != 0
|| read_be_int16(font->file, &dwidth) != 0)
{
remove_font (font);
return 0;
}
if (read_be_uint16 (font->file, &width) != 0
|| read_be_uint16 (font->file, &height) != 0
|| read_be_int16 (font->file, &xoff) != 0
|| read_be_int16 (font->file, &yoff) != 0
|| read_be_int16 (font->file, &dwidth) != 0)
{
remove_font (font);
return 0;
}
len = (width * height + 7) / 8;
glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
if (! glyph)
{
remove_font (font);
return 0;
}
if (!glyph)
{
remove_font (font);
return 0;
}
glyph->font = font;
glyph->width = width;
@ -757,13 +760,13 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
/* Don't try to read empty bitmaps (e.g., space characters). */
if (len != 0)
{
if (grub_file_read (font->file, glyph->bitmap, len) != len)
{
remove_font (font);
return 0;
}
}
{
if (grub_file_read (font->file, glyph->bitmap, len) != len)
{
remove_font (font);
return 0;
}
}
/* Restore old error message. */
grub_error_pop ();
@ -787,7 +790,7 @@ free_font (grub_font_t font)
if (font)
{
if (font->file)
grub_file_close (font->file);
grub_file_close (font->file);
grub_free (font->name);
grub_free (font->family);
grub_free (font->char_index);
@ -804,7 +807,7 @@ register_font (grub_font_t font)
struct grub_font_node *node = 0;
node = grub_malloc (sizeof (struct grub_font_node));
if (! node)
if (!node)
return 1;
node->value = font;
@ -822,18 +825,17 @@ remove_font (grub_font_t font)
struct grub_font_node **nextp, *cur;
for (nextp = &grub_font_list, cur = *nextp;
cur;
nextp = &cur->next, cur = cur->next)
cur; nextp = &cur->next, cur = cur->next)
{
if (cur->value == font)
{
*nextp = cur->next;
{
*nextp = cur->next;
/* Free the node, but not the font itself. */
grub_free (cur);
/* Free the node, but not the font itself. */
grub_free (cur);
return;
}
return;
}
}
}
@ -850,7 +852,7 @@ grub_font_get (const char *font_name)
{
grub_font_t font = node->value;
if (grub_strcmp (font->name, font_name) == 0)
return font;
return font;
}
/* If no font by that name is found, return the first font in the list
@ -927,7 +929,7 @@ grub_font_get_string_width (grub_font_t font, const char *str)
const grub_uint8_t *ptr;
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);
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
of 24 point text unless there is no other choice. */
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;
@ -1011,7 +1013,7 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
/* First try to get the glyph from the specified font. */
glyph = grub_font_get_glyph_internal (font, code);
if (glyph)
return glyph;
return glyph;
}
/* Otherwise, search all loaded fonts for the glyph and use the one from
@ -1028,16 +1030,16 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
glyph = grub_font_get_glyph_internal (curfont, code);
if (glyph)
{
int d;
{
int d;
d = get_font_diversity (curfont, font);
if (d < best_diversity)
{
best_diversity = d;
best_glyph = glyph;
}
}
d = get_font_diversity (curfont, font);
if (d < best_diversity)
{
best_diversity = d;
best_glyph = glyph;
}
}
}
if (best_glyph)
@ -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
side location of the character. */
grub_err_t
grub_font_draw_glyph (struct grub_font_glyph *glyph,
grub_video_color_t color,
int left_x, int baseline_y)
grub_font_draw_glyph (struct grub_font_glyph * glyph,
grub_video_color_t color, int left_x, int baseline_y)
{
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.height = glyph->height;
glyph_bitmap.mode_info.mode_type =
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
glyph_bitmap.mode_info.bpp = 1;
@ -1081,11 +1081,11 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
glyph_bitmap.mode_info.bg_green = 0;
glyph_bitmap.mode_info.bg_blue = 0;
glyph_bitmap.mode_info.bg_alpha = 0;
grub_video_unmap_color(color,
&glyph_bitmap.mode_info.fg_red,
&glyph_bitmap.mode_info.fg_green,
&glyph_bitmap.mode_info.fg_blue,
&glyph_bitmap.mode_info.fg_alpha);
grub_video_unmap_color (color,
&glyph_bitmap.mode_info.fg_red,
&glyph_bitmap.mode_info.fg_green,
&glyph_bitmap.mode_info.fg_blue,
&glyph_bitmap.mode_info.fg_alpha);
glyph_bitmap.data = glyph->bitmap;
int bitmap_left = left_x + glyph->offset_x;
@ -1093,9 +1093,8 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
int bitmap_top = bitmap_bottom - glyph->height;
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
bitmap_left, bitmap_top,
0, 0,
glyph->width, glyph->height);
bitmap_left, bitmap_top,
0, 0, glyph->width, glyph->height);
}
/* 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. */
grub_err_t
grub_font_draw_string (const char *str, grub_font_t font,
grub_video_color_t color,
int left_x, int baseline_y)
grub_video_color_t color, int left_x, int baseline_y)
{
int x;
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;
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);
if (grub_font_draw_glyph (glyph, color, x, baseline_y)
!= GRUB_ERR_NONE)
return grub_errno;
if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE)
return grub_errno;
x += glyph->device_width;
}
return GRUB_ERR_NONE;
}

View File

@ -143,7 +143,7 @@ mostlyclean-module-#{@name}.#{@rule_count}:
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
UNDSYMFILES += #{undsym}
ifeq ($(TARGET_NO_DYNAMIC_MODULES), yes)
ifeq ($(TARGET_NO_MODULES), yes)
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
-rm -f $@
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
@ -322,28 +322,32 @@ class Program
end
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)
prefix = @name.to_var
objs = sources.collect do |src|
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
prefix + '-' + src.to_obj
end
objs_str = objs.join(' ');
deps = objs.collect {|obj| obj.suffix('d')}
deps_str = deps.join(' ');
"CLEANFILES += #{@name} #{objs_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
"MOSTLYCLEANFILES += #{deps_str}
" + objs.collect_with_index do |obj, i|
src = sources[i]
@ -358,6 +362,7 @@ endif
-include #{dep}
#{prefix}_OBJECTS += #{obj}
"
end.join('')
end
@ -466,4 +471,5 @@ while l = gets
end
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);
void grub_dl_unload_unneeded (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
#else
#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_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
void grub_arch_dl_init_linker (void);
#endif

View File

@ -34,9 +34,9 @@
by firmware. */
#define GRUB_MACHINE_MEMORY_HOLE 6
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_uint32_t));
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, 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);
/* Defined in `dyncmd.c'. */
void read_command_list (void);
void read_command_list (const char *prefix);
/* Defined in `autofs.c'. */
void read_fs_list (void);
void read_fs_list (const char *prefix);
void grub_context_init (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);

View File

@ -121,6 +121,21 @@ struct grub_script_cmdfor
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. */
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_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 *
grub_script_create_cmdmenu (struct grub_parser_param *state,
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_cmdif (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);
/* 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
grub_register_command ("multiboot2", grub_cmd_multiboot,
0, N_("Load a multiboot 2 kernel."));
cmd_module =
grub_register_command ("module2", grub_cmd_module,
0, N_("Load a multiboot 2 module."));
#else
grub_register_command ("multiboot", grub_cmd_multiboot,
0, N_("Load a multiboot kernel."));
#endif
cmd_module =
grub_register_command ("module", grub_cmd_module,
0, N_("Load a multiboot module."));
#endif
my_mod = mod;
}

View File

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

View File

@ -66,14 +66,12 @@ grub_crypto_spec_free (void)
/* Read the file crypto.lst for auto-loading. */
void
read_crypto_list (void)
read_crypto_list (const char *prefix)
{
const char *prefix;
char *filename;
grub_file_t file;
char *buf = NULL;
prefix = grub_env_get ("prefix");
if (!prefix)
{
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. */
void
read_command_list (void)
read_command_list (const char *prefix)
{
const char *prefix;
prefix = grub_env_get ("prefix");
if (prefix)
{
char *filename;

View File

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

View File

@ -176,10 +176,17 @@ print_message (int nested, int edit, struct grub_term_output *term)
if (edit)
{
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 \
supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \
command-line or ESC to return menu."), STANDARD_MARGIN, STANDARD_MARGIN,
term);
command-line or ESC to discard edits and return to the GRUB menu."),
STANDARD_MARGIN, STANDARD_MARGIN, term);
#endif
}
else
{

View File

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

View File

@ -26,13 +26,24 @@
#include <grub/lib/arg.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
grub_script_execute_cmd (struct grub_script_cmd *cmd)
{
int ret;
char errnobuf[ERRNO_DIGITS_MAX + 1];
if (cmd == 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))
@ -260,13 +271,14 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
grub_err_t
grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
{
int ret = 0;
struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd;
/* Loop over every command and execute it. */
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. */
@ -317,6 +329,26 @@ grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
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. */
grub_err_t
grub_script_execute_menuentry (struct grub_script_cmd *cmd)

View File

@ -74,8 +74,10 @@
%token <arg> GRUB_PARSER_TOKEN_WORD "word"
%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
%lex-param { struct grub_parser_param *state };
@ -171,9 +173,11 @@ grubcmd: word arguments0
;
/* A single command. */
command: grubcmd { $$ = $1; }
| ifcmd { $$ = $1; }
| forcmd { $$ = $1; }
command: grubcmd { $$ = $1; }
| ifcmd { $$ = $1; }
| forcmd { $$ = $1; }
| whilecmd { $$ = $1; }
| untilcmd { $$ = $1; }
;
/* A list of commands. */
@ -224,18 +228,28 @@ menuentry: "menuentry"
}
;
if: "if" { grub_script_lexer_ref (state->lexerstate); }
ifcmd: "if"
{
grub_script_lexer_ref (state->lexerstate);
}
ifclause "fi"
{
$$ = $3;
grub_script_lexer_deref (state->lexerstate);
}
;
ifcmd: if commands1 delimiters1 "then" commands1 delimiters1 "fi"
{
$$ = grub_script_create_cmdif (state, $2, $5, 0);
grub_script_lexer_deref (state->lexerstate);
}
| if commands1 delimiters1 "then" commands1 delimiters1 "else" commands1 delimiters1 "fi"
{
$$ = grub_script_create_cmdif (state, $2, $5, $8);
grub_script_lexer_deref (state->lexerstate);
}
ifclause: commands1 delimiters1 "then" commands1 delimiters1
{
$$ = grub_script_create_cmdif (state, $1, $4, 0);
}
| 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);
}
;
forcmd: "for" "name"
@ -248,3 +262,25 @@ forcmd: "for" "name"
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;
}
/* 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
argument that is parsed to generate a string that can be used as
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;
break;
case 0x01:
read_key = 16;
read_key = GRUB_TERM_UP;
break;
case 0x02:
read_key = 14;
read_key = GRUB_TERM_DOWN;
break;
case 0x03:
read_key = 6;
read_key = GRUB_TERM_RIGHT;
break;
case 0x04:
read_key = 2;
read_key = GRUB_TERM_LEFT;
break;
case 0x05:
read_key = 1;
read_key = GRUB_TERM_HOME;
break;
case 0x06:
read_key = 5;
read_key = GRUB_TERM_END;
break;
case 0x07:
break;
case 0x08:
read_key = 4;
read_key = GRUB_TERM_DC;
break;
case 0x09:
break;
@ -194,6 +194,9 @@ grub_console_checkkey (void)
case 0x0d:
read_key = 5;
break;
case 0x0e:
read_key = 3;
break;
case 0x17:
read_key = '\e';
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}
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

View File

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

View File

@ -140,60 +140,73 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
fi
case x${GRUB_TERMINAL_OUTPUT} in
x | xgfxterm)
# If this platform supports gfxterm, try to use it.
if test -e ${grub_prefix}/gfxterm.mod ; then
# FIXME: this should do something smarter than just loading first
# video backend.
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then
GRUB_TERMINAL_OUTPUT=gfxterm
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
fi
fi
;;
xconsole | xserial | xofconsole) ;;
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
esac
termoutdefault=0
if [ "x${GRUB_TERMINAL_OUTPUT}" == x ]; then
GRUB_TERMINAL_OUTPUT=gfxterm;
termoutdefault=1;
fi
# check for terminals that require fonts
case ${GRUB_TERMINAL_OUTPUT} in
gfxterm)
if [ -n "$GRUB_FONT" ] ; then
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
GRUB_FONT_PATH=${GRUB_FONT}
else
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
exit 1
for x in ${GRUB_TERMINAL_OUTPUT}; do
if [ x${x} == xgfxterm ]; then
# If this platform supports gfxterm, try to use it.
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
# video backend.
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
fi
if [ -n "$GRUB_FONT" ] ; then
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
GRUB_FONT_PATH=${GRUB_FONT}
else
echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
exit 1
fi
else
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
for basename in unicode unifont ascii; do
path="${dir}/${basename}.pf2"
if is_path_readable_by_grub ${path} > /dev/null ; then
GRUB_FONT_PATH=${path}
else
continue
fi
if [ "${basename}" = "ascii" ] ; then
# make sure all our children behave in conformance with ascii..
export LANG=C
fi
break 2
done
done
fi
if [ -z "${GRUB_FONT_PATH}" ] ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "No font for gfxterm found." >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
fi
else
for dir in ${pkgdatadir} /boot/grub /usr/share/grub ; do
for basename in unicode unifont ascii; do
path="${dir}/${basename}.pf2"
if is_path_readable_by_grub ${path} > /dev/null ; then
GRUB_FONT_PATH=${path}
else
continue
fi
if [ "${basename}" = "ascii" ] ; then
# make sure all our children behave in conformance with ascii..
export LANG=C
fi
break 2
done
done
fi
if [ -z "${GRUB_FONT_PATH}" ] ; then
# fallback to the native terminal for this platform
unset GRUB_TERMINAL_OUTPUT
fi
;;
*)
# make sure all our children behave in conformance with ascii..
export LANG=C
esac
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..
export LANG=C;;
*) 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
# override them.
@ -220,6 +233,7 @@ export GRUB_DEFAULT \
GRUB_DISABLE_LINUX_UUID \
GRUB_DISABLE_LINUX_RECOVERY \
GRUB_GFXMODE \
GRUB_BACKGROUND \
GRUB_THEME \
GRUB_GFXPAYLOAD_LINUX \
GRUB_DISABLE_OS_PROBER \

View File

@ -156,7 +156,7 @@ EOF
echo "insmod $i"
done ; \
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
rm -rf ${memdisk_dir}
@ -187,7 +187,7 @@ if test -e "${pc_dir}" ; then
echo "source /boot/grub/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}"
fi

View File

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

View File

@ -59,19 +59,92 @@ function savedefault {
}
EOF
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
serial:* | *:serial)
serial=0;
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
echo "Serial terminal not available on this platform." >&2 ; exit 1
echo "Serial terminal not available on this platform." >&2 ; exit 1
fi
if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
GRUB_SERIAL_COMMAND=serial
grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
GRUB_SERIAL_COMMAND=serial
fi
echo "${GRUB_SERIAL_COMMAND}"
;;
esac
fi
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
x)
@ -89,35 +162,6 @@ EOF
esac
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)
# Just use the native terminal
;;

View File

@ -27,7 +27,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU
else
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
at_least_one=false

View File

@ -30,7 +30,7 @@ CLASS="--class os"
case "${GRUB_DISTRIBUTOR}" in
Debian)
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"

View File

@ -31,7 +31,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
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
# 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);
if (drive < 0)
{
grub_error (GRUB_ERR_BAD_DEVICE,
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"no mapping exists for `%s'", os_dev);
return 0;
}

View File

@ -35,6 +35,7 @@
#endif
#include <grub/kernel.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/cache.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");
}
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. */
void
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
grub_register_exported_symbols (void)
{
}
#endif
void
grub_exit (void)
@ -374,7 +327,7 @@ grub_millisleep (grub_uint32_t ms)
#endif
#if !(defined (__i386__) || defined (__x86_64__))
#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES
void
grub_arch_sync_caches (void *address __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;
}