Compile parts of grub-emu as modules.

* Makefile.in (TARGET_CPPFLAGS) [emu]: Remove -nostdinc -isystem.
	(pkglib_DATA) [emu]: Remove moddep.lst command.lst fs.lst
	partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst.
	(all-local): Add $(GRUB_EMU).
	(install-local): Install $(GRUB_EMU).
	(uninstall): Uninstall $(GRUB_EMU).
	* commands/parttool.c: Replace GRUB_UTIL with GRUB_NO_MODULES.
	* kern/dl.c: Likewise.
	* commands/sleep.c: Not include machine/time.h.
	* conf/any-emu.rmk (COMMON_LDFLAGS): New variable.
	(COMMON_CFLAGS): Likewise.
	(sbin_UTILITIES): Remove grub-emu.
	(grub_emu_SOURCES): Removed.
	(kernel_img_RELOCATABLE): New variable.
	(pkglib_PROGRAMS): Add kernel.img.
	(kernel_img_SOURCES): New variable
	(kernel_img_CFLAGS): Likewise.
	(kernel_img_LDFLAGS): Likewise.
	(TARGET_NO_STRIP): Likewise.
	(TARGET_NO_DYNAMIC_MODULES): Likewise.
	(pkglib_MODULES): Add progname.mod, hostfs.mod, host.mod, reboot.mod,
	halt.mod, cpuid.mod, usb.mod, sdl.mod and pci.mod.
	(grub-emu): New target.
	(GRUB_EMU): New variable.
	* configure.ac: Whitelist -emu as possible x86_64 architecture.
	* efiemu/main.c: Replace GRUB_UTIL with GRUB_MACHINE_EMU.
	* loader/xnu.c: Likewise.
	* include/grub/pci.h: Likewise.
	* genemuinit.sh: New file.
	* genemuinitheader.sh: Likewise.
	* genmk.rb: Don't strip if TARGET_NO_STRIP is yes.
	Support TARGET_NO_DYNAMIC_MODULES.
	* include/grub/dl.h (GRUB_NO_MODULES): New variable.
	* commands/search.c: Fix GRUB_MOD_INIT and GRUB_MOD_FINI arguments.
	* disk/loopback.c: Likewise.
	* font/font_cmd.c: Likewise.
	* partmap/acorn.c: Likewise.
	* partmap/amiga.c: Likewise.
	* partmap/apple.c: Likewise.
	* partmap/gpt.c: Likewise.
	* partmap/msdos.c: Likewise.
	* partmap/sun.c: Likewise.
	* parttool/msdospart.c: Likewise.
	* term/gfxterm.c: Likewise.
	* video/bitmap.c: Likewise.
	* video/readers/jpeg.c: Likewise.
	* video/readers/png.c: Likewise.
	* video/readers/tga.c: Likewise.
	* video/video.c: Likewise.
	* util/grub-emu.c (read_command_list): Removed.
	(main): Don't call util_init_nls.
	* util/misc.c (grub_err_printf) [!GRUB_UTIL]: Removed.
	(grub_util_init_nls) [!GRUB_UTIL]: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-14 16:29:52 +01:00
commit 4a6d2d06db
36 changed files with 349 additions and 167 deletions

View file

