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