Path: blob/main/stand/efi/loader/arch/amd64/amd64_tramp.S
34907 views
/*-1* Copyright (c) 2013 The FreeBSD Foundation2*3* This software was developed by Benno Rice under sponsorship from4* the FreeBSD Foundation.5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#include <machine/asmacros.h>2829#define ASM_FILE30#include "multiboot2.h"3132.text33.globl amd64_tramp3435/*36* void amd64_tramp(uint64_t stack, void *copy_finish, uint64_t kernend,37* uint64_t modulep, uint64_t pagetable, uint64_t entry)38*/39amd64_tramp:40cli /* Make sure we don't get interrupted. */41movq %rdi,%rsp /* Switch to our temporary stack. */4243movq %rdx,%r12 /* Stash the kernel values for later. */44movq %rcx,%r1345movq %r8,%r1446movq %r9,%r154748callq *%rsi /* Call copy_finish so we're all ready to go. */4950pushq %r12 /* Push kernend. */51salq $32,%r13 /* Shift modulep and push it. */52pushq %r1353pushq %r15 /* Push the entry address. */54movq %r14,%cr3 /* Switch page tables. */55ret /* "Return" to kernel entry. */5657ALIGN_TEXT58amd64_tramp_end:5960/* void multiboot2_exec(uint64_t entry, uint64_t multiboot_info, uint64_t stack) */61.globl multiboot2_exec62multiboot2_exec:63movq %rdx,%rsp64pushq %rdi65movq %rsi,%rbx66movq $MULTIBOOT2_BOOTLOADER_MAGIC,%rax67ret6869.data70.globl amd64_tramp_size71amd64_tramp_size:72.long amd64_tramp_end-amd64_tramp737475