From b255e9cfb3939bd36f039e269d30e718ac00d62d Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Sun, 7 Feb 2010 16:02:51 +0100 Subject: [PATCH 1/7] 2010-02-07 Yves Blusseau * gnulib/getdelim.c: add missing header (type ssize_t must be defined). --- ChangeLog | 4 ++++ gnulib/getdelim.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index ec3318c5b..540639220 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-07 Yves Blusseau + + * gnulib/getdelim.c: add missing header (type ssize_t must be defined). + 2010-02-07 Vladimir Serbinenko Fix warnings in grub-emu when compiling with maximum warning options. diff --git a/gnulib/getdelim.c b/gnulib/getdelim.c index 12f2167c9..85818b565 100644 --- a/gnulib/getdelim.c +++ b/gnulib/getdelim.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifndef SSIZE_MAX # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) From ac307b2ae4e58d2854281bf4a00527b778a4dd2b Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 16:47:50 +0100 Subject: [PATCH 2/7] Cleanup --- Makefile.in | 6 ++++-- conf/any-emu.rmk | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 820bfa946..7af2df1f0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,8 +89,10 @@ TARGET_ASFLAGS = @TARGET_ASFLAGS@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \ - -Wall -W +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -W +ifneq ($(platform), emu) +TARGET_CPPFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) +endif TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@ TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@ diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 77092454b..529174bc3 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -6,7 +6,6 @@ COMMON_CFLAGS += # 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 kernel_img_RELOCATABLE = yes pkglib_PROGRAMS = kernel.img From 62853e73e5b455f2208d3ba410736a4bd0b407d9 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 16:48:11 +0100 Subject: [PATCH 3/7] ChangeLog --- ChangeLog.emu-mod | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ChangeLog.emu-mod diff --git a/ChangeLog.emu-mod b/ChangeLog.emu-mod new file mode 100644 index 000000000..7ebdecdd8 --- /dev/null +++ b/ChangeLog.emu-mod @@ -0,0 +1,57 @@ +2010-02-07 Vladimir Serbinenko + + 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. From 6e14234c874224e88345492373c77eee34d00e18 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 16:51:16 +0100 Subject: [PATCH 4/7] 2010-02-07 Vladimir Serbinenko * include/grub/multiboot2.h: Remove leftover file. --- ChangeLog | 6 +++- include/grub/multiboot2.h | 70 --------------------------------------- 2 files changed, 5 insertions(+), 71 deletions(-) delete mode 100644 include/grub/multiboot2.h diff --git a/ChangeLog b/ChangeLog index 540639220..7e9e18348 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2010-02-07 Vladimir Serbinenko + + * include/grub/multiboot2.h: Remove leftover file. + 2010-02-07 Yves Blusseau - * gnulib/getdelim.c: add missing header (type ssize_t must be defined). + * gnulib/getdelim.c: add missing header (type ssize_t must be defined). 2010-02-07 Vladimir Serbinenko diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h deleted file mode 100644 index af10cdc21..000000000 --- a/include/grub/multiboot2.h +++ /dev/null @@ -1,70 +0,0 @@ -/* multiboot2.h - multiboot2 header file with grub definitions. */ -/* - * 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 . - */ - -#ifndef GRUB_MULTIBOOT2_HEADER -#define GRUB_MULTIBOOT2_HEADER 1 - -#include -#include -#include - -#ifndef GRUB_UTIL -typedef grub_uint32_t uint32_t; -typedef grub_uint64_t uint64_t; -#define __WORDSIZE GRUB_TARGET_WORDSIZE -#endif - -struct multiboot2_tag_header; - -grub_err_t -grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len); - -grub_err_t -grub_mb2_tags_arch_create (void); - -void -grub_mb2_arch_boot (grub_addr_t entry, void *tags); - -void -grub_mb2_arch_unload (struct multiboot2_tag_header *tags); - -grub_err_t -grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load); - -grub_err_t -grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load); - -grub_err_t -grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr); - -grub_err_t -grub_mb2_arch_module_free (grub_addr_t addr, grub_size_t size); - -void -grub_multiboot2 (int argc, char *argv[]); - -void -grub_module2 (int argc, char *argv[]); - -#define for_each_tag(tag, tags) \ - for (tag = tags; \ - tag && tag->key != MULTIBOOT2_TAG_END; \ - tag = (struct multiboot2_tag_header *)((char *)tag + tag->len)) - -#endif /* ! GRUB_MULTIBOOT2_HEADER */ From e28e32ae51c75a64333deffbd78f1cda9c376fc8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 16:52:47 +0100 Subject: [PATCH 5/7] 2010-02-07 Vladimir Serbinenko * include/grub/normal.h [GRUB_UTIL]: Remove leftover declarations. * include/grub/partition.h [GRUB_UTIL]: Likewise. --- ChangeLog | 2 ++ include/grub/normal.h | 33 --------------------------------- include/grub/partition.h | 14 -------------- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e9e18348..dede0af2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2010-02-07 Vladimir Serbinenko * include/grub/multiboot2.h: Remove leftover file. + * include/grub/normal.h [GRUB_UTIL]: Remove leftover declarations. + * include/grub/partition.h [GRUB_UTIL]: Likewise. 2010-02-07 Yves Blusseau diff --git a/include/grub/normal.h b/include/grub/normal.h index e804fde77..fad1a41ba 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -110,37 +110,4 @@ void read_terminal_list (void); void grub_set_more (int onoff); -#ifdef GRUB_UTIL -void grub_normal_init (void); -void grub_normal_fini (void); -void grub_hello_init (void); -void grub_hello_fini (void); -void grub_ls_init (void); -void grub_ls_fini (void); -void grub_cat_init (void); -void grub_cat_fini (void); -void grub_boot_init (void); -void grub_boot_fini (void); -void grub_cmp_init (void); -void grub_cmp_fini (void); -void grub_terminal_init (void); -void grub_terminal_fini (void); -void grub_loop_init (void); -void grub_loop_fini (void); -void grub_help_init (void); -void grub_help_fini (void); -void grub_halt_init (void); -void grub_halt_fini (void); -void grub_reboot_init (void); -void grub_reboot_fini (void); -void grub_configfile_init (void); -void grub_configfile_fini (void); -void grub_search_init (void); -void grub_search_fini (void); -void grub_test_init (void); -void grub_test_fini (void); -void grub_blocklist_init (void); -void grub_blocklist_fini (void); -#endif - #endif /* ! GRUB_NORMAL_HEADER */ diff --git a/include/grub/partition.h b/include/grub/partition.h index d35658cdd..faa89cea6 100644 --- a/include/grub/partition.h +++ b/include/grub/partition.h @@ -83,20 +83,6 @@ void EXPORT_FUNC(grub_partition_map_register) (grub_partition_map_t partmap); void EXPORT_FUNC(grub_partition_map_unregister) (grub_partition_map_t partmap); -#ifdef GRUB_UTIL -void grub_msdos_partition_map_init (void); -void grub_msdos_partition_map_fini (void); -void grub_amiga_partition_map_init (void); -void grub_amiga_partition_map_fini (void); -void grub_apple_partition_map_init (void); -void grub_apple_partition_map_fini (void); -void grub_sun_partition_map_init (void); -void grub_sun_partition_map_fini (void); -void grub_gpt_partition_map_init (void); -void grub_gpt_partition_map_fini (void); -void grub_apple_partition_map_init (void); -void grub_apple_partition_map_fini (void); -#endif static inline grub_disk_addr_t grub_partition_get_start (const grub_partition_t p) From a1a8d38a5862ec296e5940be1f38af8804118f09 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 17:30:16 +0100 Subject: [PATCH 6/7] Use nostdinc --- conf/any-emu.rmk | 25 ++++--------------------- util/grub-emu.c | 9 +++++++++ util/hostdisk.c | 6 +++--- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 529174bc3..d3d2c2f2f 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,7 +1,7 @@ # -*- makefile -*- COMMON_LDFLAGS += -nostdlib -COMMON_CFLAGS += +COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) # Used by various components. These rules need to precede them. script/lexer.c_DEPENDENCIES = grub_script.tab.h @@ -19,30 +19,12 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ util/console.c util/grub-emu.c util/misc.c \ util/hostdisk.c util/getroot.c \ \ - grub_emu_init.c -kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) + 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 -# progname.c always has warnings. Compile it separately. -pkglib_MODULES += progname.mod -progname_mod_SOURCES = gnulib/progname.c -progname_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error -progname_mod_LDFLAGS = $(COMMON_LDFLAGS) - -# For hostfs.mod. -pkglib_MODULES += hostfs.mod -hostfs_mod_SOURCES = util/hostfs.c -hostfs_mod_CFLAGS = $(COMMON_CFLAGS) -hostfs_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. pkglib_MODULES += reboot.mod reboot_mod_SOURCES = commands/reboot.c @@ -76,6 +58,7 @@ endif ifeq ($(enable_grub_emu_sdl), yes) pkglib_MODULES += sdl.mod sdl_mod_SOURCES = util/sdl.c +sdl_mod_CFLAGS = sdl_mod_LDFLAGS = $(COMMON_LDFLAGS) grub_emu_LDFLAGS += $(LIBSDL) endif diff --git a/util/grub-emu.c b/util/grub-emu.c index 08ae19836..7d4544509 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -146,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[]) { @@ -204,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); @@ -236,6 +243,8 @@ main (int argc, char *argv[]) grub_main (); grub_fini_all (); + grub_hostfs_fini (); + grub_host_fini (); grub_machine_fini (); diff --git a/util/hostdisk.c b/util/hostdisk.c index 98d3d53ae..be5d05afc 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -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; From b4674703a12144315b2d725c40bc490645727712 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 17:39:52 +0100 Subject: [PATCH 7/7] Add fno-builtin --- conf/any-emu.rmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index d3d2c2f2f..a4ee9b755 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,7 +1,7 @@ # -*- makefile -*- COMMON_LDFLAGS += -nostdlib -COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) +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