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
50 #if PARPORT_USE_PPDEV == 0
61 #if PARPORT_USE_PPDEV == 1
62 static int device_handle;
80 #define OUTPUT_BITMASK(gpio_index) BIT((adapter_gpio_config[(gpio_index)].gpio_num - 2))
86 #if PARPORT_USE_PPDEV == 1
87 ioctl(device_handle, PPRSTATUS, &data);
102 #if PARPORT_USE_PPDEV == 1
103 ioctl(device_handle, PPWDATA, &
output);
105 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
142 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
175 LOG_ERROR(
"RCLK is not supported by the adapter");
188 *khz = (499999 + denominator) / denominator;
193 #if PARPORT_USE_GIVEIO == 1
194 static bool parport_get_giveio_access(
void)
196 OSVERSIONINFO version;
198 version.dwOSVersionInfoSize =
sizeof(version);
199 if (!GetVersionEx(&version)) {
204 if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
207 HANDLE h = CreateFile(
"\\\\.\\giveio", GENERIC_READ, 0,
NULL, OPEN_EXISTING,
208 FILE_ATTRIBUTE_NORMAL,
NULL);
210 if (h == INVALID_HANDLE_VALUE) {
227 static const struct {
252 LOG_ERROR(
"The signal '%s' is required and must be configured",
262 LOG_ERROR(
"The '%s' signal pin must be 10, 11, 12, 13, or 15",
268 LOG_ERROR(
"The '%s' signal pin must be 2, 3, 4, 5, 6, 7, 8, or 9",
295 #if PARPORT_USE_PPDEV == 1
296 if (device_handle > 0) {
297 LOG_ERROR(
"Parallel port is already open");
302 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
308 LOG_WARNING(
"DEPRECATED! The lack of a parallel port specification is deprecated and will no longer work in the future");
315 if (device_handle < 0) {
317 LOG_ERROR(
"Failed to open parallel port %s (errno = %d)",
319 LOG_ERROR(
"Check whether the device exists and if you have the required access rights");
323 #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
324 int retval = ioctl(device_handle, PPCLAIM);
331 int value = PARPORT_MODE_COMPAT;
332 retval = ioctl(device_handle, PPSETMODE, &value);
335 LOG_ERROR(
"Cannot set compatible mode to device");
339 value = IEEE1284_MODE_COMPAT;
340 retval = ioctl(device_handle, PPNEGOT, &value);
343 LOG_ERROR(
"Cannot set compatible 1284 mode to device");
349 LOG_WARNING(
"DEPRECATED: Parallel port access with direct I/O is deprecated and support will be removed in the next release");
353 LOG_WARNING(
"No parallel port specified, using default 0x378 (LPT1)");
361 #if PARPORT_USE_GIVEIO == 1
362 if (!parport_get_giveio_access()) {
366 LOG_ERROR(
"Missing privileges for direct I/O");
371 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
435 #if PARPORT_USE_PPDEV == 1
437 LOG_ERROR(
"The parallel port device file is already configured");
446 unsigned long port_number = strtoul(
CMD_ARGV[0], &endptr, 0);
448 if (*endptr ==
'\0' && endptr !=
CMD_ARGV[0]) {
449 LOG_WARNING(
"DEPRECATED! Using a port number is deprecated, use the device file instead");
451 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
494 LOG_WARNING(
"DEPRECATED: 'parport write_on_exit' will be removed in the future, use the 'adapter gpio' command to configure the exit state for pins");
506 uint32_t toggling_time;
510 if (!toggling_time) {
524 LOG_INFO(
"No parallel port speed set, using zero wait states");
534 .handler = parport_handle_port_command,
536 .help =
"Specify the device file of the parallel port",
541 .handler = parport_handle_cable_command,
543 .help =
"Set the layout of the parallel port cable "
544 "used to connect to the target",
548 .name =
"write_on_exit",
549 .handler = parport_handle_write_on_exit_command,
551 .help =
"Configure the driver to write a value to the parallel port on shutdown",
552 .usage =
"('on'|'off')",
555 .name =
"toggling_time",
556 .handler = parport_handle_toggling_time_command,
558 .help =
"Configure how many nanoseconds it takes for the hardware to toggle TCK",
568 .help =
"perform parport management",
const struct adapter_gpio_config * adapter_gpio_get_config(void)
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
int adapter_get_speed(int *speed)
const char * adapter_gpio_get_name(enum adapter_gpio_config_index idx)
Retrieves gpio name.
@ ADAPTER_GPIO_INIT_STATE_ACTIVE
@ ADAPTER_GPIO_INIT_STATE_INACTIVE
@ ADAPTER_GPIO_EXIT_STATE_ACTIVE
@ ADAPTER_GPIO_EXIT_STATE_INACTIVE
adapter_gpio_config_index
Adapter GPIO.
#define ADAPTER_GPIO_NOT_SET
int bitbang_execute_queue(struct jtag_command *cmd_queue)
void command_print(struct command_invocation *cmd, const char *format,...)
int command_run_linef(struct command_context *context, 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 CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
#define DEBUG_CAP_TMS_SEQ
#define ERROR_JTAG_INIT_FAILED
char * alloc_printf(const char *format,...)
#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 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)
#define OUTPUT_BITMASK(gpio_index)
static void set_pin_state(enum adapter_gpio_config_index gpio_index, bool state)
static unsigned long dataport
static uint16_t parport_port
static char * parport_device_file
static const struct bitbang_interface parport_bitbang
static int parport_quit(void)
static bool parport_write_exit_state
static void parport_write_data(void)
static struct jtag_interface parport_interface
static int parport_speed_div(int speed, int *khz)
enum adapter_gpio_config_index gpio_index
static const struct adapter_gpio_config * adapter_gpio_config
static const struct command_registration parport_subcommand_handlers[]
static unsigned long statusport
static bool is_gpio_configured(enum adapter_gpio_config_index gpio_index)
static int parport_khz(int khz, int *jtag_speed)
static struct @31 input_pin_bitmask_map[]
static uint8_t dataport_value
static const struct @32 all_signals[]
static int parport_init(void)
static enum bb_value parport_read(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.
Configuration options for a single GPIO.
enum adapter_gpio_exit_state exit_state
enum adapter_gpio_init_state init_state
Low level callbacks (for bitbang).
enum bb_value(* 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.
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.