replace --enable-grub-emu-modules with grub-emu-lite

This commit is contained in:
BVK Chaitanya 2010-05-04 09:47:48 +05:30
parent a06157aa05
commit 725396942e
12 changed files with 63 additions and 131 deletions

View file

@ -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; \

View file

@ -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 ();

View file

@ -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

View file

@ -55,13 +55,11 @@ case "$target_cpu" in
sparc) target_cpu=sparc64 ;;
mipsel|mips64el)
target_cpu=mips;
TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1";
CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1";
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";
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

View file

@ -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 $@

View file

@ -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

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -30,6 +30,8 @@
#include <grub/reader.h>
#include <grub/parser.h>
int grub_no_autoload;
void
grub_module_iterate (int (*hook) (struct grub_module_header *header))
{

View file

@ -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 *

View file

@ -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)))