@ -1,3 +1,61 @@
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
Compile parts of grub-emu as modules.
* Makefile.in (TARGET_CPPFLAGS) [emu]: Remove -nostdinc -isystem.
(pkglib_DATA) [emu]: Remove moddep.lst command.lst fs.lst
partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst.
(all-local): Add $(GRUB_EMU).
(install-local): Install $(GRUB_EMU).
(uninstall): Uninstall $(GRUB_EMU).
* commands/parttool.c: Replace GRUB_UTIL with GRUB_NO_MODULES.
* kern/dl.c: Likewise.
* commands/sleep.c: Not include machine/time.h.
* conf/any-emu.rmk (COMMON_LDFLAGS): New variable.
(COMMON_CFLAGS): Likewise.
(sbin_UTILITIES): Remove grub-emu.
(grub_emu_SOURCES): Removed.
(kernel_img_RELOCATABLE): New variable.
(pkglib_PROGRAMS): Add kernel.img.
(kernel_img_SOURCES): New variable
(kernel_img_CFLAGS): Likewise.
(kernel_img_LDFLAGS): Likewise.
(TARGET_NO_STRIP): Likewise.
(TARGET_NO_DYNAMIC_MODULES): Likewise.
(pkglib_MODULES): Add progname.mod, hostfs.mod, host.mod, reboot.mod,
halt.mod, cpuid.mod, usb.mod, sdl.mod and pci.mod.
(grub-emu): New target.
(GRUB_EMU): New variable.
* configure.ac: Whitelist -emu as possible x86_64 architecture.
* efiemu/main.c: Replace GRUB_UTIL with GRUB_MACHINE_EMU.
* loader/xnu.c: Likewise.
* include/grub/pci.h: Likewise.
* genemuinit.sh: New file.
* genemuinitheader.sh: Likewise.
* genmk.rb: Don't strip if TARGET_NO_STRIP is yes.
Support TARGET_NO_DYNAMIC_MODULES.
* include/grub/dl.h (GRUB_NO_MODULES): New variable.
* commands/search.c: Fix GRUB_MOD_INIT and GRUB_MOD_FINI arguments.
* disk/loopback.c: Likewise.
* font/font_cmd.c: Likewise.
* partmap/acorn.c: Likewise.
* partmap/amiga.c: Likewise.
* partmap/apple.c: Likewise.
* partmap/gpt.c: Likewise.
* partmap/msdos.c: Likewise.
* partmap/sun.c: Likewise.
* parttool/msdospart.c: Likewise.
* term/gfxterm.c: Likewise.
* video/bitmap.c: Likewise.
* video/readers/jpeg.c: Likewise.
* video/readers/png.c: Likewise.
* video/readers/tga.c: Likewise.
* video/video.c: Likewise.
* util/grub-emu.c (read_command_list): Removed.
(main): Don't call util_init_nls.
* util/misc.c (grub_err_printf) [!GRUB_UTIL]: Removed.
(grub_util_init_nls) [!GRUB_UTIL]: Likewise.
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add datetime.mod,

View file

