Skip to contentSkip to conversation

New x86_64 EFI patch

PATCH In review Bean 6 participants 45 messages Jun 20, 2008 – Jul 19, 2008

lore
Share & tools
lore

Bean

author
#0 lore raw

PATCH 1/1 New x86_64 EFI patch

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

boot from usb:
appleloader USB
boot

The usb booting may not work in some machine.

Signature · 1 line
Bean
conf/i386-efi.rmk +17 -2
index 311b6ab..99bb0d4 100644
@@ -74,8 +74,8 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod \
-	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod
+pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod appleldr.mod \
+	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod pci.mod lspci.mod
 
 # For kernel.mod.
 kernel_mod_EXPORTS = no
@@ -123,6 +123,11 @@ chain_mod_SOURCES = loader/efi/chainloader_normal.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
 chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For appleldr.mod.
+appleldr_mod_SOURCES = loader/efi/appleloader.c
+appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
+appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For _linux.mod.
 _linux_mod_SOURCES = loader/i386/efi/linux.c
 _linux_mod_CFLAGS = $(COMMON_CFLAGS)
@@ -148,4 +153,14 @@ reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For pci.mod
+pci_mod_SOURCES = bus/pci.c
+pci_mod_CFLAGS = $(COMMON_CFLAGS)
+pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For lspci.mod
+lspci_mod_SOURCES = commands/lspci.c
+lspci_mod_CFLAGS = $(COMMON_CFLAGS)
+lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
conf/x86_64-efi.rmk new file +169 -0

169 lines not on this page · raw message

configure.ac +24 -5
index 5ec7a47..a5ce826 100644
@@ -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
index e51c2ea..3c5e35f 100644
@@ -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
index 6c29753..96db9a6 100644
@@ -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/chainloader.h +1 -1
index 470132b..d5c11e3 100644
@@ -19,6 +19,6 @@
 #ifndef GRUB_EFI_CHAINLOADER_HEADER
 #define GRUB_EFI_CHAINLOADER_HEADER	1
 
-void grub_chainloader_cmd (const char *filename);
+void grub_rescue_cmd_chainloader (int argc, char *argv[]);
 
 #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
include/grub/efi/pe32.h +27 -1
index b6f01a8..f2072c5 100644
@@ -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_header
   grub_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_header
   grub_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_header
   struct 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/efi/uga_draw.h new file +76 -0

76 lines not on this page · raw message

include/grub/elf.h +20 -0
index 9aec816..7b76f58 100644
@@ -454,6 +454,7 @@ typedef struct
    the 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/efi/pci.h new file +19 -0
new file mode 100755
index 0000000..8480fd7
@@ -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/pc/pci.h>
include/grub/i386/linux.h +90 -13

142 lines not on this page · raw message

include/grub/kernel.h +3 -0
index 4a4e2cc..9cbbdaf 100644
@@ -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/pci.h +13 -0
index 7108886..abc5c90 100644
@@ -22,6 +22,19 @@
 #include <grub/types.h>
 #include <grub/symbol.h>
 
+#define  GRUB_PCI_ADDR_SPACE_MASK	0x01
+#define  GRUB_PCI_ADDR_SPACE_MEMORY	0x00
+#define  GRUB_PCI_ADDR_SPACE_IO		0x01
+
+#define  GRUB_PCI_ADDR_MEM_TYPE_MASK	0x06
+#define  GRUB_PCI_ADDR_MEM_TYPE_32	0x00	/* 32 bit address */
+#define  GRUB_PCI_ADDR_MEM_TYPE_1M	0x02	/* Below 1M [obsolete] */
+#define  GRUB_PCI_ADDR_MEM_TYPE_64	0x04	/* 64 bit address */
+#define  GRUB_PCI_ADDR_MEM_PREFETCH	0x08	/* prefetchable */
+
+#define  GRUB_PCI_ADDR_MEM_MASK		~0xf
+#define  GRUB_PCI_ADDR_IO_MASK		~0x03
+
 typedef grub_uint32_t grub_pci_id_t;
 typedef int (*grub_pci_iteratefunc_t) (int bus, int device, int func,
 				       grub_pci_id_t pciid);
include/grub/x86_64/efi/kernel.h new file +33 -0
new file mode 100644
index 0000000..c0549f4
@@ -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
new file mode 100755
index 0000000..3308be0
@@ -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
new file mode 100755
index 0000000..1600768
@@ -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/pci.h new file +19 -0
new file mode 100755
index 0000000..8480fd7
@@ -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/pc/pci.h>
include/grub/x86_64/efi/time.h new file +24 -0
new file mode 100644
index 0000000..7a9241f
@@ -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
new file mode 100644
index 0000000..19ea936
@@ -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
new file mode 100644
index 0000000..e417f65
@@ -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
new file mode 100644
index 0000000..842882c
@@ -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 __inline void
+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
new file mode 100644
index 0000000..bdee5a1
@@ -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
index 9e8c24a..9654c3a 100644
@@ -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 +8 -8
index 9cd096d..5098ccd 100644
@@ -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))
kern/term.c +1 -0
index 4c45d71..07965b5 100644
@@ -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/appleloader.c new file +208 -0

208 lines not on this page · raw message

loader/efi/chainloader.c +50 -17

132 lines not on this page · raw message

loader/efi/chainloader_normal.c +1 -1
index 2ea3368..455669e 100644
@@ -29,7 +29,7 @@ chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
   if (argc == 0)
     grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
   else
-    grub_chainloader_cmd (args[0]);
+    grub_rescue_cmd_chainloader (argc, args);
   return grub_errno;
 }
 
loader/i386/efi/linux.c +352 -76

620 lines not on this page · raw message

loader/i386/ieee1275/linux.c +65 -0

82 lines not on this page · raw message

normal/x86_64/setjmp.S new file +60 -0

60 lines not on this page · raw message

term/efi/console.c +64 -16

144 lines not on this page · raw message

util/i386/efi/grub-mkimage.c +264 -151

356 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

author
#1 lore raw
Quoted 21 lines · Bean

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

Quoted 5 lines

boot from usb:
appleloader USB
boot

The usb booting may not work in some machine.

Hi,

I also fix a few problem in the linux loader, now it can load both 686 and x86_64 kernel from 64-bit EFI firmware.

Would someone test it in 32-bit EFI ?

Signature · 1 line
Bean
conf/i386-efi.rmk +17 -2
index 311b6ab..99bb0d4 100644
@@ -74,8 +74,8 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod \
-	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod
+pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod appleldr.mod \
+	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod pci.mod lspci.mod
 
 # For kernel.mod.
 kernel_mod_EXPORTS = no
@@ -123,6 +123,11 @@ chain_mod_SOURCES = loader/efi/chainloader_normal.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
 chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For appleldr.mod.
+appleldr_mod_SOURCES = loader/efi/appleloader.c
+appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
+appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For _linux.mod.
 _linux_mod_SOURCES = loader/i386/efi/linux.c
 _linux_mod_CFLAGS = $(COMMON_CFLAGS)
@@ -148,4 +153,14 @@ reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
 reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For pci.mod
+pci_mod_SOURCES = bus/pci.c
+pci_mod_CFLAGS = $(COMMON_CFLAGS)
+pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For lspci.mod
+lspci_mod_SOURCES = commands/lspci.c
+lspci_mod_CFLAGS = $(COMMON_CFLAGS)
+lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 include $(srcdir)/conf/common.mk
conf/x86_64-efi.rmk new file +169 -0

169 lines not on this page · raw message

configure.ac +24 -5
index 5ec7a47..a5ce826 100644
@@ -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
index e51c2ea..3c5e35f 100644
@@ -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
index 6c29753..96db9a6 100644
@@ -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/chainloader.h +1 -1
index 470132b..d5c11e3 100644
@@ -19,6 +19,6 @@
 #ifndef GRUB_EFI_CHAINLOADER_HEADER
 #define GRUB_EFI_CHAINLOADER_HEADER	1
 
-void grub_chainloader_cmd (const char *filename);
+void grub_rescue_cmd_chainloader (int argc, char *argv[]);
 
 #endif /* ! GRUB_EFI_CHAINLOADER_HEADER */
include/grub/efi/pe32.h +27 -1
index b6f01a8..f2072c5 100644
@@ -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_header
   grub_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_header
   grub_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_header
   struct 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/efi/uga_draw.h new file +76 -0

76 lines not on this page · raw message

include/grub/elf.h +20 -0
index 9aec816..7b76f58 100644
@@ -454,6 +454,7 @@ typedef struct
    the 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/efi/pci.h new file +19 -0
new file mode 100755
index 0000000..8480fd7
@@ -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/pc/pci.h>
include/grub/i386/linux.h +92 -13

138 lines not on this page · raw message

include/grub/kernel.h +3 -0
index 4a4e2cc..9cbbdaf 100644
@@ -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/pci.h +13 -0
index 7108886..abc5c90 100644
@@ -22,6 +22,19 @@
 #include <grub/types.h>
 #include <grub/symbol.h>
 
+#define  GRUB_PCI_ADDR_SPACE_MASK	0x01
+#define  GRUB_PCI_ADDR_SPACE_MEMORY	0x00
+#define  GRUB_PCI_ADDR_SPACE_IO		0x01
+
+#define  GRUB_PCI_ADDR_MEM_TYPE_MASK	0x06
+#define  GRUB_PCI_ADDR_MEM_TYPE_32	0x00	/* 32 bit address */
+#define  GRUB_PCI_ADDR_MEM_TYPE_1M	0x02	/* Below 1M [obsolete] */
+#define  GRUB_PCI_ADDR_MEM_TYPE_64	0x04	/* 64 bit address */
+#define  GRUB_PCI_ADDR_MEM_PREFETCH	0x08	/* prefetchable */
+
+#define  GRUB_PCI_ADDR_MEM_MASK		~0xf
+#define  GRUB_PCI_ADDR_IO_MASK		~0x03
+
 typedef grub_uint32_t grub_pci_id_t;
 typedef int (*grub_pci_iteratefunc_t) (int bus, int device, int func,
 				       grub_pci_id_t pciid);
include/grub/x86_64/efi/kernel.h new file +33 -0
new file mode 100644
index 0000000..c0549f4
@@ -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 +32 -0
new file mode 100755
index 0000000..4368a82
@@ -0,0 +1,32 @@
+/*
+ *  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
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+/* 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[]);
+
+void EXPORT_FUNC(grub_linux_real_boot) (void);
+
+#endif /* ! GRUB_LOADER_MACHINE_HEADER */
include/grub/x86_64/efi/machine.h new file +24 -0
new file mode 100755
index 0000000..1600768
@@ -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/pci.h new file +19 -0
new file mode 100755
index 0000000..8480fd7
@@ -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/pc/pci.h>
include/grub/x86_64/efi/time.h new file +24 -0
new file mode 100644
index 0000000..7a9241f
@@ -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
new file mode 100644
index 0000000..19ea936
@@ -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
new file mode 100644
index 0000000..e417f65
@@ -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
new file mode 100644
index 0000000..842882c
@@ -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 __inline void
+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
new file mode 100644
index 0000000..bdee5a1
@@ -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
index 9e8c24a..9654c3a 100644
@@ -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 +8 -8
index 9cd096d..5098ccd 100644
@@ -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))
kern/term.c +1 -0
index 4c45d71..07965b5 100644
@@ -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 +87 -0

87 lines not on this page · raw message

loader/efi/appleloader.c new file +208 -0

208 lines not on this page · raw message

loader/efi/chainloader.c +50 -17

132 lines not on this page · raw message

loader/efi/chainloader_normal.c +1 -1
index 2ea3368..455669e 100644
@@ -29,7 +29,7 @@ chainloader_command (struct grub_arg_list *state __attribute__ ((unused)),
   if (argc == 0)
     grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
   else
-    grub_chainloader_cmd (args[0]);
+    grub_rescue_cmd_chainloader (argc, args);
   return grub_errno;
 }
 
loader/i386/efi/linux.c +348 -62

601 lines not on this page · raw message

loader/i386/ieee1275/linux.c +65 -0

82 lines not on this page · raw message

normal/x86_64/setjmp.S new file +60 -0

60 lines not on this page · raw message

term/efi/console.c +64 -16

144 lines not on this page · raw message

util/i386/efi/grub-mkimage.c +264 -151

348 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#2 lore raw
Quoted 22 lines · Bean
Quoted 21 lines · Bean

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

Quoted 5 lines
Quoted 5 lines

boot from usb:
appleloader USB
boot

The usb booting may not work in some machine.

