tbm-mcu/source/shell/ftl.c

48 lines
790 B
C
Raw Normal View History

2017-05-19 19:02:03 +02:00
#include <ctype.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <flash.h>
#include <ftl.h>
#include <macros.h>
#include <shell.h>
static void do_ftl_probe(const char *s);
2017-05-19 19:02:03 +02:00
static struct cmd ftl_cmds[] = {
{ "probe", do_ftl_probe },
2017-05-19 19:02:03 +02:00
{ NULL, NULL },
};
extern struct flash_dev *flash;
static void do_ftl_probe(const char *s)
2017-05-19 19:02:03 +02:00
{
(void)s;
if (flash) {
flash_release(flash);
flash = NULL;
}
if (!(flash = flash_probe())) {
fprintf(stderr, "error: unable to probe the flash device.\n");
2017-05-19 19:02:03 +02:00
return;
}
if (!(flash = ftl_mount(flash))) {
fprintf(stderr, "error: unable to mount the flash translation layer.\n");
2017-05-19 19:02:03 +02:00
return;
}
}
void do_ftl_cmd(const char *line)
{
cmd_exec(ftl_cmds, line);
}