OpenOCD
zy1000.c File Reference
Include dependency graph for zy1000.c:

Go to the source code of this file.

Data Structures

struct  callbackentry
 

Macros

#define callbackqueue_size   128
 
#define readqueue_size   16384
 
#define ZYLIN_KHZ   60000
 

Enumerations

enum  ZY1000_CMD { ZY1000_CMD_POKE = 0x0, ZY1000_CMD_PEEK = 0x8, ZY1000_CMD_SLEEP = 0x1, ZY1000_CMD_WAITIDLE = 2 }
 

Functions

int arm11_run_instr_data_to_core_noack_inner (struct jtag_tap *tap, uint32_t opcode, uint32_t *data, size_t count)
 
 COMMAND_HANDLER (handle_power_command)
 
void embeddedice_write_dcc (struct jtag_tap *tap, int reg_addr, const uint8_t *buffer, int little, int count)
 
static bool flush_writes (void)
 
int interface_add_tms_seq (unsigned num_bits, const uint8_t *seq, enum tap_state state)
 
int interface_jtag_add_clocks (int num_cycles)
 
int interface_jtag_add_dr_scan (struct jtag_tap *active, int num_fields, const struct scan_field *fields, tap_state_t state)
 see jtag_add_dr_scan() More...
 
int interface_jtag_add_ir_scan (struct jtag_tap *active, const struct scan_field *fields, tap_state_t state)
 see jtag_add_ir_scan() More...
 
int interface_jtag_add_pathmove (int num_states, const tap_state_t *path)
 
