MdeModulePkg: Remove X86 ASM and S files
NASM has replaced ASM and S files. 1. Remove ASM from all modules. 2. Remove S files from the drivers only. 3. https://bugzilla.tianocore.org/show_bug.cgi?id=881 After NASM is updated, S files can be removed from Library. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# EFI Byte Code (EBC) Debugger.
|
||||
#
|
||||
# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
@@ -68,14 +68,10 @@
|
||||
[Sources.Ia32]
|
||||
Ia32/EbcSupport.c
|
||||
Ia32/EbcLowLevel.nasm
|
||||
Ia32/EbcLowLevel.S
|
||||
Ia32/EbcLowLevel.asm
|
||||
|
||||
[Sources.X64]
|
||||
X64/EbcSupport.c
|
||||
X64/EbcLowLevel.nasm
|
||||
X64/EbcLowLevel.S
|
||||
X64/EbcLowLevel.asm
|
||||
|
||||
[Sources.IPF]
|
||||
Ipf/EbcSupport.h
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# device drivers.
|
||||
#
|
||||
# Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
||||
# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -43,14 +43,10 @@
|
||||
[Sources.Ia32]
|
||||
Ia32/EbcSupport.c
|
||||
Ia32/EbcLowLevel.nasm
|
||||
Ia32/EbcLowLevel.S
|
||||
Ia32/EbcLowLevel.asm
|
||||
|
||||
[Sources.X64]
|
||||
X64/EbcSupport.c
|
||||
X64/EbcLowLevel.nasm
|
||||
X64/EbcLowLevel.S
|
||||
X64/EbcLowLevel.asm
|
||||
|
||||
[Sources.IPF]
|
||||
Ipf/EbcSupport.h
|
||||
|
@@ -1,83 +0,0 @@
|
||||
#/** @file
|
||||
#
|
||||
# Low level IA32 specific EBC support routines.
|
||||
#
|
||||
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#**/
|
||||
|
||||
ASM_GLOBAL ASM_PFX(CopyMem)
|
||||
ASM_GLOBAL ASM_PFX(EbcInterpret)
|
||||
ASM_GLOBAL ASM_PFX(ExecuteEbcImageEntryPoint)
|
||||
|
||||
ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative)
|
||||
ASM_PFX(EbcLLCALLEXNative):
|
||||
push %ebp
|
||||
push %ebx
|
||||
mov %esp,%ebp
|
||||
mov 0xc(%esp),%ecx
|
||||
mov 0x14(%esp),%eax
|
||||
mov 0x10(%esp),%edx
|
||||
sub %edx,%eax
|
||||
sub %eax,%esp
|
||||
mov %esp,%ebx
|
||||
push %ecx
|
||||
push %eax
|
||||
push %edx
|
||||
push %ebx
|
||||
call ASM_PFX(CopyMem)
|
||||
pop %eax
|
||||
pop %eax
|
||||
pop %eax
|
||||
pop %ecx
|
||||
call *%ecx
|
||||
mov %ebp,%esp
|
||||
mov %ebp,%esp
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ASM_GLOBAL ASM_PFX(EbcLLEbcInterpret)
|
||||
ASM_PFX(EbcLLEbcInterpret):
|
||||
# Construct new stack
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
push %esi
|
||||
push %edi
|
||||
sub $0x40, %esp
|
||||
push %eax
|
||||
mov %ebp, %esi
|
||||
add $0x8, %esi
|
||||
mov %esp, %edi
|
||||
add $0x4, %edi
|
||||
mov $0x10, %ecx
|
||||
rep movsd
|
||||
|
||||
# call C-code
|
||||
call ASM_PFX(EbcInterpret)
|
||||
add $0x44, %esp
|
||||
pop %edi
|
||||
pop %esi
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ASM_GLOBAL ASM_PFX(EbcLLExecuteEbcImageEntryPoint)
|
||||
ASM_PFX(EbcLLExecuteEbcImageEntryPoint):
|
||||
# Construct new stack
|
||||
mov %eax, -0xC(%esp)
|
||||
mov 0x4(%esp), %eax
|
||||
mov %eax, -0x8(%esp)
|
||||
mov 0x8(%esp), %eax
|
||||
mov %eax, -0x4(%esp)
|
||||
# call C-code
|
||||
sub $0xC, %esp
|
||||
call ASM_PFX(ExecuteEbcImageEntryPoint)
|
||||
add $0xC, %esp
|
||||
ret
|
@@ -1,207 +0,0 @@
|
||||
;/** @file
|
||||
;
|
||||
; This code provides low level routines that support the Virtual Machine
|
||||
; for option ROMs.
|
||||
;
|
||||
; Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
; This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;**/
|
||||
|
||||
page ,132
|
||||
title VM ASSEMBLY LANGUAGE ROUTINES
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Equate files needed.
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
.XLIST
|
||||
|
||||
.LIST
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Assembler options
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
.686p
|
||||
.model flat, C
|
||||
.code
|
||||
CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
|
||||
EbcInterpret PROTO
|
||||
ExecuteEbcImageEntryPoint PROTO
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLCALLEXNative
|
||||
;
|
||||
; This function is called to execute an EBC CALLEX instruction
|
||||
; to native code.
|
||||
; This instruction requires that we thunk out to external native
|
||||
; code. For IA32, we simply switch stacks and jump to the
|
||||
; specified function. On return, we restore the stack pointer
|
||||
; to its original location.
|
||||
;
|
||||
; Destroys no working registers.
|
||||
;****************************************************************************
|
||||
; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
|
||||
EbcLLCALLEXNative PROC PUBLIC
|
||||
push ebp
|
||||
push ebx
|
||||
mov ebp, esp ; standard function prolog
|
||||
|
||||
; Get function address in a register
|
||||
; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]
|
||||
mov ecx, dword ptr [esp + 0Ch]
|
||||
|
||||
; Set stack pointer to new value
|
||||
; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]
|
||||
mov eax, dword ptr [esp + 14h]
|
||||
mov edx, dword ptr [esp + 10h]
|
||||
sub eax, edx
|
||||
sub esp, eax
|
||||
mov ebx, esp
|
||||
push ecx
|
||||
push eax
|
||||
push edx
|
||||
push ebx
|
||||
call CopyMem
|
||||
pop eax
|
||||
pop eax
|
||||
pop eax
|
||||
pop ecx
|
||||
|
||||
; Now call the external routine
|
||||
call ecx
|
||||
|
||||
; ebp is preserved by the callee. In this function it
|
||||
; equals the original esp, so set them equal
|
||||
mov esp, ebp
|
||||
|
||||
; Standard function epilog
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
EbcLLCALLEXNative ENDP
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLEbcInterpret
|
||||
;
|
||||
; Begin executing an EBC image.
|
||||
;****************************************************************************
|
||||
; UINT64 EbcLLEbcInterpret(VOID)
|
||||
EbcLLEbcInterpret PROC PUBLIC
|
||||
;
|
||||
;; mov eax, 0xca112ebc
|
||||
;; mov eax, EbcEntryPoint
|
||||
;; mov ecx, EbcLLEbcInterpret
|
||||
;; jmp ecx
|
||||
;
|
||||
; Caller uses above instruction to jump here
|
||||
; The stack is below:
|
||||
; +-----------+
|
||||
; | RetAddr |
|
||||
; +-----------+
|
||||
; |EntryPoint | (EAX)
|
||||
; +-----------+
|
||||
; | Arg1 | <- EDI
|
||||
; +-----------+
|
||||
; | Arg2 |
|
||||
; +-----------+
|
||||
; | ... |
|
||||
; +-----------+
|
||||
; | Arg16 |
|
||||
; +-----------+
|
||||
; | EDI |
|
||||
; +-----------+
|
||||
; | ESI |
|
||||
; +-----------+
|
||||
; | EBP | <- EBP
|
||||
; +-----------+
|
||||
; | RetAddr | <- ESP is here
|
||||
; +-----------+
|
||||
; | Arg1 | <- ESI
|
||||
; +-----------+
|
||||
; | Arg2 |
|
||||
; +-----------+
|
||||
; | ... |
|
||||
; +-----------+
|
||||
; | Arg16 |
|
||||
; +-----------+
|
||||
;
|
||||
|
||||
; Construct new stack
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
push edi
|
||||
sub esp, 40h
|
||||
push eax
|
||||
mov esi, ebp
|
||||
add esi, 8
|
||||
mov edi, esp
|
||||
add edi, 4
|
||||
mov ecx, 16
|
||||
rep movsd
|
||||
|
||||
; call C-code
|
||||
call EbcInterpret
|
||||
add esp, 44h
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
EbcLLEbcInterpret ENDP
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLExecuteEbcImageEntryPoint
|
||||
;
|
||||
; Begin executing an EBC image.
|
||||
;****************************************************************************
|
||||
; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
|
||||
EbcLLExecuteEbcImageEntryPoint PROC PUBLIC
|
||||
;
|
||||
;; mov eax, 0xca112ebc
|
||||
;; mov eax, EbcEntryPoint
|
||||
;; mov ecx, EbcLLExecuteEbcImageEntryPoint
|
||||
;; jmp ecx
|
||||
;
|
||||
; Caller uses above instruction to jump here
|
||||
; The stack is below:
|
||||
; +-----------+
|
||||
; | RetAddr |
|
||||
; +-----------+
|
||||
; |EntryPoint | (EAX)
|
||||
; +-----------+
|
||||
; |ImageHandle|
|
||||
; +-----------+
|
||||
; |SystemTable|
|
||||
; +-----------+
|
||||
; | RetAddr | <- ESP is here
|
||||
; +-----------+
|
||||
; |ImageHandle|
|
||||
; +-----------+
|
||||
; |SystemTable|
|
||||
; +-----------+
|
||||
;
|
||||
|
||||
; Construct new stack
|
||||
mov [esp - 0Ch], eax
|
||||
mov eax, [esp + 04h]
|
||||
mov [esp - 08h], eax
|
||||
mov eax, [esp + 08h]
|
||||
mov [esp - 04h], eax
|
||||
|
||||
; call C-code
|
||||
sub esp, 0Ch
|
||||
call ExecuteEbcImageEntryPoint
|
||||
add esp, 0Ch
|
||||
ret
|
||||
EbcLLExecuteEbcImageEntryPoint ENDP
|
||||
|
||||
END
|
@@ -1,147 +0,0 @@
|
||||
#/** @file
|
||||
#
|
||||
# This code provides low level routines that support the Virtual Machine
|
||||
# for option ROMs.
|
||||
#
|
||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#**/
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Equate files needed.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
ASM_GLOBAL ASM_PFX(CopyMem);
|
||||
ASM_GLOBAL ASM_PFX(EbcInterpret);
|
||||
ASM_GLOBAL ASM_PFX(ExecuteEbcImageEntryPoint);
|
||||
|
||||
#****************************************************************************
|
||||
# EbcLLCALLEX
|
||||
#
|
||||
# This function is called to execute an EBC CALLEX instruction.
|
||||
# This instruction requires that we thunk out to external native
|
||||
# code. For x64, we switch stacks, copy the arguments to the stack
|
||||
# and jump to the specified function.
|
||||
# On return, we restore the stack pointer to its original location.
|
||||
#
|
||||
# Destroys no working registers.
|
||||
#****************************************************************************
|
||||
# VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
|
||||
ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative);
|
||||
ASM_PFX(EbcLLCALLEXNative):
|
||||
push %rbp
|
||||
push %rbx
|
||||
mov %rsp, %rbp
|
||||
# Function prolog
|
||||
|
||||
# Copy FuncAddr to a preserved register.
|
||||
mov %rcx, %rbx
|
||||
|
||||
# Set stack pointer to new value
|
||||
sub %rdx, %r8
|
||||
|
||||
#
|
||||
# Fix X64 native function call prolog. Prepare space for at least 4 arguments,
|
||||
# even if the native function's arguments are less than 4.
|
||||
#
|
||||
# From MSDN x64 Software Conventions, Overview of x64 Calling Conventions:
|
||||
# "The caller is responsible for allocating space for parameters to the
|
||||
# callee, and must always allocate sufficient space for the 4 register
|
||||
# parameters, even if the callee doesn't have that many parameters.
|
||||
# This aids in the simplicity of supporting C unprototyped functions,
|
||||
# and vararg C/C++ functions."
|
||||
#
|
||||
cmp $0x20, %r8
|
||||
jae skip_expansion
|
||||
mov $0x20, %r8
|
||||
skip_expansion:
|
||||
|
||||
sub %r8, %rsp
|
||||
|
||||
#
|
||||
# Fix X64 native function call 16-byte alignment.
|
||||
#
|
||||
# From MSDN x64 Software Conventions, Stack Usage:
|
||||
# "The stack will always be maintained 16-byte aligned, except within
|
||||
# the prolog (for example, after the return address is pushed)."
|
||||
#
|
||||
and $0xFFFFFFFFFFFFFFF0, %rsp
|
||||
|
||||
mov %rsp, %rcx
|
||||
sub $0x20, %rsp
|
||||
call ASM_PFX(CopyMem)
|
||||
add $0x20, %rsp
|
||||
|
||||
# Considering the worst case, load 4 potiential arguments
|
||||
# into registers.
|
||||
mov (%rsp), %rcx
|
||||
mov 0x8(%rsp), %rdx
|
||||
mov 0x10(%rsp), %r8
|
||||
mov 0x18(%rsp), %r9
|
||||
|
||||
# Now call the external routine
|
||||
call *%rbx
|
||||
|
||||
# Function epilog
|
||||
mov %rbp, %rsp
|
||||
pop %rbx
|
||||
pop %rbp
|
||||
ret
|
||||
|
||||
ASM_GLOBAL ASM_PFX(EbcLLEbcInterpret);
|
||||
ASM_PFX(EbcLLEbcInterpret):
|
||||
# save old parameter to stack
|
||||
mov %rcx, 0x8(%rsp)
|
||||
mov %rdx, 0x10(%rsp)
|
||||
mov %r8, 0x18(%rsp)
|
||||
mov %r9, 0x20(%rsp)
|
||||
|
||||
# Construct new stack
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
push %rsi
|
||||
push %rdi
|
||||
push %rbx
|
||||
sub $0x80, %rsp
|
||||
push %r10
|
||||
mov %rbp, %rsi
|
||||
add $0x10, %rsi
|
||||
mov %rsp, %rdi
|
||||
add $0x8, %rdi
|
||||
mov $0x10, %rcx
|
||||
rep movsq
|
||||
|
||||
# build new paramater calling convention
|
||||
mov 0x18(%rsp), %r9
|
||||
mov 0x10(%rsp), %r8
|
||||
mov 0x8(%rsp), %rdx
|
||||
mov %r10, %rcx
|
||||
|
||||
# call C-code
|
||||
call ASM_PFX(EbcInterpret)
|
||||
add $0x88, %esp
|
||||
pop %rbx
|
||||
pop %rdi
|
||||
pop %rsi
|
||||
pop %rbp
|
||||
ret
|
||||
|
||||
ASM_GLOBAL ASM_PFX(EbcLLExecuteEbcImageEntryPoint);
|
||||
ASM_PFX(EbcLLExecuteEbcImageEntryPoint):
|
||||
# build new paramater calling convention
|
||||
mov %rdx, %r8
|
||||
mov %rcx, %rdx
|
||||
mov %r10, %rcx
|
||||
|
||||
# call C-code
|
||||
sub $0x28, %rsp
|
||||
call ASM_PFX(ExecuteEbcImageEntryPoint)
|
||||
add $0x28, %rsp
|
||||
ret
|
@@ -1,246 +0,0 @@
|
||||
;/** @file
|
||||
;
|
||||
; This code provides low level routines that support the Virtual Machine.
|
||||
; for option ROMs.
|
||||
;
|
||||
; Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
; Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||
; This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;**/
|
||||
|
||||
page ,132
|
||||
title VM ASSEMBLY LANGUAGE ROUTINES
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Equate files needed.
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
.CODE
|
||||
|
||||
CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
|
||||
EbcInterpret PROTO
|
||||
ExecuteEbcImageEntryPoint PROTO
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLCALLEX
|
||||
;
|
||||
; This function is called to execute an EBC CALLEX instruction.
|
||||
; This instruction requires that we thunk out to external native
|
||||
; code. For x64, we switch stacks, copy the arguments to the stack
|
||||
; and jump to the specified function.
|
||||
; On return, we restore the stack pointer to its original location.
|
||||
;
|
||||
; Destroys no working registers.
|
||||
;****************************************************************************
|
||||
; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
|
||||
EbcLLCALLEXNative PROC PUBLIC
|
||||
push rbp
|
||||
push rbx
|
||||
mov rbp, rsp
|
||||
; Function prolog
|
||||
|
||||
; Copy FuncAddr to a preserved register.
|
||||
mov rbx, rcx
|
||||
|
||||
; Set stack pointer to new value
|
||||
sub r8, rdx
|
||||
|
||||
;
|
||||
; Fix X64 native function call prolog. Prepare space for at least 4 arguments,
|
||||
; even if the native function's arguments are less than 4.
|
||||
;
|
||||
; From MSDN x64 Software Conventions, Overview of x64 Calling Conventions:
|
||||
; "The caller is responsible for allocating space for parameters to the
|
||||
; callee, and must always allocate sufficient space for the 4 register
|
||||
; parameters, even if the callee doesn't have that many parameters.
|
||||
; This aids in the simplicity of supporting C unprototyped functions,
|
||||
; and vararg C/C++ functions."
|
||||
;
|
||||
cmp r8, 20h
|
||||
jae skip_expansion
|
||||
mov r8, 20h
|
||||
skip_expansion:
|
||||
|
||||
sub rsp, r8
|
||||
|
||||
;
|
||||
; Fix X64 native function call 16-byte alignment.
|
||||
;
|
||||
; From MSDN x64 Software Conventions, Stack Usage:
|
||||
; "The stack will always be maintained 16-byte aligned, except within
|
||||
; the prolog (for example, after the return address is pushed)."
|
||||
;
|
||||
and rsp, NOT 0fh
|
||||
|
||||
mov rcx, rsp
|
||||
sub rsp, 20h
|
||||
call CopyMem
|
||||
add rsp, 20h
|
||||
|
||||
; Considering the worst case, load 4 potiential arguments
|
||||
; into registers.
|
||||
mov rcx, qword ptr [rsp]
|
||||
mov rdx, qword ptr [rsp+8h]
|
||||
mov r8, qword ptr [rsp+10h]
|
||||
mov r9, qword ptr [rsp+18h]
|
||||
|
||||
; Now call the external routine
|
||||
call rbx
|
||||
|
||||
; Function epilog
|
||||
mov rsp, rbp
|
||||
pop rbx
|
||||
pop rbp
|
||||
ret
|
||||
EbcLLCALLEXNative ENDP
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLEbcInterpret
|
||||
;
|
||||
; Begin executing an EBC image.
|
||||
;****************************************************************************
|
||||
; UINT64 EbcLLEbcInterpret(VOID)
|
||||
EbcLLEbcInterpret PROC PUBLIC
|
||||
;
|
||||
;; mov rax, ca112ebccall2ebch
|
||||
;; mov r10, EbcEntryPoint
|
||||
;; mov r11, EbcLLEbcInterpret
|
||||
;; jmp r11
|
||||
;
|
||||
; Caller uses above instruction to jump here
|
||||
; The stack is below:
|
||||
; +-----------+
|
||||
; | RetAddr |
|
||||
; +-----------+
|
||||
; |EntryPoint | (R10)
|
||||
; +-----------+
|
||||
; | Arg1 | <- RDI
|
||||
; +-----------+
|
||||
; | Arg2 |
|
||||
; +-----------+
|
||||
; | ... |
|
||||
; +-----------+
|
||||
; | Arg16 |
|
||||
; +-----------+
|
||||
; | Dummy |
|
||||
; +-----------+
|
||||
; | RDI |
|
||||
; +-----------+
|
||||
; | RSI |
|
||||
; +-----------+
|
||||
; | RBP | <- RBP
|
||||
; +-----------+
|
||||
; | RetAddr | <- RSP is here
|
||||
; +-----------+
|
||||
; | Scratch1 | (RCX) <- RSI
|
||||
; +-----------+
|
||||
; | Scratch2 | (RDX)
|
||||
; +-----------+
|
||||
; | Scratch3 | (R8)
|
||||
; +-----------+
|
||||
; | Scratch4 | (R9)
|
||||
; +-----------+
|
||||
; | Arg5 |
|
||||
; +-----------+
|
||||
; | Arg6 |
|
||||
; +-----------+
|
||||
; | ... |
|
||||
; +-----------+
|
||||
; | Arg16 |
|
||||
; +-----------+
|
||||
;
|
||||
|
||||
; save old parameter to stack
|
||||
mov [rsp + 08h], rcx
|
||||
mov [rsp + 10h], rdx
|
||||
mov [rsp + 18h], r8
|
||||
mov [rsp + 20h], r9
|
||||
|
||||
; Construct new stack
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
push rsi
|
||||
push rdi
|
||||
push rbx
|
||||
sub rsp, 80h
|
||||
push r10
|
||||
mov rsi, rbp
|
||||
add rsi, 10h
|
||||
mov rdi, rsp
|
||||
add rdi, 8
|
||||
mov rcx, 16
|
||||
rep movsq
|
||||
|
||||
; build new paramater calling convention
|
||||
mov r9, [rsp + 18h]
|
||||
mov r8, [rsp + 10h]
|
||||
mov rdx, [rsp + 08h]
|
||||
mov rcx, r10
|
||||
|
||||
; call C-code
|
||||
call EbcInterpret
|
||||
add rsp, 88h
|
||||
pop rbx
|
||||
pop rdi
|
||||
pop rsi
|
||||
pop rbp
|
||||
ret
|
||||
EbcLLEbcInterpret ENDP
|
||||
|
||||
;****************************************************************************
|
||||
; EbcLLExecuteEbcImageEntryPoint
|
||||
;
|
||||
; Begin executing an EBC image.
|
||||
;****************************************************************************
|
||||
; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
|
||||
EbcLLExecuteEbcImageEntryPoint PROC PUBLIC
|
||||
;
|
||||
;; mov rax, ca112ebccall2ebch
|
||||
;; mov r10, EbcEntryPoint
|
||||
;; mov r11, EbcLLExecuteEbcImageEntryPoint
|
||||
;; jmp r11
|
||||
;
|
||||
; Caller uses above instruction to jump here
|
||||
; The stack is below:
|
||||
; +-----------+
|
||||
; | RetAddr |
|
||||
; +-----------+
|
||||
; |EntryPoint | (R10)
|
||||
; +-----------+
|
||||
; |ImageHandle|
|
||||
; +-----------+
|
||||
; |SystemTable|
|
||||
; +-----------+
|
||||
; | Dummy |
|
||||
; +-----------+
|
||||
; | Dummy |
|
||||
; +-----------+
|
||||
; | RetAddr | <- RSP is here
|
||||
; +-----------+
|
||||
; |ImageHandle| (RCX)
|
||||
; +-----------+
|
||||
; |SystemTable| (RDX)
|
||||
; +-----------+
|
||||
;
|
||||
|
||||
; build new paramater calling convention
|
||||
mov r8, rdx
|
||||
mov rdx, rcx
|
||||
mov rcx, r10
|
||||
|
||||
; call C-code
|
||||
sub rsp, 28h
|
||||
call ExecuteEbcImageEntryPoint
|
||||
add rsp, 28h
|
||||
ret
|
||||
EbcLLExecuteEbcImageEntryPoint ENDP
|
||||
|
||||
END
|
||||
|
Reference in New Issue
Block a user