module support in grub-emu
This commit is contained in:
parent
f38873b80b
commit
3dca5319c6
5 changed files with 27 additions and 71 deletions
|
@ -7,7 +7,6 @@ COMMON_CFLAGS +=
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||||
|
|
||||||
#sbin_UTILITIES += grub-emu
|
#sbin_UTILITIES += grub-emu
|
||||||
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
|
|
||||||
kernel_img_RELOCATABLE = yes
|
kernel_img_RELOCATABLE = yes
|
||||||
pkglib_PROGRAMS = kernel.img
|
pkglib_PROGRAMS = kernel.img
|
||||||
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||||
|
@ -18,9 +17,9 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.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 \
|
util/console.c util/grub-emu.c util/misc.c \
|
||||||
util/hostdisk.c util/getroot.c \
|
util/hostdisk.c util/getroot.c util/mm.c \
|
||||||
\
|
\
|
||||||
gnulib/progname.c util/hostfs.c
|
gnulib/progname.c util/hostfs.c disk/host.c
|
||||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||||
|
@ -30,9 +29,15 @@ kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
TARGET_NO_STRIP = yes
|
TARGET_NO_STRIP = yes
|
||||||
|
|
||||||
ifneq ($(TARGET_NO_MODULES), yes)
|
ifneq ($(TARGET_NO_MODULES), yes)
|
||||||
kernel_img_SOURCES += symlist.c
|
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
|
else
|
||||||
kernel_img_SOURCES += grub_emu_init.c
|
kernel_img_SOURCES += grub_emu_init.c
|
||||||
|
grub_emu_init.c_DEPENDENCIES = grub_emu_init.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# For boot.mod.
|
# For boot.mod.
|
||||||
|
@ -41,12 +46,6 @@ boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For host.mod.
|
|
||||||
pkglib_MODULES += host.mod
|
|
||||||
host_mod_SOURCES = disk/host.c
|
|
||||||
host_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
host_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For reboot.mod.
|
# For reboot.mod.
|
||||||
pkglib_MODULES += reboot.mod
|
pkglib_MODULES += reboot.mod
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
reboot_mod_SOURCES = commands/reboot.c
|
||||||
|
|
|
@ -22,7 +22,7 @@ util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
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/hostdisk.c util/misc.c util/getroot.c util/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/parser.c kern/partition.c kern/file.c \
|
||||||
\
|
\
|
||||||
|
@ -57,7 +57,7 @@ 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 util/hostfs.c \
|
||||||
util/misc.c \
|
util/misc.c util/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 \
|
||||||
|
@ -95,7 +95,7 @@ grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||||
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/grub-script-check.c util/misc.c util/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
|
||||||
|
@ -159,7 +159,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 kern/misc.c kern/err.c
|
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
|
||||||
CLEANFILES += grub-editenv
|
CLEANFILES += grub-editenv
|
||||||
|
|
||||||
# Needed for genmk.rb to work
|
# Needed for genmk.rb to work
|
||||||
|
@ -760,7 +760,7 @@ password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
password_pbkdf2_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 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 util/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
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
#include <grub_emu_init.h>
|
|
||||||
|
|
||||||
#define ENABLE_RELOCATABLE 0
|
#define ENABLE_RELOCATABLE 0
|
||||||
#include "progname.h"
|
#include "progname.h"
|
||||||
|
|
||||||
|
@ -55,6 +53,7 @@ grub_arch_modules_addr (void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GRUB_NO_MODULES
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_arch_dl_check_header (void *ehdr)
|
grub_arch_dl_check_header (void *ehdr)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
|
||||||
|
|
||||||
return GRUB_ERR_BAD_MODULE;
|
return GRUB_ERR_BAD_MODULE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_reboot (void)
|
grub_reboot (void)
|
||||||
|
@ -148,6 +148,8 @@ usage (int status)
|
||||||
|
|
||||||
void grub_hostfs_init (void);
|
void grub_hostfs_init (void);
|
||||||
void grub_hostfs_fini (void);
|
void grub_hostfs_fini (void);
|
||||||
|
void grub_host_init (void);
|
||||||
|
void grub_host_fini (void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
|
@ -207,6 +209,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
signal (SIGINT, SIG_IGN);
|
signal (SIGINT, SIG_IGN);
|
||||||
grub_console_init ();
|
grub_console_init ();
|
||||||
|
grub_host_init ();
|
||||||
grub_hostfs_init ();
|
grub_hostfs_init ();
|
||||||
|
|
||||||
/* XXX: This is a bit unportable. */
|
/* XXX: This is a bit unportable. */
|
||||||
|
@ -232,7 +235,10 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = grub_get_prefix (dir);
|
if (strcmp (root_dev, "host") == 0)
|
||||||
|
dir = xstrdup (dir);
|
||||||
|
else
|
||||||
|
dir = grub_get_prefix (dir);
|
||||||
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
||||||
sprintf (prefix, "(%s)%s", root_dev, dir);
|
sprintf (prefix, "(%s)%s", root_dev, dir);
|
||||||
free (dir);
|
free (dir);
|
||||||
|
@ -245,6 +251,7 @@ main (int argc, char *argv[])
|
||||||
grub_fini_all ();
|
grub_fini_all ();
|
||||||
#endif
|
#endif
|
||||||
grub_hostfs_fini ();
|
grub_hostfs_fini ();
|
||||||
|
grub_host_fini ();
|
||||||
|
|
||||||
grub_machine_fini ();
|
grub_machine_fini ();
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
|
||||||
|
|
||||||
drive = find_grub_drive (name);
|
drive = find_grub_drive (name);
|
||||||
if (drive < 0)
|
if (drive < 0)
|
||||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||||
"no mapping exists for `%s'", name);
|
"no mapping exists for `%s'", name);
|
||||||
|
|
||||||
disk->has_partitions = 1;
|
disk->has_partitions = 1;
|
||||||
|
@ -949,7 +949,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
||||||
drive = find_system_device (os_dev);
|
drive = find_system_device (os_dev);
|
||||||
if (drive < 0)
|
if (drive < 0)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||||
"no mapping exists for `%s'", os_dev);
|
"no mapping exists for `%s'", os_dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
52
util/misc.c
52
util/misc.c
|
@ -262,56 +262,6 @@ grub_util_write_image (const char *img, size_t size, FILE *out)
|
||||||
grub_util_error ("write failed");
|
grub_util_error ("write failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
grub_malloc (grub_size_t size)
|
|
||||||
{
|
|
||||||
return xmalloc (size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_zalloc (grub_size_t size)
|
|
||||||
{
|
|
||||||
void *ret;
|
|
||||||
|
|
||||||
ret = xmalloc (size);
|
|
||||||
memset (ret, 0, size);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_free (void *ptr)
|
|
||||||
{
|
|
||||||
free (ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_realloc (void *ptr, grub_size_t size)
|
|
||||||
{
|
|
||||||
return xrealloc (ptr, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
grub_memalign (grub_size_t align, grub_size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
#if defined(HAVE_POSIX_MEMALIGN)
|
|
||||||
if (posix_memalign (&p, align, size) != 0)
|
|
||||||
p = 0;
|
|
||||||
#elif defined(HAVE_MEMALIGN)
|
|
||||||
p = memalign (align, size);
|
|
||||||
#else
|
|
||||||
(void) align;
|
|
||||||
(void) size;
|
|
||||||
grub_util_error ("grub_memalign is not supported");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (! p)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some functions that we don't use. */
|
/* Some functions that we don't use. */
|
||||||
void
|
void
|
||||||
grub_mm_init_region (void *addr __attribute__ ((unused)),
|
grub_mm_init_region (void *addr __attribute__ ((unused)),
|
||||||
|
@ -376,7 +326,7 @@ grub_millisleep (grub_uint32_t ms)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(defined (__i386__) || defined (__x86_64__))
|
#if !(defined (__i386__) || defined (__x86_64__)) && GRUB_NO_MODULES
|
||||||
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)))
|
||||||
|
|
Loading…
Reference in a new issue