I'm not so sure about that syntax. Is there really only one way to boot from HD or USB? (for example I've been storing pc-GRUB2 in fat16 header on third partition, not mbr, and rEFIt finds it there). How does Windows do it (can we boot Windows using this)? (even though Apple made BootCamp for windows, I don't want to find out personally.) I guess you're stuck with some limitations of the apple bios software? Also , "appleloader CD" makes me think it should be used even for Mac OS X boot-CD's, which I doubt it should?

Quoted 4 lines

Hi,

I also fix a few problem in the linux loader, now it can load both 686 and x86_64 kernel from 64-bit EFI firmware.

do you mean linux successfully booting, or hanging as before?

Quoted 1 line

Would someone test it in 32-bit EFI ?

I get an error during make, after (from a clean tree) cvs up; patch -p1 -l < ~/../downloads/efi_5.diff; ./configure --with-platform=efi; make

cat kernel_syms.lst def-normal.lst def-_chain.lst def-chain.lst def-_linux.lst def-linux.lst def-cpuid.lst def-halt.lst def-reboot.lst def-fshelp.lst def-fat.lst def-ufs.lst def-ext2.lst def-ntfs.lst def-ntfscomp.lst def-minix.lst def-hfs.lst def-jfs.lst def-iso9660.lst def-xfs.lst def-affs.lst def-sfs.lst def-hfsplus.lst def-reiserfs.lst def-cpio.lst def-udf.lst def-afs.lst def-amiga.lst def-apple.lst def-pc.lst def-sun.lst def-acorn.lst def-gpt.lst def-raid.lst def-lvm.lst def-hello.lst def-boot.lst def-terminal.lst def-ls.lst def-cmp.lst def-cat.lst def-echo.lst def-help.lst def-font.lst def-search.lst def-test.lst def-loopback.lst def-configfile.lst def-terminfo.lst def-blocklist.lst def-hexdump.lst def-elf.lst def-gzio.lst def-read.lst def-sleep.lst /dev/null \
| mawk -f ./genmoddep.awk und-kernel.lst und-normal.lst

und-_chain.lst und-chain.lst und-_linux.lst und-linux.lst und-cpuid.lst und-halt.lst und-reboot.lst und-fshelp.lst und-fat.lst und-ufs.lst und-ext2.lst und-ntfs.lst und-ntfscomp.lst und-minix.lst und-hfs.lst und-jfs.lst und-iso9660.lst und-xfs.lst und-affs.lst und-sfs.lst und-hfsplus.lst und-reiserfs.lst und-cpio.lst und-udf.lst und-afs.lst und-amiga.lst und-apple.lst und-pc.lst und-sun.lst und-acorn.lst und-gpt.lst und-raid.lst und-lvm.lst und-hello.lst und-boot.lst und-terminal.lst und-ls.lst und-cmp.lst und-cat.lst und-echo.lst und-help.lst und-font.lst und-search.lst und-test.lst und-loopback.lst und-configfile.lst und-terminfo.lst und-blocklist.lst und-hexdump.lst und-elf.lst und-gzio.lst und-read.lst und-sleep.lst > moddep.lst \
	  || (rm -f moddep.lst; exit 1)

grub_pci_make_address in _linux is not defined
make: *** [moddep.lst] Error 1

author
#3 lore raw
Quoted 32 lines · Isaac Dupree
Quoted 25 lines · Bean
Quoted 23 lines · Bean

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

Quoted 5 lines
Quoted 5 lines

boot from usb:
appleloader USB
boot

The usb booting may not work in some machine.

Quoted 8 lines

I'm not so sure about that syntax. Is there really only one way to boot from HD or USB? (for example I've been storing pc-GRUB2 in fat16 header on third partition, not mbr, and rEFIt finds it there). How does Windows do it (can we boot Windows using this)? (even though Apple made BootCamp for windows, I don't want to find out personally.) I guess you're stuck with some limitations of the apple bios software? Also , "appleloader CD" makes me think it should be used even for Mac OS X boot-CD's, which I doubt it should?

Yes, this is the only way to boot from legacy HD/CD. Refit is using the same method, but it also writes an embedded syslinux mbr to the disk, and mark the partition as active, this is how it boots from different partition.

Quoted 6 lines
Quoted 4 lines

Hi,

I also fix a few problem in the linux loader, now it can load both 686 and x86_64 kernel from 64-bit EFI firmware.

do you mean linux successfully booting, or hanging as before?

It can boot both x86_64 and 686 kernel from 64-bit EFI firmware, while previously it can only boot x86_64.

Quoted 30 lines
Quoted 2 lines

Would someone test it in 32-bit EFI ?

I get an error during make, after (from a clean tree) cvs up; patch -p1 -l < ~/../downloads/efi_5.diff; ./configure --with-platform=efi; make

cat kernel_syms.lst def-normal.lst def-_chain.lst def-chain.lst def-_linux.lst def-linux.lst def-cpuid.lst def-halt.lst def-reboot.lst def-fshelp.lst def-fat.lst def-ufs.lst def-ext2.lst def-ntfs.lst def-ntfscomp.lst def-minix.lst def-hfs.lst def-jfs.lst def-iso9660.lst def-xfs.lst def-affs.lst def-sfs.lst def-hfsplus.lst def-reiserfs.lst def-cpio.lst def-udf.lst def-afs.lst def-amiga.lst def-apple.lst def-pc.lst def-sun.lst def-acorn.lst def-gpt.lst def-raid.lst def-lvm.lst def-hello.lst def-boot.lst def-terminal.lst def-ls.lst def-cmp.lst def-cat.lst def-echo.lst def-help.lst def-font.lst def-search.lst def-test.lst def-loopback.lst def-configfile.lst def-terminfo.lst def-blocklist.lst def-hexdump.lst def-elf.lst def-gzio.lst def-read.lst def-sleep.lst /dev/null \
| mawk -f ./genmoddep.awk und-kernel.lst und-normal.lst
und-_chain.lst und-chain.lst und-_linux.lst und-linux.lst und-cpuid.lst und-halt.lst und-reboot.lst und-fshelp.lst und-fat.lst und-ufs.lst und-ext2.lst und-ntfs.lst und-ntfscomp.lst und-minix.lst und-hfs.lst und-jfs.lst und-iso9660.lst und-xfs.lst und-affs.lst und-sfs.lst und-hfsplus.lst und-reiserfs.lst und-cpio.lst und-udf.lst und-afs.lst und-amiga.lst und-apple.lst und-pc.lst und-sun.lst und-acorn.lst und-gpt.lst und-raid.lst und-lvm.lst und-hello.lst und-boot.lst und-terminal.lst und-ls.lst und-cmp.lst und-cat.lst und-echo.lst und-help.lst und-font.lst und-search.lst und-test.lst und-loopback.lst und-configfile.lst und-terminfo.lst und-blocklist.lst und-hexdump.lst und-elf.lst und-gzio.lst

Quoted 4 lines
und-read.lst und-sleep.lst > moddep.lst \
         || (rm -f moddep.lst; exit 1)

grub_pci_make_address in _linux is not defined
make: *** [moddep.lst] Error 1

You should also run ./autogen.sh to update the mk files. Also, I have uploaded an binary version at:

http://grub4dos.sourceforge.net/grub2/grub.efi.1

You can use it if you still can't compile it successfully.

Signature · 1 line
Bean
#4 lore raw
In reply to Bean
Quoted 26 lines · Bean
Quoted 25 lines · Bean

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

boot from usb:
appleloader USB
boot

Quoted 8 lines
Quoted 1 line

The usb booting may not work in some machine.

Hi,

I also fix a few problem in the linux loader, now it can load both 686 and x86_64 kernel from 64-bit EFI firmware.

Would someone test it in 32-bit EFI ?

with just that patch against CVS, for me

- linux then initrd doesn't run out of memory (that fix is still there).
On the other hand, 'linux' with wrong parameters so I repeated the
command, did give me such an error. In any case, trying again perfectly and booting, gave me the same (as my last test with your EFI patches) hanging on the GRUB terminal, not booting successfully.

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands. (admittedly, I think I didn't *have* anything to boot in my CD drive, USB or MBR)

-Isaac

author
#5 lore raw
Quoted 39 lines · Isaac Dupree
Quoted 29 lines · Bean
Quoted 27 lines · Bean

Hi,

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

boot from legacy mbr:
appleloader HD
boot

boot from legacy cd:
appleloader CD
boot

boot from usb:
appleloader USB
boot

Quoted 8 lines
Quoted 1 line

The usb booting may not work in some machine.

Hi,

I also fix a few problem in the linux loader, now it can load both 686 and x86_64 kernel from 64-bit EFI firmware.

Would someone test it in 32-bit EFI ?

Quoted 8 lines

with just that patch against CVS, for me

- linux then initrd doesn't run out of memory (that fix is still there). On the other hand, 'linux' with wrong parameters so I repeated the command, did give me such an error. In any case, trying again perfectly and booting, gave me the same (as my last test with your EFI patches) hanging on the GRUB terminal, not booting successfully.

What's the kernel version ? Perhaps you need the latest 2.6.25 series.

Also, you can try adding video=efifb to the command line, does it show kernel message ?

Quoted 5 lines

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands. (admittedly, I think I didn't *have* anything to boot in my CD drive, USB
or MBR)

The model is quite old, it's possible that it uses xom. Is there a /System/Library/CoreServices/xom.efi in the OSX partition ?

Signature · 1 line
Bean
#6 lore raw
Quoted 8 lines · Bean
Quoted 6 lines

- linux then initrd doesn't run out of memory (that fix is still there). On the other hand, 'linux' with wrong parameters so I repeated the command, did give me such an error. In any case, trying again perfectly and booting, gave me the same (as my last test with your EFI patches) hanging on the GRUB terminal, not booting successfully.

What's the kernel version ? Perhaps you need the latest 2.6.25 series.

oh, maybe. It's an Ubuntu kernel.

Quoted 1 line

uname -a

Linux east 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux

Quoted 2 lines

Also, you can try adding video=efifb to the command line, does it show kernel message ?

I'll try that soon, does it need any special customization of the kernel?

Quoted 8 lines
Quoted 5 lines

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands. (admittedly, I think I didn't *have* anything to boot in my CD drive, USB
or MBR)

The model is quite old, it's possible that it uses xom. Is there a /System/Library/CoreServices/xom.efi in the OSX partition ?

only one year old :)))

No, there isn't.. the only .efi file in that directory is /System/Library/CoreServices/boot.efi

-Isaac

author
#7 lore raw
Quoted 15 lines · Isaac Dupree
Quoted 11 lines · Bean
Quoted 10 lines

- linux then initrd doesn't run out of memory (that fix is still there). On
the other hand, 'linux' with wrong parameters so I repeated the command, did
give me such an error. In any case, trying again perfectly and booting, gave me the same (as my last test with your EFI patches) hanging on the GRUB
terminal, not booting successfully.

Quoted 1 line

What's the kernel version ? Perhaps you need the latest 2.6.25 series.

oh, maybe. It's an Ubuntu kernel.

Quoted 8 lines
Quoted 1 line

uname -a

Linux east 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux

Quoted 2 lines

Also, you can try adding video=efifb to the command line, does it show kernel message ?

I'll try that soon, does it need any special customization of the kernel?

You can try the kernel I extract from Fedora's efidisk:

http://grub4dos.sourceforge.net/grub2/efi.rar

It's 2.6.25. But there is a small problem with this kernel, the screen would scramble after some kernel output. This is caused by the agp driver, not grub's fault.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no
matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands.
(admittedly, I think I didn't *have* anything to boot in my CD drive,
USB
or MBR)

Quoted 4 lines
Quoted 2 lines

The model is quite old, it's possible that it uses xom. Is there a /System/Library/CoreServices/xom.efi in the OSX partition ?

only one year old :)))

Interesting, according to refit, this should be an early 2006 model. Refit does work, doesn't it ?

Signature · 1 line
Bean
#8 lore raw
Quoted 11 lines · Bean
Quoted 3 lines
Quoted 2 lines

Also, you can try adding video=efifb to the command line, does it show kernel message ?

I'll try that soon, does it need any special customization of the kernel?

You can try the kernel I extract from Fedora's efidisk:

http://grub4dos.sourceforge.net/grub2/efi.rar

It's 2.6.25. But there is a small problem with this kernel, the screen would scramble after some kernel output. This is caused by the agp driver, not grub's fault.

Results:
Whatever linux kernel I pick, adding video=efifb to its commandline causes grub to output a couple extra lines in response to linux:
Video mode: 1280x800-32@59
Video framebuffer: 80000000

Even with video=efifb, the Ubuntu kernel works no better. But that Fedora kernel you mentioned, does work:
- with video=efifb, the penguin and kernel messages flash onto the screen for a moment before the screen turns into gibberish.
- without, the screen just turns into different gibberish, which is still an improvement over the GRUB screen remaining there :-)

Of course, that Linux kernel doesn't bring me to anything *usable*... but it shows that we're loading Linux and it's probably possible to work in practice by compiling a new enough Linux with the right configs (and maybe patches)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no
matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands.
(admittedly, I think I didn't *have* anything to boot in my CD drive,
USB
or MBR)

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

The model is quite old, it's possible that it uses xom. Is there a /System/Library/CoreServices/xom.efi in the OSX partition ?

only one year old :)))

Interesting, according to refit, this should be an early 2006 model. Refit does work, doesn't it ?

