]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add .S file for GCC tool-chain for PeiLib.
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Aug 2008 08:44:32 +0000 (08:44 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 28 Aug 2008 08:44:32 +0000 (08:44 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5749 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib_Edk2.inf
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.S [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.S [new file with mode: 0644]

index 41f41cedbbf56706f460b154c1a0db55dfb1af25..892bc19c2420cc3b6e58c152b40706c2fdbac37c 100644 (file)
@@ -62,8 +62,10 @@ COMPONENT_TYPE    = LIBRARY
   x64/Processor.c\r
   x64/ProcessorAsms.Asm          |MSFT\r
   x64/ProcessorAsms.Asm          |INTEL\r
+  x64/ProcessorAsms.S            |GCC\r
   x64/SupportItpDebug.asm        |MSFT\r
   x64/SupportItpDebug.asm        |INTEL\r
+  x64/SupportItpDebug.S          |GCC\r
   x64/EfiJump.h\r
   x64/PeiServicePointer.c\r
 \r
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.S b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.S
new file mode 100644 (file)
index 0000000..2767aef
--- /dev/null
@@ -0,0 +1,135 @@
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2008, Intel Corporation                                                         
+# All rights reserved. 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.             
+# 
+# Module Name:
+#   ProcessorAsms.S
+#
+# Abstract:
+#   This is separated from processor.c to allow this functions to be built with /O1
+#
+#
+#------------------------------------------------------------------------------
+#include <EfiBind.h>
+
+    .text
+
+.global ASM_PFX(SwitchStacks)
+.global ASM_PFX(TransferControlSetJump)
+.global ASM_PFX(TransferControlLongJump)
+
+#
+# Routine Description:
+#   This allows the caller to switch the stack and goes to the new entry point
+#
+# Arguments:
+#   EntryPoint      - Pointer to the location to enter // rcx
+#   Parameter       - Parameter to pass in             // rdx
+#   NewStack        - New Location of the stack        // r8
+#   NewBsp          - New BSP                          // r9 - not used
+#
+# Returns:
+#   Nothing. Goes to the Entry Point passing in the new parameters
+#
+ASM_PFX(SwitchStacks):
+
+    # Adjust stack for
+    #   1) leave 4 registers space
+    #   2) let it 16 bytes aligned after call
+    sub    $0x20,%r8
+    and    -0x10,%r8w   # do not assume 16 bytes aligned
+
+       mov    %r8,%rsp
+       mov    %rcx,%r10
+       mov    %rdx,%rcx
+       callq  *%r10
+
+ #
+ # no ret as we have a new stack and we jumped to the new location
+ #     
+    ret
+
+#SwitchStacks ENDP
+
+
+.equ                            EFI_SUCCESS, 0
+.equ                            EFI_WARN_RETURN_FROM_LONG_JUMP, 5
+
+#
+#Routine Description:
+#
+#  This routine implements the x64 variant of the SetJump call.  Its
+#  responsibility is to store system state information for a possible
+#  subsequent LongJump.
+#
+#Arguments:
+#
+#  Pointer to CPU context save buffer.
+#
+#Returns:
+#
+#  EFI_SUCCESS
+#
+# EFI_STATUS
+# EFIAPI
+# TransferControlLongJump (
+#   IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,
+#   IN EFI_JUMP_BUFFER                    *Jump
+#   );
+#
+# rcx - *This
+# rdx - JumpBuffer
+#
+ASM_PFX(TransferControlSetJump):
+      mov    %rbx,(%rdx)
+      mov    %rsp,0x8(%rdx)
+      mov    %rbp,0x10(%rdx)
+      mov    %rdi,0x18(%rdx)
+      mov    %rsi,0x20(%rdx)
+      mov    %r10,0x28(%rdx)
+      mov    %r11,0x30(%rdx)
+      mov    %r12,0x38(%rdx)
+      mov    %r13,0x40(%rdx)
+      mov    %r14,0x48(%rdx)
+      mov    %r15,0x50(%rdx)
+      mov    (%rsp),%rax
+      mov    %rax,0x58(%rdx)
+      mov    $0x0,%rax
+      retq   
+
+
+#
+# EFI_STATUS
+# EFIAPI
+# TransferControlLongJump (
+#   IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL  *This,  // rcx
+#   IN EFI_JUMP_BUFFER                    *Jump   // rdx
+#   );
+#
+#
+ASM_PFX(TransferControlLongJump):
+  # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+      mov    $0x5,%rax
+      mov    (%rdx),%rbx
+      mov    0x8(%rdx),%rsp
+      mov    0x10(%rdx),%rbp
+      mov    0x18(%rdx),%rdi
+      mov    0x20(%rdx),%rsi
+      mov    0x28(%rdx),%r10
+      mov    0x30(%rdx),%r11
+      mov    0x38(%rdx),%r12
+      mov    0x40(%rdx),%r13
+      mov    0x48(%rdx),%r14
+      mov    0x50(%rdx),%r15
+      add    $0x8,%rsp
+      jmpq   *0x58(%rdx)
+      mov    $0x5,%rax
+      retq   
+
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.S b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/x64/SupportItpDebug.S
new file mode 100644 (file)
index 0000000..4be5b1f
--- /dev/null
@@ -0,0 +1,78 @@
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2008, Intel Corporation                                                         
+# All rights reserved. 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.     
+#
+# Module Name:
+#
+#   SupportItpDebug.S
+# 
+# Abstract:
+# 
+#   This is the code for debuging X64, to add a break hook at loading every module
+#
+#------------------------------------------------------------------------------
+#include <EfiBind.h>
+
+  .text
+
+.global ASM_PFX(AsmEfiSetBreakSupport)
+
+#------------------------------------------------------------------------------
+#  VOID
+#  AsmEfiSetBreakSupport (
+#    IN UINTN  LoadAddr    // rcx
+#    )
+#------------------------------------------------------------------------------
+
+ASM_PFX(AsmEfiSetBreakSupport):
+
+    movw $60000, %dx
+    outl %eax, %dx
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    ret
+
+
+
+