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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "battery.h"
#include "charge_manager.h"
#include "common.h"
#include "cros_version.h"
#include "sysjump.h"
#include "system.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
char mock_jump_data[sizeof(struct jump_data) + 256];
/* When CONFIG_RAM_SIZE is defined, this is provided by common/system.c */
#ifndef CONFIG_RAM_SIZE
struct jump_data *get_jump_data(void)
{
return (struct jump_data *)&mock_jump_data;
}
#endif
__attribute__((weak)) void system_reset(int flags)
{
__builtin_unreachable();
}
__attribute__((weak)) void software_panic(uint32_t reason, uint32_t info)
{
__builtin_unreachable();
}
static uint8_t bbram[SYSTEM_BBRAM_IDX_TRY_SLOT + 1];
test_mockable int system_get_bbram(enum system_bbram_idx idx, uint8_t *value)
{
if (idx <= SYSTEM_BBRAM_IDX_TRY_SLOT) {
*value = bbram[idx];
return EC_SUCCESS;
}
return EC_ERROR_INVAL;
}
test_mockable int system_set_bbram(enum system_bbram_idx idx, uint8_t value)
{
if (idx <= SYSTEM_BBRAM_IDX_TRY_SLOT) {
bbram[idx] = value;
return EC_SUCCESS;
}
return EC_ERROR_INVAL;
}
/* When CONFIG_EC_PROTECTED_STORAGE_OFF is defined, this is provided by
* common/system.c
*/
#ifndef CONFIG_EC_PROTECTED_STORAGE_OFF
uint32_t flash_get_rw_offset(enum ec_image copy)
{
return 0;
}
#endif
/* When CONFIG_PLATFORM_EC_FLASH_CROS is defined, this is provided by
* common/flash.c
*/
#ifndef CONFIG_PLATFORM_EC_FLASH_CROS
int crec_flash_read(int offset, int size, char *data)
{
return EC_ERROR_INVAL;
}
uint32_t crec_flash_get_protect(void)
{
return 0;
}
#endif
test_mockable const char *system_get_chip_vendor(void)
{
return "Testing";
}
test_mockable const char *system_get_chip_name(void)
{
return "emu";
}
test_mockable const char *system_get_chip_revision(void)
{
return "";
}
test_mockable void board_reset_pd_mcu(void)
{
}
test_mockable void system_hibernate(uint32_t seconds, uint32_t microseconds)
{
}
|