refit doesn't tell *me* anything about the model when I'm in refit. In case what your appleloader says was confusing you, I actually have a 2.16 GHz Intel Core 2 Duo CPU (yes, 64-bit capable, I've just never used it in that way). I'm still running refit 0.9 though since I never yet bothered to upgrade to 0.10 or 0.11, and since it works fine for me.

-Isaac

author
#9 lore raw
Quoted 28 lines · Isaac Dupree
Quoted 6 lines · Bean
Quoted 5 lines
Quoted 3 lines

Also, you can try adding video=efifb to the command line, does it show kernel message ?

I'll try that soon, does it need any special customization of the kernel?

Quoted 7 lines

You can try the kernel I extract from Fedora's efidisk:

http://grub4dos.sourceforge.net/grub2/efi.rar

It's 2.6.25. But there is a small problem with this kernel, the screen would scramble after some kernel output. This is caused by the agp driver, not grub's fault.

Results:
Whatever linux kernel I pick, adding video=efifb to its commandline causes grub to output a couple extra lines in response to linux:
Video mode: 1280x800-32@59
Video framebuffer: 80000000

Even with video=efifb, the Ubuntu kernel works no better. But that Fedora kernel you mentioned, does work:
- with video=efifb, the penguin and kernel messages flash onto the screen for a moment before the screen turns into gibberish.
- without, the screen just turns into different gibberish, which is still an improvement over the GRUB screen remaining there :-)

Quoted 6 lines

Of course, that Linux kernel doesn't bring me to anything *usable*... but it shows that we're loading Linux and it's probably possible to work in practice by compiling a new enough Linux with the right configs (and maybe patches)

I'm using the 2.6.25 kernel from debian sid, it works fine. I think ubuntu can use debian packages as well. To solve the screen problem, you need the following command line:

video=efifb agp=off

If you're interested, you can also try amd64 kernel. You can use it on 686 linux directly, no need to install a full amd64 system.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 10 lines
Quoted 7 lines

- appleloader always tells me "Model : Core Duo/Solo" and nothing else (no
matter whether I give it a parameter or not). If I say "boot" nothing happens, it just stays in GRUB prompt and I can enter more commands.
(admittedly, I think I didn't *have* anything to boot in my CD drive,
USB
or MBR)

The model is quite old, it's possible that it uses xom. Is there a /System/Library/CoreServices/xom.efi in the OSX partition ?

only one year old :)))

Quoted 8 lines
Quoted 2 lines

Interesting, according to refit, this should be an early 2006 model. Refit does work, doesn't it ?

refit doesn't tell *me* anything about the model when I'm in refit. In case what your appleloader says was confusing you, I actually have a 2.16 GHz Intel Core 2 Duo CPU (yes, 64-bit capable, I've just never used it in that way). I'm still running refit 0.9 though since I never yet bothered to upgrade to 0.10 or 0.11, and since it works fine for me.

I take a look at 0.9 source, the handling is the same. Are you sure you type the command exactly as it is ?

appleloader HD
boot

You can also try my compiled version, see if it works.

Signature · 1 line
Bean
#10 lore raw
Quoted 5 lines · Bean

I take a look at 0.9 source, the handling is the same. Are you sure you type the command exactly as it is ?

appleloader HD
boot

what should I expect the result to be, given that refit is the only thing that's ever touched my MBR since Apple's manufacturing? (so there's a fake partition table created by refit's gptsync, and maybe there's whatever you were saying about refit using hacks with the mbr to boot grub-pc from my third partition, but I've never specifically installed any bootloaders to this mbr)

-Isaac

author
#11 lore raw
Quoted 8 lines · Isaac Dupree
Quoted 6 lines · Bean

I take a look at 0.9 source, the handling is the same. Are you sure you type the command exactly as it is ?

appleloader HD
boot

Quoted 6 lines

what should I expect the result to be, given that refit is the only thing that's ever touched my MBR since Apple's manufacturing? (so there's a fake partition table created by refit's gptsync, and maybe there's whatever you were saying about refit using hacks with the mbr to boot grub-pc from my third partition, but I've never specifically installed any bootloaders to this mbr)

Perhaps command line is not passed to loader correctly, you can verify it with the OSX loader:

set root=(hd0,2)
chainloader /System/Library/CoreServices/boot.efi -- -v boot

Please try this out, if parameter -v is passed to the loader, you will see console screen before switching to GUI.

Quoted 1 line

every time I've tried Ubuntu with a different kernel... it has problems. Ubuntu has a fancy initrd, modules, lots of patches, Upstart as init, >and who knows what assumptions about the boot process... but maybe. I could use the kernel from the Ubuntu development branch, if I >had any idea how to use APT to upgrade just a few specific things from an unstable package-source and not my whole system (the kernel >binary obviously doesn't depend on system libraries, so it should be uniquely easy to do this...). Do you know about debians -- if that's >possible?

In debian, all I have to do is to add the sid line to /etc/apt/source.list, apt-get update, then apt-get install linux-image-xxx. Ubuntu is based on debian, the process should be similar.

Signature · 1 line
Bean
#12 lore raw
Quoted 9 lines · Bean

Perhaps command line is not passed to loader correctly, you can verify it with the OSX loader:

set root=(hd0,2)
chainloader /System/Library/CoreServices/boot.efi -- -v boot

Please try this out, if parameter -v is passed to the loader, you will see console screen before switching to GUI.

That 'chainloader' didn't work at all: It seems GRUB2 here isn't understanding the HFS+(journaled) filesystem at all. Neither in EFI nor BIOS grub2 can I see anything on that partition, even though I have module hfsplus loaded (I think - but lsmod in grub takes up more than the whole screen, so I can't see them all - is there any way to get around that?).

Also I decided to play around and try a few other commands in grub2. cpuid (efi or pc) -- finishes instantly without outputting anything lspci (efi) -- hangs (but it works properly in pc)
reboot (efi) -- hangs (but it works properly in pc)

Quoted 7 lines
Quoted 2 lines

every time I've tried Ubuntu with a different kernel... it has problems. Ubuntu has a fancy initrd, modules, lots of patches, Upstart as init, >and who knows what assumptions about the boot process... but maybe. I could use the kernel from the Ubuntu development branch, if I >had any idea how to use APT to upgrade just a few specific things from an unstable package-source and not my whole system (the kernel >binary obviously doesn't depend on system libraries, so it should be uniquely easy to do this...). Do you know about debians -- if that's >possible?

In debian, all I have to do is to add the sid line to /etc/apt/source.list, apt-get update, then apt-get install linux-image-xxx. Ubuntu is based on debian, the process should be similar.

