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