jtag: rename CamelCase symbols

No major cross dependency, just changes internal to each file or
function.

Change-Id: Ie6258a090ce53de5db65df6a77d57ac6bb899488
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6301
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2021-04-25 23:41:15 +02:00
parent 9e358ac2c0
commit 20ee64ae4b
11 changed files with 184 additions and 184 deletions

View File

@ -31,7 +31,7 @@
/* */ /* */
static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi, static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi,
struct jtag_tap *pTap) struct jtag_tap *tap)
{ {
jim_wide w; jim_wide w;
int e = jim_getopt_wide(goi, &w); int e = jim_getopt_wide(goi, &w);
@ -41,21 +41,21 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
return e; return e;
} }
unsigned expected_len = sizeof(uint32_t) * pTap->expected_ids_cnt; unsigned expected_len = sizeof(uint32_t) * tap->expected_ids_cnt;
uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t)); uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t));
if (new_expected_ids == NULL) { if (new_expected_ids == NULL) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
assert(pTap->expected_ids); assert(tap->expected_ids);
memcpy(new_expected_ids, pTap->expected_ids, expected_len); memcpy(new_expected_ids, tap->expected_ids, expected_len);
new_expected_ids[pTap->expected_ids_cnt] = w; new_expected_ids[tap->expected_ids_cnt] = w;
free(pTap->expected_ids); free(tap->expected_ids);
pTap->expected_ids = new_expected_ids; tap->expected_ids = new_expected_ids;
pTap->expected_ids_cnt++; tap->expected_ids_cnt++;
return JIM_OK; return JIM_OK;
} }
@ -65,7 +65,7 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
/* */ /* */
static int jim_aice_newtap_cmd(struct jim_getopt_info *goi) static int jim_aice_newtap_cmd(struct jim_getopt_info *goi)
{ {
struct jtag_tap *pTap; struct jtag_tap *tap;
int x; int x;
int e; int e;
struct jim_nvp *n; struct jim_nvp *n;
@ -75,8 +75,8 @@ static int jim_aice_newtap_cmd(struct jim_getopt_info *goi)
{.name = NULL, .value = -1}, {.name = NULL, .value = -1},
}; };
pTap = calloc(1, sizeof(struct jtag_tap)); tap = calloc(1, sizeof(struct jtag_tap));
if (!pTap) { if (!tap) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
@ -87,41 +87,41 @@ static int jim_aice_newtap_cmd(struct jim_getopt_info *goi)
if (goi->argc < 3) { if (goi->argc < 3) {
Jim_SetResultFormatted(goi->interp, Jim_SetResultFormatted(goi->interp,
"Missing CHIP TAP OPTIONS ...."); "Missing CHIP TAP OPTIONS ....");
free(pTap); free(tap);
return JIM_ERR; return JIM_ERR;
} }
const char *tmp; const char *tmp;
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->chip = strdup(tmp); tap->chip = strdup(tmp);
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->tapname = strdup(tmp); tap->tapname = strdup(tmp);
/* name + dot + name + null */ /* name + dot + name + null */
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; x = strlen(tap->chip) + 1 + strlen(tap->tapname) + 1;
cp = malloc(x); cp = malloc(x);
sprintf(cp, "%s.%s", pTap->chip, pTap->tapname); sprintf(cp, "%s.%s", tap->chip, tap->tapname);
pTap->dotted_name = cp; tap->dotted_name = cp;
LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params", LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc); tap->chip, tap->tapname, tap->dotted_name, goi->argc);
while (goi->argc) { while (goi->argc) {
e = jim_getopt_nvp(goi, opts, &n); e = jim_getopt_nvp(goi, opts, &n);
if (e != JIM_OK) { if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, opts, 0); jim_getopt_nvp_unknown(goi, opts, 0);
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
LOG_DEBUG("Processing option: %s", n->name); LOG_DEBUG("Processing option: %s", n->name);
switch (n->value) { switch (n->value) {
case NTAP_OPT_EXPECTED_ID: case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap); e = jim_newtap_expected_id(n, goi, tap);
if (JIM_OK != e) { if (JIM_OK != e) {
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
break; break;
@ -129,9 +129,9 @@ static int jim_aice_newtap_cmd(struct jim_getopt_info *goi)
} /* while (goi->argc) */ } /* while (goi->argc) */
/* default is enabled-after-reset */ /* default is enabled-after-reset */
pTap->enabled = !pTap->disabled_after_reset; tap->enabled = !tap->disabled_after_reset;
jtag_tap_init(pTap); jtag_tap_init(tap);
return JIM_OK; return JIM_OK;
} }

View File

@ -158,7 +158,7 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
struct libusb_device_handle **out, struct libusb_device_handle **out,
adapter_get_alternate_serial_fn adapter_get_alternate_serial) adapter_get_alternate_serial_fn adapter_get_alternate_serial)
{ {
int cnt, idx, errCode; int cnt, idx, err_code;
int retval = ERROR_FAIL; int retval = ERROR_FAIL;
bool serial_mismatch = false; bool serial_mismatch = false;
struct libusb_device_handle *libusb_handle = NULL; struct libusb_device_handle *libusb_handle = NULL;
@ -180,11 +180,11 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
if (jtag_usb_get_location() && !jtag_libusb_location_equal(devs[idx])) if (jtag_usb_get_location() && !jtag_libusb_location_equal(devs[idx]))
continue; continue;
errCode = libusb_open(devs[idx], &libusb_handle); err_code = libusb_open(devs[idx], &libusb_handle);
if (errCode) { if (err_code) {
LOG_ERROR("libusb_open() failed with %s", LOG_ERROR("libusb_open() failed with %s",
libusb_error_name(errCode)); libusb_error_name(err_code));
continue; continue;
} }
@ -222,13 +222,13 @@ void jtag_libusb_close(struct libusb_device_handle *dev)
libusb_exit(jtag_libusb_context); libusb_exit(jtag_libusb_context);
} }
int jtag_libusb_control_transfer(struct libusb_device_handle *dev, uint8_t requestType, int jtag_libusb_control_transfer(struct libusb_device_handle *dev, uint8_t request_type,
uint8_t request, uint16_t wValue, uint16_t wIndex, char *bytes, uint8_t request, uint16_t value, uint16_t index, char *bytes,
uint16_t size, unsigned int timeout) uint16_t size, unsigned int timeout)
{ {
int transferred = 0; int transferred = 0;
transferred = libusb_control_transfer(dev, requestType, request, wValue, wIndex, transferred = libusb_control_transfer(dev, request_type, request, value, index,
(unsigned char *)bytes, size, timeout); (unsigned char *)bytes, size, timeout);
if (transferred < 0) if (transferred < 0)
@ -275,28 +275,28 @@ int jtag_libusb_set_configuration(struct libusb_device_handle *devh,
int configuration) int configuration)
{ {
struct libusb_device *udev = libusb_get_device(devh); struct libusb_device *udev = libusb_get_device(devh);
int retCode = -99; int retval = -99;
struct libusb_config_descriptor *config = NULL; struct libusb_config_descriptor *config = NULL;
int current_config = -1; int current_config = -1;
retCode = libusb_get_configuration(devh, &current_config); retval = libusb_get_configuration(devh, &current_config);
if (retCode != 0) if (retval != 0)
return retCode; return retval;
retCode = libusb_get_config_descriptor(udev, configuration, &config); retval = libusb_get_config_descriptor(udev, configuration, &config);
if (retCode != 0 || config == NULL) if (retval != 0 || config == NULL)
return retCode; return retval;
/* Only change the configuration if it is not already set to the /* Only change the configuration if it is not already set to the
same one. Otherwise this issues a lightweight reset and hangs same one. Otherwise this issues a lightweight reset and hangs
LPC-Link2 with JLink firmware. */ LPC-Link2 with JLink firmware. */
if (current_config != config->bConfigurationValue) if (current_config != config->bConfigurationValue)
retCode = libusb_set_configuration(devh, config->bConfigurationValue); retval = libusb_set_configuration(devh, config->bConfigurationValue);
libusb_free_config_descriptor(config); libusb_free_config_descriptor(config);
return retCode; return retval;
} }
int jtag_libusb_choose_interface(struct libusb_device_handle *devh, int jtag_libusb_choose_interface(struct libusb_device_handle *devh,

View File

@ -33,8 +33,8 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
adapter_get_alternate_serial_fn adapter_get_alternate_serial); adapter_get_alternate_serial_fn adapter_get_alternate_serial);
void jtag_libusb_close(struct libusb_device_handle *dev); void jtag_libusb_close(struct libusb_device_handle *dev);
int jtag_libusb_control_transfer(struct libusb_device_handle *dev, int jtag_libusb_control_transfer(struct libusb_device_handle *dev,
uint8_t requestType, uint8_t request, uint16_t wValue, uint8_t request_type, uint8_t request, uint16_t value,
uint16_t wIndex, char *bytes, uint16_t size, unsigned int timeout); uint16_t index, char *bytes, uint16_t size, unsigned int timeout);
int jtag_libusb_bulk_write(struct libusb_device_handle *dev, int ep, int jtag_libusb_bulk_write(struct libusb_device_handle *dev, int ep,
char *bytes, int size, int timeout, int *transferred); char *bytes, int size, int timeout, int *transferred);
int jtag_libusb_bulk_read(struct libusb_device_handle *dev, int ep, int jtag_libusb_bulk_read(struct libusb_device_handle *dev, int ep,

View File

@ -97,14 +97,14 @@
#define ST7_PC_TDO ST7_PC_IO9 #define ST7_PC_TDO ST7_PC_IO9
#define ST7_PA_DBGACK ST7_PA_IO10 #define ST7_PA_DBGACK ST7_PA_IO10
static struct libusb_device_handle *pHDev; static struct libusb_device_handle *hdev;
/* /*
* ep1 commands are up to USB_EP1OUT_SIZE bytes in length. * ep1 commands are up to USB_EP1OUT_SIZE bytes in length.
* This function takes care of zeroing the unused bytes before sending the packet. * This function takes care of zeroing the unused bytes before sending the packet.
* Any reply packet is not handled by this function. * Any reply packet is not handled by this function.
*/ */
static int ep1_generic_commandl(struct libusb_device_handle *pHDev_param, size_t length, ...) static int ep1_generic_commandl(struct libusb_device_handle *hdev_param, size_t length, ...)
{ {
uint8_t usb_buffer[USB_EP1OUT_SIZE]; uint8_t usb_buffer[USB_EP1OUT_SIZE];
uint8_t *usb_buffer_p; uint8_t *usb_buffer_p;
@ -130,7 +130,7 @@ static int ep1_generic_commandl(struct libusb_device_handle *pHDev_param, size_t
); );
usb_ret = jtag_libusb_bulk_write( usb_ret = jtag_libusb_bulk_write(
pHDev_param, hdev_param,
USB_EP1OUT_ADDR, USB_EP1OUT_ADDR,
(char *)usb_buffer, sizeof(usb_buffer), (char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
@ -144,7 +144,7 @@ static int ep1_generic_commandl(struct libusb_device_handle *pHDev_param, size_t
#if 0 #if 0
static ssize_t ep1_memory_read( static ssize_t ep1_memory_read(
struct libusb_device_handle *pHDev_param, uint16_t addr, struct libusb_device_handle *hdev_param, uint16_t addr,
size_t length, uint8_t *buffer) size_t length, uint8_t *buffer)
{ {
uint8_t usb_buffer[USB_EP1OUT_SIZE]; uint8_t usb_buffer[USB_EP1OUT_SIZE];
@ -174,7 +174,7 @@ static ssize_t ep1_memory_read(
usb_buffer[3] = length; usb_buffer[3] = length;
usb_ret = jtag_libusb_bulk_write( usb_ret = jtag_libusb_bulk_write(
pHDev_param, USB_EP1OUT_ADDR, hdev_param, USB_EP1OUT_ADDR,
(char *)usb_buffer, sizeof(usb_buffer), (char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -184,7 +184,7 @@ static ssize_t ep1_memory_read(
break; break;
usb_ret = jtag_libusb_bulk_read( usb_ret = jtag_libusb_bulk_read(
pHDev_param, USB_EP1IN_ADDR, hdev_param, USB_EP1IN_ADDR,
(char *)buffer, length, (char *)buffer, length,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -203,7 +203,7 @@ static ssize_t ep1_memory_read(
} }
#endif #endif
static ssize_t ep1_memory_write(struct libusb_device_handle *pHDev_param, uint16_t addr, static ssize_t ep1_memory_write(struct libusb_device_handle *hdev_param, uint16_t addr,
size_t length, uint8_t const *buffer) size_t length, uint8_t const *buffer)
{ {
uint8_t usb_buffer[USB_EP1OUT_SIZE]; uint8_t usb_buffer[USB_EP1OUT_SIZE];
@ -239,7 +239,7 @@ static ssize_t ep1_memory_write(struct libusb_device_handle *pHDev_param, uint16
int transferred; int transferred;
usb_ret = jtag_libusb_bulk_write( usb_ret = jtag_libusb_bulk_write(
pHDev_param, USB_EP1OUT_ADDR, hdev_param, USB_EP1OUT_ADDR,
(char *)usb_buffer, sizeof(usb_buffer), (char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -259,7 +259,7 @@ static ssize_t ep1_memory_write(struct libusb_device_handle *pHDev_param, uint16
#if 0 #if 0
static ssize_t ep1_memory_writel(struct libusb_device_handle *pHDev_param, uint16_t addr, static ssize_t ep1_memory_writel(struct libusb_device_handle *hdev_param, uint16_t addr,
size_t length, ...) size_t length, ...)
{ {
uint8_t buffer[USB_EP1OUT_SIZE - 4]; uint8_t buffer[USB_EP1OUT_SIZE - 4];
@ -279,7 +279,7 @@ static ssize_t ep1_memory_writel(struct libusb_device_handle *pHDev_param, uint1
remain--; remain--;
} }
return ep1_memory_write(pHDev_param, addr, length, buffer); return ep1_memory_write(hdev_param, addr, length, buffer);
} }
#endif #endif
@ -296,7 +296,7 @@ static ssize_t ep1_memory_writel(struct libusb_device_handle *pHDev_param, uint1
static uint8_t dtc_entry_download; static uint8_t dtc_entry_download;
/* The buffer is specially formatted to represent a valid image to load into the DTC. */ /* The buffer is specially formatted to represent a valid image to load into the DTC. */
static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const uint8_t *buffer, static int dtc_load_from_buffer(struct libusb_device_handle *hdev_param, const uint8_t *buffer,
size_t length) size_t length)
{ {
struct header_s { struct header_s {
@ -312,7 +312,7 @@ static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const
/* Stop the DTC before loading anything. */ /* Stop the DTC before loading anything. */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev_param, 1, hdev_param, 1,
EP1_CMD_DTC_STOP EP1_CMD_DTC_STOP
); );
if (usb_err < 0) if (usb_err < 0)
@ -346,7 +346,7 @@ static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const
case DTCLOAD_LOAD: case DTCLOAD_LOAD:
/* Send the DTC program to ST7 RAM. */ /* Send the DTC program to ST7 RAM. */
usb_err = ep1_memory_write( usb_err = ep1_memory_write(
pHDev_param, hdev_param,
DTC_LOAD_BUFFER, DTC_LOAD_BUFFER,
header->length + 1, buffer header->length + 1, buffer
); );
@ -355,7 +355,7 @@ static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const
/* Load it into the DTC. */ /* Load it into the DTC. */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev_param, 3, hdev_param, 3,
EP1_CMD_DTC_LOAD, EP1_CMD_DTC_LOAD,
(DTC_LOAD_BUFFER >> 8), (DTC_LOAD_BUFFER >> 8),
DTC_LOAD_BUFFER DTC_LOAD_BUFFER
@ -367,7 +367,7 @@ static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const
case DTCLOAD_RUN: case DTCLOAD_RUN:
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev_param, 3, hdev_param, 3,
EP1_CMD_DTC_CALL, EP1_CMD_DTC_CALL,
buffer[0], buffer[0],
EP1_CMD_DTC_WAIT EP1_CMD_DTC_WAIT
@ -383,7 +383,7 @@ static int dtc_load_from_buffer(struct libusb_device_handle *pHDev_param, const
case DTCLOAD_LUT: case DTCLOAD_LUT:
usb_err = ep1_memory_write( usb_err = ep1_memory_write(
pHDev_param, hdev_param,
ST7_USB_BUF_EP0OUT + lut_start, ST7_USB_BUF_EP0OUT + lut_start,
header->length + 1, buffer header->length + 1, buffer
); );
@ -415,7 +415,7 @@ static int dtc_start_download(void)
/* set up for download mode and make sure EP2 is set up to transmit */ /* set up for download mode and make sure EP2 is set up to transmit */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev, 7, hdev, 7,
EP1_CMD_DTC_STOP, EP1_CMD_DTC_STOP,
EP1_CMD_SET_UPLOAD, EP1_CMD_SET_UPLOAD,
@ -430,7 +430,7 @@ static int dtc_start_download(void)
/* read back ep2txr */ /* read back ep2txr */
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)&ep2txr, 1, (char *)&ep2txr, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -439,7 +439,7 @@ static int dtc_start_download(void)
return usb_err; return usb_err;
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev, 13, hdev, 13,
EP1_CMD_MEMORY_WRITE, /* preinitialize poll byte */ EP1_CMD_MEMORY_WRITE, /* preinitialize poll byte */
DTC_STATUS_POLL_BYTE >> 8, DTC_STATUS_POLL_BYTE >> 8,
@ -460,7 +460,7 @@ static int dtc_start_download(void)
/* wait for completion */ /* wait for completion */
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)&ep2txr, 1, (char *)&ep2txr, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -470,7 +470,7 @@ static int dtc_start_download(void)
} }
static int dtc_run_download( static int dtc_run_download(
struct libusb_device_handle *pHDev_param, struct libusb_device_handle *hdev_param,
uint8_t *command_buffer, uint8_t *command_buffer,
int command_buffer_size, int command_buffer_size,
uint8_t *reply_buffer, uint8_t *reply_buffer,
@ -485,7 +485,7 @@ static int dtc_run_download(
LOG_DEBUG("%d/%d", command_buffer_size, reply_buffer_size); LOG_DEBUG("%d/%d", command_buffer_size, reply_buffer_size);
usb_err = jtag_libusb_bulk_write( usb_err = jtag_libusb_bulk_write(
pHDev_param, hdev_param,
USB_EP2OUT_ADDR, USB_EP2OUT_ADDR,
(char *)command_buffer, USB_EP2BANK_SIZE, (char *)command_buffer, USB_EP2BANK_SIZE,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
@ -498,7 +498,7 @@ static int dtc_run_download(
/* Wait for DTC to finish running command buffer */ /* Wait for DTC to finish running command buffer */
for (i = 50;; ) { for (i = 50;; ) {
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev_param, 4, hdev_param, 4,
EP1_CMD_MEMORY_READ, EP1_CMD_MEMORY_READ,
DTC_STATUS_POLL_BYTE >> 8, DTC_STATUS_POLL_BYTE >> 8,
@ -509,7 +509,7 @@ static int dtc_run_download(
return usb_err; return usb_err;
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev_param, hdev_param,
USB_EP1IN_ADDR, USB_EP1IN_ADDR,
&dtc_status, 1, &dtc_status, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
@ -530,7 +530,7 @@ static int dtc_run_download(
if (reply_buffer && reply_buffer_size) { if (reply_buffer && reply_buffer_size) {
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev_param, hdev_param,
USB_EP2IN_ADDR, USB_EP2IN_ADDR,
(char *)reply_buffer, reply_buffer_size, (char *)reply_buffer, reply_buffer_size,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
@ -656,7 +656,7 @@ static int dtc_queue_run(void)
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP; dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP;
usb_err = dtc_run_download(pHDev, usb_err = dtc_run_download(hdev,
dtc_queue.cmd_buffer, dtc_queue.cmd_index, dtc_queue.cmd_buffer, dtc_queue.cmd_index,
reply_buffer, sizeof(reply_buffer) reply_buffer, sizeof(reply_buffer)
); );
@ -940,7 +940,7 @@ static void rlink_reset(int trst, int srst)
/* Read port A for bit op */ /* Read port A for bit op */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev, 4, hdev, 4,
EP1_CMD_MEMORY_READ, EP1_CMD_MEMORY_READ,
ST7_PADR >> 8, ST7_PADR >> 8,
ST7_PADR, ST7_PADR,
@ -952,7 +952,7 @@ static void rlink_reset(int trst, int srst)
} }
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)&bitmap, 1, (char *)&bitmap, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -971,7 +971,7 @@ static void rlink_reset(int trst, int srst)
* port B has no OR, and we want to emulate open drain on NSRST, so we initialize DR to 0 * port B has no OR, and we want to emulate open drain on NSRST, so we initialize DR to 0
*and assert NSRST by setting DDR to 1. */ *and assert NSRST by setting DDR to 1. */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev, 9, hdev, 9,
EP1_CMD_MEMORY_WRITE, EP1_CMD_MEMORY_WRITE,
ST7_PADR >> 8, ST7_PADR >> 8,
ST7_PADR, ST7_PADR,
@ -988,7 +988,7 @@ static void rlink_reset(int trst, int srst)
} }
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)&bitmap, 1, (char *)&bitmap, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -1005,7 +1005,7 @@ static void rlink_reset(int trst, int srst)
/* write port B and read dummy to ensure completion before returning */ /* write port B and read dummy to ensure completion before returning */
usb_err = ep1_generic_commandl( usb_err = ep1_generic_commandl(
pHDev, 6, hdev, 6,
EP1_CMD_MEMORY_WRITE, EP1_CMD_MEMORY_WRITE,
ST7_PBDDR >> 8, ST7_PBDDR >> 8,
ST7_PBDDR, ST7_PBDDR,
@ -1019,7 +1019,7 @@ static void rlink_reset(int trst, int srst)
} }
usb_err = jtag_libusb_bulk_read( usb_err = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)&bitmap, 1, (char *)&bitmap, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -1297,7 +1297,7 @@ static int rlink_execute_queue(void)
#ifndef AUTOMATIC_BUSY_LED #ifndef AUTOMATIC_BUSY_LED
/* turn LED on */ /* turn LED on */
ep1_generic_commandl(pHDev, 2, ep1_generic_commandl(hdev, 2,
EP1_CMD_SET_PORTD_LEDS, EP1_CMD_SET_PORTD_LEDS,
~(ST7_PD_NBUSY_LED) ~(ST7_PD_NBUSY_LED)
); );
@ -1381,7 +1381,7 @@ static int rlink_execute_queue(void)
#ifndef AUTOMATIC_BUSY_LED #ifndef AUTOMATIC_BUSY_LED
/* turn LED off */ /* turn LED off */
ep1_generic_commandl(pHDev, 2, ep1_generic_commandl(hdev, 2,
EP1_CMD_SET_PORTD_LEDS, EP1_CMD_SET_PORTD_LEDS,
~0 ~0
); );
@ -1404,7 +1404,7 @@ static int rlink_speed(int speed)
for (i = rlink_speed_table_size; i--; ) { for (i = rlink_speed_table_size; i--; ) {
if (rlink_speed_table[i].prescaler == speed) { if (rlink_speed_table[i].prescaler == speed) {
if (dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, if (dtc_load_from_buffer(hdev, rlink_speed_table[i].dtc,
rlink_speed_table[i].dtc_size) != 0) { rlink_speed_table[i].dtc_size) != 0) {
LOG_ERROR( LOG_ERROR(
"An error occurred while trying to load DTC code for speed \"%d\".", "An error occurred while trying to load DTC code for speed \"%d\".",
@ -1470,11 +1470,11 @@ static int rlink_init(void)
const uint16_t vids[] = { USB_IDVENDOR, 0 }; const uint16_t vids[] = { USB_IDVENDOR, 0 };
const uint16_t pids[] = { USB_IDPRODUCT, 0 }; const uint16_t pids[] = { USB_IDPRODUCT, 0 };
if (jtag_libusb_open(vids, pids, NULL, &pHDev, NULL) != ERROR_OK) if (jtag_libusb_open(vids, pids, NULL, &hdev, NULL) != ERROR_OK)
return ERROR_FAIL; return ERROR_FAIL;
struct libusb_device_descriptor descriptor; struct libusb_device_descriptor descriptor;
struct libusb_device *usb_dev = libusb_get_device(pHDev); struct libusb_device *usb_dev = libusb_get_device(hdev);
int r = libusb_get_device_descriptor(usb_dev, &descriptor); int r = libusb_get_device_descriptor(usb_dev, &descriptor);
if (r < 0) { if (r < 0) {
LOG_ERROR("error %d getting device descriptor", r); LOG_ERROR("error %d getting device descriptor", r);
@ -1492,17 +1492,17 @@ static int rlink_init(void)
return ERROR_FAIL; return ERROR_FAIL;
} }
LOG_DEBUG("Opened device, pHDev = %p", pHDev); LOG_DEBUG("Opened device, hdev = %p", hdev);
/* usb_set_configuration required under win32 */ /* usb_set_configuration required under win32 */
libusb_set_configuration(pHDev, config->bConfigurationValue); libusb_set_configuration(hdev, config->bConfigurationValue);
retries = 3; retries = 3;
do { do {
i = libusb_claim_interface(pHDev, 0); i = libusb_claim_interface(hdev, 0);
if (i != LIBUSB_SUCCESS) { if (i != LIBUSB_SUCCESS) {
LOG_ERROR("usb_claim_interface: %s", libusb_error_name(i)); LOG_ERROR("usb_claim_interface: %s", libusb_error_name(i));
j = libusb_detach_kernel_driver(pHDev, 0); j = libusb_detach_kernel_driver(hdev, 0);
if (j != LIBUSB_SUCCESS) if (j != LIBUSB_SUCCESS)
LOG_ERROR("detach kernel driver: %s", libusb_error_name(j)); LOG_ERROR("detach kernel driver: %s", libusb_error_name(j));
} else { } else {
@ -1515,7 +1515,7 @@ static int rlink_init(void)
LOG_ERROR("Initialisation failed."); LOG_ERROR("Initialisation failed.");
return ERROR_FAIL; return ERROR_FAIL;
} }
if (libusb_set_interface_alt_setting(pHDev, 0, 0) != LIBUSB_SUCCESS) { if (libusb_set_interface_alt_setting(hdev, 0, 0) != LIBUSB_SUCCESS) {
LOG_ERROR("Failed to set interface."); LOG_ERROR("Failed to set interface.");
return ERROR_FAIL; return ERROR_FAIL;
} }
@ -1531,7 +1531,7 @@ static int rlink_init(void)
*/ */
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
j = ep1_generic_commandl( j = ep1_generic_commandl(
pHDev, 1, hdev, 1,
EP1_CMD_GET_FWREV EP1_CMD_GET_FWREV
); );
if (j < USB_EP1OUT_SIZE) { if (j < USB_EP1OUT_SIZE) {
@ -1539,7 +1539,7 @@ static int rlink_init(void)
return ERROR_FAIL; return ERROR_FAIL;
} }
j = jtag_libusb_bulk_read( j = jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)reply_buffer, sizeof(reply_buffer), (char *)reply_buffer, sizeof(reply_buffer),
200, 200,
&transferred &transferred
@ -1563,7 +1563,7 @@ static int rlink_init(void)
/* Probe port E for adapter presence */ /* Probe port E for adapter presence */
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 16, hdev, 16,
EP1_CMD_MEMORY_WRITE, /* Drive sense pin with 0 */ EP1_CMD_MEMORY_WRITE, /* Drive sense pin with 0 */
ST7_PEDR >> 8, ST7_PEDR >> 8,
ST7_PEDR, ST7_PEDR,
@ -1583,7 +1583,7 @@ static int rlink_init(void)
); );
jtag_libusb_bulk_read( jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)reply_buffer, 1, (char *)reply_buffer, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -1593,7 +1593,7 @@ static int rlink_init(void)
LOG_WARNING("target detection problem"); LOG_WARNING("target detection problem");
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 11, hdev, 11,
EP1_CMD_MEMORY_READ, /* Read back */ EP1_CMD_MEMORY_READ, /* Read back */
ST7_PEDR >> 8, ST7_PEDR >> 8,
ST7_PEDR, ST7_PEDR,
@ -1608,7 +1608,7 @@ static int rlink_init(void)
); );
jtag_libusb_bulk_read( jtag_libusb_bulk_read(
pHDev, USB_EP1IN_ADDR, hdev, USB_EP1IN_ADDR,
(char *)reply_buffer, 1, (char *)reply_buffer, 1,
USB_TIMEOUT_MS, USB_TIMEOUT_MS,
&transferred &transferred
@ -1620,7 +1620,7 @@ static int rlink_init(void)
/* float ports A and B */ /* float ports A and B */
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 11, hdev, 11,
EP1_CMD_MEMORY_WRITE, EP1_CMD_MEMORY_WRITE,
ST7_PADDR >> 8, ST7_PADDR >> 8,
ST7_PADDR, ST7_PADDR,
@ -1636,7 +1636,7 @@ static int rlink_init(void)
/* make sure DTC is stopped, set VPP control, set up ports A and B */ /* make sure DTC is stopped, set VPP control, set up ports A and B */
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 14, hdev, 14,
EP1_CMD_DTC_STOP, EP1_CMD_DTC_STOP,
EP1_CMD_SET_PORTD_VPP, EP1_CMD_SET_PORTD_VPP,
~(ST7_PD_VPP_SHDN), ~(ST7_PD_VPP_SHDN),
@ -1657,7 +1657,7 @@ static int rlink_init(void)
/* set LED updating mode and make sure they're unlit */ /* set LED updating mode and make sure they're unlit */
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 3, hdev, 3,
#ifdef AUTOMATIC_BUSY_LED #ifdef AUTOMATIC_BUSY_LED
EP1_CMD_LEDUE_BUSY, EP1_CMD_LEDUE_BUSY,
#else #else
@ -1678,7 +1678,7 @@ static int rlink_quit(void)
{ {
/* stop DTC and make sure LEDs are off */ /* stop DTC and make sure LEDs are off */
ep1_generic_commandl( ep1_generic_commandl(
pHDev, 6, hdev, 6,
EP1_CMD_DTC_STOP, EP1_CMD_DTC_STOP,
EP1_CMD_LEDUE_NONE, EP1_CMD_LEDUE_NONE,
EP1_CMD_SET_PORTD_LEDS, EP1_CMD_SET_PORTD_LEDS,
@ -1687,8 +1687,8 @@ static int rlink_quit(void)
~0 ~0
); );
libusb_release_interface(pHDev, 0); libusb_release_interface(hdev, 0);
libusb_close(pHDev); libusb_close(hdev);
return ERROR_OK; return ERROR_OK;
} }

View File

@ -37,7 +37,7 @@ RESULT usbtojtagraw_fini(uint8_t interface_index)
return usbtoxxx_fini_command(USB_TO_JTAG_RAW, interface_index); return usbtoxxx_fini_command(USB_TO_JTAG_RAW, interface_index);
} }
RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t kHz) RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t khz)
{ {
uint8_t cfg_buf[4]; uint8_t cfg_buf[4];
@ -48,7 +48,7 @@ RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t kHz)
} }
#endif #endif
SET_LE_U32(&cfg_buf[0], kHz); SET_LE_U32(&cfg_buf[0], khz);
return usbtoxxx_conf_command(USB_TO_JTAG_RAW, interface_index, cfg_buf, 4); return usbtoxxx_conf_command(USB_TO_JTAG_RAW, interface_index, cfg_buf, 4);
} }

View File

@ -49,7 +49,7 @@ RESULT usbtopwr_config(uint8_t interface_index)
return usbtoxxx_conf_command(USB_TO_POWER, interface_index, NULL, 0); return usbtoxxx_conf_command(USB_TO_POWER, interface_index, NULL, 0);
} }
RESULT usbtopwr_output(uint8_t interface_index, uint16_t mV) RESULT usbtopwr_output(uint8_t interface_index, uint16_t millivolt)
{ {
#if PARAM_CHECK #if PARAM_CHECK
if (interface_index > 7) { if (interface_index > 7) {
@ -58,6 +58,6 @@ RESULT usbtopwr_output(uint8_t interface_index, uint16_t mV)
} }
#endif #endif
return usbtoxxx_out_command(USB_TO_POWER, interface_index, (uint8_t *)&mV, return usbtoxxx_out_command(USB_TO_POWER, interface_index, (uint8_t *)&millivolt,
2, 0); 2, 0);
} }

View File

@ -47,7 +47,7 @@ RESULT usbtousart_status(uint8_t interface_index,
/* USB_TO_SPI */ /* USB_TO_SPI */
RESULT usbtospi_init(uint8_t interface_index); RESULT usbtospi_init(uint8_t interface_index);
RESULT usbtospi_fini(uint8_t interface_index); RESULT usbtospi_fini(uint8_t interface_index);
RESULT usbtospi_config(uint8_t interface_index, uint32_t kHz, uint8_t mode); RESULT usbtospi_config(uint8_t interface_index, uint32_t khz, uint8_t mode);
RESULT usbtospi_io(uint8_t interface_index, uint8_t *out, uint8_t *in, RESULT usbtospi_io(uint8_t interface_index, uint8_t *out, uint8_t *in,
uint16_t bytelen); uint16_t bytelen);
@ -82,7 +82,7 @@ RESULT usbtolpcicp_poll_ready(uint8_t interface_index, uint8_t data,
/* USB_TO_JTAG_LL */ /* USB_TO_JTAG_LL */
RESULT usbtojtagll_init(uint8_t interface_index); RESULT usbtojtagll_init(uint8_t interface_index);
RESULT usbtojtagll_fini(uint8_t interface_index); RESULT usbtojtagll_fini(uint8_t interface_index);
RESULT usbtojtagll_config(uint8_t interface_index, uint32_t kHz); RESULT usbtojtagll_config(uint8_t interface_index, uint32_t khz);
RESULT usbtojtagll_tms(uint8_t interface_index, uint8_t *tms, uint8_t bytelen); RESULT usbtojtagll_tms(uint8_t interface_index, uint8_t *tms, uint8_t bytelen);
RESULT usbtojtagll_tms_clocks(uint8_t interface_index, uint32_t bytelen, RESULT usbtojtagll_tms_clocks(uint8_t interface_index, uint32_t bytelen,
uint8_t tms); uint8_t tms);
@ -94,7 +94,7 @@ RESULT usbtojtagll_scan(uint8_t interface_index, uint8_t *data,
/* USB_TO_JTAG_HL */ /* USB_TO_JTAG_HL */
RESULT usbtojtaghl_init(uint8_t interface_index); RESULT usbtojtaghl_init(uint8_t interface_index);
RESULT usbtojtaghl_fini(uint8_t interface_index); RESULT usbtojtaghl_fini(uint8_t interface_index);
RESULT usbtojtaghl_config(uint8_t interface_index, uint32_t kHz, uint8_t ub, RESULT usbtojtaghl_config(uint8_t interface_index, uint32_t khz, uint8_t ub,
uint8_t ua, uint16_t bb, uint16_t ba); uint8_t ua, uint16_t bb, uint16_t ba);
RESULT usbtojtaghl_ir(uint8_t interface_index, uint8_t *ir, uint16_t bitlen, RESULT usbtojtaghl_ir(uint8_t interface_index, uint8_t *ir, uint16_t bitlen,
uint8_t idle, uint8_t want_ret); uint8_t idle, uint8_t want_ret);
@ -108,7 +108,7 @@ RESULT usbtojtaghl_register_callback(uint8_t index, jtag_callback_t send_callbac
/* USB_TO_JTAG_RAW */ /* USB_TO_JTAG_RAW */
RESULT usbtojtagraw_init(uint8_t interface_index); RESULT usbtojtagraw_init(uint8_t interface_index);
RESULT usbtojtagraw_fini(uint8_t interface_index); RESULT usbtojtagraw_fini(uint8_t interface_index);
RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t kHz); RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t khz);
RESULT usbtojtagraw_execute(uint8_t interface_index, uint8_t *tdi, RESULT usbtojtagraw_execute(uint8_t interface_index, uint8_t *tdi,
uint8_t *tms, uint8_t *tdo, uint32_t bitlen); uint8_t *tms, uint8_t *tdo, uint32_t bitlen);
@ -123,7 +123,7 @@ RESULT usbtoc2_readdata(uint8_t interface_index, uint8_t *buf, uint8_t len);
/* USB_TO_I2C */ /* USB_TO_I2C */
RESULT usbtoi2c_init(uint8_t interface_index); RESULT usbtoi2c_init(uint8_t interface_index);
RESULT usbtoi2c_fini(uint8_t interface_index); RESULT usbtoi2c_fini(uint8_t interface_index);
RESULT usbtoi2c_config(uint8_t interface_index, uint16_t kHz, RESULT usbtoi2c_config(uint8_t interface_index, uint16_t khz,
uint16_t byte_interval, uint16_t max_dly); uint16_t byte_interval, uint16_t max_dly);
RESULT usbtoi2c_read(uint8_t interface_index, uint16_t chip_addr, RESULT usbtoi2c_read(uint8_t interface_index, uint16_t chip_addr,
uint8_t *data, uint16_t data_len, uint8_t stop, uint8_t *data, uint16_t data_len, uint8_t stop,
@ -165,7 +165,7 @@ RESULT usbtomsp430sbw_poll(uint8_t interface_index, uint32_t dr, uint32_t mask,
RESULT usbtopwr_init(uint8_t interface_index); RESULT usbtopwr_init(uint8_t interface_index);
RESULT usbtopwr_fini(uint8_t interface_index); RESULT usbtopwr_fini(uint8_t interface_index);
RESULT usbtopwr_config(uint8_t interface_index); RESULT usbtopwr_config(uint8_t interface_index);
RESULT usbtopwr_output(uint8_t interface_index, uint16_t mV); RESULT usbtopwr_output(uint8_t interface_index, uint16_t millivolt);
/* USB_TO_POLL */ /* USB_TO_POLL */
RESULT usbtopoll_start(uint16_t retry_cnt, uint16_t interval_us); RESULT usbtopoll_start(uint16_t retry_cnt, uint16_t interval_us);
@ -190,14 +190,14 @@ RESULT usbtoswd_transact(uint8_t interface_index, uint8_t request,
/* USB_TO_SWIM */ /* USB_TO_SWIM */
RESULT usbtoswim_init(uint8_t interface_index); RESULT usbtoswim_init(uint8_t interface_index);
RESULT usbtoswim_fini(uint8_t interface_index); RESULT usbtoswim_fini(uint8_t interface_index);
RESULT usbtoswim_config(uint8_t interface_index, uint8_t mHz, uint8_t cnt0, RESULT usbtoswim_config(uint8_t interface_index, uint8_t mhz, uint8_t cnt0,
uint8_t cnt1); uint8_t cnt1);
RESULT usbtoswim_srst(uint8_t interface_index); RESULT usbtoswim_srst(uint8_t interface_index);
RESULT usbtoswim_wotf(uint8_t interface_index, uint8_t *data, RESULT usbtoswim_wotf(uint8_t interface_index, uint8_t *data,
uint16_t bytelen, uint32_t addr); uint16_t bytelen, uint32_t addr);
RESULT usbtoswim_rotf(uint8_t interface_index, uint8_t *data, RESULT usbtoswim_rotf(uint8_t interface_index, uint8_t *data,
uint16_t bytelen, uint32_t addr); uint16_t bytelen, uint32_t addr);
RESULT usbtoswim_sync(uint8_t interface_index, uint8_t mHz); RESULT usbtoswim_sync(uint8_t interface_index, uint8_t mhz);
RESULT usbtoswim_enable(uint8_t interface_index); RESULT usbtoswim_enable(uint8_t interface_index);
/* USB_TO_BDM */ /* USB_TO_BDM */
@ -210,14 +210,14 @@ RESULT usbtobdm_transact(uint8_t interface_index, uint8_t *out,
/* USB_TO_DUSI */ /* USB_TO_DUSI */
RESULT usbtodusi_init(uint8_t interface_index); RESULT usbtodusi_init(uint8_t interface_index);
RESULT usbtodusi_fini(uint8_t interface_index); RESULT usbtodusi_fini(uint8_t interface_index);
RESULT usbtodusi_config(uint8_t interface_index, uint32_t kHz, uint8_t mode); RESULT usbtodusi_config(uint8_t interface_index, uint32_t khz, uint8_t mode);
RESULT usbtodusi_io(uint8_t interface_index, uint8_t *mo, uint8_t *mi, RESULT usbtodusi_io(uint8_t interface_index, uint8_t *mo, uint8_t *mi,
uint8_t *so, uint8_t *si, uint32_t bitlen); uint8_t *so, uint8_t *si, uint32_t bitlen);
/* USB_TO_MICROWIRE */ /* USB_TO_MICROWIRE */
RESULT usbtomicrowire_init(uint8_t interface_index); RESULT usbtomicrowire_init(uint8_t interface_index);
RESULT usbtomicrowire_fini(uint8_t interface_index); RESULT usbtomicrowire_fini(uint8_t interface_index);
RESULT usbtomicrowire_config(uint8_t interface_index, uint16_t kHz, RESULT usbtomicrowire_config(uint8_t interface_index, uint16_t khz,
uint8_t sel_polarity); uint8_t sel_polarity);
RESULT usbtomicrowire_transport(uint8_t interface_index, RESULT usbtomicrowire_transport(uint8_t interface_index,
uint32_t opcode, uint8_t opcode_bitlen, uint32_t opcode, uint8_t opcode_bitlen,
@ -230,7 +230,7 @@ RESULT usbtomicrowire_poll(uint8_t interface_index, uint16_t interval_us,
/* USB_TO_PWM */ /* USB_TO_PWM */
RESULT usbtopwm_init(uint8_t interface_index); RESULT usbtopwm_init(uint8_t interface_index);
RESULT usbtopwm_fini(uint8_t interface_index); RESULT usbtopwm_fini(uint8_t interface_index);
RESULT usbtopwm_config(uint8_t interface_index, uint16_t kHz, uint8_t mode); RESULT usbtopwm_config(uint8_t interface_index, uint16_t khz, uint8_t mode);
RESULT usbtopwm_out(uint8_t interface_index, uint16_t count, uint16_t *rate); RESULT usbtopwm_out(uint8_t interface_index, uint16_t count, uint16_t *rate);
RESULT usbtopwm_in(uint8_t interface_index, uint16_t count, uint16_t *rate); RESULT usbtopwm_in(uint8_t interface_index, uint16_t count, uint16_t *rate);

View File

@ -69,7 +69,7 @@ struct interface_swd_t {
struct interface_jtag_raw_t { struct interface_jtag_raw_t {
RESULT(*init)(uint8_t interface_index); RESULT(*init)(uint8_t interface_index);
RESULT(*fini)(uint8_t interface_index); RESULT(*fini)(uint8_t interface_index);
RESULT(*config)(uint8_t interface_index, uint32_t kHz); RESULT(*config)(uint8_t interface_index, uint32_t khz);
RESULT(*execute)(uint8_t interface_index, uint8_t *tdi, uint8_t *tms, RESULT(*execute)(uint8_t interface_index, uint8_t *tdi, uint8_t *tms,
uint8_t *tdo, uint32_t bitlen); uint8_t *tdo, uint32_t bitlen);
}; };

View File

@ -31,7 +31,7 @@
#define XLNX_XVC_VSEC_HDR 0x04 #define XLNX_XVC_VSEC_HDR 0x04
#define XLNX_XVC_LEN_REG 0x0C #define XLNX_XVC_LEN_REG 0x0C
#define XLNX_XVC_TMS_REG 0x10 #define XLNX_XVC_TMS_REG 0x10
#define XLNX_XVC_TDx_REG 0x14 #define XLNX_XVC_TDX_REG 0x14
#define XLNX_XVC_CAP_SIZE 0x20 #define XLNX_XVC_CAP_SIZE 0x20
#define XLNX_XVC_VSEC_ID 0x8 #define XLNX_XVC_VSEC_ID 0x8
@ -103,11 +103,11 @@ static int xlnx_pcie_xvc_transact(size_t num_bits, uint32_t tms, uint32_t tdi,
if (err != ERROR_OK) if (err != ERROR_OK)
return err; return err;
err = xlnx_pcie_xvc_write_reg(XLNX_XVC_TDx_REG, tdi); err = xlnx_pcie_xvc_write_reg(XLNX_XVC_TDX_REG, tdi);
if (err != ERROR_OK) if (err != ERROR_OK)
return err; return err;
err = xlnx_pcie_xvc_read_reg(XLNX_XVC_TDx_REG, tdo); err = xlnx_pcie_xvc_read_reg(XLNX_XVC_TDX_REG, tdo);
if (err != ERROR_OK) if (err != ERROR_OK)
return err; return err;

View File

@ -29,7 +29,7 @@
#include <helper/time_support.h> #include <helper/time_support.h>
static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi, static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi,
struct jtag_tap *pTap) struct jtag_tap *tap)
{ {
jim_wide w; jim_wide w;
int e = jim_getopt_wide(goi, &w); int e = jim_getopt_wide(goi, &w);
@ -39,15 +39,15 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
return e; return e;
} }
uint32_t *p = realloc(pTap->expected_ids, uint32_t *p = realloc(tap->expected_ids,
(pTap->expected_ids_cnt + 1) * sizeof(uint32_t)); (tap->expected_ids_cnt + 1) * sizeof(uint32_t));
if (!p) { if (!p) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
pTap->expected_ids = p; tap->expected_ids = p;
pTap->expected_ids[pTap->expected_ids_cnt++] = w; tap->expected_ids[tap->expected_ids_cnt++] = w;
return JIM_OK; return JIM_OK;
} }
@ -62,7 +62,7 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
static int jim_hl_newtap_cmd(struct jim_getopt_info *goi) static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
{ {
struct jtag_tap *pTap; struct jtag_tap *tap;
int x; int x;
int e; int e;
struct jim_nvp *n; struct jim_nvp *n;
@ -78,8 +78,8 @@ static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
{ .name = NULL, .value = -1}, { .name = NULL, .value = -1},
}; };
pTap = calloc(1, sizeof(struct jtag_tap)); tap = calloc(1, sizeof(struct jtag_tap));
if (!pTap) { if (!tap) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
@ -90,41 +90,41 @@ static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
if (goi->argc < 3) { if (goi->argc < 3) {
Jim_SetResultFormatted(goi->interp, Jim_SetResultFormatted(goi->interp,
"Missing CHIP TAP OPTIONS ...."); "Missing CHIP TAP OPTIONS ....");
free(pTap); free(tap);
return JIM_ERR; return JIM_ERR;
} }
const char *tmp; const char *tmp;
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->chip = strdup(tmp); tap->chip = strdup(tmp);
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->tapname = strdup(tmp); tap->tapname = strdup(tmp);
/* name + dot + name + null */ /* name + dot + name + null */
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; x = strlen(tap->chip) + 1 + strlen(tap->tapname) + 1;
cp = malloc(x); cp = malloc(x);
sprintf(cp, "%s.%s", pTap->chip, pTap->tapname); sprintf(cp, "%s.%s", tap->chip, tap->tapname);
pTap->dotted_name = cp; tap->dotted_name = cp;
LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params", LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc); tap->chip, tap->tapname, tap->dotted_name, goi->argc);
while (goi->argc) { while (goi->argc) {
e = jim_getopt_nvp(goi, opts, &n); e = jim_getopt_nvp(goi, opts, &n);
if (e != JIM_OK) { if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, opts, 0); jim_getopt_nvp_unknown(goi, opts, 0);
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
LOG_DEBUG("Processing option: %s", n->name); LOG_DEBUG("Processing option: %s", n->name);
switch (n->value) { switch (n->value) {
case NTAP_OPT_EXPECTED_ID: case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap); e = jim_newtap_expected_id(n, goi, tap);
if (JIM_OK != e) { if (JIM_OK != e) {
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
break; break;
@ -138,9 +138,9 @@ static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
} /* while (goi->argc) */ } /* while (goi->argc) */
/* default is enabled-after-reset */ /* default is enabled-after-reset */
pTap->enabled = !pTap->disabled_after_reset; tap->enabled = !tap->disabled_after_reset;
jtag_tap_init(pTap); jtag_tap_init(tap);
return JIM_OK; return JIM_OK;
} }

View File

@ -82,7 +82,7 @@ static bool scan_is_safe(tap_state_t state)
} }
} }
static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args) static int jim_command_drscan(Jim_Interp *interp, int argc, Jim_Obj * const *args)
{ {
int retval; int retval;
struct scan_field *fields; struct scan_field *fields;
@ -223,7 +223,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
} }
static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *args) static int jim_command_pathmove(Jim_Interp *interp, int argc, Jim_Obj * const *args)
{ {
tap_state_t states[8]; tap_state_t states[8];
@ -260,7 +260,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar
} }
static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args) static int jim_command_flush_count(Jim_Interp *interp, int argc, Jim_Obj * const *args)
{ {
Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count())); Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count()));
@ -281,7 +281,7 @@ static const struct command_registration jtag_command_handlers_to_move[] = {
{ {
.name = "drscan", .name = "drscan",
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.jim_handler = Jim_Command_drscan, .jim_handler = jim_command_drscan,
.help = "Execute Data Register (DR) scan for one TAP. " .help = "Execute Data Register (DR) scan for one TAP. "
"Other TAPs must be in BYPASS mode.", "Other TAPs must be in BYPASS mode.",
.usage = "tap_name [num_bits value]* ['-endstate' state_name]", .usage = "tap_name [num_bits value]* ['-endstate' state_name]",
@ -289,14 +289,14 @@ static const struct command_registration jtag_command_handlers_to_move[] = {
{ {
.name = "flush_count", .name = "flush_count",
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.jim_handler = Jim_Command_flush_count, .jim_handler = jim_command_flush_count,
.help = "Returns the number of times the JTAG queue " .help = "Returns the number of times the JTAG queue "
"has been flushed.", "has been flushed.",
}, },
{ {
.name = "pathmove", .name = "pathmove",
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.jim_handler = Jim_Command_pathmove, .jim_handler = jim_command_pathmove,
.usage = "start_state state1 [state2 [state3 ...]]", .usage = "start_state state1 [state2 [state3 ...]]",
.help = "Move JTAG state machine from current state " .help = "Move JTAG state machine from current state "
"(start_state) to state1, then state2, state3, etc.", "(start_state) to state1, then state2, state3, etc.",
@ -440,7 +440,7 @@ static int is_bad_irval(int ir_length, jim_wide w)
} }
static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi, static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi,
struct jtag_tap *pTap) struct jtag_tap *tap)
{ {
jim_wide w; jim_wide w;
int e = jim_getopt_wide(goi, &w); int e = jim_getopt_wide(goi, &w);
@ -449,15 +449,15 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
return e; return e;
} }
uint32_t *p = realloc(pTap->expected_ids, uint32_t *p = realloc(tap->expected_ids,
(pTap->expected_ids_cnt + 1) * sizeof(uint32_t)); (tap->expected_ids_cnt + 1) * sizeof(uint32_t));
if (!p) { if (!p) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
pTap->expected_ids = p; tap->expected_ids = p;
pTap->expected_ids[pTap->expected_ids_cnt++] = w; tap->expected_ids[tap->expected_ids_cnt++] = w;
return JIM_OK; return JIM_OK;
} }
@ -471,7 +471,7 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
#define NTAP_OPT_VERSION 6 #define NTAP_OPT_VERSION 6
static int jim_newtap_ir_param(struct jim_nvp *n, struct jim_getopt_info *goi, static int jim_newtap_ir_param(struct jim_nvp *n, struct jim_getopt_info *goi,
struct jtag_tap *pTap) struct jtag_tap *tap)
{ {
jim_wide w; jim_wide w;
int e = jim_getopt_wide(goi, &w); int e = jim_getopt_wide(goi, &w);
@ -482,33 +482,33 @@ static int jim_newtap_ir_param(struct jim_nvp *n, struct jim_getopt_info *goi,
} }
switch (n->value) { switch (n->value) {
case NTAP_OPT_IRLEN: case NTAP_OPT_IRLEN:
if (w > (jim_wide) (8 * sizeof(pTap->ir_capture_value))) { if (w > (jim_wide) (8 * sizeof(tap->ir_capture_value))) {
LOG_WARNING("%s: huge IR length %d", LOG_WARNING("%s: huge IR length %d",
pTap->dotted_name, (int) w); tap->dotted_name, (int) w);
} }
pTap->ir_length = w; tap->ir_length = w;
break; break;
case NTAP_OPT_IRMASK: case NTAP_OPT_IRMASK:
if (is_bad_irval(pTap->ir_length, w)) { if (is_bad_irval(tap->ir_length, w)) {
LOG_ERROR("%s: IR mask %x too big", LOG_ERROR("%s: IR mask %x too big",
pTap->dotted_name, tap->dotted_name,
(int) w); (int) w);
return JIM_ERR; return JIM_ERR;
} }
if ((w & 3) != 3) if ((w & 3) != 3)
LOG_WARNING("%s: nonstandard IR mask", pTap->dotted_name); LOG_WARNING("%s: nonstandard IR mask", tap->dotted_name);
pTap->ir_capture_mask = w; tap->ir_capture_mask = w;
break; break;
case NTAP_OPT_IRCAPTURE: case NTAP_OPT_IRCAPTURE:
if (is_bad_irval(pTap->ir_length, w)) { if (is_bad_irval(tap->ir_length, w)) {
LOG_ERROR("%s: IR capture %x too big", LOG_ERROR("%s: IR capture %x too big",
pTap->dotted_name, (int) w); tap->dotted_name, (int) w);
return JIM_ERR; return JIM_ERR;
} }
if ((w & 3) != 1) if ((w & 3) != 1)
LOG_WARNING("%s: nonstandard IR value", LOG_WARNING("%s: nonstandard IR value",
pTap->dotted_name); tap->dotted_name);
pTap->ir_capture_value = w; tap->ir_capture_value = w;
break; break;
default: default:
return JIM_ERR; return JIM_ERR;
@ -518,7 +518,7 @@ static int jim_newtap_ir_param(struct jim_nvp *n, struct jim_getopt_info *goi,
static int jim_newtap_cmd(struct jim_getopt_info *goi) static int jim_newtap_cmd(struct jim_getopt_info *goi)
{ {
struct jtag_tap *pTap; struct jtag_tap *tap;
int x; int x;
int e; int e;
struct jim_nvp *n; struct jim_nvp *n;
@ -534,8 +534,8 @@ static int jim_newtap_cmd(struct jim_getopt_info *goi)
{ .name = NULL, .value = -1 }, { .name = NULL, .value = -1 },
}; };
pTap = calloc(1, sizeof(struct jtag_tap)); tap = calloc(1, sizeof(struct jtag_tap));
if (!pTap) { if (!tap) {
Jim_SetResultFormatted(goi->interp, "no memory"); Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR; return JIM_ERR;
} }
@ -545,30 +545,30 @@ static int jim_newtap_cmd(struct jim_getopt_info *goi)
* */ * */
if (goi->argc < 3) { if (goi->argc < 3) {
Jim_SetResultFormatted(goi->interp, "Missing CHIP TAP OPTIONS ...."); Jim_SetResultFormatted(goi->interp, "Missing CHIP TAP OPTIONS ....");
free(pTap); free(tap);
return JIM_ERR; return JIM_ERR;
} }
const char *tmp; const char *tmp;
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->chip = strdup(tmp); tap->chip = strdup(tmp);
jim_getopt_string(goi, &tmp, NULL); jim_getopt_string(goi, &tmp, NULL);
pTap->tapname = strdup(tmp); tap->tapname = strdup(tmp);
/* name + dot + name + null */ /* name + dot + name + null */
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; x = strlen(tap->chip) + 1 + strlen(tap->tapname) + 1;
cp = malloc(x); cp = malloc(x);
sprintf(cp, "%s.%s", pTap->chip, pTap->tapname); sprintf(cp, "%s.%s", tap->chip, tap->tapname);
pTap->dotted_name = cp; tap->dotted_name = cp;
LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params", LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc); tap->chip, tap->tapname, tap->dotted_name, goi->argc);
if (!transport_is_jtag()) { if (!transport_is_jtag()) {
/* SWD doesn't require any JTAG tap parameters */ /* SWD doesn't require any JTAG tap parameters */
pTap->enabled = true; tap->enabled = true;
jtag_tap_init(pTap); jtag_tap_init(tap);
return JIM_OK; return JIM_OK;
} }
@ -576,62 +576,62 @@ static int jim_newtap_cmd(struct jim_getopt_info *goi)
* that the default. The "-ircapture" and "-irmask" options are only * that the default. The "-ircapture" and "-irmask" options are only
* needed to cope with nonstandard TAPs, or to specify more bits. * needed to cope with nonstandard TAPs, or to specify more bits.
*/ */
pTap->ir_capture_mask = 0x03; tap->ir_capture_mask = 0x03;
pTap->ir_capture_value = 0x01; tap->ir_capture_value = 0x01;
while (goi->argc) { while (goi->argc) {
e = jim_getopt_nvp(goi, opts, &n); e = jim_getopt_nvp(goi, opts, &n);
if (e != JIM_OK) { if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, opts, 0); jim_getopt_nvp_unknown(goi, opts, 0);
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
LOG_DEBUG("Processing option: %s", n->name); LOG_DEBUG("Processing option: %s", n->name);
switch (n->value) { switch (n->value) {
case NTAP_OPT_ENABLED: case NTAP_OPT_ENABLED:
pTap->disabled_after_reset = false; tap->disabled_after_reset = false;
break; break;
case NTAP_OPT_DISABLED: case NTAP_OPT_DISABLED:
pTap->disabled_after_reset = true; tap->disabled_after_reset = true;
break; break;
case NTAP_OPT_EXPECTED_ID: case NTAP_OPT_EXPECTED_ID:
e = jim_newtap_expected_id(n, goi, pTap); e = jim_newtap_expected_id(n, goi, tap);
if (JIM_OK != e) { if (JIM_OK != e) {
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
break; break;
case NTAP_OPT_IRLEN: case NTAP_OPT_IRLEN:
case NTAP_OPT_IRMASK: case NTAP_OPT_IRMASK:
case NTAP_OPT_IRCAPTURE: case NTAP_OPT_IRCAPTURE:
e = jim_newtap_ir_param(n, goi, pTap); e = jim_newtap_ir_param(n, goi, tap);
if (JIM_OK != e) { if (JIM_OK != e) {
free(cp); free(cp);
free(pTap); free(tap);
return e; return e;
} }
break; break;
case NTAP_OPT_VERSION: case NTAP_OPT_VERSION:
pTap->ignore_version = true; tap->ignore_version = true;
break; break;
} /* switch (n->value) */ } /* switch (n->value) */
} /* while (goi->argc) */ } /* while (goi->argc) */
/* default is enabled-after-reset */ /* default is enabled-after-reset */
pTap->enabled = !pTap->disabled_after_reset; tap->enabled = !tap->disabled_after_reset;
/* Did all the required option bits get cleared? */ /* Did all the required option bits get cleared? */
if (pTap->ir_length != 0) { if (tap->ir_length != 0) {
jtag_tap_init(pTap); jtag_tap_init(tap);
return JIM_OK; return JIM_OK;
} }
Jim_SetResultFormatted(goi->interp, Jim_SetResultFormatted(goi->interp,
"newtap: %s missing IR length", "newtap: %s missing IR length",
pTap->dotted_name); tap->dotted_name);
jtag_tap_free(pTap); jtag_tap_free(tap);
return JIM_ERR; return JIM_ERR;
} }