118 lines
2.8 KiB
C
118 lines
2.8 KiB
C
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <readline/readline.h>
|
|
#include <readline/history.h>
|
|
|
|
#include "config/bs_defines.h"
|
|
#include "utils.h"
|
|
#include "init.h"
|
|
#include "args.h"
|
|
|
|
// int main(int argc, char *argv[]) {
|
|
// int success = 0;
|
|
// int n_probes = 0;
|
|
// int i = 0;
|
|
// int error = 0;
|
|
// jtag_core *jc = NULL;
|
|
|
|
// struct args a = {0};
|
|
// struct probe probes[PROBES_MAX_NUM] = {0};
|
|
// unsigned long dev_ids[DEVICES_SCAN_MAX] = {0};
|
|
// int ndevs = 0;
|
|
|
|
// success = parse_args(&a, argc, argv);
|
|
// if (EXIT_FAILURE == success) exit(EXIT_FAILURE);
|
|
|
|
// jc = bsexp_init();
|
|
// if (NULL == jc) {
|
|
// error = JTAG_CORE_MEM_ERROR;
|
|
// goto err;
|
|
// }
|
|
|
|
// /* List the probes (and display if asked) */
|
|
// n_probes = list_probes(jc, probes, a.list);
|
|
|
|
// i = 0;
|
|
// while ((i<MAX_COMMANDS) && (a.cmds[i] != NO_COMMAND)) {
|
|
// switch (a.cmds[i]) {
|
|
// case COMMAND_SCAN:
|
|
// if ((0 >= a.probe) || (a.probe > MIN(n_probes, PROBES_MAX_NUM))) goto err;
|
|
// error = scan(jc, probes[a.probe-1].probe_id, &ndevs, dev_ids, 1);
|
|
// break;
|
|
// default:
|
|
// printf("Unknown command.");
|
|
// goto err;
|
|
// }
|
|
// i++;
|
|
// }
|
|
|
|
// goto end;
|
|
|
|
// err:
|
|
// printf("Exited with error (%d).\n", error);
|
|
|
|
// end:
|
|
// jtagcore_deinit(jc);
|
|
// return error;
|
|
// }
|
|
|
|
|
|
// int execute_command(jtag_core *jc, int argc, char **argv) {
|
|
// int error = 0;
|
|
// if (argv[0] == NULL) {
|
|
// return 0;
|
|
// }
|
|
|
|
// for (int i = 0; commands[i].name != NULL; i++) {
|
|
// if (strcmp(argv[0], commands[i].name) == 0) {
|
|
// error = commands[i].cmd_call(jc, argc, argv);
|
|
// return error;
|
|
// }
|
|
// }
|
|
// error = -1;
|
|
// printf("Command not found\n");
|
|
// }
|
|
|
|
int main() {
|
|
char *line = NULL;
|
|
int error = 0;
|
|
int cmd_argc=0;
|
|
char *cmd_argv[MAX_ARGS] = {0};
|
|
jtag_core *jc = NULL;
|
|
|
|
jc = bsexp_init();
|
|
if (NULL == jc) {
|
|
error = JTAG_CORE_MEM_ERROR;
|
|
printf("JTAG Core execution failed");
|
|
goto err;
|
|
}
|
|
|
|
while (1) {
|
|
line = readline("bs_explorer> ");
|
|
if (line == NULL) {
|
|
break;
|
|
}
|
|
if (*line) {
|
|
add_history(line);
|
|
}
|
|
parse_command(line, &cmd_argc, cmd_argv);
|
|
if (cmd_argv[0] == NULL) {
|
|
continue;
|
|
}
|
|
if (strcmp(cmd_argv[0], "exit") == 0) {
|
|
break;
|
|
}
|
|
// error = execute_command(jc, cmd_argc, cmd_argv);
|
|
// printf("\n");
|
|
// if (0 == error) {
|
|
// } else {
|
|
// printf("Command failed with code: %d", error);
|
|
// }
|
|
}
|
|
return 0;
|
|
|
|
err:
|
|
return error;
|
|
} |