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.

91 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. fdoext.c
  5. Abstract
  6. Author:
  7. Ervin P.
  8. Environment:
  9. Kernel mode only
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. FDO_EXTENSION *allFdoExtensions = NULL;
  14. KSPIN_LOCK allFdoExtensionsSpinLock;
  15. /*
  16. ********************************************************************************
  17. * EnqueueFdoExt
  18. ********************************************************************************
  19. *
  20. * Note: this function cannot be pageable because it
  21. * acquires a spinlock.
  22. */
  23. VOID EnqueueFdoExt(FDO_EXTENSION *fdoExt)
  24. {
  25. KIRQL oldIrql;
  26. static BOOLEAN firstCall = TRUE;
  27. if (firstCall){
  28. KeInitializeSpinLock(&allFdoExtensionsSpinLock);
  29. firstCall = FALSE;
  30. }
  31. KeAcquireSpinLock(&allFdoExtensionsSpinLock, &oldIrql);
  32. ASSERT(!fdoExt->nextFdoExt);
  33. fdoExt->nextFdoExt = allFdoExtensions;
  34. allFdoExtensions = fdoExt;
  35. KeReleaseSpinLock(&allFdoExtensionsSpinLock, oldIrql);
  36. }
  37. /*
  38. ********************************************************************************
  39. * DequeueFdoExt
  40. ********************************************************************************
  41. *
  42. * Note: this function cannot be pageable because it
  43. * acquires a spinlock.
  44. *
  45. */
  46. VOID DequeueFdoExt(FDO_EXTENSION *fdoExt)
  47. {
  48. FDO_EXTENSION *thisFdoExt;
  49. KIRQL oldIrql;
  50. KeAcquireSpinLock(&allFdoExtensionsSpinLock, &oldIrql);
  51. if (fdoExt == allFdoExtensions){
  52. allFdoExtensions = fdoExt->nextFdoExt;
  53. }
  54. else {
  55. for (thisFdoExt = allFdoExtensions; thisFdoExt; thisFdoExt = thisFdoExt->nextFdoExt){
  56. if (thisFdoExt->nextFdoExt == fdoExt){
  57. thisFdoExt->nextFdoExt = fdoExt->nextFdoExt;
  58. break;
  59. }
  60. }
  61. }
  62. fdoExt->nextFdoExt = NULL;
  63. KeReleaseSpinLock(&allFdoExtensionsSpinLock, oldIrql);
  64. }