Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwmi.c
Go to the documentation of this file.
00001 #include "miniport.h" 00002 #include "BusLogic958.h" // includes scsi.h 00003 #include "wmistr.h" // WMI definitions 00004 00005 #include "BT958dt.h" 00006 00007 #define BT958Wmi_MofResourceName L"MofResource" 00008 00009 #define BT958_SETUP_GUID_INDEX 0 00010 00011 GUID BT958WmiExtendedSetupInfoGuid = BT958Wmi_ExtendedSetupInfo_Guid; 00012 00013 UCHAR 00014 BT958ReadExtendedSetupInfo 00015 ( 00016 IN PHW_DEVICE_EXTENSION HwDeviceExtension, 00017 OUT PUCHAR Buffer 00018 ); 00019 00020 BOOLEAN 00021 BT958QueryWmiDataBlock 00022 ( 00023 IN PVOID Context, 00024 IN PSCSIWMI_REQUEST_CONTEXT RequestContext, 00025 IN ULONG GuidIndex, 00026 IN ULONG InstanceIndex, 00027 IN ULONG InstanceCount, 00028 IN OUT PULONG InstanceLengthArray, 00029 IN ULONG OutBufferSize, 00030 OUT PUCHAR Buffer 00031 ); 00032 00033 UCHAR 00034 BT958QueryWmiRegInfo 00035 ( 00036 IN PVOID Context, 00037 IN PSCSIWMI_REQUEST_CONTEXT RequestContext, 00038 OUT PWCHAR *MofResourceName 00039 ); 00040 00041 SCSIWMIGUIDREGINFO BT958GuidList[] = 00042 { 00043 {&BT958WmiExtendedSetupInfoGuid, 00044 1, 00045 0 00046 }, 00047 }; 00048 00049 #define BT958GuidCount (sizeof(BT958GuidList) / sizeof(SCSIWMIGUIDREGINFO)) 00050 00051 00052 void BT958WmiInitialize( 00053 IN PHW_DEVICE_EXTENSION HwDeviceExtension 00054 ) 00055 { 00056 PSCSI_WMILIB_CONTEXT WmiLibContext; 00057 00058 WmiLibContext = &HwDeviceExtension->WmiLibContext; 00059 00060 WmiLibContext->GuidList = BT958GuidList; 00061 WmiLibContext->GuidCount = BT958GuidCount; 00062 WmiLibContext->QueryWmiRegInfo = BT958QueryWmiRegInfo; 00063 WmiLibContext->QueryWmiDataBlock = BT958QueryWmiDataBlock; 00064 WmiLibContext->SetWmiDataItem = NULL; 00065 WmiLibContext->SetWmiDataBlock = NULL; 00066 WmiLibContext->WmiFunctionControl = NULL; 00067 WmiLibContext->ExecuteWmiMethod = NULL; 00068 } 00069 00070 00071 00072 BOOLEAN 00073 BT958WmiSrb( 00074 IN PHW_DEVICE_EXTENSION HwDeviceExtension, 00075 IN OUT PSCSI_WMI_REQUEST_BLOCK Srb 00076 ) 00077 /*++ 00078 00079 Routine Description: 00080 00081 Process an SRB_FUNCTION_WMI request packet. 00082 00083 This routine is called from the SCSI port driver synchronized with the 00084 kernel via BT958StartIo. On completion of WMI processing, the SCSI 00085 port driver is notified that the adapter can take another request, if 00086 any are available. 00087 00088 Arguments: 00089 00090 HwDeviceExtension - HBA miniport driver's adapter data storage. 00091 00092 Srb - IO request packet. 00093 00094 Return Value: 00095 00096 Value to return to BT958StartIo caller. Always TRUE. 00097 00098 --*/ 00099 { 00100 UCHAR status; 00101 SCSIWMI_REQUEST_CONTEXT requestContext; 00102 ULONG retSize; 00103 BOOLEAN pending; 00104 00105 // Validate our assumptions. 00106 ASSERT(Srb->Function == SRB_FUNCTION_WMI); 00107 ASSERT(Srb->Length == sizeof(SCSI_WMI_REQUEST_BLOCK)); 00108 ASSERT(Srb->DataTransferLength >= sizeof(ULONG)); 00109 ASSERT(Srb->DataBuffer); 00110 00111 // Check if the WMI SRB is targetted for the adapter or one of the disks 00112 if (!(Srb->WMIFlags & SRB_WMI_FLAGS_ADAPTER_REQUEST)) 00113 { 00114 00115 // This is targetted to one of the disks, since there are no per disk 00116 // wmi information we return an error. Note that if there was per 00117 // disk information, then you'd likely have a differen WmiLibContext 00118 // and a different set of guids. 00119 Srb->DataTransferLength = 0; 00120 Srb->SrbStatus = SRB_STATUS_SUCCESS; 00121 00122 } 00123 else 00124 { 00125 // Process the incoming WMI request. 00126 pending = ScsiPortWmiDispatchFunction(&HwDeviceExtension->WmiLibContext, 00127 Srb->WMISubFunction, 00128 HwDeviceExtension, 00129 &requestContext, 00130 Srb->DataPath, 00131 Srb->DataTransferLength, 00132 Srb->DataBuffer); 00133 00134 // We assune that the wmi request will never pend so that we can 00135 // allocate the requestContext from stack. If the WMI request could 00136 // ever pend then we'd need to allocate the request context from 00137 // the SRB extension. 00138 // 00139 ASSERT(! pending); 00140 00141 retSize = ScsiPortWmiGetReturnSize(&requestContext); 00142 status = ScsiPortWmiGetReturnStatus(&requestContext); 00143 00144 // We can do this since we assume it is done synchronously 00145 Srb->DataTransferLength = retSize; 00146 00147 // 00148 // Adapter ready for next request. 00149 // 00150 00151 Srb->SrbStatus = status; 00152 } 00153 00154 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); 00155 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); 00156 00157 return TRUE; 00158 } 00159 00160 00161 00162 BOOLEAN 00163 BT958QueryWmiDataBlock( 00164 IN PVOID Context, 00165 IN PSCSIWMI_REQUEST_CONTEXT RequestContext, 00166 IN ULONG GuidIndex, 00167 IN ULONG InstanceIndex, 00168 IN ULONG InstanceCount, 00169 IN OUT PULONG InstanceLengthArray, 00170 IN ULONG OutBufferSize, 00171 OUT PUCHAR Buffer 00172 ) 00173 /*++ 00174 00175 Routine Description: 00176 00177 This routine is a callback into the miniport to query for the contents of 00178 one or more instances of a data block. This callback may be called with 00179 an output buffer that is too small to return all of the data queried. 00180 In this case the callback is responsible to report the correct output 00181 buffer size needed. 00182 00183 If the request can be completed immediately without pending, 00184 ScsiPortWmiPostProcess should be called from within this callback and 00185 FALSE returned. 00186 00187 If the request cannot be completed within this callback then TRUE should 00188 be returned. Once the pending operations are finished the miniport should 00189 call ScsiPortWmiPostProcess and then complete the srb. 00190 00191 Arguments: 00192 00193 DeviceContext is a caller specified context value originally passed to 00194 ScsiPortWmiDispatchFunction. 00195 00196 RequestContext is a context associated with the srb being processed. 00197 00198 GuidIndex is the index into the list of guids provided when the 00199 miniport registered 00200 00201 InstanceIndex is the index that denotes first instance of the data block 00202 is being queried. 00203 00204 InstanceCount is the number of instances expected to be returned for 00205 the data block. 00206 00207 InstanceLengthArray is a pointer to an array of ULONG that returns the 00208 lengths of each instance of the data block. This may be NULL when 00209 there is not enough space in the output buffer to fufill the request. 00210 In this case the miniport should call ScsiPortWmiPostProcess with 00211 a status of SRB_STATUS_DATA_OVERRUN and the size of the output buffer 00212 needed to fufill the request. 00213 00214 BufferAvail on entry has the maximum size available to write the data 00215 blocks in the output buffer. If the output buffer is not large enough 00216 to return all of the data blocks then the miniport should call 00217 ScsiPortWmiPostProcess with a status of SRB_STATUS_DATA_OVERRUN 00218 and the size of the output buffer needed to fufill the request. 00219 00220 Buffer on return is filled with the returned data blocks. Note that each 00221 instance of the data block must be aligned on a 8 byte boundry. This 00222 may be NULL when there is not enough space in the output buffer to 00223 fufill the request. In this case the miniport should call 00224 ScsiPortWmiPostProcess with a status of SRB_STATUS_DATA_OVERRUN and 00225 the size of the output buffer needed to fufill the request. 00226 00227 00228 Return Value: 00229 00230 TRUE if request is pending else FALSE 00231 00232 --*/ 00233 { 00234 PHW_DEVICE_EXTENSION HwDeviceExtension = (PHW_DEVICE_EXTENSION)Context; 00235 ULONG size = 0; 00236 UCHAR status; 00237 00238 // 00239 // Only ever registers 1 instance per guid 00240 ASSERT((InstanceIndex == 0) && 00241 (InstanceCount == 1)); 00242 00243 switch (GuidIndex) 00244 { 00245 case BT958_SETUP_GUID_INDEX: 00246 { 00247 size = sizeof(BT958ExtendedSetupInfo)-1; 00248 if (OutBufferSize < size) 00249 { 00250 // 00251 // The buffer passed to return the data is too small 00252 // 00253 status = SRB_STATUS_DATA_OVERRUN; 00254 break; 00255 } 00256 00257 if ( !BT958ReadExtendedSetupInfo(HwDeviceExtension, 00258 Buffer)) 00259 { 00260 ASSERT(FALSE); 00261 size = 0; 00262 status = SRB_STATUS_ERROR; 00263 } 00264 else 00265 { 00266 *InstanceLengthArray = size; 00267 status = SRB_STATUS_SUCCESS; 00268 } 00269 break; 00270 } 00271 00272 default: 00273 { 00274 status = SRB_STATUS_ERROR; 00275 } 00276 } 00277 00278 ScsiPortWmiPostProcess( RequestContext, 00279 status, 00280 size); 00281 00282 return status; 00283 } 00284 00285 UCHAR 00286 BT958QueryWmiRegInfo( 00287 IN PVOID Context, 00288 IN PSCSIWMI_REQUEST_CONTEXT RequestContext, 00289 OUT PWCHAR *MofResourceName 00290 ) 00291 /*++ 00292 00293 Routine Description: 00294 00295 This routine is a callback into the driver to retrieve information about 00296 the guids being registered. 00297 00298 Implementations of this routine may be in paged memory 00299 00300 Arguments: 00301 00302 DeviceObject is the device whose registration information is needed 00303 00304 *RegFlags returns with a set of flags that describe all of the guids being 00305 registered for this device. If the device wants enable and disable 00306 collection callbacks before receiving queries for the registered 00307 guids then it should return the WMIREG_FLAG_EXPENSIVE flag. Also the 00308 returned flags may specify WMIREG_FLAG_INSTANCE_PDO in which case 00309 the instance name is determined from the PDO associated with the 00310 device object. Note that the PDO must have an associated devnode. If 00311 WMIREG_FLAG_INSTANCE_PDO is not set then Name must return a unique 00312 name for the device. These flags are ORed into the flags specified 00313 by the GUIDREGINFO for each guid. 00314 00315 InstanceName returns with the instance name for the guids if 00316 WMIREG_FLAG_INSTANCE_PDO is not set in the returned *RegFlags. The 00317 caller will call ExFreePool with the buffer returned. 00318 00319 *RegistryPath returns with the registry path of the driver. This is 00320 required 00321 00322 *MofResourceName returns with the name of the MOF resource attached to 00323 the binary file. If the driver does not have a mof resource attached 00324 then this can be returned as NULL. 00325 00326 *Pdo returns with the device object for the PDO associated with this 00327 device if the WMIREG_FLAG_INSTANCE_PDO flag is retured in 00328 *RegFlags. 00329 00330 Return Value: 00331 00332 status 00333 00334 --*/ 00335 { 00336 *MofResourceName = BT958Wmi_MofResourceName; 00337 return SRB_STATUS_SUCCESS; 00338 } 00339 00340 00341 UCHAR 00342 BT958ReadExtendedSetupInfo( 00343 IN PHW_DEVICE_EXTENSION HwDeviceExtension, 00344 OUT PUCHAR Buffer 00345 ) 00346 /*++ 00347 00348 Routine Description: 00349 00350 Read the adapter setup information into the supplied buffer. The buffer 00351 must be RM_CFG_MAX_SIZE (255) bytes large. 00352 00353 Arguments: 00354 00355 HwDeviceExtension - HBA miniport driver's adapter data storage. 00356 00357 Buffer - Buffer to hold adapter's setup information structure [manual 5-10]. 00358 00359 Return Value: 00360 00361 TRUE on success, FALSE on failure. 00362 00363 --*/ 00364 { 00365 UCHAR numberOfBytes = sizeof(BT958ExtendedSetupInfo)-1; 00366 00367 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; 00368 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); 00369 BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation; 00370 BusLogic_RequestedReplyLength_T RequestedReplyLength = sizeof(ExtendedSetupInformation); 00371 BOOLEAN Result = TRUE; 00372 00373 BusLogic_WmiExtendedSetupInformation_T WmiExtendedSetupInfo; 00374 PUCHAR SourceBuf = (PUCHAR) &WmiExtendedSetupInfo; 00375 00376 00377 // 00378 // Issue the Inquire Extended Setup Information command. Only genuine 00379 // BusLogic Host Adapters and TRUE clones support this command. Adaptec 1542C 00380 // series Host Adapters that respond to the Geometry Register I/O port will 00381 // fail this command. 00382 RequestedReplyLength = sizeof(ExtendedSetupInformation); 00383 if (BusLogic_Command(HostAdapter, 00384 BusLogic_InquireExtendedSetupInformation, 00385 &RequestedReplyLength, 00386 sizeof(RequestedReplyLength), 00387 &ExtendedSetupInformation, 00388 sizeof(ExtendedSetupInformation)) 00389 != sizeof(ExtendedSetupInformation)) 00390 { 00391 Result = FALSE; 00392 } 00393 00394 WmiExtendedSetupInfo.BusType = ExtendedSetupInformation.BusType; 00395 WmiExtendedSetupInfo.BIOS_Address = ExtendedSetupInformation.BIOS_Address; 00396 WmiExtendedSetupInfo.ScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit; 00397 WmiExtendedSetupInfo.MailboxCount = ExtendedSetupInformation.MailboxCount; 00398 WmiExtendedSetupInfo.BaseMailboxAddress = ExtendedSetupInformation.BaseMailboxAddress; 00399 WmiExtendedSetupInfo.FastOnEISA = ExtendedSetupInformation.Misc.FastOnEISA; 00400 WmiExtendedSetupInfo.LevelSensitiveInterrupt = ExtendedSetupInformation.Misc.LevelSensitiveInterrupt; 00401 WmiExtendedSetupInfo.FirmwareRevision[0] = ExtendedSetupInformation.FirmwareRevision[0]; 00402 WmiExtendedSetupInfo.FirmwareRevision[1] = ExtendedSetupInformation.FirmwareRevision[1]; 00403 WmiExtendedSetupInfo.FirmwareRevision[2] = ExtendedSetupInformation.FirmwareRevision[2]; 00404 WmiExtendedSetupInfo.HostWideSCSI = ExtendedSetupInformation.HostWideSCSI; 00405 WmiExtendedSetupInfo.HostDifferentialSCSI= ExtendedSetupInformation.HostDifferentialSCSI; 00406 WmiExtendedSetupInfo.HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM; 00407 WmiExtendedSetupInfo.HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI; 00408 WmiExtendedSetupInfo.HostSmartTermination= ExtendedSetupInformation.HostSmartTermination; 00409 00410 for (; numberOfBytes; numberOfBytes--) 00411 { 00412 *Buffer++ = *SourceBuf++; 00413 } 00414 return TRUE; 00415 } 00416 Generated on Sun May 27 2012 04:28:29 for ReactOS by
1.7.6.1
|