From 725396942e6929567f786234f0a95e7390d45f19 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Tue, 4 May 2010 09:47:48 +0530 Subject: [PATCH 1/9] replace --enable-grub-emu-modules with grub-emu-lite --- Makefile.in | 14 ++------- commands/parttool.c | 3 +- conf/any-emu.rmk | 38 ++++++++++++------------- configure.ac | 63 ++++++++++++++--------------------------- genmk.rb | 8 ------ include/grub/dl.h | 11 ++----- include/grub/emu/misc.h | 1 + include/grub/misc.h | 3 ++ kern/emu/main.c | 36 ++--------------------- kern/main.c | 2 ++ normal/main.c | 11 ++++--- util/misc.c | 4 +-- 12 files changed, 63 insertions(+), 131 deletions(-) diff --git a/Makefile.in b/Makefile.in index 822a08797..513deb516 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,6 @@ pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed ' # Internationalization library. LIBINTL = @LIBINTL@ -TARGET_NO_MODULES = @TARGET_NO_MODULES@ # Util library. LIBUTIL = @LIBUTIL@ @@ -187,17 +186,10 @@ 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 ($(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 cat $(DEFSYMFILES) /dev/null \ | $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \ @@ -298,7 +290,7 @@ build_env.mk: Makefile ) > $@ pkglib_BUILDDIR += config.h grub_script.tab.h -all-local: $(PROGRAMS) $(GRUB_EMU) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo) +all-local: $(PROGRAMS) $(GRUB_EMU) $(GRUB_EMU_LITE) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo) install: install-local @@ -319,7 +311,7 @@ install-local: all $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \ done $(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 - @list='$(bin_UTILITIES) $(GRUB_EMU)'; for file in $$list; do \ + @list='$(bin_UTILITIES) $(GRUB_EMU) $(GRUB_EMU_LITE)'; for file in $$list; do \ if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \ dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ $(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \ @@ -395,7 +387,7 @@ uninstall: dest="`echo $$file | sed 's,.*/,,'`"; \ rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \ done - @list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU)'; for file in $$list; do \ + @list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU) $(GRUB_EMU_LITE)'; for file in $$list; do \ dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \ rm -f $(DESTDIR)$(bindir)/$$dest; \ rm -f $(DESTDIR)$(mandir)/man1/$$dest.1; \ diff --git a/commands/parttool.c b/commands/parttool.c index 528cf43d7..f2a62e581 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } /* Load modules. */ -#if !GRUB_NO_MODULES + if (! grub_no_autoload) { const char *prefix; prefix = grub_env_get ("prefix"); @@ -233,7 +233,6 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), /* Ignore errors. */ grub_errno = GRUB_ERR_NONE; } -#endif if (argc == 1) return show_help (); diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index cb0ec873f..4e940181b 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -20,16 +20,13 @@ kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/g kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes -ifneq ($(TARGET_NO_MODULES), yes) -kernel_img_SOURCES += symlist.c kern/$(target_cpu)/dl.c -ifneq ($(target_cpu), i386) -ifneq ($(target_cpu), x86_64) -kernel_img_SOURCES += kern/$(target_cpu)/cache.S -endif -endif -else -kernel_img_SOURCES += grub_emu_init.c -endif +noinst_MODULES = emu-full.mod +emu_full_mod_SOURCES = kern/emu/full.c +emu_full_mod_CFLAGS = $(COMMON_CFLAGS) + +noinst_MODULES = emu-lite.mod +emu_lite_mod_SOURCES = kern/emu/lite.c kern/emu/cache.S symlist.c +emu_lite_mod_CFLAGS = $(COMMON_CFLAGS) # For halt.mod. pkglib_MODULES += halt.mod @@ -102,13 +99,16 @@ grub_emu_init.c: genemuinit.sh $(pkglib_MODULES) grub_emu_init.h rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@ DISTCLEANFILES += grub_emu_init.c -CLEANFILES += grub-emu -ifneq ($(TARGET_NO_MODULES), yes) -grub-emu: $(pkglib_PROGRAMS) - $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) -else -grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS) - $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) -endif -GRUB_EMU=grub-emu +grub_emu_init.o: grub_emu_init.c grub_emu_init.h + rm -f $@; $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"grub_init.c\" -c -o $@ $< +CLEANFILES += grub_emu_init.o +CLEANFILES += grub-emu-lite +grub-emu-lite: $(pkglib_PROGRAMS) emu-lite.mod + $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) +GRUB_EMU_LITE=grub-emu-lite + +CLEANFILES += grub-emu +grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS) emu-full.mod grub_emu_init.o + $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) +GRUB_EMU=grub-emu diff --git a/configure.ac b/configure.ac index 4e1dd41d8..9462b32a3 100644 --- a/configure.ac +++ b/configure.ac @@ -54,14 +54,12 @@ case "$target_cpu" in amd64) target_cpu=x86_64 ;; sparc) target_cpu=sparc64 ;; mipsel|mips64el) - target_cpu=mips; - TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1"; - CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1"; + target_cpu=mips; + cpu_CPPFLAGS="-DGRUB_CPU_MIPSEL=1"; ;; mips|mips64) - target_cpu=mips; - TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPS=1"; - CFLAGS="$CFLAGS -DGRUB_CPU_MIPS=1"; + target_cpu=mips; + cpu_CPPFLAGS="-DGRUB_CPU_MIPS=1"; ;; esac @@ -136,24 +134,27 @@ case "$host_os" in esac case "$platform" in - coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; - multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;; - efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;; - ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; - qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;; - pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;; - emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;; - yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; - qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + coreboot) machine_CPPFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; + multiboot) machine_CPPFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;; + efi) machine_CPPFLAGS="-DGRUB_MACHINE_EFI=1" ;; + ieee1275) machine_CPPFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; + qemu) machine_CPPFLAGS="-DGRUB_MACHINE_QEMU=1" ;; + pc) machine_CPPFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;; + emu) machine_CPPFLAGS="-DGRUB_MACHINE_EMU=1" ;; + yeeloong) machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + qemu-mips) machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; esac case "$target_cpu" in - mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;; - sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;; + i386) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_I386";; + x86_64) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_X86_64";; + powerpc) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_POWERPC";; + mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; # cpu_CPPFLAGS handled above + sparc64) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_SPARC64"; + machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;; esac -CFLAGS="$CFLAGS $machine_CFLAGS" -TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS" -TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS" +CPPFLAGS="$CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" +TARGET_CFLAGS="$TARGET_CFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" AC_SUBST(host_cpu) AC_SUBST(host_os) @@ -608,10 +609,6 @@ 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.] @@ -630,19 +627,6 @@ 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 "$TARGET_NO_MODULES" = yes ; then - # Do not convert modules, otherwise linkage may fail (Cygwin only). - # FIXME: Should be checked above before TARGET_OBJ2ELF is set first. - TARGET_OBJ2ELF= -fi - if test x"$enable_grub_emu_usb" = xno ; then grub_emu_usb_excuse="explicitly disabled" fi @@ -820,11 +804,6 @@ 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 e62dbd4f6..6b5ecd1d4 100644 --- a/genmk.rb +++ b/genmk.rb @@ -143,13 +143,6 @@ mostlyclean-module-#{@name}.#{@rule_count}: MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count} UNDSYMFILES += #{undsym} -ifeq ($(TARGET_NO_MODULES), yes) -#{@name}: #{pre_obj} $(TARGET_OBJ2ELF) - -rm -f $@ - $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} - if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi - if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi -else ifneq ($(TARGET_APPLE_CC),1) #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) -rm -f $@ @@ -164,7 +157,6 @@ else $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -ew2030 -ew2050 -nu -nd $@.bin $@ -rm -f $@.bin endif -endif #{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str} -rm -f $@ diff --git a/include/grub/dl.h b/include/grub/dl.h index cf5da7fd5..fde2e3163 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -91,22 +91,17 @@ 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_UTIL) || defined (GRUB_TARGET_NO_MODULES) -#define GRUB_NO_MODULES 1 -#else -#define GRUB_NO_MODULES 0 -#endif int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod)); grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name); -grub_err_t grub_dl_register_symbol (const char *name, void *addr, - grub_dl_t mod); +grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr, + grub_dl_t mod); 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) && ! GRUB_NO_MODULES +#if defined (_mips) && ! GRUB_MACHINE_EMU #define GRUB_LINKER_HAVE_INIT 1 void grub_arch_dl_init_linker (void); #endif diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index 146e64aa9..6d7fd8820 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -16,6 +16,7 @@ extern int verbosity; extern const char *program_name; +void grub_emu_init (void); void grub_init_all (void); void grub_fini_all (void); diff --git a/include/grub/misc.h b/include/grub/misc.h index 9bfc6974e..1ec8bbc5a 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -50,6 +50,9 @@ /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */ #define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n)) +/* Flag to control module autoloading in normal mode. */ +extern int EXPORT_VAR(grub_no_autoload); + void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c); diff --git a/kern/emu/main.c b/kern/emu/main.c index fb5dbf19f..8d6118c93 100644 --- a/kern/emu/main.c +++ b/kern/emu/main.c @@ -57,25 +57,6 @@ grub_arch_modules_addr (void) return 0; } -#if GRUB_NO_MODULES -grub_err_t -grub_arch_dl_check_header (void *ehdr) -{ - (void) ehdr; - - return GRUB_ERR_BAD_MODULE; -} - -grub_err_t -grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) -{ - (void) mod; - (void) ehdr; - - return GRUB_ERR_BAD_MODULE; -} -#endif - void grub_reboot (void) { @@ -154,10 +135,7 @@ void grub_hostfs_init (void); void grub_hostfs_fini (void); void grub_host_init (void); void grub_host_fini (void); -#if GRUB_NO_MODULES -void grub_init_all (void); -void grub_fini_all (void); -#endif +void grub_emu_init (void); int main (int argc, char *argv[]) @@ -216,6 +194,7 @@ main (int argc, char *argv[]) } signal (SIGINT, SIG_IGN); + grub_emu_init (); grub_console_init (); grub_host_init (); grub_hostfs_init (); @@ -223,9 +202,7 @@ main (int argc, char *argv[]) /* XXX: This is a bit unportable. */ grub_util_biosdisk_init (dev_map); -#if GRUB_NO_MODULES grub_init_all (); -#endif /* Make sure that there is a root device. */ if (! root_dev) @@ -255,9 +232,7 @@ main (int argc, char *argv[]) if (setjmp (main_env) == 0) grub_main (); -#if GRUB_NO_MODULES grub_fini_all (); -#endif grub_hostfs_fini (); grub_host_fini (); @@ -287,10 +262,3 @@ grub_millisleep (grub_uint32_t ms) } #endif - -#if GRUB_NO_MODULES -void -grub_register_exported_symbols (void) -{ -} -#endif diff --git a/kern/main.c b/kern/main.c index 1fdf4ab07..2541d3295 100644 --- a/kern/main.c +++ b/kern/main.c @@ -30,6 +30,8 @@ #include #include +int grub_no_autoload; + void grub_module_iterate (int (*hook) (struct grub_module_header *header)) { diff --git a/normal/main.c b/normal/main.c index 4ed17e82c..2d493b897 100644 --- a/normal/main.c +++ b/normal/main.c @@ -476,10 +476,13 @@ grub_normal_init_page (struct grub_term_output *term) static void read_lists (const char *val) { - read_command_list (val); - read_fs_list (val); - read_crypto_list (val); - read_terminal_list (val); + if (! grub_no_autoload) + { + read_command_list (val); + read_fs_list (val); + read_crypto_list (val); + read_terminal_list (val); + } } static char * diff --git a/util/misc.c b/util/misc.c index 1656d6b5b..caec60552 100644 --- a/util/misc.c +++ b/util/misc.c @@ -193,12 +193,10 @@ grub_mm_init_region (void *addr __attribute__ ((unused)), { } -#if GRUB_NO_MODULES void grub_register_exported_symbols (void) { } -#endif #ifdef __MINGW32__ @@ -222,7 +220,7 @@ grub_millisleep (grub_uint32_t ms) #endif -#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES +#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_MACHINE_EMU void grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) From 7ad9681655c4203a2a38e5a0b97ae7d654b1f609 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 6 May 2010 11:38:35 +0530 Subject: [PATCH 2/9] add missing files --- kern/emu/cache.S | 19 ++++++++++++++++++ kern/emu/dl.c | 19 ++++++++++++++++++ kern/emu/full.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ kern/emu/lite.c | 42 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 kern/emu/cache.S create mode 100644 kern/emu/dl.c create mode 100644 kern/emu/full.c create mode 100644 kern/emu/lite.c diff --git a/kern/emu/cache.S b/kern/emu/cache.S new file mode 100644 index 000000000..9975578b8 --- /dev/null +++ b/kern/emu/cache.S @@ -0,0 +1,19 @@ +#ifndef GRUB_MACHINE_EMU +#error "This source is only meant for grub-emu platform" +#endif + +#if defined(GRUB_CPU_I386) +/* Nothing is necessary. */ +#elif defined(GRUB_CPU_X86_64) +/* Nothing is necessary. */ +#elif defined(GRUB_CPU_SPARC64) +#include "../sparc64/cache.S" +#elif defined(GRUB_CPU_MIPS) +#include "../mips/cache.S" +#elif defined(GRUB_CPU_MIPSEL) +#include "../mips/cache.S" +#elif defined(GRUB_CPU_POWERPC) +#include "../powerpc/cache.S" +#else +#error "No target cpu type is defined" +#endif diff --git a/kern/emu/dl.c b/kern/emu/dl.c new file mode 100644 index 000000000..09e2f4a7a --- /dev/null +++ b/kern/emu/dl.c @@ -0,0 +1,19 @@ +#ifndef GRUB_MACHINE_EMU +#error "This source is only meant for grub-emu platform" +#endif + +#if defined(GRUB_CPU_I386) +#include "../i386/dl.c" +#elif defined(GRUB_CPU_X86_64) +#include "../x86_64/dl.c" +#elif defined(GRUB_CPU_SPARC64) +#include "../sparc64/dl.c" +#elif defined(GRUB_CPU_MIPS) +#include "../mips/dl.c" +#elif defined(GRUB_CPU_MIPSEL) +#include "../mips/dl.c" +#elif defined(GRUB_CPU_POWERPC) +#include "../powerpc/dl.c" +#else +#error "No target cpu type is defined" +#endif diff --git a/kern/emu/full.c b/kern/emu/full.c new file mode 100644 index 000000000..0bd33337f --- /dev/null +++ b/kern/emu/full.c @@ -0,0 +1,50 @@ +/* + * 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 . + */ + +#include +#include +#include +#include +#include +#include + +void +grub_register_exported_symbols (void) +{ +} + +grub_err_t +grub_arch_dl_check_header (void *ehdr) +{ + (void) ehdr; + return GRUB_ERR_BAD_MODULE; +} + +grub_err_t +grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) +{ + (void) mod; + (void) ehdr; + return GRUB_ERR_BAD_MODULE; +} + +void +grub_emu_init (void) +{ + grub_no_autoload = 1; +} diff --git a/kern/emu/lite.c b/kern/emu/lite.c new file mode 100644 index 000000000..884ddee10 --- /dev/null +++ b/kern/emu/lite.c @@ -0,0 +1,42 @@ +#include +#include + +#ifndef GRUB_MACHINE_EMU +#error "This source is only meant for grub-emu platform" +#endif + +#if defined(GRUB_CPU_I386) +#include "../i386/dl.c" +#elif defined(GRUB_CPU_X86_64) +#include "../x86_64/dl.c" +#elif defined(GRUB_CPU_SPARC64) +#include "../sparc64/dl.c" +#elif defined(GRUB_CPU_MIPS) +#include "../mips/dl.c" +#elif defined(GRUB_CPU_MIPSEL) +#include "../mips/dl.c" +#elif defined(GRUB_CPU_POWERPC) +#include "../powerpc/dl.c" +#else +#error "No target cpu type is defined" +#endif + +/* grub-emu-lite supports dynamic module loading, so it won't have any + embedded modules. */ +void +grub_init_all (void) +{ + return; +} + +void +grub_fini_all (void) +{ + return; +} + +void +grub_emu_init (void) +{ + return; +} From 5f02926bbcebc1acaa7475a4c3d39c915605c147 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 26 May 2010 09:56:59 +0530 Subject: [PATCH 3/9] emu build fixes for sparc64 and freebsd --- conf/any-emu.rmk | 7 ++++++- include/grub/cache.h | 3 ++- include/grub/emu/misc.h | 1 + util/misc.c | 8 -------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 3f0df06aa..17abc8911 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,6 +1,8 @@ # -*- makefile -*- -COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) +ifeq ($(target_cpu), sparc64) +COMMON_LDFLAGS += -mno-relax +endif kernel_img_RELOCATABLE = yes pkglib_PROGRAMS = kernel.img @@ -45,6 +47,9 @@ cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS) endif grub_emu_LDFLAGS = $(LIBCURSES) +ifeq ($(target_cpu), sparc64) +grub_emu_LDFLAGS += -m64 -mno-relax +endif ifeq ($(enable_grub_emu_usb), yes) kernel_img_HEADERS += libusb.h diff --git a/include/grub/cache.h b/include/grub/cache.h index 27e44f0a2..a54bc00f8 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -23,7 +23,8 @@ #include #include -#if defined (__i386__) || defined (__x86_64__) +#if defined (__i386__) || defined (__x86_64__) || \ + (defined (GRUB_MACHINE_EMU) && GRUB_MACHINE_EMU) static inline void grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index e037e6be7..1492e757a 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -46,5 +46,6 @@ int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...); #endif char * EXPORT_FUNC(xasprintf) (const char *fmt, ...); +char * canonicalize_file_name (const char *path); #endif /* GRUB_EMU_MISC_H */ diff --git a/util/misc.c b/util/misc.c index 91bc25a55..dd0077d72 100644 --- a/util/misc.c +++ b/util/misc.c @@ -214,14 +214,6 @@ grub_millisleep (grub_uint32_t ms) #endif -#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES -void -grub_arch_sync_caches (void *address __attribute__ ((unused)), - grub_size_t len __attribute__ ((unused))) -{ -} -#endif - #ifdef __MINGW32__ void sync (void) From c53fe8dfbbf70dcc7f46963015d1636afb3a464a Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 26 May 2010 16:53:43 +0530 Subject: [PATCH 4/9] build fixes for sparc64 and freebsd platforms --- conf/any-emu.rmk | 5 ++++- configure.ac | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 7560c8aba..77ba4f2b7 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,6 +1,7 @@ # -*- makefile -*- ifeq ($(target_cpu), sparc64) +COMMON_CFLAGS += -mno-app-regs COMMON_LDFLAGS += -mno-relax endif @@ -25,10 +26,12 @@ TARGET_NO_STRIP = yes noinst_MODULES = emu-full.mod emu_full_mod_SOURCES = kern/emu/full.c emu_full_mod_CFLAGS = $(COMMON_CFLAGS) +emu_full_mod_LDFLAGS = $(COMMON_LDFLAGS) noinst_MODULES = emu-lite.mod emu_lite_mod_SOURCES = kern/emu/lite.c kern/emu/cache.S symlist.c emu_lite_mod_CFLAGS = $(COMMON_CFLAGS) +emu_lite_mod_LDFLAGS = $(COMMON_LDFLAGS) # For halt.mod. pkglib_MODULES += halt.mod @@ -45,7 +48,7 @@ endif grub_emu_LDFLAGS = $(LIBCURSES) ifeq ($(target_cpu), sparc64) -grub_emu_LDFLAGS += -m64 -mno-relax +grub_emu_LDFLAGS += -m64 -melf64_sparc -mno-relax endif ifeq ($(enable_grub_emu_usb), yes) diff --git a/configure.ac b/configure.ac index 9448f792d..54622e5e9 100644 --- a/configure.ac +++ b/configure.ac @@ -155,7 +155,7 @@ esac machine_CPPFLAGS="$machine_CPPFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" CPPFLAGS="$CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" -TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CPPFLAGS" +TARGET_ASFLAGS="$TARGET_ASFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" TARGET_CFLAGS="$TARGET_CFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" AC_SUBST(host_cpu) From ac4d5ab78330f12c253f39fb6ac6d5a0a244d64b Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 26 May 2010 16:58:29 +0530 Subject: [PATCH 5/9] removed kern/emu/dl.c --- kern/emu/dl.c | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 kern/emu/dl.c diff --git a/kern/emu/dl.c b/kern/emu/dl.c deleted file mode 100644 index 09e2f4a7a..000000000 --- a/kern/emu/dl.c +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef GRUB_MACHINE_EMU -#error "This source is only meant for grub-emu platform" -#endif - -#if defined(GRUB_CPU_I386) -#include "../i386/dl.c" -#elif defined(GRUB_CPU_X86_64) -#include "../x86_64/dl.c" -#elif defined(GRUB_CPU_SPARC64) -#include "../sparc64/dl.c" -#elif defined(GRUB_CPU_MIPS) -#include "../mips/dl.c" -#elif defined(GRUB_CPU_MIPSEL) -#include "../mips/dl.c" -#elif defined(GRUB_CPU_POWERPC) -#include "../powerpc/dl.c" -#else -#error "No target cpu type is defined" -#endif From f17ead43f9e1a27b7b92694c464f61216e2770d5 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 27 May 2010 17:04:31 -0700 Subject: [PATCH 6/9] cygwin fixes --- conf/any-emu.rmk | 30 ++++++++++++++++++------------ genmk.rb | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 77ba4f2b7..0324898d3 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -23,16 +23,6 @@ kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-char-subscripts -Wn kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes -noinst_MODULES = emu-full.mod -emu_full_mod_SOURCES = kern/emu/full.c -emu_full_mod_CFLAGS = $(COMMON_CFLAGS) -emu_full_mod_LDFLAGS = $(COMMON_LDFLAGS) - -noinst_MODULES = emu-lite.mod -emu_lite_mod_SOURCES = kern/emu/lite.c kern/emu/cache.S symlist.c -emu_lite_mod_CFLAGS = $(COMMON_CFLAGS) -emu_lite_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For halt.mod. pkglib_MODULES += halt.mod halt_mod_SOURCES = commands/halt.c @@ -111,12 +101,28 @@ grub_emu_init.o: grub_emu_init.c grub_emu_init.h rm -f $@; $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"grub_init.c\" -c -o $@ $< CLEANFILES += grub_emu_init.o +kern_emu_lite.o: kern/emu/lite.c + $(TARGET_CC) $(COMMON_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"kern/emu/lite.c\" -c -o $@ $< +CLEANFILES += kern_emu_lite.o + +kern_emu_full.o: kern/emu/full.c + $(TARGET_CC) $(COMMON_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"kern/emu/full.c\" -c -o $@ $< +CLEANFILES += kern_emu_full.o + +kern_emu_cache.o: kern/emu/cache.S + $(TARGET_CC) $(COMMON_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(TARGET_ASFLAGS) -DGRUB_FILE=\"kern/emu/cache.S\" -c -o $@ $< +CLEANFILES += kern_emu_cache.o + +symlist.o: symlist.c + $(TARGET_CC) $(COMMON_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"symlist.c\" -c -o $@ $< +CLEANFILES += symlist.o + CLEANFILES += grub-emu-lite -grub-emu-lite: $(pkglib_PROGRAMS) emu-lite.mod +grub-emu-lite: kern_emu_lite.o kern_emu_cache.o symlist.o kernel.img $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) GRUB_EMU_LITE=grub-emu-lite CLEANFILES += grub-emu -grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS) emu-full.mod grub_emu_init.o +grub-emu: $(PREMODFILES) kern_emu_full.o grub_emu_init.o kernel.img $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) GRUB_EMU=grub-emu diff --git a/genmk.rb b/genmk.rb index 6b5ecd1d4..5d06d1153 100644 --- a/genmk.rb +++ b/genmk.rb @@ -161,6 +161,7 @@ endif #{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str} -rm -f $@ $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str} +PREMODFILES += #{pre_obj} #{mod_obj}: #{mod_src} $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{mod_src}\\\" -c -o $@ $< From 16eaf6f7c6470e2a7d065ae92e3022f2b640755e Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 28 May 2010 16:18:22 +0530 Subject: [PATCH 7/9] fixes for netbsd build --- kern/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kern/misc.c b/kern/misc.c index ccc01d43f..be50c671b 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -1058,7 +1058,7 @@ grub_abort (void) void abort (void) __attribute__ ((alias ("grub_abort"))); #endif -#if defined(NEED_ENABLE_EXECUTE_STACK) && !defined(GRUB_UTIL) +#if defined(NEED_ENABLE_EXECUTE_STACK) && !defined(GRUB_UTIL) && !defined(GRUB_MACHINE_EMU) /* Some gcc versions generate a call to this function in trampolines for nested functions. */ void __enable_execute_stack (void *addr __attribute__ ((unused))) From e5089776308459f799a0c6fc8be6a512373a6417 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 2 Jun 2010 13:51:05 +0530 Subject: [PATCH 8/9] review fixes --- commands/parttool.c | 6 ++++++ configure.ac | 44 ++++++++++++++++++++--------------------- include/grub/cache.h | 3 +-- include/grub/emu/misc.h | 3 +++ include/grub/misc.h | 3 --- kern/emu/cache.S | 12 ++++------- kern/emu/lite.c | 12 +++++------ kern/emu/main.c | 3 +++ kern/main.c | 2 -- normal/main.c | 6 ++++++ 10 files changed, 49 insertions(+), 45 deletions(-) diff --git a/commands/parttool.c b/commands/parttool.c index f2a62e581..3dbe129bf 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -31,6 +31,10 @@ #include #include +#if defined (GRUB_MACHINE_EMU) +#include +#endif + static struct grub_parttool *parts = 0; static int curhandle = 0; static grub_dl_t mymod; @@ -175,7 +179,9 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } /* Load modules. */ +#if defined(GRUB_MACHINE_EMU) if (! grub_no_autoload) +#endif { const char *prefix; prefix = grub_env_get ("prefix"); diff --git a/configure.ac b/configure.ac index 12f89d85e..4cfa29308 100644 --- a/configure.ac +++ b/configure.ac @@ -54,12 +54,14 @@ case "$target_cpu" in amd64) target_cpu=x86_64 ;; sparc) target_cpu=sparc64 ;; mipsel|mips64el) - target_cpu=mips; - cpu_CPPFLAGS="-DGRUB_CPU_MIPSEL=1"; + target_cpu=mips; + TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1"; + CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1"; ;; mips|mips64) - target_cpu=mips; - cpu_CPPFLAGS="-DGRUB_CPU_MIPS=1"; + target_cpu=mips; + TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPS=1"; + CFLAGS="$CFLAGS -DGRUB_CPU_MIPS=1"; ;; esac @@ -134,29 +136,25 @@ case "$host_os" in esac case "$platform" in - coreboot) machine_CPPFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; - multiboot) machine_CPPFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;; - efi) machine_CPPFLAGS="-DGRUB_MACHINE_EFI=1" ;; - ieee1275) machine_CPPFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; - qemu) machine_CPPFLAGS="-DGRUB_MACHINE_QEMU=1" ;; - pc) machine_CPPFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;; - emu) machine_CPPFLAGS="-DGRUB_MACHINE_EMU=1" ;; - yeeloong) machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; - qemu-mips) machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; + multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;; + efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;; + ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; + qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;; + pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;; + emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;; + yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; + qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;; esac case "$target_cpu" in - i386) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_I386";; - x86_64) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_X86_64";; - powerpc) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_POWERPC";; - mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; # cpu_CPPFLAGS handled above - sparc64) cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_SPARC64"; - machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;; + mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;; + sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;; esac -machine_CPPFLAGS="$machine_CPPFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" +machine_CFLAGS="$machine_CFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" -CPPFLAGS="$CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" -TARGET_ASFLAGS="$TARGET_ASFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" -TARGET_CFLAGS="$TARGET_CFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS" +CFLAGS="$CFLAGS $machine_CFLAGS" +TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS" +TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS" AC_SUBST(host_cpu) AC_SUBST(host_os) diff --git a/include/grub/cache.h b/include/grub/cache.h index a54bc00f8..27e44f0a2 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -23,8 +23,7 @@ #include #include -#if defined (__i386__) || defined (__x86_64__) || \ - (defined (GRUB_MACHINE_EMU) && GRUB_MACHINE_EMU) +#if defined (__i386__) || defined (__x86_64__) static inline void grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index bad00de71..32a5e29f8 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -49,4 +49,7 @@ int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...); char * EXPORT_FUNC(xasprintf) (const char *fmt, ...); extern char * canonicalize_file_name (const char *path); +/* Flag to control module autoloading in normal mode. */ +extern int EXPORT_VAR(grub_no_autoload); + #endif /* GRUB_EMU_MISC_H */ diff --git a/include/grub/misc.h b/include/grub/misc.h index 1ec8bbc5a..9bfc6974e 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -50,9 +50,6 @@ /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */ #define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n)) -/* Flag to control module autoloading in normal mode. */ -extern int EXPORT_VAR(grub_no_autoload); - void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c); diff --git a/kern/emu/cache.S b/kern/emu/cache.S index 9975578b8..90a5b5396 100644 --- a/kern/emu/cache.S +++ b/kern/emu/cache.S @@ -2,17 +2,13 @@ #error "This source is only meant for grub-emu platform" #endif -#if defined(GRUB_CPU_I386) +#if defined(__i386__) || defined(__x86_64__) /* Nothing is necessary. */ -#elif defined(GRUB_CPU_X86_64) -/* Nothing is necessary. */ -#elif defined(GRUB_CPU_SPARC64) +#elif defined(__sparc__) #include "../sparc64/cache.S" -#elif defined(GRUB_CPU_MIPS) +#elif defined(__mips__) #include "../mips/cache.S" -#elif defined(GRUB_CPU_MIPSEL) -#include "../mips/cache.S" -#elif defined(GRUB_CPU_POWERPC) +#elif defined(__powerpc__) #include "../powerpc/cache.S" #else #error "No target cpu type is defined" diff --git a/kern/emu/lite.c b/kern/emu/lite.c index 884ddee10..9b3728717 100644 --- a/kern/emu/lite.c +++ b/kern/emu/lite.c @@ -5,17 +5,15 @@ #error "This source is only meant for grub-emu platform" #endif -#if defined(GRUB_CPU_I386) +#if defined(__i386__) #include "../i386/dl.c" -#elif defined(GRUB_CPU_X86_64) +#elif defined(__x86_64__) #include "../x86_64/dl.c" -#elif defined(GRUB_CPU_SPARC64) +#elif defined(__sparc__) #include "../sparc64/dl.c" -#elif defined(GRUB_CPU_MIPS) +#elif defined(__mips__) #include "../mips/dl.c" -#elif defined(GRUB_CPU_MIPSEL) -#include "../mips/dl.c" -#elif defined(GRUB_CPU_POWERPC) +#elif defined(__powerpc__) #include "../powerpc/dl.c" #else #error "No target cpu type is defined" diff --git a/kern/emu/main.c b/kern/emu/main.c index 8d6118c93..1915e1a7c 100644 --- a/kern/emu/main.c +++ b/kern/emu/main.c @@ -51,6 +51,9 @@ static jmp_buf main_env; /* Store the prefix specified by an argument. */ static char *prefix = NULL; +/* Flag to control module autoloading in normal mode. */ +int grub_no_autoload; + grub_addr_t grub_arch_modules_addr (void) { diff --git a/kern/main.c b/kern/main.c index 2541d3295..1fdf4ab07 100644 --- a/kern/main.c +++ b/kern/main.c @@ -30,8 +30,6 @@ #include #include -int grub_no_autoload; - void grub_module_iterate (int (*hook) (struct grub_module_header *header)) { diff --git a/normal/main.c b/normal/main.c index b3544b99f..d1e95d9b5 100644 --- a/normal/main.c +++ b/normal/main.c @@ -32,6 +32,10 @@ #include #include +#if defined (GRUB_MACHINE_EMU) +#include +#endif + #define GRUB_DEFAULT_HISTORY_SIZE 50 static int nested_level = 0; @@ -476,7 +480,9 @@ grub_normal_init_page (struct grub_term_output *term) static void read_lists (const char *val) { +#if defined(GRUB_MACHINE_EMU) if (! grub_no_autoload) +#endif { read_command_list (val); read_fs_list (val); From 6d6f13934992f6f59b626b0fab49ef260659a112 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Wed, 2 Jun 2010 14:45:07 +0530 Subject: [PATCH 9/9] review fixes --- commands/parttool.c | 6 ------ include/grub/dl.h | 6 +++--- include/grub/emu/misc.h | 3 --- include/grub/misc.h | 7 +++++++ kern/emu/main.c | 1 - normal/main.c | 6 ------ 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/commands/parttool.c b/commands/parttool.c index 3dbe129bf..f2a62e581 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -31,10 +31,6 @@ #include #include -#if defined (GRUB_MACHINE_EMU) -#include -#endif - static struct grub_parttool *parts = 0; static int curhandle = 0; static grub_dl_t mymod; @@ -179,9 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } /* Load modules. */ -#if defined(GRUB_MACHINE_EMU) if (! grub_no_autoload) -#endif { const char *prefix; prefix = grub_env_get ("prefix"); diff --git a/include/grub/dl.h b/include/grub/dl.h index 9d5f2af2d..b66b7641e 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -95,13 +95,13 @@ int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod)); grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name); -grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr, - grub_dl_t mod); +grub_err_t grub_dl_register_symbol (const char *name, void *addr, + grub_dl_t mod); 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_MACHINE_EMU) || ! GRUB_MACHINE_EMU) +#if defined (_mips) #define GRUB_LINKER_HAVE_INIT 1 void grub_arch_dl_init_linker (void); #endif diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index 32a5e29f8..bad00de71 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -49,7 +49,4 @@ int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...); char * EXPORT_FUNC(xasprintf) (const char *fmt, ...); extern char * canonicalize_file_name (const char *path); -/* Flag to control module autoloading in normal mode. */ -extern int EXPORT_VAR(grub_no_autoload); - #endif /* GRUB_EMU_MISC_H */ diff --git a/include/grub/misc.h b/include/grub/misc.h index 9bfc6974e..077069934 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -308,4 +308,11 @@ void EXPORT_FUNC (grub_halt) (int no_apm); void EXPORT_FUNC (grub_halt) (void); #endif +#ifdef GRUB_MACHINE_EMU +/* Flag to control module autoloading in normal mode. */ +extern int EXPORT_VAR(grub_no_autoload); +#else +#define grub_no_autoload 0 +#endif + #endif /* ! GRUB_MISC_HEADER */ diff --git a/kern/emu/main.c b/kern/emu/main.c index 1915e1a7c..e2efd262f 100644 --- a/kern/emu/main.c +++ b/kern/emu/main.c @@ -51,7 +51,6 @@ static jmp_buf main_env; /* Store the prefix specified by an argument. */ static char *prefix = NULL; -/* Flag to control module autoloading in normal mode. */ int grub_no_autoload; grub_addr_t diff --git a/normal/main.c b/normal/main.c index d1e95d9b5..b3544b99f 100644 --- a/normal/main.c +++ b/normal/main.c @@ -32,10 +32,6 @@ #include #include -#if defined (GRUB_MACHINE_EMU) -#include -#endif - #define GRUB_DEFAULT_HISTORY_SIZE 50 static int nested_level = 0; @@ -480,9 +476,7 @@ grub_normal_init_page (struct grub_term_output *term) static void read_lists (const char *val) { -#if defined(GRUB_MACHINE_EMU) if (! grub_no_autoload) -#endif { read_command_list (val); read_fs_list (val);