blob: 47ad097c534403adc9392ad47e332a766612e586 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Chipset module for emulator */
/* Does not run a chipset task, but does emulate an AP chipset */
#define CONFIG_AP_POWER_CONTROL
#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(enum chipset_shutdown_reason reason)
{
fprintf(stderr, "Chipset reset: %d!\n", reason);
}
test_mockable void chipset_throttle_cpu(int throttle)
{
/* Do nothing */
}
test_mockable void chipset_force_shutdown(enum chipset_shutdown_reason reason)
{
/* Do nothing */
}
test_mockable int chipset_in_state(int state_mask)
{
return state_mask & chipset_state;
}
test_mockable int chipset_in_or_transitioning_to_state(int state_mask)
{
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) {
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);
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
}
|