ReactOS  0.4.14-dev-49-gfb4591c
wmi.c File Reference
#include "miniport.h"
#include "BusLogic958.h"
#include "wmistr.h"
#include "BT958dt.h"
Include dependency graph for wmi.c:

Go to the source code of this file.

Macros

#define BT958Wmi_MofResourceName   L"MofResource"
 
#define BT958_SETUP_GUID_INDEX   0
 
#define BT958GuidCount   (sizeof(BT958GuidList) / sizeof(SCSIWMIGUIDREGINFO))
 

Functions

UCHAR BT958ReadExtendedSetupInfo (IN PHW_DEVICE_EXTENSION HwDeviceExtension, OUT PUCHAR Buffer)
 
BOOLEAN BT958QueryWmiDataBlock (IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG InstanceCount, IN OUT PULONG InstanceLengthArray, IN ULONG OutBufferSize, OUT PUCHAR Buffer)
 
UCHAR BT958QueryWmiRegInfo (IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, OUT PWCHAR *MofResourceName)
 
void BT958WmiInitialize (IN PHW_DEVICE_EXTENSION HwDeviceExtension)
 
BOOLEAN BT958WmiSrb (IN PHW_DEVICE_EXTENSION HwDeviceExtension, IN OUT PSCSI_WMI_REQUEST_BLOCK Srb)
 

Variables

GUID BT958WmiExtendedSetupInfoGuid = BT958Wmi_ExtendedSetupInfo_Guid
 
SCSIWMIGUIDREGINFO BT958GuidList []
 

Macro Definition Documentation

◆ BT958_SETUP_GUID_INDEX

#define BT958_SETUP_GUID_INDEX   0

Definition at line 9 of file wmi.c.

◆ BT958GuidCount

#define BT958GuidCount   (sizeof(BT958GuidList) / sizeof(SCSIWMIGUIDREGINFO))

Definition at line 49 of file wmi.c.

◆ BT958Wmi_MofResourceName

#define BT958Wmi_MofResourceName   L"MofResource"

Definition at line 7 of file wmi.c.

Function Documentation

◆ BT958QueryWmiDataBlock()

BOOLEAN BT958QueryWmiDataBlock ( IN PVOID  Context,
IN PSCSIWMI_REQUEST_CONTEXT  RequestContext,
IN ULONG  GuidIndex,
IN ULONG  InstanceIndex,
IN ULONG  InstanceCount,
IN OUT PULONG  InstanceLengthArray,
IN ULONG  OutBufferSize,
OUT PUCHAR  Buffer 
)

Definition at line 163 of file wmi.c.

233 {
235  ULONG size = 0;
236  UCHAR status;
237 
238  //
239  // Only ever registers 1 instance per guid
240  ASSERT((InstanceIndex == 0) &&
241  (InstanceCount == 1));
242 
243  switch (GuidIndex)
244  {
246  {
247  size = sizeof(BT958ExtendedSetupInfo)-1;
248  if (OutBufferSize < size)
249  {
250  //
251  // The buffer passed to return the data is too small
252  //
254  break;
255  }
256 
257  if ( !BT958ReadExtendedSetupInfo(HwDeviceExtension,
258  Buffer))
259  {
260  ASSERT(FALSE);
261  size = 0;
263  }
264  else
265  {
266  *InstanceLengthArray = size;
268  }
269  break;
270  }
271 
272  default:
273  {
275  }
276  }
277 
278  ScsiPortWmiPostProcess( RequestContext,
279  status,
280  size);
281 
282  return status;
283 }
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1057
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
SCSIPORTAPI VOID NTAPI ScsiPortWmiPostProcess(_Inout_ PSCSIWMI_REQUEST_CONTEXT RequestContext, _In_ UCHAR SrbStatus, _In_ ULONG BufferUsed)
#define SRB_STATUS_ERROR
Definition: srb.h:336
UCHAR BT958ReadExtendedSetupInfo(IN PHW_DEVICE_EXTENSION HwDeviceExtension, OUT PUCHAR Buffer)
Definition: wmi.c:342
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:401
Definition: bufpool.h:45
GLsizeiptr size
Definition: glext.h:5919
#define SRB_STATUS_DATA_OVERRUN
Definition: srb.h:349
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _HW_DEVICE_EXTENSION * PHW_DEVICE_EXTENSION
#define BT958_SETUP_GUID_INDEX
Definition: wmi.c:9
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG InstanceCount
Definition: iofuncs.h:1319
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
struct _BT958ExtendedSetupInfo BT958ExtendedSetupInfo
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by BT958WmiInitialize().

◆ BT958QueryWmiRegInfo()

UCHAR BT958QueryWmiRegInfo ( IN PVOID  Context,
IN PSCSIWMI_REQUEST_CONTEXT  RequestContext,
OUT PWCHAR MofResourceName 
)

Definition at line 286 of file wmi.c.

