1/* $NetBSD: crt0-efi-ia64.S,v 1.1.1.1 2014/04/01 16:16:08 jakllsch Exp $ */ 2 3/* crt0-efi-ia64.S - IA-64 EFI startup code. 4 Copyright (C) 1999 Hewlett-Packard Co. 5 Contributed by David Mosberger <davidm@hpl.hp.com>. 6 7 All rights reserved. 8 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions 11 are met: 12 13 * Redistributions of source code must retain the above copyright 14 notice, this list of conditions and the following disclaimer. 15 * Redistributions in binary form must reproduce the above 16 copyright notice, this list of conditions and the following 17 disclaimer in the documentation and/or other materials 18 provided with the distribution. 19 * Neither the name of Hewlett-Packard Co. nor the names of its 20 contributors may be used to endorse or promote products derived 21 from this software without specific prior written permission. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 24 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 28 BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 29 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 33 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 SUCH DAMAGE. 36*/ 37 .text 38 .psr abi64 39 .psr lsb 40 .lsb 41 42 .proc _start 43_start: 44 alloc loc0=ar.pfs,2,2,2,0 45 mov loc1=rp 46 movl out0=@gprel(ImageBase) // out0 <- ImageBase (ldbase) 47 ;; 48 add out0=out0,gp 49 movl out1=@gprel(_DYNAMIC) // out1 <- _DYNAMIC 50 ;; // avoid WAW on CFM 51 add out1=out1,gp 52 br.call.sptk.few rp=_relocate 53.Lret0: 54 cmp.ne p6,p0=r0,r8 // r8 == EFI_SUCCESS? 55(p6) br.cond.sptk.few .exit // no -> 56 57.Lret1: 58 59 mov out0=in0 // image handle 60 mov out1=in1 // systab 61 br.call.sptk.few rp=efi_main 62.Lret2: 63.exit: 64 mov ar.pfs=loc0 65 mov rp=loc1 66 ;; 67 br.ret.sptk.few rp 68 69 .endp _start 70 71 72 // PE32+ wants a PLABEL, not the code address of the entry point: 73 74 .align 16 75 .global _start_plabel 76 .section .plabel, "a" 77_start_plabel: 78 data8 _start 79 data8 __gp 80 81 // hand-craft a .reloc section for the plabel: 82 83#define IMAGE_REL_BASED_DIR64 10 84 85 .section .reloc, "a" 86 data4 _start_plabel // Page RVA 87 data4 12 // Block Size (2*4+2*2) 88 data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point 89 data2 (IMAGE_REL_BASED_DIR64<<12) + 8 // reloc for plabel's global pointer 90