Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tbm-mcu/source/shell/ftl.c

55 lines
988 B

#include <ctype.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <console.h>
#include <flash.h>
#include <ftl.h>
#include <macros.h>
#include <shell.h>
extern struct flash_dev *flash;
static int do_ftl_probe(struct console *con, size_t argc, const char **argv)
{
(void)argv;
(void)argc;
if (flash) {
flash_release(flash);
flash = NULL;
}
if (!(flash = flash_probe())) {
fprintf(con->fp, "error: unable to probe the flash device.\n");
return -1;
}
if (!(flash = ftl_mount(flash))) {
fprintf(con->fp, "error: unable to mount the flash translation layer.\n");
return -1;
}
return 0;
}
static struct cmd ftl_cmds[] = {
{ "probe", NULL, do_ftl_probe },
{ NULL, NULL, NULL },
};
int do_ftl_cmd(struct console *con, size_t argc, const char **argv)
{
if (argc < 1) {
fprintf(con->fp, "usage: flash <command>\n");
return -1;
}
return cmd_exec(ftl_cmds, con, argc, argv);
}