Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!ucsd!pacbell.com!pacbell!sactoh0!jak From: jak@sactoh0.UUCP (Jay A. Konigsberg) Newsgroups: comp.unix.xenix Subject: Re: user doing direct I/O Message-ID: <3612@sactoh0.UUCP> Date: 29 Jul 90 08:08:00 GMT References: <251@carssdf.UUCP> <1990Jul26.232311.21450@metro.ucc.su.OZ.AU> <1990Jul27.103445.703@bbt.se> Reply-To: jak@sactoh0.UUCP (Jay A. Konigsberg) Organization: SAC-UNIX, Sacramento, Ca. Lines: 43 From article <251@carssdf.UUCP>, by usenet@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 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.