1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include "replacements.h"
33 #include <sys/types.h>
34 #include <machine/sysarch.h>
35 #include <machine/cpufunc.h>
36 #define ioperm(startport,length,enable)\
37 i386_set_ioperm((startport), (length), (enable))
47 #endif /* __FreeBSD__ */
53 #if PARPORT_USE_PPDEV == 1
54 #include <linux/parport.h>
55 #include <linux/ppdev.h>
57 #include <sys/ioctl.h>
60 #if PARPORT_USE_GIVEIO == 1
70 /* parallel port cable description
72 typedef struct cable_s
75 u8 TDO_MASK
; /* status port bit containing current TDO value */
76 u8 TRST_MASK
; /* data port bit for TRST */
77 u8 TMS_MASK
; /* data port bit for TMS */
78 u8 TCK_MASK
; /* data port bit for TCK */
79 u8 TDI_MASK
; /* data port bit for TDI */
80 u8 SRST_MASK
; /* data port bit for SRST */
81 u8 OUTPUT_INVERT
; /* data port bits that should be inverted */
82 u8 INPUT_INVERT
; /* status port that should be inverted */
83 u8 PORT_INIT
; /* initialize data port with this value */
88 /* name tdo trst tms tck tdi srst o_inv i_inv init */
89 { "wiggler", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80 },
90 { "old_amt_wiggler", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x80, 0x80 },
91 { "chameleon", 0x80, 0x00, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00 },
92 { "dlc5", 0x10, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x10 },
93 { "triton", 0x80, 0x08, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00 },
94 { NULL
, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
99 unsigned long parport_port
;
101 /* interface variables
103 static cable_t
* cable
;
104 static u8 dataport_value
= 0x0;
106 #if PARPORT_USE_PPDEV == 1
107 static int device_handle
;
109 static unsigned long dataport
;
110 static unsigned long statusport
;
113 /* low level command set
115 int parport_read(void);
116 void parport_write(int tck
, int tms
, int tdi
);
117 void parport_reset(int trst
, int srst
);
119 int parport_speed(int speed
);
120 int parport_register_commands(struct command_context_s
*cmd_ctx
);
121 int parport_init(void);
122 int parport_quit(void);
124 /* interface commands */
125 int parport_handle_parport_port_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
126 int parport_handle_parport_cable_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
128 jtag_interface_t parport_interface
=
132 .execute_queue
= bitbang_execute_queue
,
134 .support_statemove
= 0,
136 .speed
= parport_speed
,
137 .register_commands
= parport_register_commands
,
138 .init
= parport_init
,
139 .quit
= parport_quit
,
142 bitbang_interface_t parport_bitbang
=
144 .read
= parport_read
,
145 .write
= parport_write
,
146 .reset
= parport_reset
149 int parport_read(void)
153 #if PARPORT_USE_PPDEV == 1
154 ioctl(device_handle
, PPRSTATUS
, & data
);
156 data
= inb(statusport
);
159 if ((data
^ cable
->INPUT_INVERT
) & cable
->TDO_MASK
)
165 void parport_write(int tck
, int tms
, int tdi
)
168 int i
= jtag_speed
+ 1;
171 dataport_value
|= cable
->TCK_MASK
;
173 dataport_value
&= ~cable
->TCK_MASK
;
176 dataport_value
|= cable
->TMS_MASK
;
178 dataport_value
&= ~cable
->TMS_MASK
;
181 dataport_value
|= cable
->TDI_MASK
;
183 dataport_value
&= ~cable
->TDI_MASK
;
185 output
= dataport_value
^ cable
->OUTPUT_INVERT
;
188 #if PARPORT_USE_PPDEV == 1
189 ioctl(device_handle
, PPWDATA
, &output
);
192 outb(dataport
, output
);
194 outb(output
, dataport
);
199 /* (1) assert or (0) deassert reset lines */
200 void parport_reset(int trst
, int srst
)
203 DEBUG("trst: %i, srst: %i", trst
, srst
);
206 dataport_value
|= cable
->TRST_MASK
;
208 dataport_value
&= ~cable
->TRST_MASK
;
211 dataport_value
|= cable
->SRST_MASK
;
213 dataport_value
&= ~cable
->SRST_MASK
;
215 output
= dataport_value
^ cable
->OUTPUT_INVERT
;
217 #if PARPORT_USE_PPDEV == 1
218 ioctl(device_handle
, PPWDATA
, &output
);
221 outb(dataport
, output
);
223 outb(output
, dataport
);
229 int parport_speed(int speed
)
236 int parport_register_commands(struct command_context_s
*cmd_ctx
)
238 register_command(cmd_ctx
, NULL
, "parport_port", parport_handle_parport_port_command
,
239 COMMAND_CONFIG
, NULL
);
240 register_command(cmd_ctx
, NULL
, "parport_cable", parport_handle_parport_cable_command
,
241 COMMAND_CONFIG
, NULL
);
246 #if PARPORT_USE_GIVEIO == 1
247 int parport_get_giveio_access()
250 OSVERSIONINFO version
;
252 version
.dwOSVersionInfoSize
= sizeof version
;
253 if (!GetVersionEx( &version
)) {
257 if (version
.dwPlatformId
!= VER_PLATFORM_WIN32_NT
)
260 h
= CreateFile( "\\\\.\\giveio", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
261 if (h
== INVALID_HANDLE_VALUE
) {
272 int parport_init(void)
275 #if PARPORT_USE_PPDEV == 1
282 if ((parport_cable
== NULL
) || (parport_cable
[0] == 0))
284 parport_cable
= "wiggler";
285 WARNING("No parport cable specified, using default 'wiggler'");
288 while (cur_cable
->name
)
290 if (strcmp(cur_cable
->name
, parport_cable
) == 0)
300 ERROR("No matching cable found for %s", parport_cable
);
301 return ERROR_JTAG_INIT_FAILED
;
304 dataport_value
= cable
->PORT_INIT
;
306 #if PARPORT_USE_PPDEV == 1
309 ERROR("device is already opened");
310 return ERROR_JTAG_INIT_FAILED
;
313 snprintf(buffer
, 256, "/dev/parport%d", parport_port
);
314 device_handle
= open(buffer
, O_WRONLY
);
318 ERROR("cannot open device. check it exists and that user read and write rights are set");
319 return ERROR_JTAG_INIT_FAILED
;
322 i
=ioctl(device_handle
, PPCLAIM
);
325 ERROR("cannot claim device");
326 return ERROR_JTAG_INIT_FAILED
;
329 i
= PARPORT_MODE_COMPAT
;
330 i
= ioctl(device_handle
, PPSETMODE
, & i
);
333 ERROR(" cannot set compatible mode to device");
334 return ERROR_JTAG_INIT_FAILED
;
337 i
= IEEE1284_MODE_COMPAT
;
338 i
= ioctl(device_handle
, PPNEGOT
, & i
);
341 ERROR("cannot set compatible 1284 mode to device");
342 return ERROR_JTAG_INIT_FAILED
;
345 if (parport_port
== 0)
347 parport_port
= 0x378;
348 WARNING("No parport port specified, using default '0x378' (LPT1)");
351 dataport
= parport_port
;
352 statusport
= parport_port
+ 1;
354 #if PARPORT_USE_GIVEIO == 1
355 if (parport_get_giveio_access() != 0)
356 #else /* PARPORT_USE_GIVEIO */
357 if (ioperm(dataport
, 3, 1) != 0)
358 #endif /* PARPORT_USE_GIVEIO */
360 ERROR("missing privileges for direct i/o");
361 return ERROR_JTAG_INIT_FAILED
;
363 #endif /* PARPORT_USE_PPDEV */
366 parport_write(0, 0, 0);
368 bitbang_interface
= &parport_bitbang
;
373 int parport_quit(void)
379 int parport_handle_parport_port_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
384 /* only if the port wasn't overwritten by cmdline */
385 if (parport_port
== 0)
386 parport_port
= strtoul(args
[0], NULL
, 0);
391 int parport_handle_parport_cable_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
396 /* only if the cable name wasn't overwritten by cmdline */
397 if (parport_cable
== 0)
399 parport_cable
= malloc(strlen(args
[0]) + sizeof(char));
400 strcpy(parport_cable
, args
[0]);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)