diff options
Diffstat (limited to 'chip')
-rw-r--r-- | chip/g/system.c | 46 | ||||
-rw-r--r-- | chip/g/upgrade.c | 4 | ||||
-rw-r--r-- | chip/g/upgrade_fw.c | 26 | ||||
-rw-r--r-- | chip/host/system.c | 16 | ||||
-rw-r--r-- | chip/ish/system.c | 4 | ||||
-rw-r--r-- | chip/mchp/lfw/ec_lfw.c | 15 | ||||
-rw-r--r-- | chip/mchp/system.c | 8 | ||||
-rw-r--r-- | chip/mec1322/lfw/ec_lfw.c | 12 | ||||
-rw-r--r-- | chip/mec1322/system.c | 8 | ||||
-rw-r--r-- | chip/mt_scp/ipi.c | 2 | ||||
-rw-r--r-- | chip/npcx/system.c | 28 |
11 files changed, 83 insertions, 86 deletions
diff --git a/chip/g/system.c b/chip/g/system.c index d68da094f2..86c3f52b5d 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -287,7 +287,7 @@ int system_set_bbram(enum system_bbram_idx idx, uint8_t value) return 0; } -enum system_image_copy_t system_get_ro_image_copy(void) +enum ec_image system_get_ro_image_copy(void) { /* * The bootrom protects the selected bootloader with REGION0, @@ -296,12 +296,12 @@ enum system_image_copy_t system_get_ro_image_copy(void) */ switch (GREG32(GLOBALSEC, FLASH_REGION0_BASE_ADDR)) { case CONFIG_PROGRAM_MEMORY_BASE + CONFIG_RO_MEM_OFF: - return SYSTEM_IMAGE_RO; + return EC_IMAGE_RO; case CONFIG_PROGRAM_MEMORY_BASE + CHIP_RO_B_MEM_OFF: - return SYSTEM_IMAGE_RO_B; + return EC_IMAGE_RO_B; } - return SYSTEM_IMAGE_UNKNOWN; + return EC_IMAGE_UNKNOWN; } /* @@ -324,19 +324,19 @@ struct version_struct_deprecated { #define MAX_RO_VER_LEN 48 static char vers_str[MAX_RO_VER_LEN]; -const char *system_get_version(enum system_image_copy_t copy) +const char *system_get_version(enum ec_image copy) { const struct image_data *data; const struct version_struct_deprecated *data_deprecated; const char *version; const struct SignedHeader *h; - enum system_image_copy_t this_copy; + enum ec_image this_copy; uintptr_t vaddr, delta; switch (copy) { - case SYSTEM_IMAGE_RO: - case SYSTEM_IMAGE_RO_B: + case EC_IMAGE_RO: + case EC_IMAGE_RO_B: /* The RO header is the first thing in each flash half */ vaddr = get_program_memory_addr(copy); if (vaddr == INVALID_ADDR) @@ -347,8 +347,8 @@ const char *system_get_version(enum system_image_copy_t copy) h->epoch_, h->major_, h->minor_, h->img_chk_); return vers_str; - case SYSTEM_IMAGE_RW: - case SYSTEM_IMAGE_RW_B: + case EC_IMAGE_RW: + case EC_IMAGE_RW_B: /* * This function isn't part of any RO image, so we must be in a * RW image. If the current image is the one we're asked for, @@ -499,16 +499,16 @@ static int current_image_is_newer(struct SignedHeader **newer_image) { struct SignedHeader *me, *other; - if (system_get_image_copy() == SYSTEM_IMAGE_RW) { + if (system_get_image_copy() == EC_IMAGE_RW) { me = (struct SignedHeader *) - get_program_memory_addr(SYSTEM_IMAGE_RW); + get_program_memory_addr(EC_IMAGE_RW); other = (struct SignedHeader *) - get_program_memory_addr(SYSTEM_IMAGE_RW_B); + get_program_memory_addr(EC_IMAGE_RW_B); } else { me = (struct SignedHeader *) - get_program_memory_addr(SYSTEM_IMAGE_RW_B); + get_program_memory_addr(EC_IMAGE_RW_B); other = (struct SignedHeader *) - get_program_memory_addr(SYSTEM_IMAGE_RW); + get_program_memory_addr(EC_IMAGE_RW); } if (a_is_newer_than_b(me, other)) @@ -710,11 +710,11 @@ void system_update_rollback_mask_with_active_img(void) void system_update_rollback_mask_with_both_imgs(void) { - update_rollback_mask(get_program_memory_addr(SYSTEM_IMAGE_RO), - get_program_memory_addr(SYSTEM_IMAGE_RO_B), + update_rollback_mask(get_program_memory_addr(EC_IMAGE_RO), + get_program_memory_addr(EC_IMAGE_RO_B), INFO_RO_MAP_OFFSET); - update_rollback_mask(get_program_memory_addr(SYSTEM_IMAGE_RW), - get_program_memory_addr(SYSTEM_IMAGE_RW_B), + update_rollback_mask(get_program_memory_addr(EC_IMAGE_RW), + get_program_memory_addr(EC_IMAGE_RW_B), INFO_RW_MAP_OFFSET); } @@ -727,9 +727,9 @@ void system_get_rollback_bits(char *value, size_t value_size) uint32_t image_types[2]; } headers[] = { { .info_map_offset = INFO_RO_MAP_OFFSET, - .image_types = { SYSTEM_IMAGE_RO, SYSTEM_IMAGE_RO_B } }, + .image_types = { EC_IMAGE_RO, EC_IMAGE_RO_B } }, { .info_map_offset = INFO_RW_MAP_OFFSET, - .image_types = { SYSTEM_IMAGE_RW, SYSTEM_IMAGE_RW_B } } + .image_types = { EC_IMAGE_RW, EC_IMAGE_RW_B } } }; for (i = 0; i < ARRAY_SIZE(headers); i++) { @@ -774,8 +774,8 @@ void system_print_extended_version_info(void) { int i; struct board_id bid; - enum system_image_copy_t rw_images[] = { - SYSTEM_IMAGE_RW, SYSTEM_IMAGE_RW_B + enum ec_image rw_images[] = { + EC_IMAGE_RW, EC_IMAGE_RW_B }; if (read_board_id(&bid) != EC_SUCCESS) { diff --git a/chip/g/upgrade.c b/chip/g/upgrade.c index 03c6a0450a..e7c6120615 100644 --- a/chip/g/upgrade.c +++ b/chip/g/upgrade.c @@ -75,13 +75,13 @@ static uint8_t headers_restored(void) uint8_t total_restored; /* Examine the RW first. */ - if (system_get_image_copy() == SYSTEM_IMAGE_RW) + if (system_get_image_copy() == EC_IMAGE_RW) total_restored = header_restored(CONFIG_RW_B_MEM_OFF); else total_restored = header_restored(CONFIG_RW_MEM_OFF); /* Now the RO */ - if (system_get_ro_image_copy() == SYSTEM_IMAGE_RO) + if (system_get_ro_image_copy() == EC_IMAGE_RO) total_restored += header_restored(CHIP_RO_B_MEM_OFF); else total_restored += header_restored(CONFIG_RO_MEM_OFF); diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c index 276eac8f92..1afadbc280 100644 --- a/chip/g/upgrade_fw.c +++ b/chip/g/upgrade_fw.c @@ -38,23 +38,23 @@ struct { /* Pick sections where updates can go to based on current code addresses. */ static void set_valid_sections(void) { - switch (system_get_ro_image_copy()) { - case SYSTEM_IMAGE_RO: - valid_sections.ro_base_offset = CHIP_RO_B_MEM_OFF; - break; - case SYSTEM_IMAGE_RO_B: - valid_sections.ro_base_offset = CONFIG_RO_MEM_OFF; - break; - default: - CPRINTF("Failed to set RO image offsets\n"); - return; - } + switch (system_get_ro_image_copy()) { + case EC_IMAGE_RO: + valid_sections.ro_base_offset = CHIP_RO_B_MEM_OFF; + break; + case EC_IMAGE_RO_B: + valid_sections.ro_base_offset = CONFIG_RO_MEM_OFF; + break; + default: + CPRINTF("Failed to set RO image offsets\n"); + return; + } switch (system_get_image_copy()) { - case SYSTEM_IMAGE_RW: + case EC_IMAGE_RW: valid_sections.rw_base_offset = CONFIG_RW_B_MEM_OFF; break; - case SYSTEM_IMAGE_RW_B: + case EC_IMAGE_RW_B: valid_sections.rw_base_offset = CONFIG_RW_MEM_OFF; break; default: diff --git a/chip/host/system.c b/chip/host/system.c index b1654911ab..adbf656ba8 100644 --- a/chip/host/system.c +++ b/chip/host/system.c @@ -24,7 +24,7 @@ uint8_t __shared_mem_buf[SHARED_MEM_SIZE + RAM_DATA_SIZE]; static char *__ram_data = __shared_mem_buf + SHARED_MEM_SIZE; -static enum system_image_copy_t __running_copy; +static enum ec_image __running_copy; static void ramdata_set_persistent(void) { @@ -77,7 +77,7 @@ static uint32_t get_image_copy(void) uint32_t ret; if (f == NULL) - return SYSTEM_IMAGE_UNKNOWN; + return EC_IMAGE_UNKNOWN; fread(&ret, sizeof(ret), 1, f); release_persistent_storage(f); remove_persistent_storage("image_copy"); @@ -177,7 +177,7 @@ test_mockable int system_is_locked(void) #ifdef TEST_FUZZ /* When fuzzing, do not allow sysjumps. */ -int system_run_image_copy(enum system_image_copy_t copy) +int system_run_image_copy(enum ec_image copy) { ccprints("Emulator would sysjump here. Fuzzing: doing nothing."); return EC_ERROR_UNKNOWN; @@ -209,7 +209,7 @@ int system_set_bbram(enum system_bbram_idx idx, uint8_t value) return EC_ERROR_UNIMPLEMENTED; } -enum system_image_copy_t system_get_image_copy(void) +enum ec_image system_get_image_copy(void) { return __running_copy; } @@ -251,13 +251,13 @@ static void __jump_resetvec(void) static void __ro_jump_resetvec(void) { - set_image_copy(SYSTEM_IMAGE_RO); + set_image_copy(EC_IMAGE_RO); __jump_resetvec(); } static void __rw_jump_resetvec(void) { - set_image_copy(SYSTEM_IMAGE_RW); + set_image_copy(EC_IMAGE_RW); __jump_resetvec(); } @@ -270,8 +270,8 @@ void system_pre_init(void) ramdata_get_persistent(); __running_copy = get_image_copy(); - if (__running_copy == SYSTEM_IMAGE_UNKNOWN) { - __running_copy = SYSTEM_IMAGE_RO; + if (__running_copy == EC_IMAGE_UNKNOWN) { + __running_copy = EC_IMAGE_RO; system_set_reset_flags(load_reset_flags()); } diff --git a/chip/ish/system.c b/chip/ish/system.c index c26026dcb8..caa5e15255 100644 --- a/chip/ish/system.c +++ b/chip/ish/system.c @@ -161,7 +161,7 @@ void htimer_interrupt(void) /* Time to wake up */ } -enum system_image_copy_t system_get_shrspi_image_copy(void) +enum ec_image system_get_shrspi_image_copy(void) { return 0; } @@ -171,7 +171,7 @@ uint32_t system_get_lfw_address(void) return 0; } -void system_set_image_copy(enum system_image_copy_t copy) +void system_set_image_copy(enum ec_image copy) { } diff --git a/chip/mchp/lfw/ec_lfw.c b/chip/mchp/lfw/ec_lfw.c index 111e753d3b..edd945037c 100644 --- a/chip/mchp/lfw/ec_lfw.c +++ b/chip/mchp/lfw/ec_lfw.c @@ -327,10 +327,10 @@ void system_init(void) if (rst_sts || wdt_sts) MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) - = SYSTEM_IMAGE_UNKNOWN; + = EC_IMAGE_UNKNOWN; } -enum system_image_copy_t system_get_image_copy(void) +enum ec_image system_get_image_copy(void) { return MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX); } @@ -343,8 +343,8 @@ enum system_image_copy_t system_get_image_copy(void) * LFW checks reset type: * VTR POR, chip reset, WDT reset then set VBAT Load type to Unknown. * LFW reads VBAT Load type: - * SYSTEM_IMAGE_RO then read EC_RO from SPI flash and jump into it. - * SYSTEM_IMAGE_RO then read EC_RW from SPI flash and jump into it. + * EC_IMAGE_RO then read EC_RO from SPI flash and jump into it. + * EC_IMAGE_RO then read EC_RW from SPI flash and jump into it. * Other then jump into EC image loaded by Boot-ROM. */ void lfw_main(void) @@ -388,7 +388,7 @@ void lfw_main(void) uart_puts("\n"); switch (system_get_image_copy()) { - case SYSTEM_IMAGE_RW: + case EC_IMAGE_RW: trace0(0, LFW, 0, "LFW EC_RW Load"); uart_puts("lfw-RW load\n"); @@ -396,7 +396,7 @@ void lfw_main(void) spi_image_load(CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF); break; - case SYSTEM_IMAGE_RO: + case EC_IMAGE_RO: trace0(0, LFW, 0, "LFW EC_RO Load"); uart_puts("lfw-RO load\n"); @@ -408,8 +408,7 @@ void lfw_main(void) trace0(0, LFW, 0, "LFW default: use EC_RO loaded by BootROM"); uart_puts("lfw-default case\n"); - MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) = - SYSTEM_IMAGE_RO; + MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) = EC_IMAGE_RO; init_addr = CONFIG_RO_MEM_OFF + CONFIG_PROGRAM_MEMORY_BASE; } diff --git a/chip/mchp/system.c b/chip/mchp/system.c index c19db25759..8b62490c4a 100644 --- a/chip/mchp/system.c +++ b/chip/mchp/system.c @@ -454,7 +454,7 @@ void htimer_interrupt(void) } DECLARE_IRQ(MCHP_IRQ_HTIMER0, htimer_interrupt, 1); -enum system_image_copy_t system_get_shrspi_image_copy(void) +enum ec_image system_get_shrspi_image_copy(void) { return MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX); } @@ -467,9 +467,9 @@ uint32_t system_get_lfw_address(void) return *(lfw_vector + 1); } -void system_set_image_copy(enum system_image_copy_t copy) +void system_set_image_copy(enum ec_image copy) { - MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) = (copy == SYSTEM_IMAGE_RW) ? - SYSTEM_IMAGE_RW : SYSTEM_IMAGE_RO; + MCHP_VBAT_RAM(MCHP_IMAGETYPE_IDX) = (copy == EC_IMAGE_RW) ? + EC_IMAGE_RW : EC_IMAGE_RO; } diff --git a/chip/mec1322/lfw/ec_lfw.c b/chip/mec1322/lfw/ec_lfw.c index 7dacfc3077..39f4e378ae 100644 --- a/chip/mec1322/lfw/ec_lfw.c +++ b/chip/mec1322/lfw/ec_lfw.c @@ -218,11 +218,10 @@ void system_init(void) MEC1322_PWR_RST_STS_VCC1; if (rst_sts || wdt_sts) - MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) - = SYSTEM_IMAGE_RO; + MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) = EC_IMAGE_RO; } -enum system_image_copy_t system_get_image_copy(void) +enum ec_image system_get_image_copy(void) { return MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX); } @@ -260,20 +259,19 @@ void lfw_main() uart_puts("\n"); switch (system_get_image_copy()) { - case SYSTEM_IMAGE_RW: + case EC_IMAGE_RW: uart_puts("lfw-RW load\n"); init_addr = CONFIG_RW_MEM_OFF + CONFIG_PROGRAM_MEMORY_BASE; spi_image_load(CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF); break; - case SYSTEM_IMAGE_RO: + case EC_IMAGE_RO: uart_puts("lfw-RO load\n"); spi_image_load(CONFIG_EC_PROTECTED_STORAGE_OFF + CONFIG_RO_STORAGE_OFF); /* fall through */ default: - MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) = - SYSTEM_IMAGE_RO; + MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) = EC_IMAGE_RO; init_addr = CONFIG_RO_MEM_OFF + CONFIG_PROGRAM_MEMORY_BASE; } diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 6dac6abfc6..9104bc17b1 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -373,7 +373,7 @@ void htimer_interrupt(void) } DECLARE_IRQ(MEC1322_IRQ_HTIMER, htimer_interrupt, 1); -enum system_image_copy_t system_get_shrspi_image_copy(void) +enum ec_image system_get_shrspi_image_copy(void) { return MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX); } @@ -386,8 +386,8 @@ uint32_t system_get_lfw_address(void) return *(lfw_vector + 1); } -void system_set_image_copy(enum system_image_copy_t copy) +void system_set_image_copy(enum ec_image copy) { - MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) = (copy == SYSTEM_IMAGE_RW) ? - SYSTEM_IMAGE_RW : SYSTEM_IMAGE_RO; + MEC1322_VBAT_RAM(MEC1322_IMAGETYPE_IDX) = (copy == EC_IMAGE_RW) ? + EC_IMAGE_RW : EC_IMAGE_RO; } diff --git a/chip/mt_scp/ipi.c b/chip/mt_scp/ipi.c index f165031501..db371f02b4 100644 --- a/chip/mt_scp/ipi.c +++ b/chip/mt_scp/ipi.c @@ -245,7 +245,7 @@ void ipi_inform_ap(void) #endif scp_run.signaled = 1; - strncpy(scp_run.fw_ver, system_get_version(SYSTEM_IMAGE_RW), + strncpy(scp_run.fw_ver, system_get_version(EC_IMAGE_RW), SCP_FW_VERSION_LEN); scp_run.dec_capability = VCODEC_CAPABILITY_4K_DISABLED; scp_run.enc_capability = 0; diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 9ba374a857..48422902e0 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -1059,19 +1059,19 @@ void system_jump_to_booter(void) * Both of them need 16-bytes alignment since GDMA burst mode. */ switch (system_get_shrspi_image_copy()) { - case SYSTEM_IMAGE_RW: + case EC_IMAGE_RW: flash_offset = CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_STORAGE_OFF; flash_used = CONFIG_RW_SIZE; break; #ifdef CONFIG_RW_B - case SYSTEM_IMAGE_RW_B: + case EC_IMAGE_RW_B: flash_offset = CONFIG_EC_WRITABLE_STORAGE_OFF + CONFIG_RW_B_STORAGE_OFF; flash_used = CONFIG_RW_SIZE; break; #endif - case SYSTEM_IMAGE_RO: + case EC_IMAGE_RO: default: /* Jump to RO by default */ flash_offset = CONFIG_EC_PROTECTED_STORAGE_OFF + CONFIG_RO_STORAGE_OFF; @@ -1125,47 +1125,47 @@ uint32_t system_get_lfw_address() * NPCX_FWCTRL_RO_REGION: 1 - RO, 0 - RW * NPCX_FWCTRL_FW_SLOT: 1 - SLOT_A, 0 - SLOT_B */ -void system_set_image_copy(enum system_image_copy_t copy) +void system_set_image_copy(enum ec_image copy) { switch (copy) { - case SYSTEM_IMAGE_RW: + case EC_IMAGE_RW: CLEAR_BIT(NPCX_FWCTRL, NPCX_FWCTRL_RO_REGION); SET_BIT(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT); break; #ifdef CONFIG_RW_B - case SYSTEM_IMAGE_RW_B: + case EC_IMAGE_RW_B: CLEAR_BIT(NPCX_FWCTRL, NPCX_FWCTRL_RO_REGION); CLEAR_BIT(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT); break; #endif default: CPRINTS("Invalid copy (%d) is requested as a jump destination. " - "Change it to %d.", copy, SYSTEM_IMAGE_RO); - /* Fall through to SYSTEM_IMAGE_RO */ - case SYSTEM_IMAGE_RO: + "Change it to %d.", copy, EC_IMAGE_RO); + /* Fall through to EC_IMAGE_RO */ + case EC_IMAGE_RO: SET_BIT(NPCX_FWCTRL, NPCX_FWCTRL_RO_REGION); SET_BIT(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT); break; } } -enum system_image_copy_t system_get_shrspi_image_copy(void) +enum ec_image system_get_shrspi_image_copy(void) { if (IS_BIT_SET(NPCX_FWCTRL, NPCX_FWCTRL_RO_REGION)) { /* RO image */ #ifdef CHIP_HAS_RO_B if (!IS_BIT_SET(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT)) - return SYSTEM_IMAGE_RO_B; + return EC_IMAGE_RO_B; #endif - return SYSTEM_IMAGE_RO; + return EC_IMAGE_RO; } else { #ifdef CONFIG_RW_B /* RW image */ if (!IS_BIT_SET(NPCX_FWCTRL, NPCX_FWCTRL_FW_SLOT)) /* Slot A */ - return SYSTEM_IMAGE_RW_B; + return EC_IMAGE_RW_B; #endif - return SYSTEM_IMAGE_RW; + return EC_IMAGE_RW; } } |