Highlights this time around: - x86 efi_loader support - hello world efi test case - network device name is now representative - terminal output reports modes correctly - fix psci reset for ls1043/ls1046 - fix efi_add_runtime_mmio definition for x86 - efi_loader support for ls2080 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJYLa6qAAoJECszeR4D/txgF+4QAKpHJXY/1V+McEsLga2iwePZ lZu5NuuLeDA9IMH+ufOOGxDIoc/llZCTsqw5l8Vnkaz0JEH6v9svyEy4zC1Nqtj2 r4pOhGLAyVlGAh4O3hFFi/eHNEDyTrMoPO6JCy8ce+fEGE21VBlWed0+/c/KdV7F 85joTg3X+6htFMkLybzKZS1yiJyoROe7zUZdzPrn4ogwDGbazmYbED+P2u09dDzB WjlpIbmEDWJEska6Cbgl/ee6dBXSVl8Q/SY3V77T5TB554sZozrKDsNUehiUMEbh ggCT5VzPhsm4gb/7RBpTqqCabBT5ml8iKfB8Y7fwL43sDiMXJ1LgJyVnHuz65sCS aPPsPjQujBSiqr+k/571yhgFNLVydrs9IYNumZr+Li4UZCvx3xtCjACJVYkbLUd1 SZrpKts0V45nZcE4IoiwDKOUxavUbLEef2SJTOAOppB3DG9L3O0TWkyH00hTkaxR oDIVNSZPt9wSd4Q7FQ2MYxQ/sk+B6PrN6Gm/NMSfCnvP8DkyTzHo514qrWnEjlhQ ndVmyJh3hpipNDfFDeF6r5lLtPkTrzNxOVZcsUGQC5jvrvwLWguD+Kuv9Qq4gSDp uDawZmRwDGEGpR/yJhqj8r6/e7bZ0fOE6nPqbWLlyF+Oc4yFTz+D2CNPGR4CR0iF DFGQN/lNkYbu+HfyZOFO =xmR3 -----END PGP SIGNATURE----- Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot Patch queue for efi - 2016-11-17 Highlights this time around: - x86 efi_loader support - hello world efi test case - network device name is now representative - terminal output reports modes correctly - fix psci reset for ls1043/ls1046 - fix efi_add_runtime_mmio definition for x86 - efi_loader support for ls2080master
commit
9e40ea04e9
@ -0,0 +1,135 @@ |
||||
/* |
||||
* crt0-efi-aarch64.S - PE/COFF header for aarch64 EFI applications |
||||
* |
||||
* Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
|
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause |
||||
* |
||||
* This file is taken and modified from the gnu-efi project. |
||||
*/ |
||||
|
||||
.section .text.head |
||||
|
||||
/* |
||||
* Magic "MZ" signature for PE/COFF |
||||
*/ |
||||
.globl ImageBase
|
||||
ImageBase: |
||||
.ascii "MZ" |
||||
.skip 58 /* 'MZ' + pad + offset == 64 */ |
||||
.long pe_header - ImageBase /* Offset to the PE header */ |
||||
pe_header: |
||||
.ascii "PE" |
||||
.short 0
|
||||
coff_header: |
||||
.short 0xaa64 /* AArch64 */ |
||||
.short 2 /* nr_sections */ |
||||
.long 0 /* TimeDateStamp */ |
||||
.long 0 /* PointerToSymbolTable */ |
||||
.long 1 /* NumberOfSymbols */ |
||||
.short section_table - optional_header /* SizeOfOptionalHeader */ |
||||
/* |
||||
* Characteristics: IMAGE_FILE_DEBUG_STRIPPED | |
||||
* IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED |
||||
*/ |
||||
.short 0x206
|
||||
optional_header: |
||||
.short 0x20b /* PE32+ format */ |
||||
.byte 0x02 /* MajorLinkerVersion */ |
||||
.byte 0x14 /* MinorLinkerVersion */ |
||||
.long _edata - _start /* SizeOfCode */ |
||||
.long 0 /* SizeOfInitializedData */ |
||||
.long 0 /* SizeOfUninitializedData */ |
||||
.long _start - ImageBase /* AddressOfEntryPoint */ |
||||
.long _start - ImageBase /* BaseOfCode */ |
||||
|
||||
extra_header_fields: |
||||
.quad 0 /* ImageBase */ |
||||
.long 0x20 /* SectionAlignment */ |
||||
.long 0x8 /* FileAlignment */ |
||||
.short 0 /* MajorOperatingSystemVersion */ |
||||
.short 0 /* MinorOperatingSystemVersion */ |
||||
.short 0 /* MajorImageVersion */ |
||||
.short 0 /* MinorImageVersion */ |
||||
.short 0 /* MajorSubsystemVersion */ |
||||
.short 0 /* MinorSubsystemVersion */ |
||||
.long 0 /* Win32VersionValue */ |
||||
|
||||
.long _edata - ImageBase /* SizeOfImage */ |
||||
|
||||
/* |
||||
* Everything before the kernel image is considered part of the header |
||||
*/ |
||||
.long _start - ImageBase /* SizeOfHeaders */ |
||||
.long 0 /* CheckSum */ |
||||
.short EFI_SUBSYSTEM /* Subsystem */ |
||||
.short 0 /* DllCharacteristics */ |
||||
.quad 0 /* SizeOfStackReserve */ |
||||
.quad 0 /* SizeOfStackCommit */ |
||||
.quad 0 /* SizeOfHeapReserve */ |
||||
.quad 0 /* SizeOfHeapCommit */ |
||||
.long 0 /* LoaderFlags */ |
||||
.long 0x6 /* NumberOfRvaAndSizes */ |
||||
|
||||
.quad 0 /* ExportTable */ |
||||
.quad 0 /* ImportTable */ |
||||
.quad 0 /* ResourceTable */ |
||||
.quad 0 /* ExceptionTable */ |
||||
.quad 0 /* CertificationTable */ |
||||
.quad 0 /* BaseRelocationTable */ |
||||
|
||||
/* Section table */ |
||||
section_table: |
||||
|
||||
/* |
||||
* The EFI application loader requires a relocation section |
||||
* because EFI applications must be relocatable. This is a |
||||
* dummy section as far as we are concerned. |
||||
*/ |
||||
.ascii ".reloc" |
||||
.byte 0
|
||||
.byte 0 /* end of 0 padding of section name */ |
||||
.long 0
|
||||
.long 0
|
||||
.long 0 /* SizeOfRawData */ |
||||
.long 0 /* PointerToRawData */ |
||||
.long 0 /* PointerToRelocations */ |
||||
.long 0 /* PointerToLineNumbers */ |
||||
.short 0 /* NumberOfRelocations */ |
||||
.short 0 /* NumberOfLineNumbers */ |
||||
.long 0x42100040 /* Characteristics (section flags) */ |
||||
|
||||
|
||||
.ascii ".text" |
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0 /* end of 0 padding of section name */ |
||||
.long _edata - _start /* VirtualSize */ |
||||
.long _start - ImageBase /* VirtualAddress */ |
||||
.long _edata - _start /* SizeOfRawData */ |
||||
.long _start - ImageBase /* PointerToRawData */ |
||||
|
||||
.long 0 /* PointerToRelocations (0 for executables) */ |
||||
.long 0 /* PointerToLineNumbers (0 for executables) */ |
||||
.short 0 /* NumberOfRelocations (0 for executables) */ |
||||
.short 0 /* NumberOfLineNumbers (0 for executables) */ |
||||
.long 0xe0500020 /* Characteristics (section flags) */ |
||||
|
||||
_start: |
||||
stp x29, x30, [sp, #-32]! |
||||
mov x29, sp |
||||
|
||||
stp x0, x1, [sp, #16] |
||||
mov x2, x0 |
||||
mov x3, x1 |
||||
adr x0, ImageBase |
||||
adrp x1, _DYNAMIC |
||||
add x1, x1, #:lo12:_DYNAMIC |
||||
bl _relocate |
||||
cbnz x0, 0f |
||||
|
||||
ldp x0, x1, [sp, #16] |
||||
bl efi_main |
||||
|
||||
0: ldp x29, x30, [sp], #32 |
||||
ret |
@ -0,0 +1,138 @@ |
||||
/* |
||||
* crt0-efi-arm.S - PE/COFF header for ARM EFI applications |
||||
* |
||||
* Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
|
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause |
||||
* |
||||
* This file is taken and modified from the gnu-efi project. |
||||
*/ |
||||
|
||||
.section .text.head |
||||
|
||||
/* |
||||
* Magic "MZ" signature for PE/COFF |
||||
*/ |
||||
.globl image_base
|
||||
image_base: |
||||
.ascii "MZ" |
||||
.skip 58 /* 'MZ' + pad + offset == 64 */ |
||||
.long pe_header - image_base /* Offset to the PE header */ |
||||
pe_header: |
||||
.ascii "PE" |
||||
.short 0
|
||||
coff_header: |
||||
.short 0x1c2 /* Mixed ARM/Thumb */ |
||||
.short 2 /* nr_sections */ |
||||
.long 0 /* TimeDateStamp */ |
||||
.long 0 /* PointerToSymbolTable */ |
||||
.long 1 /* NumberOfSymbols */ |
||||
.short section_table - optional_header /* SizeOfOptionalHeader */ |
||||
/* |
||||
* Characteristics: IMAGE_FILE_32BIT_MACHINE | |
||||
* IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE | |
||||
* IMAGE_FILE_LINE_NUMS_STRIPPED |
||||
*/ |
||||
.short 0x306
|
||||
optional_header: |
||||
.short 0x10b /* PE32+ format */ |
||||
.byte 0x02 /* MajorLinkerVersion */ |
||||
.byte 0x14 /* MinorLinkerVersion */ |
||||
.long _edata - _start /* SizeOfCode */ |
||||
.long 0 /* SizeOfInitializedData */ |
||||
.long 0 /* SizeOfUninitializedData */ |
||||
.long _start - image_base /* AddressOfEntryPoint */ |
||||
.long _start - image_base /* BaseOfCode */ |
||||
.long 0 /* BaseOfData */ |
||||
|
||||
extra_header_fields: |
||||
.long 0 /* image_base */ |
||||
.long 0x20 /* SectionAlignment */ |
||||
.long 0x8 /* FileAlignment */ |
||||
.short 0 /* MajorOperatingSystemVersion */ |
||||
.short 0 /* MinorOperatingSystemVersion */ |
||||
.short 0 /* MajorImageVersion */ |
||||
.short 0 /* MinorImageVersion */ |
||||
.short 0 /* MajorSubsystemVersion */ |
||||
.short 0 /* MinorSubsystemVersion */ |
||||
.long 0 /* Win32VersionValue */ |
||||
|
||||
.long _edata - image_base /* SizeOfImage */ |
||||
|
||||
/* |
||||
* Everything before the kernel image is considered part of the header |
||||
*/ |
||||
.long _start - image_base /* SizeOfHeaders */ |
||||
.long 0 /* CheckSum */ |
||||
.short EFI_SUBSYSTEM /* Subsystem */ |
||||
.short 0 /* DllCharacteristics */ |
||||
.long 0 /* SizeOfStackReserve */ |
||||
.long 0 /* SizeOfStackCommit */ |
||||
.long 0 /* SizeOfHeapReserve */ |
||||
.long 0 /* SizeOfHeapCommit */ |
||||
.long 0 /* LoaderFlags */ |
||||
.long 0x6 /* NumberOfRvaAndSizes */ |
||||
|
||||
.quad 0 /* ExportTable */ |
||||
.quad 0 /* ImportTable */ |
||||
.quad 0 /* ResourceTable */ |
||||
.quad 0 /* ExceptionTable */ |
||||
.quad 0 /* CertificationTable */ |
||||
.quad 0 /* BaseRelocationTable */ |
||||
|
||||
section_table: |
||||
|
||||
/* |
||||
* The EFI application loader requires a relocation section |
||||
* because EFI applications must be relocatable. This is a |
||||
* dummy section as far as we are concerned. |
||||
*/ |
||||
.ascii ".reloc" |
||||
.byte 0
|
||||
.byte 0 /* end of 0 padding of section name */ |
||||
.long 0
|
||||
.long 0
|
||||
.long 0 /* SizeOfRawData */ |
||||
.long 0 /* PointerToRawData */ |
||||
.long 0 /* PointerToRelocations */ |
||||
.long 0 /* PointerToLineNumbers */ |
||||
.short 0 /* NumberOfRelocations */ |
||||
.short 0 /* NumberOfLineNumbers */ |
||||
.long 0x42100040 /* Characteristics (section flags) */ |
||||
|
||||
.ascii ".text" |
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0 /* end of 0 padding of section name */ |
||||
.long _edata - _start /* VirtualSize */ |
||||
.long _start - image_base /* VirtualAddress */ |
||||
.long _edata - _start /* SizeOfRawData */ |
||||
.long _start - image_base /* PointerToRawData */ |
||||
|
||||
.long 0 /* PointerToRelocations (0 for executables) */ |
||||
.long 0 /* PointerToLineNumbers (0 for executables) */ |
||||
.short 0 /* NumberOfRelocations (0 for executables) */ |
||||
.short 0 /* NumberOfLineNumbers (0 for executables) */ |
||||
.long 0xe0500020 /* Characteristics (section flags) */ |
||||
|
||||
_start: |
||||
stmfd sp!, {r0-r2, lr} |
||||
|
||||
mov r2, r0 |
||||
mov r3, r1 |
||||
adr r1, .L_DYNAMIC |
||||
ldr r0, [r1] |
||||
add r1, r0, r1 |
||||
adr r0, image_base |
||||
bl _relocate |
||||
teq r0, #0 |
||||
bne 0f |
||||
|
||||
ldmfd sp, {r0-r1} |
||||
bl efi_main |
||||
|
||||
0: add sp, sp, #12 |
||||
ldr pc, [sp], #4 |
||||
|
||||
.L_DYNAMIC: |
||||
.word _DYNAMIC - . |
@ -0,0 +1,70 @@ |
||||
/* |
||||
* U-Boot aarch64 EFI linker script |
||||
* |
||||
* SPDX-License-Identifier: BSD-2-Clause |
||||
* |
||||
* Modified from elf_aarch64_efi.lds in gnu-efi |
||||
*/ |
||||
|
||||
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64") |
||||
OUTPUT_ARCH(aarch64) |
||||
ENTRY(_start) |
||||
SECTIONS |
||||
{ |
||||
.text 0x0 : { |
||||
_text = .; |
||||
*(.text.head) |
||||
*(.text) |
||||
*(.text.*) |
||||
*(.gnu.linkonce.t.*) |
||||
*(.srodata) |
||||
*(.rodata*) |
||||
. = ALIGN(16); |
||||
} |
||||
_etext = .; |
||||
_text_size = . - _text; |
||||
.dynamic : { *(.dynamic) } |
||||
.data : { |
||||
_data = .; |
||||
*(.sdata) |
||||
*(.data) |
||||
*(.data1) |
||||
*(.data.*) |
||||
*(.got.plt) |
||||
*(.got) |
||||
|
||||
/* |
||||
* The EFI loader doesn't seem to like a .bss section, so we |
||||
* stick it all into .data: |
||||
*/ |
||||
. = ALIGN(16); |
||||
_bss = .; |
||||
*(.sbss) |
||||
*(.scommon) |
||||
*(.dynbss) |
||||
*(.bss) |
||||
*(.bss.*) |
||||
*(COMMON) |
||||
. = ALIGN(16); |
||||
_bss_end = .; |
||||
_edata = .; |
||||
} |
||||
.rela.dyn : { *(.rela.dyn) } |
||||
.rela.plt : { *(.rela.plt) } |
||||
.rela.got : { *(.rela.got) } |
||||
.rela.data : { *(.rela.data) *(.rela.data*) } |
||||
_data_size = . - _etext; |
||||
|
||||
. = ALIGN(4096); |
||||
.dynsym : { *(.dynsym) } |
||||
. = ALIGN(4096); |
||||
.dynstr : { *(.dynstr) } |
||||
. = ALIGN(4096); |
||||
.note.gnu.build-id : { *(.note.gnu.build-id) } |
||||
/DISCARD/ : { |
||||
*(.rel.reloc) |
||||
*(.eh_frame) |
||||
*(.note.GNU-stack) |
||||
} |
||||
.comment 0 : { *(.comment) } |
||||
} |
@ -0,0 +1,70 @@ |
||||
/* |
||||
* U-Boot ARM EFI linker script |
||||
* |
||||
* SPDX-License-Identifier: BSD-2-Clause |
||||
* |
||||
* Modified from elf_arm_efi.lds in gnu-efi |
||||
*/ |
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") |
||||
OUTPUT_ARCH(arm) |
||||
ENTRY(_start) |
||||
SECTIONS |
||||
{ |
||||
.text 0x0 : { |
||||
_text = .; |
||||
*(.text.head) |
||||
*(.text) |
||||
*(.text.*) |
||||
*(.gnu.linkonce.t.*) |
||||
*(.srodata) |
||||
*(.rodata*) |
||||
. = ALIGN(16); |
||||
} |
||||
_etext = .; |
||||
_text_size = . - _text; |
||||
.dynamic : { *(.dynamic) } |
||||
.data : { |
||||
_data = .; |
||||
*(.sdata) |
||||
*(.data) |
||||
*(.data1) |
||||
*(.data.*) |
||||
*(.got.plt) |
||||
*(.got) |
||||
|
||||
/* |
||||
* The EFI loader doesn't seem to like a .bss section, so we |
||||
* stick it all into .data: |
||||
*/ |
||||
. = ALIGN(16); |
||||
_bss = .; |
||||
*(.sbss) |
||||
*(.scommon) |
||||
*(.dynbss) |
||||
*(.bss) |
||||
*(.bss.*) |
||||
*(COMMON) |
||||
. = ALIGN(16); |
||||
_bss_end = .; |
||||
_edata = .; |
||||
} |
||||
.rel.dyn : { *(.rel.dyn) } |
||||
.rel.plt : { *(.rel.plt) } |
||||
.rel.got : { *(.rel.got) } |
||||
.rel.data : { *(.rel.data) *(.rel.data*) } |
||||
_data_size = . - _etext; |
||||
|
||||
. = ALIGN(4096); |
||||
.dynsym : { *(.dynsym) } |
||||
. = ALIGN(4096); |
||||
.dynstr : { *(.dynstr) } |
||||
. = ALIGN(4096); |
||||
.note.gnu.build-id : { *(.note.gnu.build-id) } |
||||
/DISCARD/ : { |
||||
*(.rel.reloc) |
||||
*(.eh_frame) |
||||
*(.note.GNU-stack) |
||||
} |
||||
.comment 0 : { *(.comment) } |
||||
} |
@ -0,0 +1,87 @@ |
||||
/* reloc_aarch64.c - position independent x86 ELF shared object relocator
|
||||
Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org> |
||||
Copyright (C) 1999 Hewlett-Packard Co. |
||||
Contributed by David Mosberger <davidm@hpl.hp.com>. |
||||
|
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions |
||||
are met: |
||||
|
||||
* Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above |
||||
copyright notice, this list of conditions and the following |
||||
disclaimer in the documentation and/or other materials |
||||
provided with the distribution. |
||||
* Neither the name of Hewlett-Packard Co. nor the names of its |
||||
contributors may be used to endorse or promote products derived |
||||
from this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
||||
BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
||||
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
*/ |
||||
|
||||
#include <efi.h> |
||||
|
||||
#include <elf.h> |
||||
|
||||
efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image, |
||||
struct efi_system_table *systab) |
||||
{ |
||||
long relsz = 0, relent = 0; |
||||
Elf64_Rela *rel = 0; |
||||
unsigned long *addr; |
||||
int i; |
||||
|
||||
for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { |
||||
switch (dyn[i].d_tag) { |
||||
case DT_RELA: |
||||
rel = (Elf64_Rela *)((ulong)dyn[i].d_un.d_ptr + ldbase); |
||||
break; |
||||
case DT_RELASZ: |
||||
relsz = dyn[i].d_un.d_val; |
||||
break; |
||||
case DT_RELAENT: |
||||
relent = dyn[i].d_un.d_val; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (!rel && relent == 0) |
||||
return EFI_SUCCESS; |
||||
|
||||
if (!rel || relent == 0) |
||||
return EFI_LOAD_ERROR; |
||||
|
||||
while (relsz > 0) { |
||||
/* apply the relocs */ |
||||
switch (ELF64_R_TYPE(rel->r_info)) { |
||||
case R_AARCH64_NONE: |
||||
break; |
||||
case R_AARCH64_RELATIVE: |
||||
addr = (ulong *)(ldbase + rel->r_offset); |
||||
*addr = ldbase + rel->r_addend; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
rel = (Elf64_Rela *)((char *)rel + relent); |
||||
relsz -= relent; |
||||
} |
||||
return EFI_SUCCESS; |
||||
} |
@ -0,0 +1,66 @@ |
||||
/*
|
||||
* reloc_arm.c - position-independent ARM ELF shared object relocator |
||||
* |
||||
* Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org> |
||||
* Copyright (C) 1999 Hewlett-Packard Co. |
||||
* Contributed by David Mosberger <davidm@hpl.hp.com>. |
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* SPDX-License-Identifier: BSD-3-Clause |
||||
* |
||||
* This file is taken and modified from the gnu-efi project. |
||||
*/ |
||||
|
||||
#include <efi.h> |
||||
#include <elf.h> |
||||
|
||||
efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image, |
||||
struct efi_system_table *systab) |
||||
{ |
||||
long relsz = 0, relent = 0; |
||||
Elf32_Rel *rel = 0; |
||||
ulong *addr; |
||||
int i; |
||||
|
||||
for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { |
||||
switch (dyn[i].d_tag) { |
||||
case DT_REL: |
||||
rel = (Elf32_Rel *)((ulong)dyn[i].d_un.d_ptr |
||||
+ ldbase); |
||||
break; |
||||
case DT_RELSZ: |
||||
relsz = dyn[i].d_un.d_val; |
||||
break; |
||||
case DT_RELENT: |
||||
relent = dyn[i].d_un.d_val; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (!rel && relent == 0) |
||||
return EFI_SUCCESS; |
||||
|
||||
if (!rel || relent == 0) |
||||
return EFI_LOAD_ERROR; |
||||
|
||||
while (relsz > 0) { |
||||
/* apply the relocs */ |
||||
switch (ELF32_R_TYPE(rel->r_info)) { |
||||
case R_ARM_NONE: |
||||
break; |
||||
case R_ARM_RELATIVE: |
||||
addr = (ulong *)(ldbase + rel->r_offset); |
||||
*addr += ldbase; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
rel = (Elf32_Rel *)((char *)rel + relent); |
||||
relsz -= relent; |
||||
} |
||||
|
||||
return EFI_SUCCESS; |
||||
} |
@ -0,0 +1,24 @@ |
||||
/*
|
||||
* EFI hello world |
||||
* |
||||
* Copyright (c) 2016 Google, Inc |
||||
* Written by Simon Glass <sjg@chromium.org> |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <part_efi.h> |
||||
#include <efi_api.h> |
||||
|
||||
efi_status_t EFIAPI efi_main(efi_handle_t handle, |
||||
struct efi_system_table *systable) |
||||
{ |
||||
struct efi_simple_text_output_protocol *con_out = systable->con_out; |
||||
struct efi_boot_services *boottime = systable->boottime; |
||||
|
||||
con_out->output_string(con_out, L"Hello, world!\n"); |
||||
boottime->exit(handle, 0, 0, NULL); |
||||
|
||||
return EFI_SUCCESS; |
||||
} |
Loading…
Reference in new issue