diff options
author | Yuval Peress <peress@chromium.org> | 2021-01-14 01:29:08 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-15 04:07:55 +0000 |
commit | 9e422c3c05fdd324565049b09be27c446f9dc0ca (patch) | |
tree | b4694ca5abc8c1be1000a1efe7a7bd8a02ddd856 /common | |
parent | 6aa3d78608b681e6374f30747a7f6ab80938bde6 (diff) | |
download | chrome-ec-9e422c3c05fdd324565049b09be27c446f9dc0ca.tar.gz |
Refactor CONFIG_FLASH_SIZE to CONFIG_FLASH_SIZE_BYTES
In Zephyr CONFIG_FLASH_SIZE is a Kconfig value that is used
throughout. The issue is that the units don't match. In
Zephyr the value is in KiB instead of bytes. This refactor
simply renames CONFIG_FLASH_SIZE in platform/ec to include
the unit (via _BYTES).
BRANCH=none
BUG=b:174873770
TEST=make buildall
be generated by the build instead of per board
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I44bf3c7a20fcf62aaa9ae15715be78db4210f384
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2627638
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/firmware_image.lds.S | 7 | ||||
-rw-r--r-- | common/flash.c | 17 | ||||
-rw-r--r-- | common/fmap.c | 2 | ||||
-rw-r--r-- | common/spi_flash.c | 14 | ||||
-rw-r--r-- | common/spi_flash_reg.c | 2 | ||||
-rw-r--r-- | common/vboot_hash.c | 5 |
6 files changed, 26 insertions, 21 deletions
diff --git a/common/firmware_image.lds.S b/common/firmware_image.lds.S index 65014336ab..e2e34de588 100644 --- a/common/firmware_image.lds.S +++ b/common/firmware_image.lds.S @@ -52,9 +52,10 @@ and RW images at different Flash offset */ #ifdef CONFIG_PROGRAM_MEMORY_BASE_LOAD #define IMAGE_PADDING_AT (CONFIG_PROGRAM_MEMORY_BASE_LOAD + \ - CONFIG_FLASH_SIZE - 1) + CONFIG_FLASH_SIZE_BYTES - 1) #else -#define IMAGE_PADDING_AT (CONFIG_PROGRAM_MEMORY_BASE + CONFIG_FLASH_SIZE - 1) +#define IMAGE_PADDING_AT (CONFIG_PROGRAM_MEMORY_BASE + \ + CONFIG_FLASH_SIZE_BYTES - 1) #endif OUTPUT_FORMAT(BFD_FORMAT, BFD_FORMAT, BFD_FORMAT) @@ -63,7 +64,7 @@ OUTPUT_ARCH(BFD_ARCH) MEMORY { FLASH (rx) : ORIGIN = CONFIG_PROGRAM_MEMORY_BASE, - LENGTH = CONFIG_FLASH_SIZE + LENGTH = CONFIG_FLASH_SIZE_BYTES #ifdef CONFIG_IPI IPI_BUFFER (rw) : ORIGIN = CONFIG_PROGRAM_MEMORY_BASE + CONFIG_IPC_SHARED_OBJ_ADDR, LENGTH = (CONFIG_IPC_SHARED_OBJ_BUF_SIZE + 8) * 2 diff --git a/common/flash.c b/common/flash.c index 235121f51e..ab3cd23df0 100644 --- a/common/flash.c +++ b/common/flash.c @@ -218,9 +218,9 @@ int flash_bank_start_offset(int bank) static int flash_range_ok(int offset, int size_req, int align) { if (offset < 0 || size_req < 0 || - offset > CONFIG_FLASH_SIZE || - size_req > CONFIG_FLASH_SIZE || - offset + size_req > CONFIG_FLASH_SIZE || + offset > CONFIG_FLASH_SIZE_BYTES || + size_req > CONFIG_FLASH_SIZE_BYTES || + offset + size_req > CONFIG_FLASH_SIZE_BYTES || (offset | size_req) & (align - 1)) return 0; /* Invalid range */ @@ -251,7 +251,7 @@ int flash_dataptr(int offset, int size_req, int align, const char **ptrp) if (ptrp) *ptrp = flash_physical_dataptr(offset); - return CONFIG_FLASH_SIZE - offset; + return CONFIG_FLASH_SIZE_BYTES - offset; } #endif @@ -979,7 +979,7 @@ static int command_flash_info(int argc, char **argv) { int i, flags; - ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE / 1024); + ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE_BYTES / 1024); ccprintf("Write: %4d B (ideal %d B)\n", CONFIG_FLASH_WRITE_SIZE, CONFIG_FLASH_WRITE_IDEAL_SIZE); #ifdef CONFIG_FLASH_MULTIPLE_REGION @@ -1234,7 +1234,7 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) #error "Flash: Bank size expected bigger or equal to erase size." #endif struct ec_flash_bank single_bank = { - .count = CONFIG_FLASH_SIZE / CONFIG_FLASH_BANK_SIZE, + .count = CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE, .size_exp = __fls(CONFIG_FLASH_BANK_SIZE), .write_size_exp = __fls(CONFIG_FLASH_WRITE_SIZE), .erase_size_exp = __fls(CONFIG_FLASH_ERASE_SIZE), @@ -1265,7 +1265,8 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) if (args->version >= 2) { args->response_size = sizeof(struct ec_response_flash_info_2); - r_2->flash_size = CONFIG_FLASH_SIZE - EC_FLASH_REGION_START; + r_2->flash_size = + CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START; #if (CONFIG_FLASH_ERASED_VALUE32 == 0) r_2->flags = EC_FLASH_INFO_ERASE_TO_0; #else @@ -1285,7 +1286,7 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) #ifdef CONFIG_FLASH_MULTIPLE_REGION return EC_RES_INVALID_PARAM; #else - r_1->flash_size = CONFIG_FLASH_SIZE - EC_FLASH_REGION_START; + r_1->flash_size = CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START; r_1->flags = 0; r_1->write_block_size = CONFIG_FLASH_WRITE_SIZE; r_1->erase_block_size = CONFIG_FLASH_ERASE_SIZE; diff --git a/common/fmap.c b/common/fmap.c index 289883abce..47fa75f0e9 100644 --- a/common/fmap.c +++ b/common/fmap.c @@ -101,7 +101,7 @@ const struct _ec_fmap { .fmap_ver_major = FMAP_VER_MAJOR, .fmap_ver_minor = FMAP_VER_MINOR, .fmap_base = CONFIG_PROGRAM_MEMORY_BASE, - .fmap_size = CONFIG_FLASH_SIZE, + .fmap_size = CONFIG_FLASH_SIZE_BYTES, /* Used to distinguish the EC FMAP from other FMAPs */ .fmap_name = "EC_FMAP", .fmap_nareas = NUM_EC_FMAP_AREAS, diff --git a/common/spi_flash.c b/common/spi_flash.c index 3f003052bf..c4346ef48b 100644 --- a/common/spi_flash.c +++ b/common/spi_flash.c @@ -153,7 +153,7 @@ int spi_flash_read(uint8_t *buf_usr, unsigned int offset, unsigned int bytes) { int i, read_size, ret, spi_addr; uint8_t cmd[4]; - if (offset + bytes > CONFIG_FLASH_SIZE) + if (offset + bytes > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; cmd[0] = SPI_FLASH_READ; for (i = 0; i < bytes; i += read_size) { @@ -227,7 +227,7 @@ int spi_flash_erase(unsigned int offset, unsigned int bytes) int rv = EC_SUCCESS; /* Invalid input */ - if (offset + bytes > CONFIG_FLASH_SIZE) + if (offset + bytes > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; /* Not aligned to sector (4kb) */ @@ -280,7 +280,7 @@ int spi_flash_write(unsigned int offset, unsigned int bytes, int rv, write_size; /* Invalid input */ - if (!data || offset + bytes > CONFIG_FLASH_SIZE || + if (!data || offset + bytes > CONFIG_FLASH_SIZE_BYTES || bytes > SPI_FLASH_MAX_WRITE_SIZE) return EC_ERROR_INVAL; @@ -435,7 +435,8 @@ int spi_flash_check_protect(unsigned int offset, unsigned int bytes) int rv = EC_SUCCESS; /* Invalid value */ - if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE) + if (sr1 == 0xff || sr2 == 0xff || + offset + bytes > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; /* Compute current protect range */ @@ -466,7 +467,8 @@ int spi_flash_set_protect(unsigned int offset, unsigned int bytes) uint8_t sr2 = spi_flash_get_status2(); /* Invalid values */ - if (sr1 == 0xff || sr2 == 0xff || offset + bytes > CONFIG_FLASH_SIZE) + if (sr1 == 0xff || sr2 == 0xff || + offset + bytes > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; /* Compute desired protect range */ @@ -608,7 +610,7 @@ static int command_spi_flashread(int argc, char **argv) spi_enable(CONFIG_SPI_FLASH_PORT, 1); /* Can't read past size of memory */ - if (offset + bytes > CONFIG_FLASH_SIZE) + if (offset + bytes > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; /* Wait for previous operation to complete */ diff --git a/common/spi_flash_reg.c b/common/spi_flash_reg.c index 3cee0f3bd4..ee8d31fa06 100644 --- a/common/spi_flash_reg.c +++ b/common/spi_flash_reg.c @@ -163,7 +163,7 @@ int spi_flash_protect_to_reg(unsigned int start, unsigned int len, uint8_t *sr1, return EC_ERROR_INVAL; /* Invalid data */ - if ((start && !len) || start + len > CONFIG_FLASH_SIZE) + if ((start && !len) || start + len > CONFIG_FLASH_SIZE_BYTES) return EC_ERROR_INVAL; for (i = 0; i < ARRAY_SIZE(spi_flash_protect_ranges); ++i) { diff --git a/common/vboot_hash.c b/common/vboot_hash.c index e3bdf9e6fd..334b006281 100644 --- a/common/vboot_hash.c +++ b/common/vboot_hash.c @@ -211,8 +211,9 @@ static int vboot_hash_start(uint32_t offset, uint32_t size, * Make sure request fits inside flash. That is, you can't use this * command to peek at other memory. */ - if (offset > CONFIG_FLASH_SIZE || size > CONFIG_FLASH_SIZE || - offset + size > CONFIG_FLASH_SIZE || nonce_size < 0) { + if (offset > CONFIG_FLASH_SIZE_BYTES || + size > CONFIG_FLASH_SIZE_BYTES || + offset + size > CONFIG_FLASH_SIZE_BYTES || nonce_size < 0) { return EC_ERROR_INVAL; } |