1 /** @file 2 Base Library CPU Functions for all architectures. 3 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 5 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 #include "BaseLibInternals.h" 16 17 18 /** 19 Disables CPU interrupts and returns the interrupt state prior to the disable 20 operation. 21 22 @retval TRUE CPU interrupts were enabled on entry to this call. 23 @retval FALSE CPU interrupts were disabled on entry to this call. 24 25 **/ 26 BOOLEAN 27 EFIAPI SaveAndDisableInterrupts(VOID)28SaveAndDisableInterrupts ( 29 VOID 30 ) 31 { 32 BOOLEAN InterruptState; 33 34 InterruptState = GetInterruptState (); 35 DisableInterrupts (); 36 return InterruptState; 37 } 38 39 /** 40 Set the current CPU interrupt state. 41 42 Sets the current CPU interrupt state to the state specified by 43 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If 44 InterruptState is FALSE, then interrupts are disabled. InterruptState is 45 returned. 46 47 @param InterruptState TRUE if interrupts should be enabled. FALSE if 48 interrupts should be disabled. 49 50 @return InterruptState 51 52 **/ 53 BOOLEAN 54 EFIAPI SetInterruptState(IN BOOLEAN InterruptState)55SetInterruptState ( 56 IN BOOLEAN InterruptState 57 ) 58 { 59 if (InterruptState) { 60 EnableInterrupts (); 61 } else { 62 DisableInterrupts (); 63 } 64 return InterruptState; 65 } 66