summaryrefslogtreecommitdiff
path: root/test/flash.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-08-17 15:00:27 +0800
committerGerrit <chrome-bot@google.com>2012-08-19 09:56:32 -0700
commitf229fabd8be499b45fbb801b1458f3dd2c58bd32 (patch)
treed4e26197a5a7637e99803577ad20d3fac15691dd /test/flash.c
parent088a248c794e8f2a48417256fc5fc5d0e9727ef2 (diff)
downloadchrome-ec-f229fabd8be499b45fbb801b1458f3dd2c58bd32.tar.gz
Fix flash_overwrite unit test
This also moves flash related tests to use new 'hostcmd' console command. BUG=chrome-os-partner:10262 TEST=Test passed BRANCH=none Change-Id: I5616bfa93bcde0beb4cb2baf2d38e8b5d827c275 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/30665 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'test/flash.c')
-rw-r--r--test/flash.c154
1 files changed, 0 insertions, 154 deletions
diff --git a/test/flash.c b/test/flash.c
index 2ab0b749fb..1cc40382fd 100644
--- a/test/flash.c
+++ b/test/flash.c
@@ -21,157 +21,3 @@ DECLARE_CONSOLE_COMMAND(rosize, ro_image_size,
NULL,
"Report size of RO image",
NULL);
-
-/* TODO(victoryang@): We should introduce a function to send fake host command
- * just like ec_command in ectool. See crosbug/p/11350 */
-static int hc_flash_info(int argc, char **argv)
-{
- uint8_t data[EC_HOST_PARAM_SIZE];
- enum ec_status res;
- struct ec_response_flash_info *r;
- struct host_cmd_handler_args args =
- { .command = EC_CMD_FLASH_INFO,
- .version = 0,
- .params = NULL,
- .params_size = 0,
- .response = data,
- .response_size = EC_HOST_PARAM_SIZE };
-
- res = host_command_process(&args);
- if (res != EC_RES_SUCCESS)
- return EC_ERROR_UNKNOWN;
- r = (struct ec_response_flash_info *)args.response;
- uart_printf("flash_size = %d\n", r->flash_size);
- uart_printf("write_block_size = %d\n", r->write_block_size);
- uart_printf("erase_block_size = %d\n", r->erase_block_size);
- uart_printf("protect_block_size = %d\n", r->protect_block_size);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(hcflashinfo, hc_flash_info,
- NULL, NULL, NULL);
-
-static int hc_flash_read(int argc, char **argv)
-{
- uint8_t data[EC_HOST_PARAM_SIZE];
- enum ec_status res;
- struct ec_params_flash_read *p =
- (struct ec_params_flash_read *)data;
- struct host_cmd_handler_args args =
- { .command = EC_CMD_FLASH_READ,
- .version = 0,
- .params = data,
- .params_size = EC_HOST_PARAM_SIZE,
- .response = data,
- .response_size = EC_HOST_PARAM_SIZE };
- char *e;
- int i, size;
-
- if (argc != 3)
- return EC_ERROR_PARAM_COUNT;
-
- p->offset = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
- size = strtoi(argv[2], &e, 0);
- p->size = size;
- if (*e)
- return EC_ERROR_PARAM2;
-
- res = host_command_process(&args);
- if (res != EC_RES_SUCCESS)
- return EC_ERROR_UNKNOWN;
- for (i = 0; i < size; ++i) {
- uart_printf("%02x", args.response[i]);
- if ((i & 31) == 31)
- uart_puts("\n");
- }
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(hcflashread, hc_flash_read,
- NULL, NULL, NULL);
-
-static int hc_flash_write(int argc, char **argv)
-{
- uint8_t data[EC_HOST_PARAM_SIZE];
- enum ec_status res;
- struct ec_params_flash_write *p =
- (struct ec_params_flash_write *)data;
- struct host_cmd_handler_args args =
- { .command = EC_CMD_FLASH_WRITE,
- .version = 0,
- .params = data,
- .params_size = EC_HOST_PARAM_SIZE,
- .response = data,
- .response_size = EC_HOST_PARAM_SIZE };
- char *e;
- int i, size;
- int seed, mult, add;
-
- if (argc != 6)
- return EC_ERROR_PARAM_COUNT;
-
- p->offset = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
- size = strtoi(argv[2], &e, 0);
- p->size = size;
- if (*e)
- return EC_ERROR_PARAM2;
- seed = strtoi(argv[3], &e, 0);
- if (*e)
- return EC_ERROR_PARAM3;
- mult = strtoi(argv[4], &e, 0);
- if (*e)
- return EC_ERROR_PARAM4;
- add = strtoi(argv[5], &e, 0);
- if (*e)
- return EC_ERROR_PARAM5;
-
- for (i = 0; i < size; ++i) {
- p->data[i] = (uint8_t)(seed & 0xff);
- seed = seed * mult + add;
- }
-
- res = host_command_process(&args);
- if (res != EC_RES_SUCCESS)
- return EC_ERROR_UNKNOWN;
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(hcflashwrite, hc_flash_write,
- NULL, NULL, NULL);
-
-static int hc_flash_erase(int argc, char **argv)
-{
- uint8_t data[EC_HOST_PARAM_SIZE];
- enum ec_status res;
- struct ec_params_flash_erase *p =
- (struct ec_params_flash_erase *)data;
- struct host_cmd_handler_args args =
- { .command = EC_CMD_FLASH_ERASE,
- .version = 0,
- .params = data,
- .params_size = EC_HOST_PARAM_SIZE,
- .response = data,
- .response_size = EC_HOST_PARAM_SIZE };
- char *e;
- int size;
-
- if (argc != 3)
- return EC_ERROR_PARAM_COUNT;
-
- p->offset = strtoi(argv[1], &e, 0);
- if (*e)
- return EC_ERROR_PARAM1;
- size = strtoi(argv[2], &e, 0);
- p->size = size;
- if (*e)
- return EC_ERROR_PARAM2;
-
- res = host_command_process(&args);
- if (res != EC_RES_SUCCESS)
- return EC_ERROR_UNKNOWN;
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(hcflasherase, hc_flash_erase,
- NULL, NULL, NULL);