Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencompbatt.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Composite Battery Driver 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: boot/drivers/bus/acpi/compbatt/compbatt.c 00005 * PURPOSE: Main Initialization Code and IRP Handling 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include "compbatt.h" 00012 00013 /* GLOBALS ********************************************************************/ 00014 00015 ULONG CompBattDebug; 00016 00017 /* FUNCTIONS ******************************************************************/ 00018 00019 NTSTATUS 00020 NTAPI 00021 CompBattOpenClose(IN PDEVICE_OBJECT DeviceObject, 00022 IN PIRP Irp) 00023 { 00024 PAGED_CODE(); 00025 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING OpenClose\n"); 00026 00027 /* Complete the IRP with success */ 00028 Irp->IoStatus.Status = STATUS_SUCCESS; 00029 Irp->IoStatus.Information = 0; 00030 IoCompleteRequest(Irp, IO_NO_INCREMENT); 00031 00032 /* Return success */ 00033 if (CompBattDebug & 0x100) DbgPrint("CompBatt: Exiting OpenClose\n"); 00034 return STATUS_SUCCESS; 00035 } 00036 00037 NTSTATUS 00038 NTAPI 00039 CompBattSystemControl(IN PDEVICE_OBJECT DeviceObject, 00040 IN PIRP Irp) 00041 { 00042 PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; 00043 NTSTATUS Status; 00044 PAGED_CODE(); 00045 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING System Control\n"); 00046 00047 /* Are we attached yet? */ 00048 if (DeviceExtension->AttachedDevice) 00049 { 00050 /* Send it up the stack */ 00051 IoSkipCurrentIrpStackLocation(Irp); 00052 Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); 00053 } 00054 else 00055 { 00056 /* We don't support WMI */ 00057 Status = STATUS_NOT_SUPPORTED; 00058 Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; 00059 IoCompleteRequest(Irp, IO_NO_INCREMENT); 00060 } 00061 00062 /* Return status */ 00063 return Status; 00064 } 00065 00066 NTSTATUS 00067 NTAPI 00068 CompBattMonitorIrpComplete(IN PDEVICE_OBJECT DeviceObject, 00069 IN PIRP Irp, 00070 IN PKEVENT Event) 00071 { 00072 UNIMPLEMENTED; 00073 return STATUS_NOT_IMPLEMENTED; 00074 } 00075 00076 NTSTATUS 00077 NTAPI 00078 CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_DATA BatteryData) 00079 { 00080 UNIMPLEMENTED; 00081 return STATUS_NOT_IMPLEMENTED; 00082 } 00083 00084 VOID 00085 NTAPI 00086 CompBattRecalculateTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) 00087 { 00088 PCOMPBATT_BATTERY_DATA BatteryData; 00089 ULONG Tag; 00090 PLIST_ENTRY ListHead, NextEntry; 00091 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING CompBattRecalculateTag\n"); 00092 00093 /* Loop the battery list */ 00094 ExAcquireFastMutex(&DeviceExtension->Lock); 00095 ListHead = &DeviceExtension->BatteryList; 00096 NextEntry = ListHead->Flink; 00097 while (NextEntry != ListHead) 00098 { 00099 /* Get the battery information and check if it has a tag */ 00100 BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); 00101 if (BatteryData->Flags & COMPBATT_TAG_ASSIGNED) 00102 { 00103 /* Generate the next tag and exit */ 00104 Tag = DeviceExtension->NextTag; 00105 DeviceExtension->Flags |= COMPBATT_TAG_ASSIGNED; 00106 DeviceExtension->Tag = Tag; 00107 DeviceExtension->NextTag = Tag + 1; 00108 break; 00109 } 00110 00111 /* No tag for this device extension, clear it */ 00112 DeviceExtension->Tag = 0; 00113 NextEntry = NextEntry->Flink; 00114 } 00115 00116 /* We're done */ 00117 ExReleaseFastMutex(&DeviceExtension->Lock); 00118 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING CompBattRecalculateTag\n"); 00119 } 00120 00121 NTSTATUS 00122 NTAPI 00123 CompBattIoctl(IN PDEVICE_OBJECT DeviceObject, 00124 IN PIRP Irp) 00125 { 00126 PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; 00127 NTSTATUS Status; 00128 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING Ioctl\n"); 00129 00130 /* Let the class driver handle it */ 00131 Status = BatteryClassIoctl(DeviceExtension->ClassData, Irp); 00132 if (Status == STATUS_NOT_SUPPORTED) 00133 { 00134 /* It failed, try the next driver up the stack */ 00135 Irp->IoStatus.Status = Status; 00136 IoSkipCurrentIrpStackLocation(Irp); 00137 Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); 00138 } 00139 00140 /* Return status */ 00141 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING Ioctl\n"); 00142 return Status; 00143 } 00144 00145 NTSTATUS 00146 NTAPI 00147 CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, 00148 OUT PULONG Tag) 00149 { 00150 NTSTATUS Status; 00151 PAGED_CODE(); 00152 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING QueryTag\n"); 00153 00154 /* Was a tag assigned? */ 00155 if (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED)) 00156 { 00157 /* Assign one */ 00158 CompBattRecalculateTag(DeviceExtension); 00159 } 00160 00161 /* Do we have a tag now? */ 00162 if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && (DeviceExtension->Tag)) 00163 { 00164 /* Return the tag */ 00165 *Tag = DeviceExtension->Tag; 00166 Status = STATUS_SUCCESS; 00167 } 00168 else 00169 { 00170 /* No tag */ 00171 *Tag = 0; 00172 Status = STATUS_NO_SUCH_DEVICE; 00173 } 00174 00175 /* Return status */ 00176 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING QueryTag\n"); 00177 return Status; 00178 } 00179 00180 NTSTATUS 00181 NTAPI 00182 CompBattDisableStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) 00183 { 00184 PCOMPBATT_BATTERY_DATA BatteryData; 00185 PLIST_ENTRY ListHead, NextEntry; 00186 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n"); 00187 00188 /* Loop the battery list */ 00189 ExAcquireFastMutex(&DeviceExtension->Lock); 00190 ListHead = &DeviceExtension->BatteryList; 00191 NextEntry = ListHead->Flink; 00192 while (NextEntry != ListHead) 00193 { 00194 /* Get the battery information and clear capacity data */ 00195 BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); 00196 BatteryData->WaitStatus.LowCapacity = 0; 00197 BatteryData->WaitStatus.HighCapacity = 0x7FFFFFFF; 00198 NextEntry = NextEntry->Flink; 00199 } 00200 00201 /* Done */ 00202 ExReleaseFastMutex(&DeviceExtension->Lock); 00203 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING DisableStatusNotify\n"); 00204 return STATUS_SUCCESS; 00205 } 00206 00207 NTSTATUS 00208 NTAPI 00209 CompBattSetStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, 00210 IN ULONG BatteryTag, 00211 IN PBATTERY_NOTIFY BatteryNotify) 00212 { 00213 UNIMPLEMENTED; 00214 return STATUS_NOT_IMPLEMENTED; 00215 } 00216 00217 NTSTATUS 00218 NTAPI 00219 CompBattQueryStatus(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, 00220 IN ULONG Tag, 00221 IN PBATTERY_STATUS BatteryStatus) 00222 { 00223 UNIMPLEMENTED; 00224 return STATUS_NOT_IMPLEMENTED; 00225 } 00226 00227 NTSTATUS 00228 NTAPI 00229 CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInfo, 00230 IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) 00231 { 00232 NTSTATUS Status = STATUS_SUCCESS; 00233 BATTERY_QUERY_INFORMATION InputBuffer; 00234 PCOMPBATT_BATTERY_DATA BatteryData; 00235 PLIST_ENTRY ListHead, NextEntry; 00236 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryInformation\n"); 00237 00238 /* Set defaults */ 00239 BatteryInfo->DefaultAlert1 = 0; 00240 BatteryInfo->DefaultAlert2 = 0; 00241 BatteryInfo->CriticalBias = 0; 00242 00243 /* Loop the battery list */ 00244 ExAcquireFastMutex(&DeviceExtension->Lock); 00245 ListHead = &DeviceExtension->BatteryList; 00246 NextEntry = ListHead->Flink; 00247 while (NextEntry != ListHead) 00248 { 00249 /* Try to acquire the remove lock */ 00250 BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); 00251 if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0))) 00252 { 00253 /* Now release the device lock since the battery can't go away */ 00254 ExReleaseFastMutex(&DeviceExtension->Lock); 00255 00256 /* Build the query */ 00257 InputBuffer.BatteryTag = BatteryData->Tag; 00258 InputBuffer.InformationLevel = BatteryInformation; 00259 InputBuffer.AtRate = 0; 00260 00261 /* Make sure the battery has a tag */ 00262 if (BatteryData->Tag) 00263 { 00264 /* Do we already have the data? */ 00265 if (!(BatteryData->Flags & COMPBATT_BATTERY_INFORMATION_PRESENT)) 00266 { 00267 /* Send the IOCTL to query the information */ 00268 RtlZeroMemory(&BatteryData->BatteryInformation, 00269 sizeof(BatteryData->BatteryInformation)); 00270 Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION, 00271 BatteryData->DeviceObject, 00272 &InputBuffer, 00273 sizeof(InputBuffer), 00274 &BatteryData->BatteryInformation, 00275 sizeof(BatteryData->BatteryInformation), 00276 0); 00277 if (!NT_SUCCESS(Status)) 00278 { 00279 /* Fail if the query had a problem */ 00280 if (Status == STATUS_DEVICE_REMOVED) Status = STATUS_NO_SUCH_DEVICE; 00281 ExAcquireFastMutex(&DeviceExtension->Lock); 00282 IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); 00283 break; 00284 } 00285 00286 /* Next time we can use the static copy */ 00287 BatteryData->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT; 00288 if (CompBattDebug & 2) 00289 DbgPrint("CompBattGetBatteryInformation: Read individual BATTERY_INFORMATION\n" 00290 "-------- Capabilities = %x\n-------- Technology = %x\n" 00291 "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n" 00292 "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n" 00293 "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n" 00294 "-------- CycleCount = %x\n", 00295 BatteryData->BatteryInformation.Capabilities, 00296 BatteryData->BatteryInformation.Technology, 00297 BatteryData->BatteryInformation.Chemistry, 00298 BatteryData->BatteryInformation.DesignedCapacity, 00299 BatteryData->BatteryInformation.FullChargedCapacity, 00300 BatteryData->BatteryInformation.DefaultAlert1, 00301 BatteryData->BatteryInformation.DefaultAlert2, 00302 BatteryData->BatteryInformation.CriticalBias, 00303 BatteryData->BatteryInformation.CycleCount); 00304 } 00305 00306 /* Combine capabilities */ 00307 BatteryInfo->Capabilities |= BatteryData->BatteryInformation.Capabilities; 00308 00309 /* Add-on capacity */ 00310 if (BatteryData->BatteryInformation.DesignedCapacity != BATTERY_UNKNOWN_CAPACITY) 00311 { 00312 BatteryInfo->DesignedCapacity += BatteryData->BatteryInformation.DesignedCapacity; 00313 } 00314 00315 /* Add on fully charged capacity */ 00316 if (BatteryData->BatteryInformation.FullChargedCapacity != BATTERY_UNKNOWN_CAPACITY) 00317 { 00318 BatteryInfo->FullChargedCapacity += BatteryData->BatteryInformation.FullChargedCapacity; 00319 } 00320 00321 /* Choose the highest alert */ 00322 BatteryInfo->DefaultAlert1 = max(BatteryInfo->DefaultAlert1, 00323 BatteryData->BatteryInformation.DefaultAlert1); 00324 00325 /* Choose the highest alert */ 00326 BatteryInfo->DefaultAlert2 = max(BatteryInfo->DefaultAlert2, 00327 BatteryData->BatteryInformation.DefaultAlert2); 00328 00329 /* Choose the highest critical bias */ 00330 BatteryInfo->CriticalBias = max(BatteryInfo->CriticalBias, 00331 BatteryData->BatteryInformation.CriticalBias); 00332 } 00333 00334 /* Re-acquire the device extension lock and release the remove lock */ 00335 ExAcquireFastMutex(&DeviceExtension->Lock); 00336 IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); 00337 } 00338 00339 /* Next entry */ 00340 NextEntry = NextEntry->Flink; 00341 } 00342 00343 /* We are done with the list, check if the information was queried okay */ 00344 ExReleaseFastMutex(&DeviceExtension->Lock); 00345 if (NT_SUCCESS(Status)) 00346 { 00347 /* If there's no fully charged capacity, use the design capacity */ 00348 if (!BatteryInfo->FullChargedCapacity) 00349 { 00350 BatteryInfo->FullChargedCapacity = BatteryInfo->DesignedCapacity; 00351 } 00352 00353 /* Print out final combined data */ 00354 if (CompBattDebug & 2) 00355 DbgPrint("CompBattGetBatteryInformation: Returning BATTERY_INFORMATION\n" 00356 "-------- Capabilities = %x\n-------- Technology = %x\n" 00357 "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n" 00358 "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n" 00359 "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n" 00360 "-------- CycleCount = %x\n", 00361 BatteryInfo->Capabilities, 00362 BatteryInfo->Technology, 00363 BatteryInfo->Chemistry, 00364 BatteryInfo->DesignedCapacity, 00365 BatteryInfo->FullChargedCapacity, 00366 BatteryInfo->DefaultAlert1, 00367 BatteryInfo->DefaultAlert2, 00368 BatteryInfo->CriticalBias, 00369 BatteryInfo->CycleCount); 00370 00371 /* Copy the data into the device extension */ 00372 RtlCopyMemory(&DeviceExtension->BatteryInformation, 00373 BatteryInfo, 00374 sizeof(DeviceExtension->BatteryInformation)); 00375 DeviceExtension->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT; 00376 } 00377 00378 /* We are done */ 00379 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryInformation\n"); 00380 return Status; 00381 } 00382 00383 NTSTATUS 00384 NTAPI 00385 CompBattGetBatteryGranularity(OUT PBATTERY_REPORTING_SCALE ReportingScale, 00386 IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) 00387 { 00388 NTSTATUS Status = STATUS_SUCCESS; 00389 BATTERY_QUERY_INFORMATION InputBuffer; 00390 PCOMPBATT_BATTERY_DATA BatteryData; 00391 BATTERY_REPORTING_SCALE BatteryScale[4]; 00392 PLIST_ENTRY ListHead, NextEntry; 00393 ULONG i; 00394 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryGranularity\n"); 00395 00396 /* Set defaults */ 00397 ReportingScale[0].Granularity = -1; 00398 ReportingScale[1].Granularity = -1; 00399 ReportingScale[2].Granularity = -1; 00400 ReportingScale[3].Granularity = -1; 00401 00402 /* Loop the battery list */ 00403 ExAcquireFastMutex(&DeviceExtension->Lock); 00404 ListHead = &DeviceExtension->BatteryList; 00405 NextEntry = ListHead->Flink; 00406 while (NextEntry != ListHead) 00407 { 00408 /* Try to acquire the remove lock */ 00409 BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); 00410 if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0))) 00411 { 00412 /* Now release the device lock since the battery can't go away */ 00413 ExReleaseFastMutex(&DeviceExtension->Lock); 00414 00415 /* Build the query */ 00416 InputBuffer.BatteryTag = BatteryData->Tag; 00417 InputBuffer.InformationLevel = BatteryGranularityInformation; 00418 00419 /* Make sure the battery has a tag */ 00420 if (BatteryData->Tag) 00421 { 00422 /* Send the IOCTL to query the information */ 00423 RtlZeroMemory(&BatteryData->BatteryInformation, 00424 sizeof(BatteryData->BatteryInformation)); 00425 Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION, 00426 BatteryData->DeviceObject, 00427 &InputBuffer, 00428 sizeof(InputBuffer), 00429 &BatteryScale, 00430 sizeof(BatteryScale), 00431 0); 00432 if (!NT_SUCCESS(Status)) 00433 { 00434 /* Fail if the query had a problem */ 00435 ExAcquireFastMutex(&DeviceExtension->Lock); 00436 IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); 00437 break; 00438 } 00439 00440 /* Loop all 4 scales */ 00441 for (i = 0; i < 4; i++) 00442 { 00443 /* Check for valid granularity */ 00444 if (BatteryScale[i].Granularity) 00445 { 00446 /* If it's smaller, use it instead */ 00447 ReportingScale[i].Granularity = min(BatteryScale[i].Granularity, 00448 ReportingScale[i].Granularity); 00449 } 00450 00451 } 00452 } 00453 00454 /* Re-acquire the device extension lock and release the remove lock */ 00455 ExAcquireFastMutex(&DeviceExtension->Lock); 00456 IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); 00457 } 00458 00459 /* Next entry */ 00460 NextEntry = NextEntry->Flink; 00461 } 00462 00463 /* All done */ 00464 ExReleaseFastMutex(&DeviceExtension->Lock); 00465 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryGranularity\n"); 00466 return STATUS_SUCCESS; 00467 } 00468 00469 NTSTATUS 00470 NTAPI 00471 CompBattGetEstimatedTime(OUT PULONG Time, 00472 IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) 00473 { 00474 UNIMPLEMENTED; 00475 return STATUS_NOT_IMPLEMENTED; 00476 } 00477 00478 NTSTATUS 00479 NTAPI 00480 CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, 00481 IN ULONG Tag, 00482 IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, 00483 IN OPTIONAL LONG AtRate, 00484 IN PVOID Buffer, 00485 IN ULONG BufferLength, 00486 OUT PULONG ReturnedLength) 00487 { 00488 BATTERY_INFORMATION BatteryInfo; 00489 BATTERY_REPORTING_SCALE BatteryGranularity[4]; 00490 PWCHAR BatteryName = L"Composite Battery"; 00491 //BATTERY_MANUFACTURE_DATE Date; 00492 ULONG Dummy, Time; 00493 PVOID QueryData = NULL; 00494 ULONG QueryLength = 0; 00495 NTSTATUS Status = STATUS_SUCCESS; 00496 PAGED_CODE(); 00497 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING QueryInformation\n"); 00498 00499 /* Check for valid/correct tag */ 00500 if ((Tag != DeviceExtension->Tag) || 00501 (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED))) 00502 { 00503 /* Not right, so fail */ 00504 return STATUS_NO_SUCH_DEVICE; 00505 } 00506 00507 /* Check what caller wants */ 00508 switch (InfoLevel) 00509 { 00510 case BatteryInformation: 00511 00512 /* Query combined battery information */ 00513 RtlZeroMemory(&BatteryInfo, sizeof(BatteryInfo)); 00514 Status = CompBattGetBatteryInformation(&BatteryInfo, DeviceExtension); 00515 if (NT_SUCCESS(Status)) 00516 { 00517 /* Return the data if successful */ 00518 QueryData = &BatteryInfo; 00519 QueryLength = sizeof(BatteryInfo); 00520 } 00521 break; 00522 00523 case BatteryGranularityInformation: 00524 00525 /* Query combined granularity information */ 00526 RtlZeroMemory(&BatteryGranularity, sizeof(BatteryGranularity)); 00527 Status = CompBattGetBatteryGranularity(BatteryGranularity, DeviceExtension); 00528 if (NT_SUCCESS(Status)) 00529 { 00530 /* Return the data if successful */ 00531 QueryLength = sizeof(BatteryGranularity); 00532 QueryData = &BatteryGranularity; 00533 } 00534 break; 00535 00536 case BatteryEstimatedTime: 00537 00538 /* Query combined time estimate information */ 00539 RtlZeroMemory(&Time, sizeof(Time)); 00540 Status = CompBattGetEstimatedTime(&Time, DeviceExtension); 00541 if (NT_SUCCESS(Status)) 00542 { 00543 /* Return the data if successful */ 00544 QueryLength = sizeof(Time); 00545 QueryData = &Time; 00546 } 00547 break; 00548 00549 case BatteryManufactureName: 00550 case BatteryDeviceName: 00551 00552 /* Return the static buffer */ 00553 QueryData = BatteryName; 00554 QueryLength = sizeof(L"Composite Battery"); 00555 break; 00556 00557 case BatteryManufactureDate: 00558 00559 /* Static data */ 00560 //Date.Day = 26; 00561 //Date.Month = 06; 00562 //Date.Year = 1997; 00563 break; 00564 00565 case BatteryTemperature: 00566 case BatteryUniqueID: 00567 00568 /* Return zero */ 00569 Dummy = 0; 00570 QueryData = &Dummy; 00571 QueryLength = sizeof(Dummy); 00572 break; 00573 00574 default: 00575 /* Everything else is unknown */ 00576 Status = STATUS_INVALID_PARAMETER; 00577 break; 00578 } 00579 00580 /* Return the required length and check if the caller supplied enough */ 00581 *ReturnedLength = QueryLength; 00582 if (BufferLength < QueryLength) Status = STATUS_BUFFER_TOO_SMALL; 00583 00584 /* Copy the data if there's enough space and it exists */ 00585 if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength); 00586 00587 /* Return function result */ 00588 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING QueryInformation\n"); 00589 return Status; 00590 } 00591 00592 NTSTATUS 00593 NTAPI 00594 DriverEntry(IN PDRIVER_OBJECT DriverObject, 00595 IN PUNICODE_STRING RegistryPath) 00596 { 00597 /* Register add device routine */ 00598 DriverObject->DriverExtension->AddDevice = CompBattAddDevice; 00599 00600 /* Register other handlers */ 00601 DriverObject->MajorFunction[IRP_MJ_CREATE] = CompBattOpenClose; 00602 DriverObject->MajorFunction[IRP_MJ_CLOSE] = CompBattOpenClose; 00603 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CompBattIoctl; 00604 DriverObject->MajorFunction[IRP_MJ_POWER] = CompBattPowerDispatch; 00605 DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CompBattSystemControl; 00606 DriverObject->MajorFunction[IRP_MJ_PNP] = CompBattPnpDispatch; 00607 return STATUS_SUCCESS; 00608 } 00609 00610 /* EOF */ Generated on Sat May 26 2012 04:25:59 for ReactOS by
1.7.6.1
|