yes it is similar (and I'd probably try and use the Ubuntu development branch for the next release, "intrepid") : however, what bothers me is that this seems to make the whole apt repo, not just the part I want, be a first-class citizen; so that if it contains a newer version number of any package on my system, it will install that if I ask to install the package, or it will offer to upgrade to that version if it's already installed (so I can't even begin to pick out which are the Ubuntu-stable updates). I hope I'm missing some option that lets me avoid this risky nuisance, while still keeping tabs on the unstable linux-image packages?

-Isaac

author
#13 lore raw
Quoted 18 lines · Isaac Dupree
Quoted 10 lines · Bean

Perhaps command line is not passed to loader correctly, you can verify it with the OSX loader:

set root=(hd0,2)
chainloader /System/Library/CoreServices/boot.efi -- -v boot

Please try this out, if parameter -v is passed to the loader, you will see console screen before switching to GUI.

That 'chainloader' didn't work at all: It seems GRUB2 here isn't understanding the HFS+(journaled) filesystem at all. Neither in EFI nor BIOS grub2 can I see anything on that partition, even though I have module hfsplus loaded (I think - but lsmod in grub takes up more than the whole screen, so I can't see them all - is there any way to get around that?).

Quoted 5 lines

Also I decided to play around and try a few other commands in grub2. cpuid (efi or pc) -- finishes instantly without outputting anything lspci (efi) -- hangs (but it works properly in pc)
reboot (efi) -- hangs (but it works properly in pc)

I wonder if there is bug in the hfsplus module. You can check it out with grub-fstest command:

sudo ./grub-fstest /dev/sda3 ls /

This would list the content of root directory.

You can also create a small hfs+ image and test it with grub-fstest, if it does have problem, you can upload the image for me to test.

cpuid would check if cpuid exists and set return code, there is no output.

The result is lspci is a little strange. Is there any output before hanging ? When you use video=efifb or video=vesafb. It enum pci to get the frame buffer address, if it doesn't hang there, it shouldn't hang here as well.

reboot could be a firmware related issue, I can check it out.

Oh btw, do you compile from source or use the binary version ?

Quoted 15 lines
Quoted 10 lines
Quoted 9 lines

every time I've tried Ubuntu with a different kernel... it has problems.
Ubuntu has a fancy initrd, modules, lots of patches, Upstart as init, >and
who knows what assumptions about the boot process... but maybe. I could use the kernel from the Ubuntu development branch, if I >had any idea how to use APT to upgrade just a few specific things from an unstable package-source and not my whole system (the kernel >binary obviously doesn't depend on system libraries, so it should be uniquely easy to do this...). Do you know about debians -- if that's >possible?

Quoted 4 lines

In debian, all I have to do is to add the sid line to /etc/apt/source.list, apt-get update, then apt-get install linux-image-xxx. Ubuntu is based on debian, the process should be similar.

Quoted 9 lines

yes it is similar (and I'd probably try and use the Ubuntu development branch for the next release, "intrepid") : however, what bothers me is that this seems to make the whole apt repo, not just the part I want, be a first-class citizen; so that if it contains a newer version number of any package on my system, it will install that if I ask to install the package, or it will offer to upgrade to that version if it's already installed (so I can't even begin to pick out which are the Ubuntu-stable updates). I hope I'm missing some option that lets me avoid this risky nuisance, while still keeping tabs on the unstable linux-image packages?

Perhaps the most simple way is to download the deb package from intrpid, then install it with dpkg.

Signature · 1 line
Bean
#14 lore raw
Quoted 6 lines · Bean

I wonder if there is bug in the hfsplus module. You can check it out with grub-fstest command:

sudo ./grub-fstest /dev/sda3 ls /

This would list the content of root directory.

outputs nothing, just a blank line, for /dev/sda2 which is my hfsplus (it works fine for fat16, ext3 partitions).

Quoted 2 lines

You can also create a small hfs+ image and test it with grub-fstest, if it does have problem, you can upload the image for me to test.

not sure how to create a hfs+ image... the one I have is many gigabytes and came with the laptop (I just shrunk it to 30GB to fit my linuxes, is all). Does Linux or MacOSX provide a way to create a small HFSJ image?
(also I could try going to MacOSX and turning off journalling and see
if it affects grub2's ability to read it at all, perhaps - although for just reading, not writing, I doubt it makes a significant difference)

Quoted 1 line

cpuid would check if cpuid exists and set return code, there is no output.

oh, okay, then it's just the command's help description that was confusing me

Quoted 2 lines

The result is lspci is a little strange. Is there any output before hanging ?

no, I hit enter and never get back a prompt or any output

Quoted 3 lines

When you use video=efifb or video=vesafb. It enum pci to get the frame buffer address, if it doesn't hang there, it shouldn't hang here as well.

odd, because that definitely didn't hang (when loading linux-2.6.25 that is).

Quoted 2 lines

reboot could be a firmware related issue, I can check it out.

okay, maybe it is

Quoted 1 line

Oh btw, do you compile from source or use the binary version ?

I compile grub2 from source

-Isaac

author
#15 lore raw
Quoted 40 lines · Isaac Dupree
Quoted 7 lines · Bean

I wonder if there is bug in the hfsplus module. You can check it out with grub-fstest command:

sudo ./grub-fstest /dev/sda3 ls /

This would list the content of root directory.

outputs nothing, just a blank line, for /dev/sda2 which is my hfsplus (it works fine for fat16, ext3 partitions).

Quoted 2 lines

You can also create a small hfs+ image and test it with grub-fstest, if it does have problem, you can upload the image for me to test.

not sure how to create a hfs+ image... the one I have is many gigabytes and came with the laptop (I just shrunk it to 30GB to fit my linuxes, is all).
Does Linux or MacOSX provide a way to create a small HFSJ image? (also I
could try going to MacOSX and turning off journalling and see if it affects grub2's ability to read it at all, perhaps - although for just reading, not writing, I doubt it makes a significant difference)

Quoted 1 line

cpuid would check if cpuid exists and set return code, there is no output.

oh, okay, then it's just the command's help description that was confusing me

Quoted 2 lines

The result is lspci is a little strange. Is there any output before hanging ?

no, I hit enter and never get back a prompt or any output

Quoted 3 lines

When you use video=efifb or video=vesafb. It enum pci to get the frame buffer address, if it doesn't hang there, it shouldn't hang here as well.

odd, because that definitely didn't hang (when loading linux-2.6.25 that is).

Quoted 1 line
Quoted 7 lines
Quoted 1 line

reboot could be a firmware related issue, I can check it out.

okay, maybe it is

Quoted 1 line

Oh btw, do you compile from source or use the binary version ?

I compile grub2 from source

Hi,

Perhaps you can also try the binary version at:

http://grub4dos.sourceforge.net/grub2/grub.efi.1

A friend of mine have tested in in 32-bit EFI firmware, there is no problem for him.

Signature · 1 line
Bean
author
#16 lore raw

Hi,

Any comment ?

As this patch is quite large, it's getting more difficult to sync with HEAD. If there is no objection, I'd like to commit it soon.

Signature · 1 line
Bean
#17 lore raw
In reply to Bean
Quoted 8 lines · Bean

Hi,

Perhaps you can also try the binary version at:

http://grub4dos.sourceforge.net/grub2/grub.efi.1

A friend of mine have tested in in 32-bit EFI firmware, there is no problem for him.

It confuses me! I could boot it from refit as EFI. Then it claimed to be GRUB 0.97. The "help" looked slightly different that what I was familiar with (but I've never used grub1 so I don't know...); and reboot worked. I didn't test more yet.. should I?

-Isaac

author
#18 lore raw
Quoted 8 lines · Isaac Dupree
Quoted 7 lines · Bean

Hi,

Perhaps you can also try the binary version at:

http://grub4dos.sourceforge.net/grub2/grub.efi.1

Quoted 7 lines
Quoted 2 lines

A friend of mine have tested in in 32-bit EFI firmware, there is no problem for him.

It confuses me! I could boot it from refit as EFI. Then it claimed to be GRUB 0.97. The "help" looked slightly different that what I was familiar with (but I've never used grub1 so I don't know...); and reboot worked. I didn't test more yet.. should I?

Hi,

That's the fedora efi loader, have you used the right file ?

BTW, you need to rename it as grub.efi, refit can't find files with .1 suffix.

Signature · 1 line
Bean
#19 lore raw
Quoted 16 lines · Bean
Quoted 5 lines · Isaac Dupree
Quoted 4 lines · Bean

Hi,

Perhaps you can also try the binary version at:

Quoted 8 lines
Quoted 4 lines

http://grub4dos.sourceforge.net/grub2/grub.efi.1

A friend of mine have tested in in 32-bit EFI firmware, there is no problem for him.

It confuses me! I could boot it from refit as EFI. Then it claimed to be GRUB 0.97. The "help" looked slightly different that what I was familiar with (but I've never used grub1 so I don't know...); and reboot worked. I didn't test more yet.. should I?

Quoted 5 lines

Hi,

That's the fedora efi loader, have you used the right file ?

BTW, you need to rename it as grub.efi, refit can't find files with .1 suffix.

oh, oops :-/ Now, actually using that file :-)
-- reboot and lspci work, unlike in my version (I wonder why they're different??)
-- appleloader works equally badly as with my compile.
-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

-Isaac

author
#20 lore raw
Quoted 25 lines · Isaac Dupree
Quoted 24 lines · Bean
Quoted 12 lines · Isaac Dupree
Quoted 9 lines · Bean

Hi,

Perhaps you can also try the binary version at:

http://grub4dos.sourceforge.net/grub2/grub.efi.1

A friend of mine have tested in in 32-bit EFI firmware, there is no problem for him.

Quoted 6 lines

It confuses me! I could boot it from refit as EFI. Then it claimed to be
GRUB 0.97. The "help" looked slightly different that what I was familiar with (but I've never used grub1 so I don't know...); and reboot worked.
I
didn't test more yet.. should I?

Hi,

Quoted 8 lines
Quoted 4 lines

That's the fedora efi loader, have you used the right file ?

BTW, you need to rename it as grub.efi, refit can't find files with .1 suffix.

oh, oops :-/ Now, actually using that file :-)
-- reboot and lspci work, unlike in my version (I wonder why they're different??)

Oh nice. What about hfs+, can you read files from the osx partition ?

Quoted 1 line

-- appleloader works equally badly as with my compile.

This command is firmware related, some model may not work.

Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb. grub2 will detect these options and setup frame buffer for you. You also need to use agp=off to disable agp.

Signature · 1 line
Bean
#21 lore raw
Quoted 5 lines · Bean
Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb.

How come? I thought intelfb used the bare hardware.

Quoted 2 lines

grub2 will detect these options and setup
frame buffer for you.

Can you be more specific? I thought grub was completely agnostic about Linux parameters.

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 /.)
author
#22 lore raw
Quoted 8 lines · Robert Millan
Quoted 5 lines · Bean
Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb.

How come? I thought intelfb used the bare hardware.

The video register in efi mode is not setup in the same way as bios. There are two sets of register. In EFI, set A is completely zero, while set B have non-zero value. But in bios mode, both set have non-zero value. I guess this is because bios have text and graphic mode, while efi only have graphic mode. (text mode in efi is emulated)

Quoted 6 lines
Quoted 3 lines

grub2 will detect these options and setup
frame buffer for you.

Can you be more specific? I thought grub was completely agnostic about Linux parameters.

In the parameter passed to linux kernel, there are fields for video adapter information, for example, frame buffer address, line length, etc. Normally, we don't have to worry about it, but in the case of efi, we must fill it in, as kernel can't detect the information properly.

Signature · 1 line
Bean
author
#23 lore raw
Quoted 8 lines · Bean
Quoted 2 lines

Can you be more specific? I thought grub was completely agnostic about Linux parameters.

In the parameter passed to linux kernel, there are fields for video adapter information, for example, frame buffer address, line length, etc. Normally, we don't have to worry about it, but in the case of efi, we must fill it in, as kernel can't detect the information properly.

Hi,

BTW, it's the real mode part of Linux kernel that takes care of such job. It gathers video information by querying vbe. But in efi, we skip the real mode part and jump to protected mode directly, so we must also provide kernel with similar information that would be setup by the real mode part.

Signature · 1 line
Bean
#24 lore raw
Quoted 10 lines · Bean
Quoted 8 lines · Bean
Quoted 2 lines

Can you be more specific? I thought grub was completely agnostic about Linux parameters.

In the parameter passed to linux kernel, there are fields for video adapter information, for example, frame buffer address, line length, etc. Normally, we don't have to worry about it, but in the case of efi, we must fill it in, as kernel can't detect the information properly.

Quoted 7 lines

Hi,

BTW, it's the real mode part of Linux kernel that takes care of such job. It gathers video information by querying vbe. But in efi, we skip the real mode part and jump to protected mode directly, so we must also provide kernel with similar information that would be setup by the real mode part.

Ah, I suppose this explains why Linux crashes when we try to load it via grub-linuxbios (I reused the i386-pc loader when doing the port, unaware that this would be an issue).

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 /.)
author
#25 lore raw
Quoted 19 lines · Robert Millan
Quoted 10 lines · Bean
Quoted 8 lines · Bean
Quoted 2 lines

Can you be more specific? I thought grub was completely agnostic about Linux parameters.

In the parameter passed to linux kernel, there are fields for video adapter information, for example, frame buffer address, line length, etc. Normally, we don't have to worry about it, but in the case of efi, we must fill it in, as kernel can't detect the information properly.

Quoted 7 lines

Hi,

BTW, it's the real mode part of Linux kernel that takes care of such job. It gathers video information by querying vbe. But in efi, we skip the real mode part and jump to protected mode directly, so we must also provide kernel with similar information that would be setup by the real mode part.

Quoted 3 lines

Ah, I suppose this explains why Linux crashes when we try to load it via grub-linuxbios (I reused the i386-pc loader when doing the port, unaware that this would be an issue).

Hi,

Here are the information gathered in real mode:

memory map information
video information
monitor information (edid)
hard disk information
perhaps more

The first two can be retrieved in grub, others are optional, kernel can normally get the value itself.

Perhaps we can write a generic protected mode linux loader for i386. Functions such as claiming memory, getting memory map and the like can be wrapped in platform dependent call arch_xxx.

Signature · 1 line
Bean
author
#26 lore raw

Committed.

Signature · 1 line
Bean
#27 lore raw
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1

The current system would build bootloader files as i386-pc (with the -m32 switch in gcc, which itself created the infamous "cannot find start or _start" problem when a multilib version of gcc was not installed) and helper files like grub-setup as amd64. This caused problems of its own, like grub-emu (built as amd64) being unable to load any grub modules (built as i386), but at least worked OOtB.

I was able to correctly recompile if I reconfigured GRUB with --target=i386-pc-linux-gnu (i386-pc alone was not recognized). Is this the current way to go? I feel it should not be so, because it multiboot2 comes out with amd64 support, there should be an x86_64-pc grub2.

author
#28 lore raw
Quoted 24 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1

The current system would build bootloader files as i386-pc (with the -m32 switch in gcc, which itself created the infamous "cannot find start or _start" problem when a multilib version of gcc was not installed) and helper files like grub-setup as amd64. This caused problems of its own, like grub-emu (built as amd64) being unable to load any grub modules (built as i386), but at least worked OOtB.

Quoted 4 lines

I was able to correctly recompile if I reconfigured GRUB with --target=i386-pc-linux-gnu (i386-pc alone was not recognized). Is this the current way to go? I feel it should not be so, because it multiboot2 comes out with amd64 support, there should be an x86_64-pc grub2.

Hi,

To compile 32-bit efi:

./configure --platform=efi --target=i386

To compile 64-bit efi:

./configure --platform=efi --target=x86_64

This works in i386 and x86_64 host. If you don't use --target, it will build native image.

Signature · 1 line
Bean
#29 lore raw
Quoted 4 lines · Bean

Hi,

To compile 32-bit efi:

Quoted 8 lines

./configure --platform=efi --target=i386

To compile 64-bit efi:

./configure --platform=efi --target=x86_64

This works in i386 and x86_64 host. If you don't use --target, it will build native image.

It won't. There is no default defined for x86_64. I'm fixing it now.

Signature · 2 lines
Regards,
Pavel Roskin
#30 lore raw
In reply to Javier Martín
Quoted 6 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

Quoted 10 lines
$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1

I've just noticed that. I think x86_64 should default to "i386-pc" platform. I'll have a look how to do it nicely.

Quoted 4 lines

The current system would build bootloader files as i386-pc (with the -m32 switch in gcc, which itself created the infamous "cannot find start or _start" problem when a multilib version of gcc was not installed) and helper files like grub-setup as amd64.

I was trying add an extra check there, but ran into more interesting stuff. Basically, the target checks should be better separated from the rest. I'll take another look.

Quoted 3 lines

This caused problems of its own,
like grub-emu (built as amd64) being unable to load any grub modules (built as i386), but at least worked OOtB.

I didn't know grub-emu could load modules! Live and learn :-)

Quoted 4 lines

I was able to correctly recompile if I reconfigured GRUB with --target=i386-pc-linux-gnu (i386-pc alone was not recognized). Is this the current way to go? I feel it should not be so, because it multiboot2 comes out with amd64 support, there should be an x86_64-pc grub2.

Perhaps we'll have it eventually. But I agree, the default should be restored for now.

Signature · 2 lines
Regards,
Pavel Roskin
author
#31 lore raw
Quoted 18 lines · Pavel Roskin
Quoted 6 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

Quoted 10 lines
$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1
Quoted 2 lines

I've just noticed that. I think x86_64 should default to "i386-pc" platform. I'll have a look how to do it nicely.

I have the following in configure.ac:

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

If platform is not efi, x86_64 will become i386, perhaps there is something I miss ?

Signature · 1 line
Bean
#32 lore raw
Quoted 38 lines · Bean
Quoted 18 lines · Pavel Roskin
Quoted 6 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

Quoted 10 lines
$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1
Quoted 2 lines

I've just noticed that. I think x86_64 should default to "i386-pc" platform. I'll have a look how to do it nicely.

I have the following in configure.ac:

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]) ;;
Quoted 6 lines

esac
fi

If platform is not efi, x86_64 will become i386, perhaps there is something I miss ?

It does not reach that point, the "unsupported machine type" message is thrown by this earlier check (line 59)

# Guess the platform if not specified.
if test "x$with_platform" = x; then
case "$target_cpu"-"$target_vendor" in

    i386-apple) platform=efi ;;
    i386-*) platform=pc ;;
    powerpc-*) platform=ieee1275 ;;
    sparc64-*) platform=ieee1275 ;;
    *) AC_MSG_ERROR([unsupported machine type]) ;;

