diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-06-02 07:58:31 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-06-02 07:58:31 +0000 |
commit | 7d7c2b4640a6b46eed90af5777f8d22504519a8e (patch) | |
tree | 9c0a04ff526f8204c6977720cea02847871fec41 /MdePkg/Library/BaseLib | |
parent | 6fc80a45b523d64f078f3d42f0994a36c02b8786 (diff) | |
download | edk2-platforms-7d7c2b4640a6b46eed90af5777f8d22504519a8e.tar.xz |
Deleted x64\SwitchStack.c Ipf/SwitchStack.c.
Added SwitchStack.c in Baselib\
Rename Ia32/SwitchStack.c to Ia32/InternalSwitchStack.c
Changed _SwitchStack() into InternalSwitchStack() in SwitchStack.asm and SwitchStack.s
Fixed one bug in LinkedList.c, that List length couldn't up to PcdMaximumLinkedListLength.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@394 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib')
-rw-r--r-- | MdePkg/Library/BaseLib/BaseLib-Gcc.msa | 7 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/BaseLib.msa | 7 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/BaseLibInternals.h | 9 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ia32/InternalSwitchStack.c | 52 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ipf/SwitchStack.s | 6 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/LinkedList.c | 5 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/SwitchStack.c | 51 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/X64/SwitchStack.asm | 4 |
8 files changed, 130 insertions, 11 deletions
diff --git a/MdePkg/Library/BaseLib/BaseLib-Gcc.msa b/MdePkg/Library/BaseLib/BaseLib-Gcc.msa index 8246375b05..1957312501 100644 --- a/MdePkg/Library/BaseLib/BaseLib-Gcc.msa +++ b/MdePkg/Library/BaseLib/BaseLib-Gcc.msa @@ -73,6 +73,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename>x86Thunk.c</Filename>
<Filename>Unaligned.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>Ia32/Non-existing.c</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/LShiftU64.s</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/RShiftU64.s</Filename>
@@ -89,7 +90,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename FileType="GCC_Assembly_Code">Ia32/SwapBytes64.s</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/SetJump.s</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/LongJump.s</Filename>
- <Filename>Ia32/SwitchStack.c</Filename>
+ <Filename>Ia32/InternalSwitchStack.c</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/CpuId.s</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/ReadEflags.s</Filename>
<Filename FileType="GCC_Assembly_Code">Ia32/ReadMsr64.s</Filename>
@@ -179,8 +180,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename>Unaligned.c</Filename>
<Filename>Math64.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>x64/Non-existing.c</Filename>
- <Filename>x64/SwitchStack.c</Filename>
<Filename>x64/SwitchStack.asm</Filename>
<Filename>x64/SetJump.asm</Filename>
<Filename>x64/LongJump.asm</Filename>
@@ -269,9 +270,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Arch ArchType="IPF">
<Filename>Math64.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>Ipf/setjmp.s</Filename>
<Filename>Ipf/SwitchStack.s</Filename>
- <Filename>x64/SwitchStack.c</Filename>
<Filename>Ipf/Unaligned.c</Filename>
<Filename>Ipf/CpuBreakpoint.c</Filename>
<Filename>Ipf/InterlockedCompareExchange32.s</Filename>
diff --git a/MdePkg/Library/BaseLib/BaseLib.msa b/MdePkg/Library/BaseLib/BaseLib.msa index afcfa754f3..4f50169550 100644 --- a/MdePkg/Library/BaseLib/BaseLib.msa +++ b/MdePkg/Library/BaseLib/BaseLib.msa @@ -73,7 +73,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename>x86Thunk.c</Filename>
<Filename>Unaligned.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>Ia32/Non-existing.c</Filename>
+ <Filename>Ia32/InternalSwitchStack.c</Filename>
<Filename>Ia32/LShiftU64.asm</Filename>
<Filename>Ia32/RShiftU64.asm</Filename>
<Filename>Ia32/ARShiftU64.asm</Filename>
@@ -89,7 +91,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename>Ia32/SwapBytes64.asm</Filename>
<Filename>Ia32/SetJump.asm</Filename>
<Filename>Ia32/LongJump.asm</Filename>
- <Filename>Ia32/SwitchStack.c</Filename>
<Filename>Ia32/CpuId.asm</Filename>
<Filename>Ia32/ReadEflags.asm</Filename>
<Filename>Ia32/ReadMsr64.asm</Filename>
@@ -179,8 +180,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Filename>Unaligned.c</Filename>
<Filename>Math64.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>x64/Non-existing.c</Filename>
- <Filename>x64/SwitchStack.c</Filename>
<Filename>x64/SwitchStack.asm</Filename>
<Filename>x64/SetJump.asm</Filename>
<Filename>x64/LongJump.asm</Filename>
@@ -269,9 +270,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. <Arch ArchType="IPF">
<Filename>Math64.c</Filename>
<Filename>LongJump.c</Filename>
+ <Filename>SwitchStack.c</Filename>
<Filename>Ipf/PalCallStatic.s</Filename>
<Filename>Ipf/setjmp.s</Filename>
- <Filename>x64/SwitchStack.c</Filename>
<Filename>Ipf/SwitchStack.s</Filename>
<Filename>Ipf/Unaligned.c</Filename>
<Filename>Ipf/CpuBreakpoint.c</Filename>
diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h b/MdePkg/Library/BaseLib/BaseLibInternals.h index 4cccdae528..0c32e1bd2c 100644 --- a/MdePkg/Library/BaseLib/BaseLibInternals.h +++ b/MdePkg/Library/BaseLib/BaseLibInternals.h @@ -114,6 +114,15 @@ InternalMathDivRemS64x64 ( OUT INT64 *Remainder
);
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ );
+
//
// Ia32 and x64 specific functions
//
diff --git a/MdePkg/Library/BaseLib/Ia32/InternalSwitchStack.c b/MdePkg/Library/BaseLib/Ia32/InternalSwitchStack.c new file mode 100644 index 0000000000..ab8116b4b5 --- /dev/null +++ b/MdePkg/Library/BaseLib/Ia32/InternalSwitchStack.c @@ -0,0 +1,52 @@ +/** @file
+ SwitchStack() function for IA-32.
+
+ Copyright (c) 2006, Intel Corporation<BR>
+ 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: InternalSwitchStack.c
+
+**/
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ )
+{
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
+
+ JumpBuffer.Eip = (UINTN)EntryPoint;
+ JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+ JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
+ ((VOID**)JumpBuffer.Esp)[1] = Context1;
+ ((VOID**)JumpBuffer.Esp)[2] = Context2;
+
+ LongJump (&JumpBuffer, (UINTN)-1);
+}
diff --git a/MdePkg/Library/BaseLib/Ipf/SwitchStack.s b/MdePkg/Library/BaseLib/Ipf/SwitchStack.s index 16358add22..58fe43d87f 100644 --- a/MdePkg/Library/BaseLib/Ipf/SwitchStack.s +++ b/MdePkg/Library/BaseLib/Ipf/SwitchStack.s @@ -66,7 +66,7 @@ //VOID
-//_SwitchStack (
+//InternalSwitchStack (
// VOID *ContinuationFunction,
// UINTN Parameter,
// UINTN NewTopOfStack,
@@ -85,7 +85,7 @@ //
//--*/
-PROCEDURE_ENTRY(_SwitchStack)
+PROCEDURE_ENTRY(InternalSwitchStack)
mov r16 = -0x10;;
and r16 = r34, r16;; // get new stack value in R16, 0 the last nibble.
@@ -117,6 +117,6 @@ PROCEDURE_ENTRY(_SwitchStack) ;;
br.call.sptk.few b0=b6;; // Call the continuation function
;;
-PROCEDURE_EXIT(_SwitchStack)
+PROCEDURE_EXIT(InternalSwitchStack)
diff --git a/MdePkg/Library/BaseLib/LinkedList.c b/MdePkg/Library/BaseLib/LinkedList.c index 0f42749775..9ad1b0875b 100644 --- a/MdePkg/Library/BaseLib/LinkedList.c +++ b/MdePkg/Library/BaseLib/LinkedList.c @@ -34,6 +34,10 @@ IsNodeInList ( ASSERT (Node != NULL);
Count = FixedPcdGet32 (PcdMaximumLinkedListLength);
+ if (Count != 0) {
+ Count++;
+ }
+
Ptr = List;
do {
Ptr = Ptr->ForwardLink;
@@ -44,6 +48,7 @@ IsNodeInList ( if (FixedPcdGet32 (PcdMaximumLinkedListLength) > 0) {
while ((Count > 0) && (Ptr != List)) {
Ptr = Ptr->ForwardLink;
+ Count--;
}
ASSERT (Count > 0);
}
diff --git a/MdePkg/Library/BaseLib/SwitchStack.c b/MdePkg/Library/BaseLib/SwitchStack.c new file mode 100644 index 0000000000..fec3cfaa60 --- /dev/null +++ b/MdePkg/Library/BaseLib/SwitchStack.c @@ -0,0 +1,51 @@ +/** @file
+ Switch Stack functions.
+
+ Copyright (c) 2006, Intel Corporation<BR>
+ 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: SwitchStack.c
+
+**/
+
+#include <BaseLibInternals.h>
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+SwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ )
+{
+ ASSERT (EntryPoint != NULL && NewStack != NULL);
+
+ InternalSwitchStack (EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/MdePkg/Library/BaseLib/X64/SwitchStack.asm b/MdePkg/Library/BaseLib/X64/SwitchStack.asm index a1304ca295..53d1417f0b 100644 --- a/MdePkg/Library/BaseLib/X64/SwitchStack.asm +++ b/MdePkg/Library/BaseLib/X64/SwitchStack.asm @@ -36,12 +36,12 @@ ; None
;
;------------------------------------------------------------------------------
-_SwitchStack PROC
+InternalSwitchStack PROC
mov rax, rcx
mov rcx, rdx
mov rdx, r8
lea rsp, [r9 - 20h]
call rax
-_SwitchStack ENDP
+InternalSwitchStack ENDP
END
|