16 #define _DEBUG_GW16012_IO_
21 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
23 #include <machine/sysarch.h>
24 #include <machine/cpufunc.h>
25 #define ioperm(startport, length, enable) \
26 386_set_ioperm((startport), (length), (enable))
32 #if PARPORT_USE_PPDEV == 1
33 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
34 #include <dev/ppbus/ppi.h>
35 #include <dev/ppbus/ppbconf.h>
36 #define PPRSTATUS PPIGSTATUS
37 #define PPWDATA PPISDATA
39 #include <linux/parport.h>
40 #include <linux/ppdev.h>
43 #include <sys/ioctl.h>
50 #if PARPORT_USE_GIVEIO == 1 && IS_CYGWIN == 1
62 #if PARPORT_USE_PPDEV == 1
63 static int device_handle;
71 #ifdef _DEBUG_GW16012_IO_
75 #if PARPORT_USE_PPDEV == 1
76 ioctl(device_handle, PPWDATA, &value);
78 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
91 #ifdef _DEBUG_GW16012_IO_
95 #if PARPORT_USE_PPDEV == 1
98 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
109 #if PARPORT_USE_PPDEV == 1
110 ioctl(device_handle, PPRSTATUS, value);
115 #ifdef _DEBUG_GW16012_IO_
123 LOG_DEBUG(
"trst: %i, srst: %i", trst, srst);
154 for (i = 0; i < tms_count; i++) {
155 tms = (tms_scan >> i) & 1;
164 int num_states =
cmd->num_states;
175 LOG_ERROR(
"BUG: %s -> %s isn't a valid TAP transition",
199 for (i = 0; i < num_cycles; i++) {
211 int bits_left = scan_size;
214 uint8_t scan_out, scan_in;
237 while (bits_left-- > 0) {
242 if (bits_left == 0) {
290 if (
cmd->cmd.reset->trst == 1)
295 LOG_DEBUG_IO(
"runtest %i cycles, end in %i",
cmd->cmd.runtest->num_cycles,
296 cmd->cmd.runtest->end_state);
306 LOG_DEBUG_IO(
"pathmove: %i states, end in %i",
cmd->cmd.pathmove->num_states,
307 cmd->cmd.pathmove->path[
cmd->cmd.pathmove->num_states - 1]);
314 LOG_DEBUG_IO(
"%s scan (%i) %i bit end in %i", (
cmd->cmd.scan->ir_scan) ?
"ir" :
"dr",
315 type, scan_size,
cmd->cmd.scan->end_state);
326 LOG_ERROR(
"BUG: unknown JTAG command type encountered");
335 #if PARPORT_USE_GIVEIO == 1
336 static int gw16012_get_giveio_access(
void)
339 OSVERSIONINFO version;
341 version.dwOSVersionInfoSize =
sizeof(version);
342 if (!GetVersionEx(&version)) {
346 if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
349 h = CreateFile(
"\\\\.\\giveio", GENERIC_READ, 0,
NULL, OPEN_EXISTING,
350 FILE_ATTRIBUTE_NORMAL,
NULL);
351 if (h == INVALID_HANDLE_VALUE) {
362 #if PARPORT_USE_PPDEV == 1
364 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
366 #define GW16012_PPDEV_NAME "ppi"
368 static int gw16012_init_ioctls(
void)
371 temp = ioctl(device_handle, PPCLAIM);
377 temp = PARPORT_MODE_COMPAT;
378 temp = ioctl(device_handle, PPSETMODE, &temp);
380 LOG_ERROR(
" cannot set compatible mode to device");
384 temp = IEEE1284_MODE_COMPAT;
385 temp = ioctl(device_handle, PPNEGOT, &temp);
387 LOG_ERROR(
"cannot set compatible 1284 mode to device");
394 #define GW16012_PPDEV_NAME "parport"
396 static int gw16012_init_ioctls(
void)
405 const char *device_name = GW16012_PPDEV_NAME;
408 if (device_handle > 0) {
416 device_handle = open(
buffer, O_WRONLY);
417 if (device_handle < 0) {
418 LOG_ERROR(
"cannot open device. check it exists and that user read and write rights are set");
424 if (gw16012_init_ioctls() !=
ERROR_OK)
436 LOG_WARNING(
"No gw16012 port specified, using default '0x378' (LPT1)");
440 #if PARPORT_USE_GIVEIO == 1
441 if (gw16012_get_giveio_access() != 0) {
445 LOG_ERROR(
"missing privileges for direct i/o");
451 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
489 LOG_ERROR(
"The parport port was already configured!");
501 .
name =
"parport_port",
502 .handler = gw16012_handle_parport_port_command,
504 .help =
"Display the address of the I/O port (e.g. 0x378) "
505 "or the number of the '/dev/parport' device used. "
506 "If a parameter is provided, first change that port.",
507 .usage =
"[port_number]",
const char *const jtag_only[]
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_OUT
From host to device,.
static int gw16012_init(void)
static void gw16012_runtest(int num_cycles)
static void gw16012_data(uint8_t value)
static void gw16012_control(uint8_t value)
static uint8_t gw16012_msb
static const struct command_registration gw16012_command_handlers[]
static void gw16012_reset(int trst, int srst)
static void gw16012_end_state(tap_state_t state)
static void gw16012_input(uint8_t *value)
static int gw16012_quit(void)
COMMAND_HANDLER(gw16012_handle_parport_port_command)
static int gw16012_execute_queue(void)
static uint16_t gw16012_port
struct adapter_driver gw16012_adapter_driver
static int gw16012_init_device(void)
static struct jtag_interface gw16012_interface
static void gw16012_path_move(struct pathmove_command *cmd)
static void gw16012_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size)
static void gw16012_state_move(void)
static uint8_t gw16012_control_value
bool tap_is_state_stable(tap_state_t astate)
Function tap_is_state_stable returns true if the astate is stable.
tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
Function tap_state_transition takes a current TAP state and returns the next state according to the t...
const char * tap_state_name(tap_state_t state)
Function tap_state_name Returns a string suitable for display representing the JTAG tap_state.
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_get_tms_path(tap_state_t from, tap_state_t to)
This function provides a "bit sequence" indicating what has to be done with TMS during a sequence of ...
int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
Function int tap_get_tms_path_len returns the total number of bits that represents a TMS path transit...
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...
void jtag_sleep(uint32_t us)
#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.