Treat SYSTEM_IMAGE_RW_B also as RW copy

SYSTEM_IMAGE_RW_B hasn't been globally treated as a RW copy.
This change makes EC treat it also as a RW copy.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Iae5a9090cdf30f980014daca44cdf8f2a65ea1f2
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/656337
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Daisuke Nojiri
2017-09-07 14:44:55 -07:00
committed by chrome-bot
parent 103108ec21
commit 5da63f4ea2
21 changed files with 39 additions and 37 deletions

View File

@@ -358,8 +358,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -674,8 +674,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -344,8 +344,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -547,8 +547,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -380,8 +380,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -327,8 +327,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -59,7 +59,7 @@ static void board_init(void)
/* Set PD MCU system status bits */
if (system_jumped_to_this_image())
pd_status_flags |= PD_STATUS_JUMPED_TO_IMAGE;
if (system_get_image_copy() == SYSTEM_IMAGE_RW)
if (system_is_in_rw())
pd_status_flags |= PD_STATUS_IN_RW;
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);

View File

@@ -422,8 +422,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -19,8 +19,7 @@
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -326,8 +326,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -685,8 +685,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -657,8 +657,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -432,8 +432,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return (supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -358,8 +358,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -250,7 +250,7 @@ static void board_init(void)
/* Set PD MCU system status bits */
if (system_jumped_to_this_image())
pd_status_flags |= PD_STATUS_JUMPED_TO_IMAGE;
if (system_get_image_copy() == SYSTEM_IMAGE_RW)
if (system_is_in_rw())
pd_status_flags |= PD_STATUS_IN_RW;
#ifdef CONFIG_PWM
@@ -369,8 +369,7 @@ int pd_is_max_request_allowed(void)
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
else
return supplier == CHARGE_SUPPLIER_BC12_DCP ||

View File

@@ -190,8 +190,7 @@ int board_get_ramp_current_limit(int supplier, int sup_curr)
int board_is_ramp_allowed(int supplier)
{
/* Don't allow ramping in RO when write protected. */
if (system_get_image_copy() != SYSTEM_IMAGE_RW
&& system_is_locked())
if (!system_is_in_rw() && system_is_locked())
return 0;
/*

View File

@@ -368,7 +368,7 @@ static const uintptr_t get_pstate_addr(void)
uintptr_t addr = (uintptr_t)&pstate_data;
/* Always use the pstate data in RO, even if we're RW */
if (system_get_image_copy() == SYSTEM_IMAGE_RW)
if (system_is_in_rw())
addr += CONFIG_RO_MEM_OFF - CONFIG_RW_MEM_OFF;
return addr;

View File

@@ -497,6 +497,16 @@ static void jump_to_image(uintptr_t init_addr)
resetvec();
}
static int is_rw_image(enum system_image_copy_t copy)
{
return copy == SYSTEM_IMAGE_RW || copy == SYSTEM_IMAGE_RW_B;
}
int system_is_in_rw(void)
{
return is_rw_image(system_get_image_copy());
}
int system_run_image_copy(enum system_image_copy_t copy)
{
uintptr_t base;
@@ -515,7 +525,7 @@ int system_run_image_copy(enum system_image_copy_t copy)
return EC_ERROR_ACCESS_DENIED;
/* Target image must be RW image */
if (copy != SYSTEM_IMAGE_RW)
if (!is_rw_image(copy))
return EC_ERROR_ACCESS_DENIED;
/* Jumping must still be enabled */
@@ -588,7 +598,7 @@ static const struct image_data *system_get_image_data(
* Read the version information from the proper location
* on storage.
*/
addr += (copy == SYSTEM_IMAGE_RW) ?
addr += (is_rw_image(copy)) ?
CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF :
CONFIG_EC_PROTECTED_STORAGE_OFF + CONFIG_RO_STORAGE_OFF;

View File

@@ -1629,7 +1629,7 @@ static void pd_init_tasks(void)
enable = 0;
#elif defined(CONFIG_USB_PD_COMM_LOCKED)
/* Disable PD communication at init if we're in RO and locked. */
if (system_get_image_copy() != SYSTEM_IMAGE_RW && system_is_locked())
if (!system_is_in_rw() && system_is_locked())
enable = 0;
#endif
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++)

View File

@@ -47,6 +47,13 @@ enum system_image_copy_t {
SYSTEM_IMAGE_RW_B,
};
/**
* Checks if running image is RW or not
*
* @return True if system is running in a RW image or false otherwise.
*/
int system_is_in_rw(void);
/**
* Pre-initializes the module. This occurs before clocks or tasks are
* set up.

View File

@@ -313,7 +313,7 @@ static int test_overwrite_other(void)
uint32_t offset, size;
/* Test that we can overwrite the other image */
if (system_get_image_copy() == SYSTEM_IMAGE_RW) {
if (system_is_in_rw()) {
offset = CONFIG_RO_STORAGE_OFF;
size = CONFIG_RO_SIZE;
} else {