pass: Add detailed description for all modules with doxygen style 98/191598/1
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 12 Sep 2018 07:13:32 +0000 (16:13 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 19 Oct 2018 00:03:37 +0000 (09:03 +0900)
PASS(Power Aware System Serivce) provides the multiple modules like CPUHP,
PMQoS, Thermal Monitor and defines the various structure/enumeration.
In order to improve the readability and the understanding of each unit,
add the detailed description for all modules/functions/structures/enumerations
by using doxygen[1] style.

[1] http://www.doxygen.nl/

Change-Id: I0444a95fb31b7a1ac20c451dda16dcc8791ae30a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
24 files changed:
src/hal/hal.c
src/pass/pass-cpuhp-radiation.c
src/pass/pass-cpuhp-step.c
src/pass/pass-cpuhp.c
src/pass/pass-hal.c
src/pass/pass-hal.h
src/pass/pass-parser.c
src/pass/pass-parser.h
src/pass/pass-pmqos.c
src/pass/pass-rescon.c
src/pass/pass-rescon.h
src/pass/pass-resmon-internal.h
src/pass/pass-resmon-source.c
src/pass/pass-resmon.c
src/pass/pass-resmon.h
src/pass/pass-thermal.c
src/pass/pass.c
src/pass/pass.h
src/pmqos/pmqos-parser.c
src/pmqos/pmqos.c
src/pmqos/pmqos.h
src/thermal/thermal-parser.c
src/thermal/thermal.c
src/thermal/thermal.h

index beadab57dc0fcd6cf9a1a6a91dbeb893673bdda2..0b2cffad54cc5e8dd6769cfd3d7813896c907b24 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       hal.c
+ * @brief      Provide a helper function to load shared library, like cpu.so
+ *             /gpu.so/bus.so etc, from HAL (Hardware Abstract Layer)
+ *             package according to the type of h/w resource.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
index 362c0b3d4df8db75cde0dfd727bdf8dc1e9aff68..058c251ab44724b0258f0b3e69c73d72a92dcb8b 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-cpuhp-radiation.c
+ * @brief      Decide the next proper amount of h/w resource by using the
+ *             collected system status through PASS_MODULE_RESMON. It is one
+ *             of CPUHP (CPU Core On/Off Manager) governors. It has the their
+ *             own governor method called 'radiation'. It is usually used
+ *             for quad-core cluster.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #define PASS_CPU_STATS_MAX_COUNT       20
 
-/*
- * pass_cpuhp_radiation_governor - Check cpu state and determine the amount of resource
- *
- * @res: the instance of struct pass_resource.
- * @result: the result of resource monitoring.
+/**
+ * @brief      Check CPU state and determine the proper amount of h/w resource
+ *             It checks periodically current status of system and then
+ *             determine whether pass_level up or down according to pass policy
+ *             with gathered data. Governor name is 'step'.
  *
- * This function check periodically current following state of system
- * and then determine whether pass level up or down according to pass
- * policy with gathered data.
- * - current cpu frequency
- * - the number of nr_running
- * - the number of busy_cpu
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] result Collected system status through PASS_MODULE_RESMON
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_cpuhp_radiation_governor(struct pass_resource *res, void *result)
 {
index a86a03049265d5d3e76d580c862d39883f2080a5..405deb504ff2a489baaed9994a7e17a36ed55589 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-cpuhp-step.c
+ * @brief      Decide the next proper amount of h/w resource by using the
+ *             collected system status through PASS_MODULE_RESMON. It is one
+ *             of CPUHP (CPU Core On/Off Manager) governors. It has the their
+ *             own governor method called 'step'. It is usually used
+ *             for dual-core cluster.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #define PASS_CPU_STATS_MAX_COUNT       20
 
-/*
- * pass_cpuhp_step_governor - Check cpu state and determine the amount of resource
- *
- * @res: the instance of struct pass_resource.
- * @result: the result of resource monitoring.
+/**
+ * @brief      Check CPU state and determine the proper amount of h/w resource
+ *             It checks periodically current status of system and then
+ *             determine whether pass_level up or down according to pass policy
+ *             with gathered data. Governor name is 'radiation'.
  *
- * This function check periodically current following state of system
- * and then determine whether pass level up or down according to pass
- * policy with gathered data.
- * - current cpu frequency
- * - the number of nr_running
- * - the number of busy_cpu
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] result Collected system status through PASS_MODULE_RESMON
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_cpuhp_step_governor(struct pass_resource *res, void *result)
 {
index a74b321b40b26af8ca923a0c6aaa57f8a942d02e..dfc453638aceb4cb1c91a4dec39cd8b7476c7a7b 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-cpuhp.c
+ * @brief      Provide CPUHP(CPU Core On/Off Manager) module for the multicore
+ *             system. Emphasize either power-consumption or performance
+ *             (or even balanced). It uses pass-resmon in order to monitor
+ *             the current system status and then the collected data offer to
+ *             one of pass-cpuhp-* governor like pass-cpuhp-radiation.
+ *
+ *             Provide common interface for CPUHP and then use the specific
+ *             CPUHP governor like pass-cpuhp-radiation selected by
+ *             configuration.
+ *
+ *             Selected pass-cpuhp-* governor decides the next proper amount
+ *             of h/w resources like the number of online CPU and maximum CPU
+ *             frequency. After that pass-cpuhp calls the function of
+ *             pass-rescon in order to change the value of h/w resources like
+ *             frequency, the number of online CPU and so on.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -37,13 +57,27 @@ static int cpuhp_governor_update(struct pass_resource *, enum pass_state);
 #define PASS_DEFAULT_LEVEL_DOWN_THRESHOLD      80
 #define PASS_CPU_STATS_MAX_COUNT       20
 
+/**
+ * @brief      Represent the governor of PASS_MODULE_CPUHP(CPU Core On/Off
+ *             Manager) module.
+ */
 struct pass_cpuhp_governor {
+       /** Governor name */
        char name[BUFF_MAX];
+       /** Governor enabled state */
        enum pass_state state;
 
+       /** Function pointer for initializing governor */
        int (*init)(struct pass_resource *res);
+       /** Function pointer for exiting governor */
        int (*exit)(struct pass_resource *res);
+       /** Function pointer for updating governor */
        int (*update)(struct pass_resource *res, enum pass_state state);
+       /** Function pointer for deciding the next pass_level  */
+       /**
+        * Function pointer for deciding the next proper amount of h/w resource
+        * by using the collected system status through PASS_MODULE_RESMON.
+        */
        int (*governor)(struct pass_resource *res, void *result);
 };
 
@@ -55,6 +89,13 @@ static bool is_enabled(struct pass_cpuhp *cpuhp)
        return true;
 }
 
+/**
+ * @brief      Decide whether CPU is busy or not. When deciding it, the
+ *             collected system status through PASS_MODULE_RESMON are used.
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] result Collected system status through PASS_MODULE_RESMON
+ * @return     N/A
+ */
 static void cpuhp_calculate_busy_cpu(struct pass_resource *res, void *result)
 {
        struct pass_cpuhp *cpuhp = &res->cpuhp;
@@ -117,6 +158,14 @@ static void cpuhp_calculate_busy_cpu(struct pass_resource *res, void *result)
        }
 }
 
+
+/**
+ * @brief      Get the next pass_level from the governor of PASS_MODULE_CPUHP.
+ *             It is the callback function of periodic time.
+ * @param      [in] result Collected system status through PASS_MODULE_RESMON
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int cpuhp_timer_func(void *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -169,6 +218,11 @@ static int cpuhp_timer_func(void *result, void *user_data)
        return TRUE;
 }
 
+/**
+ * @brief      Start the governor of PASS_MODULE_CPUHP
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
+ */
 static void cpuhp_governor_start(struct pass_resource *res)
 {
        struct pass_cpuhp *cpuhp = &res->cpuhp;
@@ -199,6 +253,11 @@ static void cpuhp_governor_start(struct pass_resource *res)
        cpuhp->state = PASS_ON;
 }
 
+/**
+ * @brief      Stop the governor of PASS_MODULE_CPUHP
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
+ */
 static void cpuhp_governor_stop(struct pass_resource *res)
 {
        struct pass_cpuhp *cpuhp = &res->cpuhp;
@@ -220,6 +279,11 @@ static void cpuhp_governor_stop(struct pass_resource *res)
        cpuhp->state = PASS_OFF;
 }
 
