]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/SetJump.c
MdePkg/BaseLib: Support IA32 processors without CLFLUSH
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / SetJump.c
CommitLineData
e1f414b6 1/** @file\r
2 Implementation of SetJump() on IA-32.\r
3\r
bb817c56
HT
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
e1f414b6 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
e4a34497 8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
1efcc4ae 15\r
47fc17d8 16#include "BaseLibInternals.h"\r
f734a10a 17\r
42eedea9 18/**\r
19 Worker function that checks ASSERT condition for JumpBuffer\r
e1f414b6 20\r
42eedea9 21 Checks ASSERT condition for JumpBuffer.\r
22\r
23 If JumpBuffer is NULL, then ASSERT().\r
24 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
25\r
26 @param JumpBuffer A pointer to CPU context buffer.\r
27\r
28**/\r
e1f414b6 29VOID\r
30EFIAPI\r
31InternalAssertJumpBuffer (\r
32 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
33 );\r
34\r
42eedea9 35/**\r
36 Saves the current CPU context that can be restored with a call to LongJump()\r
37 and returns 0.\r
38\r
39 Saves the current CPU context in the buffer specified by JumpBuffer and\r
40 returns 0. The initial call to SetJump() must always return 0. Subsequent\r
41 calls to LongJump() cause a non-zero value to be returned by SetJump().\r
42\r
43 If JumpBuffer is NULL, then ASSERT().\r
44 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
45\r
46 @param JumpBuffer A pointer to CPU context buffer.\r
47\r
48 @retval 0 Indicates a return from SetJump().\r
49\r
50**/\r
e1f414b6 51_declspec (naked)\r
52UINTN\r
53EFIAPI\r
54SetJump (\r
55 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
56 )\r
57{\r
58 _asm {\r
59 push [esp + 4]\r
60 call InternalAssertJumpBuffer\r
61 pop ecx\r
62 pop ecx\r
63 mov edx, [esp]\r
64 mov [edx], ebx\r
65 mov [edx + 4], esi\r
66 mov [edx + 8], edi\r
67 mov [edx + 12], ebp\r
68 mov [edx + 16], esp\r
69 mov [edx + 20], ecx\r
70 xor eax, eax\r
71 jmp ecx\r
72 }\r
73}\r
74\r