esac
else
platform="$with_platform"
fi

author
#33 lore raw
Quoted 42 lines · Javier Martín
Quoted 41 lines · Bean
Quoted 18 lines · Pavel Roskin
Quoted 6 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

Quoted 10 lines
$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1
Quoted 2 lines

I've just noticed that. I think x86_64 should default to "i386-pc" platform. I'll have a look how to do it nicely.

I have the following in configure.ac:

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

Quoted 6 lines
Quoted 3 lines

If platform is not efi, x86_64 will become i386, perhaps there is something I miss ?

It does not reach that point, the "unsupported machine type" message is thrown by this earlier check (line 59)

Hi,

Oh, you're right, use this patch:

configure.ac +1 -0
index 943b9fe..45eb472 100644
@@ -61,6 +61,7 @@ if test "x$with_platform" = x; then
   case "$target_cpu"-"$target_vendor" in
     i386-apple) platform=efi ;;
     i386-*) platform=pc ;;
+    x86_64-*) platform=pc ;;
     powerpc-*) platform=ieee1275 ;;
     sparc64-*) platform=ieee1275 ;;
     *) AC_MSG_ERROR([unsupported machine type]) ;;
Signature · 1 line
Bean
#34 lore raw
Quoted 61 lines · Bean
Quoted 42 lines · Javier Martín
Quoted 41 lines · Bean
Quoted 18 lines · Pavel Roskin
Quoted 6 lines · Javier Martín
Quoted 2 lines · Bean

