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