diff --git a/ChangeLog b/ChangeLog index 241b59b76..6ce3990a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2010-08-23 BVK Chaitanya + + Replace --enable-grub-emu-modules with grub-emu-lite. + + * kern/emu/cache.S: New file. Wrapper for $target_cpu specific + cache.S. + + * include/grub/emu/misc.h (grub_emu_init): New prototype. + * kern/emu/full.c: New file. For grub-emu specific initialization. + * kern/emu/lite.c: New file. For grub-emu-lite initialization. + * kern/emu/main.c: Call initialization function grub_emu_init. + + * Makefile.in: Include grub-emu-lite in install. + * commands/parttool.c: Use grub_no_autoload to differentiate + between grub-emu and grub-emu-lite. + * include/grub/misc.h: New variable grub_no_autoload. + + * conf/any-emu.rmk: New rules for grub-emu-lite. + * configure.ac: Remove --enable-grub-emu-modules. + * genmk.rb: Cleanup unnecessary rules. + * include/grub/dl.h: Remove GRUB_NO_MODULES macro. + + * normal/main.c: Don't load list files on grub-emu-lite. + * util/misc.c (grub_arch_sync_caches): Removed. + 2010-08-23 Colin Watson * kern/mips/startup.S (grub_prefix): Update comment to refer to diff --git a/Makefile.in b/Makefile.in index 39061be4d..4b1ec8c0a 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@ @@ -193,17 +192,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) > $@ \ @@ -309,7 +301,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 @@ -330,7 +322,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; \ @@ -406,7 +398,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 8272bf25e..1b98a0e40 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,5 +1,10 @@ # -*- makefile -*- +ifeq ($(target_cpu), sparc64) +COMMON_CFLAGS += -mno-app-regs +COMMON_LDFLAGS += -mno-relax +endif + kernel_img_RELOCATABLE = yes pkglib_PROGRAMS = kernel.img kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ @@ -18,17 +23,6 @@ kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-char-subscripts -Wn kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes -ifneq ($(TARGET_NO_MODULES), yes) -kernel_img_SOURCES += symlist.c kern/$(target_cpu)/dl.c -else -kernel_img_SOURCES += grub_emu_init.c -endif -ifneq ($(target_cpu), i386) -ifneq ($(target_cpu), x86_64) -kernel_img_SOURCES += kern/$(target_cpu)/cache.S -endif -endif - # For halt.mod. pkglib_MODULES += halt.mod halt_mod_SOURCES = commands/halt.c @@ -43,6 +37,9 @@ cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS) endif grub_emu_LDFLAGS = $(LIBCURSES) +ifeq ($(target_cpu), sparc64) +grub_emu_LDFLAGS += -m64 -melf64_sparc -mno-relax +endif ifeq ($(enable_grub_emu_usb), yes) kernel_img_HEADERS += libusb.h @@ -124,13 +121,32 @@ 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 +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: 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: $(PREMODFILES) kern_emu_full.o grub_emu_init.o kernel.img + $(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS) +GRUB_EMU=grub-emu diff --git a/configure.ac b/configure.ac index 4091b4fa2..3500aa175 100644 --- a/configure.ac +++ b/configure.ac @@ -614,10 +614,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.] @@ -636,19 +632,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 @@ -851,11 +834,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 01b969ecf..8cfc0c3ea 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,11 +157,11 @@ 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 $@ $(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 $@ $< diff --git a/include/grub/dl.h b/include/grub/dl.h index 351cca64d..29dca7ec2 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -92,11 +92,6 @@ 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); extern grub_dl_t EXPORT_VAR(grub_dl_head); @@ -110,7 +105,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) && ! GRUB_NO_MODULES +#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 ebb81a37f..e9038c916 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -42,6 +42,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 df80cf192..8bf8c82b4 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -324,4 +324,11 @@ void EXPORT_FUNC (grub_halt) (int no_apm) __attribute__ ((noreturn)); void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn)); #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/cache.S b/kern/emu/cache.S new file mode 100644 index 000000000..90a5b5396 --- /dev/null +++ b/kern/emu/cache.S @@ -0,0 +1,15 @@ +#ifndef GRUB_MACHINE_EMU +#error "This source is only meant for grub-emu platform" +#endif + +#if defined(__i386__) || defined(__x86_64__) +/* Nothing is necessary. */ +#elif defined(__sparc__) +#include "../sparc64/cache.S" +#elif defined(__mips__) +#include "../mips/cache.S" +#elif defined(__powerpc__) +#include "../powerpc/cache.S" +#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..9b3728717 --- /dev/null +++ b/kern/emu/lite.c @@ -0,0 +1,40 @@ +#include +#include + +#ifndef GRUB_MACHINE_EMU +#error "This source is only meant for grub-emu platform" +#endif + +#if defined(__i386__) +#include "../i386/dl.c" +#elif defined(__x86_64__) +#include "../x86_64/dl.c" +#elif defined(__sparc__) +#include "../sparc64/dl.c" +#elif defined(__mips__) +#include "../mips/dl.c" +#elif defined(__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; +} diff --git a/kern/emu/main.c b/kern/emu/main.c index fb5dbf19f..e2efd262f 100644 --- a/kern/emu/main.c +++ b/kern/emu/main.c @@ -51,31 +51,14 @@ static jmp_buf main_env; /* Store the prefix specified by an argument. */ static char *prefix = NULL; +int grub_no_autoload; + grub_addr_t 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 +137,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 +196,7 @@ main (int argc, char *argv[]) } signal (SIGINT, SIG_IGN); + grub_emu_init (); grub_console_init (); grub_host_init (); grub_hostfs_init (); @@ -223,9 +204,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 +234,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 +264,3 @@ grub_millisleep (grub_uint32_t ms) } #endif - -#if GRUB_NO_MODULES -void -grub_register_exported_symbols (void) -{ -} -#endif diff --git a/normal/main.c b/normal/main.c index 49658fd24..cddb15216 100644 --- a/normal/main.c +++ b/normal/main.c @@ -445,10 +445,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 21dd211e1..3101b01e6 100644 --- a/util/misc.c +++ b/util/misc.c @@ -185,12 +185,10 @@ grub_mm_init_region (void *addr __attribute__ ((unused)), { } -#if GRUB_NO_MODULES void grub_register_exported_symbols (void) { } -#endif #ifdef __MINGW32__ @@ -214,14 +212,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)