view rvinterf/asyncshell/usercmd.c @ 505:7bf0d909c87e

fc-loadtool flash ID check: change of reset after the check logic This change only affects those flash configurations that have ID checks enabled. The logic for resetting the flash after the ID check has been changed as follows: 1) If the check fails, we return without attempting to reset the flash. 2) If the check is successful, we reset the flash using the configured method (could be AMD or Intel or Intel W30) instead of always doing an AMD flash reset as the original code did.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 27 May 2019 19:58:01 +0000
parents e13f60d4f8dd
children b55a81ce7497
line wrap: on
line source

/*
 * This module implements interactive fc-shell command dispatch.
 */

#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

extern char usercmd[];

extern void cmd_disable();
extern void cmd_enable();
extern void cmd_help();
extern void cmd_key_interactive();
extern void cmd_keydown_interactive();
extern void cmd_keyup_interactive();
extern void cmd_poweroff();
extern void cmd_sendat();
extern void cmd_send_interactive();
extern void cmd_sp_interactive();
extern void cmd_tch_dispatch();
extern void cmd_tchdl_interactive();
extern void cmd_tgtreset();
extern void cmd_unterm();

void
cmd_exit()
{
	tty_cleanup();
	exit(0);
}

static struct cmdtab {
	char *cmd;
	void (*func)();
} cmdtab[] = {
	{"disable", cmd_disable},
	{"enable", cmd_enable},
	{"exit", cmd_exit},
	{"help", cmd_help},
	{"key", cmd_key_interactive},
	{"keydown", cmd_keydown_interactive},
	{"keyup", cmd_keyup_interactive},
	{"poweroff", cmd_poweroff},
	{"quit", cmd_exit},
	{"send", cmd_send_interactive},
	{"sp", cmd_sp_interactive},
	{"str", cmd_sendat},
	{"tch", cmd_tch_dispatch},
	{"tch-dl", cmd_tchdl_interactive},
	{"tgtreset", cmd_tgtreset},
	{"unterm", cmd_unterm},
	{0, 0}
};

void
dispatch_user_cmd()
{
	char *cp, *np;
	struct cmdtab *tp;

	for (cp = usercmd; isspace(*cp); cp++)
		;
	if (!*cp || *cp == '#')
		return;
	if (!strncmp(cp, "AT", 2) || !strncmp(cp, "at", 2)) {
		cmd_sendat(cp);
		return;
	}
	for (np = cp; *cp && !isspace(*cp); cp++)
		;
	if (*cp)
		*cp++ = '\0';
	for (tp = cmdtab; tp->cmd; tp++)
		if (!strcmp(tp->cmd, np))
			break;
	if (tp->func)
		tp->func(cp);
	else
		printf("error: no such command\n");
}