diff options
author | Vic Yang <victoryang@chromium.org> | 2013-07-23 01:58:49 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-22 16:09:47 -0700 |
commit | 8218aa1346e533423d445018a289f938f36bcebd (patch) | |
tree | 4ad96173a6f980034bc842e670f6ee87df59aed9 /board | |
parent | 2d205f97cbfd7eecf9d6cf6b9a44c4f667e9be79 (diff) | |
download | chrome-ec-8218aa1346e533423d445018a289f938f36bcebd.tar.gz |
Add system_common unit test
This tests reboot-on-ap-shutdown.
BUG=chrome-os-partner:19236
TEST=Pass the test
BRANCH=None
Change-Id: Ic1a07670f82646e85d014d52a2aba0835319c212
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62855
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/host/build.mk | 3 | ||||
-rw-r--r-- | board/host/chipset.c | 41 |
2 files changed, 38 insertions, 6 deletions
diff --git a/board/host/build.mk b/board/host/build.mk index 28525a7679..8b6ee6d2be 100644 --- a/board/host/build.mk +++ b/board/host/build.mk @@ -8,4 +8,5 @@ CHIP:=host -board-y=board.o chipset.o +board-y=board.o +board-$(HAS_TASK_CHIPSET)+=chipset.o diff --git a/board/host/chipset.c b/board/host/chipset.c index b06e293778..4197c46326 100644 --- a/board/host/chipset.c +++ b/board/host/chipset.c @@ -8,7 +8,13 @@ #include <stdio.h> #include "chipset.h" #include "common.h" +#include "hooks.h" #include "task.h" +#include "test_util.h" + +static int chipset_state = CHIPSET_STATE_SOFT_OFF; +static int power_on_req; +static int power_off_req; test_mockable void chipset_reset(int cold_reset) { @@ -20,15 +26,40 @@ test_mockable void chipset_force_shutdown(void) /* Do nothing */ } -#ifdef HAS_TASK_CHIPSET test_mockable int chipset_in_state(int state_mask) { - return state_mask & CHIPSET_STATE_SOFT_OFF; + return state_mask & chipset_state; +} + +void test_chipset_on(void) +{ + if (chipset_in_state(CHIPSET_STATE_ON)) + return; + power_on_req = 1; + task_wake(TASK_ID_CHIPSET); +} + +void test_chipset_off(void) +{ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return; + power_off_req = 1; + task_wake(TASK_ID_CHIPSET); } test_mockable void chipset_task(void) { - while (1) - task_wait_event(-1); + while (1) { + while (!power_on_req) + task_wait_event(-1); + power_on_req = 0; + hook_notify(HOOK_CHIPSET_PRE_INIT); + chipset_state = CHIPSET_STATE_ON; + hook_notify(HOOK_CHIPSET_STARTUP); + while (!power_off_req) + task_wait_event(-1); + power_off_req = 0; + chipset_state = CHIPSET_STATE_SOFT_OFF; + hook_notify(HOOK_CHIPSET_SHUTDOWN); + } } -#endif |