Leaked source code of windows server 2003
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.

169 lines
4.1 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. control.c
  5. Abstract:
  6. This module contains support routines for the port driver to access
  7. the miniport's HwAdapterControl functionality.
  8. Authors:
  9. Peter Wieland
  10. Environment:
  11. Kernel mode only
  12. Notes:
  13. Revision History:
  14. --*/
  15. #include "port.h"
  16. #ifdef ALLOC_PRAGMA
  17. #pragma alloc_text(PAGE, SpGetSupportedAdapterControlFunctions)
  18. #endif
  19. #define SIZEOF_CONTROL_TYPE_LIST (sizeof(SCSI_SUPPORTED_CONTROL_TYPE_LIST) +\
  20. sizeof(BOOLEAN) * (ScsiAdapterControlMax + 1))
  21. VOID
  22. SpGetSupportedAdapterControlFunctions(
  23. PADAPTER_EXTENSION Adapter
  24. )
  25. /*++
  26. Routine Description:
  27. This routine will query the miniport to determine which adapter control
  28. types are supported for the specified adapter. The
  29. SupportedAdapterControlBitmap in the adapter extension will be updated with
  30. the data returned by the miniport. These flags are used to determine
  31. what functionality (for power management and such) the miniport will
  32. support.
  33. Arguments:
  34. Adapter - the adapter to query
  35. Return Value:
  36. none
  37. --*/
  38. {
  39. UCHAR buffer[SIZEOF_CONTROL_TYPE_LIST];
  40. SCSI_ADAPTER_CONTROL_STATUS status;
  41. PSCSI_SUPPORTED_CONTROL_TYPE_LIST typeList =
  42. (PSCSI_SUPPORTED_CONTROL_TYPE_LIST) &buffer[0];
  43. PAGED_CODE();
  44. //
  45. // Must initialize the bitmap header before using it.
  46. //
  47. RtlInitializeBitMap(&(Adapter->SupportedControlBitMap),
  48. Adapter->SupportedControlBits,
  49. ScsiAdapterControlMax);
  50. //
  51. // Zero all the bits in the bitmap.
  52. //
  53. RtlClearAllBits(&(Adapter->SupportedControlBitMap));
  54. //
  55. // If the miniport does not support the adapter control function or if the
  56. // adapter is not PNP, the array has already been cleared so we can quit.
  57. //
  58. if ((Adapter->HwAdapterControl == NULL) || (Adapter->IsPnp == FALSE)) {
  59. return;
  60. }
  61. //
  62. // Zero the list of supported control types.
  63. //
  64. RtlZeroMemory(typeList, SIZEOF_CONTROL_TYPE_LIST);
  65. //
  66. // Initialize the max control type to signal the end of the array.
  67. //
  68. typeList->MaxControlType = ScsiAdapterControlMax;
  69. #if DBG
  70. typeList->SupportedTypeList[ScsiAdapterControlMax] = 0x63;
  71. #endif
  72. //
  73. // Call into the miniport to get the list of supported control types.
  74. //
  75. status = Adapter->HwAdapterControl(Adapter->HwDeviceExtension,
  76. ScsiQuerySupportedControlTypes,
  77. typeList);
  78. //
  79. // If the call into the miniport succeeded, walk the list of supported
  80. // types and for each type supported by the miniport, set the associated
  81. // bit in the bitmap.
  82. //
  83. if (status == ScsiAdapterControlSuccess) {
  84. ULONG i;
  85. ASSERT(typeList->SupportedTypeList[ScsiAdapterControlMax] == 0x63);
  86. for (i = 0; i < ScsiAdapterControlMax; i++) {
  87. if (typeList->SupportedTypeList[i] == TRUE) {
  88. RtlSetBits(&(Adapter->SupportedControlBitMap), i, 1);
  89. }
  90. }
  91. }
  92. return;
  93. }
  94. BOOLEAN
  95. SpIsAdapterControlTypeSupported(
  96. IN PADAPTER_EXTENSION AdapterExtension,
  97. IN SCSI_ADAPTER_CONTROL_TYPE ControlType
  98. )
  99. {
  100. return RtlAreBitsSet(&(AdapterExtension->SupportedControlBitMap),
  101. ControlType,
  102. 1);
  103. }
  104. SCSI_ADAPTER_CONTROL_STATUS
  105. SpCallAdapterControl(
  106. IN PADAPTER_EXTENSION AdapterExtension,
  107. IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
  108. IN PVOID Parameters
  109. )
  110. {
  111. ASSERT(TEST_FLAG(AdapterExtension->InterruptData.InterruptFlags,
  112. PD_ADAPTER_REMOVED) == FALSE);
  113. ASSERT(SpIsAdapterControlTypeSupported(AdapterExtension, ControlType));
  114. return AdapterExtension->HwAdapterControl(
  115. AdapterExtension->HwDeviceExtension,
  116. ControlType,
  117. Parameters);
  118. }