1 1.2 nonaka /* $NetBSD: start.S,v 1.2 2017/04/29 00:05:35 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.2 nonaka #include <sys/bootblock.h> 43 1.1 nonaka 44 1.1 nonaka .text 45 1.1 nonaka .align 16 46 1.1 nonaka .globl _start 47 1.1 nonaka _start: 48 1.1 nonaka subq $8, %rsp 49 1.1 nonaka pushq %rcx 50 1.1 nonaka pushq %rdx 51 1.1 nonaka 52 1.1 nonaka 0: 53 1.1 nonaka lea ImageBase(%rip), %rdi 54 1.1 nonaka lea _DYNAMIC(%rip), %rsi 55 1.1 nonaka 56 1.1 nonaka popq %rcx 57 1.1 nonaka popq %rdx 58 1.1 nonaka pushq %rcx 59 1.1 nonaka pushq %rdx 60 1.1 nonaka call _C_LABEL(self_reloc) 61 1.1 nonaka 62 1.1 nonaka popq %rdi 63 1.1 nonaka popq %rsi 64 1.1 nonaka 65 1.1 nonaka call _C_LABEL(efi_main) 66 1.1 nonaka addq $8, %rsp 67 1.1 nonaka 68 1.1 nonaka .Lexit: 69 1.1 nonaka ret 70 1.1 nonaka 71 1.1 nonaka /* 72 1.1 nonaka * hand-craft a dummy .reloc section so EFI knows it's a relocatable 73 1.1 nonaka * executable: 74 1.1 nonaka */ 75 1.1 nonaka 76 1.1 nonaka .data 77 1.1 nonaka .section .reloc, "a" 78 1.1 nonaka .long 0 79 1.1 nonaka .long 10 80 1.1 nonaka .word 0 81 1.2 nonaka 82 1.2 nonaka /* boot parameters */ 83 1.2 nonaka .text 84 1.2 nonaka .code16 85 1.2 nonaka .align 512 86 1.2 nonaka .Lfake_bootxx: 87 1.2 nonaka jmp 1f 88 1.2 nonaka .balign 4 89 1.2 nonaka .long X86_BOOT_MAGIC_EFI /* checked by installboot */ 90 1.2 nonaka .globl _C_LABEL(boot_params) 91 1.2 nonaka _C_LABEL(boot_params): /* space for patchable variables */ 92 1.2 nonaka .long 1f - boot_params /* length of this data area */ 93 1.2 nonaka #include <boot_params.S> 94 1.2 nonaka . = .Lfake_bootxx + 0x80 /* Space for patching unknown params */ 95 1.2 nonaka 1: 96