X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Fparport.c;h=175a3c940feb9f1ead30d57953eea8236a59aa88;hb=67caf323f74937e11c0f5f95c2ee57d2786ac02b;hp=e56d65c6eede87fcea3ca2ded28b843b1f7902c8;hpb=26470de0e05ebb01efe71157cd69703fe3348561;p=openocd.git diff --git a/src/jtag/parport.c b/src/jtag/parport.c index e56d65c6ee..175a3c940f 100644 --- a/src/jtag/parport.c +++ b/src/jtag/parport.c @@ -2,6 +2,9 @@ * Copyright (C) 2005 by Dominic Rath * * Dominic.Rath@gmx.de * * * + * Copyright (C) 2008 by Spencer Oliver * + * spen@spen-soft.co.uk * + * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * @@ -21,33 +24,18 @@ #include "config.h" #endif -#include "replacements.h" - -#include "jtag.h" +#define INCLUDE_JTAG_INTERFACE_H +#include "interface.h" #include "bitbang.h" -/* system includes */ /* -ino: 060521-1036 */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - -#include #include #include #define ioperm(startport,length,enable)\ i386_set_ioperm((startport), (length), (enable)) - -#else - -#ifdef _WIN32 -#include "errno.h" -#endif /* _WIN32 */ - #endif /* __FreeBSD__ */ -#include -#include -#include - #if PARPORT_USE_PPDEV == 1 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include @@ -58,7 +46,6 @@ #include #include #endif -#include #include #else /* not PARPORT_USE_PPDEV */ #ifndef _WIN32 @@ -66,14 +53,10 @@ #endif #endif -#if PARPORT_USE_GIVEIO == 1 -#if IS_CYGWIN == 1 +#if PARPORT_USE_GIVEIO == 1 && IS_CYGWIN == 1 #include -#include -#endif #endif -#include "log.h" /* parallel port cable description */ @@ -93,7 +76,7 @@ typedef struct cable_s u8 LED_MASK; /* data port bit for LED */ } cable_t; -cable_t cables[] = +static cable_t cables[] = { /* name tdo trst tms tck tdi srst o_inv i_inv init exit led */ { "wiggler", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x80, 0x00 }, @@ -101,6 +84,7 @@ cable_t cables[] = { "wiggler_ntrst_inverted", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x11, 0x80, 0x80, 0x80, 0x00 }, { "old_amt_wiggler", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x80, 0x80, 0x80, 0x00 }, + { "arm-jtag", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x01, 0x80, 0x80, 0x80, 0x00 }, { "chameleon", 0x80, 0x00, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, { "dlc5", 0x10, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00 }, { "triton", 0x80, 0x08, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, @@ -119,8 +103,8 @@ cable_t cables[] = }; /* configuration */ -char* parport_cable = NULL; -u16 parport_port; +static char* parport_cable = NULL; +static u16 parport_port; static int parport_exit = 0; /* interface variables @@ -137,20 +121,20 @@ static unsigned long statusport; /* low level command set */ -int parport_read(void); -void parport_write(int tck, int tms, int tdi); -void parport_reset(int trst, int srst); -void parport_led(int on); +static int parport_read(void); +static void parport_write(int tck, int tms, int tdi); +static void parport_reset(int trst, int srst); +static void parport_led(int on); -int parport_speed(int speed); -int parport_register_commands(struct command_context_s *cmd_ctx); -int parport_init(void); -int parport_quit(void); +static int parport_speed(int speed); +static int parport_register_commands(struct command_context_s *cmd_ctx); +static int parport_init(void); +static int parport_quit(void); /* interface commands */ -int parport_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int parport_handle_parport_cable_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int parport_handle_write_on_exit_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int parport_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int parport_handle_parport_cable_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int parport_handle_write_on_exit_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); jtag_interface_t parport_interface = { @@ -164,7 +148,7 @@ jtag_interface_t parport_interface = .quit = parport_quit, }; -bitbang_interface_t parport_bitbang = +static bitbang_interface_t parport_bitbang = { .read = parport_read, .write = parport_write, @@ -172,7 +156,7 @@ bitbang_interface_t parport_bitbang = .blink = parport_led }; -int parport_read(void) +static int parport_read(void) { int data = 0; @@ -204,7 +188,7 @@ static __inline__ void parport_write_data(void) #endif } -void parport_write(int tck, int tms, int tdi) +static void parport_write(int tck, int tms, int tdi) { int i = jtag_speed + 1; @@ -228,7 +212,7 @@ void parport_write(int tck, int tms, int tdi) } /* (1) assert or (0) deassert reset lines */ -void parport_reset(int trst, int srst) +static void parport_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); @@ -246,7 +230,7 @@ void parport_reset(int trst, int srst) } /* turn LED on parport adapter on (1) or off (0) */ -void parport_led(int on) +static void parport_led(int on) { if (on) dataport_value |= cable->LED_MASK; @@ -256,50 +240,50 @@ void parport_led(int on) parport_write_data(); } -int parport_speed(int speed) +static int parport_speed(int speed) { return ERROR_OK; } -int parport_register_commands(struct command_context_s *cmd_ctx) +static int parport_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "parport_port", parport_handle_parport_port_command, - COMMAND_CONFIG, NULL); + COMMAND_CONFIG, "either the address of the I/O port or the number of the ‘/dev/parport’ device"); register_command(cmd_ctx, NULL, "parport_cable", parport_handle_parport_cable_command, - COMMAND_CONFIG, NULL); + COMMAND_CONFIG, "the layout of the parallel port cable used to connect to the target"); register_command(cmd_ctx, NULL, "parport_write_on_exit", parport_handle_write_on_exit_command, - COMMAND_CONFIG, NULL); + COMMAND_CONFIG, "configure the parallel driver to write a known value to the parallel interface"); return ERROR_OK; } #if PARPORT_USE_GIVEIO == 1 -int parport_get_giveio_access() +static int parport_get_giveio_access(void) { - HANDLE h; - OSVERSIONINFO version; - - version.dwOSVersionInfoSize = sizeof version; - if (!GetVersionEx( &version )) { - errno = EINVAL; - return -1; - } - if (version.dwPlatformId != VER_PLATFORM_WIN32_NT) - return 0; - - h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - if (h == INVALID_HANDLE_VALUE) { - errno = ENODEV; - return -1; - } - - CloseHandle( h ); - - return 0; + HANDLE h; + OSVERSIONINFO version; + + version.dwOSVersionInfoSize = sizeof version; + if (!GetVersionEx( &version )) { + errno = EINVAL; + return -1; + } + if (version.dwPlatformId != VER_PLATFORM_WIN32_NT) + return 0; + + h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + if (h == INVALID_HANDLE_VALUE) { + errno = ENODEV; + return -1; + } + + CloseHandle( h ); + + return 0; } #endif -int parport_init(void) +static int parport_init(void) { cable_t *cur_cable; #if PARPORT_USE_PPDEV == 1 @@ -425,7 +409,7 @@ int parport_init(void) return ERROR_OK; } -int parport_quit(void) +static int parport_quit(void) { parport_led(0); @@ -444,7 +428,7 @@ int parport_quit(void) return ERROR_OK; } -int parport_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int parport_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) return ERROR_OK; @@ -456,7 +440,7 @@ int parport_handle_parport_port_command(struct command_context_s *cmd_ctx, char return ERROR_OK; } -int parport_handle_parport_cable_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int parport_handle_parport_cable_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) return ERROR_OK; @@ -471,7 +455,7 @@ int parport_handle_parport_cable_command(struct command_context_s *cmd_ctx, char return ERROR_OK; } -int parport_handle_write_on_exit_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int parport_handle_write_on_exit_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc != 1) {