diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-02-12 17:35:53 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-02-12 17:35:53 +0100 |
commit | 84357741a6a6e6430f199b2c3f7498e0e97da9ad (patch) | |
tree | 23e8d66ede9506b94c76fb36910ca3c7dd15c74e /sanei | |
parent | 302276dc1b90cfc972fb726ca94a23b18f4b0088 (diff) |
New upstream version 1.2.1upstream/1.2.1
Diffstat (limited to 'sanei')
-rw-r--r-- | sanei/Makefile.am | 2 | ||||
-rw-r--r-- | sanei/sanei_ab306.c | 42 | ||||
-rw-r--r-- | sanei/sanei_directio.c | 367 | ||||
-rw-r--r-- | sanei/sanei_jpeg.c | 24 | ||||
-rw-r--r-- | sanei/sanei_magic.c | 4 | ||||
-rw-r--r-- | sanei/sanei_pa4s2.c | 64 | ||||
-rw-r--r-- | sanei/sanei_pio.c | 154 | ||||
-rw-r--r-- | sanei/sanei_pp.c | 71 | ||||
-rw-r--r-- | sanei/sanei_pv8630.c | 3 | ||||
-rw-r--r-- | sanei/sanei_scsi.c | 3 |
10 files changed, 435 insertions, 299 deletions
diff --git a/sanei/Makefile.am b/sanei/Makefile.am index 46d3ff4..30b9781 100644 --- a/sanei/Makefile.am +++ b/sanei/Makefile.am @@ -9,7 +9,7 @@ AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \ noinst_LTLIBRARIES = libsanei.la -libsanei_la_SOURCES = sanei_ab306.c sanei_constrain_value.c \ +libsanei_la_SOURCES = sanei_directio.c sanei_ab306.c sanei_constrain_value.c \ sanei_init_debug.c sanei_net.c sanei_wire.c sanei_codec_ascii.c \ sanei_codec_bin.c sanei_scsi.c sanei_config.c sanei_config2.c \ sanei_pio.c sanei_pa4s2.c sanei_auth.c sanei_usb.c sanei_thread.c \ diff --git a/sanei/sanei_ab306.c b/sanei/sanei_ab306.c index aa642c9..5c1f200 100644 --- a/sanei/sanei_ab306.c +++ b/sanei/sanei_ab306.c @@ -47,33 +47,7 @@ #include <sys/types.h> -#ifdef HAVE_SYS_IO_H -# include <sys/io.h> /* use where available (glibc 2.x, for example) */ -# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB -# define IO_SUPPORT_MISSING -# endif -#elif HAVE_ASM_IO_H -# include <asm/io.h> /* ugly, but backwards compatible */ -#elif defined (__i386__) && defined (__GNUC__) - -static __inline__ void -outb (u_char value, u_long port) -{ - __asm__ __volatile__ ("outb %0,%1" : : "a" (value), "d" ((u_short) port)); -} - -static __inline__ u_char -inb (u_long port) -{ - u_char value; - - __asm__ __volatile__ ("inb %1,%0" : "=a" (value) : "d" ((u_short)port)); - return value; -} - -#else -# define IO_SUPPORT_MISSING -#endif +#include "../include/sane/sanei_directio.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" @@ -149,7 +123,7 @@ ab306_outb (Port *p, u_long addr, u_char val) return; } else - outb (val, addr); + sanei_outb (addr, val); } static int @@ -166,7 +140,7 @@ ab306_inb (Port *p, u_long addr) return ch; } else - return inb (addr); + return sanei_inb (addr); } /* Send a single command-byte over the AB306N-interface. */ @@ -299,11 +273,11 @@ sanei_ab306_open (const char *dev, int *fdp) byte = wakeup[j]; if (j == NELEMS(wakeup) - 1) byte |= i; - outb (byte, AB306_CIO); + sanei_outb (AB306_CIO, byte); } #else /* !defined(__FreeBSD__) */ - if (ioperm (AB306_CIO, 1, 1) != 0) + if (sanei_ioperm (AB306_CIO, 1, 1) != 0) { DBG(1, "sanei_ab306_ioport: using /dev/port access\n"); if (port[i].port_fd < 0) @@ -329,7 +303,7 @@ sanei_ab306_open (const char *dev, int *fdp) byte = wakeup[j]; if (j == NELEMS(wakeup) - 1) byte |= i; - outb (byte, AB306_CIO); + sanei_outb (AB306_CIO, byte); } status = sanei_ab306_get_io_privilege (i); if (status != SANE_STATUS_GOOD) @@ -373,7 +347,7 @@ sanei_ab306_get_io_privilege (int fd) if (dev_io_fd < 0) return SANE_STATUS_IO_ERROR; #else /* !defined(__FreeBSD__) */ - if (ioperm (port[fd].base, 3, 1) != 0) + if (sanei_ioperm (port[fd].base, 3, 1) != 0) return SANE_STATUS_IO_ERROR; #endif /* !defined(__FreeBSD__) */ } @@ -493,7 +467,7 @@ sanei_ab306_rdata (int fd, int planes, SANE_Byte * buf, int lines, int bpl) /* the pixel-loop: */ for (bcnt = 0; bcnt < xmax; bcnt++) { - *(u_char *) buf = inb (p->base); + *(u_char *) buf = sanei_inb (p->base); ++buf; } } diff --git a/sanei/sanei_directio.c b/sanei/sanei_directio.c new file mode 100644 index 0000000..c95bb97 --- /dev/null +++ b/sanei/sanei_directio.c @@ -0,0 +1,367 @@ +/*************************************************/ +/* here we define sanei_inb/sanei_outb based on */ +/* OS dependent inb/outb definitions */ +/* SANE_INB is defined whenever a valid inb/outb */ +/* definition has been found */ +/*************************************************/ + +#include "../include/sane/config.h" + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <sys/types.h> + +#include "../include/sane/sane.h" +#include "../include/sane/sanei.h" +#include "../include/sane/sanei_directio.h" + +#ifdef ENABLE_PARPORT_DIRECTIO + +#define TEST_SANE_INB(val) ( SANE_INB == val ) + +#if ( TEST_SANE_INB(1) ) /* OS/2 EMX case */ +int +sanei_ioperm (int start, int length, int enable) +{ + if (enable) + return _portaccess (port, port + length - 1); + return 0; +} + +unsigned char +sanei_inb (unsigned int port) +{ + return _inp8 (port) & 0xFF; +} + +void +sanei_outb (unsigned int port, unsigned char value) +{ + _outp8 (port, value); +} + +void +sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) +{ + _inps8 (port, (unsigned char *) addr, count); +} + +void +sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) +{ + _inps32 (port, (unsigned long *) addr, count); +} + +void +sanei_outsb (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + _outps8 (port, (unsigned char *) addr, count); +} + +void +sanei_outsl (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + _outps32 (port, (unsigned long *) addr, count); +} +#endif /* OS/2 EMX case */ + + + +#if ( TEST_SANE_INB(2) ) /* FreeBSD case */ +int +sanei_ioperm (int start, int length, int enable) +{ +#ifdef HAVE_I386_SET_IOPERM + return i386_set_ioperm (start, length, enable); +#else + int fd = 0; + + /* makes compilers happy */ + start = length + enable; + fd = open ("/dev/io", O_RDONLY); + if (fd > 0) + return 0; + return -1; +#endif +} + +unsigned char +sanei_inb (unsigned int port) +{ + return inb (port); +} + +void +sanei_outb (unsigned int port, unsigned char value) +{ + outb (port, value); +} + +void +sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) +{ + insb (port, addr, count); +} + +void +sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) +{ + insl (port, addr, count); +} + +void +sanei_outsb (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + outsb (port, addr, count); +} + +void +sanei_outsl (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + outsl (port, addr, count); +} +#endif /* FreeBSD case */ + + +/* linux GCC on i386 */ +#if ( TEST_SANE_INB(3) ) /* FreeBSD case */ + +int +sanei_ioperm (int start, int length, int enable) +{ +#ifdef HAVE_IOPERM + return ioperm (start, length, enable); +#else + /* linux without ioperm ? hum ... */ + /* makes compilers happy */ + start = length + enable; + return 0; +#endif +} + +unsigned char +sanei_inb (unsigned int port) +{ + return inb (port); +} + +void +sanei_outb (unsigned int port, unsigned char value) +{ + outb (value, port); +} + +void +sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) +{ + insb (port, addr, count); +} + +void +sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) +{ + insl (port, addr, count); +} + +void +sanei_outsb (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + outsb (port, addr, count); +} + +void +sanei_outsl (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + /* oddly, 32 bit I/O are done with outsw instead of the expected outsl */ + outsw (port, addr, count); +} +#endif /* linux GCC on i386 */ + + +/* linux GCC non i386 */ +#if ( TEST_SANE_INB(4) ) +int +sanei_ioperm (int start, int length, int enable) +{ +#ifdef HAVE_IOPERM + return ioperm (start, length, enable); +#else + /* linux without ioperm ? hum ... */ + /* makes compilers happy */ + start = length + enable; + return 0; +#endif +} + +unsigned char +sanei_inb (unsigned int port) +{ + return inb (port); +} + +void +sanei_outb (unsigned int port, unsigned char value) +{ + outb (value, port); +} + +void +sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) +{ + unsigned int i; + + for (i = 0; i < count; i++) + addr[i] = sanei_inb (port); +} + +void +sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) +{ + unsigned int i; + + for (i = 0; i < count * 4; i++) + addr[i] = sanei_inb (port); +} + +void +sanei_outsb (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + unsigned int i; + + for (i = 0; i < count; i++) + sanei_outb (port, addr[i]); +} + +void +sanei_outsl (unsigned int port, const unsigned char *addr, + unsigned long count) +{ + unsigned int i; + + for (i = 0; i < count * 4; i++) + sanei_outb (port, addr[i]); +} +#endif /* linux GCC non i386 */ + + +/* ICC on i386 */ +#if ( TEST_SANE_INB(5) ) +int +sanei_ioperm (int start, int length, int enable) +{ +#ifdef HAVE_IOPERM + return ioperm (start, length, enable); +#else + /* ICC without ioperm() ... */ + /* makes compilers happy */ + start = length + enable; + return 0; +#endif +} +unsigned char +sanei_inb (unsigned int port) +{ + unsigned char ret; + + __asm__ __volatile__ ("inb %%dx,%%al":"=a" (ret):"d" ((u_int) port)); + return ret; +} + +void +sanei_outb (unsigned int port, unsigned char value) +{ + __asm__ __volatile__ ("outb %%al,%%dx"::"a" (value), "d" ((u_int) port)); +} + +void +sanei_insb (unsigned int port, void *addr, unsigned long count) +{ + __asm__ __volatile__ ("rep ; insb":"=D" (addr), "=c" (count):"d" (port), + "0" (addr), "1" (count)); +} + +void +sanei_insl (unsigned int port, void *addr, unsigned long count) +{ + __asm__ __volatile__ ("rep ; insl":"=D" (addr), "=c" (count):"d" (port), + "0" (addr), "1" (count)); +} + +void +sanei_outsb (unsigned int port, const void *addr, unsigned long count) +{ + __asm__ __volatile__ ("rep ; outsb":"=S" (addr), "=c" (count):"d" (port), + "0" (addr), "1" (count)); +} + +void +sanei_outsl (unsigned int port, const void *addr, unsigned long count) +{ + __asm__ __volatile__ ("rep ; outsl":"=S" (addr), "=c" (count):"d" (port), + "0" (addr), "1" (count)); +} + +#endif /* ICC on i386 */ + +#endif /* ENABLE_PARPORT_DIRECTIO */ +/* + * no inb/outb without --enable-parport-directio * + */ +#ifndef ENABLE_PARPORT_DIRECTIO +int +sanei_ioperm (__sane_unused__ int start, __sane_unused__ int length, + __sane_unused__ int enable) +{ + /* returns failure */ + return -1; +} + +unsigned char +sanei_inb (__sane_unused__ unsigned int port) +{ + return 255; +} + +void +sanei_outb (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char value) +{ +} + +void +sanei_insb (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char *addr, + __sane_unused__ unsigned long count) +{ +} + +void +sanei_insl (__sane_unused__ unsigned int port, + __sane_unused__ unsigned char *addr, + __sane_unused__ unsigned long count) +{ +} + +void +sanei_outsb (__sane_unused__ unsigned int port, + __sane_unused__ const unsigned char *addr, + __sane_unused__ unsigned long count) +{ +} + +void +sanei_outsl (__sane_unused__ unsigned int port, + __sane_unused__ const unsigned char *addr, + __sane_unused__ unsigned long count) +{ +} +#endif /* ENABLE_PARPORT_DIRECTIO is not defined */ diff --git a/sanei/sanei_jpeg.c b/sanei/sanei_jpeg.c index 7b66dae..d27701f 100644 --- a/sanei/sanei_jpeg.c +++ b/sanei/sanei_jpeg.c @@ -57,8 +57,8 @@ typedef ppm_dest_struct *ppm_dest_ptr; METHODDEF (void) sanei_jpeg_start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) { - cinfo = cinfo; - dinfo = dinfo; + (void) cinfo; + (void) dinfo; /* header image is supplied for us */ } @@ -66,8 +66,8 @@ sanei_jpeg_start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) METHODDEF (void) sanei_jpeg_finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) { - cinfo = cinfo; - dinfo = dinfo; + (void) cinfo; + (void) dinfo; /* nothing to do */ } @@ -85,9 +85,9 @@ sanei_jpeg_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied, char *data) { ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - cinfo = cinfo; - dinfo = dinfo; - rows_supplied = rows_supplied; + (void) cinfo; + (void) dinfo; + (void) rows_supplied; memcpy (data, dest->iobuffer, dest->buffer_width); } @@ -107,9 +107,9 @@ sanei_jpeg_copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, register JSAMPROW ptr; register JDIMENSION col; - cinfo = cinfo; - dinfo = dinfo; - rows_supplied = rows_supplied; + (void) cinfo; + (void) dinfo; + (void) rows_supplied; ptr = dest->pub.buffer[0]; bufferptr = dest->iobuffer; @@ -140,7 +140,7 @@ sanei_jpeg_put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, register JSAMPROW color_map2 = cinfo->colormap[2]; register JDIMENSION col; - rows_supplied = rows_supplied; + (void) rows_supplied; ptr = dest->pub.buffer[0]; bufferptr = dest->iobuffer; @@ -165,7 +165,7 @@ sanei_jpeg_put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, register JSAMPROW color_map = cinfo->colormap[0]; register JDIMENSION col; - rows_supplied = rows_supplied; + (void) rows_supplied; ptr = dest->pub.buffer[0]; bufferptr = dest->iobuffer; diff --git a/sanei/sanei_magic.c b/sanei/sanei_magic.c index f5d1ac0..e62c56a 100644 --- a/sanei/sanei_magic.c +++ b/sanei/sanei_magic.c @@ -527,7 +527,7 @@ sanei_magic_findSkew(SANE_Parameters * params, SANE_Byte * buffer, DBG (10, "sanei_magic_findSkew: start\n"); - dpiX=dpiX; + (void) dpiX; /* get buffers for edge detection */ topBuf = sanei_magic_getTransY(params,dpiY,buffer,1); @@ -1406,7 +1406,7 @@ getLine (int height, int width, int * buff, minSlope,maxSlope,minOffset,maxOffset); /*silence compiler*/ - height = height; + (void) height; if(absMaxSlope < absMinSlope) absMaxSlope = absMinSlope; diff --git a/sanei/sanei_pa4s2.c b/sanei/sanei_pa4s2.c index 5e59743..92fcf7f 100644 --- a/sanei/sanei_pa4s2.c +++ b/sanei/sanei_pa4s2.c @@ -66,43 +66,7 @@ #elif defined(ENABLE_PARPORT_DIRECTIO) -# if defined(HAVE_SYS_IO_H) -# if defined (__ICC) && __ICC >= 700 -# define __GNUC__ 2 -# endif -# include <sys/io.h> -# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB -# define IO_SUPPORT_MISSING -# endif -# if defined (__ICC) && __ICC >= 700 -# undef __GNUC__ -# elif defined(__ICC) && defined(HAVE_ASM_IO_H) -# include <asm/io.h> -# endif -# elif defined(HAVE_ASM_IO_H) -# include <asm/io.h> /* ugly, but backwards compatible */ -# elif defined(HAVE_SYS_HW_H) -# include <sys/hw.h> -# elif defined(__i386__) && ( defined (__GNUC__) || defined (__ICC) ) - -static __inline__ void -outb (u_char value, u_long port) -{ - __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port)); -} - -static __inline__ u_char -inb (u_long port) -{ - u_char value; - - __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port)); - return value; -} - -# else -# define IO_SUPPORT_MISSING -# endif +#include "../include/sane/sanei_directio.h" #else @@ -306,7 +270,7 @@ pa4s2_init (SANE_Status *status) if (first_time == SANE_FALSE) { DBG (5, "pa4s2_init: sanei already initialized\n"); - status = SANE_STATUS_GOOD; + *status = SANE_STATUS_GOOD; return 0; } @@ -519,7 +483,7 @@ pa4s2_open (const char *dev, SANE_Status * status) /* TODO: insert FreeBSD compatible code here */ - if (ioperm (port[n].base, 5, 1)) + if (sanei_ioperm (port[n].base, 5, 1)) { DBG (1, "pa4s2_open: cannot get io privilege for port 0x%03lx\n", @@ -571,15 +535,15 @@ static void outbyte3(int fd, u_char val) #else -#define inbyte0(fd) inb(port[fd].base) -#define inbyte1(fd) inb(port[fd].base + 1) -#define inbyte2(fd) inb(port[fd].base + 2) -#define inbyte4(fd) inb(port[fd].base + 4) +#define inbyte0(fd) sanei_inb(port[fd].base) +#define inbyte1(fd) sanei_inb(port[fd].base + 1) +#define inbyte2(fd) sanei_inb(port[fd].base + 2) +#define inbyte4(fd) sanei_inb(port[fd].base + 4) -#define outbyte0(fd,val) outb(val, port[fd].base) -#define outbyte1(fd,val) outb(val, port[fd].base + 1) -#define outbyte2(fd,val) outb(val, port[fd].base + 2) -#define outbyte3(fd,val) outb(val, port[fd].base + 3) +#define outbyte0(fd,val) sanei_outb(port[fd].base, val) +#define outbyte1(fd,val) sanei_outb(port[fd].base + 1, val) +#define outbyte2(fd,val) sanei_outb(port[fd].base + 2, val) +#define outbyte3(fd,val) sanei_outb(port[fd].base + 3, val) #endif @@ -882,7 +846,7 @@ pa4s2_close (int fd, SANE_Status * status) #if defined(HAVE_LIBIEEE1284) if ((result = ieee1284_close(pplist.portv[fd])) < 0) #else - if (ioperm (port[fd].base, 5, 0)) + if (sanei_ioperm (port[fd].base, 5, 0)) #endif { @@ -1427,7 +1391,7 @@ sanei_pa4s2_enable (int fd, int enable) linux 2.2, although they seem to be inherited on linux 2.4), so we should make sure we get the permission */ - if (ioperm (port[fd].base, 5, 1)) + if (sanei_ioperm (port[fd].base, 5, 1)) { DBG (1, "sanei_pa4s2_enable: cannot get io privilege for port" " 0x%03lx\n", port[fd].base); @@ -1917,7 +1881,7 @@ sanei_pa4s2_open (const char *dev, int *fd) DBG (3, "sanei_pa4s2_open: A4S2 support not compiled\n"); DBG (6, "sanei_pa4s2_open: basically, this backend does only compile\n"); DBG (6, "sanei_pa4s2_open: on x86 architectures. Furthermore it\n"); - DBG (6, "sanei_pa4s2_open: needs ioperm() and inb()/outb() calls.\n"); + DBG (6, "sanei_pa4s2_open: needs sanei_ioperm() and sanei_inb()/sanei_outb() calls.\n"); DBG (6, "sanei_pa4s2_open: alternatively it makes use of libieee1284\n"); DBG (6, "sanei_pa4s2_open: (which isn't present either)\n"); DBG (5, "sanei_pa4s2_open: returning SANE_STATUS_INVAL\n"); diff --git a/sanei/sanei_pio.c b/sanei/sanei_pio.c index ee27267..cd379dd 100644 --- a/sanei/sanei_pio.c +++ b/sanei/sanei_pio.c @@ -48,6 +48,8 @@ */ #include "../include/sane/config.h" +#include "../include/sane/sanei_directio.h" +/* pick up compatibility defs */ #define BACKEND_NAME sanei_pio #include "../include/sane/sanei_backend.h" /* pick up compatibility defs */ @@ -57,42 +59,10 @@ #endif #include <sys/types.h> -#ifdef HAVE_SYS_IO_H -# include <sys/io.h> /* use where available (glibc 2.x, for example) */ -# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB -# define IO_SUPPORT_MISSING -# endif -#elif HAVE_ASM_IO_H -# include <asm/io.h> /* ugly, but backwards compatible */ -#elif HAVE_SYS_HW_H -# include <sys/hw.h> -#elif defined(__i386__) && defined (__GNUC__) - -static __inline__ void -outb (u_char value, u_long port) -{ - __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port)); -} - -static __inline__ u_char -inb (u_long port) -{ - u_char value; - - __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port)); - return value; -} - -#else -# define IO_SUPPORT_MISSING -#endif - #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_pio.h" -#if defined (HAVE_IOPERM) && !defined (IO_SUPPORT_MISSING) - #include <errno.h> #include <fcntl.h> #include <limits.h> @@ -161,8 +131,6 @@ static PortRec port[] = extern int setuid (uid_t); -static inline int pio_outb (const Port port, u_char val, u_long addr); -static inline int pio_inb (const Port port, u_char * val, u_long addr); static inline int pio_wait (const Port port, u_char val, u_char mask); static inline void pio_ctrl (const Port port, u_char val); static inline void pio_delay (const Port port); @@ -173,38 +141,6 @@ static int pio_read (const Port port, u_char * buf, int n); static int pio_open (const char *dev, SANE_Status * status); static inline int -pio_outb (const Port port, u_char val, u_long addr) -{ - - if (-1 == port->fd) - outb (val, addr); - else - { - if (addr != (u_long)lseek (port->fd, addr, SEEK_SET)) - return -1; - if (1 != write (port->fd, &val, 1)) - return -1; - } - return 0; -} - -static inline int -pio_inb (const Port port, u_char * val, u_long addr) -{ - - if (-1 == port->fd) - *val = inb (addr); - else - { - if (addr != (u_long)lseek (port->fd, addr, SEEK_SET)) - return -1; - if (1 != read (port->fd, val, 1)) - return -1; - } - return 0; -} - -static inline int pio_wait (const Port port, u_char val, u_char mask) { int stat = 0; @@ -221,7 +157,7 @@ pio_wait (const Port port, u_char val, u_char mask) for (;;) { ++poll_count; - stat = inb (port->base + PIO_STAT); + stat = sanei_inb (port->base + PIO_STAT); if ((stat & mask) == (val & mask)) { DBG (DL60, "got %02x after %ld tries\n", stat, poll_count); @@ -261,7 +197,7 @@ pio_ctrl (const Port port, u_char val) DBG (DL61, " FDXT %s\n", val & PIO_CTRL_FDXT ? "on" : "off"); DBG (DL61, " NSTROBE %s\n", val & PIO_CTRL_NSTROBE ? "on" : "off"); - outb (val, port->base + PIO_CTRL); + sanei_outb (port->base + PIO_CTRL, val); return; } @@ -269,7 +205,7 @@ pio_ctrl (const Port port, u_char val) static inline void pio_delay (const Port port) { - inb (port->base + PIO_STAT); /* delay */ + sanei_inb (port->base + PIO_STAT); /* delay */ return; } @@ -290,8 +226,8 @@ pio_reset (const Port port) for (n = PIO_APPLYRESET; --n >= 0;) { - outb ((PIO_CTRL_IE | PIO_CTRL_NINIT) ^ PIO_CTRL_NINIT, - port->base + PIO_CTRL); + sanei_outb (port->base + PIO_CTRL, + (PIO_CTRL_IE | PIO_CTRL_NINIT) ^ PIO_CTRL_NINIT); } pio_init (port); @@ -323,7 +259,7 @@ pio_write (const Port port, const u_char * buf, int n) #endif DBG (DL60, "out %02x\n", (int) *buf); - outb (*buf, port->base + PIO_IOPORT); + sanei_outb (port->base + PIO_IOPORT, *buf); pio_delay (port); pio_delay (port); @@ -387,7 +323,7 @@ pio_read (const Port port, u_char * buf, int n) /* busynack */ #endif - *buf = inb (port->base + PIO_IOPORT); + *buf = sanei_inb (port->base + PIO_IOPORT); DBG (DL60, "in %02x\n", (int) *buf); DBG (DL40, "end read byte\n"); } @@ -465,7 +401,7 @@ pio_open (const char *dev, SANE_Status * status) port[n].max_time_seconds = 10; port[n].in_use = 1; - if (ioperm (port[n].base, 3, 1)) + if (sanei_ioperm (port[n].base, 3, 1)) { DBG (1, "sanei_pio_open: cannot get io privilege for port 0x%03lx\n", port[n].base); @@ -533,73 +469,3 @@ sanei_pio_write (int fd, const u_char * buf, int n) return pio_write (&port[fd], buf, n); } - -#else /* !HAVE_IOPERM */ - -#ifdef __BEOS__ - -#include <fcntl.h> - -SANE_Status -sanei_pio_open (const char *dev, int *fdp) -{ - int fp; - - /* open internal parallel port */ - fp=open("/dev/parallel/parallel1",O_RDWR); - - *fdp=fp; - if(fp<0) return SANE_STATUS_INVAL; - return(SANE_STATUS_GOOD); -} - - -void -sanei_pio_close (int fd) -{ - close(fd); - return; -} - -int -sanei_pio_read (int fd, u_char * buf, int n) -{ - return(read(fd,buf,n)); -} - -int -sanei_pio_write (int fd, const u_char * buf, int n) -{ - return(write(fd,buf,n)); -} - -#else /* !__BEOS__ */ - -SANE_Status -sanei_pio_open (const char *dev, int *fdp) -{ - *fdp = -1; - return SANE_STATUS_INVAL; -} - - -void -sanei_pio_close (int fd) -{ - return; -} - -int -sanei_pio_read (int fd, u_char * buf, int n) -{ - return -1; -} - -int -sanei_pio_write (int fd, const u_char * buf, int n) -{ - return -1; -} -#endif /* __BEOS__ */ - -#endif /* !HAVE_IOPERM */ diff --git a/sanei/sanei_pp.c b/sanei/sanei_pp.c index 5150313..efd271d 100644 --- a/sanei/sanei_pp.c +++ b/sanei/sanei_pp.c @@ -87,40 +87,7 @@ #endif #if defined (ENABLE_PARPORT_DIRECTIO) # undef HAVE_LIBIEEE1284 -# if defined(HAVE_SYS_IO_H) -# if defined (__ICC) && __ICC >= 700 -# define __GNUC__ 2 -# endif -# include <sys/io.h> -# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB -# define IO_SUPPORT_MISSING -# endif -# if defined (__ICC) && __ICC >= 700 -# undef __GNUC__ -# elif defined(__ICC) && defined(HAVE_ASM_IO_H) -# include <asm/io.h> -# endif -# elif defined(HAVE_ASM_IO_H) -# include <asm/io.h> -# elif defined(HAVE_SYS_HW_H) -# include <sys/hw.h> -# elif defined(__i386__) && ( defined (__GNUC__) || defined (__ICC) ) - -static __inline__ void -outb( u_char value, u_long port ) -{ - __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port)); -} - -static __inline__ u_char -inb( u_long port ) -{ - u_char value; - - __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port)); - return value; -} -# endif +# include "../include/sane/sanei_directio.h" #elif defined(HAVE_LIBIEEE1284) # include <ieee1284.h> #else @@ -228,30 +195,26 @@ static inline void outb_addr(int fd, u_char val) #else -#define inb_data(fd) inb(port[fd].base) -#define inb_stat(fd) inb(port[fd].base + 1) -#define inb_ctrl(fd) inb(port[fd].base + 2) -#define inb_eppdata(fd) inb(port[fd].base + 4) +#define inb_data(fd) sanei_inb(port[fd].base) +#define inb_stat(fd) sanei_inb(port[fd].base + 1) +#define inb_ctrl(fd) sanei_inb(port[fd].base + 2) +#define inb_eppdata(fd) sanei_inb(port[fd].base + 4) -#define outb_data(fd,val) outb(val, port[fd].base) -#define outb_stat(fd,val) outb(val, port[fd].base + 1) -#define outb_ctrl(fd,val) outb(val, port[fd].base + 2) -#define outb_addr(fd,val) outb(val, port[fd].base + 3) -#define outb_eppdata(fd,val) outb(val, port[fd].base + 4) +#define outb_data(fd,val) sanei_outb(port[fd].base, val) +#define outb_stat(fd,val) sanei_outb(port[fd].base + 1, val) +#define outb_ctrl(fd,val) sanei_outb(port[fd].base + 2, val) +#define outb_addr(fd,val) sanei_outb(port[fd].base + 3, val) +#define outb_eppdata(fd,val) sanei_outb(port[fd].base + 4, val) #ifdef HAVE_IOPL # define _SET_IOPL() iopl(3) -# define inbyte400(fd) inb(port[fd].base + 0x400) -# define inbyte402(fd) inb(port[fd].base + 0x402) -# define outbyte400(fd,val) outb(val, port[fd].base + 0x400) -# define outbyte402(fd,val) outb(val, port[fd].base + 0x402) #else # define _SET_IOPL() -# define inbyte400(fd) -# define inbyte402(fd,val) -# define outbyte400(fd,val) -# define outbyte402(fd,val) #endif +#define inbyte400(fd) sanei_inb(port[fd].base + 0x400) +#define inbyte402(fd) sanei_inb(port[fd].base + 0x402) +#define outbyte400(fd,val) sanei_outb(port[fd].base + 0x400, val) +#define outbyte402(fd,val) sanei_outb(port[fd].base + 0x402, val) #endif /* should also be in unistd.h */ @@ -848,7 +811,7 @@ pp_open( const char *dev, SANE_Status * status ) /* TODO: insert FreeBSD compatible code here */ - if( ioperm( port[i].base, 5, 1 )) { + if( sanei_ioperm( port[i].base, 5, 1 )) { DBG( 1, "pp_open: cannot get io privilege for port 0x%03lx\n", port[i].base); @@ -901,7 +864,7 @@ pp_close( int fd, SANE_Status *status ) #if defined(HAVE_LIBIEEE1284) if((result = ieee1284_close(pplist.portv[fd])) < 0) { #else - if( ioperm( port[fd].base, 5, 0 )) { + if( sanei_ioperm( port[fd].base, 5, 0 )) { #endif #if defined(HAVE_LIBIEEE1284) DBG( 1, "pp_close: can't free port '%s' (%s)\n", @@ -1328,7 +1291,7 @@ sanei_pp_open( const char *dev, int *fd ) DBG( 3, "sanei_pp_open: support not compiled\n" ); DBG( 6, "sanei_pp_open: basically, this backend does only compile\n" ); DBG( 6, "sanei_pp_open: on x86 architectures. Furthermore it\n" ); - DBG( 6, "sanei_pp_open: needs ioperm() and inb()/outb() calls.\n" ); + DBG( 6, "sanei_pp_open: needs ioperm() and sanei_inb()/sanei_outb() calls.\n" ); DBG( 6, "sanei_pp_open: alternatively it makes use of libieee1284\n" ); DBG( 6, "sanei_pp_open: (which isn't present either)\n"); return SANE_STATUS_INVAL; diff --git a/sanei/sanei_pv8630.c b/sanei/sanei_pv8630.c index 5f3c2af..2bbc0f4 100644 --- a/sanei/sanei_pv8630.c +++ b/sanei/sanei_pv8630.c @@ -87,7 +87,8 @@ sanei_pv8630_read_byte (int fd, SANEI_PV_Index index, SANE_Byte * byte) { SANE_Status status; - DBG(DBG_info, "sanei_pv8630_read_byte - index=%d, byte=%p\n", index, byte); + DBG(DBG_info, "sanei_pv8630_read_byte - index=%d, byte=%p\n", + index, (void *) byte); status = sanei_usb_control_msg (fd, 0xc0, PV8630_REQ_READBYTE, 0, index, 1, byte); diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c index 53736ca..6eef998 100644 --- a/sanei/sanei_scsi.c +++ b/sanei/sanei_scsi.c @@ -50,6 +50,7 @@ #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <inttypes.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -3509,7 +3510,7 @@ sanei_scsi_find_devices (const char *findvendor, const char *findmodel, if (cdm.matches[i].type != DEV_MATCH_PERIPH) continue; result = &cdm.matches[i].result.periph_result; - DBG (4, "%s%d on scbus%d %d:%d\n", + DBG (4, "%s%d on scbus%d %d:" PRIu64 "\n", result->periph_name, result->unit_number, result->path_id, result->target_id, result->target_lun); if (cam_compare_inquiry (fd, result->path_id, |