Committed.

Seemingly, the fact that there is now separate recognition for "x86_64" machine types has borked the current build system in amd64 PCs:

Quoted 10 lines
$ make
./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../src/configure
--prefix=/home/javier/Proyectos/grub/build/out/  --no-create
--no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: unsupported machine type
make: *** [config.status] Error 1
Quoted 2 lines

I've just noticed that. I think x86_64 should default to "i386-pc" platform. I'll have a look how to do it nicely.

I have the following in configure.ac:

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

Quoted 6 lines
Quoted 3 lines

If platform is not efi, x86_64 will become i386, perhaps there is something I miss ?

It does not reach that point, the "unsupported machine type" message is thrown by this earlier check (line 59)

Hi,

Oh, you're right, use this patch:

configure.ac +0 -0
index 943b9fe..45eb472 100644

configure.ac if test "x$with_platform" = x; then · line 67

Quoted 7 lines
configure.ac +1 -0
@@ -61,6 +61,7 @@ if test "x$with_platform" = x; then
   case "$target_cpu"-"$target_vendor" in
     i386-apple) platform=efi ;;
     i386-*) platform=pc ;;
+    x86_64-*) platform=pc ;;
     powerpc-*) platform=ieee1275 ;;
     sparc64-*) platform=ieee1275 ;;
     *) AC_MSG_ERROR([unsupported machine type]) ;;

I think this one would be better, as it follows the structure what's done with i386: vendor=apple -> efi; anything_else -> pc. Also, this one errors out with a more understandable message that does not conflict with another check some lines down.

configure.ac (copia de trabajo) renamed from configure.ac (revisión: 1714) +3 -3
Index: configure.ac
===================================================================
@@ -59,11 +59,11 @@
 # Guess the platform if not specified.
 if test "x$with_platform" = x; then
   case "$target_cpu"-"$target_vendor" in
-    i386-apple) platform=efi ;;
-    i386-*) platform=pc ;;
+    i386-apple|x86_64-apple) platform=efi ;;
+    i386-*|x86_64-*) platform=pc ;;
     powerpc-*) platform=ieee1275 ;;
     sparc64-*) platform=ieee1275 ;;
-    *) AC_MSG_ERROR([unsupported machine type]) ;;
+    *) AC_MSG_ERROR([unable to guess platform. Use --with-platform]) ;;
   esac
 else
   platform="$with_platform"
#35 lore raw
Quoted 2 lines · Javier Martín

I think this one would be better, as it follows the structure what's done with i386: vendor=apple -> efi; anything_else -> pc.

That's a good call. I'm working on a more radical patch now. I'll post it for review.

Quoted 3 lines

Also, this one
errors out with a more understandable message that does not conflict with another check some lines down.

I agree that the messages should be improved.

Quoted 6 lines

Index: configure.ac
===================================================================

configure.ac (copia de trabajo) renamed from configure.ac (revisión: 1714) +0 -0
@@ -59,11 +59,11 @@
 # Guess the platform if not specified.

configure.ac (copia de trabajo) line 66

Quoted 10 lines
configure.ac (copia de trabajo) renamed from configure.ac (revisión: 1714) +3 -3
 if test "x$with_platform" = x; then
   case "$target_cpu"-"$target_vendor" in
-    i386-apple) platform=efi ;;
-    i386-*) platform=pc ;;
+    i386-apple|x86_64-apple) platform=efi ;;
+    i386-*|x86_64-*) platform=pc ;;
     powerpc-*) platform=ieee1275 ;;
     sparc64-*) platform=ieee1275 ;;
-    *) AC_MSG_ERROR([unsupported machine type]) ;;
+    *) AC_MSG_ERROR([unable to guess platform. Use --with-platform]) ;;

That's misleading. We can guess platform for any supported CPU (well, we try out best). The real problem is that the CPU is not supported, and that's what the message should say.

Signature · 2 lines
Regards,
Pavel Roskin
#36 lore raw
In reply to Bean
Quoted 6 lines · Bean
Quoted 2 lines

It does not reach that point, the "unsupported machine type" message is thrown by this earlier check (line 59)

Hi,

Oh, you're right, use this patch:

It's there already. Now I'm trying to simplify checks and make output more comprehensible.

Signature · 2 lines
Regards,
Pavel Roskin
#37 lore raw
Quoted 11 lines · Pavel Roskin
Quoted 6 lines · Bean
Quoted 2 lines

It does not reach that point, the "unsupported machine type" message is thrown by this earlier check (line 59)

Hi,

Oh, you're right, use this patch:

It's there already. Now I'm trying to simplify checks and make output more comprehensible.

Dunno if you read the latter patch, but nevertheless those three checks have some nasty circular dependencies. Besides, now that we're talking about the build system, the Makefile.in file refers to the inexistent conf/i386-coreboot.rmk file, and that's affecting every other system because make "can't find a rule to make conf/i386-coreboot.rmk, required for conf/i386.coreboot.mk. Halt" - I suspect a rename to/from conf/i386-linuxbios.rmk file was left incomplete or is still uncommitted to SVN.

#38 lore raw

generic BIOS-less boot (Re: [PATCH] New x86_64 EFI patch)

In reply to Bean
Quoted 11 lines · Bean

Hi,

Here are the information gathered in real mode:

memory map information
video information
monitor information (edid)
hard disk information
perhaps more

Quoted 6 lines

The first two can be retrieved in grub, others are optional, kernel can normally get the value itself.

Perhaps we can write a generic protected mode linux loader for i386. Functions such as claiming memory, getting memory map and the like can be wrapped in platform dependent call arch_xxx.

I was wondering if maybe it would be simpler to emulate the BIOS (and use stubs where suitable). Memory map would be simple to produce since we already have this information which we used to initialize our heap. As for video information, do you have more details (or know a document that explains what's probed for)? If it's only for vesa modes maybe we could just stub it.

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 /.)
#39 lore raw
In reply to Bean
Quoted 8 lines · Bean
Quoted 7 lines · Robert Millan
Quoted 5 lines · Bean
Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb.

Quoted 7 lines
Quoted 1 line

How come? I thought intelfb used the bare hardware.

The video register in efi mode is not setup in the same way as bios. There are two sets of register. In EFI, set A is completely zero, while set B have non-zero value. But in bios mode, both set have non-zero value. I guess this is because bios have text and graphic mode, while efi only have graphic mode. (text mode in efi is emulated)

But isn't intelfb supposed to access the hardware without any support from bios/vesa or efi?

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 /.)
author
#40 lore raw
Quoted 11 lines · Robert Millan
Quoted 10 lines · Bean
Quoted 8 lines · Robert Millan
Quoted 5 lines · Bean
Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb.

How come? I thought intelfb used the bare hardware.

Quoted 8 lines
Quoted 5 lines

The video register in efi mode is not setup in the same way as bios. There are two sets of register. In EFI, set A is completely zero, while set B have non-zero value. But in bios mode, both set have non-zero value. I guess this is because bios have text and graphic mode, while efi only have graphic mode. (text mode in efi is emulated)

But isn't intelfb supposed to access the hardware without any support from bios/vesa or efi?

Intelfb uses the environment setup before, it doesn't try to reinitialize video registers.

Signature · 1 line
Bean
author
#41 lore raw
Quoted 18 lines · Bean
Quoted 17 lines · Robert Millan
Quoted 15 lines · Bean
Quoted 8 lines · Robert Millan
Quoted 5 lines · Bean
Quoted 2 lines

-- I tried passing video=intelfb to linux; it worked under grub2-pc but didn't improve anything under efi.

intelfb doesn't work. The only way to see console in efi is to use video=vesafb or video=efifb.

How come? I thought intelfb used the bare hardware.

The video register in efi mode is not setup in the same way as bios. There are two sets of register. In EFI, set A is completely zero, while set B have non-zero value. But in bios mode, both set have non-zero value. I guess this is because bios have text and graphic mode, while efi only have graphic mode. (text mode in efi is emulated)

Quoted 5 lines
Quoted 2 lines

But isn't intelfb supposed to access the hardware without any support from bios/vesa or efi?

Intelfb uses the environment setup before, it doesn't try to reinitialize video registers.

Hi,

