user doing direct I/O

Jay A. Konigsberg jak at sactoh0.UUCP
Sun Jul 29 18:08:00 AEST 1990


>From article <251 at carssdf.UUCP>, by usenet at carssdf.UUCP (John Watson):
> 
>   Is there any way for a user to do direct (INP/OUTP) io to devices
> similar to the printer port without writing a device driver?  These
> instructions normally result in a protection violation.

A lot of people would like to know how to do this. 
It turns out that it can be done on Xenix 2.2.2 and up using an ioctl. Only

The following code works on Xenix 2.3.2 (386), Unix Sys V (3B2) and
several other Unix platforms.
	      ====

The code could use a little cleaning up, but it works as stated.
See termio(7) and ioctl(2) for further information.

--------------------------------------------------------------------------
#include <termio.h>

main()
{
struct	termio	ttyset;
unsigned short	holdvalue;
unsigned char	holdnext;

/* enter raw mode */
ioctl(0, TCGETA, &ttyset);
holdvalue=ttyset.c_lflag;
holdnext=ttyset.c_cc[4];
ttyset.c_cc[4] = (unsigned char)1;
ttyset.c_lflag &= ~ICANON;
ioctl(0, TCSETAW, &ttyset);

/* reset terminal charastics */
ttyset.c_lflag = holdvalue;
ttyset.c_cc[4] = holdnext;
ioctl(0, TCSETAW, &ttyset);
return(0);
}
-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, its worth doing correctly.



More information about the Comp.unix.xenix mailing list