pass down the tokenized array to completion handlers in case they want to parse info in earlier tokens

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1930 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent adeb3616f4
commit cfa19fc564

@ -14,6 +14,17 @@
all of the sub-commands actually supported. Pull out the const strings
(things you actually type) out of the translated string.
* src/cmd/cmd.h (urj_cmd_t.complete): Add a new arg for the token list.
* src/cmd/cmd_cmd.c (urj_cmd_complete): Pass down tokenized list for
handlers to work off of if they want info about previous tokens.
* src/cmd/cmd_bfin.c, src/cmd/cmd_cable.c, src/cmd/cmd_cmd.c,
src/cmd/cmd_debug.c, src/cmd/cmd_endian.c, src/cmd/cmd_flashmem.c,
src/cmd/cmd_get.c, src/cmd/cmd_help.c, src/cmd/cmd_include.c,
src/cmd/cmd_initbus.c, src/cmd/cmd_instruction.c, src/cmd/cmd_print.c,
src/cmd/cmd_readmem.c, src/cmd/cmd_salias.c, src/cmd/cmd_set.c,
src/cmd/cmd_shift.c, src/cmd/cmd_test.c: Add new tokens arg to completion
handlers.
2011-06-27 Jie Zhang <jie.zhang@analog.com>
* include/urjtag/Makefile.am (nodist_pkginclude_HEADERS): New and

@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <urjtag/chain.h>
#include <urjtag/tap_state.h>
@ -1537,13 +1538,41 @@ chain_system_reset (urj_chain_t *chain)
p0 = part_get_p0 (chain, chain->main_part);
r0 = part_get_r0 (chain, chain->main_part);
/*
* Flush all system events like cache line fills. Otherwise,
* when we reset the system side, any events that the core was
* waiting on no longer exist, and the core hangs.
*/
part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE);
/* Write 0x7 to SWRST to start system reset. */
part_set_p0 (chain, chain->main_part, SWRST);
part_set_r0 (chain, chain->main_part, 0x7);
part_emuir_set (chain, chain->main_part, gen_store16_offset (REG_P0, 0, REG_R0), URJ_CHAIN_EXITMODE_IDLE);
part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE);
/*
* Delay at least 10 SCLKs instead of doing an SSYNC insn.
* Since the system is being reset, the sync signal might
* not be asserted, and so the core hangs waiting for it.
* The magic "10" number was given to us by ADI designers
* who looked at the schematic and ran some simulations.
*/
usleep (100);
/* Write 0x0 to SWRST to stop system reset. */
part_set_r0 (chain, chain->main_part, 0);
part_emuir_set (chain, chain->main_part, gen_store16_offset (REG_P0, 0, REG_R0), URJ_CHAIN_EXITMODE_IDLE);
part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE);
/* Delay at least 1 SCLK; see comment above for more info. */
usleep (100);
/*
* Clear software reset status bit to workaround some bootrom
* bugs. Specifically, the BF526-0.0 will crash when starting
* up if this is set. Should be harmless to everyone else other
* than the bit in SWRST is always cleared ...
*/
// part_set_p0 (chain, chain->main_part, SWRST + 4); /* SYSCR */
part_set_p0 (chain, chain->main_part, p0);
part_set_r0 (chain, chain->main_part, r0);

@ -48,7 +48,8 @@ typedef struct
* syntax and library errors */
int (*run) (urj_chain_t *chain, char *params[]);
void (*complete) (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point);
char * const *tokens, const char *text, size_t text_len,
size_t token_point);
} urj_cmd_t;
#define _URJ_CMD(cmd) extern const urj_cmd_t urj_cmd_##cmd;

@ -512,7 +512,8 @@ cmd_bfin_help (void)
static void
cmd_bfin_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 1)
return;

@ -118,7 +118,8 @@ cmd_cable_help (void)
static void
cmd_cable_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
size_t i;

@ -157,7 +157,8 @@ urj_cmd_complete (urj_chain_t *chain, const char *line, int point)
else
name = "";
cmd->complete (chain, &ret, &ret_cnt, name, strlen (name), token_point);
cmd->complete (chain, &ret, &ret_cnt, tokens, name,
strlen (name), token_point);
if (ret_cnt)
ret[ret_cnt] = NULL;

@ -133,7 +133,8 @@ cmd_debug_help (void)
static void
cmd_debug_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 1)
return;

@ -123,7 +123,8 @@ cmd_endian_help (void)
static void
cmd_endian_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 1)
return;

@ -114,7 +114,8 @@ cmd_flashmem_help (void)
static void
cmd_flashmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{

@ -94,7 +94,8 @@ cmd_get_help (void)
static void
cmd_get_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{

@ -80,7 +80,8 @@ cmd_help_help (void)
static void
cmd_help_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
size_t i;

@ -103,7 +103,8 @@ cmd_include_help (void)
static void
cmd_include_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
#ifdef HAVE_LIBREADLINE
int state;

@ -67,7 +67,8 @@ cmd_initbus_help (void)
static void
cmd_initbus_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
size_t i;

@ -113,7 +113,8 @@ cmd_instruction_help (void)
static void
cmd_instruction_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
urj_part_t *part;
urj_part_instruction_t *i;

@ -281,7 +281,8 @@ cmd_print_help (void)
static void
cmd_print_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 1)
return;

@ -95,7 +95,8 @@ cmd_readmem_help (void)
static void
cmd_readmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{

@ -96,7 +96,8 @@ cmd_salias_help (void)
static void
cmd_salias_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 2)
return;

@ -119,7 +119,8 @@ cmd_set_help (void)
static void
cmd_set_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{

@ -79,7 +79,8 @@ cmd_shift_help (void)
static void
cmd_shift_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
if (token_point != 1)
return;

@ -110,7 +110,8 @@ cmd_test_help (void)
static void
cmd_test_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{

Loading…
Cancel
Save