@ -178,7 +178,9 @@ endif
### General targets.
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
ifneq ($(platform), emu)
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) > $@ \
@ -279,7 +281,7 @@ build_env.mk: Makefile
) > $@
pkglib_BUILDDIR += config.h grub_script.tab.h
all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
all-local: $(PROGRAMS) $(GRUB_EMU) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
install: install-local
@ -300,7 +302,7 @@ install-local: all
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \
done
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
@list='$(bin_UTILITIES)'; for file in $$list; do \
@list='$(bin_UTILITIES) $(GRUB_EMU)'; 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; \
@ -376,7 +378,7 @@ uninstall:
dest="`echo $$file | sed 's,.*/,,'`"; \
rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
done
@list='$(bin_UTILITIES) $(bin_SCRIPTS)'; for file in $$list; do \
@list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU)'; 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. */
#ifndef GRUB_UTIL
#if GRUB_NO_MODULES
{
const char *prefix;
prefix = grub_env_get ("prefix");

View file

@ -149,11 +149,11 @@ grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
static grub_command_t cmd;
#ifdef DO_SEARCH_FILE
GRUB_MOD_INIT(search_file)
GRUB_MOD_INIT(search_fs_file)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_INIT(search_fs_uuid)
#else
GRUB_MOD_INIT(search_fs_label)
GRUB_MOD_INIT(search_label)
#endif
{
cmd =
@ -163,11 +163,11 @@ GRUB_MOD_INIT(search_fs_label)
}
#ifdef DO_SEARCH_FILE
GRUB_MOD_FINI(search_file)
GRUB_MOD_FINI(search_fs_file)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_FINI(search_fs_uuid)
#else
GRUB_MOD_FINI(search_fs_label)
GRUB_MOD_FINI(search_label)
#endif
{
grub_unregister_command (cmd);

View file

@ -22,7 +22,6 @@
#include <grub/time.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/machine/time.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>

View file

@ -1,129 +1,105 @@
# -*- makefile -*-
COMMON_LDFLAGS += -nostdlib
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
# Used by various components. These rules need to precede them.
script/lexer.c_DEPENDENCIES = grub_script.tab.h
sbin_UTILITIES += grub-emu
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/echo.c commands/help.c \
commands/handler.c commands/ls.c commands/test.c \
commands/search_wrap.c commands/search_file.c \
commands/search_label.c commands/search_uuid.c \
commands/blocklist.c commands/hexdump.c \
lib/hexdump.c commands/halt.c commands/reboot.c \
lib/envblk.c commands/loadenv.c \
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
commands/password.c commands/keystatus.c \
disk/host.c disk/loopback.c disk/scsi.c \
fs/fshelp.c \
\
io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
kernel_img_RELOCATABLE = yes
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 commands/extcmd.c kern/file.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/partition.c kern/term.c \
kern/rescue_reader.c kern/rescue_parser.c \
lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \
normal/handler.c normal/auth.c lib/crypto.c normal/autofs.c \
normal/completion.c normal/main.c normal/color.c \
normal/menu.c normal/menu_entry.c \
normal/menu_text.c normal/crypto.c normal/term.c \
commands/terminal.c normal/context.c lib/charset.c \
script/main.c script/execute.c script/function.c \
script/lexer.c script/script.c grub_script.tab.c \
partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \
partmap/acorn.c partmap/gpt.c \
\
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\
video/video.c video/fb/video_fb.c video/fb/fbblit.c \
video/fb/fbfill.c video/fb/fbutil.c commands/videotest.c \
video/bitmap.c video/bitmap_scale.c video/readers/tga.c \
video/readers/jpeg.c video/readers/png.c font/font_cmd.c \
font/font.c term/gfxterm.c io/bufio.c \
\
gfxmenu/gfxmenu.c gfxmenu/model.c gfxmenu/view.c \
gfxmenu/icon_manager.c gfxmenu/theme_loader.c \
gfxmenu/widget-box.c gfxmenu/gui_canvas.c \
gfxmenu/gui_circular_progress.c gfxmenu/gui_box.c \
gfxmenu/gui_label.c gfxmenu/gui_list.c gfxmenu/gui_image.c \
gfxmenu/gui_progress_bar.c gfxmenu/gui_util.c \
gfxmenu/gui_string_util.c gfxmenu/named_colors.c trigtables.c \
\
util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
util/console.c util/grub-emu.c util/misc.c \
util/hostdisk.c util/getroot.c \
\
disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
commands/parttool.c parttool/msdospart.c \
lib/libgcrypt-grub/cipher/md5.c \
grub_emu_init.c gnulib/progname.c
grub_emu_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
TARGET_NO_STRIP = yes
TARGET_NO_DYNAMIC_MODULES = yes
# For reboot.mod.
pkglib_MODULES += reboot.mod
reboot_mod_SOURCES = commands/reboot.c
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For halt.mod.
pkglib_MODULES += halt.mod
halt_mod_SOURCES = commands/halt.c
halt_mod_CFLAGS = $(COMMON_CFLAGS)
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifeq ($(target_cpu), i386)
grub_emu_SOURCES += commands/i386/cpuid.c
pkglib_MODULES += cpuid.mod
cpuid_mod_SOURCES = commands/i386/cpuid.c
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
endif
grub_emu_LDFLAGS = $(LIBCURSES)
ifeq ($(enable_grub_emu_usb), yes)
grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
commands/usbtest.c
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
pkglib_MODULES += libusb.mod
libusb_mod_SOURCES = util/usb.c
libusb_mod_CFLAGS =
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usb.mod
pkglib_MODULES += usb.mod
usb_mod_SOURCES = bus/usb/usb.c
usb_mod_CFLAGS = $(COMMON_CFLAGS)
usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usbtest.mod
pkglib_MODULES += usbtest.mod
usbtest_mod_SOURCES = commands/usbtest.c
usbtest_mod_CFLAGS = $(COMMON_CFLAGS)
usbtest_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usbms.mod
pkglib_MODULES += usbms.mod
usbms_mod_SOURCES = disk/usbms.c
usbms_mod_CFLAGS = $(COMMON_CFLAGS)
usbms_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBUSB)
endif
ifeq ($(enable_grub_emu_sdl), yes)
grub_emu_SOURCES += util/sdl.c
pkglib_MODULES += sdl.mod
sdl_mod_SOURCES = util/sdl.c
sdl_mod_CFLAGS =
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBSDL)
endif
ifeq ($(enable_grub_emu_pci), yes)
grub_emu_SOURCES += util/pci.c commands/lspci.c
pkglib_MODULES += pci.mod
pci_mod_SOURCES = util/pci.c commands/lspci.c
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBPCIACCESS)
endif
grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
DISTCLEANFILES += grub_emu_init.lst
include $(srcdir)/conf/common.mk
grub_emu_init.h: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninitheader.sh
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.h
grub_emu_init.c: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninit.sh grub_emu_init.h
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.c
CLEANFILES += grub-emu
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
GRUB_EMU=grub-emu
# FIXME: this could be shared with common.rmk
trigtables.c: gentrigtables
./gentrigtables > $@
DISTCLEANFILES += trigtables.c
gentrigtables: gentrigtables.c
$(CC) -o $@ $^ $(CPPFLAGS) -lm
DISTCLEANFILES += gentrigtables
# For grub-mkfont.
ifeq ($(enable_grub_mkfont), yes)
bin_UTILITIES += grub-mkfont
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
grub_mkfont_CFLAGS = $(freetype_cflags)
grub_mkfont_LDFLAGS = $(freetype_libs)
endif
grub_script.tab.c grub_script.tab.h: script/parser.y
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
bin_UTILITIES += grub-bin2h
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c

