From 10523df4781740c499113bed7f1827f627f82cbf Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Sat, 23 Jan 2010 11:19:26 +0530 Subject: [PATCH 01/27] while and until loops support --- include/grub/script_sh.h | 22 ++++++++++++++++++++++ script/execute.c | 20 ++++++++++++++++++++ script/parser.y | 35 ++++++++++++++++++++++++++++++----- script/script.c | 22 ++++++++++++++++++++++ util/grub-script-check.c | 6 ++++++ 5 files changed, 100 insertions(+), 5 deletions(-) diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index 4436afbf1..207b5fcbc 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -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. */ diff --git a/script/execute.c b/script/execute.c index aa6975fdd..b905de46f 100644 --- a/script/execute.c +++ b/script/execute.c @@ -308,6 +308,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) || (!cmdwhile->until && 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) diff --git a/script/parser.y b/script/parser.y index 26a6e3735..4d22ae400 100644 --- a/script/parser.y +++ b/script/parser.y @@ -76,8 +76,9 @@ %token GRUB_PARSER_TOKEN_WORD "word" %type word argument arguments0 arguments1 -%type script_init script grubcmd ifcmd forcmd command -%type commands1 menuentry statement +%type script_init script +%type grubcmd ifcmd forcmd whilecmd untilcmd +%type command commands1 menuentry statement %pure-parser %lex-param { struct grub_parser_param *state }; @@ -173,9 +174,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. */ @@ -250,3 +253,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); + } +; diff --git a/script/script.c b/script/script.c index 9142a8245..4c87d9491 100644 --- a/script/script.c +++ b/script/script.c @@ -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. diff --git a/util/grub-script-check.c b/util/grub-script-check.c index 3b3f5bd47..eb11988e3 100644 --- a/util/grub-script-check.c +++ b/util/grub-script-check.c @@ -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))) { From c1273662b92bb745d7b1dbdcc247fea7b918e25e Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 26 Jan 2010 09:39:51 +0530 Subject: [PATCH 02/27] added change log file --- ChangeLog.while-until-loops | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ChangeLog.while-until-loops diff --git a/ChangeLog.while-until-loops b/ChangeLog.while-until-loops new file mode 100644 index 000000000..33a3a839d --- /dev/null +++ b/ChangeLog.while-until-loops @@ -0,0 +1,15 @@ +2010-01-26 BVK Chaitanya + + 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. + From 3342306cec42aed344501adaeb13571a3dc4c1ae Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 26 Jan 2010 12:32:24 +0530 Subject: [PATCH 03/27] several fixes in return value handling --- ChangeLog.while-until-loops | 5 +++++ commands/test.c | 3 +-- commands/true.c | 2 +- conf/tests.rmk | 4 ++++ script/execute.c | 28 ++++++++++++++++------------ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/ChangeLog.while-until-loops b/ChangeLog.while-until-loops index 33a3a839d..ac54b8cd9 100644 --- a/ChangeLog.while-until-loops +++ b/ChangeLog.while-until-loops @@ -13,3 +13,8 @@ * util/grub-script-check.c (grub_script_execute_cmdwhile): New function. + * tests/grub_script_while1.in: New testcase. + * conf/tests.rmk: New testcase make rule. + + * commands/true.c (grub_cmd_false): Remove printing error message. + * commands/test.c (grub_cmd_test): Likewise. diff --git a/commands/test.c b/commands/test.c index 6995165cf..64ad69522 100644 --- a/commands/test.c +++ b/commands/test.c @@ -412,8 +412,7 @@ grub_cmd_test (grub_command_t cmd __attribute__ ((unused)), if (argc >= 1 && grub_strcmp (args[argc - 1], "]") == 0) argc--; - return test_parse (args, &argn, argc) ? GRUB_ERR_NONE - : grub_error (GRUB_ERR_TEST_FAILURE, "false"); + return test_parse (args, &argn, argc) ? 0 : 1; } static grub_command_t cmd_1, cmd_2; diff --git a/commands/true.c b/commands/true.c index aa8125853..20403c588 100644 --- a/commands/true.c +++ b/commands/true.c @@ -34,7 +34,7 @@ grub_cmd_false (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused))) { - return grub_error (GRUB_ERR_TEST_FAILURE, "false"); + return 1; } static grub_command_t cmd_true, cmd_false; diff --git a/conf/tests.rmk b/conf/tests.rmk index 92f14797d..442beb0d3 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -53,6 +53,9 @@ 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 + # List of tests to execute on "make check" # SCRIPTED_TESTS = example_scripted_test # SCRIPTED_TESTS += example_grub_script_test @@ -63,6 +66,7 @@ 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 # dependencies between tests and testing-tools $(SCRIPTED_TESTS): grub-shell grub-shell-tester diff --git a/script/execute.c b/script/execute.c index b905de46f..37686627d 100644 --- a/script/execute.c +++ b/script/execute.c @@ -26,13 +26,24 @@ #include #include +/* 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; } /* Expand arguments in ARGLIST into multiple arguments. */ @@ -188,7 +199,6 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_err_t ret = 0; int argcount = 0; grub_script_function_t func = 0; - char errnobuf[18]; char *cmdname; /* Lookup the command. */ @@ -222,11 +232,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_env_set (assign, eq); } grub_free (assign); - - grub_snprintf (errnobuf, sizeof (errnobuf), "%d", grub_errno); - grub_env_set ("?", errnobuf); - - return 0; + return grub_errno; } } @@ -241,9 +247,6 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_free (args[i]); grub_free (args); - grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret); - grub_env_set ("?", errnobuf); - return ret; } @@ -251,13 +254,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. */ From 2aa1646307cc44f4ae31d340d24f70fdc226b0fa Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 26 Jan 2010 12:32:47 +0530 Subject: [PATCH 04/27] new testcase for while and until loops --- tests/grub_script_while1.in | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/grub_script_while1.in diff --git a/tests/grub_script_while1.in b/tests/grub_script_while1.in new file mode 100644 index 000000000..554247f76 --- /dev/null +++ b/tests/grub_script_while1.in @@ -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 From b5c5144ab11c3b9168949abe2c52a069ba58e862 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 26 Jan 2010 14:33:23 +0530 Subject: [PATCH 05/27] made while/until loop condition check more readable --- script/execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/execute.c b/script/execute.c index 37686627d..cdfe47337 100644 --- a/script/execute.c +++ b/script/execute.c @@ -323,7 +323,7 @@ grub_script_execute_cmdwhile (struct grub_script_cmd *cmd) result = 0; do { cond = grub_script_execute_cmd (cmdwhile->cond); - if ((cmdwhile->until && !cond) || (!cmdwhile->until && cond)) + if (cmdwhile->until ? !cond : cond) break; result = grub_script_execute_cmd (cmdwhile->list); From f38873b80b1c55d0f8020500adf3351589294365 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 15:17:26 +0100 Subject: [PATCH 06/27] Build system support for grub-emu modules --- Makefile.in | 8 +++++++- conf/any-emu.rmk | 46 ++++++++++++++++++++++++++++++++-------------- configure.ac | 16 ++++++++++++++++ genmk.rb | 34 ++++++++++++++++++++-------------- genmoddep.awk | 4 ++-- include/grub/dl.h | 4 ++-- include/grub/sdl.h | 24 ++++++++++++++++++++++++ util/grub-emu.c | 9 +++++++++ util/misc.c | 2 ++ 9 files changed, 114 insertions(+), 33 deletions(-) create mode 100644 include/grub/sdl.h diff --git a/Makefile.in b/Makefile.in index 820bfa946..8eaf17a7a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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@ @@ -175,10 +176,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 diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 77092454b..009f1079b 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -13,30 +13,33 @@ pkglib_PROGRAMS = kernel.img kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ kern/err.c kern/list.c kern/handler.c \ kern/command.c kern/corecmd.c kern/file.c \ - kern/fs.c commands/boot.c kern/main.c kern/misc.c kern/parser.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 \ \ - grub_emu_init.c -kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) + gnulib/progname.c util/hostfs.c +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 \ + list.h handler.h command.h i18n.h env_private.h +kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wno-undef kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes -TARGET_NO_DYNAMIC_MODULES = yes -# progname.c always has warnings. Compile it separately. -pkglib_MODULES += progname.mod -progname_mod_SOURCES = gnulib/progname.c -progname_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error -progname_mod_LDFLAGS = $(COMMON_LDFLAGS) +ifneq ($(TARGET_NO_MODULES), yes) +kernel_img_SOURCES += symlist.c +else +kernel_img_SOURCES += grub_emu_init.c +endif -# For hostfs.mod. -pkglib_MODULES += hostfs.mod -hostfs_mod_SOURCES = util/hostfs.c -hostfs_mod_CFLAGS = $(COMMON_CFLAGS) -hostfs_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For boot.mod. +pkglib_MODULES += boot.mod +boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c +boot_mod_CFLAGS = $(COMMON_CFLAGS) +boot_mod_LDFLAGS = $(COMMON_LDFLAGS) # For host.mod. pkglib_MODULES += host.mod @@ -77,8 +80,10 @@ endif ifeq ($(enable_grub_emu_sdl), yes) pkglib_MODULES += sdl.mod sdl_mod_SOURCES = util/sdl.c +sdl_mod_CFLAGS = $(COMMON_CFLAGS) sdl_mod_LDFLAGS = $(COMMON_LDFLAGS) grub_emu_LDFLAGS += $(LIBSDL) +kernel_img_HEADERS += sdl.h endif ifeq ($(enable_grub_emu_pci), yes) @@ -90,6 +95,14 @@ endif include $(srcdir)/conf/common.mk +MOSTLYCLEANFILES += symlist.c kernel_syms.lst +DEFSYMFILES += kernel_syms.lst +symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh + /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + +kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh + /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES) rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@ DISTCLEANFILES += grub_emu_init.h @@ -99,7 +112,12 @@ grub_emu_init.c: genemuinit.sh $(pkglib_MODULES) 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 diff --git a/configure.ac b/configure.ac index f3fcd8c48..7c8bdb62c 100644 --- a/configure.ac +++ b/configure.ac @@ -548,6 +548,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.] @@ -566,6 +570,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 @@ -733,6 +744,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 diff --git a/genmk.rb b/genmk.rb index 7df15043a..5cecc5d16 100644 --- a/genmk.rb +++ b/genmk.rb @@ -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()} diff --git a/genmoddep.awk b/genmoddep.awk index 19ac80c71..9f751389b 100644 --- a/genmoddep.awk +++ b/genmoddep.awk @@ -32,13 +32,13 @@ FNR == 1 { else if ($1 != "__gnu_local_gp") { printf "%s in %s is not defined\n", $1, module >"/dev/stderr"; error++; - exit; +# exit; } } # Output the result. END { - if (error == 1) + if (error != 0) exit 1; for (mod in modtab) { diff --git a/include/grub/dl.h b/include/grub/dl.h index 17e03f400..cfb7c2f99 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -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 diff --git a/include/grub/sdl.h b/include/grub/sdl.h new file mode 100644 index 000000000..e4efdc9b1 --- /dev/null +++ b/include/grub/sdl.h @@ -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 . + */ + +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); diff --git a/util/grub-emu.c b/util/grub-emu.c index 08ae19836..3ad6e406c 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -146,6 +146,9 @@ usage (int status) } +void grub_hostfs_init (void); +void grub_hostfs_fini (void); + int main (int argc, char *argv[]) { @@ -204,11 +207,14 @@ main (int argc, char *argv[]) signal (SIGINT, SIG_IGN); grub_console_init (); + grub_hostfs_init (); /* 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) @@ -235,7 +241,10 @@ main (int argc, char *argv[]) if (setjmp (main_env) == 0) grub_main (); +#if GRUB_NO_MODULES grub_fini_all (); +#endif + grub_hostfs_fini (); grub_machine_fini (); diff --git a/util/misc.c b/util/misc.c index 7381c8fdd..16a8b234b 100644 --- a/util/misc.c +++ b/util/misc.c @@ -319,10 +319,12 @@ grub_mm_init_region (void *addr __attribute__ ((unused)), { } +#if GRUB_NO_MODULES void grub_register_exported_symbols (void) { } +#endif void grub_exit (void) From 3dca5319c6a1f6bee442e29e82866aefd0da6056 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 16:13:59 +0100 Subject: [PATCH 07/27] module support in grub-emu --- conf/any-emu.rmk | 19 +++++++++--------- conf/common.rmk | 10 +++++----- util/grub-emu.c | 13 +++++++++--- util/hostdisk.c | 4 ++-- util/misc.c | 52 +----------------------------------------------- 5 files changed, 27 insertions(+), 71 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 009f1079b..ad71f06bd 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -7,7 +7,6 @@ COMMON_CFLAGS += script/lexer.c_DEPENDENCIES = grub_script.tab.h #sbin_UTILITIES += grub-emu -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 \ @@ -18,9 +17,9 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.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/hostdisk.c util/getroot.c util/mm.c \ \ - gnulib/progname.c util/hostfs.c + gnulib/progname.c util/hostfs.c disk/host.c 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 \ @@ -30,9 +29,15 @@ kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes ifneq ($(TARGET_NO_MODULES), yes) -kernel_img_SOURCES += symlist.c +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 +grub_emu_init.c_DEPENDENCIES = grub_emu_init.h endif # For boot.mod. @@ -41,12 +46,6 @@ boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c boot_mod_CFLAGS = $(COMMON_CFLAGS) boot_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For host.mod. -pkglib_MODULES += host.mod -host_mod_SOURCES = disk/host.c -host_mod_CFLAGS = $(COMMON_CFLAGS) -host_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For reboot.mod. pkglib_MODULES += reboot.mod reboot_mod_SOURCES = commands/reboot.c diff --git a/conf/common.rmk b/conf/common.rmk index 6cce36395..a77512643 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -22,7 +22,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 \ \ @@ -57,7 +57,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 \ @@ -95,7 +95,7 @@ grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c 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 @@ -159,7 +159,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 @@ -760,7 +760,7 @@ password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS) password_pbkdf2_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 diff --git a/util/grub-emu.c b/util/grub-emu.c index 3ad6e406c..fadb79385 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -38,8 +38,6 @@ #include #include -#include - #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) @@ -148,6 +148,8 @@ usage (int status) void grub_hostfs_init (void); void grub_hostfs_fini (void); +void grub_host_init (void); +void grub_host_fini (void); int main (int argc, char *argv[]) @@ -207,6 +209,7 @@ main (int argc, char *argv[]) signal (SIGINT, SIG_IGN); grub_console_init (); + grub_host_init (); grub_hostfs_init (); /* XXX: This is a bit unportable. */ @@ -232,7 +235,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); @@ -245,6 +251,7 @@ main (int argc, char *argv[]) grub_fini_all (); #endif grub_hostfs_fini (); + grub_host_fini (); grub_machine_fini (); diff --git a/util/hostdisk.c b/util/hostdisk.c index 98d3d53ae..0b22e0ad3 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -168,7 +168,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) drive = find_grub_drive (name); if (drive < 0) - return grub_error (GRUB_ERR_BAD_DEVICE, + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no mapping exists for `%s'", name); disk->has_partitions = 1; @@ -949,7 +949,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; } diff --git a/util/misc.c b/util/misc.c index 16a8b234b..6182f138e 100644 --- a/util/misc.c +++ b/util/misc.c @@ -262,56 +262,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)), @@ -376,7 +326,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))) From 7eed9925e2b2a0bf59a26b4947ee0cd603b4d885 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 18:10:36 +0100 Subject: [PATCH 08/27] missing files --- ChangeLog.emu-modload | 18 +++++++++ util/mm.c | 85 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 ChangeLog.emu-modload create mode 100644 util/mm.c diff --git a/ChangeLog.emu-modload b/ChangeLog.emu-modload new file mode 100644 index 000000000..dd0ea6bf0 --- /dev/null +++ b/ChangeLog.emu-modload @@ -0,0 +1,18 @@ +2010-02-07 Vladimir Serbinenko + + 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. + * configure.ac (grub-emu-modules): New option. + * genmk.rb: Handle multiple source lists. + * genmoddep.awk: Output all undefined symbols. + * include/grub/sdl.h: New file. + * 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. diff --git a/util/mm.c b/util/mm.c new file mode 100644 index 000000000..0e9e9f3a8 --- /dev/null +++ b/util/mm.c @@ -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 . + */ + +#include +#include +#include +#include +#include + +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; +} From 0f3a3e3ece624cc267900771798069cc8e9339a5 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Sun, 21 Mar 2010 10:27:21 +0530 Subject: [PATCH 09/27] added elif patch from Deepak Vankadaru --- conf/tests.rmk | 4 ++++ script/parser.y | 34 ++++++++++++++++++++++------------ tests/grub_script_if.in | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 tests/grub_script_if.in diff --git a/conf/tests.rmk b/conf/tests.rmk index 92f14797d..427720e82 100644 --- a/conf/tests.rmk +++ b/conf/tests.rmk @@ -53,6 +53,9 @@ 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_if +grub_script_if_SOURCES = tests/grub_script_if.in + # List of tests to execute on "make check" # SCRIPTED_TESTS = example_scripted_test # SCRIPTED_TESTS += example_grub_script_test @@ -63,6 +66,7 @@ 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_if # dependencies between tests and testing-tools $(SCRIPTED_TESTS): grub-shell grub-shell-tester diff --git a/script/parser.y b/script/parser.y index caba0f433..4ed58b4f2 100644 --- a/script/parser.y +++ b/script/parser.y @@ -74,7 +74,7 @@ %token GRUB_PARSER_TOKEN_WORD "word" %type word argument arguments0 arguments1 -%type script_init script grubcmd ifcmd forcmd command +%type script_init script grubcmd ifclause ifcmd forcmd command %type commands1 menuentry statement %pure-parser @@ -224,18 +224,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" diff --git a/tests/grub_script_if.in b/tests/grub_script_if.in new file mode 100644 index 000000000..fb17eaf70 --- /dev/null +++ b/tests/grub_script_if.in @@ -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 From d5631db0f2763746d35bd6ca895610b133f0841d Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 2 Apr 2010 21:12:20 +0200 Subject: [PATCH 10/27] grub-mkconfig multiple terminal support. * util/grub-mkconfig.in: Handle multiple terminals correctly. * util/grub.d/00_header.in: Likewise. --- ChangeLog.mtcfg | 6 ++ util/grub-mkconfig.in | 115 ++++++++++++++++++++++----------------- util/grub.d/00_header.in | 76 ++++++++++++++------------ 3 files changed, 110 insertions(+), 87 deletions(-) create mode 100644 ChangeLog.mtcfg diff --git a/ChangeLog.mtcfg b/ChangeLog.mtcfg new file mode 100644 index 000000000..2f246c26a --- /dev/null +++ b/ChangeLog.mtcfg @@ -0,0 +1,6 @@ +2010-04-02 Vladimir Serbinenko + + grub-mkconfig multiple terminal support. + + * util/grub-mkconfig.in: Handle multiple terminals correctly. + * util/grub.d/00_header.in: Likewise. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index daa110be7..94cd2e199 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -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. diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index c86f7b867..81f7a213a 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -59,19 +59,52 @@ 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 + set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME` +EOF + fi + cat << EOF +fi +EOF +fi case x${GRUB_TERMINAL_INPUT} in x) @@ -89,35 +122,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 ;; From f9d9068aa720aea0fd25bf4f7033b430d965b926 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 6 Apr 2010 12:21:11 +0530 Subject: [PATCH 11/27] removed -serial stdio option from qemu cmdline --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 2b9131547..a41a6f6f4 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -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 From fa09c82e6e0e3aa36c80d8c7b98f80f0da2787ce Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 6 Apr 2010 12:31:44 +0530 Subject: [PATCH 12/27] updated changelog --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5fb147455..10e9a774d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-06 BVK Chaitanya + + Fix unit testing framework for qemu 0.12. + + * tests/util/grub-shell.in: Remove -serial stdio option. + 2010-04-06 Vladimir Serbinenko POSIX header file wrappers. From df60998c64afaf0025f59365c172109c6ecab774 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 8 Apr 2010 10:54:44 +0100 Subject: [PATCH 13/27] * 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. --- ChangeLog | 8 ++++++++ util/grub.d/10_hurd.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7441af4b3..83825a6c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-04-08 Colin Watson + + * 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 Fix unit testing framework for Qemu 0.12. diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index fbb4eb752..5dbb11f22 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -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 diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index dc87d6162..43651c82b 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -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" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 2c60bc681..8dc0df5d9 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -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 From b7841cebaafade6c545b7bef66ae2a0a1c7be91f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 16:18:25 +0200 Subject: [PATCH 14/27] 2010-04-09 Vladimir Serbinenko * Makefile.in: Specify files explicitly instead of using $< and $@ since we use cd $(srcdir). --- ChangeLog | 5 +++++ Makefile.in | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83825a6c3..ee19f60d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 Vladimir Serbinenko + + * Makefile.in: Specify files explicitly instead of using $< and $@ since + we use cd $(srcdir). + 2010-04-08 Colin Watson * util/grub.d/10_linux.in: Only use the first word of diff --git a/Makefile.in b/Makefile.in index ed460e4cf..d5eda4be3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -530,8 +530,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 $@ $^ From d64795c0eb35035727f5186535f4b81df0542d99 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 16:56:07 +0200 Subject: [PATCH 15/27] Load fonts and modules for gfxmenu in grub-mkconfig. Idea by: Mario Vasquez * util/grub.d/00_header.in: Load pf2 and image modules. --- ChangeLog | 7 +++++++ util/grub.d/00_header.in | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ChangeLog b/ChangeLog index cbc8ff331..0b77ea6a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-04-09 Vladimir Serbinenko + + Load fonts and modules for gfxmenu in grub-mkconfig. + Idea by: Mario Vasquez + + * util/grub.d/00_header.in: Load pf2 and image modules. + 2010-04-09 Vladimir Serbinenko grub-mkconfig multiple terminal support. diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 81f7a213a..f99010d6d 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -98,6 +98,32 @@ EOF 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" ]; 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 fi From d7c43ba1c0e8c2449377c1b3aa43238f985f83da Mon Sep 17 00:00:00 2001 From: Mario Vazquez Date: Fri, 9 Apr 2010 17:37:38 +0200 Subject: [PATCH 16/27] GRUB_BACKGROUND support. * util/grub-mkconfig.in: Export GRUB_BACKGROUND. * util/grub.d/00_header.in: Parse GRUB_BACKGROUND. --- ChangeLog | 9 ++++++++- util/grub-mkconfig.in | 1 + util/grub.d/00_header.in | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0b77ea6a4..1fdd2a21b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,14 @@ +2010-04-09 Mario Vazquez + + GRUB_BACKGROUND support. + + * util/grub-mkconfig.in: Export GRUB_BACKGROUND. + * util/grub.d/00_header.in: Parse GRUB_BACKGROUND. + 2010-04-09 Vladimir Serbinenko Load fonts and modules for gfxmenu in grub-mkconfig. - Idea by: Mario Vasquez + Idea by: Mario Vazquez * util/grub.d/00_header.in: Load pf2 and image modules. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 94cd2e199..b98bbc993 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -233,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 \ diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index f99010d6d..beb9653da 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -125,6 +125,20 @@ EOF 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 From e215d8e02a47435a54f5c014c2ee99b59153d601 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 17:44:03 +0200 Subject: [PATCH 17/27] * util/grub.d/00_header.in: Add few missing quotes. Recognise *.jpeg as *.jpg. --- ChangeLog | 5 +++++ util/grub.d/00_header.in | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fdd2a21b..1db00bc4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 Vladimir Serbinenko + + * util/grub.d/00_header.in: Add few missing quotes. Recognise *.jpeg + as *.jpg. + 2010-04-09 Mario Vazquez GRUB_BACKGROUND support. diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index beb9653da..d181fdffc 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -84,22 +84,22 @@ fi if [ "x$gfxterm" = x1 ]; then # Make the font accessible - prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}` + 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 +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 + 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/^/ /" + prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"` | sed -e "s/^/ /" cat << EOF insmod gfxmenu EOF - themedir="`dirname $GRUB_THEME`" + themedir="`dirname "$GRUB_THEME"`" for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do if [ -f "$x" ]; then cat << EOF @@ -107,7 +107,7 @@ EOF EOF fi done - if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ]; then + if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then cat << EOF insmod jpeg EOF From 1118c32ec7cde35f2d6da9f4fb6e41c8aadf6186 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 19:38:23 +0200 Subject: [PATCH 18/27] * font/font.c: Indented. --- ChangeLog | 4 + font/font.c | 462 ++++++++++++++++++++++++++-------------------------- 2 files changed, 233 insertions(+), 233 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e23de038..d6cdfdbe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-09 Vladimir Serbinenko + + * font/font.c: Indented. + 2010-04-09 BVK Chaitanya Elif support to GRUB script (by Deepak Vankadaru). diff --git a/font/font.c b/font/font.c index 1b3dc6387..9a89cadc5 100644 --- a/font/font.c +++ b/font/font.c @@ -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 = ""; - 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, §ion) != 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 (§ion); - if (!font->name) - goto fail; - } + sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) + { + font->name = read_section_as_string (§ion); + 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 (§ion, &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 (§ion, &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 (§ion); - 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 (§ion); + 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 (§ion, &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 (§ion, &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 (§ion, &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 (§ion, &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 (§ion, &font->ascent) != 0) - goto fail; - } + FONT_FORMAT_SECTION_NAMES_ASCENT, + sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1) + == 0) + { + if (read_section_as_short (§ion, &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 (§ion, &font->descent) != 0) - goto fail; - } + sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1) + == 0) + { + if (read_section_as_short (§ion, &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; } - From 477797112671d69767fee13f6e6ddb3b08e2ccff Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 20:40:14 +0200 Subject: [PATCH 19/27] * util/grub-mkrescue.in: Fix incorrect path in coreboot part. Reported by: Thomas Schmitt. Add -no-emul-boot to grub-mkisofs parameters. --- ChangeLog | 6 ++++++ util/grub-mkrescue.in | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6cdfdbe8..a2a33b2ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-09 Vladimir Serbinenko + + * 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 * font/font.c: Indented. diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in index db29b0899..aafdfb059 100644 --- a/util/grub-mkrescue.in +++ b/util/grub-mkrescue.in @@ -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 From 027de555e271b3954fbd749c293ec807cf720405 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 21:07:24 +0200 Subject: [PATCH 20/27] * 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. --- ChangeLog | 11 +++++++++++ include/grub/normal.h | 8 ++++---- normal/autofs.c | 5 +---- normal/crypto.c | 4 +--- normal/dyncmd.c | 5 +---- normal/main.c | 25 ++++++++++++++++--------- normal/term.c | 4 +--- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2a33b2ef..5f3251fcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-04-09 Vladimir Serbinenko + + * 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 * util/grub-mkrescue.in: Fix incorrect path in coreboot part. diff --git a/include/grub/normal.h b/include/grub/normal.h index fe45ddf71..35eedf5ae 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -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); diff --git a/normal/autofs.c b/normal/autofs.c index 11b3fc1be..e1d4c017c 100644 --- a/normal/autofs.c +++ b/normal/autofs.c @@ -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; diff --git a/normal/crypto.c b/normal/crypto.c index f051e2c4c..465c9f81d 100644 --- a/normal/crypto.c +++ b/normal/crypto.c @@ -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; diff --git a/normal/dyncmd.c b/normal/dyncmd.c index ca9a82289..a3cafa514 100644 --- a/normal/dyncmd.c +++ b/normal/dyncmd.c @@ -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; diff --git a/normal/main.c b/normal/main.c index 5a5467485..df92e622b 100644 --- a/normal/main.c +++ b/normal/main.c @@ -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) diff --git a/normal/term.c b/normal/term.c index 7bedd6799..688141dab 100644 --- a/normal/term.c +++ b/normal/term.c @@ -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; From 25f4e25287453d430890dbc87c0af5d8f8c38968 Mon Sep 17 00:00:00 2001 From: EFI Coder Date: Fri, 9 Apr 2010 21:16:17 +0200 Subject: [PATCH 21/27] * 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. --- ChangeLog | 6 ++++++ normal/menu_text.c | 11 +++++++++-- term/efi/console.c | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f3251fcb..e25639a42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-09 EFI Coder + + * 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 * normal/autofs.c (read_fs_list): New parameter 'prefix'. diff --git a/normal/menu_text.c b/normal/menu_text.c index b39f57512..bb0587502 100644 --- a/normal/menu_text.c +++ b/normal/menu_text.c @@ -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 { diff --git a/term/efi/console.c b/term/efi/console.c index 264770cae..c33cffdfe 100644 --- a/term/efi/console.c +++ b/term/efi/console.c @@ -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; From 5d7e744525cd67fca0c2c9508c9f8a480e1ab9a5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 21:35:52 +0200 Subject: [PATCH 22/27] * term/efi/console.c (grub_console_checkkey): Macroify key contants. --- ChangeLog | 4 ++++ term/efi/console.c | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e25639a42..820b595ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-09 Vladimir Serbinenko + + * term/efi/console.c (grub_console_checkkey): Macroify key contants. + 2010-04-09 EFI Coder * normal/menu_text.c (print_message): Clean up the message and show diff --git a/term/efi/console.c b/term/efi/console.c index c33cffdfe..664861398 100644 --- a/term/efi/console.c +++ b/term/efi/console.c @@ -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; From 47822096b5f7433456791d82128f2decb3282271 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 9 Apr 2010 23:04:00 +0200 Subject: [PATCH 23/27] * 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. --- ChangeLog | 7 +++++++ Makefile.in | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 820b595ed..3313a4911 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-04-09 Vladimir Serbinenko + + * 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 * term/efi/console.c (grub_console_checkkey): Macroify key contants. diff --git a/Makefile.in b/Makefile.in index d5eda4be3..57af32cfc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -136,7 +136,7 @@ enable_efiemu = @enable_efiemu@ ### General variables. -RMKFILES = $(wildcard conf/*.rmk) +RMKFILES = $(wildcard $(srcdir)/conf/*.rmk) MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES)) @@ -155,7 +155,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. @@ -427,6 +429,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: From b3d0fa12aff7cd1a42201fdbce9b67513aad7e36 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 10 Apr 2010 01:56:51 +0200 Subject: [PATCH 24/27] Fix usb support --- ChangeLog.emu-modload | 7 ++++++- conf/any-emu.rmk | 4 +++- include/grub/libusb.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 include/grub/libusb.h diff --git a/ChangeLog.emu-modload b/ChangeLog.emu-modload index dd0ea6bf0..c675021de 100644 --- a/ChangeLog.emu-modload +++ b/ChangeLog.emu-modload @@ -7,10 +7,15 @@ (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. - * genmoddep.awk: Output all undefined symbols. * 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. diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index e27a6978b..ddc6b0fd4 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -15,7 +15,7 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ \ gnulib/progname.c util/hostfs.c disk/host.c kernel_img_HEADERS += datetime.h -kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wno-undef +kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes @@ -46,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 = diff --git a/include/grub/libusb.h b/include/grub/libusb.h new file mode 100644 index 000000000..26548bccb --- /dev/null +++ b/include/grub/libusb.h @@ -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 . + */ + +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); From be124579b1e6e4b1e28a5caccb2caa0c326e9f22 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 10 Apr 2010 02:08:01 +0200 Subject: [PATCH 25/27] * lib/posix_wrap/locale.h: Add missing file. Reported by: Seth Goldberg. --- ChangeLog | 5 +++++ lib/posix_wrap/locale.h | 0 2 files changed, 5 insertions(+) create mode 100644 lib/posix_wrap/locale.h diff --git a/ChangeLog b/ChangeLog index bc2225d2e..813ea512f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-10 Vladimir Serbinenko + + * lib/posix_wrap/locale.h: Add missing file. + Reported by: Seth Goldberg. + 2010-04-10 Vladimir Serbinenko grub-emu module load support. diff --git a/lib/posix_wrap/locale.h b/lib/posix_wrap/locale.h new file mode 100644 index 000000000..e69de29bb From f2fd9d2b2bf4c958c3e5b505dd5450e341d2e50c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 10 Apr 2010 02:45:26 +0200 Subject: [PATCH 26/27] * include/grub/efi/memory.h (grub_machine_mmap_iterate): Remove EXPORT_FUNC. Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ include/grub/efi/memory.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 813ea512f..a8d498033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-10 Vladimir Serbinenko + + * include/grub/efi/memory.h (grub_machine_mmap_iterate): Remove + EXPORT_FUNC. + Reported by: Seth Goldberg. + 2010-04-10 Vladimir Serbinenko * lib/posix_wrap/locale.h: Add missing file. diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h index e5ea58d67..285be8359 100644 --- a/include/grub/efi/memory.h +++ b/include/grub/efi/memory.h @@ -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); From daea6abdeb9f58dfa0dfe072101d78b540f0a623 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 10 Apr 2010 03:05:03 +0200 Subject: [PATCH 27/27] * loader/multiboot.c (GRUB_MOD_INIT) [GRUB_USE_MULTIBOOT2]: Rename "module" to "module2". Reported by: Seth Goldberg. --- ChangeLog | 6 ++++++ loader/multiboot.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8d498033..d39c0b65a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-10 Vladimir Serbinenko + + * loader/multiboot.c (GRUB_MOD_INIT) [GRUB_USE_MULTIBOOT2]: + Rename "module" to "module2". + Reported by: Seth Goldberg. + 2010-04-10 Vladimir Serbinenko * include/grub/efi/memory.h (grub_machine_mmap_iterate): Remove diff --git a/loader/multiboot.c b/loader/multiboot.c index 1a22cd3a6..ce1e75dda 100644 --- a/loader/multiboot.c +++ b/loader/multiboot.c @@ -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; }