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
67 {
"wiggler", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x80, 0x00 },
68 {
"wiggler2", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x00, 0x20 },
69 {
"wiggler_ntrst_inverted", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x11, 0x80, 0x80, 0x80, 0x00 },
70 {
"old_amt_wiggler", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x80, 0x80, 0x80, 0x00 },
71 {
"arm-jtag", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x01, 0x80, 0x80, 0x80, 0x00 },
72 {
"chameleon", 0x80, 0x00, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 },
73 {
"dlc5", 0x10, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00 },
74 {
"triton", 0x80, 0x08, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 },
75 {
"lattice", 0x40, 0x10, 0x04, 0x02, 0x01, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00 },
76 {
"flashlink", 0x20, 0x10, 0x02, 0x01, 0x04, 0x20, 0x30, 0x20, 0x00, 0x00, 0x00 },
85 {
"altium", 0x10, 0x20, 0x04, 0x02, 0x01, 0x80, 0x00, 0x00, 0x10, 0x00, 0x08 },
86 {
"aspo", 0x10, 0x01, 0x04, 0x08, 0x02, 0x10, 0x17, 0x00, 0x17, 0x17, 0x00 },
87 {
NULL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
102 #if PARPORT_USE_PPDEV == 1
103 static int device_handle;
113 #if PARPORT_USE_PPDEV == 1
114 ioctl(device_handle, PPRSTATUS, &data);
130 #if PARPORT_USE_PPDEV == 1
131 ioctl(device_handle, PPWDATA, &
output);
133 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
169 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
220 *khz = (499999 + denominator) / denominator;
224 #if PARPORT_USE_GIVEIO == 1
225 static int parport_get_giveio_access(
void)
228 OSVERSIONINFO version;
230 version.dwOSVersionInfoSize =
sizeof(version);
231 if (!GetVersionEx(&version)) {
235 if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
238 h = CreateFile(
"\\\\.\\giveio", GENERIC_READ, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
239 if (h == INVALID_HANDLE_VALUE) {
258 const struct cable *cur_cable;
259 #if PARPORT_USE_PPDEV == 1
267 LOG_WARNING(
"No parport cable specified, using default 'wiggler'");
270 while (cur_cable->
name) {
285 #if PARPORT_USE_PPDEV == 1
286 if (device_handle > 0) {
291 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
295 device_handle = open(
buffer, O_WRONLY);
300 device_handle = open(
buffer, O_WRONLY);
303 if (device_handle < 0) {
305 LOG_ERROR(
"cannot open device. check it exists and that user read and write rights are set. errno=%d", err);
311 #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
312 int i = ioctl(device_handle, PPCLAIM);
319 i = PARPORT_MODE_COMPAT;
320 i = ioctl(device_handle, PPSETMODE, &i);
322 LOG_ERROR(
" cannot set compatible mode to device");
326 i = IEEE1284_MODE_COMPAT;
327 i = ioctl(device_handle, PPNEGOT, &i);
329 LOG_ERROR(
"cannot set compatible 1284 mode to device");
337 LOG_WARNING(
"No parport port specified, using default '0x378' (LPT1)");
344 #if PARPORT_USE_GIVEIO == 1
345 if (parport_get_giveio_access() != 0) {
349 LOG_ERROR(
"missing privileges for direct i/o");
355 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
398 LOG_ERROR(
"The parport port was already configured!");
439 int retval = parse_u32(
CMD_ARGV[0], &ns);
445 LOG_ERROR(
"0 ns is not a valid parport toggling time");
455 LOG_INFO(
"no parport speed set - defaulting to zero wait states");
469 .handler = parport_handle_parport_port_command,
471 .help =
"Display the address of the I/O port (e.g. 0x378) "
472 "or the number of the '/dev/parport' device used. "
473 "If a parameter is provided, first change that port.",
474 .usage =
"[port_number]",
478 .handler = parport_handle_parport_cable_command,
480 .help =
"Set the layout of the parallel port cable "
481 "used to connect to the target.",
486 .name =
"write_on_exit",
487 .handler = parport_handle_write_on_exit_command,
489 .help =
"Configure the parallel driver to write "
490 "a known value to the parallel interface on exit.",
491 .usage =
"('on'|'off')",
494 .name =
"toggling_time",
495 .handler = parport_handle_parport_toggling_time_command,
497 .help =
"Displays or assigns how many nanoseconds it "
498 "takes for the hardware to toggle TCK.",
499 .usage =
"[nanoseconds]",
508 .help =
"perform parport management",
const char *const jtag_only[]
int adapter_get_speed(int *speed)
int bitbang_execute_queue(void)
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 int parport_led(int on)
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)
COMMAND_HANDLER(parport_handle_parport_port_command)
static uint8_t dataport_value
static int parport_init(void)
struct adapter_driver parport_adapter_driver
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 supported
Bit vector listing capabilities exposed by this driver.