Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
1.4 KiB

  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. #pragma RUNTIME_CODE(RtAcquireLock)
  11. VOID
  12. RtAcquireLock (
  13. IN FLOCK *Lock
  14. )
  15. /*++
  16. Routine Description:
  17. Raising to the task priority level of the mutual exclusion
  18. lock, and then acquires ownership of the lock.
  19. Arguments:
  20. Lock - The lock to acquire
  21. Returns:
  22. Lock owned
  23. --*/
  24. {
  25. if (BS) {
  26. if (BS->RaiseTPL != NULL) {
  27. Lock->OwnerTpl = BS->RaiseTPL(Lock->Tpl);
  28. }
  29. }
  30. else {
  31. if (LibRuntimeRaiseTPL != NULL) {
  32. Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl);
  33. }
  34. }
  35. Lock->Lock += 1;
  36. ASSERT (Lock->Lock == 1);
  37. }
  38. #pragma RUNTIME_CODE(RtAcquireLock)
  39. VOID
  40. RtReleaseLock (
  41. IN FLOCK *Lock
  42. )
  43. /*++
  44. Routine Description:
  45. Releases ownership of the mutual exclusion lock, and
  46. restores the previous task priority level.
  47. Arguments:
  48. Lock - The lock to release
  49. Returns:
  50. Lock unowned
  51. --*/
  52. {
  53. EFI_TPL Tpl;
  54. Tpl = Lock->OwnerTpl;
  55. ASSERT(Lock->Lock == 1);
  56. Lock->Lock -= 1;
  57. if (BS) {
  58. if (BS->RestoreTPL != NULL) {
  59. BS->RestoreTPL (Tpl);
  60. }
  61. }
  62. else {
  63. if (LibRuntimeRestoreTPL != NULL) {
  64. LibRuntimeRestoreTPL(Tpl);
  65. }
  66. }
  67. }