/* this file contains the external ioctl definitions for the hp-ux driver for IKON's ISA/EISA hardcopy boards. These are essentially the same definitions used in IKON's and other unix drivers on Sbus & other platforms. In particular, the old VME Versatec calls are still suported. Several of the left-over VME & sbus calls have no effect on this HP/eisa/unix driver. */ /* 16 July, 1992 */ /* 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 this driver, arg is always a pointer. In one case - data out - it points to an array of charater data to be sent to the attached device. the argument is restricted to a maximum of 255 bytes - (formerly by unix) by the driver. the following ioctl commands are available to programs using the ihcp driver: IHCPIO_DEV_RESET reset attached device IHCPIO_SET_CONFIG no op for this driver IHCPIO_SET_DMATIME set dma timeout to arg seconds IHCPIO_SET_RDYTIME set ready wait timeout to arg seconds IHCPIO_GET_REGS return board's registers in arg - mix of old and new formats - see code 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 - for compatibility w/Sbus driver 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 device and interface ready IHCPIO_HALF_WAIT same as RDY_WAIT - for compatibility w/Sbus driver 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 - always indicates empty - Sbus compatibility IHCPIO_STB_INH inhibits device data strobe - special application - this driver only IHCPIO_STB_ENB enables device data strobe - special application - this driver only */ /* 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 (or more, depending on implementation) 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 IHCP_DATA_OUT IOCTL, THE CALLING PROGRAM IS REQUIRED TO COMBINE THE ARGUMENT LENGTH WITH THE IOCTL COMMAND AS FOLLOWS: cmd = IHCP_DATA_OUT | ( ( arg_length & 0xFF ) << 16 ) ; 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 ioccom.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" */ /* The HP-UX C COMPILER WANTS THE MAGIC LETTER IN EACH MACRO QUOTED!!!!! FURTHERMORE - THERE ARE NO _IORN OR IOWN MACROS IN THIS UNIX. these were used in our Sbus driver when array-type data of various sizes had to be moved in & out. SO WE WILL HAVE TO DEFINE OUR OWN - since we need a reasonable way to provide function defs for the user without having to declare types with various sizes. these macros allow using a direct byte count as an argument, rather than a type for the 'sizeof' operator inside the macro */ #include /* include _IOx macro definitions */ #ifndef _IORN #define _IORN(x,y,t) (IOC_OUT|(((t)&IOCPARM_MASK)<<16)|((x)<<8)|y) #endif #ifndef _IOWN #define _IOWN(x,y,t) (IOC_IN|(((t)&IOCPARM_MASK)<<16)|((x)<<8)|y) #endif /* dev_reset and stream on & off don't affect other latched function bits*/ #define IHCPIO_DEV_RESET _IO('H',0) /* reset attached device */ /* sets & resets latched reset bit */ #define IHCPIO_SET_CONFIG _IOW('H',1,int) /* NO_OP for this drive (ignore busy, speed selection for Sbus) */ #define IHCPIO_SET_DMATIME _IOW('H',2,int) /* set dma timeout to arg secs */ #define IHCPIO_SET_FIFOTIME _IOW('H',3,int) /* set wait for ready timeout in seconds */ #define IHCPIO_GET_REGS _IORN('H',4,44) /* puts all regs in arg array */ /* returns all board registers. the residual count from the most recent write call is returned in arg[2] to emulate the Sbus card's range counter - for programs that use this value after a timeout to re-start a write. we probably should have returned resid in the write call - but we defined a timeout as an error - so we are stuck with this if we want to preserve complete compatibility (as much as possible). the board's registers are all byte-wide. each value is returned in a 32 bit longword in the following order: (u_long larg[11]) arg array this driver Sbus driver larg[0] = 0 DMAIO CSR larg[1] = 0 DMAIO ADD larg[2] = residual count from prev. write DMAIO RANGE larg[3] = latched functions LATCHED FUNCTIONS larg[4] = interface status INTERFACE STATUS larg[5] = diagnostic data DEVICE STATUS larg[6] = device status larg[7] = switches larg[8] = 0 (pad) larg[9] = modes larg[10]= 0 (pad) */ #define IHCPIO_GET_STATUS _IOR('H',5,int) /* returns FORMATTED device */ /* status - not like dump regs */ #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,int) /* gets board type */ #define IHCPIO_VERS_DIFF 0x000000A0 #define IHCPIO_VERS_TTL 0x00000060 #define IHCPIO_CENT 0x000000C0 #define IHCPIO_DP_DIFF 0x00000080 /* '97 only */ #define IHCPIO_DP_TTL 0x00000040 /* '97 only */ #define IHCPIO_SET_VMODE _IOW('H',7,int) /* sets print/plot, spp - LEAVES*/ /* READY FF ON */ #define IHCPIO_SET_VMODEX _IOW('H',8,int) /* same as above - kept for compatibility */ #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,int) /* pulse commands to versatec */ /* all wait for ready following command */ #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 !!! */ /* sends char array in ARG to */ /* device. waits for ready after*/ /* each byte is transferred. if */ /* caller tries to send more */ /* 255 bytes, or if fifo becomes*/ /* full during transfers. */ #define IHCPIO_RDY_WAIT _IO('H',11) /* waits for device and interface ready */ #define IHCPIO_HALF_WAIT _IO('H',12) /* same as rdy_wait - compatibility call */ #define IHCPIO_STREAM_ON _IO('H',13) /* turns on data streaming */ #define IHCPIO_STREAM_OFF _IO('H',14) /* turns off data streaming */ #define IHCPIO_GET_FLAGS _IOR('H',15,int) /* returns unit's "flags" word */ /* fron driver's unit array */ #define IHCP_DMA_WAIT 0x80000000 /* waiting for dma end */ #define IHCP_RDY_WAIT 0x40000000 /* waiting for rdy & fifo */ #define IHCP_HALF_WAIT 0x20000000 /* waitint for fifo