[BACK]Return to patch-src_jtag_parport_c CVS log [TXT][DIR] Up to [local] / ports / devel / openocd / patches

Annotation of ports/devel/openocd/patches/patch-src_jtag_parport_c, Revision 1.1.1.1

1.1       yason       1: $OpenBSD$
                      2: --- src/jtag/parport.c.orig    Fri Jan 16 10:02:25 2009
                      3: +++ src/jtag/parport.c Wed May 27 11:43:45 2009
                      4: @@ -31,7 +31,7 @@
                      5:
                      6:  /* system includes */
                      7:  /* -ino: 060521-1036 */
                      8: -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
                      9: +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
                     10:
                     11:  #include <sys/types.h>
                     12:  #include <machine/sysarch.h>
                     13: @@ -45,29 +45,32 @@
                     14:  #include "errno.h"
                     15:  #endif /* _WIN32 */
                     16:
                     17: -#endif /* __FreeBSD__ */
                     18: +#endif /* __FreeBSD__ || __OpenBSD__ */
                     19:
                     20:  #include <string.h>
                     21:  #include <stdlib.h>
                     22:  #include <stdio.h>
                     23:
                     24:  #if PARPORT_USE_PPDEV == 1
                     25: +#ifdef __OpenBSD__
                     26: +#error "OpenBSD doesn't have ppdev. Please compile with direct i/o instead."
                     27: +#endif /* __OpenBSD__ */
                     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
                     33: -#else
                     34: +#else /* not __FreeBSD__ */
                     35:  #include <linux/parport.h>
                     36:  #include <linux/ppdev.h>
                     37:  #endif
                     38:  #include <fcntl.h>
                     39:  #include <sys/ioctl.h>
                     40:  #else /* not PARPORT_USE_PPDEV */
                     41: -#ifndef _WIN32
                     42: +#if !defined(_WIN32) && !defined(__OpenBSD__)
                     43:  #include <sys/io.h>
                     44: +#endif /* ! _WIN32 && !__OpenBSD__ */
                     45:  #endif
                     46: -#endif
                     47:
                     48:  #if PARPORT_USE_GIVEIO == 1
                     49:  #if IS_CYGWIN == 1
                     50: @@ -76,6 +79,10 @@
                     51:  #endif
                     52:  #endif
                     53:
                     54: +#ifdef __OpenBSD__
                     55: +#include <i386/pio.h>  /* inb/outb macross */
                     56: +#endif /* __OpenBSD__ */
                     57: +
                     58:  #include "log.h"
                     59:
                     60:  /* parallel port cable description
                     61: @@ -200,12 +207,12 @@ static __inline__ void parport_write_data(void)
                     62:  #if PARPORT_USE_PPDEV == 1
                     63:        ioctl(device_handle, PPWDATA, &output);
                     64:  #else
                     65: -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
                     66: +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
                     67:        outb(dataport, output);
                     68:  #else
                     69:        outb(output, dataport);
                     70:  #endif
                     71: -#endif
                     72: +#endif  /* not PARPORT_USE_PPDEV */
                     73:  }
                     74:
                     75:  void parport_write(int tck, int tms, int tdi)
                     76: @@ -310,6 +317,12 @@ int parport_init(void)
                     77:        char buffer[256];
                     78:        int i = 0;
                     79:  #endif
                     80: +#ifdef __OpenBSD__
                     81: +      u_long  iopermtable[32] = {};
                     82: +
                     83: +      /* get current i/o permission table */
                     84: +      i386_get_ioperm(iopermtable);
                     85: +#endif /* __OpenBSD__ */
                     86:
                     87:        cur_cable = cables;
                     88:
                     89: @@ -403,7 +416,16 @@ int parport_init(void)
                     90:  #if PARPORT_USE_GIVEIO == 1
                     91:        if (parport_get_giveio_access() != 0)
                     92:  #else /* PARPORT_USE_GIVEIO */
                     93: +#ifdef __FreeBSD__
                     94:        if (ioperm(dataport, 3, 1) != 0)
                     95: +#endif /* __FreeBSD__ */
                     96: +#ifdef __OpenBSD__
                     97: +      /* request access to desired i/o port */
                     98: +      iopermtable[parport_port / 32] &= ~(1 << parport_port % 32);
                     99: +      iopermtable[parport_port / 32] &= ~(1 << parport_port % 32 + 1);
                    100: +      iopermtable[parport_port / 32] &= ~(1 << parport_port % 32 + 2);
                    101: +      if (i386_set_ioperm(iopermtable) != 0)
                    102: +#endif /* __OpenBSD__ */
                    103:  #endif /* PARPORT_USE_GIVEIO */
                    104:        {
                    105:                LOG_ERROR("missing privileges for direct i/o");
                    106: @@ -412,7 +434,7 @@ int parport_init(void)
                    107:        LOG_DEBUG("...privileges granted");
                    108:
                    109:        /* make sure parallel port is in right mode (clear tristate and interrupt */
                    110: -      #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
                    111: +      #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
                    112:                outb(parport_port + 2, 0x0);
                    113:        #else
                    114:                outb(0x0, parport_port + 2);
                    115: @@ -469,7 +491,7 @@ int parport_handle_parport_cable_command(struct comman
                    116:        if (parport_cable == 0)
                    117:        {
                    118:                parport_cable = malloc(strlen(args[0]) + sizeof(char));
                    119: -              strcpy(parport_cable, args[0]);
                    120: +              strlcpy(parport_cable, args[0], strlen(args[0]) + sizeof(char));
                    121:        }
                    122:
                    123:        return ERROR_OK;

CVSweb