Skip to content

Commit f58f37e

Browse files
committed
[COMPBATT] Document the newly added code
1 parent 65b29fe commit f58f37e

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

drivers/bus/acpi/compbatt/compbatt.c

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ CompBattSystemControl(
6767
return Status;
6868
}
6969

70+
/**
71+
* @brief
72+
* Queues a work item thread worker which is bound to the individual
73+
* CM (Control Method) ACPI battery to handle the IRP.
74+
*
75+
* @param[in] DeviceObject
76+
* A pointer to a device object, this parameter is unused.
77+
*
78+
* @param[in] Irp
79+
* A pointer to an I/O request packet. It is used to gather the I/O stack
80+
* location which contains the data of the individual battery.
81+
*
82+
* @param[in] Context
83+
* An aribtrary pointer that points to context data, this paramater
84+
* is unused.
85+
*
86+
* @return
87+
* Returns STATUS_MORE_PROCESSING_REQUIRED to indicate the I/O request
88+
* is still in action, therefore the IRP is not freed.
89+
*/
7090
NTSTATUS
7191
NTAPI
7292
CompBattMonitorIrpComplete(
@@ -89,6 +109,17 @@ CompBattMonitorIrpComplete(
89109
return STATUS_MORE_PROCESSING_REQUIRED;
90110
}
91111

112+
/**
113+
* @brief
114+
* The brains of the battery IRP worker. It monitors the state of the
115+
* IRP as well as sends the IRP down the device stack to gather battery
116+
* related data, such tag and status. It also serves as the I/O
117+
* completion routine of which it elaborates the gathered data.
118+
*
119+
* @param[in] BatteryData
120+
* A pointer to battery data of an individual battery that contains
121+
* the IRP to be send down the device stack.
122+
*/
92123
VOID
93124
NTAPI
94125
CompBattMonitorIrpCompleteWorker(
@@ -481,6 +512,29 @@ CompBattDisableStatusNotify(
481512
return STATUS_SUCCESS;
482513
}
483514

515+
/**
516+
* @brief
517+
* Calculates the total discharging/charging rate flow of each individual
518+
* battery linked with the composite battery and determines whether at
519+
* least one battery is behaving improperly.
520+
*
521+
* @param[in] DeviceExtension
522+
* A pointer to a device extension which describes the composite battery
523+
* itself. It is used to gather each connected battery in the list with
524+
* the composite battery.
525+
*
526+
* @param[out] TotalRate
527+
* A pointer returned to caller that describes the total accumulated
528+
* rate flow of all batteries.
529+
*
530+
* @param[out] BatteriesCount
531+
* A pointer returned to caller that describes the batteries present.
532+
*
533+
* @return
534+
* Returns TRUE if at least one battery is behaving improperly, FALSE
535+
* otherwise. This is determined by the fact if a battery has a negative
536+
* rate but is charging, or if it has a positive rate but is discharging.
537+
*/
484538
static
485539
BOOLEAN
486540
CompBattCalculateTotalRateAndLinkedBatteries(
@@ -590,6 +644,33 @@ CompBattCalculateTotalRateAndLinkedBatteries(
590644
return BadBattery;
591645
}
592646

647+
/**
648+
* @brief
649+
* Sets a new configuration battery wait status settings of each battery.
650+
* The purpose of this is so that the composite battery gets notified
651+
* of new battery status as if it was a single battery.
652+
*
653+
* @param[in] DeviceExtension
654+
* A pointer to a device extension which describes the composite battery
655+
* itself. It is used to gather each connected battery in the list with
656+
* the composite battery.
657+
*
658+
* @param[in] BatteryTag
659+
* A battery tag supplied by the caller. This is typically the tag of
660+
* the composite battery which is used to check against the cached tag
661+
* of the composite battery if it has changed or not.
662+
*
663+
* @param[in] BatteryNotify
664+
* A pointer to a structure filled with battery notification settings,
665+
* supplied by the caller. It is used as the new values for the
666+
* configuration wait settings.
667+
*
668+
* @return
669+
* Returns STATUS_NO_SUCH_DEVICE if the supplied battery tag does not match
670+
* with that of the cached composite battery's tag or if the composite
671+
* battery currently does not have a tag assigned. Otherwise STATUS_SUCCESS
672+
* is returned.
673+
*/
593674
NTSTATUS
594675
NTAPI
595676
CompBattSetStatusNotify(
@@ -819,6 +900,33 @@ CompBattSetStatusNotify(
819900
return STATUS_SUCCESS;
820901
}
821902

903+
/**
904+
* @brief
905+
* Queries the battery status of each individiual connected battery with
906+
* the composite battery and combines all the retrieved data as one
907+
* single battery status for the composite battery.
908+
*
909+
* @param[in] DeviceExtension
910+
* A pointer to a device extension which describes the composite battery
911+
* itself. It is used to gather each connected battery in the list with
912+
* the composite battery.
913+
*
914+
* @param[in] Tag
915+
* A battery tag supplied by the caller. This is typically the tag of
916+
* the composite battery which is used to check against the cached tag
917+
* of the composite battery if it has changed or not.
918+
*
919+
* @param[out] BatteryStatus
920+
* A pointer to a battery status that contains the combined data, returned
921+
* to the caller. It serves as the battery status for the composite battery.
922+
*
923+
* @return
924+
* Returns STATUS_NO_SUCH_DEVICE if the supplied battery tag does not match
925+
* with that of the cached composite battery's tag or if the composite
926+
* battery currently does not have a tag assigned. Otherwise STATUS_SUCCESS
927+
* is returned, which it will also return success if the composite battery's
928+
* cached battery status is fresh which indicates it has already been computed.
929+
*/
822930
NTSTATUS
823931
NTAPI
824932
CompBattQueryStatus(
@@ -1282,6 +1390,20 @@ CompBattGetBatteryGranularity(
12821390
return STATUS_SUCCESS;
12831391
}
12841392

1393+
/**
1394+
* @brief
1395+
* Calculates the "At Rate" flow of the composite battery based on the
1396+
* sum of all connected batteries, in order to retrieve the precise
1397+
* battery time estimation.
1398+
*
1399+
* @param[in] DeviceExtension
1400+
* A pointer to a device extension which describes the composite battery
1401+
* itself. It is used to gather each connected battery in the list with
1402+
* the composite battery.
1403+
*
1404+
* @return
1405+
* Returns the computed "At Rate" flow to the caller.
1406+
*/
12851407
static
12861408
LONG
12871409
CompBattCalculateAtRateTime(
@@ -1351,6 +1473,28 @@ CompBattCalculateAtRateTime(
13511473
return ComputedAtRate;
13521474
}
13531475

1476+
/**
1477+
* @brief
1478+
* Retrieves the estimated time of the composite battery based on the
1479+
* power drain rate of all the batteries present in the system.
1480+
*
1481+
* @param[out] Time
1482+
* A pointer to the computed estimated time of the composite battery,
1483+
* returned to caller. Note that if there are not any batteries that
1484+
* are draining power, or if the system is powered by external AC source,
1485+
* the estimated time is unknown
1486+
*
1487+
* @param[in] DeviceExtension
1488+
* A pointer to a device extension which describes the composite battery
1489+
* itself. It is used to gather each connected battery in the list with
1490+
* the composite battery.
1491+
*
1492+
* @return
1493+
* Returns STATUS_NO_SUCH_DEVICE if the supplied battery tag does not match
1494+
* with that of the cached composite battery's tag or if the composite
1495+
* battery currently does not have a tag assigned. Otherwise STATUS_SUCCESS
1496+
* is returned.
1497+
*/
13541498
NTSTATUS
13551499
NTAPI
13561500
CompBattGetEstimatedTime(

0 commit comments

Comments
 (0)