/* * ihcp_io.h * public ioctl and default definition file for Linux 2.0.35 driver for PCI hardcopy boards * * (this file unchanged through 2.6.x versions of driver) * * Tahoma Technology * (formerly Ikon Corporation) * 107 2nd Avenue North * Seattle, WA, USA 98109 * * 206.728.6465 * http://www.tahomatech.com * tahoma@tahomatech.com * * This code released under the GPL, and in the public domain * References to IKON left in place for compatibility and historical reasons */ #ifndef IHCP_IO_H #define IHCP_IO_H /* * the defines in this file are the "public" definitions used by the driver and the * calling program * * included are the ioctl command codes used by the code that calls the driver, and * some defaults that may be changed by editing this file and re compiling the driver * * this file is also used inside driver code !!! don't mess with this unless you mean it! */ #include #include /* the ioctl() function call looks like: * * ioctl(filedescriptor,command,argument) * * argument is used in some of the ihcp ioctl calls to provide values to * the driver ioctl routine, or return values to the calling program. In * one case - data out - it contains an array of charater data to be sent * to the attached device. the argument is restricted to a maximum of 255 * bytes - by unix, and by the driver. * * the following ioctl commands * are available to programs using the ihcp driver: * * *** legacy ioctl commands - originally for Sbus hardcopy cards *** * * IHCPIO_DEV_RESET reset attached device * IHCPIO_SET_CONFIG select device timing,burst, and busy mode w/ value in arg * IHCPIO_SET_DMATIME set dma timeout to arg seconds * IHCPIO_SET_FIFOTIME set fifo <1/2 full and fifo empty+device ready * timeout to arg seconds * IHCPIO_GET_REGS return board's registers in arg * IHCPIO_GET_STATUS return device status in arg * IHCPIO_GET_BOARD return board type in arg * IHCPIO_SET_VMODE set versatec print/plot/spp mode using value in arg * IHCPIO_SET_VMODEX same as VMODE, but clear ready sync ff - most plotters * will use VMODE - both for versatec only * IHCPIO_V_CMD send pulse command to plotter using value in arg * (versatec only) * IHCPIO_DATA_OUT send data bytes from arg array to device. byte count * in IHCPIO_COUNT_MASK portion of cmd * IHCPIO_RDY_WAIT wait for fifo empty and device ready * IHCPIO_HALF_WAIT wait for fifo less than 1/2 full * IHCPIO_STREAM_ON select data streaming mode (centronics only) * IHCPIO_STREAM_OFF clear data streaming mode * IHCPIO_GET_FLAGS returns unit_flags in arg * IHCPIO_GET_FIFO returns fifo status in arg * IHCPIO_MASTER_CLEAR resets board and clears fifo FACTORY USE ONLY! * IHCPIO_SOFT_ACK simulates ack sequence from device * * *** new ioctl commands for PCI hardcopy cards ** * * IHCPIO_AUTO_LTR_COUNT set automatic line terminate byte count (line length) to arg bytes * IHCPIO_AUTO_LTR_ON enable automatic line terminate * IHCPIO_AUTO_LTR_OFF disable auto line terminate * IHCPIO_DEV_AND_VEND_ID return board device and vendor ids in arg * IHCPIO_REVISION_ID return board revision level in arg * IHCPIO_LITTLE_ENDIAN set little endian mode - plotter data will go low byte first * IHCPIO_BIG_ENDIAN set big endian mode - plotter data will go high byte first * * ioctls to allow direct fiddling of mode and device control * * IHCPIO_DIRECT_MODE direct write arg to mode register * IHCPIO_DEVICE_CONTROL direct write arg to device control * IHCPIO_INTERFACE_STATUS direct read of interface status register returned in arg * IHCPIO_DEVICE_STATUS direct read of device status register returned in arg * IHCPIO_REVERSE_DATA read of reverse data register returned in arg * */ /* the ioctl command codes conform to the unix pattern: * * the top 3 bits of the 32 bit value indicate whether arguments * are to be copied in, copied out, both, or neither. * * 0x80000000 = copy in * 0x40000000 = copy out * 0x20000000 = no argument transfer * 0xC0000000 = copy in and out * * the number of bytes in the argument is encoded in the lower * 8 bits of the upper half of the u_int, and the actual command * is encoded in the lower half. a rather arbitrary character, * which is intended to identify the driver, is also encoded in * the lower half of the command. it becomes part of the command * value. * for all commands except DATA_OUT, the arg length is part of * the command value. * * WHEN USING THE IHCPIO_DATA_OUT IOCTL, * THE CALLING PROGRAM IS REQUIRED TO COMBINE THE ARGUMENT LENGTH * WITH THE IOCTL COMMAND AS FOLLOWS: * * cmd = IHCPIO_DATA_OUT | ( ( arg_length & 0xFF ) << 16 ) ; * * more accurately, for linux: * * cmd = IHCPIO_DATA_OUT | ((arg_length & _IOC_SIZEMASK) << _IOC_SIZESHIFT) * * commands which require arguments - in or out - will pass those * values as 32 bit unsigned integers. the only exception is the * DATA_OUT ioctl, which uses an array of up to 255 bytes as its * argument. * * the magic character that identifies this driver is hereby * (arbitrarily) chosen to be 'H'. * * the following ioctl commands are defined using pre-existing * ioctl command macros. the CMD_MASK and COUNT_MASK values * defined MUST match the usage in ioctl.h. refer to that include * file for further information. * * ADDITIONAL IOCTL COMMANDS AND ARGUMENTS ARE FOUND AT THE END OF THIS * FILE. THEY ARE INCLUDED FOR COMPATIBILITY WITH SUN AND VERSATEC * DRIVERS FOR THE 10088 VME BOARD, AND WILL HOPEFULLY BE COMPATIBLE * WITH OTHER MANUFACTURERS BOARDS AND DRIVERS (SHOULD THERE BE ANY!) * * the "magic character" for these commands is "v" */ /* * other versions of this driver used the entire lower 16 bits of the command to decode the specific * function requested. this includes both the ioctl type (magic letter) and number as defined * in linux/ioctl.h. we reconstruct the full function mask the hard way to try to protect against * the shifting sands of linux defines */ #define IHCPIO_CMD_MASK ((_IOC_TYPEMASK << _IOC_TYPESHIFT) | (_IOC_NRMASK << _IOC_NRSHIFT)) #define IHCPIO_COUNT_MASK IOCSIZE_MASK /* arg byte count here - IOCSIZE_MASK is already shifted left */ /* * THE SOLARIS 2.0 MACROS IN ioccom.h WANT THE 'MAGIC LETTER' QUOTED. * THE SOLARIS 1.X MACROS WANTED IT WITHOUT QUOTES. * LINUX WANTS QUOTES * * SOME VERSIONS OF ioccom.h DIDN'T INCLUDE _IORN AND _IOWN. SOL2 SEEMS TO HAVE THEM * linux/ioctl.h DOESN'T SEEM TO HAVE THEM * * we will use the lower-level _IOC macro (asm/ioctl.h) to define these since we need to * provide the size as an actual byte count, not as a type input to sizeof(), which is used * by the higher level (_IOR, _IOW) macros */ #define _IORN(type, nr, size) _IOC(_IOC_READ, (type), (nr), (size)) #define _IOWN(type, nr, size) _IOC(_IOC_WRITE, (type), (nr), (size)) #define IHCPIO_DEV_RESET _IO('H',0) /* reset attached device */ /* sets & resets latched reset */ #define IHCPIO_SET_CONFIG _IOW('H',1,__u32) /* arg bits set configuration */ /* * the config bit patterns use those defined for the Sbus card - even * though they don't match the PCI card's bit posistions. this is done * to try to preserve compatibility between applications * * the first version of this driver doesn't try to support all the possible * modes available in the PCI card. * */ /* *** legacy bits **** */ #define IHCPIO_SPEED0 0x00 /* slowest device speed */ #define IHCPIO_SPEED1 0x04 #define IHCPIO_SPEED2 0x08 #define IHCPIO_SPEED3 0x0C /*fastest device timing */ #define IHCPIO_IGNORE_BUSY 0x80 /* ignore centr busy */ /* *** new for PCI *** */ #define IHCPIO_BUSY_HANDSHAKE 0x100 /* use BUSY instead of ACK */ #define IHCPIO_4_EDGE 0x200 /* use four edge handshake */ #define IHCPIO_V_BURST 0x400 /* select synch burst mode only */ /* available on some new v-tech */ /* and requires pld218B or later */ #define IHCPIO_SET_DMATIME _IOW('H',2,__u32) /* set dma timeout to arg secs */ #define IHCPIO_SET_FIFOTIME _IOW('H',3,__u32) /* set wait for <1/2 full or */ /* empty and dev rdy timeout */ /* to arg seconds */ /* * return array size used here and in ioctl code * _IORN takes the direct byte count, not a type to be * passed to the sizeof() operator, as is done with * the other _IOx macros */ #define IHCP_RETURN_ARRAY_SIZE 19 /* in long words!! */ #define IHCPIO_GET_REGS _IORN('H',4,IHCP_RETURN_ARRAY_SIZE * 4) /* puts all regs in arg array */ /* * returns all "IHCP" registers and some of the "PLX" registers. * also returns the device IDs and revision level. * PLX registers are all 32 bits wide. IHCP registers are 8 * bits wide. each is returned in a 32 bit longword as shown below. * the DMA registers returned are either channel 0 or 1, depending * on which is used in the particular revision of the board. * * * (__u32 larg[19]) * * larg[0] = device ID (high 16 bits) & vendor id (low 16 bits) * larg[1] = revision ID * larg[2] = PLX interrupt control/status * larg[3] = PLX EEPROM control and user bits * larg[4] = PLX DMA mode * larg[5] = PLX DMA PCI address * larg[6] = PLX DMA local address * larg[7] = PLX DMA transfer count * larg[8] = PLX DMA descriptor pointer * larg[9] = PLX DMA command/status register * larg[10]= interrupt mask * larg[11]= mode * larg[12]= device control * larg[13]= interface control * larg[14]= interface status * larg[15]= device status * larg[16]= reverse data * larg[17]= auto ltr count low * larg[18]= auto ltr count high * */ #define IHCPIO_GET_STATUS _IOR('H',5,__u32) /* returns FORMATTED device */ /* status in arg */ #define IHCPIO_DEV_RDY 0x00000010 /* v-rdy or centr ack asserted */ #define IHCPIO_DEV_BUSY 0x00000008 /* centronics asserting busy */ #define IHCPIO_DEV_FAULT 0x00000004 /* centronics asserting fault */ #define IHCPIO_DEV_POUT 0x00000002 /* v or c no paper */ #define IHCPIO_DEV_SEL 0x00000001 /* v online or c selected */ #define IHCPIO_GET_BOARD _IOR('H',6,__u32) /* gets board strapping - sbus compatibility */ /* strapping bits returned in arg */ #define IHCPIO_VERS_DIFF 0x000000A0 /* versatec differential */ #define IHCPIO_VERS_TTL 0x00000060 /* versatec ttl */ #define IHCPIO_CENT 0x000000C0 /* centronics */ #define IHCPIO_SET_VMODE _IOW('H',7,__u32) /* sets print/plot, spp as selected by arg */ #define IHCPIO_SET_VMODEX _IOW('H',8,__u32) /* same as above for PCI boards */ #define IHCPIO_V_SPP 0x00000002 /* sets spp w/MODE(X) */ #define IHCPIO_V_PLOT 0x00000001 /* sets plot mode w/MODE(X) */ #define IHCPIO_V_NPRINT 0x00000000 /* 0 = normal print mode */ #define IHCPIO_V_CMD _IOW('H',9,__u32) /* pulse commands to versatec selected by arg */ #define IHCPIO_VLTR 0x00000000 /* remote line terminate */ #define IHCPIO_VEOT 0x00000001 /* remote eot */ #define IHCPIO_VFED 0x00000002 /* remote form feed */ #define IHCPIO_VCLR 0x00000003 /* remote buffer clear */ #define IHCPIO_DATA_OUT _IOWN('H',10,0) /* CALLING PGM WILL AND IN THE */ /* ACTUAL CHARACTER COUNT - DONE */ /* THIS WAY SO COUNT CAN BE A */ /* VARAIBLE, NOT CONSTANT !!! */ /* see ioctl description above */ /* sends char array in arg to */ /* fifo if room. if not - return */ /* EINVAL. will flag error if */ /* caller tries to send more */ /* 255 bytes, or if fifo becomes */ /* full during transfers. */ #define IHCPIO_RDY_WAIT _IO('H',11) /* waits for fifo empty and */ /* device ready */ #define IHCPIO_HALF_WAIT _IO('H',12) /* wait for fifo 64K max w/4K pages */ #define MAX_BOARDS_DEF 2 /* default to two boards, to save a little kernel memory */ #endif /* IHCP_IO_H */