Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 2 | /* |
| 3 | * crt0-efi-x86_64.S - x86_64 EFI startup code. |
| 4 | * Copyright (C) 1999 Hewlett-Packard Co. |
| 5 | * Contributed by David Mosberger <davidm@hpl.hp.com>. |
Ivan Gorinov | 4123662 | 2018-06-13 17:27:39 -0700 | [diff] [blame] | 6 | * Copyright (C) 2005 Intel Corporation |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 7 | * Contributed by Fenghua Yu <fenghua.yu@intel.com>. |
| 8 | * |
| 9 | * All rights reserved. |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 10 | */ |
| 11 | .text |
| 12 | .align 4 |
| 13 | |
| 14 | .globl _start |
| 15 | _start: |
| 16 | subq $8, %rsp |
Ivan Gorinov | 4123662 | 2018-06-13 17:27:39 -0700 | [diff] [blame] | 17 | |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 18 | pushq %rcx |
| 19 | pushq %rdx |
| 20 | |
Ivan Gorinov | 4123662 | 2018-06-13 17:27:39 -0700 | [diff] [blame] | 21 | lea image_base(%rip), %rcx |
| 22 | lea _DYNAMIC(%rip), %rdx |
| 23 | |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 24 | call _relocate |
| 25 | |
Ivan Gorinov | 4123662 | 2018-06-13 17:27:39 -0700 | [diff] [blame] | 26 | popq %rdx |
| 27 | popq %rcx |
| 28 | |
| 29 | testq %rax, %rax |
| 30 | jnz .exit |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 31 | |
| 32 | call efi_main |
Ivan Gorinov | 4123662 | 2018-06-13 17:27:39 -0700 | [diff] [blame] | 33 | .exit: |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 34 | addq $8, %rsp |
| 35 | |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 36 | ret |
| 37 | |
| 38 | /* |
| 39 | * hand-craft a dummy .reloc section so EFI knows it's a relocatable |
| 40 | * executable: |
| 41 | */ |
| 42 | .data |
| 43 | dummy: .long 0 |
| 44 | |
| 45 | #define IMAGE_REL_ABSOLUTE 0 |
| 46 | .section .reloc, "a" |
| 47 | label1: |
| 48 | .long dummy-label1 /* Page RVA */ |
| 49 | .long 10 /* Block Size (2*4+2) */ |
| 50 | .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */ |