summaryrefslogtreecommitdiff
path: root/common/hooks.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-30 09:42:58 -0700
committerGerrit <chrome-bot@google.com>2012-10-30 12:42:40 -0700
commit4a0b4262d395ec2c46809e1584b2109f3a3d872e (patch)
tree3514f309c3b267a8c844d05324dc1b41058ad3c2 /common/hooks.c
parentc795ea69ff4930d90e3d0cbdc9a10332e34be2bb (diff)
downloadchrome-ec-4a0b4262d395ec2c46809e1584b2109f3a3d872e.tar.gz
Add tick task
Adds a new HOOK_TICK event which is called every 250ms (LM4) or 500ms (STM32). This will be used to consolidate a number of tasks which do small amounts of work infrequently, and previously needed their own task functions. This CL adds the tick task; subsequent CLs will consolidate watchdog and other tasks into tick hooks. BUG=chrome-os-partner:15714 BRANCH=none TEST=taskinfo shows TICK task as lowest priority Change-Id: I9068ee99d56a5bf5c12afd86ad51998c013f4954 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36908 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/hooks.c')
-rw-r--r--common/hooks.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/hooks.c b/common/hooks.c
index 81d84b3d00..385f0e0478 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -7,6 +7,7 @@
#include "hooks.h"
#include "link_defs.h"
+#include "timer.h"
#include "util.h"
struct hook_ptrs {
@@ -29,6 +30,7 @@ static const struct hook_ptrs hook_list[] = {
{__hooks_chipset_shutdown, __hooks_chipset_shutdown_end},
{__hooks_ac_change, __hooks_ac_change_end},
{__hooks_lid_change, __hooks_lid_change_end},
+ {__hooks_tick, __hooks_tick_end},
};
void hook_notify(enum hook_type type)
@@ -59,3 +61,17 @@ void hook_notify(enum hook_type type)
}
}
}
+
+void hook_task(void)
+{
+ while (1) {
+ uint64_t t = get_time().val;
+
+ hook_notify(HOOK_TICK);
+
+ /* Use up the rest of our hook tick interval */
+ t = get_time().val - t;
+ if (t < HOOK_TICK_INTERVAL)
+ usleep(HOOK_TICK_INTERVAL - t);
+ }
+}