xref: /freebsd/stand/efi/loader/arch/amd64/start.S (revision 42b38843)
1ca987d46SWarner Losh/*-
2ca987d46SWarner Losh * Copyright (C) 1999 Hewlett-Packard Co.
3ca987d46SWarner Losh *     Contributed by David Mosberger <davidm@hpl.hp.com>.
4ca987d46SWarner Losh * Copyright (C) 2005 Intel Co.
5ca987d46SWarner Losh *     Contributed by Fenghua Yu <fenghua.yu@intel.com>.
6ca987d46SWarner Losh * All rights reserved.
7ca987d46SWarner Losh *
8ca987d46SWarner Losh * Redistribution and use in source and binary forms, with or without
9ca987d46SWarner Losh * modification, are permitted provided that the following conditions
10ca987d46SWarner Losh * are met:
11ca987d46SWarner Losh * 1. Redistributions of source code must retain the above copyright
12ca987d46SWarner Losh *    notice, this list of conditions and the following disclaimer.
13ca987d46SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright
14ca987d46SWarner Losh *    notice, this list of conditions and the following disclaimer in the
15ca987d46SWarner Losh *    documentation and/or other materials provided with the distribution.
16ca987d46SWarner Losh * 3. Neither the name of Hewlett-Packard Co. nor the names of its
17ca987d46SWarner Losh *    contributors may be used to endorse or promote products derived
18ca987d46SWarner Losh *    from this software without specific prior written permission.
19ca987d46SWarner Losh *
20ca987d46SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21ca987d46SWarner Losh * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22ca987d46SWarner Losh * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23ca987d46SWarner Losh * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
24ca987d46SWarner Losh * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25ca987d46SWarner Losh * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26ca987d46SWarner Losh * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27ca987d46SWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28ca987d46SWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
29ca987d46SWarner Losh * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30ca987d46SWarner Losh * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31ca987d46SWarner Losh * SUCH DAMAGE.
32ca987d46SWarner Losh */
33ca987d46SWarner Losh
34ca987d46SWarner Losh/*
35ca987d46SWarner Losh * crt0-efi-x86_64.S - x86_64 EFI startup code.
36ca987d46SWarner Losh */
37ca987d46SWarner Losh
38ca987d46SWarner Losh	.text
39ca987d46SWarner Losh	.align 4
40ca987d46SWarner Losh
41ca987d46SWarner Losh	.globl _start
42ca987d46SWarner Losh_start:
43ca987d46SWarner Losh	subq $8, %rsp
44ca987d46SWarner Losh	pushq %rcx
45ca987d46SWarner Losh	pushq %rdx
46ca987d46SWarner Losh
47ca987d46SWarner Losh0:
48ca987d46SWarner Losh	lea ImageBase(%rip), %rdi
49ca987d46SWarner Losh	lea _DYNAMIC(%rip), %rsi
50ca987d46SWarner Losh
51ca987d46SWarner Losh	popq %rcx
52ca987d46SWarner Losh	popq %rdx
53ca987d46SWarner Losh	pushq %rcx
54ca987d46SWarner Losh	pushq %rdx
55ca987d46SWarner Losh	call self_reloc
56ca987d46SWarner Losh
57ca987d46SWarner Losh	popq %rdi
58ca987d46SWarner Losh	popq %rsi
59ca987d46SWarner Losh
60ca987d46SWarner Losh	call efi_main
61ca987d46SWarner Losh	addq $8, %rsp
62ca987d46SWarner Losh
63ca987d46SWarner Losh.exit:
64ca987d46SWarner Losh	ret
65ca987d46SWarner Losh
66ca987d46SWarner Losh	/*
67ca987d46SWarner Losh	 * hand-craft a dummy .reloc section so EFI knows it's a relocatable
68ca987d46SWarner Losh	 * executable:
69ca987d46SWarner Losh	 */
70ca987d46SWarner Losh
71ca987d46SWarner Losh	.data
72ca987d46SWarner Losh	.section .reloc, "a"
73ca987d46SWarner Losh	.long   0
74ca987d46SWarner Losh	.long   10
75ca987d46SWarner Losh	.word   0
76