/***************************************************************************
* Copyright (C) 2009 by Simon Qian *
* SimonQian@SimonQian.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* The specification for SVF is available here:
* http://www.asset-intertech.com/support/svf.pdf
* Below, this document is refered to as the "SVF spec".
*
* The specification for XSVF is available here:
* http://www.xilinx.com/support/documentation/application_notes/xapp503.pdf
* Below, this document is refered to as the "XSVF spec".
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "svf.h"
#include "jtag.h"
#include "command.h"
#include "log.h"
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
// SVF command
typedef enum
{
ENDDR,
ENDIR,
FREQUENCY,
HDR,
HIR,
PIO,
PIOMAP,
RUNTEST,
SDR,
SIR,
STATE,
TDR,
TIR,
TRST,
}svf_command_t;
const char *svf_command_name[14] =
{
"ENDDR",
"ENDIR",
"FREQUENCY",
"HDR",
"HIR",
"PIO",
"PIOMAP",
"RUNTEST",
"SDR",
"SIR",
"STATE",
"TDR",
"TIR",
"TRST"
};
typedef enum
{
TRST_ON,
TRST_OFF,
TRST_Z,
TRST_ABSENT
}trst_mode_t;
const char *svf_trst_mode_name[4] =
{
"ON",
"OFF",
"Z",
"ABSENT"
};
char *svf_tap_state_name[16];
#define XXR_TDI (1 << 0)
#define XXR_TDO (1 << 1)
#define XXR_MASK (1 << 2)
#define XXR_SMASK (1 << 3)
typedef struct
{
int len;
int data_mask;
u8 *tdi;
u8 *tdo;
u8 *mask;
u8 *smask;
}svf_xxr_para_t;
typedef struct
{
float frequency;
tap_state_t ir_end_state;
tap_state_t dr_end_state;
tap_state_t runtest_run_state;
tap_state_t runtest_end_state;
trst_mode_t trst_mode;
svf_xxr_para_t hir_para;
svf_xxr_para_t hdr_para;
svf_xxr_para_t tir_para;
svf_xxr_para_t tdr_para;
svf_xxr_para_t sir_para;
svf_xxr_para_t sdr_para;
}svf_para_t;
svf_para_t svf_para;
const svf_para_t svf_para_init =
{
// frequency, ir_end_state, dr_end_state, runtest_run_state, runtest_end_state, trst_mode
0, TAP_IDLE, TAP_IDLE, TAP_IDLE,