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