ReactOS 0.4.15-dev-8241-g63935f8
wmi.c
Go to the documentation of this file.
1#include "miniport.h"
2#include "BusLogic958.h" // includes scsi.h
3#include "wmistr.h" // WMI definitions
4
5#include "BT958dt.h"
6
7#define BT958Wmi_MofResourceName L"MofResource"
8
9#define BT958_SETUP_GUID_INDEX 0
10
12
15(
16 IN PHW_DEVICE_EXTENSION HwDeviceExtension,
18);
19
22(
24 IN PSCSIWMI_REQUEST_CONTEXT RequestContext,
28 IN OUT PULONG InstanceLengthArray,
31);
32
35(
37 IN PSCSIWMI_REQUEST_CONTEXT RequestContext,
39);
40
42{
44 1,
45 0
46 },
47};
48
49#define BT958GuidCount (sizeof(BT958GuidList) / sizeof(SCSIWMIGUIDREGINFO))
50
51
53 IN PHW_DEVICE_EXTENSION HwDeviceExtension
54 )
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}
69
70
71
74 IN PHW_DEVICE_EXTENSION HwDeviceExtension,
76 )
77/*++
78
79Routine Description:
80
81 Process an SRB_FUNCTION_WMI request packet.
82
83 This routine is called from the SCSI port driver synchronized with the
84 kernel via BT958StartIo. On completion of WMI processing, the SCSI
85 port driver is notified that the adapter can take another request, if
86 any are available.
87
88Arguments:
89
90 HwDeviceExtension - HBA miniport driver's adapter data storage.
91
92 Srb - IO request packet.
93
94Return Value:
95
96 Value to return to BT958StartIo caller. Always TRUE.
97
98--*/
99{
101 SCSIWMI_REQUEST_CONTEXT requestContext;
102 ULONG retSize;
103 BOOLEAN pending;
104
105 // Validate our assumptions.
108 ASSERT(Srb->DataTransferLength >= sizeof(ULONG));
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.
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,
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
152 }
153
154 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
155 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
156
157 return TRUE;
158}
159
160
161
165 IN PSCSIWMI_REQUEST_CONTEXT RequestContext,
169 IN OUT PULONG InstanceLengthArray,
172 )
173/*++
174
175Routine Description:
176
177 This routine is a callback into the miniport to query for the contents of
178 one or more instances of a data block. This callback may be called with
179 an output buffer that is too small to return all of the data queried.
180 In this case the callback is responsible to report the correct output
181 buffer size needed.
182
183 If the request can be completed immediately without pending,
184 ScsiPortWmiPostProcess should be called from within this callback and
185 FALSE returned.
186
187 If the request cannot be completed within this callback then TRUE should
188 be returned. Once the pending operations are finished the miniport should
189 call ScsiPortWmiPostProcess and then complete the srb.
190
191Arguments:
192
193 DeviceContext is a caller specified context value originally passed to
194 ScsiPortWmiDispatchFunction.
195
196 RequestContext is a context associated with the srb being processed.
197
198 GuidIndex is the index into the list of guids provided when the
199 miniport registered
200
201 InstanceIndex is the index that denotes first instance of the data block
202 is being queried.
203
204 InstanceCount is the number of instances expected to be returned for
205 the data block.
206
207 InstanceLengthArray is a pointer to an array of ULONG that returns the
208 lengths of each instance of the data block. This may be NULL when
209 there is not enough space in the output buffer to fufill the request.
210 In this case the miniport should call ScsiPortWmiPostProcess with
211 a status of SRB_STATUS_DATA_OVERRUN and the size of the output buffer
212 needed to fufill the request.
213
214 BufferAvail on entry has the maximum size available to write the data
215 blocks in the output buffer. If the output buffer is not large enough
216 to return all of the data blocks then the miniport should call
217 ScsiPortWmiPostProcess with a status of SRB_STATUS_DATA_OVERRUN
218 and the size of the output buffer needed to fufill the request.
219
220 Buffer on return is filled with the returned data blocks. Note that each
221 instance of the data block must be aligned on a 8 byte boundry. This
222 may be NULL when there is not enough space in the output buffer to
223 fufill the request. In this case the miniport should call
224 ScsiPortWmiPostProcess with a status of SRB_STATUS_DATA_OVERRUN and
225 the size of the output buffer needed to fufill the request.
226
227
228Return Value:
229
230 TRUE if request is pending else FALSE
231
232--*/
233{
235 ULONG size = 0;
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}
284
285UCHAR
288 IN PSCSIWMI_REQUEST_CONTEXT RequestContext,
290 )
291/*++
292
293Routine Description:
294
295 This routine is a callback into the driver to retrieve information about
296 the guids being registered.
297
298 Implementations of this routine may be in paged memory
299
300Arguments:
301
302 DeviceObject is the device whose registration information is needed
303
304 *RegFlags returns with a set of flags that describe all of the guids being
305 registered for this device. If the device wants enable and disable
306 collection callbacks before receiving queries for the registered
307 guids then it should return the WMIREG_FLAG_EXPENSIVE flag. Also the
308 returned flags may specify WMIREG_FLAG_INSTANCE_PDO in which case
309 the instance name is determined from the PDO associated with the
310 device object. Note that the PDO must have an associated devnode. If
311 WMIREG_FLAG_INSTANCE_PDO is not set then Name must return a unique
312 name for the device. These flags are ORed into the flags specified
313 by the GUIDREGINFO for each guid.
314
315 InstanceName returns with the instance name for the guids if
316 WMIREG_FLAG_INSTANCE_PDO is not set in the returned *RegFlags. The
317 caller will call ExFreePool with the buffer returned.
318
319 *RegistryPath returns with the registry path of the driver. This is
320 required
321
322 *MofResourceName returns with the name of the MOF resource attached to
323 the binary file. If the driver does not have a mof resource attached
324 then this can be returned as NULL.
325
326 *Pdo returns with the device object for the PDO associated with this
327 device if the WMIREG_FLAG_INSTANCE_PDO flag is returned in
328 *RegFlags.
329
330Return Value:
331
332 status
333
334--*/
335{
337 return SRB_STATUS_SUCCESS;
338}
339
340
341UCHAR
343 IN PHW_DEVICE_EXTENSION HwDeviceExtension,
345 )
346/*++
347
348Routine Description:
349
350 Read the adapter setup information into the supplied buffer. The buffer
351 must be RM_CFG_MAX_SIZE (255) bytes large.
352
353Arguments:
354
355 HwDeviceExtension - HBA miniport driver's adapter data storage.
356
357 Buffer - Buffer to hold adapter's setup information structure [manual 5-10].
358
359Return Value:
360
361 TRUE on success, FALSE on failure.
362
363--*/
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);
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}
416
#define BT958Wmi_ExtendedSetupInfo_Guid
Definition: BT958dt.h:27
struct _BT958ExtendedSetupInfo BT958ExtendedSetupInfo
int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, BusLogic_OperationCode_T OperationCode, void *ParameterData, int ParameterLength, void *ReplyData, int ReplyLength)
Definition: BusLogic958.c:606
@ BusLogic_InquireExtendedSetupInformation
Definition: BusLogic958.h:150
UCHAR BusLogic_RequestedReplyLength_T
Definition: BusLogic958.h:169
unsigned char BOOLEAN
struct _HW_DEVICE_EXTENSION * PHW_DEVICE_EXTENSION
_In_ PVOID WmiLibContext
Definition: batclass.h:377
VOID __cdecl ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, IN ...)
Definition: scsiport.c:1324
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
Definition: bufpool.h:45
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1251
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:419
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SRB_FUNCTION_WMI
Definition: srb.h:331
#define SRB_STATUS_DATA_OVERRUN
Definition: srb.h:357
#define SRB_WMI_FLAGS_ADAPTER_REQUEST
Definition: srb.h:427
#define SRB_STATUS_ERROR
Definition: srb.h:344
@ RequestComplete
Definition: srb.h:531
@ NextRequest
Definition: srb.h:532
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
UCHAR BT958QueryWmiRegInfo(IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, OUT PWCHAR *MofResourceName)
Definition: wmi.c:286
#define BT958GuidCount
Definition: wmi.c:49
#define BT958Wmi_MofResourceName
Definition: wmi.c:7
#define BT958_SETUP_GUID_INDEX
Definition: wmi.c:9
GUID BT958WmiExtendedSetupInfoGuid
Definition: wmi.c:11
SCSIWMIGUIDREGINFO BT958GuidList[]
Definition: wmi.c:41
UCHAR BT958ReadExtendedSetupInfo(IN PHW_DEVICE_EXTENSION HwDeviceExtension, OUT PUCHAR Buffer)
Definition: wmi.c:342
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
void BT958WmiInitialize(IN PHW_DEVICE_EXTENSION HwDeviceExtension)
Definition: wmi.c:52
BOOLEAN BT958WmiSrb(IN PHW_DEVICE_EXTENSION HwDeviceExtension, IN OUT PSCSI_WMI_REQUEST_BLOCK Srb)
Definition: wmi.c:73
GLsizeiptr size
Definition: glext.h:5919
#define ASSERT(a)
Definition: mode.c:44
SCSIPORT_API VOID NTAPI ScsiPortWmiPostProcess(_Inout_ PSCSIWMI_REQUEST_CONTEXT RequestContext, _In_ UCHAR SrbStatus, _In_ ULONG BufferUsed)
_Must_inspect_result_ SCSIPORT_API 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)
#define ScsiPortWmiGetReturnSize(RequestContext)
Definition: scsiwmi.h:182
#define ScsiPortWmiGetReturnStatus(RequestContext)
Definition: scsiwmi.h:189
struct BusLogic_ExtendedSetupInformation::@1332 Misc
BusLogic_BusAddress_T BaseMailboxAddress
Definition: BusLogic958.h:344
BusLogic_BusAddress_T BaseMailboxAddress
Definition: BusLogic958.h:801
BusLogic_HostAdapter_T hcs
Definition: BusLogic958.h:757
PVOID DataBuffer
Definition: srb.h:263
UCHAR Function
Definition: srb.h:250
ULONG DataTransferLength
Definition: srb.h:261
USHORT Length
Definition: srb.h:249
UCHAR SrbStatus
Definition: srb.h:251
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2464
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_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:409
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
unsigned char UCHAR
Definition: xmlstorage.h:181