I think the real problem of intelfb is that it uses agp, which requires video hardware to be configure properly. But if we use vesafb or efifb, it uses the frame buffer, so as long as we setup video information properly in grub2, we can see console output.

Signature · 1 line
Bean
#42 lore raw
In reply to Bean
Quoted 8 lines · Bean

I'm using the 2.6.25 kernel from debian sid, it works fine. I think ubuntu can use debian packages as well. To solve the screen problem, you need the following command line:

video=efifb agp=off

If you're interested, you can also try amd64 kernel. You can use it on 686 linux directly, no need to install a full amd64 system.

every time I've tried Ubuntu with a different kernel... it has problems.
Ubuntu has a fancy initrd, modules, lots of patches, Upstart as init,
and who knows what assumptions about the boot process... but maybe. I could use the kernel from the Ubuntu development branch, if I had any idea how to use APT to upgrade just a few specific things from an unstable package-source and not my whole system (the kernel binary obviously doesn't depend on system libraries, so it should be uniquely easy to do this...). Do you know about debians -- if that's possible?

-Isaac

#43 lore raw
In reply to Bean

Hi,

Quoted 5 lines · Bean

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

Doesn't it break other systems?

Quoted 4 lines

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

I am not sure if appleloader is a good word. Can you explain how it works and what it actually does? Perhaps something like "legacy" would be a better word, especially since it is not apple specific.

btw, you forgot the changelog entry.

--
Marco

author
#44 lore raw
Quoted 11 lines · Marco Gerards

Hi,

Quoted 5 lines · Bean

This new patch add the following function to the original x86_64 EFI patch:

1, Fix menu drawing problem
It maps the unicode char to EFI char so that the rectangle box is showed properly

Doesn't it break other systems?

It only changes term/efi/console.c, which is efi specific.

Quoted 9 lines
Quoted 5 lines

2, Handle command line option for chainloader command

3, Add new command appleloader
The command is used to enable bios boot in apple's bootcamp, for example

I am not sure if appleloader is a good word. Can you explain how it works and what it actually does? Perhaps something like "legacy" would be a better word, especially since it is not apple specific.

The code is apple specific. They use special pathname for the bios switcher, we just chainloading it. The pathname is not even the same among different models, we need to go through an array to find a possible match.

Quoted 3 lines

btw, you forgot the changelog entry.

Here it is:

2008-07-04 Bean <[email protected]>

* conf/i386/efi.rmk (pkglib_MODULES): add pci.mod and lspci.mod. (appleldr_mod_SOURCE): New variavle. (appleldr_mod_CFLAGS): Likewise. (appleldr_mod_LDFLAGS): Likewise.
(pci_mod_SOURCES): Likewise.
(pci_mod_CFLAGS): Likewise.
(pci_mod_LDFLAGS): Likewise.
(lspci_mod_SOURCES): Likewise.
(lspci_mod_CFLAGS): Likewise.
(lspci_mod_LDFLAGS): Likewise.

* conf/x86_64-efi.rmk: New file.

* disk/efi/efidisk.c (grub_efidisk_read): Wrap efi calls with efi_call_N macro.
(grub_efidisk_write): Likewise.

* include/efi/api.h (efi_call_0): New macro. (efi_call_1): Likewise. (efi_call_2): Likewise. (efi_call_3): Likewise. (efi_call_4): Likewise. (efi_call_5): Likewise. (efi_call_6): Likewise.

* include/grub/efi/chainloader.h (grub_chainloader_cmd): Rename to grub_rescue_cmd_chainloader.

* include/grub/efi/pe32.h (GRUB_PE32_MACHINE_X86_64): New macro. (grub_pe32_optional_header): Change some fields based on i386 or x86_64 platform.
(GRUB_PE32_PE32_MAGIC): Likewise.

* include/grub/efi/uga_draw.h: New file.

* include/grub/elf.h (STN_ABS): New constant. (R_X86_64_NONE): Relocation constant for x86_64. (R_X86_64_64): Likewise. (R_X86_64_PC32): Likewise. (R_X86_64_GOT32): Likewise. (R_X86_64_PLT32): Likewise. (R_X86_64_COPY): Likewise. (R_X86_64_GLOB_DAT): Likewise. (R_X86_64_JUMP_SLOT): Likewise. (R_X86_64_RELATIVE): Likewise. (R_X86_64_GOTPCREL): Likewise. (R_X86_64_32): Likewise. (R_X86_64_32S): Likewise. (R_X86_64_16): Likewise. (R_X86_64_PC16): Likewise. (R_X86_64_8): Likewise.
(R_X86_64_PC8): Likewise.

* include/grub/i386/efi/pci.h: New file.

* include/grub/i386/linux.h (GRUB_LINUX_EFI_SIGNATURE):
Change it value based on platform. (GRUB_LINUX_EFI_SIGNATURE_0204): New constant. (GRUB_E820_RAM): Likewise.
(GRUB_E820_RESERVED): Likewise.
(GRUB_E820_ACPI): Likewise.
(GRUB_E820_NVS): Likewise.
(GRUB_E820_EXEC_CODE): Likewise. (GRUB_E820_MAX_ENTRY): Likewise.
(grub_e820_mmap): New structure. (linux_kernel_header): Change the efi field according to different kernel version, also field from linux_kernel_header.

* include/grub/kernel.h (grub_module_info): Add padding for x86_64.

* include/grub/pci.h (GRUB_PCI_ADDR_SPACE_MASK): New constant. (GRUB_PCI_ADDR_SPACE_MEMORY): Likewise. (GRUB_PCI_ADDR_SPACE_IO): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_MASK): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_32): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_1M): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_64): Likewise. (GRUB_PCI_ADDR_MEM_PREFETCH): Likewise. (GRUB_PCI_ADDR_MEM_MASK): Likewise. (GRUB_PCI_ADDR_IO_MASK): Likewise.

* include/grub/x86_64/efi/kernel.h: New file.

* include/grub/x86_64/efi/loader.h: Likewise.

* include/grub/x86_64/efi/machine.h: Likewise.

* include/grub/x86_64/efi/pci.h: Likewise.

* include/grub/x86_64/efi/time.h: Likewise.

* include/grub/x86_64/linux.h: Likewise.

* include/grub/x86_64/setjmp.h: Likewise.

* include/grub/x86_64/time.h: Likewise.

* include/grub/x86_64/types.h: Likewise.

* kern/dl.c (GRUB_CPU_SIZEOF_VOID_P): Changed to GRUB_TARGET_SIZEOF_VOID_P.

* kern/efi/efi.c (grub_efi_locate_protocol): Wrap efi calls. (grub_efi_locate_handle): Likewise. (grub_efi_open_protocol): Likewise. (grub_efi_set_text_mode): Likewise. (grub_efi_stall): Likewise.
(grub_exit): Likewise.
(grub_reboot): Likewise.
(grub_halt): Likewise. (grub_efi_exit_boot_services): Likewise. (grub_get_rtc): Likewise.

* kern/efi/mm.c (MEMORY_MAP_SIZE): Change to 0x3000 for new models. (GRUB_CPU_SIZEOF_VOID_P): Changed to GRUB_TARGET_SIZEOF_VOID_P. (grub_efi_allocate_pages): Wrap efi calls. (grub_efi_free_pages): Wrap efi calls. (grub_efi_get_memory_map): Wrap efi calls.

* kern/x86_64/dl.c: New file.

* kern/x86_64/efi/callwrap.S: Likewise.

* kern/x86_64/efi/startup.S: Likewise.

* loader/efi/appleloader.c: Likewise.

* loader/efi/chainloader.c (cmdline): New variable. (grub_chainloader_unload): Wrap efi calls. (grub_chainloader_boot): Likewise. (grub_rescue_cmd_chainloader): Wrap efi calls, handle command line.

* loader/efi/chainloader_normal.c (chainloader_command):
Change grub_chainloader_cmd to grub_rescue_cmd_chainloader, pass command line.

* loader/i386/efi/linux.c (allocate_pages): Change allocation method.
(grub_e820_add_region): New function. (grub_linux_boot): Construct e820 map from efi map, handle x86_64 booting.
(grub_find_video_card): New function. (grub_linux_setup_video): New function. (grub_rescue_cmd_linux): Probe for video information.

* normal/x86_64/setjmp.S: New file.

* term/efi/console.c (map_char): New function. (grub_console_putchar): Map unicode char. (grub_console_checkkey): Wrap efi calls. (grub_console_getkey): Likewise. (grub_console_getwh): Likewise. (grub_console_gotoxy): Likewise. (grub_console_cls): Likewise. (grub_console_setcolorstate): Likewise. (grub_console_setcursor): Likewise.

* util/i386/efi/grub-mkimage.c: Add support for x86_64.

Signature · 1 line
Bean