lock.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. lock.h
  9. Abstract:
  10. This header contains definitions for EFI "lock" functions.
  11. Author:
  12. Evan Green 5-Mar-2014
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // ------------------------------------------------------ Data Type Definitions
  22. //
  23. typedef enum _EFI_LOCK_STATE {
  24. EfiLockUninitialized,
  25. EfiLockReleased,
  26. EfiLockAcquired
  27. } EFI_LOCK_STATE, *PEFI_LOCK_STATE;
  28. typedef struct _EFI_LOCK {
  29. EFI_TPL Tpl;
  30. EFI_TPL OwnerTpl;
  31. EFI_LOCK_STATE State;
  32. } EFI_LOCK, *PEFI_LOCK;
  33. //
  34. // -------------------------------------------------------------------- Globals
  35. //
  36. //
  37. // -------------------------------------------------------- Function Prototypes
  38. //
  39. VOID
  40. EfiCoreInitializeLock (
  41. PEFI_LOCK Lock,
  42. EFI_TPL Tpl
  43. );
  44. /*++
  45. Routine Description:
  46. This routine initializes an EFI lock.
  47. Arguments:
  48. Lock - Supplies a pointer to the lock to initialize.
  49. Tpl - Supplies the Task Prioriry Level the lock is acquired at.
  50. Return Value:
  51. None.
  52. --*/
  53. EFI_STATUS
  54. EfiCoreAcquireLockOrFail (
  55. PEFI_LOCK Lock
  56. );
  57. /*++
  58. Routine Description:
  59. This routine attempts to acquire the given lock, and fails if it is already
  60. held.
  61. Arguments:
  62. Lock - Supplies a pointer to the lock to try to acquire.
  63. Return Value:
  64. EFI_SUCCESS if the lock was successfully acquired.
  65. EFI_ACCESS_DENIED if the lock was already held and could not be acquired.
  66. --*/
  67. VOID
  68. EfiCoreAcquireLock (
  69. PEFI_LOCK Lock
  70. );
  71. /*++
  72. Routine Description:
  73. This routine raises to the task priority level of the given lock and
  74. acquires the lock.
  75. Arguments:
  76. Lock - Supplies a pointer to the lock to acquire.
  77. Return Value:
  78. None.
  79. --*/
  80. VOID
  81. EfiCoreReleaseLock (
  82. PEFI_LOCK Lock
  83. );
  84. /*++
  85. Routine Description:
  86. This routine releases ownership of the given lock, and lowers back down
  87. to the original TPL.
  88. Arguments:
  89. Lock - Supplies a pointer to the lock to release.
  90. Return Value:
  91. None.
  92. --*/
  93. BOOLEAN
  94. EfiCoreIsLockHeld (
  95. PEFI_LOCK Lock
  96. );
  97. /*++
  98. Routine Description:
  99. This routine determines if the given lock is held.
  100. Arguments:
  101. Lock - Supplies a pointer to the lock to query.
  102. Return Value:
  103. TRUE if the lock is held.
  104. FALSE if the lock is not held.
  105. --*/