335 {
337  return SRB_STATUS_SUCCESS;
338 }
#define BT958Wmi_MofResourceName
Definition: wmi.c:7
_Out_ ULONG _Out_ PUNICODE_STRING _Out_ PUNICODE_STRING MofResourceName
Definition: classpnp.h:386
#define SRB_STATUS_SUCCESS
Definition: srb.h:333

Referenced by BT958WmiInitialize().

◆ BT958ReadExtendedSetupInfo()

UCHAR BT958ReadExtendedSetupInfo ( IN PHW_DEVICE_EXTENSION  HwDeviceExtension,
OUT PUCHAR  Buffer 
)

Definition at line 342 of file wmi.c.

364 {
365  UCHAR numberOfBytes = sizeof(BT958ExtendedSetupInfo)-1;
366 
367  PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
368  BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
369  BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
370  BusLogic_RequestedReplyLength_T RequestedReplyLength = sizeof(ExtendedSetupInformation);
371  BOOLEAN Result = TRUE;
372 
373  BusLogic_WmiExtendedSetupInformation_T WmiExtendedSetupInfo;
374  PUCHAR SourceBuf = (PUCHAR) &WmiExtendedSetupInfo;
375 
376 
377  //
378  // Issue the Inquire Extended Setup Information command. Only genuine
379  // BusLogic Host Adapters and TRUE clones support this command. Adaptec 1542C
380  // series Host Adapters that respond to the Geometry Register I/O port will
381  // fail this command.
382  RequestedReplyLength = sizeof(ExtendedSetupInformation);
383  if (BusLogic_Command(HostAdapter,
385  &RequestedReplyLength,
386  sizeof(RequestedReplyLength),
387  &ExtendedSetupInformation,
388  sizeof(ExtendedSetupInformation))
389  != sizeof(ExtendedSetupInformation))
390  {
391  Result = FALSE;
392  }
393 
394  WmiExtendedSetupInfo.BusType = ExtendedSetupInformation.BusType;
395  WmiExtendedSetupInfo.BIOS_Address = ExtendedSetupInformation.BIOS_Address;
396  WmiExtendedSetupInfo.ScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit;
397  WmiExtendedSetupInfo.MailboxCount = ExtendedSetupInformation.MailboxCount;
398  WmiExtendedSetupInfo.BaseMailboxAddress = ExtendedSetupInformation.BaseMailboxAddress;
399  WmiExtendedSetupInfo.FastOnEISA = ExtendedSetupInformation.Misc.FastOnEISA;
400  WmiExtendedSetupInfo.LevelSensitiveInterrupt = ExtendedSetupInformation.Misc.LevelSensitiveInterrupt;
401  WmiExtendedSetupInfo.FirmwareRevision[0] = ExtendedSetupInformation.FirmwareRevision[0];
402  WmiExtendedSetupInfo.FirmwareRevision[1] = ExtendedSetupInformation.FirmwareRevision[1];
403  WmiExtendedSetupInfo.FirmwareRevision[2] = ExtendedSetupInformation.FirmwareRevision[2];
404  WmiExtendedSetupInfo.HostWideSCSI = ExtendedSetupInformation.HostWideSCSI;
405  WmiExtendedSetupInfo.HostDifferentialSCSI= ExtendedSetupInformation.HostDifferentialSCSI;
406  WmiExtendedSetupInfo.HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM;
407  WmiExtendedSetupInfo.HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI;
408  WmiExtendedSetupInfo.HostSmartTermination= ExtendedSetupInformation.HostSmartTermination;
409 
410  for (; numberOfBytes; numberOfBytes--)
411  {
412  *Buffer++ = *SourceBuf++;
413  }
414  return TRUE;
415 }
BusLogic_BusAddress_T BaseMailboxAddress
Definition: BusLogic958.h:801
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
BusLogic_BusAddress_T BaseMailboxAddress
Definition: BusLogic958.h:344
int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, BusLogic_OperationCode_T OperationCode, void *ParameterData, int ParameterLength, void *ReplyData, int ReplyLength)
Definition: BusLogic958.c:606
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
BusLogic_HostAdapter_T hcs
Definition: BusLogic958.h:757
unsigned char UCHAR
Definition: xmlstorage.h:181
struct BusLogic_ExtendedSetupInformation::@1262 Misc
UCHAR BusLogic_RequestedReplyLength_T
Definition: BusLogic958.h:169
struct _BT958ExtendedSetupInfo BT958ExtendedSetupInfo

Referenced by BT958QueryWmiDataBlock().

◆ BT958WmiInitialize()

void BT958WmiInitialize ( IN PHW_DEVICE_EXTENSION  HwDeviceExtension)

Definition at line 52 of file wmi.c.

