Line 1... |
Line 1... |
/* Remote debugging interface for JTAG debugging protocol.
|
/* Remote debugging interface for JTAG debugging protocol.
|
|
JTAG connects to or1k target ops. See or1k-tdep.c
|
|
|
Copyright 1993-1995, 2000 Free Software Foundation, Inc.
|
Copyright 1993-1995, 2000 Free Software Foundation, Inc.
|
Contributed by Cygnus Support. Written by Marko Mlinar
|
Contributed by Cygnus Support. Written by Marko Mlinar
|
<markom@opencores.org>
|
<markom@opencores.org>
|
|
|
This file is part of GDB.
|
This file is part of GDB.
|
Line 60... |
Line 62... |
static int chain_has_rw[] = { 0, 1, 0, 0, 1 };
|
static int chain_has_rw[] = { 0, 1, 0, 0, 1 };
|
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
|
|
/* Currently selected scan chain - just to prevent unnecessary
|
/* Currently selected scan chain - just to prevent unnecessary
|
transfers. */
|
transfers. */
|
|
|
static int current_chain;
|
static int current_chain;
|
|
|
/* Designates whether we are in SELECT_DR state, otherwise in
|
/* Designates whether we are in SELECT_DR state, otherwise in
|
RUN TEST/IDLE */
|
RUN TEST/IDLE */
|
static int select_dr = 0;
|
static int select_dr = 0;
|
Line 74... |
Line 75... |
|
|
/* Crc of current read or written data. */
|
/* Crc of current read or written data. */
|
static int crc_r, crc_w = 0;
|
static int crc_r, crc_w = 0;
|
|
|
/* Generates new crc, sending in new bit input_bit */
|
/* Generates new crc, sending in new bit input_bit */
|
|
|
static int
|
static int
|
crc_calc (int crc, int input_bit)
|
crc_calc (int crc, int input_bit)
|
{
|
{
|
int c;
|
int c;
|
int new_crc;
|
int new_crc;
|
Line 87... |
Line 89... |
d = input_bit&1;
|
d = input_bit&1;
|
c = crc;
|
c = crc;
|
|
|
/* Move queue left. */
|
/* Move queue left. */
|
new_crc = crc << 1;
|
new_crc = crc << 1;
|
|
|
/* Mask upper five bits. */
|
/* Mask upper five bits. */
|
new_crc &= 0xF8;
|
new_crc &= 0xF8;
|
|
|
/* Set lower three bits */
|
/* Set lower three bits */
|
new_crc |= (d ^ ((c >> 7)&1));
|
new_crc |= (d ^ ((c >> 7)&1));
|
Line 230... |
Line 233... |
for (retry = 0; retry < NUM_RETRIES; retry++)
|
for (retry = 0; retry < NUM_RETRIES; retry++)
|
{
|
{
|
jp1_write_JTAG (0); /* CAPTURE_DR */
|
jp1_write_JTAG (0); /* CAPTURE_DR */
|
jp1_write_JTAG (0); /* SHIFT_DR */
|
jp1_write_JTAG (0); /* SHIFT_DR */
|
crc_w = 0;
|
crc_w = 0;
|
|
|
/* write addr */
|
/* write addr */
|
jp1_write_stream (regno, chain_addr_size[current_chain], 0);
|
jp1_write_stream (regno, chain_addr_size[current_chain], 0);
|
|
|
/* write (R/W=1) - we tested that previously. */
|
/* write (R/W=1) - we tested that previously. */
|
jp1_write_JTAG (2);
|
jp1_write_JTAG (2);
|
|
|
/* write data */
|
/* write data */
|
jp1_write_stream (data, chain_data_size[current_chain], 0);
|
jp1_write_stream (data, chain_data_size[current_chain], 0);
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
{
|
{
|
crc_write = crc_w;
|
crc_write = crc_w;
|
|
|
/* write CRC, EXIT1_DR */
|
/* write CRC, EXIT1_DR */
|
crc_read = jp1_read_stream (crc_write, CRC_SIZE, 1);
|
crc_read = jp1_read_stream (crc_write, CRC_SIZE, 1);
|
}
|
}
|
jp1_write_JTAG (1); /* UPDATE_DR */
|
jp1_write_JTAG (1); /* UPDATE_DR */
|
|
|
/* Did JTAG receive packet correctly? */
|
/* Did JTAG receive packet correctly? */
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
crc_ok = jp1_read_JTAG ();
|
crc_ok = jp1_read_JTAG ();
|
jp1_write_JTAG (1); /* SELECT_DR */
|
jp1_write_JTAG (1); /* SELECT_DR */
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
Line 276... |
Line 284... |
for (retry = 0; retry < NUM_RETRIES; retry++)
|
for (retry = 0; retry < NUM_RETRIES; retry++)
|
{
|
{
|
jp1_write_JTAG (0); /* CAPTURE_DR */
|
jp1_write_JTAG (0); /* CAPTURE_DR */
|
jp1_write_JTAG (0); /* SHIFT_DR */
|
jp1_write_JTAG (0); /* SHIFT_DR */
|
crc_w = 0;
|
crc_w = 0;
|
|
|
/* write addr */
|
/* write addr */
|
jp1_write_stream (regno, chain_addr_size[current_chain], 0);
|
jp1_write_stream (regno, chain_addr_size[current_chain], 0);
|
|
|
/* read (R/W=0) */
|
/* read (R/W=0) */
|
if (chain_has_rw[current_chain])
|
if (chain_has_rw[current_chain])
|
jp1_write_JTAG (0);
|
jp1_write_JTAG (0);
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
{
|
{
|
crc_r = 0;
|
crc_r = 0;
|
|
|
/* data = 0 */
|
/* data = 0 */
|
data = jp1_read_stream (0, chain_data_size[current_chain], 0);
|
data = jp1_read_stream (0, chain_data_size[current_chain], 0);
|
crc_write = crc_w;
|
crc_write = crc_w;
|
crc_actual_read = crc_read;
|
crc_actual_read = crc_read;
|
|
|
/* Send my crc, EXIT1_DR */
|
/* Send my crc, EXIT1_DR */
|
crc_read = jp1_read_stream (crc_write, CRC_SIZE, 1);
|
crc_read = jp1_read_stream (crc_write, CRC_SIZE, 1);
|
}
|
}
|
jp1_write_JTAG (1); /* UPDATE_DR */
|
jp1_write_JTAG (1); /* UPDATE_DR */
|
|
|
/* Did JTAG receive packet correctly? */
|
/* Did JTAG receive packet correctly? */
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
crc_ok = jp1_read_JTAG ();
|
crc_ok = jp1_read_JTAG ();
|
jp1_write_JTAG (1); /* SELECT_DR */
|
jp1_write_JTAG (1); /* SELECT_DR */
|
if (chain_has_crc[current_chain])
|
if (chain_has_crc[current_chain])
|
Line 321... |
Line 334... |
if (!chain_is_valid[chain])
|
if (!chain_is_valid[chain])
|
error ("Chain not valid.");
|
error ("Chain not valid.");
|
|
|
current_chain = chain;
|
current_chain = chain;
|
jp1_prepare_control ();
|
jp1_prepare_control ();
|
|
|
|
jp1_write_JTAG (0); /* CAPTURE_IR */
|
|
jp1_write_JTAG (0); /* SHIFT_IR */
|
|
|
|
/* write data, EXIT1_IR */
|
|
jp1_write_stream (JI_CHAIN_SELECT, JI_SIZE, 4);
|
|
|
|
jp1_write_JTAG (1); /* UPDATE_IR */
|
|
jp1_write_JTAG (1); /* SELECT_DR */
|
|
|
|
jp1_write_JTAG (0); /* CAPTURE_DR */
|
|
jp1_write_JTAG (0); /* SHIFT_DR */
|
|
|
|
/* write data, EXIT1_DR */
|
jp1_write_stream (chain, SC_SIZE, 1);
|
jp1_write_stream (chain, SC_SIZE, 1);
|
|
|
|
jp1_write_JTAG (1); /* UPDATE_DR */
|
|
jp1_write_JTAG (1); /* SELECT_DR */
|
|
|
|
/* Now we have to go out of SELECT_CHAIN mode. */
|
|
jp1_write_JTAG (1); /* SELECT_IR */
|
|
jp1_write_JTAG (0); /* CAPTURE_IR */
|
|
jp1_write_JTAG (0); /* SHIFT_IR */
|
|
|
|
/* write data, EXIT1_IR */
|
|
jp1_write_stream (JI_DEBUG, JI_SIZE,1 );
|
|
|
|
jp1_write_JTAG (1); /* UPDATE_IR */
|
|
jp1_write_JTAG (1); /* SELECT_DR */
|
|
select_dr = 1;
|
}
|
}
|
}
|
}
|
|
|
/* Initialize a new connection to the or1k board, and make sure we are
|
/* Initialize a new connection to the or1k board, and make sure we are
|
really connected. */
|
really connected. */
|
Line 340... |
Line 382... |
|
|
if (args == 0)
|
if (args == 0)
|
error ( "To open a or1k remote debugging connection, you need to specify what parallel\n"
|
error ( "To open a or1k remote debugging connection, you need to specify what parallel\n"
|
"port device is attached to the target board (e.g., /dev/lp0).\n");
|
"port device is attached to the target board (e.g., /dev/lp0).\n");
|
|
|
/* Parse the serial port name. */
|
/* Parse the port name. */
|
if ((argv = buildargv (args)) == NULL)
|
if ((argv = buildargv (args)) == NULL)
|
nomem (0);
|
nomem (0);
|
port_name = strsave (argv[0]);
|
port_name = strsave (argv[0]);
|
make_cleanup_freeargv (argv);
|
make_cleanup_freeargv (argv);
|
|
|