1/* $NetBSD: start.S,v 1.2 2017/04/29 00:05:35 nonaka Exp $ */ 2 3/*- 4 * Copyright (c) 2008-2010 Rui Paulo <rpaulo@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: head/sys/boot/efi/loader/arch/i386/start.S 282728 2015-05-10 13:30:21Z ian $ 29 */ 30 31#include <machine/asm.h> 32#include <sys/bootblock.h> 33 34 .text 35 .align 16 36 37/* 38 * EFI entry point. 39 * _start(EFI_IMAGE image_handle, EFI_SYSTEM_TABLE *system_table); 40 * 41 * We calculate the base address along with _DYNAMIC, relocate us and finally 42 * pass control to efi_main. 43 */ 44 45ENTRY(_start) 46 pushl %ebp 47 movl %esp, %ebp 48 49 pushl 12(%ebp) /* image_handle */ 50 pushl 8(%ebp) /* system_table */ 51 call 0f 520: popl %eax 53 movl %eax, %ebx 54 addl $ImageBase-0b, %eax 55 addl $_DYNAMIC-0b, %ebx 56 pushl %ebx /* dynamic */ 57 pushl %eax /* ImageBase */ 58 call _C_LABEL(self_reloc) 59 popl %ebx /* remove ImageBase from the stack */ 60 popl %ebx /* remove dynamic from the stack */ 61 call _C_LABEL(efi_main) 621: leave 63 ret 64END(_start) 65 66 /* 67 * hand-craft a dummy .reloc section so EFI knows it's a relocatable 68 * executable: 69 */ 70 71 .data 72 .section .reloc, "a" 73 .long 0 74 .long 10 75 .word 0 76 77 /* boot parameters */ 78 .text 79 .code16 80 .align 512 81.Lfake_bootxx: 82 jmp 1f 83 .balign 4 84 .long X86_BOOT_MAGIC_EFI /* checked by installboot */ 85 .globl _C_LABEL(boot_params) 86_C_LABEL(boot_params): /* space for patchable variables */ 87 .long 1f - boot_params /* length of this data area */ 88#include <boot_params.S> 89 . = .Lfake_bootxx + 0x80 /* Space for patching unknown params */ 901: 91