X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Famt_jtagaccel.c;h=500f1797d66a423816048229f5f80630f2a989e3;hb=3fe23f94fb71d838eb86dd7bdeb9e67216b6e801;hp=113aee664ada372eb13a2b9249e736829df76eaf;hpb=82d2633b5f550115e9e7c7d0520babb6680aa38f;p=openocd.git diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c index 113aee664a..500f1797d6 100644 --- a/src/jtag/amt_jtagaccel.c +++ b/src/jtag/amt_jtagaccel.c @@ -21,11 +21,16 @@ #include "config.h" #endif -#include "log.h" +#include "replacements.h" + #include "jtag.h" /* system includes */ -#include + +#ifdef _WIN32 +#include "errno.h" +#endif /* _WIN32 */ + #include #include @@ -38,8 +43,22 @@ #include #include #include +#else /* not PARPORT_USE_PPDEV */ +#ifndef _WIN32 +#include +#endif #endif +#if PARPORT_USE_GIVEIO == 1 +#if IS_CYGWIN == 1 +#include +#include +#undef ERROR +#endif +#endif + +#include "log.h" + /* configuration */ unsigned long amt_jtagaccel_port; @@ -100,8 +119,6 @@ jtag_interface_t amt_jtagaccel_interface = .execute_queue = amt_jtagaccel_execute_queue, - .support_statemove = 0, - .speed = amt_jtagaccel_speed, .register_commands = amt_jtagaccel_register_commands, .init = amt_jtagaccel_init, @@ -164,7 +181,7 @@ void amt_wait_scan_busy() if (ar_status & 0x80) { - ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s", (rtck_enabled) ? "enabled" : "disabled"); + ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x", (rtck_enabled) ? "enabled" : "disabled", ar_status); exit(-1); } } @@ -314,6 +331,12 @@ int amt_jtagaccel_execute_queue(void) int scan_size; enum scan_type type; u8 *buffer; + int retval; + + /* return ERROR_OK, unless a jtag_read_buffer returns a failed check + * that wasn't handled by a caller-provided error handler + */ + retval = ERROR_OK; while (cmd) { @@ -362,13 +385,13 @@ int amt_jtagaccel_execute_queue(void) type = jtag_scan_type(cmd->cmd.scan); amt_jtagaccel_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) - return ERROR_JTAG_QUEUE_FAILED; + retval = ERROR_JTAG_QUEUE_FAILED; if (buffer) free(buffer); break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ - DEBUG("sleep", cmd->cmd.sleep->us); + DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; @@ -379,9 +402,35 @@ int amt_jtagaccel_execute_queue(void) cmd = cmd->next; } - return ERROR_OK; + return retval; } +#if PARPORT_USE_GIVEIO == 1 +int amt_jtagaccel_get_giveio_access() +{ + HANDLE h; + OSVERSIONINFO version; + + version.dwOSVersionInfoSize = sizeof version; + if (!GetVersionEx( &version )) { + errno = EINVAL; + return -1; + } + if (version.dwPlatformId != VER_PLATFORM_WIN32_NT) + return 0; + + h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + if (h == INVALID_HANDLE_VALUE) { + errno = ENODEV; + return -1; + } + + CloseHandle( h ); + + return 0; +} +#endif + int amt_jtagaccel_init(void) { #if PARPORT_USE_PPDEV == 1 @@ -391,7 +440,8 @@ int amt_jtagaccel_init(void) #else u8 status_port; #endif - + u8 ar_status; + #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { @@ -435,8 +485,12 @@ int amt_jtagaccel_init(void) amt_jtagaccel_port = 0x378; WARNING("No parport port specified, using default '0x378' (LPT1)"); } - + +#if PARPORT_USE_GIVEIO == 1 + if (amt_jtagaccel_get_giveio_access() != 0) { +#else /* PARPORT_USE_GIVEIO */ if (ioperm(amt_jtagaccel_port, 5, 1) != 0) { +#endif /* PARPORT_USE_GIVEIO */ ERROR("missing privileges for direct i/o"); return ERROR_JTAG_INIT_FAILED; } @@ -451,6 +505,12 @@ int amt_jtagaccel_init(void) outb(0x04, amt_jtagaccel_port + 2); #endif + if (rtck_enabled) + { + /* set RTCK enable bit */ + aw_control_fsm |= 0x02; + } + /* enable JTAG port */ aw_control_fsm |= 0x04; AMT_AW(aw_control_fsm); @@ -469,6 +529,10 @@ int amt_jtagaccel_init(void) amt_jtagaccel_reset(0, 0); + /* read status register */ + AMT_AR(ar_status); + DEBUG("AR_STATUS: 0x%2.2x", ar_status); + return ERROR_OK; } @@ -502,10 +566,10 @@ int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *c if (strcmp(args[0], "enabled") == 0) { rtck_enabled = 1; - - /* set RTCK enable bit */ - aw_control_fsm |= 0x02; - AMT_AW(aw_control_fsm); + } + else + { + rtck_enabled = 0; } }