]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added AsmSwitchStackAndBackingStore() to BaseLib.h for stack switching on IPF.
authorbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 05:32:47 +0000 (05:32 +0000)
committerbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 05:32:47 +0000 (05:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1305 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/BaseLib.h
MdePkg/Library/BaseLib/Ipf/SwitchStack.s

index 6a43c164547a73c40c493d716cfe059fddbe3b6b..c1d1fa09006734c9adb760b3a036b2918700096a 100644 (file)
@@ -2475,9 +2475,9 @@ InterlockedDecrement (
   Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r
 \r
   Performs an atomic compare exchange operation on the 32-bit unsigned integer\r
-  specified by Value.  If Value is equal to CompareValue, then Value is set to \r
+  specified by Value.  If Value is equal to CompareValue, then Value is set to\r
   ExchangeValue and CompareValue is returned.  If Value is not equal to CompareValue,\r
-  then Value is returned.  The compare exchange operation must be performed using \r
+  then Value is returned.  The compare exchange operation must be performed using\r
   MP safe mechanisms.\r
 \r
   If Value is NULL, then ASSERT().\r
@@ -2501,9 +2501,9 @@ InterlockedCompareExchange32 (
 /**\r
   Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
 \r
-  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified \r
-  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and \r
-  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned. \r
+  Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
+  by Value.  If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
+  CompareValue is returned.  If Value is not equal to CompareValue, then Value is returned.\r
   The compare exchange operation must be performed using MP safe mechanisms.\r
 \r
   If Value is NULL, then ASSERT().\r
@@ -4987,4 +4987,36 @@ AsmPrepareAndThunk16 (
   IN OUT  THUNK_CONTEXT             *ThunkContext\r
   );\r
 \r
+/**\r
+  Transfers control to a function starting with a new stack.\r
+\r
+  Transfers control to the function specified by EntryPoint using the new stack\r
+  specified by NewStack and passing in the parameters specified by Context1 and\r
+  Context2. Context1 and Context2 are optional and may be NULL. The function\r
+  EntryPoint must never return.\r
+\r
+  If EntryPoint is NULL, then ASSERT().\r
+  If NewStack is NULL, then ASSERT().\r
+\r
+  @param  EntryPoint  A pointer to function to call with the new stack.\r
+  @param  Context1    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  Context2    A pointer to the context to pass into the EntryPoint\r
+                      function.\r
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint\r
+                      function.\r
+  @param  NewBsp      A pointer to the new memory location for RSE backing\r
+                      store.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmSwitchStackAndBackingStore (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack,\r
+  IN      VOID                      *NewBsp\r
+  );\r
+\r
 #endif\r
index 58fe43d87f23c5deb44f6daae27a2ac4c91d3288..a3c524f1191d287886e164371fa51ceb6ae680db 100644 (file)
-//++\r
-// Copyright (c) 2006, Intel Corporation                                                         \r
-// All rights reserved. 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
-//  Contains an implementation of a stack switch for the Itanium-based architecture.\r
-//\r
-//\r
-//\r
-// Revision History:\r
-//\r
-//--\r
-\r
-  .file  "SwitchStack.s"\r
-\r
-#include  "asm.h"\r
-#include  "ia_64gen.h"\r
-\r
-// Define hardware RSE Configuration Register\r
-//\r
-// RS Configuration (RSC) bit field positions\r
-\r
-#define RSC_MODE       0\r
-#define RSC_PL         2\r
-#define RSC_BE         4\r
-// RSC bits 5-15 reserved\r
-#define RSC_MBZ0       5\r
-#define RSC_MBZ0_V     0x3ff\r
-#define RSC_LOADRS     16\r
-#define RSC_LOADRS_LEN 14\r
-// RSC bits 30-63 reserved\r
-#define RSC_MBZ1       30\r
-#define RSC_MBZ1_V     0x3ffffffffULL\r
-\r
-// RSC modes\r
-// Lazy\r
-#define RSC_MODE_LY (0x0)\r
-// Store intensive\r
-#define RSC_MODE_SI (0x1)\r
-// Load intensive\r
-#define RSC_MODE_LI (0x2)\r
-// Eager\r
-#define RSC_MODE_EA (0x3)\r
-\r
-// RSC Endian bit values\r
-#define RSC_BE_LITTLE 0\r
-#define RSC_BE_BIG    1\r
-\r
-// RSC while in kernel: enabled, little endian, pl = 0, eager mode\r
-#define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
-// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode\r
-#define RSC_KERNEL_LAZ ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
-// RSE disabled: disabled, pl = 0, little endian, eager mode\r
-#define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))\r
-\r
-\r
-//VOID\r
-//InternalSwitchStack (\r
-//    VOID    *ContinuationFunction,\r
-//    UINTN   Parameter,\r
-//    UINTN   NewTopOfStack,\r
-//    UINTN   NewBSPStore OPTIONAL\r
-//)\r
-///*++\r
-//\r
-//Input Arguments\r
-//\r
-//  ContinuationFunction - This is a pointer to the PLABEL of the function that should  be called once the\r
-//        new stack has been created.  \r
-//  Parameter - The parameter to pass to the continuation function\r
-//  NewTopOfStack - This is the new top of the memory stack for ensuing code.  This is mandatory and\r
-//      should be non-zero\r
-//  NewBSPStore - This is the new BSP store for the ensuing code.  It is optional on IA-32 and mandatory on Itanium-based platform.\r
-//\r
-//--*/\r
-\r
-PROCEDURE_ENTRY(InternalSwitchStack)\r
-\r
-        mov        r16 = -0x10;;\r
-        and        r16 = r34, r16;;             // get new stack value in R16, 0 the last nibble.\r
-        mov        r15 = r35;;                  // Get new BspStore into R15\r
-        mov        r13 = r32;;                  // this is a pointer to the PLABEL of the continuation function.  \r
-        mov        r17 = r33;;                  // this is the parameter to pass to the continuation function\r
-\r
-        alloc       r11=0,0,0,0                 // Set 0-size frame\r
-        ;;\r
-        flushrs;;\r
-\r
-        mov         r21 = RSC_KERNEL_DISABLED   // for rse disable             \r
-        ;;\r
-        mov         ar.rsc = r21                // turn off RSE                \r
-\r
-        add         sp = r0, r16;;              // transfer to the EFI stack\r
-        mov         ar.bspstore = r15           // switch to EFI BSP        \r
-        invala                                  // change of ar.bspstore needs invala.     \r
-      \r
-        mov         r18 = RSC_KERNEL_LAZ        // RSC enabled, Lazy mode\r
-        ;;\r
-        mov         ar.rsc = r18                // turn rse on, in kernel mode     \r
-        ;;        \r
-        alloc       r11=0,0,1,0;;               // alloc 0 outs going to ensuing DXE IPL service\r
-        mov         out0 = r17\r
-        ld8         r16 = [r13],8;;             // r16 = address of continuation function from the PLABEL\r
-        ld8         gp = [r13]                  // gp  = gp of continuation function from the PLABEL\r
-        mov         b6 = r16\r
-        ;;\r
-        br.call.sptk.few b0=b6;;                // Call the continuation function\r
-        ;;\r
-PROCEDURE_EXIT(InternalSwitchStack)\r
-\r
-\r
+/// @file\r
+///  IPF specific SwitchStack() function\r
+///\r
+/// Copyright (c) 2006, Intel Corporation\r
+/// All rights reserved. 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: SwitchStack.s\r
+///\r
+///\r
+\r
+.auto\r
+.text\r
+\r
+.proc   AsmSwitchStackAndBackingStore\r
+.type   AsmSwitchStackAndBackingStore, @function\r
+.regstk 5, 0, 0, 0\r
+AsmSwitchStackAndBackingStore::\r
+        mov                 r14 = ar.rsc\r
+        movl                r2  = ~((((1 << 14) - 1) << 16) | 3)\r
+\r
+        mov                 r17 = in1\r
+        mov                 r18 = in2\r
+        and                 r2  = r14, r2\r
+\r
+        mov                 ar.rsc = r2\r
+        mov                 sp  = in3\r
+        mov                 r19 = in4\r
+\r
+        ld8.nt1             r16 = [in0], 8\r
+        ld8.nta             gp  = [in0]\r
+        mov                 r3  = -1\r
+\r
+        loadrs\r
+        mov                 ar.bspstore = r19\r
+        mov                 b7  = r16\r
+\r
+        alloc               r2  = ar.pfs, 0, 0, 2, 0\r
+        mov                 out0 = r17\r
+        mov                 out1 = r18\r
+\r
+        mov                 ar.rnat = r3\r
+        mov                 ar.rsc = r14\r
+        br.call.sptk.many   b0  = b7\r
+.endp   AsmSwitchStackAndBackingStore\r