55 {
57 
58  WmiLibContext = &HwDeviceExtension->WmiLibContext;
59 
60  WmiLibContext->GuidList = BT958GuidList;
61  WmiLibContext->GuidCount = BT958GuidCount;
62  WmiLibContext->QueryWmiRegInfo = BT958QueryWmiRegInfo;
63  WmiLibContext->QueryWmiDataBlock = BT958QueryWmiDataBlock;
64  WmiLibContext->SetWmiDataItem = NULL;
65  WmiLibContext->SetWmiDataBlock = NULL;
66  WmiLibContext->WmiFunctionControl = NULL;
67  WmiLibContext->ExecuteWmiMethod = NULL;
68 }
_In_ PVOID WmiLibContext
Definition: batclass.h:377
SCSIWMIGUIDREGINFO BT958GuidList[]
Definition: wmi.c:41
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN BT958QueryWmiDataBlock(IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, IN ULONG InstanceIndex, IN ULONG InstanceCount, IN OUT PULONG InstanceLengthArray, IN ULONG OutBufferSize, OUT PUCHAR Buffer)
Definition: wmi.c:163
#define BT958GuidCount
Definition: wmi.c:49
UCHAR BT958QueryWmiRegInfo(IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, OUT PWCHAR *MofResourceName)
Definition: wmi.c:286

◆ BT958WmiSrb()

BOOLEAN BT958WmiSrb ( IN PHW_DEVICE_EXTENSION  HwDeviceExtension,
IN OUT PSCSI_WMI_REQUEST_BLOCK  Srb 
)

Definition at line 73 of file wmi.c.

99 {
100  UCHAR status;
101  SCSIWMI_REQUEST_CONTEXT requestContext;
102  ULONG retSize;
103  BOOLEAN pending;
104 
105  // Validate our assumptions.
106  ASSERT(Srb->Function == SRB_FUNCTION_WMI);
107  ASSERT(Srb->Length == sizeof(SCSI_WMI_REQUEST_BLOCK));
108  ASSERT(Srb->DataTransferLength >= sizeof(ULONG));
109  ASSERT(Srb->DataBuffer);
110 
111  // Check if the WMI SRB is targeted for the adapter or one of the disks
112  if (!(Srb->WMIFlags & SRB_WMI_FLAGS_ADAPTER_REQUEST))
113  {
114 
115  // This is targeted to one of the disks, since there are no per disk
116  // wmi information we return an error. Note that if there was per
117  // disk information, then you'd likely have a differen WmiLibContext
118  // and a different set of guids.
119  Srb->DataTransferLength = 0;
120  Srb->SrbStatus = SRB_STATUS_SUCCESS;
121 
122  }
123  else
124  {
125  // Process the incoming WMI request.
126  pending = ScsiPortWmiDispatchFunction(&HwDeviceExtension->WmiLibContext,
127  Srb->WMISubFunction,
128  HwDeviceExtension,
129  &requestContext,
130  Srb->DataPath,
131  Srb->DataTransferLength,
132  Srb->DataBuffer);
133 
134  // We assume that the wmi request will never pend so that we can
135  // allocate the requestContext from stack. If the WMI request could
136  // ever pend then we'd need to allocate the request context from
137  // the SRB extension.
138  //
139  ASSERT(! pending);
140 
141  retSize = ScsiPortWmiGetReturnSize(&requestContext);
142  status = ScsiPortWmiGetReturnStatus(&requestContext);
143 
144  // We can do this since we assume it is done synchronously
145  Srb->DataTransferLength = retSize;
146 
147  //
148  // Adapter ready for next request.
149  //
150 
151  Srb->SrbStatus = status;
152  }
153 
154  ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
155  ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
156 
157  return TRUE;
158 }
#define TRUE
Definition: types.h:120
#define ScsiPortWmiGetReturnStatus(RequestContext)
Definition: scsiwmi.h:189
#define ScsiPortWmiGetReturnSize(RequestContext)
Definition: scsiwmi.h:182
_Must_inspect_result_ SCSIPORTAPI BOOLEAN NTAPI ScsiPortWmiDispatchFunction(_In_ PSCSI_WMILIB_CONTEXT WmiLibInfo, _In_ UCHAR MinorFunction, _In_ PVOID DeviceContext, _In_ PSCSIWMI_REQUEST_CONTEXT RequestContext, _In_ PVOID DataPath, _In_ ULONG BufferSize, _In_ PVOID Buffer)
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SRB_FUNCTION_WMI
Definition: srb.h:323
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define SRB_WMI_FLAGS_ADAPTER_REQUEST
Definition: srb.h:419
VOID __cdecl ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, IN ...)
Definition: scsiport.c:1308
unsigned int ULONG
Definition: retypes.h:1
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Variable Documentation

◆ BT958GuidList

SCSIWMIGUIDREGINFO BT958GuidList[]
Initial value:
=
{
1,
0
},
}
GUID BT958WmiExtendedSetupInfoGuid
Definition: wmi.c:11

Definition at line 41 of file wmi.c.

Referenced by BT958WmiInitialize().

◆ BT958WmiExtendedSetupInfoGuid

GUID BT958WmiExtendedSetupInfoGuid = BT958Wmi_ExtendedSetupInfo_Guid

Definition at line 11 of file wmi.c.