View file

@ -91,6 +91,7 @@ fi
if test -z "$target_alias"; then
case "$target_cpu"-"$platform" in
x86_64-efi) ;;
x86_64-emu) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
esac
@ -522,6 +523,7 @@ enable_efiemu=no
fi
AC_SUBST([enable_efiemu])
if test "$platform" != emu; then
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
@ -535,6 +537,7 @@ int va_arg_func (int fixed, va_list args);]], [[]])],
if test x"$grub_cv_cc_isystem" = xyes ; then
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
fi
fi
# Restore the flags.
CC="$tmp_CC"

View file

@ -242,7 +242,7 @@ static struct grub_disk_dev grub_loopback_dev =
static grub_extcmd_t cmd;
GRUB_MOD_INIT(loop)
GRUB_MOD_INIT(loopback)
{
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
GRUB_COMMAND_FLAG_BOTH,
@ -251,7 +251,7 @@ GRUB_MOD_INIT(loop)
grub_disk_dev_register (&grub_loopback_dev);
}
GRUB_MOD_FINI(loop)
GRUB_MOD_FINI(loopback)
{
grub_unregister_extcmd (cmd);
grub_disk_dev_unregister (&grub_loopback_dev);

View file

@ -265,7 +265,7 @@ grub_efiemu_autocore (void)
grub_free (filename);
if (err)
return err;
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
err = grub_machine_efiemu_init_tables ();
if (err)
return err;
@ -313,7 +313,7 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
err = grub_efiemu_load_file (args[0]);
if (err)
return err;
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
err = grub_machine_efiemu_init_tables ();
if (err)
return err;

View file

@ -281,7 +281,7 @@ grub_efiemu_mmap_init (void)
// the place for memory used by efiemu itself
mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1;
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
grub_machine_mmap_iterate (bounds_hook);
#endif
@ -394,7 +394,7 @@ grub_efiemu_mmap_fill (void)
}
}
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
grub_machine_mmap_iterate (fill_hook);
#endif

