Fix various issues created by previous commits
This commit is contained in:
parent
614be3f119
commit
94ac790645
13 changed files with 285 additions and 88 deletions
|
@ -90,7 +90,7 @@ GNULIB_CFLAGS = $(GNULIB_UTIL_CFLAGS) $(POSIX_CFLAGS)
|
||||||
ASFLAGS = @ASFLAGS@
|
ASFLAGS = @ASFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@ $(LIBS)
|
LDFLAGS = @LDFLAGS@ $(LIBS)
|
||||||
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
||||||
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
|
-DGRUB_LIBDIR=\"$(libdir)\" -DLOCALEDIR=\"$(localedir)\"
|
||||||
TARGET_CC = @TARGET_CC@
|
TARGET_CC = @TARGET_CC@
|
||||||
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
|
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
|
||||||
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
|
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
|
||||||
|
@ -287,7 +287,7 @@ build_env.mk: Makefile
|
||||||
echo "TARGET_CC=$(TARGET_CC)" ; \
|
echo "TARGET_CC=$(TARGET_CC)" ; \
|
||||||
echo "TARGET_CFLAGS=$(TARGET_CFLAGS)" ; \
|
echo "TARGET_CFLAGS=$(TARGET_CFLAGS)" ; \
|
||||||
echo "TARGET_ASFLAGS=$(TARGET_ASFLAGS)" ; \
|
echo "TARGET_ASFLAGS=$(TARGET_ASFLAGS)" ; \
|
||||||
echo "TARGET_CPPFLAGS=$(TARGET_CPPFLAGS) -I$(pkglibdir) -I$(includedir)" ; \
|
echo "TARGET_CPPFLAGS=$(TARGET_CPPFLAGS) -I$(libdir) -I$(includedir)" ; \
|
||||||
echo "STRIP=$(STRIP)" ; \
|
echo "STRIP=$(STRIP)" ; \
|
||||||
echo "OBJCONV=$(OBJCONV)" ; \
|
echo "OBJCONV=$(OBJCONV)" ; \
|
||||||
echo "TARGET_MODULE_FORMAT=$(TARGET_MODULE_FORMAT)" ; \
|
echo "TARGET_MODULE_FORMAT=$(TARGET_MODULE_FORMAT)" ; \
|
||||||
|
|
|
@ -31,7 +31,7 @@ _start:
|
||||||
|
|
||||||
jmp 1f
|
jmp 1f
|
||||||
|
|
||||||
. = _start + GRUB_BOOT_MACHINE_CORE_ENTRY_ADDR
|
. = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
|
||||||
VARIABLE(grub_core_entry_addr)
|
VARIABLE(grub_core_entry_addr)
|
||||||
.long 0
|
.long 0
|
||||||
1:
|
1:
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <grub/boot.h>
|
#include <grub/boot.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.align 4
|
.align 4
|
||||||
|
@ -87,8 +88,8 @@ after_info_block:
|
||||||
call console_write
|
call console_write
|
||||||
mov NOTIFICATION_STRING_LEN, %o3
|
mov NOTIFICATION_STRING_LEN, %o3
|
||||||
|
|
||||||
GET_ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE, %l2)
|
GET_ABS(firstlist - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
|
||||||
set GRUB_BOOT_MACHINE_IMAGE_ADDRESS, %l3
|
set GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
|
||||||
bootloop:
|
bootloop:
|
||||||
lduw [%l2 + 0x08], %o0
|
lduw [%l2 + 0x08], %o0
|
||||||
brz %o0, bootit
|
brz %o0, bootit
|
||||||
|
@ -115,7 +116,7 @@ bootloop:
|
||||||
mov NOTIFICATION_STEP_LEN, %o3
|
mov NOTIFICATION_STEP_LEN, %o3
|
||||||
|
|
||||||
ba bootloop
|
ba bootloop
|
||||||
sub %l2, GRUB_BOOT_MACHINE_LIST_SIZE, %l2
|
sub %l2, GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
|
||||||
|
|
||||||
bootit:
|
bootit:
|
||||||
GET_ABS(prom_close_name, %o0)
|
GET_ABS(prom_close_name, %o0)
|
||||||
|
@ -127,8 +128,8 @@ bootit:
|
||||||
GET_ABS(notification_done, %o2)
|
GET_ABS(notification_done, %o2)
|
||||||
call console_write
|
call console_write
|
||||||
mov NOTIFICATION_DONE_LEN, %o3
|
mov NOTIFICATION_DONE_LEN, %o3
|
||||||
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
sethi %hi(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
|
||||||
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
jmpl %o2 + %lo(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
|
||||||
mov CIF_REG, %o4
|
mov CIF_REG, %o4
|
||||||
1: ba,a 1b
|
1: ba,a 1b
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ case "$target_cpu" in
|
||||||
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||||
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||||
esac
|
esac
|
||||||
|
machine_CFLAGS="$machine_CFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
|
||||||
|
|
||||||
CFLAGS="$CFLAGS $machine_CFLAGS"
|
CFLAGS="$CFLAGS $machine_CFLAGS"
|
||||||
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
||||||
|
|
|
@ -99,12 +99,8 @@ struct grub_pe32_optional_header
|
||||||
grub_uint32_t entry_addr;
|
grub_uint32_t entry_addr;
|
||||||
grub_uint32_t code_base;
|
grub_uint32_t code_base;
|
||||||
|
|
||||||
#if GRUB_TARGET_SIZEOF_VOID_P == 4
|
|
||||||
grub_uint32_t data_base;
|
grub_uint32_t data_base;
|
||||||
grub_uint32_t image_base;
|
grub_uint32_t image_base;
|
||||||
#else
|
|
||||||
grub_uint64_t image_base;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
grub_uint32_t section_alignment;
|
grub_uint32_t section_alignment;
|
||||||
grub_uint32_t file_alignment;
|
grub_uint32_t file_alignment;
|
||||||
|
@ -121,22 +117,66 @@ struct grub_pe32_optional_header
|
||||||
grub_uint16_t subsystem;
|
grub_uint16_t subsystem;
|
||||||
grub_uint16_t dll_characteristics;
|
grub_uint16_t dll_characteristics;
|
||||||
|
|
||||||
#if GRUB_TARGET_SIZEOF_VOID_P == 4
|
|
||||||
|
|
||||||
grub_uint32_t stack_reserve_size;
|
grub_uint32_t stack_reserve_size;
|
||||||
grub_uint32_t stack_commit_size;
|
grub_uint32_t stack_commit_size;
|
||||||
grub_uint32_t heap_reserve_size;
|
grub_uint32_t heap_reserve_size;
|
||||||
grub_uint32_t heap_commit_size;
|
grub_uint32_t heap_commit_size;
|
||||||
|
|
||||||
#else
|
grub_uint32_t loader_flags;
|
||||||
|
grub_uint32_t num_data_directories;
|
||||||
|
|
||||||
|
/* Data directories. */
|
||||||
|
struct grub_pe32_data_directory export_table;
|
||||||
|
struct grub_pe32_data_directory import_table;
|
||||||
|
struct grub_pe32_data_directory resource_table;
|
||||||
|
struct grub_pe32_data_directory exception_table;
|
||||||
|
struct grub_pe32_data_directory certificate_table;
|
||||||
|
struct grub_pe32_data_directory base_relocation_table;
|
||||||
|
struct grub_pe32_data_directory debug;
|
||||||
|
struct grub_pe32_data_directory architecture;
|
||||||
|
struct grub_pe32_data_directory global_ptr;
|
||||||
|
struct grub_pe32_data_directory tls_table;
|
||||||
|
struct grub_pe32_data_directory load_config_table;
|
||||||
|
struct grub_pe32_data_directory bound_import;
|
||||||
|
struct grub_pe32_data_directory iat;
|
||||||
|
struct grub_pe32_data_directory delay_import_descriptor;
|
||||||
|
struct grub_pe32_data_directory com_runtime_header;
|
||||||
|
struct grub_pe32_data_directory reserved_entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grub_pe64_optional_header
|
||||||
|
{
|
||||||
|
grub_uint16_t magic;
|
||||||
|
grub_uint8_t major_linker_version;
|
||||||
|
grub_uint8_t minor_linker_version;
|
||||||
|
grub_uint32_t code_size;
|
||||||
|
grub_uint32_t data_size;
|
||||||
|
grub_uint32_t bss_size;
|
||||||
|
grub_uint32_t entry_addr;
|
||||||
|
grub_uint32_t code_base;
|
||||||
|
|
||||||
|
grub_uint64_t image_base;
|
||||||
|
|
||||||
|
grub_uint32_t section_alignment;
|
||||||
|
grub_uint32_t file_alignment;
|
||||||
|
grub_uint16_t major_os_version;
|
||||||
|
grub_uint16_t minor_os_version;
|
||||||
|
grub_uint16_t major_image_version;
|
||||||
|
grub_uint16_t minor_image_version;
|
||||||
|
grub_uint16_t major_subsystem_version;
|
||||||
|
grub_uint16_t minor_subsystem_version;
|
||||||
|
grub_uint32_t reserved;
|
||||||
|
grub_uint32_t image_size;
|
||||||
|
grub_uint32_t header_size;
|
||||||
|
grub_uint32_t checksum;
|
||||||
|
grub_uint16_t subsystem;
|
||||||
|
grub_uint16_t dll_characteristics;
|
||||||
|
|
||||||
grub_uint64_t stack_reserve_size;
|
grub_uint64_t stack_reserve_size;
|
||||||
grub_uint64_t stack_commit_size;
|
grub_uint64_t stack_commit_size;
|
||||||
grub_uint64_t heap_reserve_size;
|
grub_uint64_t heap_reserve_size;
|
||||||
grub_uint64_t heap_commit_size;
|
grub_uint64_t heap_commit_size;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
grub_uint32_t loader_flags;
|
grub_uint32_t loader_flags;
|
||||||
grub_uint32_t num_data_directories;
|
grub_uint32_t num_data_directories;
|
||||||
|
|
||||||
|
@ -221,6 +261,8 @@ struct grub_pe32_header
|
||||||
struct grub_pe32_optional_header optional_header;
|
struct grub_pe32_optional_header optional_header;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GRUB_PE32_SIGNATURE_SIZE 4
|
||||||
|
|
||||||
struct grub_pe32_fixup_block
|
struct grub_pe32_fixup_block
|
||||||
{
|
{
|
||||||
grub_uint32_t page_rva;
|
grub_uint32_t page_rva;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#ifndef GRUB_BOOT_MACHINE_HEADER
|
#ifndef GRUB_BOOT_MACHINE_HEADER
|
||||||
#define GRUB_BOOT_MACHINE_HEADER 1
|
#define GRUB_BOOT_MACHINE_HEADER 1
|
||||||
|
|
||||||
#define MACHINE I386_PC
|
|
||||||
#include <grub/offsets.h>
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
/* The signature for bootloader. */
|
/* The signature for bootloader. */
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
#ifndef KERNEL_MACHINE_HEADER
|
#ifndef KERNEL_MACHINE_HEADER
|
||||||
#define KERNEL_MACHINE_HEADER 1
|
#define KERNEL_MACHINE_HEADER 1
|
||||||
|
|
||||||
#define MACHINE I386_PC
|
|
||||||
|
|
||||||
#include <grub/offsets.h>
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
/* Enable LZMA compression */
|
/* Enable LZMA compression */
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include <grub/i386/memory.h>
|
#include <grub/i386/memory.h>
|
||||||
|
|
||||||
#define MACHINE I386_PC
|
|
||||||
#include <grub/offsets.h>
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
/* The scratch buffer used in real mode code. */
|
/* The scratch buffer used in real mode code. */
|
||||||
|
|
|
@ -19,14 +19,7 @@
|
||||||
#ifndef GRUB_KERNEL_MACHINE_HEADER
|
#ifndef GRUB_KERNEL_MACHINE_HEADER
|
||||||
#define GRUB_KERNEL_MACHINE_HEADER 1
|
#define GRUB_KERNEL_MACHINE_HEADER 1
|
||||||
|
|
||||||
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
|
#include <grub/offsets.h>
|
||||||
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc
|
|
||||||
|
|
||||||
/* The offset of GRUB_PREFIX. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX 0x10
|
|
||||||
|
|
||||||
/* End of the data section. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x50
|
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
|
101
include/grub/offsets.h
Normal file
101
include/grub/offsets.h
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2002,2003,2007,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 OFFSETS_HEADER
|
||||||
|
#define OFFSETS_HEADER 1
|
||||||
|
|
||||||
|
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE 0x8
|
||||||
|
|
||||||
|
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE 0xc
|
||||||
|
|
||||||
|
/* The offset of GRUB_COMPRESSED_SIZE. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_COMPRESSED_SIZE 0x10
|
||||||
|
|
||||||
|
/* The offset of GRUB_INSTALL_DOS_PART. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_INSTALL_DOS_PART 0x14
|
||||||
|
|
||||||
|
/* The offset of GRUB_INSTALL_BSD_PART. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x18
|
||||||
|
|
||||||
|
/* The offset of GRUB_PREFIX. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_PREFIX 0x1c
|
||||||
|
|
||||||
|
/* End of the data section. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_DATA_END 0x5c
|
||||||
|
|
||||||
|
/* The size of the first region which won't be compressed. */
|
||||||
|
#define GRUB_KERNEL_I386_PC_RAW_SIZE (GRUB_KERNEL_I386_PC_DATA_END + 0x5F0)
|
||||||
|
|
||||||
|
/* The segment where the kernel is loaded. */
|
||||||
|
#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800
|
||||||
|
|
||||||
|
/* The upper memory area (starting at 640 kiB). */
|
||||||
|
#define GRUB_MEMORY_I386_PC_UPPER 0xa0000
|
||||||
|
#define GRUB_MEMORY_I386_QEMU_UPPER GRUB_MEMORY_I386_PC_UPPER
|
||||||
|
|
||||||
|
/* The offset of GRUB_CORE_ENTRY_ADDR. */
|
||||||
|
#define GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR 0x4
|
||||||
|
|
||||||
|
/* The offset of GRUB_CORE_ENTRY_ADDR. */
|
||||||
|
#define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8
|
||||||
|
|
||||||
|
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
|
||||||
|
#define GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE 0xc
|
||||||
|
|
||||||
|
/* The offset of GRUB_PREFIX. */
|
||||||
|
#define GRUB_KERNEL_I386_QEMU_PREFIX 0x10
|
||||||
|
|
||||||
|
/* End of the data section. */
|
||||||
|
#define GRUB_KERNEL_I386_QEMU_DATA_END 0x50
|
||||||
|
|
||||||
|
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
|
||||||
|
|
||||||
|
#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
|
||||||
|
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
|
||||||
|
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
||||||
|
|
||||||
|
#ifdef MACHINE
|
||||||
|
#define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
|
||||||
|
#define GRUB_OFFSETS_CONCAT(a,b,c) GRUB_OFFSETS_CONCAT_(a,b,c)
|
||||||
|
#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _TOTAL_MODULE_SIZE)
|
||||||
|
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _KERNEL_IMAGE_SIZE)
|
||||||
|
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _COMPRESSED_SIZE)
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _PREFIX)
|
||||||
|
#define GRUB_KERNEL_MACHINE_DATA_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _DATA_END)
|
||||||
|
#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, MACHINE, _KERNEL_SEG)
|
||||||
|
#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, MACHINE, _UPPER)
|
||||||
|
#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _RAW_SIZE)
|
||||||
|
#define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _INSTALL_BSD_PART)
|
||||||
|
#define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _INSTALL_DOS_PART)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ASM_FILE
|
||||||
|
struct grub_pc_bios_boot_blocklist
|
||||||
|
{
|
||||||
|
grub_uint64_t start;
|
||||||
|
grub_uint16_t len;
|
||||||
|
grub_uint16_t segment;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -20,28 +20,12 @@
|
||||||
#define GRUB_KERNEL_MACHINE_HEADER 1
|
#define GRUB_KERNEL_MACHINE_HEADER 1
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
#define GRUB_PLATFORM_IMAGE_FORMATS "raw, elf"
|
|
||||||
#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
|
|
||||||
|
|
||||||
#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX 0x4
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x44
|
|
||||||
#define GRUB_KERNEL_MACHINE_LINK_ALIGN 4
|
|
||||||
|
|
||||||
#define EM_TARGET EM_PPC
|
|
||||||
#define GRUB_KERNEL_MACHINE_LINK_ADDR 0x200000
|
#define GRUB_KERNEL_MACHINE_LINK_ADDR 0x200000
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GRUB_PLATFORM_IMAGE_RAW,
|
|
||||||
GRUB_PLATFORM_IMAGE_ELF
|
|
||||||
}
|
|
||||||
grub_platform_image_format_t;
|
|
||||||
#define GRUB_PLATFORM_IMAGE_RAW GRUB_PLATFORM_IMAGE_RAW
|
|
||||||
#define GRUB_PLATFORM_IMAGE_ELF GRUB_PLATFORM_IMAGE_ELF
|
|
||||||
|
|
||||||
/* The prefix which points to the directory where GRUB modules and its
|
/* The prefix which points to the directory where GRUB modules and its
|
||||||
configuration file are located. */
|
configuration file are located. */
|
||||||
extern char grub_prefix[];
|
extern char grub_prefix[];
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
_start:
|
_start:
|
||||||
jmp codestart
|
jmp codestart
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_MACHINE_CORE_ENTRY_ADDR
|
. = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
|
||||||
VARIABLE(grub_core_entry_addr)
|
VARIABLE(grub_core_entry_addr)
|
||||||
.long 0
|
.long 0
|
||||||
VARIABLE(grub_kernel_image_size)
|
VARIABLE(grub_kernel_image_size)
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct image_target_desc
|
||||||
unsigned section_align;
|
unsigned section_align;
|
||||||
signed vaddr_offset;
|
signed vaddr_offset;
|
||||||
unsigned install_dos_part, install_bsd_part;
|
unsigned install_dos_part, install_bsd_part;
|
||||||
|
grub_uint64_t link_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct image_target_desc image_targets[] =
|
struct image_target_desc image_targets[] =
|
||||||
|
@ -90,8 +91,11 @@ struct image_target_desc image_targets[] =
|
||||||
},
|
},
|
||||||
{"i386-efi", 4, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
{"i386-efi", 4, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
.vaddr_offset = ALIGN_UP (sizeof (struct grub_pe32_header)
|
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
+ 5 * sizeof (struct grub_pe32_section_table),
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
|
+ sizeof (struct grub_pe32_optional_header)
|
||||||
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
GRUB_PE32_SECTION_ALIGNMENT)
|
||||||
},
|
},
|
||||||
{"i386-ieee1275", 4, 0, IMAGE_I386_IEEE1275, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
{"i386-ieee1275", 4, 0, IMAGE_I386_IEEE1275, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
||||||
|
@ -102,8 +106,11 @@ struct image_target_desc image_targets[] =
|
||||||
.vaddr_offset = 0},
|
.vaddr_offset = 0},
|
||||||
{"x86_64-efi", 8, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
{"x86_64-efi", 8, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
.vaddr_offset = ALIGN_UP (sizeof (struct grub_pe32_header)
|
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
+ 5 * sizeof (struct grub_pe32_section_table),
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
|
+ sizeof (struct grub_pe64_optional_header)
|
||||||
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
GRUB_PE32_SECTION_ALIGNMENT)
|
||||||
},
|
},
|
||||||
{"mipsel-yeeloong-elf", 4, 0, IMAGE_YEELOONG_ELF, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
{"mipsel-yeeloong-elf", 4, 0, IMAGE_YEELOONG_ELF, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
||||||
|
@ -1150,19 +1157,35 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
case IMAGE_EFI:
|
case IMAGE_EFI:
|
||||||
{
|
{
|
||||||
void *pe_img;
|
void *pe_img;
|
||||||
|
grub_uint8_t *header;
|
||||||
size_t pe_size;
|
size_t pe_size;
|
||||||
struct grub_pe32_header *header;
|
|
||||||
struct grub_pe32_coff_header *c;
|
struct grub_pe32_coff_header *c;
|
||||||
struct grub_pe32_optional_header *o;
|
|
||||||
struct grub_pe32_section_table *text_section, *data_section;
|
struct grub_pe32_section_table *text_section, *data_section;
|
||||||
struct grub_pe32_section_table *mods_section, *reloc_section;
|
struct grub_pe32_section_table *mods_section, *reloc_section;
|
||||||
static const grub_uint8_t stub[] = GRUB_PE32_MSDOS_STUB;
|
static const grub_uint8_t stub[] = GRUB_PE32_MSDOS_STUB;
|
||||||
int header_size = ALIGN_UP (sizeof (struct grub_pe32_header)
|
int header_size;
|
||||||
+ 5 * sizeof (struct grub_pe32_section_table),
|
int reloc_addr;
|
||||||
image_target->section_align);
|
|
||||||
int reloc_addr = ALIGN_UP (header_size + core_size, image_target->section_align);
|
|
||||||
|
|
||||||
pe_size = ALIGN_UP (reloc_addr + reloc_size, image_target->section_align);
|
if (image_target->voidp_sizeof == 4)
|
||||||
|
header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
|
+ sizeof (struct grub_pe32_optional_header)
|
||||||
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
|
GRUB_PE32_SECTION_ALIGNMENT);
|
||||||
|
else
|
||||||
|
header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
|
+ sizeof (struct grub_pe64_optional_header)
|
||||||
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
|
GRUB_PE32_SECTION_ALIGNMENT);
|
||||||
|
|
||||||
|
reloc_addr = ALIGN_UP (header_size + core_size,
|
||||||
|
image_target->section_align);
|
||||||
|
|
||||||
|
pe_size = ALIGN_UP (reloc_addr + reloc_size,
|
||||||
|
image_target->section_align);
|
||||||
pe_img = xmalloc (reloc_addr + reloc_size);
|
pe_img = xmalloc (reloc_addr + reloc_size);
|
||||||
memset (pe_img, 0, header_size);
|
memset (pe_img, 0, header_size);
|
||||||
memcpy (pe_img + header_size, core_img, core_size);
|
memcpy (pe_img + header_size, core_img, core_size);
|
||||||
|
@ -1170,11 +1193,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
header = pe_img;
|
header = pe_img;
|
||||||
|
|
||||||
/* The magic. */
|
/* The magic. */
|
||||||
memcpy (header->msdos_stub, stub, sizeof (header->msdos_stub));
|
memcpy (header, stub, GRUB_PE32_MSDOS_STUB_SIZE);
|
||||||
memcpy (header->signature, "PE\0\0", sizeof (header->signature));
|
memcpy (header + GRUB_PE32_MSDOS_STUB_SIZE, "PE\0\0",
|
||||||
|
GRUB_PE32_SIGNATURE_SIZE);
|
||||||
|
|
||||||
/* The COFF file header. */
|
/* The COFF file header. */
|
||||||
c = &header->coff_header;
|
c = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE;
|
||||||
if (image_target->voidp_sizeof == 4)
|
if (image_target->voidp_sizeof == 4)
|
||||||
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
|
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
|
||||||
else
|
else
|
||||||
|
@ -1182,7 +1206,6 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
|
|
||||||
c->num_sections = grub_host_to_target16 (4);
|
c->num_sections = grub_host_to_target16 (4);
|
||||||
c->time = grub_host_to_target32 (time (0));
|
c->time = grub_host_to_target32 (time (0));
|
||||||
c->optional_header_size = grub_host_to_target16 (sizeof (header->optional_header));
|
|
||||||
c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE
|
c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE
|
||||||
| GRUB_PE32_LINE_NUMS_STRIPPED
|
| GRUB_PE32_LINE_NUMS_STRIPPED
|
||||||
| ((image_target->voidp_sizeof == 4)
|
| ((image_target->voidp_sizeof == 4)
|
||||||
|
@ -1192,33 +1215,74 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
| GRUB_PE32_DEBUG_STRIPPED);
|
| GRUB_PE32_DEBUG_STRIPPED);
|
||||||
|
|
||||||
/* The PE Optional header. */
|
/* The PE Optional header. */
|
||||||
o = &header->optional_header;
|
|
||||||
o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
|
|
||||||
o->code_size = grub_host_to_target32 (exec_size);
|
|
||||||
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
|
|
||||||
o->bss_size = grub_cpu_to_le32 (bss_size);
|
|
||||||
o->entry_addr = grub_cpu_to_le32 (start_address);
|
|
||||||
o->code_base = grub_cpu_to_le32 (header_size);
|
|
||||||
if (image_target->voidp_sizeof == 4)
|
if (image_target->voidp_sizeof == 4)
|
||||||
o->data_base = grub_host_to_target32 (header_size + exec_size);
|
{
|
||||||
o->image_base = 0;
|
struct grub_pe32_optional_header *o;
|
||||||
o->section_alignment = grub_host_to_target32 (image_target->section_align);
|
|
||||||
o->file_alignment = grub_host_to_target32 (image_target->section_align);
|
|
||||||
o->image_size = grub_host_to_target32 (pe_size);
|
|
||||||
o->header_size = grub_host_to_target32 (header_size);
|
|
||||||
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
|
|
||||||
|
|
||||||
/* Do these really matter? */
|
c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
|
||||||
o->stack_reserve_size = grub_host_to_target32 (0x10000);
|
|
||||||
o->stack_commit_size = grub_host_to_target32 (0x10000);
|
o = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
|
||||||
o->heap_reserve_size = grub_host_to_target32 (0x10000);
|
+ sizeof (struct grub_pe32_coff_header);
|
||||||
o->heap_commit_size = grub_host_to_target32 (0x10000);
|
o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
|
||||||
|
o->code_size = grub_host_to_target32 (exec_size);
|
||||||
|
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
|
||||||
|
o->bss_size = grub_cpu_to_le32 (bss_size);
|
||||||
|
o->entry_addr = grub_cpu_to_le32 (start_address);
|
||||||
|
o->code_base = grub_cpu_to_le32 (header_size);
|
||||||
|
|
||||||
|
o->data_base = grub_host_to_target32 (header_size + exec_size);
|
||||||
|
|
||||||
|
o->image_base = 0;
|
||||||
|
o->section_alignment = grub_host_to_target32 (image_target->section_align);
|
||||||
|
o->file_alignment = grub_host_to_target32 (image_target->section_align);
|
||||||
|
o->image_size = grub_host_to_target32 (pe_size);
|
||||||
|
o->header_size = grub_host_to_target32 (header_size);
|
||||||
|
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
|
||||||
|
|
||||||
|
/* Do these really matter? */
|
||||||
|
o->stack_reserve_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->stack_commit_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->heap_reserve_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->heap_commit_size = grub_host_to_target32 (0x10000);
|
||||||
|
|
||||||
o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
|
o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
|
||||||
|
|
||||||
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
|
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
|
||||||
o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
|
o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct grub_pe64_optional_header *o;
|
||||||
|
|
||||||
|
c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
|
||||||
|
|
||||||
|
o = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header);
|
||||||
|
o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
|
||||||
|
o->code_size = grub_host_to_target32 (exec_size);
|
||||||
|
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
|
||||||
|
o->bss_size = grub_cpu_to_le32 (bss_size);
|
||||||
|
o->entry_addr = grub_cpu_to_le32 (start_address);
|
||||||
|
o->code_base = grub_cpu_to_le32 (header_size);
|
||||||
|
o->image_base = 0;
|
||||||
|
o->section_alignment = grub_host_to_target32 (image_target->section_align);
|
||||||
|
o->file_alignment = grub_host_to_target32 (image_target->section_align);
|
||||||
|
o->image_size = grub_host_to_target32 (pe_size);
|
||||||
|
o->header_size = grub_host_to_target32 (header_size);
|
||||||
|
o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
|
||||||
|
|
||||||
|
/* Do these really matter? */
|
||||||
|
o->stack_reserve_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->stack_commit_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->heap_reserve_size = grub_host_to_target32 (0x10000);
|
||||||
|
o->heap_commit_size = grub_host_to_target32 (0x10000);
|
||||||
|
|
||||||
|
o->num_data_directories
|
||||||
|
= grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
|
||||||
|
|
||||||
|
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
|
||||||
|
o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
|
||||||
|
}
|
||||||
/* The sections. */
|
/* The sections. */
|
||||||
text_section = (struct grub_pe32_section_table *) (header + 1);
|
text_section = (struct grub_pe32_section_table *) (header + 1);
|
||||||
strcpy (text_section->name, ".text");
|
strcpy (text_section->name, ".text");
|
||||||
|
@ -1422,10 +1486,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
|
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
|
||||||
|
|
||||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||||
target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR
|
target_addr = ALIGN_UP (image_target->link_addr
|
||||||
+ kernel_size + total_module_size, 32);
|
+ kernel_size + total_module_size, 32);
|
||||||
else
|
else
|
||||||
target_addr = GRUB_KERNEL_MACHINE_LINK_ADDR;
|
target_addr = image_target->link_addr;
|
||||||
ehdr->e_entry = grub_host_to_target32 (target_addr);
|
ehdr->e_entry = grub_host_to_target32 (target_addr);
|
||||||
phdr->p_vaddr = grub_host_to_target32 (target_addr);
|
phdr->p_vaddr = grub_host_to_target32 (target_addr);
|
||||||
phdr->p_paddr = grub_host_to_target32 (target_addr);
|
phdr->p_paddr = grub_host_to_target32 (target_addr);
|
||||||
|
@ -1534,7 +1598,7 @@ Usage: %s [OPTION]... [MODULES]\n\
|
||||||
\n\
|
\n\
|
||||||
Make a bootable image of GRUB.\n\
|
Make a bootable image of GRUB.\n\
|
||||||
\n\
|
\n\
|
||||||
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
|
-d, --directory=DIR use images and modules under DIR [default=%s/@platform@]\n\
|
||||||
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
|
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
|
||||||
-m, --memdisk=FILE embed FILE as a memdisk image\n\
|
-m, --memdisk=FILE embed FILE as a memdisk image\n\
|
||||||
-f, --font=FILE embed FILE as a boot font\n\
|
-f, --font=FILE embed FILE as a boot font\n\
|
||||||
|
@ -1679,6 +1743,21 @@ main (int argc, char *argv[])
|
||||||
free (output);
|
free (output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dir)
|
||||||
|
{
|
||||||
|
const char *last;
|
||||||
|
last = strchr (image_target->name, '-');
|
||||||
|
if (last)
|
||||||
|
last = strchr (last + 1, '-');
|
||||||
|
if (!last)
|
||||||
|
last = image_target->name + strlen (image_target->name);
|
||||||
|
dir = xmalloc (sizeof (GRUB_LIBDIR) + (last - image_target->name));
|
||||||
|
memcpy (dir, GRUB_LIBDIR, sizeof (GRUB_LIBDIR) - 1);
|
||||||
|
memcpy (dir + sizeof (GRUB_LIBDIR) - 1, image_target->name,
|
||||||
|
last - image_target->name);
|
||||||
|
*(dir + sizeof (GRUB_LIBDIR) - 1 + (last - image_target->name)) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
generate_image (dir ? : GRUB_LIBDIR, prefix ? : DEFAULT_DIRECTORY, fp,
|
generate_image (dir ? : GRUB_LIBDIR, prefix ? : DEFAULT_DIRECTORY, fp,
|
||||||
argv + optind, memdisk, font, config,
|
argv + optind, memdisk, font, config,
|
||||||
image_target, note);
|
image_target, note);
|
||||||
|
|
Loading…
Reference in a new issue