]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Cpu.c
Removed MdePkg usage of ModuleName: in file headers
[mirror_edk2.git] / MdePkg / Library / BaseLib / Cpu.c
1 /** @file
2 Base Library CPU Functions for all architectures.
3
4 Copyright (c) 2006, 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 common header file for this module.
17 //
18 #include <BaseLibInternals.h>
19
20
21 /**
22 Disables CPU interrupts and returns the interrupt state prior to the disable
23 operation.
24
25 Disables CPU interrupts and returns the interrupt state prior to the disable
26 operation.
27
28 @retval TRUE CPU interrupts were enabled on entry to this call.
29 @retval FALSE CPU interrupts were disabled on entry to this call.
30
31 **/
32 BOOLEAN
33 EFIAPI
34 SaveAndDisableInterrupts (
35 VOID
36 )
37 {
38 BOOLEAN InterruptState;
39
40 InterruptState = GetInterruptState ();
41 DisableInterrupts ();
42 return InterruptState;
43 }
44
45 /**
46 Set the current CPU interrupt state.
47
48 Sets the current CPU interrupt state to the state specified by
49 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
50 InterruptState is FALSE, then interrupts are disabled. InterruptState is
51 returned.
52
53 @param InterruptState TRUE if interrupts should enabled. FALSE if
54 interrupts should be disabled.
55
56 @return InterruptState
57
58 **/
59 BOOLEAN
60 EFIAPI
61 SetInterruptState (
62 IN BOOLEAN InterruptState
63 )
64 {
65 if (InterruptState) {
66 EnableInterrupts ();
67 } else {
68 DisableInterrupts ();
69 }
70 return InterruptState;
71 }