]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Cpu.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / Cpu.c
1 /** @file
2 Base Library CPU Functions for all architectures.
3
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "BaseLibInternals.h"
10
11 /**
12 Disables CPU interrupts and returns the interrupt state prior to the disable
13 operation.
14
15 @retval TRUE CPU interrupts were enabled on entry to this call.
16 @retval FALSE CPU interrupts were disabled on entry to this call.
17
18 **/
19 BOOLEAN
20 EFIAPI
21 SaveAndDisableInterrupts (
22 VOID
23 )
24 {
25 BOOLEAN InterruptState;
26
27 InterruptState = GetInterruptState ();
28 DisableInterrupts ();
29 return InterruptState;
30 }
31
32 /**
33 Set the current CPU interrupt state.
34
35 Sets the current CPU interrupt state to the state specified by
36 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
37 InterruptState is FALSE, then interrupts are disabled. InterruptState is
38 returned.
39
40 @param InterruptState TRUE if interrupts should be enabled. FALSE if
41 interrupts should be disabled.
42
43 @return InterruptState
44
45 **/
46 BOOLEAN
47 EFIAPI
48 SetInterruptState (
49 IN BOOLEAN InterruptState
50 )
51 {
52 if (InterruptState) {
53 EnableInterrupts ();
54 } else {
55 DisableInterrupts ();
56 }
57
58 return InterruptState;
59 }