lock.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. lock.c
  5. Abstract:
  6. Implements FLOCK
  7. Revision History
  8. --*/
  9. #include "lib.h"
  10. VOID
  11. InitializeLock (
  12. IN OUT FLOCK *Lock,
  13. IN EFI_TPL Priority
  14. )
  15. /*++
  16. Routine Description:
  17. Initialize a basic mutual exclusion lock. Each lock
  18. provides mutual exclusion access at it's task priority
  19. level. Since there is no-premption (at any TPL) or
  20. multiprocessor support, acquiring the lock only consists
  21. of raising to the locks TPL.
  22. Note on a debug build the lock is acquired and released
  23. to help ensure proper usage.
  24. Arguments:
  25. Lock - The FLOCK structure to initialize
  26. Priority - The task priority level of the lock
  27. Returns:
  28. An initialized F Lock structure.
  29. --*/
  30. {
  31. Lock->Tpl = Priority;
  32. Lock->OwnerTpl = 0;
  33. Lock->Lock = 0;
  34. }
  35. VOID
  36. AcquireLock (
  37. IN FLOCK *Lock
  38. )
  39. /*++
  40. Routine Description:
  41. Raising to the task priority level of the mutual exclusion
  42. lock, and then acquires ownership of the lock.
  43. Arguments:
  44. Lock - The lock to acquire
  45. Returns:
  46. Lock owned
  47. --*/
  48. {
  49. RtAcquireLock (Lock);
  50. }
  51. VOID
  52. ReleaseLock (
  53. IN FLOCK *Lock
  54. )
  55. /*++
  56. Routine Description:
  57. Releases ownership of the mutual exclusion lock, and
  58. restores the previous task priority level.
  59. Arguments:
  60. Lock - The lock to release
  61. Returns:
  62. Lock unowned
  63. --*/
  64. {
  65. RtReleaseLock (Lock);
  66. }