x86_64 EFI support for grub2
PATCH 1/1 x86_64 EFI support for grub2
Hi,
This patch add a new platform x86_64 EFI, it's used in the new "Santa Rosa" generation of MacBooks.
You can compile it from 32-bit or 64-bit machine:
./configure --target=x86_64 --with-platform=efi
make
In 32-bit machine, the *.mod files are 64-bit, but tools like grub-mkimage is still 32-bit, so that you can create the efi image in your native environment and deploy it in 64-bit machine.
To create the original 32-bit EFI image: (hopefully I don't break anything)
./configure --target=i386 --with-platform=efi
make
Please note that if you want to cross compile between 64-bit and 32-bit, you need to install the gcc-multilib package.
To create the efi image, use grub-mkimage:
grub-mkimage -d . -o grub2.efi gpt normal hfsplus ext2 fat ls
TODO:
There is some problem with loaders, other function seems ok.
Also, I currently use GRUB_TARGET_SIZEOF_VOID_P to distingish between i386 and x86_64, but it should be more specific, otherwise it can't coexist with other 64-bit platform like ia64. Is there some auto generated macro in autoconf, or do I need to define some ?
--
Bean
conf/x86_64-efi.rmk new file +155 -0
@@ -0,0 +1,155 @@ +# -*- makefile -*- + +COMMON_ASFLAGS = -nostdinc -fno-builtin -m64 +COMMON_CFLAGS = -fno-builtin -m64 +COMMON_LDFLAGS = -melf_x86_64 -nostdlib + +# Used by various components. These rules need to precede them. +normal/execute.c_DEPENDENCIES = grub_script.tab.h +normal/command.c_DEPENDENCIES = grub_script.tab.h +normal/function.c_DEPENDENCIES = grub_script.tab.h +normal/lexer.c_DEPENDENCIES = grub_script.tab.h + +# Utilities. +bin_UTILITIES = grub-mkimage +#sbin_UTILITIES = grub-mkdevicemap +#ifeq ($(enable_grub_emu), yes) +#sbin_UTILITIES += grub-emu +#endif + +# For grub-mkimage. +grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \ + util/resolve.c + +# For grub-setup. +#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/biosdisk.c \ +# util/misc.c util/getroot.c kern/device.c kern/disk.c \ +# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ +# fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ +# fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ +# kern/fs.c kern/env.c fs/fshelp.c + +# For grub-mkdevicemap. +grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c \ + util/i386/get_disk_name.c + +# For grub-emu. +util/grub-emu.c_DEPENDENCIES = grub_emu_init.h +grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ + commands/configfile.c commands/help.c \ + commands/terminal.c commands/ls.c commands/test.c \ + commands/search.c commands/hexdump.c \ + commands/halt.c commands/reboot.c \ + commands/i386/cpuid.c \ + disk/loopback.c \ + \ + fs/affs.c fs/cpio.c fs/ext2.c fs/fat.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/xfs.c fs/afs.c \ + \ + io/gzio.c \ + kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ + kern/err.c \ + normal/execute.c kern/file.c kern/fs.c normal/lexer.c \ + kern/loader.c kern/main.c kern/misc.c kern/parser.c \ + grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ + normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ + normal/completion.c normal/context.c normal/main.c \ + normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \ + normal/color.c \ + partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/acorn.c partmap/gpt.c \ + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ + util/biosdisk.c util/getroot.c \ + util/i386/pc/misc.c \ + \ + disk/raid.c disk/lvm.c \ + grub_emu_init.c + +grub_emu_LDFLAGS = $(LIBCURSES) + +# Scripts. +sbin_SCRIPTS = grub-install + +# For grub-install. +grub_install_SOURCES = util/i386/efi/grub-install.in + +# Modules. +pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod \ + cpuid.mod halt.mod reboot.mod +# _linux.mod linux.mod + +# For kernel.mod. +kernel_mod_EXPORTS = no +kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ + kern/main.c kern/device.c \ + kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ + kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ + kern/x86_64/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \ + kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \ + term/efi/console.c disk/efi/efidisk.c +kernel_mod_HEADERS = arg.h 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 \ + partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ + efi/efi.h efi/time.h efi/disk.h +kernel_mod_CFLAGS = $(COMMON_CFLAGS) +kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) +kernel_mod_LDFLAGS = $(COMMON_LDFLAGS) + +MOSTLYCLEANFILES += symlist.c +MOSTLYCLEANFILES += symlist.c kernel_syms.lst +DEFSYMFILES += kernel_syms.lst + +symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.sh + /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + +kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh + /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + +# For normal.mod. +normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ + normal/completion.c normal/execute.c \ + normal/function.c normal/lexer.c normal/main.c normal/menu.c \ + normal/menu_entry.c normal/misc.c grub_script.tab.c \ + normal/script.c normal/x86_64/setjmp.S normal/color.c +normal_mod_CFLAGS = $(COMMON_CFLAGS) +normal_mod_ASFLAGS = $(COMMON_ASFLAGS) +normal_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For _chain.mod. +_chain_mod_SOURCES = loader/efi/chainloader.c +_chain_mod_CFLAGS = $(COMMON_CFLAGS) +_chain_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For chain.mod. +chain_mod_SOURCES = loader/efi/chainloader_normal.c +chain_mod_CFLAGS = $(COMMON_CFLAGS) +chain_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For _linux.mod. +_linux_mod_SOURCES = loader/i386/efi/linux.c +_linux_mod_CFLAGS = $(COMMON_CFLAGS) +_linux_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For linux.mod. +linux_mod_SOURCES = loader/i386/efi/linux_normal.c +linux_mod_CFLAGS = $(COMMON_CFLAGS) +linux_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For cpuid.mod. +cpuid_mod_SOURCES = commands/i386/cpuid.c +cpuid_mod_CFLAGS = $(COMMON_CFLAGS) +cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For halt.mod. +halt_mod_SOURCES = commands/halt.c +halt_mod_CFLAGS = $(COMMON_CFLAGS) +halt_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For reboot.mod. +reboot_mod_SOURCES = commands/reboot.c +reboot_mod_CFLAGS = $(COMMON_CFLAGS) +reboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +include $(srcdir)/conf/common.mk
configure.ac +24 -5
@@ -49,11 +49,6 @@ esac case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; - x86_64) target_cpu=i386 target_m32=1 ;; - powerpc) ;; - powerpc64) target_cpu=powerpc target_m32=1;; - sparc64) ;; - *) AC_MSG_ERROR([unsupported CPU type]) ;; esac # Specify the platform (such as firmware).
@@ -74,9 +69,27 @@ else platform="$with_platform" fi +if test "x$platform" = "xefi" ; then + case "$target_cpu" in + i386) ;; + x86_64) target_m64=1 ;; + *) AC_MSG_ERROR([unsupported CPU type for EFI]) ;; + esac +else + case "$target_cpu" in + i386) ;; + x86_64) target_cpu=i386 target_m32=1 ;; + powerpc) ;; + powerpc64) target_cpu=powerpc target_m32=1;; + sparc64) ;; + *) AC_MSG_ERROR([unsupported CPU type]) ;; + esac +fi + # Sanity check. case "$target_cpu"-"$platform" in i386-efi) ;; + x86_64-efi) ;; i386-pc) ;; i386-linuxbios) ;; i386-ieee1275) ;;
@@ -238,6 +251,12 @@ if test "x$target_m32" = x1; then TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" fi +if test "x$target_m64" = x1; then + # Force 64-bit mode. + TARGET_CFLAGS="$TARGET_CFLAGS -m64" + TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" +fi + # # Compiler features. #
disk/efi/efidisk.c +2 -2
@@ -574,7 +574,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,"reading 0x%x sectors at the sector 0x%llx from %s\n" , size, sector, disk->name); - status = dio->read (dio, bio->media->media_id, + status =efi_call_5 (dio->read, dio, bio->media->media_id, (grub_efi_uint64_t ) sector <<GRUB_DISK_SECTOR_BITS , (grub_efi_uintn_t ) size <<GRUB_DISK_SECTOR_BITS , buf);
@@ -602,7 +602,7 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,"writing 0x%x sectors at the sector 0x%llx to %s\n" , size, sector, disk->name); - status = dio->write (dio, bio->media->media_id, + status =efi_call_5 (dio->write, dio, bio->media->media_id, (grub_efi_uint64_t ) sector <<GRUB_DISK_SECTOR_BITS , (grub_efi_uintn_t ) size <<GRUB_DISK_SECTOR_BITS , (void *) buf);
include/grub/efi/api.h +38 -0
@@ -1095,4 +1095,42 @@ struct grub_efi_block_io };typedef struct grub_efi_block_io grub_efi_block_io_t ; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 + +#define efi_call_0 (func) func() +#define efi_call_1 (func, a) func(a) +#define efi_call_2 (func, a, b) func(a, b) +#define efi_call_3 (func, a, b, c) func(a, b, c) +#define efi_call_4 (func, a, b, c, d) func(a, b, c, d) +#define efi_call_5 (func, a, b, c, d, e) func(a, b, c, d, e) +#define efi_call_6 (func, a, b, c, d, e, f) func(a, b, c, d, e, f) + +#else + +#define efi_call_0 (func) efi_wrap_0(func) +#define efi_call_1 (func, a) efi_wrap_1(func, (grub_uint64_t) a) +#define efi_call_2 (func, a, b) efi_wrap_2(func, (grub_uint64_t) a, (grub_uint64_t) b) +#define efi_call_3 (func, a, b, c) efi_wrap_3(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c) +#define efi_call_4 (func, a, b, c, d) efi_wrap_4(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d) +#define efi_call_5 (func, a, b, c, d, e) efi_wrap_5(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d, (grub_uint64_t) e) +#define efi_call_6 (func, a, b, c, d, e, f) efi_wrap_6(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d, (grub_uint64_t) e, (grub_uint64_t) f) + +grub_uint64_t EXPORT_FUNC (efi_wrap_0 ) (void *func); +grub_uint64_t EXPORT_FUNC (efi_wrap_1 ) (void *func,grub_uint64_t arg1); +grub_uint64_t EXPORT_FUNC (efi_wrap_2 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2); +grub_uint64_t EXPORT_FUNC (efi_wrap_3 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3); +grub_uint64_t EXPORT_FUNC (efi_wrap_4 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4); +grub_uint64_t EXPORT_FUNC (efi_wrap_5 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4,grub_uint64_t arg5); +grub_uint64_t EXPORT_FUNC (efi_wrap_6 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4,grub_uint64_t arg5, +grub_uint64_t arg6); +#endif +#endif /* ! GRUB_EFI_API_HEADER */
include/grub/efi/pe32.h +27 -1
@@ -64,6 +64,7 @@ struct grub_pe32_coff_header };#define GRUB_PE32_MACHINE_I386 0x14c +#define GRUB_PE32_MACHINE_X86_64 0x8664#define GRUB_PE32_RELOCS_STRIPPED 0x0001#define GRUB_PE32_EXECUTABLE_IMAGE 0x0002
@@ -98,9 +99,13 @@ struct grub_pe32_optional_headergrub_uint32_t entry_addr;grub_uint32_t code_base; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 grub_uint32_t data_base; -grub_uint32_t image_base; +#else +grub_uint64_t image_base; +#endif +grub_uint32_t section_alignment;grub_uint32_t file_alignment;grub_uint16_t major_os_version;
@@ -115,10 +120,23 @@ struct grub_pe32_optional_headergrub_uint32_t checksum;grub_uint16_t subsystem;grub_uint16_t dll_characteristics; + +#if GRUB_TARGET_SIZEOF_VOID_P ==4 +grub_uint32_t stack_reserve_size;grub_uint32_t stack_commit_size;grub_uint32_t heap_reserve_size;grub_uint32_t heap_commit_size; + +#else + +grub_uint64_t stack_reserve_size; +grub_uint64_t stack_commit_size; +grub_uint64_t heap_reserve_size; +grub_uint64_t heap_commit_size; + +#endif +grub_uint32_t loader_flags;grub_uint32_t num_data_directories;
@@ -141,8 +159,16 @@ struct grub_pe32_optional_headerstruct grub_pe32_data_directory reserved_entry; }; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 +#define GRUB_PE32_PE32_MAGIC 0x10b +#else + +#define GRUB_PE32_PE32_MAGIC 0x20b + +#endif +#define GRUB_PE32_SUBSYSTEM_EFI_APPLICATION 10#define GRUB_PE32_NUM_DATA_DIRECTORIES 16
include/grub/elf.h +20 -0
@@ -454,6 +454,7 @@ typedef structthe end of a chain, meaning no further symbols are found in that bucket. */ #define STN_UNDEF 0/* End of a chain. */ +#define STN_ABS 65521/* How to extract and insert information held in the st_other field. */
@@ -1108,8 +1109,27 @@ typedef struct/* Keep this the last entry. */ #define R_386_NUM 38 +/* SUN SPARC specific definitions. */ +/* x86_64 specific definitions. */ +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ #define STT_REGISTER 13/* Global register reserved to app. */
include/grub/kernel.h +3 -0
@@ -38,6 +38,9 @@ struct grub_module_info {/* Magic number so we know we have modules present. */ grub_uint32_t magic; +#if GRUB_TARGET_SIZEOF_VOID_P ==8 +grub_uint32_t padding; +#endif /* The offset of the modules. */ grub_target_off_t offset;/* The size of all modules plus this header. */
include/grub/x86_64/efi/kernel.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2003,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/>. +*/ + +#ifndef GRUB_MACHINE_KERNEL_HEADER +#define GRUB_MACHINE_KERNEL_HEADER 1 + +/* The prefix which points to the directory where GRUB modules and its +configuration file are located. */ +extern char grub_prefix[]; + +/* The offset of GRUB_PREFIX. */ +#define GRUB_KERNEL_MACHINE_PREFIX 0x8 + +/* End of the data section. */ +#define GRUB_KERNEL_MACHINE_DATA_END 0x50 + +#endif /* ! GRUB_MACHINE_KERNEL_HEADER */ +
include/grub/x86_64/efi/loader.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2003,2004,2006,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/>. +*/ + +#ifndef GRUB_LOADER_MACHINE_HEADER +#define GRUB_LOADER_MACHINE_HEADER 1 + +/* It is necessary to export these functions, because normal mode commands +reuse rescue mode commands. */ +void grub_rescue_cmd_linux (int argc,char *argv[]); +void grub_rescue_cmd_initrd (int argc,char *argv[]); + +#endif /* ! GRUB_LOADER_MACHINE_HEADER */
include/grub/x86_64/efi/machine.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 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/>. +*/ + +#ifndef GRUB_MACHINE_MACHINE_HEADER +#define GRUB_MACHINE_MACHINE_HEADER 1 + +#define GRUB_MACHINE_EFI 1 + +#endif /* ! GRUB_MACHINE_MACHINE_HEADER */
include/grub/x86_64/efi/time.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2006,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/>. +*/ + +#ifndef GRUB_MACHINE_TIME_HEADER +#define GRUB_MACHINE_TIME_HEADER 1 + +#include <grub/efi/time.h> + +#endif /* ! GRUB_MACHINE_TIME_HEADER */
include/grub/x86_64/setjmp.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2003,2006,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/>. +*/ + +#ifndef GRUB_SETJMP_CPU_HEADER +#define GRUB_SETJMP_CPU_HEADER 1 + +typedef unsigned long grub_jmp_buf [8 ]; + +int grub_setjmp (grub_jmp_buf env); +void grub_longjmp (grub_jmp_buf env,int val) __attribute__ ((noreturn)); + +#endif /* ! GRUB_SETJMP_CPU_HEADER */
include/grub/x86_64/time.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 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/>. +*/ + +#ifndef KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +static __inlinevoid +grub_cpu_idle (void ) +{ +/* FIXME: this can't work until we handle interrupts. */ +/* __asm__ __volatile__ ("hlt"); */ +} + +#endif /* ! KERNEL_CPU_TIME_HEADER */
include/grub/x86_64/types.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2008 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/>. +*/ + +#ifndef GRUB_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 8 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 8 + +/* x86_64 is little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN + +#endif /* ! GRUB_TYPES_CPU_HEADER */
kern/dl.c +2 -2
@@ -29,7 +29,7 @@#include <grub/env.h> #include <grub/cache.h> -#if GRUB_CPU_SIZEOF_VOID_P ==4 +#if GRUB_TARGET_SIZEOF_VOID_P ==4 typedef Elf32_Word Elf_Word ;typedef Elf32_Addr Elf_Addr ;
@@ -40,7 +40,7 @@ typedef Elf32_Sym Elf_Sym;# define ELF_ST_BIND (val) ELF32_ST_BIND (val)# define ELF_ST_TYPE (val) ELF32_ST_TYPE (val) -#elif GRUB_CPU_SIZEOF_VOID_P ==8 +#elif GRUB_TARGET_SIZEOF_VOID_P ==8 typedef Elf64_Word Elf_Word ;typedef Elf64_Addr Elf_Addr ;
kern/efi/efi.c +21 -23
114 lines not on this page · raw message
kern/efi/mm.c +6 -6
@@ -30,7 +30,7 @@/* The size of a memory map obtained from the firmware. This must be a multiplier of 4KB. */ -#define MEMORY_MAP_SIZE 0x1000 +#define MEMORY_MAP_SIZE 0x3000/* Maintain the list of allocated pages. */ struct allocated_page
@@ -59,7 +59,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,grub_efi_status_t status;grub_efi_boot_services_t *b; -#if GRUB_CPU_SIZEOF_VOID_P <8 +#if GRUB_TARGET_SIZEOF_VOID_P <8 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address >0xffffffff )return 0 ;
@@ -79,7 +79,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,#endif b = grub_efi_system_table->boot_services; - status = b->allocate_pages (type,GRUB_EFI_LOADER_DATA , pages, &address); + status =efi_call_4 (b->allocate_pages, type,GRUB_EFI_LOADER_DATA , pages, &address);if (status !=GRUB_EFI_SUCCESS )return 0 ;
@@ -88,7 +88,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,/* Uggh, the address 0 was allocated... This is too annoying, so reallocate another one. */ address =0xffffffff ; - status = b->allocate_pages (type,GRUB_EFI_LOADER_DATA , pages, &address); + status =efi_call_4 (b->allocate_pages, type,GRUB_EFI_LOADER_DATA , pages, &address);grub_efi_free_pages (0 , pages);if (status !=GRUB_EFI_SUCCESS )return 0 ;
@@ -135,7 +135,7 @@ grub_efi_free_pages (grub_efi_physical_address_t address, } b = grub_efi_system_table->boot_services; - b->free_pages (address, pages); +efi_call_2 (b->free_pages, address, pages); }/* Get the memory map as defined in the EFI spec. Return 1 if successful,
@@ -159,7 +159,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size, descriptor_version = &version; b = grub_efi_system_table->boot_services; - status = b->get_memory_map (memory_map_size, memory_map, map_key, + status =efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key, descriptor_size, descriptor_version);if (status ==GRUB_EFI_SUCCESS )return 1 ;
kern/main.c +0 -0
kern/partition.c +0 -0
kern/term.c +1 -0
@@ -21,6 +21,7 @@#include <grub/mm.h> #include <grub/misc.h> #include <grub/env.h> +#include <grub/efi/efi.h> /* The list of terminals. */ static grub_term_t grub_term_list;
kern/x86_64/dl.c new file +121 -0
121 lines not on this page · raw message
kern/x86_64/efi/callwrap.S new file +96 -0
96 lines not on this page · raw message
kern/x86_64/efi/startup.S new file +61 -0
61 lines not on this page · raw message
loader/efi/chainloader.c +7 -7
@@ -47,9 +47,9 @@ grub_chainloader_unload (void)grub_efi_boot_services_t *b; b = grub_efi_system_table->boot_services; - b->unload_image (image_handle); - b->free_pages (address, pages); -grub_free (file_path); +efi_call_1 (b->unload_image, image_handle); +efi_call_2 (b->free_pages, address, pages); +efi_call_1 (grub_free, file_path);grub_dl_unref (my_mod);return GRUB_ERR_NONE ;
@@ -64,7 +64,7 @@ grub_chainloader_boot (void)grub_efi_char16_t *exit_data; b = grub_efi_system_table->boot_services; - status = b->start_image (image_handle, &exit_data_size, &exit_data); + status =efi_call_3 (b->start_image, image_handle, &exit_data_size, &exit_data);if (status !=GRUB_EFI_SUCCESS ) {if (exit_data)
@@ -227,7 +227,7 @@ grub_chainloader_cmd (const char *filename) size =grub_file_size (file); pages = (((grub_efi_uintn_t ) size + ((1 <<12 ) -1 )) >>12 ); - status = b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES , + status =efi_call_4 (b->allocate_pages,GRUB_EFI_ALLOCATE_ANY_PAGES ,GRUB_EFI_LOADER_CODE , pages, &address);if (status !=GRUB_EFI_SUCCESS )
@@ -244,7 +244,7 @@ grub_chainloader_cmd (const char *filename) goto fail; } - status = b->load_image (0 , grub_efi_image_handle, file_path, + status =efi_call_6 (b->load_image,0 , grub_efi_image_handle, file_path, (void *) ((grub_addr_t ) address), size, &image_handle);if (status !=GRUB_EFI_SUCCESS )
@@ -284,7 +284,7 @@ grub_chainloader_cmd (const char *filename)grub_free (file_path);if (address) - b->free_pages (address, pages); +efi_call_2 (b->free_pages, address, pages);grub_dl_unref (my_mod); }
normal/x86_64/setjmp.S new file +64 -0
64 lines not on this page · raw message
term/efi/console.c +13 -13
@@ -52,10 +52,10 @@ grub_console_putchar (grub_uint32_t c) str[1 ] =0 ;/* Should this test be cached? */ -if (c >0x7f && o->test_string (o, str) !=GRUB_EFI_SUCCESS ) +if (c >0x7f &&efi_call_2 (o->test_string, o, str) !=GRUB_EFI_SUCCESS )return ; - o->output_string (o, str); +efi_call_2 (o->output_string, o, str); } static grub_ssize_t
@@ -76,7 +76,7 @@ grub_console_checkkey (void)return 1 ; i = grub_efi_system_table->con_in; - status = i->read_key_stroke (i, &key); + status =efi_call_2 (i->read_key_stroke, i, &key);#if 1 switch (status) {
@@ -169,7 +169,7 @@ grub_console_getkey (void) do { - status = b->wait_for_event (1, &(i->wait_for_key), &index); + status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index); if (status != GRUB_EFI_SUCCESS) return -1;
@@ -189,7 +189,7 @@ grub_console_getwh (void)grub_efi_uintn_t columns, rows; o = grub_efi_system_table->con_out; -if (o->query_mode (o, o->mode->mode, &columns, &rows) !=GRUB_EFI_SUCCESS ) +if (efi_call_4 (o->query_mode, o, o->mode->mode, &columns, &rows) !=GRUB_EFI_SUCCESS ) {/* Why does this fail? */ columns =80 ;
@@ -214,7 +214,7 @@ grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y)grub_efi_simple_text_output_interface_t *o; o = grub_efi_system_table->con_out; - o->set_cursor_position (o, x, y); +efi_call_3 (o->set_cursor_position, o, x, y); } static void
@@ -225,9 +225,9 @@ grub_console_cls (void) o = grub_efi_system_table->con_out; orig_attr = o->mode->attribute; - o->set_attributes (o,GRUB_EFI_BACKGROUND_BLACK ); - o->clear_screen (o); - o->set_attributes (o, orig_attr); +efi_call_2 (o->set_attributes, o,GRUB_EFI_BACKGROUND_BLACK ); +efi_call_1 (o->clear_screen, o); +efi_call_2 (o->set_attributes, o, orig_attr); } static void
@@ -239,13 +239,13 @@ grub_console_setcolorstate (grub_term_color_state state)switch (state) {case GRUB_TERM_COLOR_STANDARD : - o->set_attributes (o, grub_console_standard_color); +efi_call_2 (o->set_attributes, o, grub_console_standard_color);break ;case GRUB_TERM_COLOR_NORMAL : - o->set_attributes (o, grub_console_normal_color); +efi_call_2 (o->set_attributes, o, grub_console_normal_color);break ;case GRUB_TERM_COLOR_HIGHLIGHT : - o->set_attributes (o, grub_console_highlight_color); +efi_call_2 (o->set_attributes, o, grub_console_highlight_color);break ;default :break ;
@@ -272,7 +272,7 @@ grub_console_setcursor (int on)grub_efi_simple_text_output_interface_t *o; o = grub_efi_system_table->con_out; - o->enable_cursor (o, on); +efi_call_2 (o->enable_cursor, o, on); } static struct grub_term grub_console_term =
util/i386/efi/grub-mkimage.c +264 -151
728 lines not on this page · raw message
conf/x86_64-efi.rmk line 5
Quoted 4 lines · Bean
conf/x86_64-efi.rmk new file +4
-0+ +COMMON_ASFLAGS = -nostdinc -fno-builtin -m64 +COMMON_CFLAGS = -fno-builtin -m64 +COMMON_LDFLAGS = -melf_x86_64 -nostdlib
How much does this file differ from its i386 version? If it's just a few flags, we could solve this with variables passed on from the caller.
conf/x86_64-efi.rmk line 115
Quoted 1 line
conf/x86_64-efi.rmk new file +1
-0+ normal/script.c normal/x86_64/setjmp.S normal/color.c
... and #ifdefs in normal/i386/setjmp.S and the like?
Maintaining so many duplicated stuff in *.rmk is starting to become a PITA (not that I know of any good solution for that ... :-/)
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Hi,
Ok, I can basically make everything else work, even chainloading OS X, but it just don't boot Linux. Kernel and initrd loads properly, but it hangs when boot. I start to wonder if this is the kernel's fault. I apply the patches from mactel-linux.org, not working either. And elilo also fails to load linux.
Anyone has success booting linux kernel using the new 64-bit Mac Intel EFI ?
Signature · 1 line
Bean
Hi,
Ok, I solve this now, the new patch is capable of booting Linux from x86_64 EFI. In theory, it should also be able to boot from 32-bit EFI, but I haven't verified it yet.
You should add root=/dev/sdaX command line so that it can find the root partition. After booting, it may seem hang, just give it some time, it could still be running. After a short while, you should see a scramble screen, that's it, linux have started !
The reason of scramble screen is that it can't find the proper frame buffer driver, you can add the following line to .config
CONFIG_FB_IMAC="y"
and recompile the kernel. You should also add parameter like "video=fbimac:macbook" to the command line. For more information, check out Documentation/fb/imac.txt in the kernel source.
BTW, you need 2.6.25 if you are using x86_64 firmware. 2.5.24 is not working ! It actually cause me a lot of time to figure this out.
Signature · 1 line
Bean
conf/x86_64-efi.rmk new file +154 -0
@@ -0,0 +1,154 @@ +# -*- makefile -*- + +COMMON_ASFLAGS = -nostdinc -fno-builtin -m64 +COMMON_CFLAGS = -fno-builtin -m64 +COMMON_LDFLAGS = -melf_x86_64 -nostdlib + +# Used by various components. These rules need to precede them. +normal/execute.c_DEPENDENCIES = grub_script.tab.h +normal/command.c_DEPENDENCIES = grub_script.tab.h +normal/function.c_DEPENDENCIES = grub_script.tab.h +normal/lexer.c_DEPENDENCIES = grub_script.tab.h + +# Utilities. +bin_UTILITIES = grub-mkimage +#sbin_UTILITIES = grub-mkdevicemap +#ifeq ($(enable_grub_emu), yes) +#sbin_UTILITIES += grub-emu +#endif + +# For grub-mkimage. +grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \ + util/resolve.c + +# For grub-setup. +#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/biosdisk.c \ +# util/misc.c util/getroot.c kern/device.c kern/disk.c \ +# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ +# fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \ +# fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \ +# kern/fs.c kern/env.c fs/fshelp.c + +# For grub-mkdevicemap. +grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c \ + util/i386/get_disk_name.c + +# For grub-emu. +util/grub-emu.c_DEPENDENCIES = grub_emu_init.h +grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ + commands/configfile.c commands/help.c \ + commands/terminal.c commands/ls.c commands/test.c \ + commands/search.c commands/hexdump.c \ + commands/halt.c commands/reboot.c \ + commands/i386/cpuid.c \ + disk/loopback.c \ + \ + fs/affs.c fs/cpio.c fs/ext2.c fs/fat.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/xfs.c fs/afs.c \ + \ + io/gzio.c \ + kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ + kern/err.c \ + normal/execute.c kern/file.c kern/fs.c normal/lexer.c \ + kern/loader.c kern/main.c kern/misc.c kern/parser.c \ + grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \ + normal/arg.c normal/cmdline.c normal/command.c normal/function.c\ + normal/completion.c normal/context.c normal/main.c \ + normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \ + normal/color.c \ + partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ + partmap/acorn.c partmap/gpt.c \ + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ + util/biosdisk.c util/getroot.c \ + util/i386/pc/misc.c \ + \ + disk/raid.c disk/lvm.c \ + grub_emu_init.c + +grub_emu_LDFLAGS = $(LIBCURSES) + +# Scripts. +sbin_SCRIPTS = grub-install + +# For grub-install. +grub_install_SOURCES = util/i386/efi/grub-install.in + +# Modules. +pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod \ + cpuid.mod halt.mod reboot.mod _linux.mod linux.mod + +# For kernel.mod. +kernel_mod_EXPORTS = no +kernel_mod_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \ + kern/main.c kern/device.c \ + kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ + kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ + kern/x86_64/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \ + kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \ + term/efi/console.c disk/efi/efidisk.c +kernel_mod_HEADERS = arg.h 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 \ + partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ + efi/efi.h efi/time.h efi/disk.h +kernel_mod_CFLAGS = $(COMMON_CFLAGS) +kernel_mod_ASFLAGS = $(COMMON_ASFLAGS) +kernel_mod_LDFLAGS = $(COMMON_LDFLAGS) + +MOSTLYCLEANFILES += symlist.c +MOSTLYCLEANFILES += symlist.c kernel_syms.lst +DEFSYMFILES += kernel_syms.lst + +symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.sh + /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + +kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh + /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1) + +# For normal.mod. +normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \ + normal/completion.c normal/execute.c \ + normal/function.c normal/lexer.c normal/main.c normal/menu.c \ + normal/menu_entry.c normal/misc.c grub_script.tab.c \ + normal/script.c normal/x86_64/setjmp.S normal/color.c +normal_mod_CFLAGS = $(COMMON_CFLAGS) +normal_mod_ASFLAGS = $(COMMON_ASFLAGS) +normal_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For _chain.mod. +_chain_mod_SOURCES = loader/efi/chainloader.c +_chain_mod_CFLAGS = $(COMMON_CFLAGS) +_chain_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For chain.mod. +chain_mod_SOURCES = loader/efi/chainloader_normal.c +chain_mod_CFLAGS = $(COMMON_CFLAGS) +chain_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For _linux.mod. +_linux_mod_SOURCES = loader/i386/efi/linux.c +_linux_mod_CFLAGS = $(COMMON_CFLAGS) +_linux_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For linux.mod. +linux_mod_SOURCES = loader/i386/efi/linux_normal.c +linux_mod_CFLAGS = $(COMMON_CFLAGS) +linux_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For cpuid.mod. +cpuid_mod_SOURCES = commands/i386/cpuid.c +cpuid_mod_CFLAGS = $(COMMON_CFLAGS) +cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For halt.mod. +halt_mod_SOURCES = commands/halt.c +halt_mod_CFLAGS = $(COMMON_CFLAGS) +halt_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For reboot.mod. +reboot_mod_SOURCES = commands/reboot.c +reboot_mod_CFLAGS = $(COMMON_CFLAGS) +reboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +include $(srcdir)/conf/common.mk
configure +28 -7
@@ -1927,13 +1927,6 @@ esac case "$target_cpu" in i[3456]86) target_cpu=i386 ;; - x86_64) target_cpu=i386 target_m32=1 ;; - powerpc) ;; - powerpc64) target_cpu=powerpc target_m32=1;; - sparc64) ;; - *) { { echo "$as_me:$LINENO: error: unsupported CPU type" >&5 -echo "$as_me: error: unsupported CPU type" >&2;} - { (exit 1); exit 1; }; } ;; esac # Specify the platform (such as firmware).
@@ -1959,9 +1952,31 @@ else platform="$with_platform" fi +if test "x$platform" = "xefi" ; then + case "$target_cpu" in + i386) ;; + x86_64) target_m64=1 ;; + *) { { echo "$as_me:$LINENO: error: unsupported CPU type for EFI" >&5 +echo "$as_me: error: unsupported CPU type for EFI" >&2;} + { (exit 1); exit 1; }; } ;; + esac +else + case "$target_cpu" in + i386) ;; + x86_64) target_cpu=i386 target_m32=1 ;; + powerpc) ;; + powerpc64) target_cpu=powerpc target_m32=1;; + sparc64) ;; + *) { { echo "$as_me:$LINENO: error: unsupported CPU type" >&5 +echo "$as_me: error: unsupported CPU type" >&2;} + { (exit 1); exit 1; }; } ;; + esac +fi + # Sanity check. case "$target_cpu"-"$platform" in i386-efi) ;; + x86_64-efi) ;; i386-pc) ;; i386-linuxbios) ;; i386-ieee1275) ;;
@@ -6686,6 +6701,12 @@ if test "x$target_m32" = x1; then TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" fi +if test "x$target_m64" = x1; then + # Force 64-bit mode. + TARGET_CFLAGS="$TARGET_CFLAGS -m64" + TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" +fi + # # Compiler features. #
configure.ac +24 -5
@@ -49,11 +49,6 @@ esac case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; - x86_64) target_cpu=i386 target_m32=1 ;; - powerpc) ;; - powerpc64) target_cpu=powerpc target_m32=1;; - sparc64) ;; - *) AC_MSG_ERROR([unsupported CPU type]) ;; esac # Specify the platform (such as firmware).
@@ -74,9 +69,27 @@ else platform="$with_platform" fi +if test "x$platform" = "xefi" ; then + case "$target_cpu" in + i386) ;; + x86_64) target_m64=1 ;; + *) AC_MSG_ERROR([unsupported CPU type for EFI]) ;; + esac +else + case "$target_cpu" in + i386) ;; + x86_64) target_cpu=i386 target_m32=1 ;; + powerpc) ;; + powerpc64) target_cpu=powerpc target_m32=1;; + sparc64) ;; + *) AC_MSG_ERROR([unsupported CPU type]) ;; + esac +fi + # Sanity check. case "$target_cpu"-"$platform" in i386-efi) ;; + x86_64-efi) ;; i386-pc) ;; i386-linuxbios) ;; i386-ieee1275) ;;
@@ -238,6 +251,12 @@ if test "x$target_m32" = x1; then TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" fi +if test "x$target_m64" = x1; then + # Force 64-bit mode. + TARGET_CFLAGS="$TARGET_CFLAGS -m64" + TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" +fi + # # Compiler features. #
disk/efi/efidisk.c +2 -2
@@ -574,7 +574,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,"reading 0x%x sectors at the sector 0x%llx from %s\n" , size, sector, disk->name); - status = dio->read (dio, bio->media->media_id, + status =efi_call_5 (dio->read, dio, bio->media->media_id, (grub_efi_uint64_t ) sector <<GRUB_DISK_SECTOR_BITS , (grub_efi_uintn_t ) size <<GRUB_DISK_SECTOR_BITS , buf);
@@ -602,7 +602,7 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,"writing 0x%x sectors at the sector 0x%llx to %s\n" , size, sector, disk->name); - status = dio->write (dio, bio->media->media_id, + status =efi_call_5 (dio->write, dio, bio->media->media_id, (grub_efi_uint64_t ) sector <<GRUB_DISK_SECTOR_BITS , (grub_efi_uintn_t ) size <<GRUB_DISK_SECTOR_BITS , (void *) buf);
include/grub/efi/api.h +38 -0
@@ -1095,4 +1095,42 @@ struct grub_efi_block_io };typedef struct grub_efi_block_io grub_efi_block_io_t ; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 + +#define efi_call_0 (func) func() +#define efi_call_1 (func, a) func(a) +#define efi_call_2 (func, a, b) func(a, b) +#define efi_call_3 (func, a, b, c) func(a, b, c) +#define efi_call_4 (func, a, b, c, d) func(a, b, c, d) +#define efi_call_5 (func, a, b, c, d, e) func(a, b, c, d, e) +#define efi_call_6 (func, a, b, c, d, e, f) func(a, b, c, d, e, f) + +#else + +#define efi_call_0 (func) efi_wrap_0(func) +#define efi_call_1 (func, a) efi_wrap_1(func, (grub_uint64_t) a) +#define efi_call_2 (func, a, b) efi_wrap_2(func, (grub_uint64_t) a, (grub_uint64_t) b) +#define efi_call_3 (func, a, b, c) efi_wrap_3(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c) +#define efi_call_4 (func, a, b, c, d) efi_wrap_4(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d) +#define efi_call_5 (func, a, b, c, d, e) efi_wrap_5(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d, (grub_uint64_t) e) +#define efi_call_6 (func, a, b, c, d, e, f) efi_wrap_6(func, (grub_uint64_t) a, (grub_uint64_t) b, (grub_uint64_t) c, (grub_uint64_t) d, (grub_uint64_t) e, (grub_uint64_t) f) + +grub_uint64_t EXPORT_FUNC (efi_wrap_0 ) (void *func); +grub_uint64_t EXPORT_FUNC (efi_wrap_1 ) (void *func,grub_uint64_t arg1); +grub_uint64_t EXPORT_FUNC (efi_wrap_2 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2); +grub_uint64_t EXPORT_FUNC (efi_wrap_3 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3); +grub_uint64_t EXPORT_FUNC (efi_wrap_4 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4); +grub_uint64_t EXPORT_FUNC (efi_wrap_5 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4,grub_uint64_t arg5); +grub_uint64_t EXPORT_FUNC (efi_wrap_6 ) (void *func,grub_uint64_t arg1, +grub_uint64_t arg2,grub_uint64_t arg3, +grub_uint64_t arg4,grub_uint64_t arg5, +grub_uint64_t arg6); +#endif +#endif /* ! GRUB_EFI_API_HEADER */
include/grub/efi/pe32.h +27 -1
@@ -64,6 +64,7 @@ struct grub_pe32_coff_header };#define GRUB_PE32_MACHINE_I386 0x14c +#define GRUB_PE32_MACHINE_X86_64 0x8664#define GRUB_PE32_RELOCS_STRIPPED 0x0001#define GRUB_PE32_EXECUTABLE_IMAGE 0x0002
@@ -98,9 +99,13 @@ struct grub_pe32_optional_headergrub_uint32_t entry_addr;grub_uint32_t code_base; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 grub_uint32_t data_base; -grub_uint32_t image_base; +#else +grub_uint64_t image_base; +#endif +grub_uint32_t section_alignment;grub_uint32_t file_alignment;grub_uint16_t major_os_version;
@@ -115,10 +120,23 @@ struct grub_pe32_optional_headergrub_uint32_t checksum;grub_uint16_t subsystem;grub_uint16_t dll_characteristics; + +#if GRUB_TARGET_SIZEOF_VOID_P ==4 +grub_uint32_t stack_reserve_size;grub_uint32_t stack_commit_size;grub_uint32_t heap_reserve_size;grub_uint32_t heap_commit_size; + +#else + +grub_uint64_t stack_reserve_size; +grub_uint64_t stack_commit_size; +grub_uint64_t heap_reserve_size; +grub_uint64_t heap_commit_size; + +#endif +grub_uint32_t loader_flags;grub_uint32_t num_data_directories;
@@ -141,8 +159,16 @@ struct grub_pe32_optional_headerstruct grub_pe32_data_directory reserved_entry; }; +#if GRUB_TARGET_SIZEOF_VOID_P ==4 +#define GRUB_PE32_PE32_MAGIC 0x10b +#else + +#define GRUB_PE32_PE32_MAGIC 0x20b + +#endif +#define GRUB_PE32_SUBSYSTEM_EFI_APPLICATION 10#define GRUB_PE32_NUM_DATA_DIRECTORIES 16
include/grub/elf.h +20 -0
@@ -454,6 +454,7 @@ typedef structthe end of a chain, meaning no further symbols are found in that bucket. */ #define STN_UNDEF 0/* End of a chain. */ +#define STN_ABS 65521/* How to extract and insert information held in the st_other field. */
@@ -1108,8 +1109,27 @@ typedef struct/* Keep this the last entry. */ #define R_386_NUM 38 +/* SUN SPARC specific definitions. */ +/* x86_64 specific definitions. */ +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ #define STT_REGISTER 13/* Global register reserved to app. */
include/grub/i386/linux.h +50 -4
81 lines not on this page · raw message
include/grub/kernel.h +3 -0
@@ -38,6 +38,9 @@ struct grub_module_info {/* Magic number so we know we have modules present. */ grub_uint32_t magic; +#if GRUB_TARGET_SIZEOF_VOID_P ==8 +grub_uint32_t padding; +#endif /* The offset of the modules. */ grub_target_off_t offset;/* The size of all modules plus this header. */
include/grub/x86_64/efi/kernel.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2003,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/>. +*/ + +#ifndef GRUB_MACHINE_KERNEL_HEADER +#define GRUB_MACHINE_KERNEL_HEADER 1 + +/* The prefix which points to the directory where GRUB modules and its +configuration file are located. */ +extern char grub_prefix[]; + +/* The offset of GRUB_PREFIX. */ +#define GRUB_KERNEL_MACHINE_PREFIX 0x8 + +/* End of the data section. */ +#define GRUB_KERNEL_MACHINE_DATA_END 0x50 + +#endif /* ! GRUB_MACHINE_KERNEL_HEADER */ +
include/grub/x86_64/efi/loader.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2002,2003,2004,2006,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/>. +*/ + +#ifndef GRUB_LOADER_MACHINE_HEADER +#define GRUB_LOADER_MACHINE_HEADER 1 + +/* It is necessary to export these functions, because normal mode commands +reuse rescue mode commands. */ +void grub_rescue_cmd_linux (int argc,char *argv[]); +void grub_rescue_cmd_initrd (int argc,char *argv[]); + +#endif /* ! GRUB_LOADER_MACHINE_HEADER */
include/grub/x86_64/efi/machine.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 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/>. +*/ + +#ifndef GRUB_MACHINE_MACHINE_HEADER +#define GRUB_MACHINE_MACHINE_HEADER 1 + +#define GRUB_MACHINE_EFI 1 + +#endif /* ! GRUB_MACHINE_MACHINE_HEADER */
include/grub/x86_64/efi/time.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2006,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/>. +*/ + +#ifndef GRUB_MACHINE_TIME_HEADER +#define GRUB_MACHINE_TIME_HEADER 1 + +#include <grub/efi/time.h> + +#endif /* ! GRUB_MACHINE_TIME_HEADER */
include/grub/x86_64/linux.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2008 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/i386/linux.h>
include/grub/x86_64/setjmp.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2003,2006,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/>. +*/ + +#ifndef GRUB_SETJMP_CPU_HEADER +#define GRUB_SETJMP_CPU_HEADER 1 + +typedef unsigned long grub_jmp_buf [8 ]; + +int grub_setjmp (grub_jmp_buf env); +void grub_longjmp (grub_jmp_buf env,int val) __attribute__ ((noreturn)); + +#endif /* ! GRUB_SETJMP_CPU_HEADER */
include/grub/x86_64/time.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 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/>. +*/ + +#ifndef KERNEL_CPU_TIME_HEADER +#define KERNEL_CPU_TIME_HEADER 1 + +static __inlinevoid +grub_cpu_idle (void ) +{ +/* FIXME: this can't work until we handle interrupts. */ +/* __asm__ __volatile__ ("hlt"); */ +} + +#endif /* ! KERNEL_CPU_TIME_HEADER */
include/grub/x86_64/types.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2008 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/>. +*/ + +#ifndef GRUB_TYPES_CPU_HEADER +#define GRUB_TYPES_CPU_HEADER 1 + +/* The size of void *. */ +#define GRUB_TARGET_SIZEOF_VOID_P 8 + +/* The size of long. */ +#define GRUB_TARGET_SIZEOF_LONG 8 + +/* x86_64 is little-endian. */ +#undef GRUB_TARGET_WORDS_BIGENDIAN + +#endif /* ! GRUB_TYPES_CPU_HEADER */
kern/dl.c +2 -2
@@ -29,7 +29,7 @@#include <grub/env.h> #include <grub/cache.h> -#if GRUB_CPU_SIZEOF_VOID_P ==4 +#if GRUB_TARGET_SIZEOF_VOID_P ==4 typedef Elf32_Word Elf_Word ;typedef Elf32_Addr Elf_Addr ;
@@ -40,7 +40,7 @@ typedef Elf32_Sym Elf_Sym;# define ELF_ST_BIND (val) ELF32_ST_BIND (val)# define ELF_ST_TYPE (val) ELF32_ST_TYPE (val) -#elif GRUB_CPU_SIZEOF_VOID_P ==8 +#elif GRUB_TARGET_SIZEOF_VOID_P ==8 typedef Elf64_Word Elf_Word ;typedef Elf64_Addr Elf_Addr ;
kern/efi/efi.c +21 -23
114 lines not on this page · raw message
kern/efi/mm.c +9 -8
@@ -30,7 +30,7 @@/* The size of a memory map obtained from the firmware. This must be a multiplier of 4KB. */ -#define MEMORY_MAP_SIZE 0x1000 +#define MEMORY_MAP_SIZE 0x3000/* Maintain the list of allocated pages. */ struct allocated_page
@@ -59,7 +59,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,grub_efi_status_t status;grub_efi_boot_services_t *b; -#if GRUB_CPU_SIZEOF_VOID_P <8 +#if GRUB_TARGET_SIZEOF_VOID_P <8 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address >0xffffffff )return 0 ;
@@ -79,7 +79,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,#endif b = grub_efi_system_table->boot_services; - status = b->allocate_pages (type,GRUB_EFI_LOADER_DATA , pages, &address); + status =efi_call_4 (b->allocate_pages, type,GRUB_EFI_LOADER_DATA , pages, &address);if (status !=GRUB_EFI_SUCCESS )return 0 ;
@@ -88,7 +88,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,/* Uggh, the address 0 was allocated... This is too annoying, so reallocate another one. */ address =0xffffffff ; - status = b->allocate_pages (type,GRUB_EFI_LOADER_DATA , pages, &address); + status =efi_call_4 (b->allocate_pages, type,GRUB_EFI_LOADER_DATA , pages, &address);grub_efi_free_pages (0 , pages);if (status !=GRUB_EFI_SUCCESS )return 0 ;
@@ -135,7 +135,7 @@ grub_efi_free_pages (grub_efi_physical_address_t address, } b = grub_efi_system_table->boot_services; - b->free_pages (address, pages); +efi_call_2 (b->free_pages, address, pages); }/* Get the memory map as defined in the EFI spec. Return 1 if successful,
@@ -159,7 +159,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size, descriptor_version = &version; b = grub_efi_system_table->boot_services; - status = b->get_memory_map (memory_map_size, memory_map, map_key, + status =efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key, descriptor_size, descriptor_version);if (status ==GRUB_EFI_SUCCESS )return 1 ;
@@ -218,7 +218,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) {if (desc->type ==GRUB_EFI_CONVENTIONAL_MEMORY -#if GRUB_CPU_SIZEOF_VOID_P < 8 +#if GRUB_TARGET_SIZEOF_VOID_P < 8 && desc->physical_start <=0xffffffff #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
@@ -234,7 +234,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, desc->physical_start =0x100000 ; } -#if GRUB_CPU_SIZEOF_VOID_P <8 +#if GRUB_TARGET_SIZEOF_VOID_P <8 if (BYTES_TO_PAGES (filtered_desc->physical_start) + filtered_desc->num_pages >BYTES_TO_PAGES (0x100000000LL ))
@@ -326,6 +326,7 @@ print_memory_map (grub_efi_memory_descriptor_t *memory_map, desc < memory_map_end; desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size), i++) { +if (desc->type ==GRUB_EFI_CONVENTIONAL_MEMORY )grub_printf ("MD: t=%x, p=%llx, v=%llx, n=%llx, a=%llx\n" , desc->type, desc->physical_start, desc->virtual_start, desc->num_pages, desc->attribute);
kern/term.c +1 -0
@@ -21,6 +21,7 @@#include <grub/mm.h> #include <grub/misc.h> #include <grub/env.h> +#include <grub/efi/efi.h> /* The list of terminals. */ static grub_term_t grub_term_list;
kern/x86_64/dl.c new file +121 -0
121 lines not on this page · raw message
kern/x86_64/efi/callwrap.S new file +96 -0
96 lines not on this page · raw message
kern/x86_64/efi/startup.S new file +61 -0
61 lines not on this page · raw message
loader/efi/chainloader.c +8 -8
@@ -47,9 +47,9 @@ grub_chainloader_unload (void)grub_efi_boot_services_t *b; b = grub_efi_system_table->boot_services; - b->unload_image (image_handle); - b->free_pages (address, pages); -grub_free (file_path); +efi_call_1 (b->unload_image, image_handle); +efi_call_2 (b->free_pages, address, pages); +efi_call_1 (grub_free, file_path);grub_dl_unref (my_mod);return GRUB_ERR_NONE ;
@@ -64,7 +64,7 @@ grub_chainloader_boot (void)grub_efi_char16_t *exit_data; b = grub_efi_system_table->boot_services; - status = b->start_image (image_handle, &exit_data_size, &exit_data); + status =efi_call_3 (b->start_image, image_handle, &exit_data_size, &exit_data);if (status !=GRUB_EFI_SUCCESS ) {if (exit_data)
@@ -86,7 +86,7 @@ grub_chainloader_boot (void) }if (exit_data) - b->free_pool (exit_data); +efi_call_1 (b->free_pool, exit_data);grub_chainloader_unload ();
@@ -227,7 +227,7 @@ grub_chainloader_cmd (const char *filename) size =grub_file_size (file); pages = (((grub_efi_uintn_t ) size + ((1 <<12 ) -1 )) >>12 ); - status = b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES , + status =efi_call_4 (b->allocate_pages,GRUB_EFI_ALLOCATE_ANY_PAGES ,GRUB_EFI_LOADER_CODE , pages, &address);if (status !=GRUB_EFI_SUCCESS )
@@ -244,7 +244,7 @@ grub_chainloader_cmd (const char *filename) goto fail; } - status = b->load_image (0 , grub_efi_image_handle, file_path, + status =efi_call_6 (b->load_image,0 , grub_efi_image_handle, file_path, (void *) ((grub_addr_t ) address), size, &image_handle);if (status !=GRUB_EFI_SUCCESS )
@@ -284,7 +284,7 @@ grub_chainloader_cmd (const char *filename)grub_free (file_path);if (address) - b->free_pages (address, pages); +efi_call_2 (b->free_pages, address, pages);grub_dl_unref (my_mod); }
loader/i386/efi/linux.c +201 -74
436 lines not on this page · raw message
normal/x86_64/setjmp.S new file +64 -0
64 lines not on this page · raw message
term/efi/console.c +13 -13
@@ -52,10 +52,10 @@ grub_console_putchar (grub_uint32_t c) str[1 ] =0 ;/* Should this test be cached? */ -if (c >0x7f && o->test_string (o, str) !=GRUB_EFI_SUCCESS ) +if (c >0x7f &&efi_call_2 (o->test_string, o, str) !=GRUB_EFI_SUCCESS )return ; - o->output_string (o, str); +efi_call_2 (o->output_string, o, str); } static grub_ssize_t
@@ -76,7 +76,7 @@ grub_console_checkkey (void)return 1 ; i = grub_efi_system_table->con_in; - status = i->read_key_stroke (i, &key); + status =efi_call_2 (i->read_key_stroke, i, &key);#if 1 switch (status) {
@@ -169,7 +169,7 @@ grub_console_getkey (void) do { - status = b->wait_for_event (1, &(i->wait_for_key), &index); + status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index); if (status != GRUB_EFI_SUCCESS) return -1;
@@ -189,7 +189,7 @@ grub_console_getwh (void)grub_efi_uintn_t columns, rows; o = grub_efi_system_table->con_out; -if (o->query_mode (o, o->mode->mode, &columns, &rows) !=GRUB_EFI_SUCCESS ) +if (efi_call_4 (o->query_mode, o, o->mode->mode, &columns, &rows) !=GRUB_EFI_SUCCESS ) {/* Why does this fail? */ columns =80 ;
@@ -214,7 +214,7 @@ grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y)grub_efi_simple_text_output_interface_t *o; o = grub_efi_system_table->con_out; - o->set_cursor_position (o, x, y); +efi_call_3 (o->set_cursor_position, o, x, y); } static void
@@ -225,9 +225,9 @@ grub_console_cls (void) o = grub_efi_system_table->con_out; orig_attr = o->mode->attribute; - o->set_attributes (o,GRUB_EFI_BACKGROUND_BLACK ); - o->clear_screen (o); - o->set_attributes (o, orig_attr); +efi_call_2 (o->set_attributes, o,GRUB_EFI_BACKGROUND_BLACK ); +efi_call_1 (o->clear_screen, o); +efi_call_2 (o->set_attributes, o, orig_attr); } static void
@@ -239,13 +239,13 @@ grub_console_setcolorstate (grub_term_color_state state)switch (state) {case GRUB_TERM_COLOR_STANDARD : - o->set_attributes (o, grub_console_standard_color); +efi_call_2 (o->set_attributes, o, grub_console_standard_color);break ;case GRUB_TERM_COLOR_NORMAL : - o->set_attributes (o, grub_console_normal_color); +efi_call_2 (o->set_attributes, o, grub_console_normal_color);break ;case GRUB_TERM_COLOR_HIGHLIGHT : - o->set_attributes (o, grub_console_highlight_color); +efi_call_2 (o->set_attributes, o, grub_console_highlight_color);break ;default :break ;
@@ -272,7 +272,7 @@ grub_console_setcursor (int on)grub_efi_simple_text_output_interface_t *o; o = grub_efi_system_table->con_out; - o->enable_cursor (o, on); +efi_call_2 (o->enable_cursor, o, on); } static struct grub_term grub_console_term =
util/i386/efi/grub-mkimage.c +264 -151
728 lines not on this page · raw message