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.

146 lines
3.6 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. VOID
  20. SpGetSupportedAdapterControlFunctions(
  21. PADAPTER_EXTENSION Adapter
  22. )
  23. /*++
  24. Routine Description:
  25. This routine will query the miniport to determine which adapter control
  26. types are supported for the specified adapter. The
  27. SupportedAdapterControlBitmap in the adapter extension will be updated with
  28. the data returned by the miniport. These flags are used to determine
  29. what functionality (for power management and such) the miniport will support
  30. Arguments:
  31. Adapter - the adapter to query
  32. Return Value:
  33. none
  34. --*/
  35. {
  36. UCHAR buffer[sizeof(SCSI_SUPPORTED_CONTROL_TYPE_LIST) +
  37. (sizeof(BOOLEAN) * (ScsiAdapterControlMax + 1))];
  38. PSCSI_SUPPORTED_CONTROL_TYPE_LIST typeList =
  39. (PSCSI_SUPPORTED_CONTROL_TYPE_LIST) &buffer;
  40. SCSI_ADAPTER_CONTROL_STATUS status;
  41. PAGED_CODE();
  42. RtlInitializeBitMap(&(Adapter->SupportedControlBitMap),
  43. Adapter->SupportedControlBits,
  44. ScsiAdapterControlMax);
  45. RtlClearAllBits(&(Adapter->SupportedControlBitMap));
  46. if((Adapter->HwAdapterControl == NULL) ||
  47. (Adapter->IsPnp == FALSE)) {
  48. //
  49. // Adapter control is not supported by the miniport or the miniport
  50. // isn't pnp (in which case it's not supported by scsiport) - the
  51. // supported array has already been cleared so we can just quit now.
  52. //
  53. return;
  54. }
  55. RtlZeroMemory(typeList, (sizeof(SCSI_SUPPORTED_CONTROL_TYPE_LIST) +
  56. sizeof(BOOLEAN) * (ScsiAdapterControlMax + 1)));
  57. typeList->MaxControlType = ScsiAdapterControlMax;
  58. #if DBG
  59. typeList->SupportedTypeList[ScsiAdapterControlMax] = 0x63;
  60. #endif
  61. status = Adapter->HwAdapterControl(Adapter->HwDeviceExtension,
  62. ScsiQuerySupportedControlTypes,
  63. typeList);
  64. // ASSERT(status != ScsiAdapterControlNotSupported);
  65. if(status == ScsiAdapterControlSuccess) {
  66. ULONG i;
  67. ASSERT(typeList->SupportedTypeList[ScsiAdapterControlMax] == 0x63);
  68. for(i = 0; i < ScsiAdapterControlMax; i++) {
  69. if(typeList->SupportedTypeList[i] == TRUE) {
  70. RtlSetBits(&(Adapter->SupportedControlBitMap),
  71. i,
  72. 1);
  73. }
  74. }
  75. }
  76. return;
  77. }
  78. BOOLEAN
  79. SpIsAdapterControlTypeSupported(
  80. IN PADAPTER_EXTENSION AdapterExtension,
  81. IN SCSI_ADAPTER_CONTROL_TYPE ControlType
  82. )
  83. {
  84. return RtlAreBitsSet(&(AdapterExtension->SupportedControlBitMap),
  85. ControlType,
  86. 1);
  87. }
  88. SCSI_ADAPTER_CONTROL_STATUS
  89. SpCallAdapterControl(
  90. IN PADAPTER_EXTENSION AdapterExtension,
  91. IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
  92. IN PVOID Parameters
  93. )
  94. {
  95. ASSERT(TEST_FLAG(AdapterExtension->InterruptData.InterruptFlags,
  96. PD_ADAPTER_REMOVED) == FALSE);
  97. ASSERT(SpIsAdapterControlTypeSupported(AdapterExtension, ControlType));
  98. return AdapterExtension->HwAdapterControl(
  99. AdapterExtension->HwDeviceExtension,
  100. ControlType,
  101. Parameters);
  102. }