Fill info tables for qemu, sparc and mips
This commit is contained in:
parent
0253aeb7a1
commit
962b15b4c1
8 changed files with 205 additions and 126 deletions
|
@ -137,7 +137,7 @@ lastlist:
|
||||||
.word 0
|
.word 0
|
||||||
.word 0
|
.word 0
|
||||||
|
|
||||||
. = _start + (0x200 - GRUB_BOOT_MACHINE_LIST_SIZE)
|
. = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
|
||||||
blocklist_default_start:
|
blocklist_default_start:
|
||||||
.word 0
|
.word 0
|
||||||
.word 2
|
.word 2
|
||||||
|
|
|
@ -23,41 +23,8 @@
|
||||||
/* Non-zero value is only needed for PowerMacs. */
|
/* Non-zero value is only needed for PowerMacs. */
|
||||||
#define GRUB_MOD_GAP 0x0
|
#define GRUB_MOD_GAP 0x0
|
||||||
|
|
||||||
#define GRUB_KERNEL_MACHINE_LINK_ALIGN 32
|
|
||||||
|
|
||||||
#define GRUB_KERNEL_CPU_RAW_SIZE 0x200
|
|
||||||
#define GRUB_KERNEL_CPU_COMPRESSED_SIZE 0x8
|
|
||||||
#define GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE 0xc
|
|
||||||
#define GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE 0x10
|
|
||||||
|
|
||||||
#define GRUB_KERNEL_CPU_PREFIX GRUB_KERNEL_CPU_RAW_SIZE
|
|
||||||
#define GRUB_KERNEL_CPU_DATA_END GRUB_KERNEL_CPU_RAW_SIZE + 0x48
|
|
||||||
|
|
||||||
#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_KERNEL_CPU_RAW_SIZE
|
|
||||||
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX GRUB_KERNEL_CPU_PREFIX
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END GRUB_KERNEL_CPU_DATA_END
|
|
||||||
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE
|
|
||||||
#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE
|
|
||||||
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_KERNEL_CPU_COMPRESSED_SIZE
|
|
||||||
|
|
||||||
#define GRUB_PLATFORM_IMAGE_FORMATS "raw, elf"
|
|
||||||
#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
|
|
||||||
|
|
||||||
#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
|
|
||||||
|
|
||||||
#define EM_TARGET EM_MIPS
|
|
||||||
|
|
||||||
#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[];
|
||||||
|
|
|
@ -67,14 +67,45 @@
|
||||||
/* End of the data section. */
|
/* End of the data section. */
|
||||||
#define GRUB_KERNEL_I386_QEMU_DATA_END 0x50
|
#define GRUB_KERNEL_I386_QEMU_DATA_END 0x50
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200
|
||||||
|
|
||||||
|
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8
|
||||||
|
|
||||||
|
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE 0xc
|
||||||
|
|
||||||
|
/* The offset of GRUB_COMPRESSED_SIZE. */
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE 0x10
|
||||||
|
|
||||||
|
/* The offset of GRUB_PREFIX. */
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX 0x14
|
||||||
|
|
||||||
|
/* End of the data section. */
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_DATA_END 0x114
|
||||||
|
|
||||||
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
|
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
|
||||||
|
|
||||||
#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
|
#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE 0
|
||||||
|
#define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
|
||||||
|
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
|
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
|
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN 32
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE 0x200
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE 0x8
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE 0xc
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_KERNEL_IMAGE_SIZE 0x10
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE
|
||||||
|
#define GRUB_KERNEL_MIPS_YEELOONG_DATA_END GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE + 0x48
|
||||||
|
|
||||||
#ifdef MACHINE
|
#ifdef MACHINE
|
||||||
#define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
|
#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_OFFSETS_CONCAT(a,b,c) GRUB_OFFSETS_CONCAT_(a,b,c)
|
||||||
|
|
|
@ -24,22 +24,6 @@
|
||||||
/* Non-zero value is only needed for PowerMacs. */
|
/* Non-zero value is only needed for PowerMacs. */
|
||||||
#define GRUB_MOD_GAP 0x0
|
#define GRUB_MOD_GAP 0x0
|
||||||
|
|
||||||
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE 0x8
|
|
||||||
|
|
||||||
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc
|
|
||||||
|
|
||||||
/* The offset of GRUB_COMPRESSED_SIZE. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE 0x10
|
|
||||||
|
|
||||||
/* The offset of GRUB_PREFIX. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX 0x14
|
|
||||||
|
|
||||||
/* End of the data section. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x114
|
|
||||||
|
|
||||||
#define GRUB_KERNEL_MACHINE_RAW_SIZE 0
|
|
||||||
#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
|
#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/cpu/kernel.h>
|
#include <grub/offsets.h>
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
|
#include <grub/machine/kernel.h>
|
||||||
|
|
||||||
#define BASE_ADDR 8
|
#define BASE_ADDR 8
|
||||||
|
|
||||||
|
@ -32,13 +33,13 @@ _start:
|
||||||
start:
|
start:
|
||||||
bal codestart
|
bal codestart
|
||||||
base:
|
base:
|
||||||
. = _start + GRUB_KERNEL_CPU_COMPRESSED_SIZE
|
. = _start + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
|
||||||
compressed_size:
|
compressed_size:
|
||||||
.long 0
|
.long 0
|
||||||
. = _start + GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE
|
. = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||||
total_module_size:
|
total_module_size:
|
||||||
.long 0
|
.long 0
|
||||||
. = _start + GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE
|
. = _start + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE
|
||||||
kernel_image_size:
|
kernel_image_size:
|
||||||
.long 0
|
.long 0
|
||||||
codestart:
|
codestart:
|
||||||
|
@ -105,10 +106,10 @@ argdone:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Decompress the payload. */
|
/* Decompress the payload. */
|
||||||
addiu $a0, $s0, GRUB_KERNEL_CPU_RAW_SIZE - BASE_ADDR
|
addiu $a0, $s0, GRUB_KERNEL_MACHINE_RAW_SIZE - BASE_ADDR
|
||||||
lui $a1, %hi(compressed)
|
lui $a1, %hi(compressed)
|
||||||
addiu $a1, %lo(compressed)
|
addiu $a1, %lo(compressed)
|
||||||
lw $a2, (GRUB_KERNEL_CPU_COMPRESSED_SIZE - BASE_ADDR)($s0)
|
lw $a2, (GRUB_KERNEL_MACHINE_COMPRESSED_SIZE - BASE_ADDR)($s0)
|
||||||
move $s1, $a1
|
move $s1, $a1
|
||||||
|
|
||||||
/* $a0 contains source compressed address, $a1 is destination,
|
/* $a0 contains source compressed address, $a1 is destination,
|
||||||
|
@ -134,9 +135,9 @@ reloccont:
|
||||||
addiu $t1, %lo(cont)
|
addiu $t1, %lo(cont)
|
||||||
|
|
||||||
jr $t1
|
jr $t1
|
||||||
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
|
. = _start + GRUB_KERNEL_MACHINE_RAW_SIZE
|
||||||
compressed:
|
compressed:
|
||||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||||
|
|
||||||
VARIABLE(grub_prefix)
|
VARIABLE(grub_prefix)
|
||||||
|
|
||||||
|
@ -146,7 +147,7 @@ VARIABLE(grub_prefix)
|
||||||
* Leave some breathing room for the prefix.
|
* Leave some breathing room for the prefix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||||
VARIABLE (grub_arch_busclock)
|
VARIABLE (grub_arch_busclock)
|
||||||
.long 0
|
.long 0
|
||||||
|
@ -171,7 +172,7 @@ cont:
|
||||||
/* Move the modules out of BSS. */
|
/* Move the modules out of BSS. */
|
||||||
lui $t1, %hi(_start)
|
lui $t1, %hi(_start)
|
||||||
addiu $t1, %lo(_start)
|
addiu $t1, %lo(_start)
|
||||||
lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($s0)
|
lw $t2, (GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE - BASE_ADDR)($s0)
|
||||||
addu $t2, $t1, $t2
|
addu $t2, $t1, $t2
|
||||||
|
|
||||||
lui $t1, %hi(_end)
|
lui $t1, %hi(_end)
|
||||||
|
@ -181,7 +182,7 @@ cont:
|
||||||
nor $t3, $t3, $0
|
nor $t3, $t3, $0
|
||||||
and $t1, $t1, $t3
|
and $t1, $t1, $t3
|
||||||
|
|
||||||
lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
|
lw $t3, (GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
|
||||||
|
|
||||||
/* Backward copy. */
|
/* Backward copy. */
|
||||||
add $t1, $t1, $t3
|
add $t1, $t1, $t3
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
|
#include <grub/offsets.h>
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.align 4
|
.align 4
|
||||||
|
|
|
@ -55,7 +55,6 @@ struct image_target_desc
|
||||||
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
|
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
|
||||||
IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC
|
IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC
|
||||||
} id;
|
} id;
|
||||||
enum {FORMAT_RAW, FORMAT_AOUT, FORMAT_ELF, FORMAT_PE} format;
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PLATFORM_FLAGS_NONE = 0,
|
PLATFORM_FLAGS_NONE = 0,
|
||||||
|
@ -77,56 +76,153 @@ struct image_target_desc
|
||||||
|
|
||||||
struct image_target_desc image_targets[] =
|
struct image_target_desc image_targets[] =
|
||||||
{
|
{
|
||||||
{"i386-coreboot", 4, 0, IMAGE_COREBOOT, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
{
|
||||||
.section_align = 1,
|
.name = "i386-coreboot",
|
||||||
.vaddr_offset = 0
|
.voidp_sizeof = 4,
|
||||||
|
.bigendian = 0,
|
||||||
|
.id = IMAGE_COREBOOT,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0
|
||||||
},
|
},
|
||||||
{"i386-pc", 4, 0, IMAGE_I386_PC, FORMAT_RAW, PLATFORM_FLAGS_LZMA,
|
{
|
||||||
GRUB_KERNEL_I386_PC_PREFIX, GRUB_KERNEL_I386_PC_DATA_END,
|
.name = "i386-pc",
|
||||||
GRUB_KERNEL_I386_PC_RAW_SIZE, GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
|
.voidp_sizeof = 4,
|
||||||
GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE, GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
|
.bigendian = 0,
|
||||||
.section_align = 1,
|
.id = IMAGE_I386_PC,
|
||||||
.vaddr_offset = 0,
|
.flags = PLATFORM_FLAGS_LZMA,
|
||||||
GRUB_KERNEL_I386_PC_INSTALL_DOS_PART, GRUB_KERNEL_I386_PC_INSTALL_BSD_PART
|
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_I386_PC_DATA_END,
|
||||||
|
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
|
||||||
|
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
|
||||||
|
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
|
||||||
|
.compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
|
||||||
|
.install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
|
||||||
|
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
|
||||||
},
|
},
|
||||||
{"i386-efi", 4, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
{
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.name = "i386-efi",
|
||||||
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
.voidp_sizeof = 4,
|
||||||
+ GRUB_PE32_SIGNATURE_SIZE
|
.bigendian = 0,
|
||||||
+ sizeof (struct grub_pe32_coff_header)
|
.id = IMAGE_EFI,
|
||||||
+ sizeof (struct grub_pe32_optional_header)
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
.vaddr_offset = 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)
|
||||||
},
|
},
|
||||||
{"i386-ieee1275", 4, 0, IMAGE_I386_IEEE1275, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
{
|
||||||
.section_align = 1,
|
.name = "i386-ieee1275",
|
||||||
.vaddr_offset = 0},
|
.voidp_sizeof = 4,
|
||||||
{"i386-qemu", 4, 0, IMAGE_QEMU, FORMAT_RAW, PLATFORM_FLAGS_NONE,
|
.bigendian = 0,
|
||||||
.section_align = 1,
|
.id = IMAGE_I386_IEEE1275,
|
||||||
.vaddr_offset = 0},
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
{"x86_64-efi", 8, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
|
.section_align = 1,
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.vaddr_offset = 0
|
||||||
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
},
|
||||||
+ GRUB_PE32_SIGNATURE_SIZE
|
{
|
||||||
+ sizeof (struct grub_pe32_coff_header)
|
.name = "i386-qemu",
|
||||||
+ sizeof (struct grub_pe64_optional_header)
|
.voidp_sizeof = 4,
|
||||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
.bigendian = 0,
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
.id = IMAGE_QEMU,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_I386_QEMU_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_I386_QEMU_LINK_ADDR
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "x86_64-efi",
|
||||||
|
.voidp_sizeof = 8,
|
||||||
|
.bigendian = 0,
|
||||||
|
.id = IMAGE_EFI,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
|
.vaddr_offset = 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)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "mipsel-yeeloong-elf",
|
||||||
|
.voidp_sizeof = 4,
|
||||||
|
.bigendian = 0,
|
||||||
|
.id = IMAGE_YEELOONG_ELF,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_MIPS_YEELOONG_DATA_END,
|
||||||
|
.raw_size = GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE,
|
||||||
|
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
|
||||||
|
.compressed_size = GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE,
|
||||||
|
.kernel_image_size = GRUB_KERNEL_MIPS_YEELOONG_KERNEL_IMAGE_SIZE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR,
|
||||||
|
.elf_target = EM_MIPS,
|
||||||
|
.link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "powerpc-ieee1275",
|
||||||
|
.voidp_sizeof = 4,
|
||||||
|
.bigendian = 1,
|
||||||
|
.id = IMAGE_PPC,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "sparc64-ieee1275-raw",
|
||||||
|
.voidp_sizeof = 8,
|
||||||
|
.bigendian = 1,
|
||||||
|
.id = IMAGE_SPARC64_RAW,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
|
||||||
|
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
|
||||||
|
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
|
||||||
|
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
|
||||||
|
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "sparc64-ieee1275-aout",
|
||||||
|
.voidp_sizeof = 8,
|
||||||
|
.bigendian = 1,
|
||||||
|
.id = IMAGE_SPARC64_AOUT,
|
||||||
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
|
||||||
|
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
|
||||||
|
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
|
||||||
|
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
|
||||||
|
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
|
||||||
|
.section_align = 1,
|
||||||
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||||
},
|
},
|
||||||
{"mipsel-yeeloong-elf", 4, 0, IMAGE_YEELOONG_ELF, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
|
||||||
.section_align = 1,
|
|
||||||
.vaddr_offset = 0},
|
|
||||||
{"powerpc-ieee1275", 4, 1, IMAGE_PPC, FORMAT_ELF, PLATFORM_FLAGS_NONE,
|
|
||||||
.section_align = 1,
|
|
||||||
.vaddr_offset = 0},
|
|
||||||
{"sparc64-ieee1275-raw", 8, 1, IMAGE_SPARC64_RAW,
|
|
||||||
FORMAT_RAW, PLATFORM_FLAGS_NONE,
|
|
||||||
.section_align = 1,
|
|
||||||
.vaddr_offset = 0},
|
|
||||||
{"sparc64-ieee1275-aout", 8, 1, IMAGE_SPARC64_AOUT,
|
|
||||||
FORMAT_AOUT, PLATFORM_FLAGS_NONE,
|
|
||||||
.section_align = 1,
|
|
||||||
.vaddr_offset = 0},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
|
#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
|
||||||
|
@ -191,8 +287,8 @@ grub_host_to_target16_real (struct image_target_desc *image_target, grub_uint16_
|
||||||
return grub_cpu_to_le16 (in);
|
return grub_cpu_to_le16 (in);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline grub_uint32_t
|
static inline grub_uint64_t
|
||||||
grub_host_to_target_addr_real (struct image_target_desc *image_target, grub_uint32_t in)
|
grub_host_to_target_addr_real (struct image_target_desc *image_target, grub_uint64_t in)
|
||||||
{
|
{
|
||||||
if (image_target->voidp_sizeof == 8)
|
if (image_target->voidp_sizeof == 8)
|
||||||
return grub_host_to_target64_real (image_target, in);
|
return grub_host_to_target64_real (image_target, in);
|
||||||
|
@ -200,8 +296,8 @@ grub_host_to_target_addr_real (struct image_target_desc *image_target, grub_uint
|
||||||
return grub_host_to_target32_real (image_target, in);
|
return grub_host_to_target32_real (image_target, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline grub_uint32_t
|
static inline grub_uint64_t
|
||||||
grub_target_to_host_real (struct image_target_desc *image_target, grub_uint32_t in)
|
grub_target_to_host_real (struct image_target_desc *image_target, grub_uint64_t in)
|
||||||
{
|
{
|
||||||
if (image_target->voidp_sizeof == 8)
|
if (image_target->voidp_sizeof == 8)
|
||||||
return grub_target_to_host64_real (image_target, in);
|
return grub_target_to_host64_real (image_target, in);
|
||||||
|
|
|
@ -67,11 +67,11 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
|
||||||
= (Elf_Shdr *) ((char *) sections
|
= (Elf_Shdr *) ((char *) sections
|
||||||
+ (grub_target_to_host32 (symtab_section->sh_link)
|
+ (grub_target_to_host32 (symtab_section->sh_link)
|
||||||
* section_entsize));
|
* section_entsize));
|
||||||
strtab = (char *) e + grub_target_to_host32 (strtab_section->sh_offset);
|
strtab = (char *) e + grub_target_to_host (strtab_section->sh_offset);
|
||||||
|
|
||||||
symtab_size = grub_target_to_host32 (symtab_section->sh_size);
|
symtab_size = grub_target_to_host (symtab_section->sh_size);
|
||||||
sym_size = grub_target_to_host32 (symtab_section->sh_entsize);
|
sym_size = grub_target_to_host (symtab_section->sh_entsize);
|
||||||
symtab_offset = grub_target_to_host32 (symtab_section->sh_offset);
|
symtab_offset = grub_target_to_host (symtab_section->sh_offset);
|
||||||
num_syms = symtab_size / sym_size;
|
num_syms = symtab_size / sym_size;
|
||||||
|
|
||||||
for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset);
|
for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset);
|
||||||
|
@ -482,7 +482,7 @@ SUFFIX (is_text_section) (Elf_Shdr *s, struct image_target_desc *image_target)
|
||||||
if (image_target->id != IMAGE_EFI
|
if (image_target->id != IMAGE_EFI
|
||||||
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
|
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
|
||||||
return 0;
|
return 0;
|
||||||
return ((grub_target_to_host32 (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
|
return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
|
||||||
== (SHF_EXECINSTR | SHF_ALLOC));
|
== (SHF_EXECINSTR | SHF_ALLOC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ SUFFIX (is_data_section) (Elf_Shdr *s, struct image_target_desc *image_target)
|
||||||
if (image_target->id != IMAGE_EFI
|
if (image_target->id != IMAGE_EFI
|
||||||
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
|
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
|
||||||
return 0;
|
return 0;
|
||||||
return ((grub_target_to_host32 (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
|
return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
|
||||||
== SHF_ALLOC);
|
== SHF_ALLOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,6 @@ SUFFIX (locate_sections) (Elf_Shdr *sections, Elf_Half section_entsize,
|
||||||
{
|
{
|
||||||
Elf_Word align = grub_host_to_target32 (s->sh_addralign);
|
Elf_Word align = grub_host_to_target32 (s->sh_addralign);
|
||||||
const char *name = strtab + grub_host_to_target32 (s->sh_name);
|
const char *name = strtab + grub_host_to_target32 (s->sh_name);
|
||||||
|
|
||||||
if (align)
|
if (align)
|
||||||
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
||||||
align) - image_target->vaddr_offset;
|
align) - image_target->vaddr_offset;
|
||||||
|
@ -551,7 +550,7 @@ SUFFIX (locate_sections) (Elf_Shdr *sections, Elf_Half section_entsize,
|
||||||
grub_util_info ("locating the section %s at 0x%x",
|
grub_util_info ("locating the section %s at 0x%x",
|
||||||
name, current_address);
|
name, current_address);
|
||||||
section_addresses[i] = current_address;
|
section_addresses[i] = current_address;
|
||||||
current_address += grub_host_to_target32 (s->sh_size);
|
current_address += grub_host_to_target_addr (s->sh_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
||||||
|
@ -576,7 +575,7 @@ SUFFIX (locate_sections) (Elf_Shdr *sections, Elf_Half section_entsize,
|
||||||
grub_util_info ("locating the section %s at 0x%x",
|
grub_util_info ("locating the section %s at 0x%x",
|
||||||
name, current_address);
|
name, current_address);
|
||||||
section_addresses[i] = current_address;
|
section_addresses[i] = current_address;
|
||||||
current_address += grub_host_to_target32 (s->sh_size);
|
current_address += grub_host_to_target_addr (s->sh_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
|
||||||
|
@ -616,7 +615,7 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
||||||
if (! SUFFIX (check_elf_header) (e, kernel_size, image_target))
|
if (! SUFFIX (check_elf_header) (e, kernel_size, image_target))
|
||||||
grub_util_error ("invalid ELF header");
|
grub_util_error ("invalid ELF header");
|
||||||
|
|
||||||
section_offset = grub_target_to_host32 (e->e_shoff);
|
section_offset = grub_target_to_host (e->e_shoff);
|
||||||
section_entsize = grub_target_to_host16 (e->e_shentsize);
|
section_entsize = grub_target_to_host16 (e->e_shentsize);
|
||||||
num_sections = grub_target_to_host16 (e->e_shnum);
|
num_sections = grub_target_to_host16 (e->e_shnum);
|
||||||
|
|
||||||
|
@ -660,7 +659,7 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
||||||
grub_util_info ("locating the section %s at 0x%x",
|
grub_util_info ("locating the section %s at 0x%x",
|
||||||
name, current_address);
|
name, current_address);
|
||||||
section_vaddresses[i] = current_address + VADDR_OFFSET;
|
section_vaddresses[i] = current_address + VADDR_OFFSET;
|
||||||
current_address += grub_host_to_target32 (s->sh_size);
|
current_address += grub_host_to_target_addr (s->sh_size);
|
||||||
}
|
}
|
||||||
current_address = ALIGN_UP (current_address + VADDR_OFFSET, SECTION_ALIGN)
|
current_address = ALIGN_UP (current_address + VADDR_OFFSET, SECTION_ALIGN)
|
||||||
- VADDR_OFFSET;
|
- VADDR_OFFSET;
|
||||||
|
@ -715,11 +714,11 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
||||||
{
|
{
|
||||||
if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS)
|
if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS)
|
||||||
memset (out_img + section_addresses[i], 0,
|
memset (out_img + section_addresses[i], 0,
|
||||||
grub_host_to_target32 (s->sh_size));
|
grub_host_to_target_addr (s->sh_size));
|
||||||
else
|
else
|
||||||
memcpy (out_img + section_addresses[i],
|
memcpy (out_img + section_addresses[i],
|
||||||
kernel_img + grub_host_to_target32 (s->sh_offset),
|
kernel_img + grub_host_to_target_addr (s->sh_offset),
|
||||||
grub_host_to_target32 (s->sh_size));
|
grub_host_to_target_addr (s->sh_size));
|
||||||
}
|
}
|
||||||
free (kernel_img);
|
free (kernel_img);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue