diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/flash.c | 20 | ||||
-rw-r--r-- | common/fmap.c | 27 | ||||
-rw-r--r-- | common/system.c | 4 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 8 |
4 files changed, 28 insertions, 31 deletions
diff --git a/common/flash.c b/common/flash.c index 302dae0f08..6d903eca95 100644 --- a/common/flash.c +++ b/common/flash.c @@ -400,17 +400,11 @@ uint32_t flash_get_protect(void) /* Scan flash protection */ for (i = 0; i < PHYSICAL_BANKS; i++) { /* Is this bank part of RO */ - int is_ro = (i >= RO_BANK_OFFSET && - i < RO_BANK_OFFSET + RO_BANK_COUNT) ? 1 : 0; - int bank_flag; - -#if defined(CONFIG_FLASH_PSTATE) && defined(CONFIG_FLASH_PSTATE_BANK) - /* PSTATE acts like part of RO; protected at same time */ - if (i >= PSTATE_BANK && i < PSTATE_BANK + PSTATE_BANK_COUNT) - is_ro = 1; -#endif - bank_flag = (is_ro ? EC_FLASH_PROTECT_RO_NOW : - EC_FLASH_PROTECT_ALL_NOW); + int is_ro = (i >= WP_BANK_OFFSET && + i < WP_BANK_OFFSET + WP_BANK_COUNT) ? 1 : 0; + + int bank_flag = (is_ro ? EC_FLASH_PROTECT_RO_NOW : + EC_FLASH_PROTECT_ALL_NOW); if (flash_physical_get_protect(i)) { /* At least one bank in the region is protected */ @@ -879,11 +873,11 @@ static int flash_command_region_info(struct host_cmd_handler_args *args) switch (p->region) { case EC_FLASH_REGION_RO: - r->offset = CONFIG_RO_MEM_OFF; + r->offset = CONFIG_RO_STORAGE_OFF; r->size = CONFIG_RO_SIZE; break; case EC_FLASH_REGION_RW: - r->offset = CONFIG_RW_MEM_OFF; + r->offset = CONFIG_RW_STORAGE_OFF; r->size = CONFIG_RW_SIZE; break; case EC_FLASH_REGION_WP_RO: diff --git a/common/fmap.c b/common/fmap.c index 0785dc30d7..16b45c9db6 100644 --- a/common/fmap.c +++ b/common/fmap.c @@ -17,10 +17,10 @@ #define FMAP_VER_MINOR 0 /* - * For address containing CONFIG_FLASH_BASE (symbols in *.lds.S and variable), - * this computes the offset to the start of flash. + * For address containing CONFIG_FLASH_BASE (symbols in *.RO.lds.S and + * variable), this computes the offset to the start of the image on flash. */ -#define RELATIVE(addr) ((addr) - CONFIG_FLASH_BASE) +#define RELATIVE_RO(addr) ((addr) - CONFIG_FLASH_BASE - CONFIG_RO_MEM_OFF) struct fmap_header { char fmap_signature[FMAP_SIGNATURE_SIZE]; @@ -69,14 +69,14 @@ const struct _ec_fmap { * volatile data (ex, calibration results). */ .area_name = "EC_RO", - .area_offset = CONFIG_RO_MEM_OFF, + .area_offset = CONFIG_RO_STORAGE_OFF, .area_size = CONFIG_RO_SIZE, .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, }, { /* (Optional) RO firmware code. */ .area_name = "FR_MAIN", - .area_offset = CONFIG_RO_MEM_OFF, + .area_offset = CONFIG_RO_STORAGE_OFF, .area_size = CONFIG_RO_SIZE, .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, }, @@ -86,8 +86,8 @@ const struct _ec_fmap { * ASCII, and padded with \0. */ .area_name = "RO_FRID", - .area_offset = CONFIG_RO_MEM_OFF + - RELATIVE((uint32_t)__version_struct_offset) + + .area_offset = CONFIG_RO_STORAGE_OFF + + RELATIVE_RO((uint32_t)__version_struct_offset) + offsetof(struct version_struct, version), .area_size = sizeof(version_data.version), .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, @@ -96,8 +96,8 @@ const struct _ec_fmap { /* Other RO stuff: FMAP, WP, KEYS, etc. */ { .area_name = "FMAP", - .area_offset = CONFIG_RO_MEM_OFF + - RELATIVE((uint32_t)&ec_fmap), + .area_offset = CONFIG_RO_STORAGE_OFF + + RELATIVE_RO((uint32_t)&ec_fmap), .area_size = sizeof(ec_fmap), .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, }, @@ -117,7 +117,7 @@ const struct _ec_fmap { { /* The range of RW firmware to be auto-updated. */ .area_name = "EC_RW", - .area_offset = CONFIG_RW_MEM_OFF, + .area_offset = CONFIG_RW_STORAGE_OFF, .area_size = CONFIG_RW_SIZE, .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, }, @@ -125,10 +125,13 @@ const struct _ec_fmap { /* * RW firmware version ID. Must be NULL terminated * ASCII, and padded with \0. + * TODO: Get the relative offset of + * __version_struct_offset within our RW image to + * accomodate image asymmetry. */ .area_name = "RW_FWID", - .area_offset = CONFIG_RW_MEM_OFF + - RELATIVE((uint32_t)__version_struct_offset) + + .area_offset = CONFIG_RW_STORAGE_OFF + + RELATIVE_RO((uint32_t)__version_struct_offset) + offsetof(struct version_struct, version), .area_size = sizeof(version_data.version), .area_flags = FMAP_AREA_STATIC, diff --git a/common/system.c b/common/system.c index abb62e331b..a144935c4b 100644 --- a/common/system.c +++ b/common/system.c @@ -357,11 +357,11 @@ test_mockable int system_unsafe_to_overwrite(uint32_t offset, uint32_t size) switch (system_get_image_copy()) { case SYSTEM_IMAGE_RO: - r_offset = CONFIG_RO_MEM_OFF; + r_offset = CONFIG_RO_STORAGE_OFF; r_size = CONFIG_RO_SIZE; break; case SYSTEM_IMAGE_RW: - r_offset = CONFIG_RW_MEM_OFF; + r_offset = CONFIG_RW_STORAGE_OFF; r_size = CONFIG_RW_SIZE; break; default: diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 0ed69cb8a7..4ab8f870a3 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -819,7 +819,7 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_GET_AMODE, #endif -#define FW_RW_END (CONFIG_RW_MEM_OFF + CONFIG_RW_SIZE) +#define FW_RW_END (CONFIG_RW_STORAGE_OFF + CONFIG_RW_SIZE) uint8_t *flash_hash_rw(void) { @@ -881,14 +881,14 @@ int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload) if (system_get_image_copy() != SYSTEM_IMAGE_RO) break; pd_log_event(PD_EVENT_ACC_RW_ERASE, 0, 0, NULL); - flash_offset = CONFIG_RW_MEM_OFF; - flash_physical_erase(CONFIG_RW_MEM_OFF, CONFIG_RW_SIZE); + flash_offset = CONFIG_RW_STORAGE_OFF; + flash_physical_erase(CONFIG_RW_STORAGE_OFF, CONFIG_RW_SIZE); rw_flash_changed = 1; break; case VDO_CMD_FLASH_WRITE: /* do not kill the code under our feet */ if ((system_get_image_copy() != SYSTEM_IMAGE_RO) || - (flash_offset < CONFIG_RW_MEM_OFF)) + (flash_offset < CONFIG_RW_STORAGE_OFF)) break; flash_physical_write(flash_offset, 4*(cnt - 1), (const char *)(payload+1)); |