View file

@ -56,7 +56,7 @@ lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
static grub_command_t cmd_loadfont, cmd_lsfonts;
GRUB_MOD_INIT(font_manager)
GRUB_MOD_INIT(font)
{
grub_font_loader_init ();
@ -69,7 +69,7 @@ GRUB_MOD_INIT(font_manager)
0, "List the loaded fonts.");
}
GRUB_MOD_FINI(font_manager)
GRUB_MOD_FINI(font)
{
/* TODO: Determine way to free allocated resources.
Warning: possible pointer references could be in use. */

72
genemuinit.sh Normal file
View file

@ -0,0 +1,72 @@
#! /bin/sh
#
# Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
#
# This gensymlist.sh is free software; the author
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
nm="$1"
shift
cat <<EOF
/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include "grub_emu_init.h"
EOF
cat <<EOF
void
grub_init_all (void)
{
EOF
read mods
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
echo "grub_${line}_init ();" | sed 's,\.mod,,g;'
fi
done
cat <<EOF
}
EOF
cat <<EOF
void
grub_fini_all (void)
{
EOF
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
echo "grub_${line}_fini ();" | sed 's,\.mod,,g;'
fi
done
cat <<EOF
}
EOF

52
genemuinitheader.sh Normal file
View file

@ -0,0 +1,52 @@
#! /bin/sh
#
# Copyright (C) 2005,2007 Free Software Foundation, Inc.
#
# This gensymlist.sh is free software; the author
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
nm="$1"
shift
cat <<EOF
/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2007 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
EOF
cat <<EOF
void grub_init_all (void);
void grub_fini_all (void);
EOF
read mods
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
echo "void grub_${line}_init (void);" | sed 's,\.mod,,g;'
fi
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
echo "void grub_${line}_fini (void);" | sed 's,\.mod,,g;'
fi
done

View file

@ -143,12 +143,19 @@ mostlyclean-module-#{@name}.#{@rule_count}:
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
UNDSYMFILES += #{undsym}
ifeq ($(TARGET_NO_DYNAMIC_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 $@
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
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
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
-rm -f $@
@ -157,6 +164,7 @@ else
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@
-rm -f $@.bin
endif
endif
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
-rm -f $@
@ -330,11 +338,11 @@ MOSTLYCLEANFILES += #{deps_str}
ifeq ($(#{prefix}_RELOCATABLE),yes)
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
$(STRIP) --strip-unneeded -K start -R .note -R .comment $@
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)
$(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
endif
" + objs.collect_with_index do |obj, i|

View file

@ -91,7 +91,12 @@ 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);
#ifdef GRUB_UTIL
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
#define GRUB_NO_MODULES 1
#else
#define GRUB_NO_MODULES 0
#endif
#if GRUB_NO_MODULES
static inline int
grub_dl_ref (grub_dl_t mod)
{
@ -116,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)
#if defined (_mips) && ! defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
#define GRUB_LINKER_HAVE_INIT 1
void grub_arch_dl_init_linker (void);
#endif

View file

@ -36,7 +36,7 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
/* For debugging. */
#if defined(MM_DEBUG) && !defined(GRUB_UTIL)
#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
/* Set this variable to 1 when you want to trace all memory function calls. */
extern int EXPORT_VAR(grub_mm_debug);

View file

@ -68,7 +68,7 @@
typedef grub_uint32_t grub_pci_id_t;
#ifdef GRUB_UTIL
#ifdef GRUB_MACHINE_EMU
#include <grub/pciutils.h>
#else
typedef grub_uint32_t grub_pci_address_t;

View file

@ -469,7 +469,7 @@ grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
return GRUB_ERR_NONE;
}
#ifndef GRUB_UTIL
#if !GRUB_NO_MODULES
int
grub_dl_ref (grub_dl_t mod)
{

View file

@ -29,10 +29,10 @@
#include <grub/cpu/kernel.h>
extern void grub_video_sm712_init (void);
extern void grub_video_video_init (void);
extern void grub_video_bitmap_init (void);
extern void grub_font_manager_init (void);
extern void grub_term_gfxterm_init (void);
extern void grub_video_init (void);
extern void grub_bitmap_init (void);
extern void grub_font_init (void);
extern void grub_gfxterm_init (void);
extern void grub_at_keyboard_init (void);
/* FIXME: use interrupt to count high. */
@ -76,10 +76,10 @@ grub_machine_init (void)
/* Initialize output terminal (can't be done earlier, as gfxterm
relies on a working heap. */
grub_video_sm712_init ();
grub_video_video_init ();
grub_video_bitmap_init ();
grub_font_manager_init ();
grub_term_gfxterm_init ();
grub_video_init ();
grub_bitmap_init ();
grub_font_init ();
grub_gfxterm_init ();
grub_at_keyboard_init ();
}

View file

@ -1390,7 +1390,7 @@ grub_cmd_xnu_splash (grub_extcmd_t cmd,
}
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
static grub_err_t
grub_cmd_xnu_resume (grub_command_t cmd __attribute__ ((unused)),
int argc, char *args[])
@ -1444,7 +1444,7 @@ GRUB_MOD_INIT(xnu)
N_("Load a splash image for XNU."),
xnu_splash_cmd_options);
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume,
0, N_("Load XNU hibernate image."));
#endif
@ -1456,7 +1456,7 @@ GRUB_MOD_INIT(xnu)
GRUB_MOD_FINI(xnu)
{
#ifndef GRUB_UTIL
#ifndef GRUB_MACHINE_EMU
grub_unregister_command (cmd_resume);
#endif
grub_unregister_command (cmd_mkext);

View file

@ -188,12 +188,12 @@ static struct grub_partition_map grub_acorn_partition_map =
.get_name = acorn_partition_map_get_name
};
GRUB_MOD_INIT(acorn_partition_map)
GRUB_MOD_INIT(part_acorn)
{
grub_partition_map_register (&grub_acorn_partition_map);
}
GRUB_MOD_FINI(acorn_partition_map)
GRUB_MOD_FINI(part_acorn)
{
grub_partition_map_unregister (&grub_acorn_partition_map);
}

View file

@ -197,12 +197,12 @@ static struct grub_partition_map grub_amiga_partition_map =
.get_name = amiga_partition_map_get_name
};
GRUB_MOD_INIT(amiga_partition_map)
GRUB_MOD_INIT(part_amiga)
{
grub_partition_map_register (&grub_amiga_partition_map);
}
GRUB_MOD_FINI(amiga_partition_map)
GRUB_MOD_FINI(part_amiga)
{
grub_partition_map_unregister (&grub_amiga_partition_map);
}

View file

@ -240,12 +240,12 @@ static struct grub_partition_map grub_apple_partition_map =
.get_name = apple_partition_map_get_name
};
GRUB_MOD_INIT(apple_partition_map)
GRUB_MOD_INIT(part_apple)
{
grub_partition_map_register (&grub_apple_partition_map);
}
GRUB_MOD_FINI(apple_partition_map)
GRUB_MOD_FINI(part_apple)
{
grub_partition_map_unregister (&grub_apple_partition_map);
}

View file

@ -175,12 +175,12 @@ static struct grub_partition_map grub_gpt_partition_map =
.get_name = gpt_partition_map_get_name
};
GRUB_MOD_INIT(gpt_partition_map)
GRUB_MOD_INIT(part_gpt)
{
grub_partition_map_register (&grub_gpt_partition_map);
}
GRUB_MOD_FINI(gpt_partition_map)
GRUB_MOD_FINI(part_gpt)
{
grub_partition_map_unregister (&grub_gpt_partition_map);
}

View file

@ -321,12 +321,12 @@ static struct grub_partition_map grub_msdos_partition_map =
.get_name = pc_partition_map_get_name
};
GRUB_MOD_INIT(pc_partition_map)
GRUB_MOD_INIT(part_msdos)
{
grub_partition_map_register (&grub_msdos_partition_map);
}
GRUB_MOD_FINI(pc_partition_map)
GRUB_MOD_FINI(part_msdos)
{
grub_partition_map_unregister (&grub_msdos_partition_map);
}

View file

@ -208,12 +208,12 @@ static struct grub_partition_map grub_sun_partition_map =
.get_name = sun_partition_map_get_name
};
GRUB_MOD_INIT(sun_partition_map)
GRUB_MOD_INIT(part_sun)
{
grub_partition_map_register (&grub_sun_partition_map);
}
GRUB_MOD_FINI(sun_partition_map)
GRUB_MOD_FINI(part_sun)
{
grub_partition_map_unregister (&grub_sun_partition_map);
}

View file

@ -138,7 +138,7 @@ static grub_err_t grub_pcpart_type (const grub_device_t dev,
return GRUB_ERR_NONE;
}
GRUB_MOD_INIT (pcpart)
GRUB_MOD_INIT (msdospart)
{
activate_table_handle = grub_parttool_register ("part_msdos",
grub_pcpart_boot,
@ -148,7 +148,7 @@ GRUB_MOD_INIT (pcpart)
grub_pcpart_typeargs);
}
GRUB_MOD_FINI(pcpart)
GRUB_MOD_FINI(msdospart)
{
grub_parttool_unregister (activate_table_handle);
grub_parttool_unregister (type_table_handle);

View file

@ -354,7 +354,7 @@ grub_gfxterm_fullscreen (void)
}
static grub_err_t
grub_gfxterm_init (void)
grub_gfxterm_term_init (void)
{
char *tmp;
grub_err_t err;
@ -398,7 +398,7 @@ destroy_window (void)
}
static grub_err_t
grub_gfxterm_fini (void)
grub_gfxterm_term_fini (void)
{
destroy_window ();
grub_video_restore ();
@ -1161,8 +1161,8 @@ grub_gfxterm_background_image_cmd (grub_extcmd_t cmd __attribute__ ((unused)),
static struct grub_term_output grub_video_term =
{
.name = "gfxterm",
.init = grub_gfxterm_init,
.fini = grub_gfxterm_fini,
.init = grub_gfxterm_term_init,
.fini = grub_gfxterm_term_fini,
.putchar = grub_gfxterm_putchar,
.getcharwidth = grub_gfxterm_getcharwidth,
.getwh = grub_virtual_screen_getwh,
@ -1180,7 +1180,7 @@ static struct grub_term_output grub_video_term =
static grub_extcmd_t background_image_cmd_handle;
GRUB_MOD_INIT(term_gfxterm)
GRUB_MOD_INIT(gfxterm)
{
grub_term_register_output ("gfxterm", &grub_video_term);
background_image_cmd_handle =
@ -1192,7 +1192,7 @@ GRUB_MOD_INIT(term_gfxterm)
background_image_cmd_options);
}
GRUB_MOD_FINI(term_gfxterm)
GRUB_MOD_FINI(gfxterm)
{
grub_unregister_extcmd (background_image_cmd_handle);
grub_term_unregister_output (&grub_video_term);

View file

@ -107,10 +107,6 @@ grub_machine_fini (void)
grub_console_fini ();
}
void
read_command_list (void)
{
}
static struct option options[] =
@ -150,6 +146,11 @@ 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[])
{
@ -161,8 +162,6 @@ main (int argc, char *argv[])
set_program_name (argv[0]);
grub_util_init_nls ();
while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1)
switch (opt)
{
@ -210,6 +209,8 @@ main (int argc, char *argv[])
signal (SIGINT, SIG_IGN);
grub_console_init ();
grub_host_init ();
grub_hostfs_init ();
/* XXX: This is a bit unportable. */
grub_util_biosdisk_init (dev_map);
@ -242,6 +243,8 @@ main (int argc, char *argv[])
grub_main ();
grub_fini_all ();
grub_hostfs_fini ();
grub_host_fini ();
grub_machine_fini ();

View file

@ -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;
@ -198,7 +198,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
fd = open (map[drive].device, O_RDONLY);
if (fd == -1)
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device);
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device);
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
@ -244,7 +244,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal."
#endif
if (stat (map[drive].device, &st) < 0)
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive].device);
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "cannot stat `%s'", map[drive].device);
disk->total_sectors = st.st_size >> GRUB_DISK_SECTOR_BITS;

