pull-in emu-lite branch
This commit is contained in:
commit
16321bf9ca
26 changed files with 316 additions and 345 deletions
|
@ -123,7 +123,7 @@ esac
|
||||||
|
|
||||||
case "$platform" in
|
case "$platform" in
|
||||||
coreboot) machine_CPPFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
coreboot) machine_CPPFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
||||||
multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
|
multiboot) machine_CPPFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
|
||||||
efi) machine_CPPFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
efi) machine_CPPFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
||||||
ieee1275) machine_CPPFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
ieee1275) machine_CPPFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
||||||
qemu) machine_CPPFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
qemu) machine_CPPFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
||||||
|
@ -801,4 +801,3 @@ AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
|
||||||
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
|
AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
|
||||||
AM_CONDITIONAL([COND_GRUB_FSTEST], [test x$enable_grub_fstest = xyes])
|
AM_CONDITIONAL([COND_GRUB_FSTEST], [test x$enable_grub_fstest = xyes])
|
||||||
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
|
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load modules. */
|
/* Load modules. */
|
||||||
#if defined(GRUB_MACHINE_EMU)
|
if (! grub_no_autoload)
|
||||||
{
|
{
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
prefix = grub_env_get ("prefix");
|
prefix = grub_env_get ("prefix");
|
||||||
|
@ -233,7 +233,6 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||||
/* Ignore errors. */
|
/* Ignore errors. */
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return show_help ();
|
return show_help ();
|
||||||
|
|
|
@ -9,26 +9,24 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||||
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/term.c \
|
kern/parser.c kern/partition.c kern/term.c \
|
||||||
kern/rescue_reader.c kern/rescue_parser.c \
|
kern/rescue_reader.c kern/rescue_parser.c \
|
||||||
\
|
\
|
||||||
util/console.c util/grub-emu.c util/misc.c \
|
kern/emu/main.c kern/emu/mm.c kern/emu/misc.c \
|
||||||
util/hostdisk.c util/getroot.c util/mm.c util/time.c \
|
kern/emu/getroot.c kern/emu/time.c kern/emu/hostdisk.c \
|
||||||
\
|
kern/emu/hostfs.c kern/emu/console.c \
|
||||||
gnulib/progname.c util/hostfs.c disk/host.c
|
\
|
||||||
kernel_img_HEADERS += datetime.h util/misc.h
|
gnulib/progname.c disk/host.c
|
||||||
|
kernel_img_HEADERS += datetime.h emu/misc.h
|
||||||
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
TARGET_NO_STRIP = yes
|
TARGET_NO_STRIP = yes
|
||||||
|
|
||||||
ifneq ($(TARGET_NO_MODULES), yes)
|
noinst_MODULES = emu-full.mod
|
||||||
kernel_img_SOURCES += symlist.c kern/$(target_cpu)/dl.c
|
emu_full_mod_SOURCES = kern/emu/full.c
|
||||||
ifneq ($(target_cpu), i386)
|
emu_full_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
ifneq ($(target_cpu), x86_64)
|
|
||||||
kernel_img_SOURCES += kern/$(target_cpu)/cache.S
|
noinst_MODULES = emu-lite.mod
|
||||||
endif
|
emu_lite_mod_SOURCES = kern/emu/lite.c kern/emu/cache.S symlist.c
|
||||||
endif
|
emu_lite_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
else
|
|
||||||
kernel_img_SOURCES += grub_emu_init.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# For halt.mod.
|
# For halt.mod.
|
||||||
pkglib_MODULES += halt.mod
|
pkglib_MODULES += halt.mod
|
||||||
|
@ -49,7 +47,7 @@ ifeq ($(enable_grub_emu_usb), yes)
|
||||||
kernel_img_HEADERS += libusb.h
|
kernel_img_HEADERS += libusb.h
|
||||||
|
|
||||||
pkglib_MODULES += libusb.mod
|
pkglib_MODULES += libusb.mod
|
||||||
libusb_mod_SOURCES = util/usb.c
|
libusb_mod_SOURCES = bus/usb/emu/usb.c
|
||||||
libusb_mod_CFLAGS =
|
libusb_mod_CFLAGS =
|
||||||
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_sdl), yes)
|
ifeq ($(enable_grub_emu_sdl), yes)
|
||||||
pkglib_MODULES += sdl.mod
|
pkglib_MODULES += sdl.mod
|
||||||
sdl_mod_SOURCES = util/sdl.c
|
sdl_mod_SOURCES = video/emu/sdl.c
|
||||||
sdl_mod_CFLAGS =
|
sdl_mod_CFLAGS =
|
||||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBSDL)
|
grub_emu_LDFLAGS += $(LIBSDL)
|
||||||
|
@ -85,7 +83,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_pci), yes)
|
ifeq ($(enable_grub_emu_pci), yes)
|
||||||
pkglib_MODULES += pci.mod
|
pkglib_MODULES += pci.mod
|
||||||
pci_mod_SOURCES = util/pci.c commands/lspci.c
|
pci_mod_SOURCES = bus/emu/pci.c commands/lspci.c
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||||
kernel_img_HEADERS += libpciaccess.h
|
kernel_img_HEADERS += libpciaccess.h
|
||||||
|
@ -101,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) > $@
|
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
|
||||||
DISTCLEANFILES += grub_emu_init.c
|
DISTCLEANFILES += grub_emu_init.c
|
||||||
|
|
||||||
CLEANFILES += grub-emu
|
grub_emu_init.o: grub_emu_init.c grub_emu_init.h
|
||||||
ifneq ($(TARGET_NO_MODULES), yes)
|
rm -f $@; $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -DGRUB_FILE=\"grub_init.c\" -c -o $@ $<
|
||||||
grub-emu: $(pkglib_PROGRAMS)
|
CLEANFILES += grub_emu_init.o
|
||||||
$(CC) -o $@ $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
|
||||||
else
|
|
||||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
|
||||||
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
|
||||||
endif
|
|
||||||
GRUB_EMU=grub-emu
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
|
@ -6,7 +6,7 @@ script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||||
sbin_UTILITIES += grub-mkdevicemap
|
sbin_UTILITIES += grub-mkdevicemap
|
||||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||||
util/deviceiter.c \
|
util/deviceiter.c \
|
||||||
util/misc.c
|
util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
||||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
||||||
|
@ -16,16 +16,15 @@ endif
|
||||||
|
|
||||||
# For grub-mkelfimage.
|
# For grub-mkelfimage.
|
||||||
bin_UTILITIES += grub-mkelfimage
|
bin_UTILITIES += grub-mkelfimage
|
||||||
grub_mkelfimage_SOURCES = gnulib/progname.c \
|
grub_mkelfimage_SOURCES = gnulib/progname.c util/elf/grub-mkimage.c \
|
||||||
util/elf/grub-mkimage.c util/misc.c \
|
util/misc.c kern/emu/misc.c util/resolve.c
|
||||||
util/resolve.c
|
|
||||||
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# For grub-probe.
|
# For grub-probe.
|
||||||
sbin_UTILITIES += grub-probe
|
sbin_UTILITIES += grub-probe
|
||||||
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
||||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||||
util/hostdisk.c util/misc.c util/getroot.c util/mm.c \
|
kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c \
|
||||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
||||||
\
|
\
|
||||||
|
@ -60,8 +59,8 @@ grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||||
|
|
||||||
# For grub-fstest.
|
# For grub-fstest.
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
||||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \
|
||||||
util/misc.c util/mm.c \
|
util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
||||||
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
||||||
|
@ -83,14 +82,14 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
||||||
# For grub-mkfont.
|
# For grub-mkfont.
|
||||||
ifeq ($(enable_grub_mkfont), yes)
|
ifeq ($(enable_grub_mkfont), yes)
|
||||||
bin_UTILITIES += grub-mkfont
|
bin_UTILITIES += grub-mkfont
|
||||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c
|
||||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
grub_mkfont_CFLAGS = $(freetype_cflags)
|
||||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
grub_mkfont_LDFLAGS = $(freetype_libs)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# For grub-mkrelpath.
|
# For grub-mkrelpath.
|
||||||
bin_UTILITIES += grub-mkrelpath
|
bin_UTILITIES += grub-mkrelpath
|
||||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
bin_UTILITIES += grub-bin2h
|
bin_UTILITIES += grub-bin2h
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||||
|
@ -104,7 +103,7 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
bin_UTILITIES += grub-script-check
|
bin_UTILITIES += grub-script-check
|
||||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||||
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
||||||
util/grub-script-check.c util/misc.c util/mm.c \
|
util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
script/main.c script/script.c script/function.c script/lexer.c \
|
script/main.c script/script.c script/function.c script/lexer.c \
|
||||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||||
|
@ -187,7 +186,7 @@ DISTCLEANFILES += grub_fstest_init.c
|
||||||
|
|
||||||
# for grub-editenv
|
# for grub-editenv
|
||||||
bin_UTILITIES += grub-editenv
|
bin_UTILITIES += grub-editenv
|
||||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c util/mm.c kern/misc.c kern/err.c
|
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/misc.c kern/err.c
|
||||||
CLEANFILES += grub-editenv
|
CLEANFILES += grub-editenv
|
||||||
|
|
||||||
# Needed for genmk.rb to work
|
# Needed for genmk.rb to work
|
||||||
|
@ -195,7 +194,7 @@ ifeq (0,1)
|
||||||
bin_UTILITIES += grub-macho2img grub-pe2elf
|
bin_UTILITIES += grub-macho2img grub-pe2elf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c
|
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c kern/emu/misc.c
|
||||||
CLEANFILES += grub-pe2elf
|
CLEANFILES += grub-pe2elf
|
||||||
|
|
||||||
grub_macho2img_SOURCES = util/grub-macho2img.c
|
grub_macho2img_SOURCES = util/grub-macho2img.c
|
||||||
|
@ -861,7 +860,7 @@ boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
||||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c util/mm.c kern/err.c
|
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/err.c
|
||||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
||||||
|
|
||||||
include $(srcdir)/conf/gcry.mk
|
include $(srcdir)/conf/gcry.mk
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/lvm.h>
|
#include <grub/lvm.h>
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct grub_lvm_vg *vg_list;
|
static struct grub_lvm_vg *vg_list;
|
||||||
|
|
|
@ -105,13 +105,13 @@ int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||||
int EXPORT_FUNC(grub_dl_unref) (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));
|
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
|
||||||
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
||||||
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr,
|
||||||
grub_dl_t mod);
|
grub_dl_t mod);
|
||||||
|
|
||||||
grub_err_t grub_arch_dl_check_header (void *ehdr);
|
grub_err_t grub_arch_dl_check_header (void *ehdr);
|
||||||
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
||||||
|
|
||||||
#if defined (_mips)
|
#if defined (_mips) && ! GRUB_MACHINE_EMU
|
||||||
#define GRUB_LINKER_HAVE_INIT 1
|
#define GRUB_LINKER_HAVE_INIT 1
|
||||||
void grub_arch_dl_init_linker (void);
|
void grub_arch_dl_init_linker (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,12 +4,24 @@
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
/* NetBSD uses /boot for its boot block. */
|
||||||
|
# define DEFAULT_DIRECTORY "/grub"
|
||||||
|
#else
|
||||||
|
# define DEFAULT_DIRECTORY "/boot/grub"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
|
||||||
|
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
extern const char *program_name;
|
extern const char *program_name;
|
||||||
|
|
||||||
|
void grub_emu_init (void);
|
||||||
void grub_init_all (void);
|
void grub_init_all (void);
|
||||||
void grub_fini_all (void);
|
void grub_fini_all (void);
|
||||||
|
|
||||||
|
char *grub_make_system_path_relative_to_its_root (const char *path);
|
||||||
|
|
||||||
void * EXPORT_FUNC(xmalloc) (grub_size_t size);
|
void * EXPORT_FUNC(xmalloc) (grub_size_t size);
|
||||||
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size);
|
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size);
|
||||||
char * EXPORT_FUNC(xstrdup) (const char *str);
|
char * EXPORT_FUNC(xstrdup) (const char *str);
|
||||||
|
@ -19,4 +31,14 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
||||||
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
||||||
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
int EXPORT_FUNC(vasprintf) (char **buf, const char *fmt, va_list ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||||
|
|
||||||
#endif /* GRUB_EMU_MISC_H */
|
#endif /* GRUB_EMU_MISC_H */
|
||||||
|
|
|
@ -50,6 +50,9 @@
|
||||||
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
||||||
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
|
#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);
|
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_strcpy) (char *dest, const char *src);
|
||||||
char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
|
char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
|
||||||
|
|
|
@ -28,15 +28,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#ifdef __NetBSD__
|
|
||||||
/* NetBSD uses /boot for its boot block. */
|
|
||||||
# define DEFAULT_DIRECTORY "/grub"
|
|
||||||
#else
|
|
||||||
# define DEFAULT_DIRECTORY "/boot/grub"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
|
|
||||||
|
|
||||||
char *grub_util_get_path (const char *dir, const char *file);
|
char *grub_util_get_path (const char *dir, const char *file);
|
||||||
size_t grub_util_get_fp_size (FILE *fp);
|
size_t grub_util_get_fp_size (FILE *fp);
|
||||||
|
@ -48,18 +40,6 @@ void grub_util_write_image (const char *img, size_t size, FILE *out);
|
||||||
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
||||||
FILE *out);
|
FILE *out);
|
||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
|
||||||
|
|
||||||
int vasprintf (char **buf, const char *fmt, va_list ap);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int asprintf (char **buf, const char *fmt, ...);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
#define fseeko fseeko64
|
#define fseeko fseeko64
|
||||||
|
|
|
@ -474,7 +474,8 @@ grub_dl_ref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
if (!mod) return 0;
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_ref (dep->mod);
|
grub_dl_ref (dep->mod);
|
||||||
|
@ -487,7 +488,8 @@ grub_dl_unref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
if (!mod) return 0;
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_unref (dep->mod);
|
grub_dl_unref (dep->mod);
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
#error "This source is only meant for grub-emu platform"
|
#error "This source is only meant for grub-emu platform"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GRUB_CPU_I386
|
#if defined(GRUB_CPU_I386)
|
||||||
#elif GRUB_CPU_X86_64
|
/* Nothing is necessary. */
|
||||||
#elif GRUB_CPU_SPARC64
|
#elif defined(GRUB_CPU_X86_64)
|
||||||
|
/* Nothing is necessary. */
|
||||||
|
#elif defined(GRUB_CPU_SPARC64)
|
||||||
#include "../sparc64/cache.S"
|
#include "../sparc64/cache.S"
|
||||||
#elif GRUB_CPU_MIPS
|
#elif defined(GRUB_CPU_MIPS)
|
||||||
#include "../mips/cache.S"
|
#include "../mips/cache.S"
|
||||||
#elif GRUB_CPU_MIPSEL
|
#elif defined(GRUB_CPU_MIPSEL)
|
||||||
#include "../mips/cache.S"
|
#include "../mips/cache.S"
|
||||||
#elif GRUB_CPU_POWERPC
|
#elif defined(GRUB_CPU_POWERPC)
|
||||||
#include "../powerpc/cache.S"
|
#include "../powerpc/cache.S"
|
||||||
#else
|
#else
|
||||||
#error "No target cpu type is defined"
|
#error "No target cpu type is defined"
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef GRUB_MACHINE_EMU
|
|
||||||
#error "This source is only meant for grub-emu platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if GRUB_CPU_I386
|
|
||||||
#include "../i386/dl.c"
|
|
||||||
#elif GRUB_CPU_X86_64
|
|
||||||
#include "../x86_64/dl.c"
|
|
||||||
#elif GRUB_CPU_SPARC64
|
|
||||||
#include "../sparc64/dl.c"
|
|
||||||
#elif GRUB_CPU_MIPS
|
|
||||||
#include "../mips/dl.c"
|
|
||||||
#elif GRUB_CPU_MIPSEL
|
|
||||||
#include "../mips/dl.c"
|
|
||||||
#elif GRUB_CPU_POWERPC
|
|
||||||
#include "../powerpc/dl.c"
|
|
||||||
#else
|
|
||||||
#error "No target cpu type is defined"
|
|
||||||
#endif
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
#include <grub/kernel.h>
|
|
||||||
#include <grub/emu/misc.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_register_exported_symbols (void)
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -18,12 +18,20 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/kernel.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_register_exported_symbols (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_arch_dl_check_header (void *ehdr)
|
grub_arch_dl_check_header (void *ehdr)
|
||||||
{
|
{
|
||||||
(void) ehdr;
|
(void) ehdr;
|
||||||
|
|
||||||
return GRUB_ERR_BAD_MODULE;
|
return GRUB_ERR_BAD_MODULE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,20 +40,11 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||||
{
|
{
|
||||||
(void) mod;
|
(void) mod;
|
||||||
(void) ehdr;
|
(void) ehdr;
|
||||||
|
|
||||||
return GRUB_ERR_BAD_MODULE;
|
return GRUB_ERR_BAD_MODULE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int */
|
void
|
||||||
/* grub_dl_ref (grub_dl_t mod) */
|
grub_emu_init (void)
|
||||||
/* { */
|
{
|
||||||
/* (void) mod; */
|
grub_no_autoload = 1;
|
||||||
/* return 0; */
|
}
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* int */
|
|
||||||
/* grub_dl_unref (grub_dl_t mod) */
|
|
||||||
/* { */
|
|
||||||
/* (void) mod; */
|
|
||||||
/* return 0; */
|
|
||||||
/* } */
|
|
|
@ -27,13 +27,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
# include <sys/fcntl.h>
|
|
||||||
# include <sys/cygwin.h>
|
|
||||||
# include <limits.h>
|
|
||||||
# define DEV_CYGDRIVE_MAJOR 98
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNU__
|
#ifdef __GNU__
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/lookup.h>
|
#include <hurd/lookup.h>
|
||||||
|
@ -546,101 +539,3 @@ grub_util_check_char_device (const char *blk_dev)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function never prints trailing slashes (so that its output
|
|
||||||
can be appended a slash unconditionally). */
|
|
||||||
char *
|
|
||||||
grub_make_system_path_relative_to_its_root (const char *path)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
char *p, *buf, *buf2, *buf3;
|
|
||||||
uintptr_t offset = 0;
|
|
||||||
dev_t num;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* canonicalize. */
|
|
||||||
p = canonicalize_file_name (path);
|
|
||||||
|
|
||||||
if (p == NULL)
|
|
||||||
grub_util_error ("failed to get canonical path of %s", path);
|
|
||||||
|
|
||||||
len = strlen (p) + 1;
|
|
||||||
buf = xstrdup (p);
|
|
||||||
free (p);
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
buf2 = xstrdup (buf);
|
|
||||||
num = st.st_dev;
|
|
||||||
|
|
||||||
/* This loop sets offset to the number of chars of the root
|
|
||||||
directory we're inspecting. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
p = strrchr (buf, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
/* This should never happen. */
|
|
||||||
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
|
||||||
if (p != buf)
|
|
||||||
*p = 0;
|
|
||||||
else
|
|
||||||
*++p = 0;
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
/* buf is another filesystem; we found it. */
|
|
||||||
if (st.st_dev != num)
|
|
||||||
{
|
|
||||||
/* offset == 0 means path given is the mount point.
|
|
||||||
This works around special-casing of "/" in Un*x. This function never
|
|
||||||
prints trailing slashes (so that its output can be appended a slash
|
|
||||||
unconditionally). Each slash in is considered a preceding slash, and
|
|
||||||
therefore the root directory is an empty string. */
|
|
||||||
if (offset == 0)
|
|
||||||
{
|
|
||||||
free (buf);
|
|
||||||
free (buf2);
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = p - buf;
|
|
||||||
/* offset == 1 means root directory. */
|
|
||||||
if (offset == 1)
|
|
||||||
{
|
|
||||||
/* Include leading slash. */
|
|
||||||
offset = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free (buf);
|
|
||||||
buf3 = xstrdup (buf2 + offset);
|
|
||||||
free (buf2);
|
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
|
||||||
{
|
|
||||||
/* Reached some mount point not below /cygdrive.
|
|
||||||
GRUB does not know Cygwin's emulated mounts,
|
|
||||||
convert to Win32 path. */
|
|
||||||
grub_util_info ("Cygwin path = %s\n", buf3);
|
|
||||||
char * temp = get_win32_path (buf3);
|
|
||||||
free (buf3);
|
|
||||||
buf3 = temp;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Remove trailing slashes, return empty string if root directory. */
|
|
||||||
len = strlen (buf3);
|
|
||||||
while (len > 0 && buf3[len - 1] == '/')
|
|
||||||
{
|
|
||||||
buf3[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf3;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,42 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/emu/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
|
|
||||||
|
#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
|
/* grub-emu-lite supports dynamic module loading, so it won't have any
|
||||||
embedded modules. */
|
embedded modules. */
|
||||||
void
|
void
|
||||||
grub_init_all(void)
|
grub_init_all (void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_fini_all(void)
|
grub_fini_all (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_emu_init (void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/setjmp.h>
|
#include <grub/setjmp.h>
|
||||||
#include <grub/fs.h>
|
#include <grub/fs.h>
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
#include <grub/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/emu/console.h>
|
#include <grub/emu/console.h>
|
||||||
#include <grub/emu/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/util/misc.h>
|
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/emu/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
|
@ -136,6 +136,7 @@ void grub_hostfs_init (void);
|
||||||
void grub_hostfs_fini (void);
|
void grub_hostfs_fini (void);
|
||||||
void grub_host_init (void);
|
void grub_host_init (void);
|
||||||
void grub_host_fini (void);
|
void grub_host_fini (void);
|
||||||
|
void grub_emu_init (void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
|
@ -194,6 +195,7 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
signal (SIGINT, SIG_IGN);
|
signal (SIGINT, SIG_IGN);
|
||||||
|
grub_emu_init ();
|
||||||
grub_console_init ();
|
grub_console_init ();
|
||||||
grub_host_init ();
|
grub_host_init ();
|
||||||
grub_hostfs_init ();
|
grub_hostfs_init ();
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
|
@ -62,70 +66,14 @@ grub_util_error (const char *fmt, ...)
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
grub_malloc (grub_size_t size)
|
|
||||||
{
|
|
||||||
return malloc (size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_zalloc (grub_size_t size)
|
|
||||||
{
|
|
||||||
void *ret;
|
|
||||||
|
|
||||||
ret = malloc (size);
|
|
||||||
memset (ret, 0, size);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_free (void *ptr)
|
|
||||||
{
|
|
||||||
free (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_realloc (void *ptr, grub_size_t size)
|
|
||||||
{
|
|
||||||
return realloc (ptr, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_memalign (grub_size_t align, grub_size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
#if defined(HAVE_POSIX_MEMALIGN)
|
|
||||||
if (align < sizeof (void *))
|
|
||||||
align = sizeof (void *);
|
|
||||||
|
|
||||||
else if (align % sizeof (void *))
|
|
||||||
grub_fatal ("bad alignment");
|
|
||||||
|
|
||||||
if (posix_memalign (&p, align, size) != 0)
|
|
||||||
p = 0;
|
|
||||||
#elif defined(HAVE_MEMALIGN)
|
|
||||||
p = memalign (align, size);
|
|
||||||
#else
|
|
||||||
(void) align;
|
|
||||||
(void) size;
|
|
||||||
grub_fatal ("grub_memalign is not supported");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (! p)
|
|
||||||
grub_fatal ("out of memory");
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xmalloc (grub_size_t size)
|
xmalloc (grub_size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
p = grub_malloc (size);
|
p = malloc (size);
|
||||||
if (! p)
|
if (! p)
|
||||||
grub_fatal ("out of memory");
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -133,9 +81,9 @@ xmalloc (grub_size_t size)
|
||||||
void *
|
void *
|
||||||
xrealloc (void *ptr, grub_size_t size)
|
xrealloc (void *ptr, grub_size_t size)
|
||||||
{
|
{
|
||||||
ptr = grub_realloc (ptr, size);
|
ptr = realloc (ptr, size);
|
||||||
if (! ptr)
|
if (! ptr)
|
||||||
grub_fatal ("out of memory");
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -146,13 +94,43 @@ xstrdup (const char *str)
|
||||||
size_t len;
|
size_t len;
|
||||||
char *newstr;
|
char *newstr;
|
||||||
|
|
||||||
len = grub_strlen (str);
|
len = strlen (str);
|
||||||
newstr = (char *) xmalloc (len + 1);
|
newstr = (char *) xmalloc (len + 1);
|
||||||
grub_memcpy (newstr, str, len + 1);
|
memcpy (newstr, str, len + 1);
|
||||||
|
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
vasprintf (char **buf, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
/* Should be large enough. */
|
||||||
|
*buf = xmalloc (512);
|
||||||
|
|
||||||
|
return vsprintf (*buf, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
asprintf (char **buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
status = vasprintf (*buf, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
xasprintf (const char *fmt, ...)
|
xasprintf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -197,3 +175,102 @@ grub_get_rtc (void)
|
||||||
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
||||||
* GRUB_TICKS_PER_SECOND / 1000000));
|
* GRUB_TICKS_PER_SECOND / 1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This function never prints trailing slashes (so that its output
|
||||||
|
can be appended a slash unconditionally). */
|
||||||
|
char *
|
||||||
|
grub_make_system_path_relative_to_its_root (const char *path)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *p, *buf, *buf2, *buf3;
|
||||||
|
uintptr_t offset = 0;
|
||||||
|
dev_t num;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* canonicalize. */
|
||||||
|
p = canonicalize_file_name (path);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
grub_util_error ("failed to get canonical path of %s", path);
|
||||||
|
|
||||||
|
len = strlen (p) + 1;
|
||||||
|
buf = xstrdup (p);
|
||||||
|
free (p);
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
buf2 = xstrdup (buf);
|
||||||
|
num = st.st_dev;
|
||||||
|
|
||||||
|
/* This loop sets offset to the number of chars of the root
|
||||||
|
directory we're inspecting. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
p = strrchr (buf, '/');
|
||||||
|
if (p == NULL)
|
||||||
|
/* This should never happen. */
|
||||||
|
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
||||||
|
if (p != buf)
|
||||||
|
*p = 0;
|
||||||
|
else
|
||||||
|
*++p = 0;
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
/* buf is another filesystem; we found it. */
|
||||||
|
if (st.st_dev != num)
|
||||||
|
{
|
||||||
|
/* offset == 0 means path given is the mount point.
|
||||||
|
This works around special-casing of "/" in Un*x. This function never
|
||||||
|
prints trailing slashes (so that its output can be appended a slash
|
||||||
|
unconditionally). Each slash in is considered a preceding slash, and
|
||||||
|
therefore the root directory is an empty string. */
|
||||||
|
if (offset == 0)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
free (buf2);
|
||||||
|
return xstrdup ("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = p - buf;
|
||||||
|
/* offset == 1 means root directory. */
|
||||||
|
if (offset == 1)
|
||||||
|
{
|
||||||
|
/* Include leading slash. */
|
||||||
|
offset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (buf);
|
||||||
|
buf3 = xstrdup (buf2 + offset);
|
||||||
|
free (buf2);
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||||
|
{
|
||||||
|
/* Reached some mount point not below /cygdrive.
|
||||||
|
GRUB does not know Cygwin's emulated mounts,
|
||||||
|
convert to Win32 path. */
|
||||||
|
grub_util_info ("Cygwin path = %s\n", buf3);
|
||||||
|
char * temp = get_win32_path (buf3);
|
||||||
|
free (buf3);
|
||||||
|
buf3 = temp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Remove trailing slashes, return empty string if root directory. */
|
||||||
|
len = strlen (buf3);
|
||||||
|
while (len > 0 && buf3[len - 1] == '/')
|
||||||
|
{
|
||||||
|
buf3[len - 1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf3;
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <grub/reader.h>
|
#include <grub/reader.h>
|
||||||
#include <grub/parser.h>
|
#include <grub/parser.h>
|
||||||
|
|
||||||
|
int grub_no_autoload;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,8 @@ kernel = {
|
||||||
mips_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK';
|
mips_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK';
|
||||||
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
|
||||||
i386_qemu_ccasflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
|
i386_qemu_ccasflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
|
||||||
|
emu_cflags = '$(CFLAGS_GNULIB)';
|
||||||
|
emu_cppflags = '$(CPPFLAGS_GNULIB)';
|
||||||
|
|
||||||
mips_ldadd = '-lgcc';
|
mips_ldadd = '-lgcc';
|
||||||
powerpc_ldadd = '-lgcc';
|
powerpc_ldadd = '-lgcc';
|
||||||
|
@ -187,6 +189,8 @@ kernel = {
|
||||||
sparc64_ieee1275 = disk/ieee1275/ofdisk.c;
|
sparc64_ieee1275 = disk/ieee1275/ofdisk.c;
|
||||||
sparc64_ieee1275 = term/ieee1275/ofconsole.c;
|
sparc64_ieee1275 = term/ieee1275/ofconsole.c;
|
||||||
|
|
||||||
|
emu = kern/emu/mm.c;
|
||||||
|
emu = kern/emu/main.c;
|
||||||
emu = kern/emu/misc.c;
|
emu = kern/emu/misc.c;
|
||||||
emu = kern/emu/getroot.c;
|
emu = kern/emu/getroot.c;
|
||||||
emu = kern/emu/time.c;
|
emu = kern/emu/time.c;
|
||||||
|
@ -194,6 +198,7 @@ kernel = {
|
||||||
emu = kern/emu/hostfs.c;
|
emu = kern/emu/hostfs.c;
|
||||||
emu = kern/emu/console.c;
|
emu = kern/emu/console.c;
|
||||||
emu = disk/host.c;
|
emu = disk/host.c;
|
||||||
|
emu = gnulib/progname.c;
|
||||||
|
|
||||||
image_nostrip = { emu; };
|
image_nostrip = { emu; };
|
||||||
image_strip_keep_kernel = { i386_efi; x86_64_efi; };
|
image_strip_keep_kernel = { i386_efi; x86_64_efi; };
|
||||||
|
@ -205,16 +210,9 @@ program = {
|
||||||
name = grub-emu;
|
name = grub-emu;
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
source = kern/emu/main.c;
|
source = kern/emu/full.c;
|
||||||
source = kern/emu/dummy/dl.c;
|
|
||||||
source = kern/emu/dummy/symlist.c;
|
|
||||||
source = gnulib/progname.c;
|
|
||||||
|
|
||||||
nodist = grub_emu_init.c;
|
nodist = grub_emu_init.c;
|
||||||
|
|
||||||
cflags = '$(CFLAGS_GNULIB)';
|
|
||||||
cppflags = '$(CPPFLAGS_GNULIB)';
|
|
||||||
|
|
||||||
ldadd = kernel.exec;
|
ldadd = kernel.exec;
|
||||||
ldadd = '$(MODULE_FILES)';
|
ldadd = '$(MODULE_FILES)';
|
||||||
ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
|
ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
|
||||||
|
@ -225,16 +223,10 @@ program = {
|
||||||
program = {
|
program = {
|
||||||
name = grub-emu-lite;
|
name = grub-emu-lite;
|
||||||
|
|
||||||
source = kern/emu/main.c;
|
|
||||||
source = kern/emu/lite.c;
|
source = kern/emu/lite.c;
|
||||||
source = kern/emu/dl.c;
|
|
||||||
source = kern/emu/cache.S;
|
source = kern/emu/cache.S;
|
||||||
source = gnulib/progname.c;
|
|
||||||
nodist = symlist.c;
|
nodist = symlist.c;
|
||||||
|
|
||||||
cflags = '$(CFLAGS_GNULIB)';
|
|
||||||
cppflags = '$(CPPFLAGS_GNULIB)';
|
|
||||||
|
|
||||||
ldadd = kernel.exec;
|
ldadd = kernel.exec;
|
||||||
ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
|
ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
|
||||||
|
|
||||||
|
|
|
@ -476,10 +476,13 @@ grub_normal_init_page (struct grub_term_output *term)
|
||||||
static void
|
static void
|
||||||
read_lists (const char *val)
|
read_lists (const char *val)
|
||||||
{
|
{
|
||||||
read_command_list (val);
|
if (! grub_no_autoload)
|
||||||
read_fs_list (val);
|
{
|
||||||
read_crypto_list (val);
|
read_command_list (val);
|
||||||
read_terminal_list (val);
|
read_fs_list (val);
|
||||||
|
read_crypto_list (val);
|
||||||
|
read_terminal_list (val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
|
@ -19,6 +19,7 @@ library = {
|
||||||
|
|
||||||
source = util/misc.c;
|
source = util/misc.c;
|
||||||
source = grub-core/kern/misc.c;
|
source = grub-core/kern/misc.c;
|
||||||
|
source = grub-core/kern/emu/mm.c;
|
||||||
source = grub-core/kern/emu/misc.c;
|
source = grub-core/kern/emu/misc.c;
|
||||||
source = grub-core/kern/emu/hostfs.c;
|
source = grub-core/kern/emu/hostfs.c;
|
||||||
source = grub-core/kern/emu/getroot.c;
|
source = grub-core/kern/emu/getroot.c;
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
#include <grub/emu/getroot.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/emu/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/util/misc.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
|
|
46
util/misc.c
46
util/misc.c
|
@ -278,7 +278,34 @@ grub_mm_init_region (void *addr __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !(defined (__i386__) || defined (__x86_64__))
|
void
|
||||||
|
grub_register_exported_symbols (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
Sleep (ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ts.tv_sec = ms / 1000;
|
||||||
|
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||||
|
nanosleep (&ts, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_MACHINE_EMU
|
||||||
void
|
void
|
||||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||||
grub_size_t len __attribute__ ((unused)))
|
grub_size_t len __attribute__ ((unused)))
|
||||||
|
@ -286,23 +313,6 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int
|
|
||||||
asprintf (char **buf, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
status = vasprintf (*buf, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
void sync (void)
|
void sync (void)
|
||||||
|
|
Loading…
Reference in a new issue