lock.h 2.4 KB

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