xref: /openbmc/u-boot/arch/x86/lib/crt0_ia32_efi.S (revision 274bced8)
1/*
2 * crt0-efi-ia32.S - x86 EFI startup code.
3 *
4 * Copyright (C) 1999 Hewlett-Packard Co.
5 * Contributed by David Mosberger <davidm@hpl.hp.com>.
6 * All rights reserved.
7 *
8 * SPDX-License-Identifier:	BSD-3-Clause
9 */
10
11	.text
12	.align 4
13
14	.globl _start
15_start:
16	pushl %ebp
17	movl %esp,%ebp
18
19	pushl 12(%ebp)			# copy "image" argument
20	pushl  8(%ebp)			# copy "systab" argument
21
22	call 0f
230:	popl %eax
24	movl %eax,%ebx
25
26	addl $image_base-0b,%eax	# %eax = ldbase
27	addl $_DYNAMIC-0b,%ebx		# %ebx = _DYNAMIC
28
29	pushl %ebx			# pass _DYNAMIC as second argument
30	pushl %eax			# pass ldbase as first argument
31	call _relocate
32	popl %ebx
33	popl %ebx
34	testl %eax,%eax
35	jne .exit
36	call efi_main		# call app with "image" and "systab" argument
37
38.exit:	leave
39	ret
40
41	/*
42	 * hand-craft a dummy .reloc section so EFI knows it's a relocatable
43	 * executable:
44	 */
45	.data
46dummy:	.long	0
47
48#define IMAGE_REL_ABSOLUTE	0
49	.section .reloc
50	.long	dummy					/* Page RVA */
51	.long	10					/* Block Size (2*4+2) */
52	.word	(IMAGE_REL_ABSOLUTE << 12) +  0		/* reloc for dummy */
53