20 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21 #include <machine/sysarch.h>
22 #include <machine/cpufunc.h>
23 #define ioperm(startport, length, enable)\
24 i386_set_ioperm((startport), (length), (enable))
27 #if PARPORT_USE_PPDEV == 1
28 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
29 #include <dev/ppbus/ppi.h>
30 #include <dev/ppbus/ppbconf.h>
31 #define PPRSTATUS PPIGSTATUS
32 #define PPWDATA PPISDATA
34 #include <linux/parport.h>
35 #include <linux/ppdev.h>
37 #include <sys/ioctl.h>
44 #if PARPORT_USE_GIVEIO == 1 && IS_CYGWIN == 1
77 {
"wiggler", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x80, 0x00 },
78 {
"wiggler2", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x00, 0x20 },
79 {
"wiggler_ntrst_inverted", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x11, 0x80, 0x80, 0x80, 0x00 },
80 {
"old_amt_wiggler", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x80, 0x80, 0x80, 0x00 },
81 {
"arm-jtag", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x01, 0x80, 0x80, 0x80, 0x00 },
82 {
"chameleon", 0x80, 0x00, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 },
83 {
"dlc5", 0x10, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00 },
84 {
"triton", 0x80, 0x08, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 },
85 {
"lattice", 0x40, 0x10, 0x04, 0x02, 0x01, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00 },
86 {
"flashlink", 0x20, 0x10, 0x02, 0x01, 0x04, 0x20, 0x30, 0x20, 0x00, 0x00, 0x00 },
95 {
"altium", 0x10, 0x20, 0x04, 0x02, 0x01, 0x80, 0x00, 0x00, 0x10, 0x00, 0x08 },
96 {
"aspo", 0x10, 0x01, 0x04, 0x08, 0x02, 0x10, 0x17, 0x00, 0x17, 0x17, 0x00 },
97 {
NULL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
111 #if PARPORT_USE_PPDEV == 1
112 static int device_handle;
122 #if PARPORT_USE_PPDEV == 1
123 ioctl(device_handle, PPRSTATUS, &data);
139 #if PARPORT_USE_PPDEV == 1
140 ioctl(device_handle, PPWDATA, &
output);
142 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
178 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
228 *khz = (499999 + denominator) / denominator;
232 #if PARPORT_USE_GIVEIO == 1
233 static int parport_get_giveio_access(
void)
236 OSVERSIONINFO version;
238 version.dwOSVersionInfoSize =
sizeof(version);
239 if (!GetVersionEx(&version)) {
243 if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
246 h = CreateFile(
"\\\\.\\giveio", GENERIC_READ, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
247 if (h == INVALID_HANDLE_VALUE) {
266 const struct cable *cur_cable;
267 #if PARPORT_USE_PPDEV == 1
275 LOG_WARNING(
"No parport cable specified, using default 'wiggler'");
278 while (cur_cable->
name) {
293 #if PARPORT_USE_PPDEV == 1
294 if (device_handle > 0) {
299 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
303 device_handle = open(
buffer, O_WRONLY);
308 device_handle = open(
buffer, O_WRONLY);
311 if (device_handle < 0) {
313 LOG_ERROR(
"cannot open device. check it exists and that user read and write rights are set. errno=%d", err);
319 #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
320 int i = ioctl(device_handle, PPCLAIM);
327 i = PARPORT_MODE_COMPAT;
328 i = ioctl(device_handle, PPSETMODE, &i);
330 LOG_ERROR(
" cannot set compatible mode to device");
334 i = IEEE1284_MODE_COMPAT;
335 i = ioctl(device_handle, PPNEGOT, &i);
337 LOG_ERROR(
"cannot set compatible 1284 mode to device");
345 LOG_WARNING(
"No parport port specified, using default '0x378' (LPT1)");
352 #if PARPORT_USE_GIVEIO == 1
353 if (parport_get_giveio_access() != 0) {
357 LOG_ERROR(
"missing privileges for direct i/o");
363 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
406 LOG_ERROR(
"The parport port was already configured!");
451 int retval = parse_u32(
CMD_ARGV[0], &ns);
457 LOG_ERROR(
"0 ns is not a valid parport toggling time");
469 LOG_INFO(
"no parport speed set - defaulting to zero wait states");
483 .handler = parport_handle_port_command,
485 .help =
"Display the address of the I/O port (e.g. 0x378) "
486 "or the number of the '/dev/parport' device used. "
487 "If a parameter is provided, first change that port.",
488 .usage =
"[port_number]",
492 .handler = parport_handle_cable_command,
494 .help =
"Set the layout of the parallel port cable "
495 "used to connect to the target.",
500 .name =
"write_on_exit",
501 .handler = parport_handle_write_on_exit_command,
503 .help =
"Configure the parallel driver to write "
504 "a known value to the parallel interface on exit.",
505 .usage =
"('on'|'off')",
508 .name =
"toggling_time",
509 .handler = parport_handle_toggling_time_command,
511 .help =
"Displays or assigns how many nanoseconds it "
512 "takes for the hardware to toggle TCK.",
513 .usage =
"[nanoseconds]",
522 .help =
"perform parport management",
const char *const jtag_only[]
int adapter_get_speed(int *speed)
int bitbang_execute_queue(struct jtag_command *cmd_queue)
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 COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
#define ERROR_COMMAND_SYNTAX_ERROR
#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.
#define DEBUG_CAP_TMS_SEQ
#define ERROR_JTAG_INIT_FAILED
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static int parport_reset(int trst, int srst)
static const struct cable * cable
static int parport_speed(int speed)
static const struct command_registration parport_command_handlers[]
static uint32_t parport_toggling_time_ns
static int parport_write(int tck, int tms, int tdi)
static const struct cable cables[]
static unsigned long dataport
static bb_value_t parport_read(void)
static uint16_t parport_port
static int parport_quit(void)
static void parport_write_data(void)
static struct jtag_interface parport_interface
static struct bitbang_interface parport_bitbang
static char * parport_cable
static int parport_speed_div(int speed, int *khz)
static const struct command_registration parport_subcommand_handlers[]
static unsigned long statusport
static int parport_khz(int khz, int *jtag_speed)
static uint8_t dataport_value
static int parport_init(void)
COMMAND_HANDLER(parport_handle_port_command)
struct adapter_driver parport_adapter_driver
static int parport_led(bool on)
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
Low level callbacks (for bitbang).
bb_value_t(* read)(void)
Sample TDO and return the value.
const char * usage
a string listing the options and arguments, required or optional
Represents a driver for a debugging interface.
unsigned int supported
Bit vector listing capabilities exposed by this driver.