+++ /dev/null
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php.\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-# SwitchStack.S\r
-#\r
-# Abstract:\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# Routine Description:\r
-#\r
-# Routine for switching stacks with 3 parameters EFI ABI\r
-# Convert UNIX to EFI ABI\r
-#\r
-# Arguments:\r
-#\r
-# (rdi) EntryPoint - Entry point with new stack.\r
-# (rsi) Context1 - Parameter1 for entry point. (rcx)\r
-# (rdx) Context2 - Parameter2 for entry point. (rdx) \r
-# (rcx) Context3 - Parameter3 for entry point. (r8)\r
-# (r8) NewStack - The pointer to new stack.\r
-#\r
-# Returns:\r
-#\r
-# None\r
-#\r
-#------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
-ASM_PFX(PeiSwitchStacks):\r
- pushq %rbp // stack frame is for the debugger\r
- movq %rsp, %rbp\r
-\r
- movq %r8, %rsp\r
- \r
- movq %rdi, %rax\r
- movq %rsi, %rcx\r
- movq %rcx, %r8 \r
- \r
- #\r
- # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
- # in case the callee wishes to spill them.\r
- #\r
- subq $32, %rsp // 32-byte shadow space plus alignment pad\r
- call *%rax\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# Routine Description:\r
-#\r
-# Routine for switching stacks with 3 parameters UNIX ABI\r
-#\r
-# Arguments:\r
-#\r
-# (rdi) EntryPoint - Entry point with new stack.\r
-# (rsi) Context1 - Parameter1 for entry point.\r
-# (rdx) Context2 - Parameter2 for entry point.\r
-# (rcx) Context3 - Parameter3 for entry point.\r
-# (r8) NewStack - The pointer to new stack.\r
-#\r
-# Returns:\r
-#\r
-# None\r
-#\r
-#------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks)\r
-ASM_PFX(UnixPeiSwitchStacks):\r
- pushq %rbp // stack frame is for the debugger\r
- movq %rsp, %rbp\r
-\r
- mov %rdi, %rax\r
- mov %rsi, %rdi\r
- mov %rdx, %rsi\r
- mov %rcx, %rdx\r
- mov %r8, %rsp\r
- \r
- \r
- #\r
- # Reserve space for redzone on the stack,\r
- # in case the callee wishes to spill them.\r
- #\r
- lea -0x80(%rsp), %rsp\r
- call *%rax\r
-\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# VOID\r
-# EFIAPI\r
-# SecSwitchStack (\r
-# UINT32 TemporaryMemoryBase, // Rcx, Rdi\r
-# UINT32 PermenentMemoryBase // Rdx, Rsi\r
-# );\r
-#------------------------------------------------------------------------------ \r
-ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
-ASM_PFX(SecSwitchStack):\r
- pushq %rbp // stack frame is for the debugger\r
- movq %rsp, %rbp\r
-\r
- mov %rsp, %rax\r
- sub %rdi, %rax\r
- add %rsi, %rax\r
- mov (%rip), %r10\r
- mov %r10, (%rax) \r
- \r
- popq %rbp\r
- ret\r
- \r
-
\ No newline at end of file