15 #if PARPORT_USE_PPDEV == 1
16 #include <linux/parport.h>
17 #include <linux/ppdev.h>
18 #include <sys/ioctl.h>
25 #if PARPORT_USE_GIVEIO == 1
51 #if PARPORT_USE_PPDEV == 1
52 static int device_handle;
54 static const int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
62 __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
63 assert(__retval >= 0); \
64 __retval = write(device_handle, &val, 1); \
65 assert(__retval >= 0); \
71 __retval = ioctl(device_handle, PPSETMODE, &addr_mode); \
72 assert(__retval >= 0); \
73 __retval = read(device_handle, &val, 1); \
74 assert(__retval >= 0); \
77 static const int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
83 __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
84 assert(__retval >= 0); \
85 __retval = write(device_handle, &val, 1); \
86 assert(__retval >= 0); \
92 __retval = ioctl(device_handle, PPSETMODE, &data_mode); \
93 assert(__retval >= 0); \
94 __retval = read(device_handle, &val, 1); \
95 assert(__retval >= 0); \
100 #define AMT_AW(val) do { outb(val, amt_jtagaccel_port + 3); } while (0)
101 #define AMT_AR(val) do { val = inb(amt_jtagaccel_port + 3); } while (0)
102 #define AMT_DW(val) do { outb(val, amt_jtagaccel_port + 4); } while (0)
103 #define AMT_DR(val) do { val = inb(amt_jtagaccel_port + 4); } while (0)
117 { {0x1f, 0x00}, {0x0f, 0x00}, {0x05, 0x00}, {0x0a, 0x00}, {0x06, 0x00}, {0x96, 0x00} },
118 { {0x1f, 0x00}, {0x00, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x0b, 0x00} },
119 { {0x1f, 0x00}, {0x0d, 0x00}, {0x00, 0x00}, {0x01, 0x00}, {0x8f, 0x09}, {0x8f, 0x01} },
120 { {0x1f, 0x00}, {0x0c, 0x00}, {0x08, 0x00}, {0x00, 0x00}, {0x8f, 0x09}, {0x8f, 0x01} },
121 { {0x1f, 0x00}, {0x0d, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x00, 0x00}, {0x01, 0x00} },
122 { {0x1f, 0x00}, {0x0c, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x08, 0x00}, {0x00, 0x00} },
165 while (((ar_status) & 0x80) && (
timeout-- > 0))
168 if (ar_status & 0x80) {
170 "amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x",
179 uint8_t aw_scan_tms_5;
188 aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
196 if (tms_scan[0] & 0x80) {
197 aw_scan_tms_5 = 0x40 | (tms_scan[1] & 0x1f);
209 uint8_t aw_scan_tms_5;
210 uint8_t aw_scan_tms_1to4;
220 while (num_cycles - i >= 5) {
221 aw_scan_tms_5 = 0x40;
226 if (num_cycles - i > 0) {
227 aw_scan_tms_1to4 = 0x80 | ((num_cycles - i - 1) & 0x3) << 4;
238 int bits_left = scan_size;
241 uint8_t aw_tdi_option;
262 if ((scan_size - 1) % 8) {
263 aw_tdi_option = 0x30 | (((scan_size - 1) % 8) - 1);
273 dr_tdo = dr_tdo >> (8 - ((scan_size - 1) % 8));
277 bit_count += (scan_size - 1) % 8;
278 bits_left -= (scan_size - 1) % 8;
281 while (bits_left - 1 >= 8) {
300 aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (
buf_get_u32(
buffer, bit_count, 1) << 5);
307 dr_tdo = dr_tdo >> 7;
311 if (tms_scan[0] & 0x80) {
312 aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
337 cmd->cmd.reset->trst,
338 cmd->cmd.reset->srst);
339 if (
cmd->cmd.reset->trst == 1)
345 cmd->cmd.runtest->num_cycles,
346 cmd->cmd.runtest->end_state);
370 LOG_ERROR(
"BUG: unknown JTAG command type encountered");
379 #if PARPORT_USE_GIVEIO == 1
380 int amt_jtagaccel_get_giveio_access(
void)
383 OSVERSIONINFO version;
385 version.dwOSVersionInfoSize =
sizeof(version);
386 if (!GetVersionEx(&version)) {
390 if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
393 h = CreateFile(
"\\\\.\\giveio",
398 FILE_ATTRIBUTE_NORMAL,
400 if (h == INVALID_HANDLE_VALUE) {
413 #if PARPORT_USE_PPDEV == 1
416 uint8_t control_port;
422 #if PARPORT_USE_PPDEV == 1
423 if (device_handle > 0) {
429 device_handle = open(
buffer, O_RDWR);
431 if (device_handle < 0) {
433 "cannot open device. check it exists and that user read and write rights are set");
437 i = ioctl(device_handle, PPCLAIM);
443 i = IEEE1284_MODE_EPP;
444 i = ioctl(device_handle, PPSETMODE, &i);
446 LOG_ERROR(
" cannot set compatible mode to device");
451 i = ioctl(device_handle, PPWCONTROL, &control_port);
454 i = ioctl(device_handle, PPWCONTROL, &control_port);
459 LOG_WARNING(
"No parport port specified, using default '0x378' (LPT1)");
462 #if PARPORT_USE_GIVEIO == 1
463 if (amt_jtagaccel_get_giveio_access() != 0) {
467 LOG_ERROR(
"missing privileges for direct i/o");
505 LOG_DEBUG(
"AR_STATUS: 0x%2.2x", ar_status);
525 LOG_ERROR(
"The parport port was already configured!");
539 "amt_jtagaccel RTCK feature %s",
543 if (strcmp(
CMD_ARGV[0],
"enabled") == 0)
554 .
name =
"parport_port",
555 .handler = &amt_jtagaccel_handle_parport_port_command,
557 .help =
"configure or display the parallel port to use",
558 .usage =
"[port_num]",
568 .handler = &amt_jtagaccel_handle_rtck_command,
570 .help =
"configure or display RTCK support",
571 .usage =
"[enable|disable]",
581 .
name =
"amt_jtagaccel",
const char *const jtag_only[]
int adapter_get_speed(int *speed)
static const struct command_registration amtjtagaccel_command_handlers[]
COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
static int amt_jtagaccel_init(void)
static int amt_jtagaccel_quit(void)
struct adapter_driver amt_jtagaccel_adapter_driver
static uint16_t amt_jtagaccel_port
static int amt_jtagaccel_execute_queue(void)
static void amt_wait_scan_busy(void)
static uint8_t aw_control_fsm
static uint8_t aw_control_baudrate
static const uint8_t amt_jtagaccel_tap_move[6][6][2]
static void amt_jtagaccel_state_move(void)
static int amt_jtagaccel_speed(int speed)
static void amt_jtagaccel_runtest(int num_cycles)
static void amt_jtagaccel_end_state(tap_state_t state)
static struct jtag_interface amt_jtagaccel_interface
static uint8_t aw_control_rst
static void amt_jtagaccel_reset(int trst, int srst)
static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
static void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
struct jtag_command * jtag_command_queue
The current queue of jtag_command_s structures.
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
enum scan_type jtag_scan_type(const struct scan_command *cmd)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
scan_type
The inferred type of a scan_command_s structure, indicating whether the command has the host scan in ...
@ SCAN_IN
From device to host,.
@ SCAN_IO
Full-duplex scan.
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
void tap_set_end_state(tap_state_t new_end_state)
This function sets the state of an "end state follower" which tracks the state that any cable driver ...
tap_state_t tap_get_end_state(void)
For more information,.
int tap_move_ndx(tap_state_t astate)
Function tap_move_ndx when given a stable state, returns an index from 0-5.
tap_state_t tap_get_state(void)
This function gets the state of the "state follower" which tracks the state of the TAPs connected to ...
#define tap_set_state(new_state)
This function sets the state of a "state follower" which tracks the state of the TAPs connected to th...
static enum reset_types jtag_reset_config
void jtag_sleep(uint32_t us)
enum reset_types jtag_get_reset_config(void)
#define ERROR_JTAG_QUEUE_FAILED
#define ERROR_JTAG_INIT_FAILED
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
#define LOG_DEBUG_IO(expr ...)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
Represents a driver for a debugging interface.
int(* execute_queue)(void)
Execute queued commands.