+/**
+ * @brief      Initialize the governor of PASS_MODULE_CPUHP
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
+ */
 static int cpuhp_governor_init(struct pass_resource *res)
 {
        struct pass_cpuhp *cpuhp = &res->cpuhp;
@@ -239,6 +303,11 @@ static int cpuhp_governor_init(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Exit the governor of PASS_MODULE_CPUHP
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
+ */
 static int cpuhp_governor_exit(struct pass_resource *res)
 {
        struct pass_cpuhp *cpuhp = &res->cpuhp;
@@ -258,6 +327,11 @@ static int cpuhp_governor_exit(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Enable or disable the governor of PASS_MODULE_CPUHP
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
+ */
 static int cpuhp_governor_update(struct pass_resource *res,
                        enum pass_state state)
 {
@@ -276,11 +350,9 @@ static int cpuhp_governor_update(struct pass_resource *res,
        return 0;
 }
 
-/*
- * Define CPUHP governor
- *
- * - Step governor
- * - Radiation governor
+/**
+ * @brief      Represent the implementation of 'dummy' governor
+ *             for PASS_MODULE_CPUHP
  */
 static struct pass_cpuhp_governor pass_gov_dummy = {
        .name           = "pass_dummy",
@@ -290,6 +362,10 @@ static struct pass_cpuhp_governor pass_gov_dummy = {
        .governor       = NULL,
 };
 
+/**
+ * @brief      Represent the implementation of 'step' governor
+ *             for PASS_MODULE_CPUHP
+ */
 static struct pass_cpuhp_governor pass_gov_step = {
        .name           = "pass_step",
        .init           = cpuhp_governor_init,
@@ -298,6 +374,10 @@ static struct pass_cpuhp_governor pass_gov_step = {
        .governor       = pass_cpuhp_step_governor,
 };
 
+/**
+ * @brief      Represent the implementation of 'radiation' governor
+ *             for PASS_MODULE_CPUHP
+ */
 static struct pass_cpuhp_governor pass_gov_radiation = {
        .name           = "pass_radiation",
        .init           = cpuhp_governor_init,
@@ -306,9 +386,11 @@ static struct pass_cpuhp_governor pass_gov_radiation = {
        .governor       = pass_cpuhp_radiation_governor,
 };
 
-/*
- * pass_get_governor - Return specific governor instance according to type
- * @type: the type of PASS governor
+/**
+ * @brief      Return specific governor instance according to governor type
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] type Governor type of PASS_MODULE_CPUHP
+ * @return     @c instance is not NULL on success, otherwise error value
  */
 static struct pass_cpuhp_governor* cpuhp_get_governor(struct pass_resource *res,
                                                enum pass_gov_type type)
@@ -334,10 +416,10 @@ static struct pass_cpuhp_governor* cpuhp_get_governor(struct pass_resource *res,
        return NULL;
 }
 
-/*
- * pass_cpuhp_init - Initialize CPUHP (CPU Hotplug Manager) module
- *
- * @res: the instance of struct pass_resource
+/**
+ * @brief      Initialize PASS_MODULE_CPUHP(CPU Core On/Off Manager) module
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_cpuhp_init(struct pass_resource *res)
 {
@@ -392,10 +474,10 @@ int pass_cpuhp_init(struct pass_resource *res)
        return cpuhp->governor->init(res);
 }
 
-/*
- * pass_cpuhp_exit - Exit CPUHP (CPU Hotplug Manager) module
- *
- * @res: the instance of struct pass_resource
+/**
+ * @brief      Exit PASS_MODULE_CPUHP(CPU Core On/Off Manager) module
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_cpuhp_exit(struct pass_resource *res)
 {
index 1df19127f15675fb7e012876b04c22d14a81dc5a..05909ecb228dd7fb1d1ab4bafc99ce0c55e437b0 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-hal.c
+ * @brief      Define HAL(Hardware Abstract Layer) interface for PASS HAL
+ *             package because each h/w board has the different amount of
+ *             h/w resource and different interface to handle h/w them.
+ *             Also, provide the HAL helper functions to handle the various
+ *             attribute of h/w resource like the minimum and maximum
+ *             frequency of CPU/GPU/Memory bus, the minimum and maximum number
+ *             of online CPU and so on.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #include <inttypes.h>
 #include <stdio.h>
@@ -85,7 +96,16 @@ static struct pass_resource_hotplug_ops *get_hotplug(struct pass_resource *res,
        return hotplug;
 }
 
-/* Get and set the current governor for DVFS resource. */
+/**
+ * @brief      Get the current governor for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] governor Current governor name will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_curr_governor(struct pass_resource *res, char *governor)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -103,6 +123,16 @@ int pass_get_curr_governor(struct pass_resource *res, char *governor)
        return dvfs->get_curr_governor(res->config_data.res_name, governor);
 }
 
+/**
+ * @brief      Set the current governor for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] governor Governor name
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_curr_governor(struct pass_resource *res, char *governor)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -120,7 +150,15 @@ int pass_set_curr_governor(struct pass_resource *res, char *governor)
        return dvfs->set_curr_governor(res->config_data.res_name, governor);
 }
 
-/* Get and set the current/min/max frequency for DVFS resource. */
+/**
+ * @brief      Get the current frequency for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_curr_freq(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -138,7 +176,15 @@ int pass_get_curr_freq(struct pass_resource *res)
        return dvfs->get_curr_freq(res->config_data.res_name);
 }
 
-
+/**
+ * @brief      Get the minimum frequency for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_min_freq(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -156,6 +202,16 @@ int pass_get_min_freq(struct pass_resource *res)
        return dvfs->get_min_freq(res->config_data.res_name);
 }
 
+/**
+ * @brief      Set the minimum frequency for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] freq Minimum frequency
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_min_freq(struct pass_resource *res, int freq)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -173,6 +229,15 @@ int pass_set_min_freq(struct pass_resource *res, int freq)
        return dvfs->set_min_freq(res->config_data.res_name, freq);
 }
 
+/**
+ * @brief      Get the maximum frequency for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_max_freq(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -190,6 +255,16 @@ int pass_get_max_freq(struct pass_resource *res)
        return dvfs->get_max_freq(res->config_data.res_name);
 }
 
+/**
+ * @brief      Set the maximum frequency for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] freq Maximum frequency
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_max_freq(struct pass_resource *res, int freq)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -207,7 +282,15 @@ int pass_set_max_freq(struct pass_resource *res, int freq)
        return dvfs->set_max_freq(res->config_data.res_name, freq);
 }
 
-/* Get the minimum/maximum frequency which can be set to resource. */
+/**
+ * @brief      Get the available minimum frequency which can be set to resource
+ *             for DVFS(Dynamic Voltage and Frequency Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_available_min_freq(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -225,6 +308,15 @@ int pass_get_available_min_freq(struct pass_resource *res)
        return dvfs->get_available_min_freq(res->config_data.res_name);
 }
 
+/**
+ * @brief      Get the available maximum frequency which can be set to resource
+ *             for DVFS(Dynamic Voltage and Frequency Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_available_max_freq(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -242,7 +334,15 @@ int pass_get_available_max_freq(struct pass_resource *res)
        return dvfs->get_available_max_freq(res->config_data.res_name);
 }
 
-/* Get and set the up_threshold for DVFS resource. */
+/**
+ * @brief      Get the up_threshold for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_up_threshold(struct pass_resource *res)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -260,6 +360,16 @@ int pass_get_up_threshold(struct pass_resource *res)
        return dvfs->get_up_threshold(res->config_data.res_name);
 }
 
+/**
+ * @brief      Set the up_threshold for DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] up_threshold Up_threshold
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_up_threshold(struct pass_resource *res, int up_threshold)
 {
        struct pass_resource_dvfs_ops *dvfs;
@@ -277,7 +387,15 @@ int pass_set_up_threshold(struct pass_resource *res, int up_threshold)
        return dvfs->set_up_threshold(res->config_data.res_name, up_threshold);
 }
 
-/* Get and set the online state of HOTPLUG resource (e.g., CPU). */
+/**
+ * @brief      Get the online state of CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] cpu CPU id
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_online_state(struct pass_resource *res, int cpu)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -295,6 +413,16 @@ int pass_get_online_state(struct pass_resource *res, int cpu)
        return hotplug->get_online_state(res->config_data.res_name, cpu);
 }
 
+/**
+ * @brief      Set the online state of CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] cpu CPU id
+ * @param      [in] on Online state which is either 1 or 0
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_online_state(struct pass_resource *res, int cpu, int on)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -312,6 +440,14 @@ int pass_set_online_state(struct pass_resource *res, int cpu, int on)
        return hotplug->set_online_state(res->config_data.res_name, cpu, on);
 }
 
+/**
+ * @brief      Get the minimum number of online CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_online_min_num(struct pass_resource *res)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -329,6 +465,15 @@ int pass_get_online_min_num(struct pass_resource *res)
        return hotplug->get_online_min_num(res->config_data.res_name);
 }
 
+/**
+ * @brief      Set the minimum number of online CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] num Minimum number of online CPU
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_online_min_num(struct pass_resource *res, int num)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -346,6 +491,14 @@ int pass_set_online_min_num(struct pass_resource *res, int num)
        return hotplug->set_online_min_num(res->config_data.res_name, num);
 }
 
+/**
+ * @brief      Get the maximum number of online CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_online_max_num(struct pass_resource *res)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -363,6 +516,15 @@ int pass_get_online_max_num(struct pass_resource *res)
        return hotplug->get_online_max_num(res->config_data.res_name);
 }
 
+/**
+ * @brief      Set the maximum number of online CPU h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] num Maximum number of online CPU
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_online_max_num(struct pass_resource *res, int num)
 {
        struct pass_resource_hotplug_ops *hotplug;
@@ -380,7 +542,14 @@ int pass_set_online_max_num(struct pass_resource *res, int num)
        return hotplug->set_online_max_num(res->config_data.res_name, num);
 }
 
-/* Get the temperature and thermal policy for Thermal resource. */
+/**
+ * @brief      Get the temperature for h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c integer (both positive and negative are possible) on success
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_temp(struct pass_resource *res)
 {
        struct pass_resource_tmu_ops *tmu;
@@ -402,6 +571,15 @@ int pass_get_temp(struct pass_resource *res)
        return tmu->get_temp(res->config_data.res_thermal_name);
 }
 
+/**
+ * @brief      Get the thermal policy for h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] policy Current thermal policy name will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_tmu_policy(struct pass_resource *res, char *policy)
 {
        struct pass_resource_tmu_ops *tmu;
@@ -423,6 +601,16 @@ int pass_get_tmu_policy(struct pass_resource *res, char *policy)
        return tmu->get_policy(res->config_data.res_thermal_name, policy);
 }
 
+/**
+ * @brief      Set the fault_around_bytes for memory h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] fault_around_bytes The number of bytes to be mapped around
+ *             the fault
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_fault_around_bytes(struct pass_resource *res,
                                int fault_around_bytes)
 {
@@ -445,6 +633,14 @@ int pass_set_fault_around_bytes(struct pass_resource *res,
        return memory->set_fault_around_bytes(res->config_data.res_name, fault_around_bytes);
 }
 
+/**
+ * @brief      Get the fault_around_bytes for memory h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c positive integer on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_get_fault_around_bytes(struct pass_resource *res)
 {
        struct pass_resource_memory *memory;
@@ -466,6 +662,14 @@ int pass_get_fault_around_bytes(struct pass_resource *res)
        return memory->get_fault_around_bytes(res->config_data.res_name);
 }
 
+/**
+ * @brief      Deprecated - set pmqos_data for nonstandard h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ * @retval     -22 Invalid argument (-EINVAL)
+ * @retval     -1 Operation not permitted (-EPERM)
+ * @retval     -19 Operation not supported (-ENODEV)
+ */
 int pass_set_pmqos_data(struct pass_resource *res, void *data)
 {
        struct pass_resource_nonstandard *nonstandard = NULL;
@@ -487,6 +691,13 @@ int pass_set_pmqos_data(struct pass_resource *res, void *data)
        return nonstandard->set_pmqos_data(res->config_data.res_name, data);
 }
 
+/**
+ * @brief      Save the initial state of DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource before PASS (Power Aware System Service)
+ *             daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_save_dvfs_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -512,6 +723,12 @@ static int pass_save_dvfs_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Save the initial online state of CPU h/w resource
+ *             before PASS (Power Aware System Service) daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_save_hotplug_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -542,6 +759,12 @@ static int pass_save_hotplug_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Save the initial state of memory h/w resource
+ *             before PASS (Power Aware System Service) daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_save_memory_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -551,6 +774,13 @@ static int pass_save_memory_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Restore the saved state of DVFS(Dynamic Voltage and Frequency
+ *             Scaling) resource when PASS (Power Aware System Service) daemon
+ *             stopped
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_restore_dvfs_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -583,6 +813,12 @@ static int pass_restore_dvfs_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Restore the saved online state of CPU h/w resource when PASS
+ *             (Power Aware System Service) daemon stopped
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_restore_hotplug_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -622,6 +858,12 @@ static int pass_restore_hotplug_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Restore the saved state of memory h/w resource when PASS
+ *             (Power Aware System Service) daemon stopped
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_restore_memory_initdata(struct pass_resource *res)
 {
        struct pass_resource_init_data *initdata = &res->init_data;
@@ -637,6 +879,12 @@ static int pass_restore_memory_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Save the initial state of h/w resource before PASS
+ *             (Power Aware System Service) daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_save_initdata(struct pass_resource *res)
 {
        int ret;
@@ -681,6 +929,12 @@ int pass_save_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Restore the saved state of h/w resource when PASS
+ *             (Power Aware System Service) daemon stopped
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_restore_initdata(struct pass_resource *res)
 {
        int ret;
@@ -725,6 +979,14 @@ int pass_restore_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Load shared library from PASS (Power Aware System Service)
+ *             HAL (Hardware Abstract Layer) package and open the library in
+ *             order to initialize the member of 'struct pass_resource'
+ *             according to the type of h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_get_resource(struct pass_resource *res)
 {
        struct pass_resource_info *info;
@@ -802,6 +1064,12 @@ int pass_get_resource(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Close the library in order to free the member of
+ *             'struct pass_resource' according to the type of h/w resource
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_put_resource(struct pass_resource *res)
 {
        struct pass_resource_common *common;
index da47a49ccf289c5053ecbdb65cd662d05196aeee..3ff1b6e9bfac67c99bac269cc041b92b6442ea67 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-hal.h
+ * @brief      Define HAL(Hardware Abstract Layer) interface for PASS HAL
+ *             package because each h/w board has the different amount of
+ *             h/w resource and different interface to handle h/w them.
+ *             Also, provide the HAL helper functions to handle the various
+ *             attribute of h/w resource like the minimum and maximum
+ *             frequency of CPU/GPU/Memory bus, the minimum and maximum number
+ *             of online CPU and so on.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #ifndef __PASS_HAL__
 #define __PASS_HAL__
index cedbf7600c91f55a518d04c782b6dcea948468e3..b653e76e3dc8f458b053e8ed126b4b98977c7702 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-parser.c
+ * @brief      Parse the supported h/w resource's information from
+ *             configuration files such as /etc/pass/pass.conf.
+ *             - /etc/pass/pass.conf contains the list of supported h/w
+ *             resources. For example, if a specific h/w board has Octa-core,
+ *             GPU and two memory bus, pass.conf contains five resource
+ *             information like two CPU, one GPU and two memory bus.
+ *             - /etc/pass/pass-resource-xxx.conf contains h/w resource
+ *             information for each h/w resource. For example, if a specific
+ *             h/w board has Octa-core, GPU and two memory bus, PASS controls
+ *             five H/W resources. Therefore, each h/w resource mush have its
+ *             own pass-resource-xxx.conf, which contains the detailed h/w
+ *             resource information.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #include <ctype.h>
 #include <stdio.h>
@@ -75,6 +91,12 @@ static enum pass_state is_supported(char *value)
        return state;
 }
 
+/**
+ * @brief      Parse scenario section to get scenario name and information
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] scenario Parsed data of a scenario will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_scenario(struct parse_result *result,
                                struct pass_scenario *scenario)
 {
@@ -108,6 +130,12 @@ static int parse_scenario(struct parse_result *result,
        return 0;
 }
 
+/**
+ * @brief      Parse pass_level section to get pass_level information
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] level Parsed data of a pass_level will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_level(struct parse_result *result,
                                struct pass_level *level)
 {
@@ -188,6 +216,12 @@ static int parse_level(struct parse_result *result,
        return 0;
 }
 
+/**
+ * @brief      Parse pmqos section to get PASS_MODULE_PMQOS information
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_pmqos(struct parse_result *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -229,6 +263,12 @@ static int parse_pmqos(struct parse_result *result, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Parse thermal section to get PASS_MODULE_THERMAL information
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_thermal(struct parse_result *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -270,6 +310,12 @@ static int parse_thermal(struct parse_result *result, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Parse core section to get module information
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_core(struct parse_result *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -324,6 +370,12 @@ static int parse_core(struct parse_result *result, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Parse configuration for each h/w resource
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_each_resource(struct parse_result *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -420,6 +472,13 @@ out:
        return 0;
 }
 
+/**
+ * @brief      Parse resource section in pass.conf for each h/w resource
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @param      [in] id Resource index number
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_resource_data(struct parse_result *result,
                                    void *user_data, int id)
 {
@@ -483,6 +542,13 @@ static int parse_resource_data(struct parse_result *result,
        return 0;
 }
 
+/**
+ * @brief      Parse pass.conf for all h/w resources to get list of supported
+ *             h/w resources
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int parse_resource(struct parse_result *result, void *user_data)
 {
        static char path[BUFF_MAX];
@@ -587,21 +653,21 @@ static int parse_resource(struct parse_result *result, void *user_data)
        return 0;
 }
 
-/*
- * pass_get_resource_config - Get all h/w resource information
- *
- * @pass: the instance of struct pass which contains all information
- * @path: the path of configuration files (e.g., /etc/pass/pass.conf)
+/**
+ * @brief      Get all h/w resource information
+ * @param      [in] pass Instance of 'struct pass' contains all information
+ * @param      [in] path Path of configuration files (/etc/pass/pass.conf)
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_get_resource_config(struct pass *pass, char *path)
 {
        return config_parse(path, parse_resource, pass);
 }
 
-/*
- * pass_get_resource_config - Free h/w resource information
- *
- * @pass: the instance of struct pass which contains all information
+/**
+ * @brief      Free h/w resource information
+ * @param      [in] pass Instance of 'struct pass' contains all information
+ * @return     N/A
  */
 void pass_put_resource_config(struct pass *pass)
 {
@@ -610,11 +676,11 @@ void pass_put_resource_config(struct pass *pass)
        pass->num_resources = 0;
 }
 
-/*
- * pass_get_each_resource_config - Get each h/w resource information
- *
- * @res: the instance of struct pass_resource
- * @path: the path of configuration file for each h/w resource
+/**
+ * @brief      Get each h/w resource information
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] path Path of configuration file for each h/w resource
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_get_each_resource_config(struct pass_resource *res, char *path)
 {
@@ -671,10 +737,10 @@ int pass_get_each_resource_config(struct pass_resource *res, char *path)
        return 0;
 }
 
-/*
- * pass_put_each_resource_config - Free each h/w resource information
- *
- * @res: the instance of struct pass_resource
+/**
+ * @brief      Free each h/w resource information
+ * @param      [in] res Instance of h/w resource
+ * @return     N/A
  */
 void pass_put_each_resource_config(struct pass_resource *res)
 {
index 1c5a4400cf20d0c993c88652742516e9ffa815fa..bd554b5d072a9e6c2173b42de5867d29570f706e 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-parser.h
+ * @brief      Parse the supported h/w resource's information from
+ *             configuration files such as /etc/pass/pass.conf.
+ *             - /etc/pass/pass.conf contains the list of supported h/w
+ *             resources. For example, if a specific h/w board has Octa-core,
+ *             GPU and two memory bus, pass.conf contains five resource
+ *             information like two CPU, one GPU and two memory bus.
+ *             - /etc/pass/pass-resource-xxx.conf contains h/w resource
+ *             information for each h/w resource. For example, if a specific
+ *             h/w board has Octa-core, GPU and two memory bus, PASS controls
+ *             five H/W resources. Therefore, each h/w resource mush have its
+ *             own pass-resource-xxx.conf, which contains the detailed h/w
+ *             resource information.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #ifndef __PASS_PARSER__
 #define __PASS_PARSER__
 
index 0625699875cec3ed14b0e238cd4f2c4cc36a83c8..ceea62ac4796f3a16ec44ed6a8a329396ab9a290 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-pmqosc
+ * @brief      Provide PMQoS (Power Management Quality of Service) module.
+ *             Control each h/w resource according to specific scenario such
+ *             as 'AppLaunch', 'UltraPowerSaving' and so on. Verify whether
+ *             the asked scenario is supported or not for each h/w resource.
+ *             Also, it can handle multiple scenarios at the same time.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
index 2ea800b84f7e0bd9b6d806f1ea2017cb8bcb752d..074e5276aedcff0916a4553aae78106fda57f60d 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-rescon.c
+ * @brief      Provide RESCON(Resource Controller) module. Control h/w resource
+ *             to change the value such as the minimum and maximum frequency
+ *             of CPU/GPU/Memory bus, the minimum and maximum number of online
+ *             CPU and so on. Other modules in PASS are able to use pass-rescon
+ *             in order to change the value of h/w resource.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include "pass.h"
 #include "pass-hal.h"
 
+/**
+ * @brief      Set the next pass_level required from modules like
+ *             PASS_MODULE_CPUHP, PASS_MODULE_PMQOS and so on. The demanded
+ *             pass_level has the different h/w value such as minimum/maximum
+ *             frequency, the number of online CPU, fault_around_bytes and son
+ *             on. It changes the h/w value by using the data within the
+ *             demanded pass_level and it is final step to change h/w value.
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] new_level Index of demanded pass_level
+ * @return     @c 0 on success, otherwise error value
+ */
 static int rescon_set_level(struct pass_resource *res, int new_level)
 {
        struct pass_level *levels = res->config_data.levels;;
@@ -42,7 +63,7 @@ static int rescon_set_level(struct pass_resource *res, int new_level)
        res->rescon.prev_level = curr_level;
        res->rescon.curr_level = new_level;
 
-       /* Turn on/off CPUs according required number of online CPU */
+       /* Turn on/off CPUs according demanded number of online CPU */
        if (limit_min_cpu >= 0) {
                if (limit_min_cpu > res->config_data.num_cpus)
                        limit_min_cpu = res->config_data.num_cpus;
@@ -95,11 +116,12 @@ static int rescon_set_level(struct pass_resource *res, int new_level)
        return 0;
 };
 
-/*
- * pass_rescon_set_level - Change frequency and number of online resources
- *
- * @res: the instance of struct pass_resource
- * @new_level: the desired pass level
+/**
+ * @brief      Adjust the demanded pass_level by using the supported minimum
+ *             and maximum pass_level.
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] new_level Index of demanded pass_level
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_rescon_set_level(struct pass_resource *res, int new_level)
 {
@@ -118,14 +140,15 @@ int pass_rescon_set_level(struct pass_resource *res, int new_level)
        return rescon_set_level(res, new_level);
 };
 
-/*
- * pass_rescon_set_level_scope - Change the scope of pass level
- *
- * @res: the instance of struct pass_resource
- * @new_level: the desirous pass level
- * @min_level: the minimum pass level
- * @max_level: the maximum pass level
- * @data: the PMQoS's data containing the scenario name and lock state
+/**
+ * @brief      Change the range of pass_level like the minimum and maximum
+ *             pass_level.
+ * @param      [in] res Instance of h/w resource
+ * @param      [in] new_level Demanded pass_level
+ * @param      [in] min_level Minimum pass_level
+ * @param      [in] max_level Maximum pass_level
+ * @param      [in] data PMQoS data containing the scenario name and lock state
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_rescon_set_level_scope(struct pass_resource *res, int new_level,
                                int min_level, int max_level, void *data)
@@ -160,10 +183,10 @@ int pass_rescon_set_level_scope(struct pass_resource *res, int new_level,
        return 0;
 }
 
-/*
- * pass_rescon_init - Initialize ResCon (Resource Controller) module
- *
- * @res: the instance of struct pass_resource
+/**
+ * @brief      Initialize PASS_MODULE_RESCON(Resource Controller) module.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_rescon_init(struct pass_resource *res)
 {
@@ -225,10 +248,10 @@ int pass_rescon_init(struct pass_resource *res)
        return 0;
 }
 
-/*
- * pass_rescon_exit - Exit ResCon (Resource Controller) module
- *
- * @res: the instance of struct pass_resource
+/**
+ * @brief      Exit PASS_MODULE_RESCON(Resource Controller) module.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_rescon_exit(struct pass_resource *res)
 {
index 9e06cd964a197c91320c793dfe5b033ac988dd5c..383c8c6ed77db3db91573d5d6459d738ac32760e 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-rescon.h
+ * @brief      Provide RESCON(Resource Controller) module. Control h/w resource
+ *             to change the value such as the minimum and maximum frequency
+ *             of CPU/GPU/Memory bus, the minimum and maximum number of online
+ *             CPU and so on. Other modules in PASS are able to use pass-rescon
+ *             in order to change the value of h/w resource.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #ifndef __PASS_RESCON__
 #define __PASS_RESCON__
 
index c45e1456b28acd4afa5afdb6aeb15052dba8c03f..d49be99fb1fba04ce902156b0db6d6ad484c183e 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-resmon-internal.h
+ * @brief      Define the private structure and enumeration for only RESMON
+ *             (Resource Monitor) module.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #ifndef __PASS_RESMON_INTERNAL__
 #define __PASS_RESMON_INTERNAL__
 
 #include <libudev.h>
 
-/*
- * enum resmon_type - Represents the type of resource-monitor.
- * - RESMON_TIMER: Timer-based resource-monitor type. (Polling method)
- * - RESMON_UEVENT: Uevent-based resource-monitor type. (Interrupt method)
+/**
+ * @brief      Represents the type of resource-monitor.
  */
 enum resmon_type {
+       /** Timer-based resource-monitor type. (Polling method) */
        RESMON_UNKNOWN          = 0x0,
+       /** Uevent-based resource-monitor type. (Interrupt method) */
        RESMON_TIMER            = 0x1,
+       /** Not special meaning. It is just end of enum resmon_type  */
        RESMON_UEVENT           = 0x2,
 };
 
 struct resmon;
 
+/**
+ * @brief      Represent the operation of each resource monitor source
+ *             for PASS_MODULE_RESMON(Resource Monitor) module.
+ */
 struct resmon_ops {
+       /** Function pointer for initializing resource monitor source */
        int (*init)(struct resmon *monitor);
+       /** Function pointer for exiting resource monitor source */
        int (*exit)(struct resmon *monitor);
 
-       /* Callback of timer-based resource monitor */
+       /** Callback function pointer of timer-based resource monitor */
        int (*timer_handler)(struct resmon *monitor, void *result);
 
-       /* Callback of uevent-based resource monitor */
+       /* Callback function pointer of uevent-based resource monitor */
        int (*uevent_handler)(struct resmon *monitor, void *result,
                                struct udev_device *dev);
+       /**
+        * Intance of uevent subsystem. It will be used for only uevent-based
+        * resource monitor.
+        */
        const char *uevent_subsystem;
+       /**
+        * Intance of uevent device type. It will be used for only uevent-based
+        * resource monitor.
+        */
        const char *uevent_devtype;
 };
 
+/**
+ * @brief      Represent a resource monitor. It will be either timer-based or
+ *             uevent-based resource monitor.
+ */
 struct resmon {
+       /** Instance of PASS_MODULE_RESMON (Resource Monitor) module */
        struct pass_resmon *resmon;
 
-       /* Resource Monitor's type is either timer or uevent. */
+       /** Resource Monitor's type is either timer or uevent. */
        enum resmon_type type;
 
-       /* Resource Monitor's source type */
+       /** Resource Monitor's source type */
        enum resmon_src_type src_type;
 
-       /*
+       /**
         * User callback function when following event happen:
         * - In case of timer-baed resmon, the timer is expired.
         * - In case of uevent-baed resmon, receive the required uevent.
         */
        int (*user_func)(void *result, void *user_data);
+       /** User data passed from user who register the resource monitor */
        void *user_data;
+       /** Monitored data from the resource monitor */
        void *result;
 
+       /** Instance of the operation of resource monitor */
        struct resmon_ops *ops;
 
-       /* Private data of timer-based resource-monitor */
+       /**
+        * Type of timer-based resource monitor. It will be only used for
+        * timer-based resource monitor.
+        */
        enum resmon_timer_type timer_type;
+       /**
+        * Interval of timer (unit: millisecond). It will be only used for
+        * timer-based resource monitor.
+        */
        unsigned int timer_interval;
+       /**
+        * Timer ID. It will be only used for
+        * timer-based resource monitor.
+        */
        guint timer_id;
 
-       /* Private data of uevent-based resource-monitor */
+       /**
+        * Type of uevent-based resource monitor. It will be only used for
+        * uevent-based resource monitor.
+        */
        struct udev_monitor *udev_monitor;
+       /**
+        * File descriptor for udev device. It will be only used for
+        * uevent-based resource monitor.
+        */
        guint udev_moniotr_fd;
 };
 
index 5da41bde738d12d3b814c323f63d3124df51405f..e26651cc5280579b874b066aa6f25b0cbf13c233 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-resmon-source.c
+ * @brief      Provide the detailed operation for each h/w monitoring type
+ *             such as thermal, CPU history and so on. pass-resmon uses the
+ *             detailed operation of pass-resmon-source to monitor the h/w
+ *             resources.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <inttypes.h>
 
 #include <pass/log.h>
 #include "pass-resmon-internal.h"
 
 /* RESMON_SRC_THERMAL */
+
+/**
+ * @brief      Initialize RESMON_SRC_THERMAL resource monitor to monitor
+ *             thermal information.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_thermal_init(struct resmon *monitor)
 {
        struct resmon_result_src_thermal *result;
@@ -42,6 +58,12 @@ static int resmon_thermal_init(struct resmon *monitor)
        return 0;
 }
 
+/**
+ * @brief      Exit RESMON_SRC_THERMAL resource monitor to monitor.
+ *             thermal information.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_thermal_exit(struct resmon *monitor)
 {
        if (!monitor->result)
@@ -53,6 +75,13 @@ static int resmon_thermal_exit(struct resmon *monitor)
        return 0;
 }
 
+/**
+ * @brief      Monitor raw data of RESMON_SRC_THERMAL resource monitor based
+ *             on timer.
+ * @param      [in] monitor Instance of a resource monitor
+ * @param      [in] result Monitored data of thermal will be saved to it.
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_thermal_timer_handler(struct resmon *monitor, void *result)
 {
        struct pass_resmon *resmon = monitor->resmon;
@@ -74,6 +103,14 @@ static int resmon_thermal_timer_handler(struct resmon *monitor, void *result)
        return 0;
 }
 
+/**
+ * @brief      Get raw data of RESMON_SRC_THERMAL resource monitor based
+ *             on uevent.
+ * @param      [in] monitor Instance of a resource monitor
+ * @param      [in] result Monitored data of thermal will be saved to it.
+ * @param      [in] dev
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_thermal_uevent_handler(struct resmon *monitor, void *result,
                                                struct udev_device *dev)
 {
@@ -98,6 +135,13 @@ static int resmon_thermal_uevent_handler(struct resmon *monitor, void *result,
 
 /* RESMON_SRC_CPUHP */
 #define RESMON_SRC_CPUHP_COUNT 20
+
+/**
+ * @brief      Initialize RESMON_SRC_CPUHP resource monitor to monitor
+ *             CPU history information.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_cpuhp_init(struct resmon *monitor)
 {
        struct resmon_result_src_cpuhp *result;
@@ -122,6 +166,12 @@ static int resmon_cpuhp_init(struct resmon *monitor)
        return 0;
 }
 
+/**
+ * @brief      Exit RESMON_SRC_CPUHP resource monitor to monitor
+ *             CPU history information.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_cpuhp_exit(struct resmon *monitor)
 {
        struct resmon_result_src_cpuhp *result;
@@ -146,6 +196,13 @@ static int resmon_cpuhp_exit(struct resmon *monitor)
        return 0;
 }
 
+/**
+ * @brief      Monitor raw data of RESMON_SRC_CPUHP resource monitor based
+ *             on timer.
+ * @param      [in] monitor Instance of a resource monitor
+ * @param      [in] result Monitored data of thermal will be saved to it.
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_cpuhp_timer_handler(struct resmon *monitor, void *result)
 {
        struct pass_resmon *resmon = monitor->resmon;
@@ -194,6 +251,10 @@ static int resmon_cpuhp_timer_handler(struct resmon *monitor, void *result)
        return 0;
 }
 
+/**
+ * @brief      Represent the implementation of RESMON_SRC_THERMAL resource
+ *             monitor.
+ */
 struct resmon_ops thermal_src_ops = {
        .init = resmon_thermal_init,
        .exit = resmon_thermal_exit,
@@ -203,6 +264,10 @@ struct resmon_ops thermal_src_ops = {
        .uevent_devtype = NULL,
 };
 
+/**
+ * @brief      Represent the implementation of RESMON_SRC_CPUHP resource
+ *             monitor.
+ */
 struct resmon_ops cpuhp_src_ops = {
        .init = resmon_cpuhp_init,
        .exit = resmon_cpuhp_exit,
@@ -212,6 +277,13 @@ struct resmon_ops cpuhp_src_ops = {
        .uevent_devtype = NULL,
 };
 
+/**
+ * @brief      Get operation structure of resource monitor.
+ * @param      [in] monitor Instance of a resource monitor
+ * @param      [in] result Monitored data of thermal will be saved to it.
+ * @return     Instance pointer of 'struct resmon_ops' according to type of
+ *             resource monitor source.
+ */
 struct resmon_ops *resmon_get_ops(enum resmon_src_type src_type)
 {
        switch (src_type) {
index fe45b5fcfb246b2d89d0f9f48ebcf78605275b42..dc323379ff2f7f7bd02bfa1cd3153a1f1962ef12 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-resmon.c
+ * @brief      Provide RESMON(Resource Monitor) module. Monitor h/w resource
+ *             such as the frequency of GPU/GPU/Memory bus, the number of
+ *             online CPU, thermal and so on. Other modules in PASS(Power Aware
+ *             System Service) are able to use pass-resmon in order to monitor
+ *             and collect the resource data.
+ *
+ *             Provide the common interface for h/w resource monitoring and
+ *             then pass-resmon-source provides the detailed operation for
+ *             each h/w monitoring type such as thermal, CPU history and so on.
+ *
+ *             Provide two monitoring method. First, timer-based resource
+ *             monitor like polling method. It support both oneshot and perodic
+ *             timer resource monitor. Second, uevent-based resource monitor
+ *             like interrupt method. It notifies the result of monitoring when
+ *             receiving the uevent.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <glib-unix.h>
 #include <libudev.h>
 
 #include "pass-resmon.h"
 #include "pass-resmon-internal.h"
 
+/**
+ * @brief      Global instance indicating udev
+ */
 static struct udev *g_udev = NULL;
+
+/**
+ * @brief      Global instance indicating the usage count of udev
+ */
 static int g_udev_count = 0;
 
 extern struct resmon_ops *resmon_get_ops(enum resmon_src_type src_type);
 
+/**
+ * @brief      Specify the supported sources of timer-based resource monitor
+ *             according the type of h/w resource.
+ */
 uint64 available_resmon_timer[] = {
        [PASS_RESOURCE_UNKNOWN]         = 0,
        [PASS_RESOURCE_CPU_ID]          = RESMON_SRC_THERMAL
@@ -42,6 +73,10 @@ uint64 available_resmon_timer[] = {
        [PASS_RESOURCE_NONSTANDARD_ID]  = 0
 };
 
+/**
+ * @brief      Specify the supported sources of uevent-based resource monitor
+ *             according the type of h/w resource.
+ */
 uint64 available_resmon_uevent[] = {
        [PASS_RESOURCE_UNKNOWN]         = 0,
        [PASS_RESOURCE_CPU_ID]          = RESMON_SRC_THERMAL,
@@ -114,6 +149,13 @@ static struct resmon *resmon_find_monitor(struct pass_resmon *resmon,
 }
 
 static gboolean resmon_timer_func(gpointer data);
+
+/**
+ * @brief      Add a timer-based resource monitor with the required interval.
+ * @param      [in] monitor Instance of a resource monitor
+ * @param      [in] interval Interval of timer-based resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_timer_add(struct resmon *monitor, unsigned int interval)
 {
        struct pass_resmon *resmon = monitor->resmon;
@@ -155,6 +197,11 @@ static int resmon_timer_add(struct resmon *monitor, unsigned int interval)
        return 0;
 }
 
+/**
+ * @brief      Delete a timer-based resource monitor.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_timer_delete(struct resmon *monitor)
 {
        struct pass_resmon *resmon = monitor->resmon;
@@ -178,6 +225,12 @@ static int resmon_timer_delete(struct resmon *monitor)
        return 0;
 }
 
+/**
+ * @brief      Callback function of timer-based resource monitor. It will be
+ *             executed when the timer interval is expired.
+ * @param      [in] data Instance of a resource monitor
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean resmon_timer_func(gpointer data)
 {
        struct resmon *monitor = data;
@@ -231,15 +284,15 @@ static gboolean resmon_timer_func(gpointer data)
        return true;
 }
 
-/*
- * pass_resmon_register_timer - Register timer-based resource monitor
- *
- * @res: the instance of struct pass_resource.
- * @src_type: the type of resource monitor among 'enum resmon_src_type'.
- * @timer_type: the type of timer among 'enum resmon_timer_type'.
- * @timer_interval: the interval of timer (unit: millisecond).
- * @user_func: the callback function when timer is expired.
- * @user_data: the passed user user_data.
+/**
+ * @brief      Register a timer-based resource monitor.
+ * @param      [in] res Instance of a resource monitor
+ * @param      [in] src_type Type of resource monitor source
+ * @param      [in] timer_type Type of timer among 'enum resmon_timer_type'
+ * @param      [in] timer_interval Interval of timer (unit: millisecond)
+ * @param      [in] user_func Callback function pointer when timer is expired
+ * @param      [in] user_data The passed user user_data.
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_resmon_register_timer(struct pass_resource *res,
                                enum resmon_src_type src_type,
@@ -309,11 +362,11 @@ err:
        return ret;
 }
 
-/*
- * pass_resmon_unregister_timer - Unregister timer-based resource monitor
- *
- * @res: the instance of struct pass_resource
- * @src_type: the type of resource monitor among 'enum resmon_src_type'.
+/**
+ * @brief      Unregister a timer-based resource monitor
+ * @param      [in] res Instance of a resource monitor
+ * @param      [in] src_type Type of resource monitor source
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_resmon_unregister_timer(struct pass_resource *res,
                                enum resmon_src_type src_type)
@@ -341,12 +394,13 @@ int pass_resmon_unregister_timer(struct pass_resource *res,
        return 0;
 }
 
-/*
- * pass_resmon_update_interval - Update the period of timer
- *
- * @res: the instance of struct pass_resource.
- * @src_type: the type of resource monitor among 'enum resmon_src_type'.
- * @timer_interval: the interval of timer (unit: millisecond).
+/**
+ * @brief      Update the interval of timer
+ * @param      [in] res Instance of a resource monitor
+ * @param      [in] src_type Type of resource monitor source
+ * @param      [in] timer_interval Interval of timer-based resource monitor
+ *             (unit: millisecond)
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_resmon_update_timer_interval(struct pass_resource *res,
                                enum resmon_src_type src_type,
@@ -377,6 +431,12 @@ int pass_resmon_update_timer_interval(struct pass_resource *res,
        return 0;
 }
 
+/**
+ * @brief      Callback function of uevent-based resource monitor. It will be
+ *             executed when the uevent occurs from linux kernel.
+ * @param      [in] data Instance of a resource monitor
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean resmon_uevent_func(gint fd, GIOCondition cond, void *data)
 {
        struct resmon *monitor = data;
@@ -426,6 +486,12 @@ static gboolean resmon_uevent_func(gint fd, GIOCondition cond, void *data)
 }
 
 #define UDEV_MONITOR_SIZE      (128 * 1024)
+
+/**
+ * @brief      Add an uevent-based resource monitor.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_uevent_add(struct resmon *monitor)
 {
        struct udev_monitor *udev_monitor;
@@ -540,6 +606,11 @@ err_udev_monitor:
        return ret;
 }
 
+/**
+ * @brief      Delete an uevent-based resource monitor.
+ * @param      [in] monitor Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int resmon_uevent_delete(struct resmon *monitor)
 {
        struct pass_resmon *resmon = monitor->resmon;
@@ -571,13 +642,13 @@ static int resmon_uevent_delete(struct resmon *monitor)
        return 0;
 }
 
-/*
- * pass_resmon_register_uevent - Register uevent-based resource monitor
- *
- * @res: the instance of struct pass_resource.
- * @src_type: the type of resource monitor among 'enum resmon_src_type'.
- * @user_func: the callback function when timer is expired.
- * @user_data: the passed user user_data.
+/**
+ * @brief      Register an uevent-based resource monitor.
+ * @param      [in] res Instance of a resource monitor
+ * @param      [in] src_type Type of resource monitor source
+ * @param      [in] user_func Callback function pointer when uevent occurs
+ * @param      [in] user_data The passed user user_data.
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_resmon_register_uevent(struct pass_resource *res,
                                enum resmon_src_type src_type,
@@ -648,11 +719,11 @@ err:
        return ret;
 }
 
-/*
- * pass_resmon_unregister_uevent - Unregister uevent-based resource monitor
- *
- * @res: the instance of struct pass_resource
- * @src_type: the type of resource monitor among 'enum resmon_src_type'.
+/**
+ * @brief      Unregister an uevent-based resource monitor.
+ * @param      [in] res Instance of a resource monitor
+ * @param      [in] src_type Type of resource monitor source
+ * @return     @c 0 on success, otherwise error value
  */
 int pass_resmon_unregister_uevent(struct pass_resource *res,
                                enum resmon_src_type src_type)
@@ -687,6 +758,11 @@ int pass_resmon_unregister_uevent(struct pass_resource *res,
 
 }
 
+/**
+ * @brief      Initialize PASS_MODULE_RESMON(Resource Monitor) module
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_resmon_init(struct pass_resource *res)
 {
        struct pass_resmon *resmon;
@@ -721,6 +797,11 @@ int pass_resmon_init(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Exit PASS_MODULE_RESMON(Resource Monitor) module
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_resmon_exit(struct pass_resource *res)
 {
        struct pass_resmon *resmon;
index 84768b6661a0ec0fb6dff5ef1fc5c1d10a60017d..05f0b7fea1d4f7547e1a8b1b90287142e36ffaf6 100644 (file)
 #ifndef __PASS_RESMON__
 #define __PASS_RESMON__
 
-/*
- * enum resmon_timer_type - Represents the type of timer-based resource monitor.
- * - RESMON_TIMER_PERIODIC: Periodic timer with the regular interval.
- * - RESMON_TIMER_ONESHOT: Oneshot timer after the interval.
+/**
+ * @file       pass-resmon.c
+ * @brief      Provide RESMON(Resource Monitor) module. Monitor h/w resource
+ *             such as the frequency of GPU/GPU/Memory bus, the number of
+ *             online CPU, thermal and so on. Other modules in PASS(Power Aware
+ *             System Service) are able to use pass-resmon in order to monitor
+ *             and collect the resource data.
+ *
+ *             Provide the common interface for h/w resource monitoring and
+ *             then pass-resmon-source provides the detailed operation for
+ *             each h/w monitoring type such as thermal, CPU history and so on.
+ *
+ *             Provide two monitoring method. First, timer-based resource
+ *             monitor like polling method. It support both oneshot and perodic
+ *             timer resource monitor. Second, uevent-based resource monitor
+ *             like interrupt method. It notifies the result of monitoring when
+ *             receiving the uevent.
+ * @ingroup    COM_POWER_MGNT
+ */
+
+/**
+ * @breif      Represents the type of timer-based resource monitor.
  */
 enum resmon_timer_type {
+       /** Periodic timer with the regular interval */
        RESMON_TIMER_PERIODIC = 1,
+       /** Oneshot timer after the interval */
        RESMON_TIMER_ONESHOT,
 };
 
-/*
- * enum resmon_src_type - Represents the source type of resource-monitor.
- * - RESMON_THERMAL: Monitor the 'thermal' info of h/w resource.
- * - RESMON_CPUHP: Monitor the 'CPU h/w resource' as following:
- *   CPU utilization/frequency/the number of running tasks. But this type
- *   is using nonstandard linux kernel interface. It should be replaced with
- *   the linux kernel standard interface.
- *
- * Description of result format of resource monitor's source type:
- * - RESMON_SRC_THERMAL: struct resmon_result_src_thermal
- * - RESMON_SRC_CPUHP : struct resmon_result_src_cpuhp
+/**
+ * @brief      Represents the source type of resource-monitor.
  */
 enum resmon_src_type {
        RESMON_SRC_UNKNOWN              = 0x0,
+       /**
+        * Monitor the 'thermal' info of h/w resource.
+        *
+        * Description of result format of resource monitor's source type:
+        * - RESMON_SRC_THERMAL: struct resmon_result_src_thermal
+        */
        RESMON_SRC_THERMAL              = 0x1,
+       /**
+        * Monitor the 'CPU h/w resource' as following:
+        * CPU utilization/frequency/the number of running tasks. But this type
+        * is using nonstandard linux kernel interface. It should be replaced
+        * with the linux kernel standard interface.
+        *
+        * Description of result format of resource monitor's source type:
+        * - RESMON_SRC_CPUHP : struct resmon_result_src_cpuhp
+        */
        RESMON_SRC_CPUHP                = 0x2,
 };
 
-/* Result of RESMON_SRC_THERMAL resource monitor */
+/**
+ * @brief      Result of RESMON_SRC_THERMAL resource monitor
+ */
 struct resmon_result_src_thermal {
-       int temp;
+       int temp;       /** Temperature */
 };
 
-/* Result of RESMON_SRC_CPUHP's resource monitor */
+/**
+ * @brief      Result of RESMON_SRC_CPUHP's resource monitor
+ */
 struct resmon_result_src_cpuhp {
+       /** Measuring time */
        int64_t time;
+       /** Previous CPU frequency */
        unsigned int freq;
+       /** Current CPU frequency */
        unsigned int freq_new;
+       /** The average number of running tasks in the same cluster */
        unsigned int nr_runnings;
-
+       /**
+        * CPU utilization. The size of load array is the number of CPU
+        * in the same cluster.
+        */
        unsigned int *load;
-       unsigned int *nr_running;
-       unsigned int *runnable_load;
 
-       unsigned int num_busy_cpu;
-       unsigned int avg_load;
-       unsigned int avg_runnable_load;
-       unsigned int avg_thread_load;
+       unsigned int *nr_running;       /** Unused paramerter will be removed */
+       unsigned int *runnable_load;    /** Unused paramerter will be removed */
+
+       unsigned int num_busy_cpu;      /** Unused paramerter will be removed */
+       unsigned int avg_load;          /** Unused paramerter will be removed */
+       unsigned int avg_runnable_load; /** Unused paramerter will be removed */
+       unsigned int avg_thread_load;   /** Unused paramerter will be removed */
+       /** Unused paramerter will be removed */
        unsigned int avg_thread_runnable_load;
 };
 
index 290950b307cdb716915ba5f6dbd25d4da127bb0b..8224deaf34d9bc6fd92fb98248e22fd8459f11e3 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass-thermal.c
+ * @brief      Provide Thermal Monitor module. Decide the thermal scenario by
+ *             using both parsed thermal scenario information and collected
+ *             raw thermal data. After deciding the thermal scenario, notify
+ *             the decided thermal scenario to Thermal Monitor (thermal).
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <pass/log.h>
 #include <pass/hal/hal.h>
 #include <pass/device-notifier.h>
 
 #define DEFAULT_TEMPERATURE            (-1000)
 
+/**
+ * @brief      Decide the proper thermal scenario by using both the monitored
+ *             raw data of thermal information and the parsed thermal
+ *             information from scenario section. And then notify the decided
+ *             thermal scenario to Thermal Monitor featrue (thermal) which
+ *             provides the external D-bus interface for Thermal Monitor.
+ * thermal
+ * @param      [in] result Monitored data of thermal will be saved to it.
+ * @param      [in] user_data Instance of a resource monitor
+ * @return     @c 0 on success, otherwise error value
+ */
 static int thermal_monitor_func(void *result, void *user_data)
 {
        struct pass_resource *res = user_data;
@@ -105,6 +125,11 @@ static int thermal_monitor_func(void *result, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Initialize PASS_MODULE_THERMAL(Thermal Monitor) module.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_thermal_init(struct pass_resource *res)
 {
        int ret;
@@ -158,6 +183,11 @@ err_timer:
        return -EINVAL;
 }
 
+/**
+ * @brief      Exit PASS_MODULE_THERMAL(Thermal Monitor) module.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pass_thermal_exit(struct pass_resource *res)
 {
        int ret;
index 378ca9e62968719a639a8dcae1fcb57120c4a0dc..99bebb87a9a19005716a018d3aa460b6eb8f0db5 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass.c
+ * @brief      Initialize all modules of PASS (Power Aware System Service)
+ *             system daemon and get the shared library from HAL (Hardware
+ *             Abstract Layer) package in order to control and monitor h/w
+ *             resources such as CPU/GPU/Memory Bus/Memory and so on.
+ *             Allocate the power-related resources based on the configuration
+ *             files like /etc/pass/pass.conf. Also, control the start and stop
+ *             of PASS core when receiving D-Bus command.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #include <glib.h>
 #include <stdbool.h>
 
 #define PASS_CONF_PATH                         "/etc/pass/pass.conf"
 
+/**
+ * @brief      Specify the supported modules according to the type of h/w
+ *             resource.
+ */
 static uint64 supported_module[] = {
        [PASS_RESOURCE_UNKNOWN]         = 0,
        [PASS_RESOURCE_CPU_ID]          = PASS_MODULE_PARSER
@@ -73,7 +88,15 @@ extern int pass_pmqos_exit(struct pass_resource *res);
 extern int pass_thermal_init(struct pass_resource *res);
 extern int pass_thermal_exit(struct pass_resource *res);
 
+/**
+ * @brief      Global instance indicating PASS (Power Aware System Service)
+ */
 static struct pass g_pass;
+
+/**
+ * @brief      Global instance indicating the D-Bus interface
+ *             for PASS (Power Aware System Service)
+ */
 static SystemPassCore *g_gdbus_instance = NULL;
 
 /******************************************************
@@ -89,6 +112,15 @@ static void pass_exit_done(void);
 /******************************************************
  *                PASS D-Bus interface                *
  ******************************************************/
+
+/**
+ * @brief      Callback function when receive the start requirement of
+ *             PASS(Power Aware System Service) core through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Not used
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_core_start(SystemPassCore *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -109,6 +141,14 @@ static gboolean dbus_cb_core_start(SystemPassCore *obj,
        return FALSE;
 }
 
+/**
+ * @brief      Callback function when receive the stop requirement of
+ *             PASS(Power Aware System Service) core through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Not used
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_core_stop(SystemPassCore *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -122,6 +162,12 @@ static gboolean dbus_cb_core_stop(SystemPassCore *obj,
        return TRUE;
 }
 
+/**
+ * @brief      Define the supported D-bus signal information for PASS (Power
+ *             Aware System Service) Core feature. It contains the signal name
+ *             and callback function pointer which is executed when receives
+ *             the defined signal.
+ */
 static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
        {
                .handler = DBUS_CORE_I_START_HANDLER,
@@ -146,6 +192,12 @@ static bool is_supported_module(struct pass_resource *res,
        return !!(supported_module[res->config_data.res_type] & type);
 }
 
+/**
+ * @brief      Initialize PASS(Power Aware System Service) modules
+ *             for each h/w resource.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_init_resource(struct pass_resource *res)
 {
        int ret;
@@ -236,6 +288,12 @@ err_resmon:
        return ret;
 }
 
+/**
+ * @brief      Exit PASS(Power Aware System Service) modules for each h/w
+ *             resource.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_exit_resource(struct pass_resource *res)
 {
        int ret;
@@ -290,6 +348,13 @@ static int pass_exit_resource(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Initialize all h/w resources when receiving 'finished' signal
+ *             from systemd.
+ * @param      [in] data Unused parameter
+ * @param      [in] user_data Unused parameter
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pass_init_done(void *data, void *user_data)
 {
        int i, ret;
@@ -352,6 +417,10 @@ static int pass_init_done(void *data, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Exit all h/w resources.
+ * @return     N/A
+ */
 static void pass_exit_done(void)
 {
        int i, ret = 0;
@@ -383,22 +452,22 @@ static void pass_exit_done(void)
        g_pass.state = PASS_OFF;
 }
 
-/*
- * pass_init - Initialize PASS(Power Aware System Service)
- *
- * @data: When the data is passed from main(), it is NULL.
- *     On the other hand, it will contain the result of this function
+/**
+ * @brief      Initialize PASS(Power Aware System Service) daemon.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
  */
 static void pass_init(void *data)
 {
        /* This is the only case of daemon creation: DO NOTHING */
 }
 
-/*
- * pass_exit - Exit PASS
- *
- * @data: When the data is passed from main(), it is NULL.
- *     On the other hand, it will contain the result of this function
+/**
+ * @brief      Exit PASS(Power Aware System Service) daemon.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
  */
 static void pass_exit(void *data)
 {
@@ -414,10 +483,13 @@ static void pass_exit(void *data)
        _I("Exit PASS daemon without any errors\n");
 }
 
-/*
- * pass_probe - Probe PASS
- *
- * @data: the data passed from main(), currently NULL
+/**
+ * @brief      Register a notifier for the 'finished' event of systemd.
+ *             The actual initialization of PASS(Power Aware System Service)
+ *             daemon is performed by this notifier after booting is completely
+ *             done.
+ * @param      [in] data The data passed from main(), currently NULL
+ * @return     @c 0 on success, otherwise error value
  */
 static int pass_probe(void *data)
 {
index b77ffb79f0ec18f674e3e1a7fc8e62f43e57b871..5c1bfe77bd9a83e325a7d9110a4682454da78b58 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pass.h
+ * @brief      Initialize all modules of PASS (Power Aware System Service)
+ *             system daemon and get the shared library from HAL (Hardware
+ *             Abstract Layer) package in order to control and monitor h/w
+ *             resources such as CPU/GPU/Memory Bus/Memory and so on.
+ *             Allocate the power-related resources based on the configuration
+ *             files like /etc/pass/pass.conf. Also, control the start and stop
+ *             of PASS core when receiving D-Bus command.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #ifndef __PASS__
 #define __PASS__
 
 struct pass_resource;
 struct pass_cpuhp_governor;
 
-/*
- * enum pass_module_type - Define supported modules of PASS
- *
- * PASS_MODULE_PARSER: Represents the parser module
- * PASS_MODULE_RESCON: Represents the Resource Monitor module
- * PASS_MODULE_RESMON: Represents the Resource Controller module
- * PASS_MODULE_PMQOS: Represents the Scenario-based PMQoS module
- * PASS_MODULE_CPUHP: Represents the CPU Hotplug Manager module
- * PASS_MODULE_THERMAL: Represents the Thermal Monitor module
+/**
+ * @brief      Define supported modules of PASS(Power Aware System Service).
  */
 enum pass_module_type {
-       PASS_MODULE_UNKNOWN             = 0x0,
-
-       PASS_MODULE_PARSER              = 0x1,
-       PASS_MODULE_RESCON              = 0x2,
-       PASS_MODULE_RESMON              = 0x4,
-       PASS_MODULE_PMQOS               = 0x8,
-       PASS_MODULE_CPUHP               = 0x10,
-       PASS_MODULE_THERMAL             = 0x20,
+       PASS_MODULE_UNKNOWN     = 0x0,  /** Unknown module */
+
+       PASS_MODULE_PARSER      = 0x1,  /** Parser module */
+       PASS_MODULE_RESCON      = 0x2,  /** Resource Controller module */
+       PASS_MODULE_RESMON      = 0x4,  /** Resource Monitor module */
+       PASS_MODULE_PMQOS       = 0x8,  /** PMQoS module */
+       PASS_MODULE_CPUHP       = 0x10, /** CPU Core On/Off Manager module */
+       PASS_MODULE_THERMAL     = 0x20, /** Thermal Monitor module */
 };
 
-/*
- * PASS Governor type
+/**
+ * @brief      Define supported governor type.
  *
  * ---------------------------------------------------------------------------
  * | Governor name    | HAL       | Resource   | Hotplug   | Runtime         |
@@ -78,107 +83,161 @@ enum pass_gov_type {
        PASS_GOV_END,
 };
 
+/**
+ * @brief      Define state of PASS(Power Aware System Service) and modules.
+ */
 enum pass_state {
-       PASS_UNUSED = -1,
-       PASS_OFF = 0,
-       PASS_ON = 1,
+       PASS_UNUSED = -1,       /** Uninitialized state of modules */
+       PASS_OFF = 0,           /** Inactive state of modules */
+       PASS_ON = 1,            /** Active state of modules */
 };
 
+/**
+ * @brief      Represent condition of level change between pass_level for only
+ *             CPUHP (CPU Core On/Off Manager) module.
+ */
 struct pass_level_condition {
-       int freq;
-       int nr_running;
-       int busy_cpu;
-       int avg_load;
+       int freq;               /** Frequency */
+       int nr_running;         /** The number of running tasks */
+       int busy_cpu;           /** The number of busy CPU  */
+       int avg_load;           /** CPU utilization */
 };
 
 /******************************************************
  *                   PASS Basic Unit                  *
  ******************************************************/
 
-/*
- * struct pass_level - Represent 'level' which includes real value of h/w
- *
- * @limit_max_freq: the limited maximum frequency
- *     this property is used for the following resoures:
- *     - PASS_RESOURCE_CPU_ID
- *     - PASS_RESOURCE_BUS_ID
- *     - PASS_RESOURCE_GPU_ID
- * @limit_min_freq: the limited minimum frequency
- *     this property is used for the following resoures:
- *     - PASS_RESOURCE_CPU_ID
- *     - PASS_RESOURCE_BUS_ID
- *     - PASS_RESOURCE_GPU_ID
- * @limit_min_cpu: the minimum number of online CPUs
- *     this property is used for the following resoures:
- *     - PASS_RESOURCE_CPU_ID
- *     - PASS_RESOURCE_BUS_ID
- *     - PASS_RESOURCE_GPU_ID
- * @fault_around_bytes: the number of bytes to be mapped around the fault
- *     this property is used for the following resoures:
- *     - PASS_RESOURCE_MEMORY_ID
- *
- * @gov_timeout: the period of timer for each PASS's level
- *     this property is used for the following resoures:
- *     - PASS_RESOURCE_CPU_ID
- *
- * @{up|down|left|right}_cond: the conditions to move next PASS's level
- *     these properties are used for the following resoures and
- *     they are valid when governor type is either GOV_RADIATION or GOV_STEP.
- *     - PASS_RESOURCE_CPU_ID
- * @num_{up|down|left|right}: the number of conditions
- *     these properties are used for the following resoures and
- *     they are valid when governor type is either GOV_RADIATION or GOV_STEP.
- *     - PASS_RESOURCE_CPU_ID
+/**
+ * @brief      Represent the basic unit of PASS (Power Aware System Service)
+ *             which contains the value of h/w resource if this pass_level is
+ *             selected. And includes the condition to change between
+ *             pass_level.
  */
 struct pass_level {
        /* Properties for the h/w resources */
+
+       /**
+        * Limited maximum frequency
+        * and this property is used for following resources:
+        * - PASS_RESOURCE_CPU_ID
+        * - PASS_RESOURCE_BUS_ID
+        * - PASS_RESOURCE_GPU_ID
+        */
        int limit_max_freq;
+       /**
+        * Limited minimum frequency
+        * and this property is used for following resources:
+        * - PASS_RESOURCE_CPU_ID
+        * - PASS_RESOURCE_BUS_ID
+        * - PASS_RESOURCE_GPU_ID
+        */
        int limit_min_freq;
+       /**
+        * The minimum number of online CPU
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        * - PASS_RESOURCE_BUS_ID
+        * - PASS_RESOURCE_GPU_ID
+        */
        int limit_min_cpu;
-
+       /**
+        * The number of bytes to be mapped around the fault
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_MEMORY_ID
+        */
        int fault_around_bytes;
 
+
        /* Properties for the timer */
+
+       /**
+        * Period of timer for each pass_level
+        * and this property is used for thefollowing resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        double gov_timeout;
 
        /* Properties for the GOV_RADIATION or GOV_STEP governor */
+
+       /**
+        * The up condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        struct pass_level_condition up_cond[PASS_LEVEL_COND_MAX];
+       /**
+        * The down condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        struct pass_level_condition down_cond[PASS_LEVEL_COND_MAX];
+       /**
+        * The left condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        struct pass_level_condition left_cond[PASS_LEVEL_COND_MAX];
+       /**
+        * The right condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        struct pass_level_condition right_cond[PASS_LEVEL_COND_MAX];
+
+       /**
+        * The number of up condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        int num_up_cond;
+       /**
+        * The number of down condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        int num_down_cond;
+       /**
+        * The number of left condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        int num_left_cond;
+       /**
+        * The number of right condition to change between pass_level
+        * and this property is used for the following resources:
+        * - PASS_RESOURCE_CPU_ID
+        */
        int num_right_cond;
 };
 
-/*
- * struct pass_scenario - Represent 'scenario'
- *
- * @name: the unique scenario name.
- * @state: the state of the scenario (either supported or not).
- * @pmqos: the private data for PASS_MODULE_PMQOS
- * - locked: the locked state of scenario (either locked or unlocked).
- * - locked_time: the requiired locking time of scenario.
- * - min_level: the required minimum PASS's level.
- * - max_level: the required maximum PASS's level.
- * @pmqos: the private data for PASS_MODULE_THERMAL
- * - temperature: the temperature of the scenario.
- * - timer_interval: the interval of timer-based monitor (unit: millisecond).
+/**
+ * @brief      Represent the scenario for specific situation like AppLaunch.
+ *             Modules like PASS_MODULE_PMQOS use it to define the scenario
+ *             with specific information.
  */
 struct pass_scenario {
+       /** Unique scenario name */
        char name[BUFF_MAX];
+       /** State of the scenario */
        enum pass_state state;
 
+       /** Private data for PASS_MODULE_PMQOS */
        struct {
+               /** Locked state of scenario (either locked or unlocked) */
                enum pass_state locked;
+               /** Requiired locking time of scenario */
                int64_t locked_time;
+               /** Required minimum pass_level */
                unsigned int min_level;
+               /** Required maximum pass_level */
                unsigned int max_level;
        } pmqos;
 
+       /** Private data for PASS_MODULE_THERMAL */
        struct {
+               /** Temperature of the scenario */
                int temperature;
+               /** Interval of timer-based monitor (unit: millisecond) */
                int timer_interval;
        } thermal;
 };
@@ -187,273 +246,303 @@ struct pass_scenario {
  *                   PASS Module                      *
  ******************************************************/
 
-/*
- * struct pass_rescon - Represent ResCon (Resource-Controller) module
- *
- * @state: the state of ResCon (either enabled or disabled).
- * @init_level: the required initial level when initializing h/w resource..
- * @curr_level: the current level controlled by resource-controller.
- * @prev_level: the previous level controlled by resource-controller.
- * @min_level: the available minimum level controlled by resource-controller.
- * @max_level: the available maxiumu level controlled by resource-controller.
- *
- * ResCon should be always enabled in order to controle h/w resources.
+/**
+ * @brief      Represent PASS_MODULE_RESCON (Resource Controller) module.
+ *             It should be always enabled in order to control h/w resources.
  */
 struct pass_rescon {
+       /** State of PASS_MODULE_RESCON */
        enum pass_state state;
 
+       /**
+        * Initial level when initializing h/w resource by resource controller
+        */
        unsigned int init_level;
+       /** Current level controlled by resource controller */
        unsigned int curr_level;
+       /** Previous level controlled by resource controller */
        unsigned int prev_level;
+       /** Available minimum level controlled by resource controller */
        unsigned int min_level;
+       /** Available maximum level controlled by resource controller */
        unsigned int max_level;
 };
 
-/*
- * struct pass_resmon - Represent ResMon (Resource Monitor) module
- *
- * @state: the state of ResMon (either enabled or disabled).
- * @timer_list: the list of required timer-based resource monitor.
- * @timer_state: the state of all timer-based resource-monitor.
- * @uevent_list: the list of required uevent-based resource monitor.
- * @uevent_state: the state of all uevent-based resource-monitor.
+/**
+ * @brief      Represent PASS_MODULE_RESMON (Resource Monitor) module.
+ *             It should be always enabled in order to monitor h/w resources.
  */
 struct pass_resmon {
+       /** State of PASS_MODULE_RESMON */
        enum pass_state state;
 
+       /** List of required timer-based resource monitor */
        GList *timer_list;
+       /** State of all timer-based resource-monitor */
        uint64 timer_state;
 
+       /** List of required uevent-based resource monitor */
        GList *uevent_list;
+       /** State of all uevent-based resource monitor */
        uint64 uevent_state;
 };
 
-/*
- * struct pass_pmqos - Represent PMQoS module
- *
- * @state: the state of PMQoS (either enabled or disabled).
- * @num_scenarios: the number of scenarios.
- * @num_locked_scenarios: the number of locked scenarios.
- * @scenarios: the list of scenarios.
- * @init_level: the initial level according to first locked scenario.
- * @curr_level: the current level according to locked scenarios.
- * @min_level: the available minimum level according to locked scenarios.
- * @max_level: the availabl maximum level according to locked scenarios.
- *
- * PMQoS may be enabled or disabled according to configuration file setting.
+/**
+ * @brief      Represent PASS_MODULE_PMQOS (PMQoS) module. It may be enabled
+ *             or disabled according to configuration.
  */
 struct pass_pmqos {
+       /** State of PASS_MODULE_PMQOS */
        enum pass_state state;
 
+       /** The number of scenarios */
        unsigned int num_scenarios;
+       /** The number of locked scenarios */
        unsigned int num_locked_scenarios;
+       /** The list of scenarios */
        struct pass_scenario *scenarios;
 
+       /** Initial level according to first locked scenario */
        unsigned int init_level;
+       /** Current level according to locked scenarios */
        unsigned int curr_level;
+       /** Available minimum level according to locked scenarios */
        unsigned int min_level;
+       /** Availabl maximum level according to locked scenarios */
        unsigned int max_level;
 };
 
-/*
- * struct pass_cpuhp - Represent CPUHP (CPU Hotplug Manager) module
- *
- * @state: the state of CPUHP (either enabled or disabled).
- * @pass_cpu_threshold:
- * @up_threshold: the threshold used when increasing the level
- * @down_threshold: the threshold used when decreasing the level
- * @last_time: the updated last time of cpu_stats
- * @governor: the instance of CPUHP Policy governor.
- * @max_freq: the maximum frequency among levels
- *
- * CPUHP may be o enabled or disabled according to configuration file setting.
+/**
+ * @brief      Represent PASS_MODULE_CPUHP (CPU Core On/Off Manager) module.
+ *             It may be enabled or disabled according to configuration.
  */
 struct pass_cpuhp {
+       /** State of PASS_MODULE_CPUHP */
        enum pass_state state;
 
+       /** Threshold used when decide whether CPU is busy or not */
        unsigned int pass_cpu_threshold;
+       /** Threshold used when increasing the pass_level */
        unsigned int up_threshold;
+       /** Threshold used when decreasing the pass_level */
        unsigned int down_threshold;
 
+       /** Updated last time of cpu_stats */
        int64_t last_time;
 
+       /** Instance of PASS_MODULE_CPUHP's governor */
        struct pass_cpuhp_governor *governor;
 
+       /** Maximum frequency among levels */
        unsigned int max_freq;
 };
 
-/*
- * struct pass_thermal - Represent Thermal Monitor module
- *
- * @state: the state of Thermal Monitor (either enabled or disabled).
- * @num_scenarios: the number of scenarios.
- * @scenarios: the list of scenarios.
- * @timer_interval: the interval of timer-based  monitor (unit: millisecond).
- * @curr_scenario_idx: the index of current thermal scenario.
- * @curr_temp: the current temperature.
- *
- * Thermal Monitor may be enabled or disabled according to configuration.
+/**
+ * @brief      Represent PASS_MODULE_THERMAL (Thermal Monitor) module.
+ *             It may be enabled or disabled according to configuration.
  */
 struct pass_thermal {
+       /** State of PASS_MODULE_THERMAL */
        enum pass_state state;
 
+       /** The number of scenarios */
        unsigned int num_scenarios;
+       /** List of thermal scenarios */
        struct pass_scenario *scenarios;
 
+       /** Interval of timer-based monitor (unit: millisecond) */
        unsigned int timer_interval;
+       /** Index of current thermal scenario */
        int curr_scenario_idx;
+       /** Current temperature */
        int curr_temp;
 };
 
 /******************************************************
  *                   PASS Resource                    *
  ******************************************************/
-/*
- * struct pass_resource_config_data - Parsed data for each h/w resource.
- *
- * Parsed data from resource list configuration (e.g., pass.conf)
- * [Mandatory]
- * @res_type: the unique id for each h/w resource. The id can have
- *     the one value among following defined resource id.
- *     -  1: PASS_RESOURCE_CPU_ID
- *     -  2: PASS_RESOURCE_BUS_ID
- *     -  3: PASS_RESOURCE_GPU_ID
- *     -  4: PASS_RESOURCE_MEMORY_ID
- *     - 99: PASS_RESOURCE_NONSTANDARD_ID
- * @res_name: the unique name of sysfs entry.
- *     - In case of /sys/devices/system/cpu/cpu0, res_name is 'cpu0'
- *     - In case of /sys/devices/system/cpu/cpu4, res_name is 'cpu4'
- *     - In case of /sys/class/devfreq/devfreq3, res_name is 'devfreq3'
- *     - In case of /sys/class/devfreq/mali.11400000, res_name is 'mali.11400000'
- * @res_thermal_name: the unique thermal sysfs node name for each resource
- *     - In the case of 'cpu0',
- *     the thermal sysfs node is /sys/class/thermal/thermal_zone3,
- *     then the res_thermal_name is 'thermal_zone3'
- * @path_conf_file: the path for PASS configuration file
- * @path_load_table: the path for load_table entry from kernel
- *
- * [Optional]
- * @num_cpus: the number of supported cpus in the same cluster.
- * @cpu: the index of first cpu in the same cluster.
- *
- *
- * Parsed data from each resource info configuration (e.g., pass-resource*.conf)
- * @gov_type: the governor type
- * @gov_timeout: the sampling rate of timer.
- * @default_min_level: the default minimum level.
- * @default_max_level: the default maximum level.
- * @num_levels: the number of levels.
- * @levels: the list of levels.
+
+/**
+ * @brief      Represent the parsed data for each h/w resource from
+ *             configurations. It contains following two parsed data:
+ *             - Parsed data from h/w resource list configuration
+ *             (/etc/pass/pass.conf)
+ *             - Parsed data from each h/w resource configuration
+ *             (/etc/pass/pass-resource-xxx.conf)
  *
- * 'struct pass_resource_config_data's data can't be changed after initialized.
- * It has the constant attribute after initialization step.
+ *             'struct pass_resource_config_data's data can't be changed after
+ *             initialized. It has the constant attribute after initialization
+ *             step.
  */
 struct pass_resource_config_data {
-       /* Parsed data from resource list configuration (e.g., pass.conf) */
+       /*
+        * Parsed data from resource list configuration
+        * (e.g., /etc/pass/pass.conf)
+        */
+
+       /**
+        * [mandatory] The unique id for each h/w resource. The id can have
+        * the one value among following defined resource id.
+        * -  1: PASS_RESOURCE_CPU_ID
+        * -  2: PASS_RESOURCE_BUS_ID
+        * -  3: PASS_RESOURCE_GPU_ID
+        * -  4: PASS_RESOURCE_MEMORY_ID
+        * - 99: PASS_RESOURCE_NONSTANDARD_ID
+        */
        unsigned int res_type;
+       /**
+        * [mandatory] the unique name of sysfs entry
+        * - In case of /sys/devices/system/cpu/cpu0, res_name is 'cpu0'.
+        * - In case of /sys/devices/system/cpu/cpu4, res_name is 'cpu4'.
+        * - In case of /sys/class/devfreq/devfreq3, res_name is 'devfreq3'.
+        * - In case of /sys/class/devfreq/mali.11400000,
+        *   res_name is 'mali.11400000'.
+        */
        char res_name[BUFF_MAX];
+       /**
+        * [optional] the unique thermal sysfs node name for each resource
+        * - In the case of 'cpu0',
+        *   If thermal sysfs node is /sys/class/thermal/thermal_zone3,
+        *   res_thermal_name is 'thermal_zone3'.
+        */
        char res_thermal_name[BUFF_MAX];
+       /** [mandatory] Path fo configuration for each h/w resource */
        char path_conf_file[BUFF_MAX];
-       char path_load_table[BUFF_MAX];
 
+       /**
+        * Path for load_table entry from kernel. If res_type is
+        * PASS_RESOURCE_CPU_ID, it is mandatory.
+        */
+       char path_load_table[BUFF_MAX];
+       /**
+        * The number of supported CPU in the same cluster.
+        * If res_type is PASS_RESOURCE_CPU_ID, it is mandatory.
+        */
        unsigned int num_cpus;
+       /**
+        * [optional] Index of first cpu in the same cluster.
+        * If res_type is PASS_RESOURCE_CPU_ID, it is mandatory.
+        */
        unsigned int cpu;
 
        /*
         * Parsed data from each resource info configuration
-        * (e.g., pass-resource*.conf)
+        * (e.g., /etc/pass/pass-resource-xxx.conf)
         */
+
+       /** State of each h/w resource (supported or not) */
        enum pass_state state;
+       /** governor type */
        enum pass_gov_type gov_type;
+       /** Interval for periodic timer */
        double gov_timeout;
+       /** Default minimum level */
        unsigned int default_min_level;
+       /** default maximum level */
        unsigned int default_max_level;
 
+       /** The number of pass_levels */
        unsigned int num_levels;
+       /** List of pass_levels */
        struct pass_level *levels;
 };
 
-/*
- * struct pass_resource_init_data - Represent initial data of each h/w resource.
- *
- * @dvfs: the initial value of dvfs configuration
- * - governor: the initial type of current governor
- * - min_freq: the initial value of minimum frequency
- * - max_freq: the initial value of maximum frequency
- * - up_threshold: the initial threshold of boosting frequency
- * @hotplug: the initial value of hotplug configuration
- * - online_state: the array of resource's online state
- * - online_min_num: the initial minimum number of online resources
- * - online_max_num: the initial maximum number of online resources
- * @tmu: the initial value of tmu configuration
- * @memory: the initial value of memory configuration
- * - fault_around_bytes: the number of bytes to be mapped around the fault
+/**
+ * @brief      Represent initial data of each h/w resource before starting
+ *             PASS (Power Aware System Service). It will be used when stop
+ *             PASS daemon and restore to previous state for h/w resources.
  *
- * 'struct pass_resource_init_data's data can't be changed after initialized.
- * It has the constant attribute after initialization step.
+ *             'struct pass_resource_init_data's data can't be changed after
+ *             initialized. It has the constant attribute after initialization
+ *             step.
  */
 struct pass_resource_init_data {
+       /**
+        * Initial state of DVFS (Dynamic Voltage and Frequency Scaling)
+        * properties.
+        */
        struct {
+               /** Initial type of current governor */
                char *governor;
+               /** Initial value of minimum frequency */
                int min_freq;
+               /**  Initial value of maximum frequency */
                int max_freq;
+               /** Initial threshold of boosting frequency */
                int up_threshold;
        } dvfs;
 
+       /** Initial state of hotplug properties */
        struct {
+               /** Array of CPU online state */
                int *online_state;
+               /** Initial minimum number of online CPU */
                int online_min_num;
+               /** Initial maximum number of online CPU */
                int online_max_num;
        } hotplug;
 
+       /** Initial state of thermal configuration */
        struct {
                /* NOTE: tmu has no writable data yet. */
        } tmu;
 
+       /** Initial state of memory configuration */
        struct {
+               /** the number of bytes to be mapped around the fault */
                int fault_around_bytes;
        } memory;
 };
 
-/*
- * struct pass_resource - Represent the each h/w resource.
- *
- * @state: the state of h/w resource (either initialized or not).
- * @config_data: the parsed data from configuration files (pass.conf,
- *             pass-resource*.conf).
- * @init_data: the initial data to restore when pass service is stopped
- * @hal: the hal instance of each h/w resource from pass_get_hal_info().
- * - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
- * - If res_type of cdata is PASS_RESOURCE_BUS_ID, hal.bus will be used.
- * - If res_type of cdata is PASS_RESOURCE_GPU_ID, hal.gpu will be used.
- * - If res_type of cdata is PASS_RESOURCE_MEMORY_ID, hal.memory will be used.
- * - If res_type of cdata is PASS_RESOURCE_NONSTANDARD_ID,
- *   hal.nonstandard will be used.
- * @rescon: represents ResCon (Resource Controller) module.
- * @resmon: represents ResMon (Resource Monitor) module.
- * @cpuhp: represents CPUHP (CPU Hotplug Manager) module.
- * @pmqos: represents PMQoS module.
- * @thermal: represents Thermal Monitor module.
+/**
+ * @brief      Represent the each h/w resource. 'struct pass' is basic unit
+ *             to handle h/w resources by PASS (Power Aware System Service).
  */
 struct pass_resource {
+       /** State of h/w resource (either initialized or not) */
        enum pass_state state;
 
+       /**
+        * The parsed data from configuration files (pass.conf,
+        * pass-resource-xxx.conf).
+        */
        struct pass_resource_config_data config_data;
+
+       /** Initial data to restore when pass service is stopped */
        struct pass_resource_init_data init_data;
 
+       /**
+        * The hal instance of each h/w resource from pass_get_hal_info().
+        * - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
+        * - If res_type of cdata is PASS_RESOURCE_BUS_ID, hal.bus will be used.
+        * - If res_type of cdata is PASS_RESOURCE_GPU_ID, hal.gpu will be used.
+        * - If res_type of cdata is PASS_RESOURCE_MEMORY_ID,
+        *   hal.memory will be used.
+        * - If res_type of cdata is PASS_RESOURCE_NONSTANDARD_ID,
+        *   hal.nonstandard will be used.
+        */
        union {
+               /** Instance for CPU h/w resource */
                struct pass_resource_cpu *cpu;
+               /** Instance for Memory Bus h/w resource */
                struct pass_resource_bus *bus;
+               /** Instance for GPU h/w resource */
                struct pass_resource_gpu *gpu;
+               /** Instance for Memory h/w resource */
                struct pass_resource_memory *memory;
+               /** Instance for Nonstandard h/w resource */
                struct pass_resource_nonstandard *nonstandard;
        } hal;
 
+       /** Instance of PASS_MODULE_RESCON module */
        struct pass_rescon rescon;
+       /** Instance of PASS_MODULE_RESMON module */
        struct pass_resmon resmon;
-
+       /** Instance of PASS_MODULE_CPUHP module */
        struct pass_cpuhp cpuhp;
+       /** Instance of PASS_MODULE_PMQOS module */
        struct pass_pmqos pmqos;
+       /** Instance of PASS_MODULE_THERMAL module */
        struct pass_thermal thermal;
 };
 
@@ -461,16 +550,15 @@ struct pass_resource {
  *                   PASS global structure            *
  ******************************************************/
 
-/*
- * struct pass - Represent the each h/w resource.
- *
- * @state: the state of PASS subsystem (either started or stoped by systemctl)
- * @num_resources: the number of h/w resources
- * @res: the list of h/w resources
+/**
+ * @brief      Represent PASS(Power Aware System Serice).
  */
 struct pass {
+       /** State of PASS daemon */
        enum pass_state state;
+       /** The number of h/w resources */
        unsigned int num_resources;
+       /** List of h/w resources */
        struct pass_resource *res;
 };
 
index 8352f08083062923c49b304eb2dd1342499fda03..168c78e3ae0c07c58ff4dc68cf9dc72ba006e6cb 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pmqos-parser.c
+ * @brief      Parse the supported PMQoS(Power Management Quality of Service)
+ *             scenario information from /etc/pass/pass-pmqos.conf
+ *             configuration.
+ *             - /etc/pass/pass-pmqos.conf contains the list and information
+ *             for supported PMQoS scenarios. For example, AppLaunch and
+ *             UltraPowerSaving.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #include <stdio.h>
 #include <stdbool.h>
@@ -40,6 +50,14 @@ static bool is_supported(const char *value)
        return false;
 }
 
+/**
+ * @brief      Parse scenario section to get a scenario information
+ *             for PMQoS(Power Management Quality of Service).
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance for each scenario
+ * @param      [in] index Index of each scenario
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_parse_scenario(struct parse_result *result, void *user_data, unsigned int index)
 {
        struct pmqos_scenario *scenarios = (struct pmqos_scenario *)user_data;
@@ -100,6 +118,14 @@ static int pmqos_parse_scenario(struct parse_result *result, void *user_data, un
        return 0;
 }
 
+/**
+ * @brief      Parse configuration to get information of supported scenarios
+ *             for PMQoS(Power Management Quality of Service) such as
+ *             AppLaunch, UltraPowerSaving.
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance for each scenario
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_load_config(struct parse_result *result, void *user_data)
 {
        struct pmqos_scenario *scenarios = (struct pmqos_scenario *)user_data;
@@ -141,6 +167,12 @@ out:
        return 0;
 }
 
+/**
+ * @brief      Free all scenarios information of PMQoS(Power Management
+ *             Quality of Service).
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int pmqos_put_scenario(struct pmqos_scenario *scenarios)
 {
        if (!scenarios)
@@ -156,6 +188,13 @@ int pmqos_put_scenario(struct pmqos_scenario *scenarios)
        return 0;
 }
 
+/**
+ * @brief      Get all scenarios information for PMQoS(Power Management
+ *             Quality of Service).
+ * @param      [in] path Path of configuration file for all scenarios
+ * @param      [in] scenarios Parsed data of scenarios will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ */
 int pmqos_get_scenario(const char *path, struct pmqos_scenario *scenarios)
 {
        int ret;
index 0c8355b36a0cbfe37ba98db8644832d53edb195e..13aae6942b4d937c5bd8f90a52b83614cb457a97 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pmqos.c
+ * @brief      Provide PMQoS (Power Management Quality of Service) external
+ *             D-bus interface and handle the asked scenarios from external
+ *             user. Verify whether the asked scenarios are supported or not
+ *             and control the timeout of asked scenario in order to keep
+ *             the scenario during the asked timeout. After expired, release
+ *             the scenario in order to prevent the infinite occupation.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <glib.h>
 #include <stdio.h>
 #include <limits.h>
 #define MILLISECONDS(tv)       ((tv.tv_sec)*1000 + (tv.tv_nsec)/1000000)
 #define DELTA(a, b)            (MILLISECONDS(a) - MILLISECONDS(b))
 
+/**
+ * @brief      Global instance indicating the PMQoS D-Bus interface
+ *             for PASS (Power Aware System Service)
+ */
 static SystemPassPmqos *g_gdbus_instance = NULL;
+
+/**
+ * @brief      Global instance indicating PMQoS feature for PASS (Power Aware
+ *             System Service)
+ */
 static struct pmqos_scenario *g_pmqos = NULL;
 
 struct pmqos_cpu {
@@ -74,6 +94,15 @@ static int pmqos_request(const char *name, int val);
 /******************************************************
  *                PASS D-Bus interface                *
  ******************************************************/
+
+/**
+ * @brief      Callback function when receive the start requirement of PMQoS
+ *             feature through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Not used
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_pmqos_start(SystemPassPmqos *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -95,6 +124,14 @@ static gboolean dbus_cb_pmqos_start(SystemPassPmqos *obj,
        return FALSE;
 }
 
+/**
+ * @brief      Callback function when receive the stop requirement of PMQoS
+ *             feature through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Unused parameter
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_pmqos_stop(SystemPassPmqos *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -108,6 +145,15 @@ static gboolean dbus_cb_pmqos_stop(SystemPassPmqos *obj,
        return TRUE;
 }
 
+/**
+ * @brief      Callback function when receive the scenario like AppLaunch,
+ *             UltraPowerSaving through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] duration Duration to keep scenario during demanded time
+ * @param      [in] user_data Unused parameter
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj,
                GDBusMethodInvocation *invoc,
                int duration,
@@ -158,6 +204,11 @@ out:
        return ret_out;
 }
 
+/**
+ * @brief      Define the supported D-bus signal information for PMQoS
+ *             feature. It contains the signal name and callback function
+ *             pointer which is executed when receives the defined signal.
+ */
 static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
        {
                .handler = DBUS_PMQOS_I_APPLAUNCH_HANDLER,
@@ -210,6 +261,13 @@ static int compare_timeout(const void *a, const void *b)
        return 0;
 }
 
+/**
+ * @brief      Request to keep or cancel the scenario to PASS_MODULE_PMQOS
+ *             according to the duration.
+ * @param      [in] name Scenario name like AppLaunch
+ * @param      [in] duration Duration to keep scenario during demanded time
+ * @return     @c 0 on success, otherwise error value
+ */
 static int set_pmqos(const char *name, int val)
 {
        char scenario[100];
@@ -224,6 +282,11 @@ static int set_pmqos(const char *name, int val)
        return 0;
 }
 
+/**
+ * @brief      Update the interval of registered timer when scenario is either
+ *             added or removed from the registered scenario list.
+ * @return     N/A
+ */
 static void pmqos_unlock_timeout_update(void)
 {
        GList *elem, *next;
@@ -263,6 +326,11 @@ static void pmqos_unlock_timeout_update(void)
        }
 }
 
+/**
+ * @brief      Request to cancel the already required scenario.
+ * @param      [in] name Scenario name like AppLaunch
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_cancel(const char *name)
 {
        GList *elem;
@@ -295,6 +363,11 @@ out:
        return 0;
 }
 
+/**
+ * @brief      Register a timer with the duration. If timer is expired, cancel
+ *             the required scenario.
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_unlock_timer_start(void)
 {
        int ret;
@@ -330,6 +403,12 @@ static int pmqos_unlock_timer_start(void)
        return 0;
 }
 
+/**
+ * @brief      Request to keep the scenario during the demanded time.
+ * @param      [in] name Scenario name like AppLaunch
+ * @param      [in] duration Duration to keep scenario during demanded time
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_request(const char *name, int val)
 {
        GList *elem;
@@ -383,6 +462,13 @@ err:
        return ret;
 }
 
+/**
+ * @brief      Initialize the resources of PMQoS feature when receiving
+ *             'finished' signal from systemd.
+ * @param      [in] data Unused parameter
+ * @param      [in] user_data Unused parameter
+ * @return     @c 0 on success, otherwise error value
+ */
 static int pmqos_init_done(void *data, void *user_data)
 {
        int *booting_done;
@@ -436,12 +522,22 @@ static int pmqos_init_done(void *data, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Initialize PMQoS feature.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
+ */
 static void pmqos_init(void *data)
 {
        /* This is the case of daemon creation: DO NOTHING */
        return;
 }
 
+/**
+ * @brief      Free the resources of PMQoS feature.
+ * @return     N/A
+ */
 static void pmqos_free(void)
 {
        int ret;
@@ -468,6 +564,13 @@ static void pmqos_free(void)
        }
 }
 
+
+/**
+ * @brief      Exit PMQoS feature.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
+ */
 static void pmqos_exit(void *data)
 {
        unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
@@ -480,10 +583,13 @@ static void pmqos_exit(void *data)
        pmqos_free();
 }
 
-/*
- * pmqos_probe - Probe PMQOS
- *
- * @data: the data passed from main(), currently NULL
+/**
+ * @brief      Register a notifier for the 'finished' event of systemd.
+ *             The actual initialization of PMQoS feature of PASS(Power Aware
+ *             System Service) daemon is performed by this notifier
+ *             after booting is completely done.
+ * @param      [in] data The data passed from main(), currently NULL
+ * @return     @c 0 on success, otherwise error value
  */
 static int pmqos_probe(void *data)
 {
index 2337cb7a6a4de1b7177289e48300ef86f112d824..4058d4c4f4c755a2ac55b7032e7015cf9d816287 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       pmqos.h
+ * @brief      Provide PMQoS (Power Management Quality of Service) external
+ *             D-bus interface and handle the asked scenarios from external
+ *             user. Verify whether the asked scenarios are supported or not
+ *             and control the timeout of asked scenario in order to keep
+ *             the scenario during the asked timeout. After expired, release
+ *             the scenario in order to prevent the infinite occupation.
+ * @ingroup    COM_POWER_MGNT
+ */
 
 #ifndef __PMQOS_H__
 #define __PMQOS_H__
 #include <stdbool.h>
 #include <limits.h>
 
+/**
+ * @brief      Represent PMQoS feature of PASS(Power Aware System Service).
+ */
 struct pmqos_scenario {
+       /** List of supported PMQoS scenarios */
        struct scenario {
-               char name[NAME_MAX];
-               bool support;
+               char name[NAME_MAX];    /** Unique scenario name */
+               bool support;           /** State is either supported or not */
        } *list;
+
+       /** The number of supported PMQoS scenarios */
        int num;
+       /** Maximum duration */
        int max_timeout_ms;
+       /** State of PMQoS feature is either supported or not*/
        bool support;
 };
 
index 3dab8b5e1cf05345bc5cb426db3e9ab643871f87..6b3dd8d7e414a5f59fe73b0103ae7f1d587d7450 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       thermal-parser.c
+ * @brief      Parse the supported thermal scenario information from
+ *             /etc/pass/pass-thermal.conf configuration.
+ *             - /etc/pass/pass-thermal.conf contains the list and information
+ *             for supported thermal scenarios. For example, ReleaseAction,
+ *             WarningAction, LimitAction and ShutdownAction.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <stdio.h>
 #include <stdbool.h>
 #include <stdlib.h>
@@ -41,6 +51,14 @@ static bool is_supported(const char *value)
        return false;
 }
 
+/**
+ * @brief      Parse scenario section to get a scenario information
+ *             for Thermal Monitor.
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance for each scenario
+ * @param      [in] index Index of each scenario
+ * @return     @c 0 on success, otherwise error value
+ */
 static int thermal_parse_scenario(struct parse_result *result, void *user_data,
                                        unsigned int index)
 {
@@ -88,6 +106,13 @@ static int thermal_parse_scenario(struct parse_result *result, void *user_data,
        return 0;
 }
 
+/**
+ * @brief      Parse configuration to get information of supported scenarios
+ *             for Thermal Monitor such as ReleaseAction, WarningAction.
+ * @param      [in] result Parsed raw data from configuration
+ * @param      [in] user_data Instance for each scenario
+ * @return     @c 0 on success, otherwise error value
+ */
 static int thermal_load_config(struct parse_result *result, void *user_data)
 {
        struct thermal_scenario *scenarios
@@ -131,6 +156,11 @@ out:
        return 0;
 }
 
+/**
+ * @brief      Free all scenarios information of Thermal Monitor.
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
 int thermal_put_scenario(struct thermal_scenario *scenarios)
 {
        if (!scenarios)
@@ -145,6 +175,12 @@ int thermal_put_scenario(struct thermal_scenario *scenarios)
        return 0;
 }
 
+/**
+ * @brief      Get all scenarios information for Thermal Monitor.
+ * @param      [in] path Path of configuration file for all scenarios
+ * @param      [in] scenarios Parsed data of scenarios will be saved to it
+ * @return     @c 0 on success, otherwise error value
+ */
 int thermal_get_scenario(const char *path, struct thermal_scenario *scenarios)
 {
        int ret;
index 8c80aefc6e88216ea674d7554ec2316412f52c2e..2bab82d636cab4d54c7268c4695400afe6fab6d7 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       thermal.c
+ * @brief      Provide Thermal Monitor external D-bus interface and verify
+ *             whether the thermal scenarios are supported or not and then
+ *             send broadcasting D-bus signal with the decided thermal
+ *             scenario like ReleseAction through D-bus interface.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #include <glib.h>
 #include <stdio.h>
 #include <string.h>
 
 #define THERMAL_CONF_PATH              "/etc/pass/pass-thermal.conf"
 
+/**
+ * @brief      Global instance indicating the Thermal Monitor D-Bus interface
+ *             for PASS (Power Aware System Service)
+ */
 static SystemPassMonitorThermal *g_gdbus_instance = NULL;
+
+/**
+ * @brief      Global instance indicating Thermal Monitor feature for PASS
+ *             (Power Aware System Service)
+ */
 static struct thermal_scenario *g_thermal = NULL;
 
+/**
+ * @brief      Free the resources of Thermal Monitor feature.
+ * @return     N/A
+ */
 static void thermal_free(void)
 {
        int ret;
@@ -46,6 +68,13 @@ static void thermal_free(void)
        g_thermal = NULL;
 }
 
+/**
+ * @brief      Initialize the resources of Thermal Monitor feature
+ *             when receiving 'finished' signal from systemd.
+ * @param      [in] data Unused parameter
+ * @param      [in] user_data Unused parameter
+ * @return     @c 0 on success, otherwise error value
+ */
 static int thermal_init_done(void *data, void *user_data)
 {
        int *booting_done;
@@ -91,6 +120,14 @@ static int thermal_init_done(void *data, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Callback function when receive the start requirement of
+ *             Thermal Monitor feature through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Not used
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_thermal_start(SystemPassMonitorThermal *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -112,6 +149,14 @@ static gboolean dbus_cb_thermal_start(SystemPassMonitorThermal *obj,
        return FALSE;
 }
 
+/**
+ * @brief      Callback function when receive the stop requirement of
+ *             Thermal Monitor feature through D-bus interface.
+ * @param      [in] obj Instance of SystemPassPmqos
+ * @param      [in] invoc Instance of GDBusMethodInvocation
+ * @param      [in] user_data Unused parameter
+ * @return     @c true if success, otherwise @c false if fail
+ */
 static gboolean dbus_cb_thermal_stop(SystemPassMonitorThermal *obj,
                GDBusMethodInvocation *invoc, gpointer user_data)
 {
@@ -125,7 +170,12 @@ static gboolean dbus_cb_thermal_stop(SystemPassMonitorThermal *obj,
        return TRUE;
 }
 
-
+/**
+ * @brief      Define the supported D-bus signal information for Thermal
+ *             Monitor feature. It contains the signal name and callback
+ *             function pointer which is executed when receives the defined
+ *             signal.
+ */
 static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
        {
                .handler = DBUS_THERMAL_I_START_HANDLER,
@@ -140,9 +190,12 @@ static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
        },
 };
 
-/*
- * data: thermal action string
- * user_data: instance of struct pass_resource
+/**
+ * @brief      Send broadcasting signal with the decided scenario name from
+ *             pass-thermal before checking whether the scenario is supported
+ *             or not..
+ * @param      [in] data Scenario name like ReleaseAction, WarningAction
+ * @param      [in] user_data Unused parameter
  */
 static int thermal_notifier_cb(void *data, void *user_data)
 {
@@ -186,12 +239,24 @@ static int thermal_notifier_cb(void *data, void *user_data)
        return 0;
 }
 
+/**
+ * @brief      Initialize Thermal Monitor feature.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
+ */
 static void thermal_init(void *data)
 {
        /* This is the case of daemon creation: DO NOTHING */
        return;
 }
 
+/**
+ * @brief      Exit Thermal Monitor feature.
+ * @param      [in] data When the data is passed from main(), it is NULL.
+ *             On the other hand, it will contain the result of this function
+ * @return     N/A
+ */
 static void thermal_exit(void *data)
 {
        unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
@@ -204,6 +269,14 @@ static void thermal_exit(void *data)
        thermal_free();
 }
 
+/**
+ * @brief      Register a notifier for the 'finished' event of systemd.
+ *             The actual initialization of Thermal Monitor feature of
+ *             PASS(Power Aware System Service) daemon is performed
+ *             by this notifier after booting is completely done.
+ * @param      [in] data The data passed from main(), currently NULL
+ * @return     @c 0 on success, otherwise error value
+ */
 static int thermal_probe(void *data)
 {
        int ret = 0;
index 9da0cdc3b91ebb654f85def8bfaea75554817822..fd8295c3c23150b230e02de37163b37e50d0f47c 100644 (file)
  * limitations under the License.
  */
 
+/**
+ * @file       thermal.h
+ * @brief      Provide Thermal Monitor external D-bus interface and verify
+ *             whether the thermal scenarios are supported or not and then
+ *             send broadcasting D-bus signal with the decided thermal
+ *             scenario like ReleseAction through D-bus interface.
+ * @ingroup    COM_POWER_MGNT
+ */
+
 #ifndef __THERMAL_H__
 #define __THERMAL_H__
 
 #include <stdbool.h>
 #include <limits.h>
 
+/**
+ * @brief      Represent Thermal Monitor feature of PASS(Power Aware System
+ *             Service).
+ */
 struct thermal_scenario {
+       /** List of supported Thermal Monitor scenarios */
        struct scenario {
-               char name[NAME_MAX];
-               bool support;
+               char name[NAME_MAX];    /** Unique scenario name */
+               bool support;           /** State is either supported or not */
        } *list;
 
+       /** The number of supported Thermal Monitor scenarios */
        int num;
+       /** State of Thermal Monitor feature is either supported or not*/
        bool support;
 };