int interface_jtag_add_plain_dr_scan (int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 
int interface_jtag_add_plain_ir_scan (int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
 
int interface_jtag_add_reset (int req_trst, int req_srst)
 This drives the actual srst and trst pins. More...
 
int interface_jtag_add_runtest (int num_cycles, tap_state_t state)
 
int interface_jtag_add_sleep (uint32_t us)
 
int interface_jtag_add_tlr (void)
 
int interface_jtag_execute_queue (void)
 
static int jim_zy1000_server (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static void jtag_pre_post_bits (struct jtag_tap *tap, int *pre, int *post)
 
static bool readLong (uint32_t *out_data)
 
static bool readPowerDropout (void)
 
static bool readSRST (void)
 
static void scanBits (const uint8_t *out_value, uint8_t *in_value, int num_bits, bool pause_now, tap_state_t shiftState, tap_state_t end_state)
 
static void scanFields (int num_fields, const struct scan_field *fields, tap_state_t shiftState, tap_state_t end_state)
 
static void setPower (bool power)
 
static void tcpip_open (void)
 
void waitIdle (void)
 
static void waitSRST (bool asserted)
 
static bool writeLong (uint32_t l)
 
static void writeShiftValue (uint8_t *data, int bits)
 
void zy1000_flush_callbackqueue (void)
 
void zy1000_flush_readqueue (void)
 
int zy1000_init (void)
 
void zy1000_jtag_add_callback (jtag_callback1_t callback, jtag_callback_data_t data0)
 
void zy1000_jtag_add_callback4 (jtag_callback_t callback, jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
 
static int zy1000_jtag_add_clocks (int num_cycles, tap_state_t state, tap_state_t clockstate)
 
static int zy1000_jtag_convert_to_callback4 (jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
 
static int zy1000_khz (int khz, int *jtag_speed)
 
static int zy1000_power_dropout (int *dropout)
 
int zy1000_quit (void)
 
void zy1000_reset (int trst, int srst)
 
int zy1000_speed (int speed)
 
static int zy1000_speed_div (int speed, int *khz)
 
static int zy1000_srst_asserted (int *srst_asserted)
 
uint32_t zy1000_tcpin (uint32_t address)
 
void zy1000_tcpout (uint32_t address, uint32_t data)
 
static int zylinjtag_Jim_Command_powerstatus (Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 

Variables

static struct callbackentry callbackqueue [callbackqueue_size]
 
static int callbackqueue_pos
 
static uint8_t in_buffer [16384]
 
static size_t in_pos
 
static size_t in_write
 
static uint8_t out_buffer [16384]
 
static size_t out_pos
 
struct {
   int   bits
 
   uint8_t *   dest
 
readqueue [readqueue_size]
 
static int readqueue_pos
 
static bool savePower
 
static int tcp_ip = -1
 
static char * tcp_server = "notspecified"
 
struct adapter_driver zy1000_adapter_driver
 
static const struct command_registration zy1000_commands []
 
static struct jtag_interface zy1000_interface
 
static bool zy1000_rclk
 

Macro Definition Documentation

◆ callbackqueue_size

#define callbackqueue_size   128

Definition at line 1003 of file zy1000.c.

Referenced by zy1000_jtag_add_callback4().

◆ readqueue_size

#define readqueue_size   16384

Definition at line 959 of file zy1000.c.

Referenced by writeShiftValue().

◆ ZYLIN_KHZ

#define ZYLIN_KHZ   60000

Definition at line 59 of file zy1000.c.

Referenced by zy1000_khz(), zy1000_speed(), and zy1000_speed_div().

Enumeration Type Documentation

◆ ZY1000_CMD

enum ZY1000_CMD
Enumerator
ZY1000_CMD_POKE 
ZY1000_CMD_PEEK 
ZY1000_CMD_SLEEP 
ZY1000_CMD_WAITIDLE 

Definition at line 863 of file zy1000.c.

Function Documentation

◆ arm11_run_instr_data_to_core_noack_inner()

◆ COMMAND_HANDLER()

COMMAND_HANDLER ( handle_power_command  )

◆ embeddedice_write_dcc()

void embeddedice_write_dcc ( struct jtag_tap tap,
int  reg_addr,
const uint8_t *  buffer,
int  little,
int  count 
)

◆ flush_writes()

static bool flush_writes ( void  )
static

Definition at line 811 of file zy1000.c.

References out_buffer, out_pos, and tcp_ip.

Referenced by readLong(), and writeLong().

◆ interface_add_tms_seq()

◆ interface_jtag_add_clocks()

◆ interface_jtag_add_dr_scan()

◆ interface_jtag_add_ir_scan()

◆ interface_jtag_add_pathmove()

◆ interface_jtag_add_plain_dr_scan()

int interface_jtag_add_plain_dr_scan ( int  num_bits,
const uint8_t *  out_bits,
uint8_t *  in_bits,
tap_state_t  state 
)

Definition at line 480 of file zy1000.c.

References ERROR_OK, jtag_add_plain_scan(), scanBits(), and TAP_DRSHIFT.

◆ interface_jtag_add_plain_ir_scan()

int interface_jtag_add_plain_ir_scan ( int  num_bits,
const uint8_t *  out_bits,
uint8_t *  in_bits,
tap_state_t  state 
)

Definition at line 445 of file zy1000.c.

References ERROR_OK, jtag_add_plain_scan(), scanBits(), and TAP_IRSHIFT.

◆ interface_jtag_add_reset()

int interface_jtag_add_reset ( int  trst,
int  srst 
)

This drives the actual srst and trst pins.

srst will always be 0 if jtag_reset_config & RESET_SRST_PULLS_TRST != 0 and ditto for trst.

the higher level jtag_add_reset will invoke jtag_add_tlr() if appropriate

Definition at line 495 of file zy1000.c.

References jtag_command::cmd, cmd_queue_alloc(), ERROR_OK, jtag_queue_command(), JTAG_RESET, jtag_command_container::reset, reset_command::srst, reset_command::trst, jtag_command::type, and zy1000_reset().

◆ interface_jtag_add_runtest()

◆ interface_jtag_add_sleep()

◆ interface_jtag_add_tlr()

◆ interface_jtag_execute_queue()

◆ jim_zy1000_server()

static int jim_zy1000_server ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

Definition at line 282 of file zy1000.c.

References NULL, and tcp_server.

◆ jtag_pre_post_bits()

static void jtag_pre_post_bits ( struct jtag_tap tap,
int *  pre,
int *  post 
)
static

Definition at line 609 of file zy1000.c.

References jtag_tap_next_enabled(), and NULL.

Referenced by arm11_run_instr_data_to_core_noack_inner(), and embeddedice_write_dcc().

◆ readLong()

static bool readLong ( uint32_t *  out_data)
static

Definition at line 832 of file zy1000.c.

References flush_writes(), in_buffer, in_pos, in_write, out_pos, and tcp_ip.

Referenced by zy1000_flush_readqueue(), and zy1000_tcpin().

◆ readPowerDropout()

static bool readPowerDropout ( void  )
static

◆ readSRST()

static bool readSRST ( void  )
static

Definition at line 121 of file zy1000.c.

References srstAsserted, ZY1000_JTAG_BASE, ZY1000_PEEK, and ZY1000_POKE.

Referenced by waitSRST(), and zy1000_srst_asserted().

◆ scanBits()

static void scanBits ( const uint8_t *  out_value,
uint8_t *  in_value,
int  num_bits,
bool  pause_now,
tap_state_t  shiftState,
tap_state_t  end_state 
)
inlinestatic

◆ scanFields()

static void scanFields ( int  num_fields,
const struct scan_field fields,
tap_state_t  shiftState,
tap_state_t  end_state 
)
inlinestatic

Definition at line 392 of file zy1000.c.

References scanBits().

Referenced by interface_jtag_add_dr_scan(), and interface_jtag_add_ir_scan().

◆ setPower()

static void setPower ( bool  power)
static

Definition at line 252 of file zy1000.c.

References savePower, ZY1000_JTAG_BASE, and ZY1000_POKE.

Referenced by COMMAND_HANDLER(), and zy1000_init().

◆ tcpip_open()

static void tcpip_open ( void  )
static

Definition at line 876 of file zy1000.c.

References flag, tcp_ip, and tcp_server.

Referenced by interface_jtag_add_sleep(), waitIdle(), zy1000_flush_readqueue(), zy1000_tcpin(), and zy1000_tcpout().

◆ waitIdle()

◆ waitSRST()

static void waitSRST ( bool  asserted)
static

Definition at line 145 of file zy1000.c.

References keep_alive(), LOG_ERROR, LOG_USER, mode, readSRST(), srstAsserted, start, and timeval_ms().

Referenced by zy1000_reset().

◆ writeLong()

static bool writeLong ( uint32_t  l)
static

◆ writeShiftValue()

static void writeShiftValue ( uint8_t *  data,
int  bits 
)
static

◆ zy1000_flush_callbackqueue()

◆ zy1000_flush_readqueue()

void zy1000_flush_readqueue ( void  )

◆ zy1000_init()

int zy1000_init ( void  )

Definition at line 1203 of file zy1000.c.

References ERROR_FAIL, ERROR_OK, LOG_ERROR, setPower(), ZY1000_JTAG_BASE, ZY1000_POKE, and zy1000_reset().

◆ zy1000_jtag_add_callback()

void zy1000_jtag_add_callback ( jtag_callback1_t  callback,
jtag_callback_data_t  data0 
)

Definition at line 1049 of file zy1000.c.

References zy1000_jtag_add_callback4(), and zy1000_jtag_convert_to_callback4().

◆ zy1000_jtag_add_callback4()

◆ zy1000_jtag_add_clocks()

static int zy1000_jtag_add_clocks ( int  num_cycles,
tap_state_t  state,
tap_state_t  clockstate 
)
static

◆ zy1000_jtag_convert_to_callback4()

static int zy1000_jtag_convert_to_callback4 ( jtag_callback_data_t  data0,
jtag_callback_data_t  data1,
jtag_callback_data_t  data2,
jtag_callback_data_t  data3 
)
static

Definition at line 1040 of file zy1000.c.

References ERROR_OK.

Referenced by zy1000_jtag_add_callback().

◆ zy1000_khz()

static int zy1000_khz ( int  khz,
int *  jtag_speed 
)
static

Definition at line 64 of file zy1000.c.

References ERROR_OK, and ZYLIN_KHZ.

◆ zy1000_power_dropout()

static int zy1000_power_dropout ( int *  dropout)
static

Definition at line 138 of file zy1000.c.

References ERROR_OK, and readPowerDropout().

◆ zy1000_quit()

int zy1000_quit ( void  )

Definition at line 309 of file zy1000.c.

References ERROR_OK.

◆ zy1000_reset()

void zy1000_reset ( int  trst,
int  srst 
)

◆ zy1000_speed()

int zy1000_speed ( int  speed)

◆ zy1000_speed_div()

static int zy1000_speed_div ( int  speed,
int *  khz 
)
static

Definition at line 99 of file zy1000.c.

References ERROR_OK, and ZYLIN_KHZ.

Referenced by zy1000_speed().

◆ zy1000_srst_asserted()

static int zy1000_srst_asserted ( int *  srst_asserted)
static

Definition at line 132 of file zy1000.c.

References ERROR_OK, and readSRST().

◆ zy1000_tcpin()

uint32_t zy1000_tcpin ( uint32_t  address)

Definition at line 934 of file zy1000.c.

References readLong(), tcpip_open(), writeLong(), ZY1000_CMD_PEEK, and zy1000_flush_readqueue().

◆ zy1000_tcpout()

void zy1000_tcpout ( uint32_t  address,
uint32_t  data 
)

Definition at line 912 of file zy1000.c.

References tcpip_open(), writeLong(), and ZY1000_CMD_POKE.

◆ zylinjtag_Jim_Command_powerstatus()

static int zylinjtag_Jim_Command_powerstatus ( Jim_Interp *  interp,
int  argc,
Jim_Obj *const *  argv 
)
static

Definition at line 293 of file zy1000.c.

References readPowerDropout().

Variable Documentation

◆ bits

◆ callbackqueue

◆ callbackqueue_pos

int callbackqueue_pos
static

Definition at line 1012 of file zy1000.c.

Referenced by zy1000_flush_callbackqueue(), and zy1000_jtag_add_callback4().

◆ dest

uint8_t* dest

Definition at line 961 of file zy1000.c.

Referenced by auipc(), csrw(), fence(), fence_i(), fld(), flw(), fmv_w_x(), fmv_x_d(), fmv_x_w(), fsd(), lui(), and xori().

◆ in_buffer

uint8_t in_buffer[16384]
static

Definition at line 809 of file zy1000.c.

Referenced by adbg_wb_burst_read(), jsp_input(), jsp_poll_read(), or1k_to_du(), and readLong().

◆ in_pos

size_t in_pos
static

Definition at line 807 of file zy1000.c.

Referenced by readLong().

◆ in_write

size_t in_write
static

Definition at line 808 of file zy1000.c.

Referenced by readLong().

◆ out_buffer

uint8_t out_buffer[16384]
static

Definition at line 806 of file zy1000.c.

Referenced by flush_writes(), jsp_poll_read(), or1k_to_du(), and writeLong().

◆ out_pos

size_t out_pos
static

Definition at line 805 of file zy1000.c.

Referenced by flush_writes(), readLong(), and writeLong().

◆ readqueue

struct { ... } readqueue[readqueue_size]

◆ readqueue_pos

int readqueue_pos
static

Definition at line 965 of file zy1000.c.

Referenced by writeShiftValue(), and zy1000_flush_readqueue().

◆ savePower

bool savePower
static

Definition at line 250 of file zy1000.c.

Referenced by COMMAND_HANDLER(), and setPower().

◆ tcp_ip

int tcp_ip = -1
static

Definition at line 802 of file zy1000.c.

Referenced by flush_writes(), readLong(), and tcpip_open().

◆ tcp_server

char* tcp_server = "notspecified"
static

Definition at line 281 of file zy1000.c.

Referenced by jim_zy1000_server(), and tcpip_open().

◆ zy1000_adapter_driver

struct adapter_driver zy1000_adapter_driver
Initial value:
= {
.name = "ZY1000",
.transports = jtag_only,
.commands = zy1000_commands,
.init = zy1000_init,
.quit = zy1000_quit,
.speed = zy1000_speed,
.khz = zy1000_khz,
.speed_div = zy1000_speed_div,
.power_dropout = zy1000_power_dropout,
.srst_asserted = zy1000_srst_asserted,
.jtag_ops = &zy1000_interface,
}
const char *const jtag_only[]
Definition: adapter.c:50
int zy1000_init(void)
Definition: zy1000.c:1203
int zy1000_speed(int speed)
Definition: zy1000.c:218
static int zy1000_srst_asserted(int *srst_asserted)
Definition: zy1000.c:132
static const struct command_registration zy1000_commands[]
Definition: zy1000.c:773
static int zy1000_khz(int khz, int *jtag_speed)
Definition: zy1000.c:64
static int zy1000_power_dropout(int *dropout)
Definition: zy1000.c:138
static struct jtag_interface zy1000_interface
Definition: zy1000.c:1240
static int zy1000_speed_div(int speed, int *khz)
Definition: zy1000.c:99
int zy1000_quit(void)
Definition: zy1000.c:309

Definition at line 1245 of file zy1000.c.

◆ zy1000_commands

const struct command_registration zy1000_commands[]
static
Initial value:
= {
{
.name = "power",
.handler = handle_power_command,
.mode = COMMAND_ANY,
.help = "Turn power switch to target on/off. "
"With no arguments, prints status.",
.usage = "('on'|'off)",
},
{
.name = "zy1000_server",
.mode = COMMAND_ANY,
.jim_handler = jim_zy1000_server,
.help = "Tcpip address for ZY1000 server.",
.usage = "address",
},
{
.name = "powerstatus",
.mode = COMMAND_ANY,
.help = "Returns power status of target",
},
}
static int jim_zy1000_server(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: zy1000.c:282
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:234
static int zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: zy1000.c:293

Definition at line 773 of file zy1000.c.

◆ zy1000_interface

struct jtag_interface zy1000_interface
static
Initial value:
= {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = NULL,
}
#define DEBUG_CAP_TMS_SEQ
Definition: interface.h:200
#define NULL
Definition: usb.h:27

Definition at line 1240 of file zy1000.c.

◆ zy1000_rclk

bool zy1000_rclk
static

Definition at line 62 of file zy1000.c.

Referenced by interface_jtag_execute_queue(), and zy1000_speed().