View file

@ -104,6 +104,7 @@ grub_util_error (const char *fmt, ...)
exit (1);
}
#ifdef GRUB_UTIL
int
grub_err_printf (const char *fmt, ...)
{
@ -116,6 +117,7 @@ grub_err_printf (const char *fmt, ...)
return ret;
}
#endif
void *
xmalloc (size_t size)
@ -598,6 +600,7 @@ make_system_path_relative_to_its_root (const char *path)
return buf3;
}
#ifdef GRUB_UTIL
void
grub_util_init_nls (void)
{
@ -607,3 +610,4 @@ grub_util_init_nls (void)
textdomain (PACKAGE);
#endif /* ENABLE_NLS */
}
#endif

View file

@ -243,11 +243,11 @@ void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap)
}
/* Initialize bitmap module. */
GRUB_MOD_INIT(video_bitmap)
GRUB_MOD_INIT(bitmap)
{
}
/* Finalize bitmap module. */
GRUB_MOD_FINI(video_bitmap)
GRUB_MOD_FINI(bitmap)
{
}

View file

@ -729,7 +729,7 @@ static struct grub_video_bitmap_reader jpeg_reader = {
.next = 0
};
GRUB_MOD_INIT (video_reader_jpeg)
GRUB_MOD_INIT (jpeg)
{
grub_video_bitmap_reader_register (&jpg_reader);
grub_video_bitmap_reader_register (&jpeg_reader);
@ -740,7 +740,7 @@ GRUB_MOD_INIT (video_reader_jpeg)
#endif
}
GRUB_MOD_FINI (video_reader_jpeg)
GRUB_MOD_FINI (jpeg)
{
#if defined(JPEG_DEBUG)
grub_unregister_command (cmd);

View file

@ -894,7 +894,7 @@ static struct grub_video_bitmap_reader png_reader = {
.next = 0
};
GRUB_MOD_INIT (video_reader_png)
GRUB_MOD_INIT (png)
{
grub_video_bitmap_reader_register (&png_reader);
#if defined(PNG_DEBUG)
@ -904,7 +904,7 @@ GRUB_MOD_INIT (video_reader_png)
#endif
}
GRUB_MOD_FINI (video_reader_png)
GRUB_MOD_FINI (png)
{
#if defined(PNG_DEBUG)
grub_unregister_command (cmd);

View file

@ -477,7 +477,7 @@ static struct grub_video_bitmap_reader tga_reader = {
.next = 0
};
GRUB_MOD_INIT(video_reader_tga)
GRUB_MOD_INIT(tga)
{
grub_video_bitmap_reader_register (&tga_reader);
#if defined(TGA_DEBUG)
@ -486,7 +486,7 @@ GRUB_MOD_INIT(video_reader_tga)
#endif
}
GRUB_MOD_FINI(video_reader_tga)
GRUB_MOD_FINI(tga)
{
#if defined(TGA_DEBUG)
grub_unregister_command (cmd);

View file

@ -696,11 +696,11 @@ grub_video_set_mode (const char *modestring,
}
/* Initialize Video API module. */
GRUB_MOD_INIT(video_video)
GRUB_MOD_INIT(video)
{
}
/* Finalize Video API module. */
GRUB_MOD_FINI(video_video)
GRUB_MOD_FINI(video)
{
}