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.
78 lines
1.6 KiB
78 lines
1.6 KiB
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <console.h>
|
|
#include <gpio.h>
|
|
#include <flash.h>
|
|
#include <ftl.h>
|
|
#include <mufs.h>
|
|
#include <rcc.h>
|
|
#include <rtc.h>
|
|
#include <shell.h>
|
|
|
|
#include <shell/boot.h>
|
|
#include <shell/echo.h>
|
|
#include <shell/mufs.h>
|
|
#include <shell/rtc.h>
|
|
#include <shell/version.h>
|
|
|
|
struct console *user_con, *admin_con;
|
|
struct shell user_shell, admin_shell;
|
|
|
|
extern struct flash_dev *flash;
|
|
extern struct mufs *mufs;
|
|
|
|
struct cmd user_cmds[] = {
|
|
{ "hi", "", shell_version },
|
|
{ "cat", "", shell_cat },
|
|
{ "ls", "", shell_ls },
|
|
{ "date", "", shell_date },
|
|
{ "time", "", shell_time },
|
|
{ "booting", "", shell_prepare },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
struct cmd admin_cmds[] = {
|
|
{ "echo", "", shell_echo },
|
|
{ "flash", "", do_flash_cmd },
|
|
{ "ftl", "", do_ftl_cmd },
|
|
{ "mufs", "", do_mufs_cmd },
|
|
{ "date", "", shell_date },
|
|
{ "time", "", shell_time },
|
|
{ "set-date", "", shell_set_date },
|
|
{ NULL, NULL, NULL },
|
|
};
|
|
|
|
int main(void)
|
|
{
|
|
rcc_init();
|
|
gpio_init();
|
|
rtc_init(NULL);
|
|
|
|
user_con = console_init(1);
|
|
admin_con = console_init(0);
|
|
|
|
if ((flash = flash_probe())) {
|
|
flash = ftl_mount(flash);
|
|
mufs = mufs_mount(flash);
|
|
} else {
|
|
fprintf(admin_con->fp, "error: unable to probe flash chip.\n");
|
|
}
|
|
|
|
fprintf(user_con->fp, "TBM-dev (built on " __DATE__ ")\n");
|
|
fprintf(admin_con->fp, "TBM-dev (built on " __DATE__ ")\n");
|
|
|
|
shell_init(&user_shell, user_cmds, user_con, "tbm $",
|
|
SHELL_SHOW_EXIT_CODE);
|
|
shell_init(&admin_shell, admin_cmds, admin_con, "tbm #",
|
|
SHELL_SHOW_EXIT_CODE);
|
|
|
|
while (1) {
|
|
shell_parse(&user_shell);
|
|
shell_parse(&admin_shell);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|