ads - XENIX V/386 async data scope part 3/3

Warren Tucker wht at tridom.uucp
Tue Sep 26 05:43:13 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file x386sel/fixttiocom.c continued
#
CurArch=3
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file x386sel/fixttiocom.c"
sed 's/^X//' << 'SHAR_EOF' >> x386sel/fixttiocom.c
X/*+:EDITS:*/
X/*:07-17-1989-01:51-wht-creation */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
Xchar *lib = "libfix.a";
X
X/* file positions where names needed changing */
X#define PLACE1 0xdcaL
X#define PLACE2 0x1b1cbL
X#define PLACE3 0x1c41bL
X
X/*+-------------------------------------------------------------------------
X	main(argc,argv,envp)
X--------------------------------------------------------------------------*/
Xmain(argc,argv,envp)
Xint argc;
Xchar **argv;
Xchar **envp;
X{
Xint fd = open(lib,O_RDWR,0);
Xunsigned char ch1,ch2,ch3;
Xlong lseek();
X
X	if(fd < 0)
X	{
X		perror(lib);
X		exit(9);
X	}
X
X	if(lseek(fd,PLACE1,0) != PLACE1)
X	{
X		perror("seek1");
X		exit(1);
X	}
X	if(read(fd,&ch1,1) != 1)
X	{
X		perror("read1");
X		exit(1);
X	}
X	printf("char 1 = %02x\n",ch1);
X
X	if(lseek(fd,PLACE2,0) != PLACE2)
X	{
X		perror("seek2");
X		exit(2);
X	}
X	if(read(fd,&ch2,2) != 2)
X	{
X		perror("read2");
X		exit(2);
X	}
X	printf("char 2 = %02x\n",ch2);
X
X
X	if(lseek(fd,PLACE3,0) != PLACE3)
X	{
X		perror("seek3");
X		exit(3);
X	}
X	if(read(fd,&ch3,1) != 1)
X	{
X		perror("read3");
X		exit(3);
X	}
X	printf("char 3 = %02x\n",ch3);
X
X	if((ch1 != 't') || (ch2 != 't') || (ch3 != 't'))
X		exit(8);
X	if(lseek(fd,PLACE1,0) != PLACE1)
X	{
X		perror("seek1");
X		exit(1);
X	}
X	write(fd,"T",1);
X	if(lseek(fd,PLACE2,0) != PLACE2)
X	{
X		perror("seek1");
X		exit(1);
X	}
X	write(fd,"T",1);
X	if(lseek(fd,PLACE3,0) != PLACE3)
X	{
X		perror("seek1");
X		exit(1);
X	}
X	write(fd,"T",1);
X	printf("done\n");
X	close(fd);
X
X	exit(0);
X}	/* end of main */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of fixttiocom.c */
SHAR_EOF
echo "File x386sel/fixttiocom.c is complete"
chmod 0644 x386sel/fixttiocom.c || echo "restore of x386sel/fixttiocom.c fails"
echo "x - extracting x386sel/select-update (Text)"
sed 's/^X//' << 'SHAR_EOF' > x386sel/select-update &&
XSubject: Re: Select(S) in Xenix 386 2.3.2
XNewsgroups: comp.unix.xenix
XKeywords: select, serial, pipes
XReferences: <117 at accsys.acc.uu.no> <172 at prmmbx.UUCP>
X
XIn article <172 at prmmbx.UUCP>, csch at netcs.UUCP (Clemens Schrimpe) writes:
X> ivar at acc.uu.no (Ivar Hosteng) writes:
X> <> I have experienced some problems using the select call in Xenix 386 V2.3.2.
X> <> It does not seems to detect when a pipe gets ready to been read from.
X> This is, because there is no provision to select on pipes!
X> Why? The stuff is almost totally ported 1:1 from the Berkeley code and
X> in BSD pipes should consist of AF_UNIX sockets, on which you can naturally
X> select.
X> I was very angry, when I found this out after hours of digging with adb in
X> the kernel. But I also tried the same on a SUN under SunOS 4.0 and it doesn't
X> work either ... seems to be a common illness ???
X> (I wonder, because the code for that is very simple ... ??? ...)
X> 
X> <> I also 
X> <> have trouble using select on a serial port.  When I do that the input
X> <> turns into garbage.  This does not occur when I use select on the
X> <> multiscreen ttys (tty01-tty12).
X> Hehe - we had just the same!
X> Here is the solution (thanks to my colleague Stefan Koehler, who took one
X> look at my screen, into which I had starred for hours, to find it ...)
X> 
X> Select is implemented by an undocumented ioctl
X> 	(0xFFFF == IOC_SELECT -> [sys/slect.h])
X> which is handled by ttiocom() for all devices using the standard
X> SYS-V linediscipline!
X> 
X> The ioctl-routine for the serial devices [sioioctl()] just calls 
X> ttiocom() [after some undefinable VPIX stuff ???] and
X> if it returns NON-ZERO it calls sioparam(), which adjusts certain
X> parameters and garbles the output!
X> OK so far. Now: The Bug lies in the ttiocom-code within the check
X> for IOC_SELECT. After detecting the IOC_SELECT, the ttiocom calls
X> the select-code and returns NOTHING, which means that if EAX is
X> non-zero (randomly) sioparam() is called and garbles the output.
X> 
X> The Fix: (quick and dirty)
X> Write a routine called "ttiocom", which might look like this:
X> 
X> ttiocom(ttyp, com, arg, flag)
X> struct tty *ttyp;
X> int com, arg, flag;	/* there should be better types for this :-) */
X> {
X> 	if (com == IOC_SELECT)
X> 	{
X> 		ttselect(ttyp, flag);
X> 		return(0);	/*** THIS IS IMPORTANT ***/
X> 	}
X> 	return(Ttiocom(ttyp, com ,arg, flag));
X> }
X> 
X> Compile something like this, then use whatever you have (GNU-Emacs is
X> great in patching strings in binaries) to patch /usr/sys/sys/libsys.a
X> to change the original ttiocom into Ttiocom !
X> Link in your code and -by some magic reason- experience a full blown
X> select on your System V / Xenix machine!!!
X> 
X> Have fun playing around with it -
X> 
X> 	Clemens Schrimpe, netCS Informationstechnik GmbH Berlin
X> --
X> UUCP:		csch at netcs		BITNET:	csch at db0tui6.BITNET
X> ARPA/NSF:	csch at garp.mit.edu	PSI: PSI%45300033047::CSCH
X> PHONE:		+49-30-24 42 37		FAX: +49-30-24 38 00
X> BTX:		0303325016-0003		TELEX: 186672 net d
X
X
SHAR_EOF
chmod 0644 x386sel/select-update || echo "restore of x386sel/select-update fails"
echo "x - extracting x386sel/select.asm (Text)"
sed 's/^X//' << 'SHAR_EOF' > x386sel/select.asm &&
X;  CHK=0x1E37
X;+----------------------------------------------------------
X; select(S)
X;
X;#include <stdio.h>
X;#include <sys/select.h>
X;#include <fcntl.h>
X;
X;main(argc,argv,envp)
X;int argc;
X;char **argv;
X;char **envp;
X;{
X;struct timeval t;
X;int readfds;
X;int fd = open("/dev/null",O_RDONLY,0);
X;
X;	readfds = 1<<fd | 1<<0;
X;
X;	t.tv_sec = 5;
X;	t.tv_usec = 0;
X;
X;	printf("%d\n",select(32,&readfds,0,0,&t));
X;	printf("%08x\n",readfds);
X;	exit(0);
X;}	/* end of main */
X;
X;-----------------------------------------------------------
X
X	title	select
X
X	.386
X
XSYSNUM	equ 	2428h
X
Xextrn	_errno:dword
X
Xpublic  _select
X
X_TEXT	segment  dword use32 public 'CODE'
X	assume   cs: _TEXT
X_select	proc near
X	mov	eax, SYSNUM		; Get system call number.
X
X	;
X	; I don't even pretend to understand masm syntax.  I tried
X	; the following line (and variations) without any success.
X	;
X
X;	call    far 7:0			; Switch to kernel and call SYSNUM.
X
X	;
X	; Don't laugh, it works.
X	;
X
X	db 9ah
X	dw 0,0
X	dw 7
X
X	jb	short _cerror		; below == error.
X
X;	xor	eax, eax		; zero return value (no error).
X	ret				; done.
X
X_cerror:
X	mov	_errno, eax		; Save error code in _errno.
X	mov	eax, -1			; Return -1 (as error).
X	ret				; done.
X
X_select	endp
X
X_TEXT	ends
X
X	end
X; vi: set tabstop=8 :
SHAR_EOF
chmod 0644 x386sel/select.asm || echo "restore of x386sel/select.asm fails"
echo "x - extracting x386sel/select.txt (Text)"
sed 's/^X//' << 'SHAR_EOF' > x386sel/select.txt &&
XNOTE from ...!gatech!emory!tridom!wht:
Xthe following is the mail message I originally received; with
Xa little tinkering, i got the select call to behave as advertised
Xin the BSD manual (my xenix is 386 2.3).  Added it to /lib/386/Slibx.a
Xand all is well for me.  Good luck.
X
X
XFrom emory!gatech!hubcap!ncrcae!ncr-sd!crash!elgar!ag Thu Feb  2 13:04:07 EST 1989
XArticle 4851 of comp.unix.xenix:
XPath: tridom!emory!gatech!hubcap!ncrcae!ncr-sd!crash!elgar!ag
X>From: ag at elgar.UUCP (Keith Gabryelski)
XNewsgroups: comp.unix.xenix
XSubject: select() on SCO XENIX 2.3.
XMessage-ID: <38 at elgar.UUCP>
XDate: 24 Jan 89 04:54:17 GMT
XReply-To: ag at elgar.UUCP (Keith Gabryelski)
XOrganization: Elgar Corporation, San Diego, CA
XLines: 474
X
XA few days ago I was paging through my SCO XENIX 2.3.1 Release Notes
Xand found, on page 44 (section 16), a section describing 4BSD
Xenhancements to the current release of SCO XENIX.
X
Xselect(S) was mentioned specifically.
X
XI checked the rest of the 2.3 manuals to see if there was a clue on
Xhow to access select(); no dice.  I tried my 2.2 dev sys libraries to
Xsee if it had been supported in previous releases and just not
Xmentioned; negative.
X
XI decided to see if I could get select() to work on my system.  And
Xthat is what this article is about.
X
XI checked /xenix and found:
X
X	% nm xenix | grep select
X	nm: xenix: too many symbols to sort		# chuckle
X	0020:00015bec  T _select
X
XBingo!  I also found <sys/select.h> (which has a comment about
Xthe select(2) system call. :-) ).
X
XWhen a system call is made in a C program on a Unix system (eg
Xopen(2)), it actually links in a file from libc.a (/lib/libc.a) (in
Xthis case `open.o') written in assembly that loads a register with a
Xsystem call number and causes an exception to occur.  The `trap'
Xinstruction is used on the 68000, on a vax it's `chmk', and on a 370
Xit's `svc'.  Control is transfered to the kernel which (in the case of
Xthis particular exception) will index the register into a table
X(called the sysent table) to get the address of the actual routine in
Xkernel memory to call (_open).
X
XAt least under SCO XENIX this algorithm is modified somewhat.
X
XWhen a system call is made in a C program on a SCO XENIX system (eg
Xopen(S)), it links in a file from libc.a (/lib/386/Slibc.a) (in this
Xcase `open.o') written in assembly that loads the register `eax' with
Xa system call number and jumps to 7:0 which (a guess) is mapped to an
Xinstruction that switches into supervisory mode and jumps to the
Xroutine ioint (??) in the kernel address space.  The interrupt routine
Xhands the system call number (along with the user given arguments) to
X_trap with figures out what to sysent table to use (there are a few
Xunder SCO XENIX) and does the right thing.
X
XThe _open routine (in libc.a's open.o) would probably look something
Xlike:
X
X;
X; open - open a file for reading or writing
X;
X
X	title	open
X
X	.386
X
XSYSNUM	equ 	5			; open's system call number is `5'.
Xextrn	_errno:dword
X
Xpublic  _open
X
X_TEXT	segment  dword use32 public 'CODE'
X	assume   cs: _TEXT
X_open	proc near
X	mov	eax, SYSNUM		; Get system call number.
X
X	;
X	; I don't even pretend to understand masm syntax.  I tried
X	; the following line (and variations) without any success.
X	;
X
X;	call    far 7:0			; Switch to kernel and call SYSNUM.
X
X	;
X	; Don't laugh, it works.
X	;
X
X	db 9ah
X	dw 0,0
X	dw 7
X
X	jb	short _cerror		; below == error.
X
X	xor	eax, eax		; zero return value (no error).
X	ret				; done.
X
X_cerror:
X	mov	_errno, eax		; Save error code in _errno.
X	mov	eax, -1			; Return -1 (as error).
X	ret				; done.
X
X_open	endp
X
X_TEXT	ends
X
X	end
X
XUnder SCO XENIX the sysent table (struct sysent in <sys/systm.h>) looks
Xsomething like:
X
Xstruct sysent
X{
X    unsigned char  sy_ret;	 /* Type of return value (int, void ...) */
X    unsigned char  sy_arg386;	 /* Number of 386 words args on stack */
X    unsigned char  sy_nlarg286;	 /* # of 286 large model word args on stack */
X    unsigned char  sy_nmarg286;	 /* 286 Small Middle: max # of args */
X    unsigned	   sy_argmask;	 /* Argument types on stack. */
X	     int   (*sy_call)(); /* System call address in kernel */
X}
X
Xsy_ret is the type return of the value this system call returns.  `0'
Xseems to be INT and `6' is probably void.
X
Xsy_arg386 is the number of words the arguments for this system call
Xtake on the stack.
X
Xsy_nlarg286 and sy_nmarg286 are similar to sy_arg386 but used for
Xdoing 286 stuff.  I don't plan on mentioning the 286 stuff in this
Xarticle that much, it just isn't interesting to me.
X
Xsy_argmask is the type of args on the stack using the following table:
X
XNUM | SYMBOL  | 386 | 286L | EXPLANATION
X 0  |         |     |      | Arg not used.
X 1  | DATAP   |	 2  |  1   | Arg is a data pointer; seg + address
X 2  | TEXTP   |	 2  |  1   | Arg is a text pointer; seg + address
X 3  | CONST   |	 1  |  1   | Arg is an int-sized constant 
X 4  | UCONST  |	 1  |  1   | Arg is an unsigned int-sized constant
X 5  | LCONST  |  1  |  1   | Arg is a long-sized constant
X 6  | FDATAP  |	 1  |  1   | Arg is FAR data pointer.
X 7  | SODATAP |  2  |      | 386: 32-bit offset.
X    |         |     |  1   | 286: low word is 16 bit data pointer offset,
X    |         |	    |      |	  high word is 16 bit selector.
X 8  | SOTEXTP |  2  |      | 386: 32-bit offset.
X    |         |     |  1   | 286: low word is 16 bit text pointer offset,
X    |         |	    |      |	  high word is 16 bit selector.
X
XEach nybble in sy_argmask represents one argument passed to the system
Xcall.  Bits 0-3 represent arg one; 4-7 arg two; 8-12 arg three; etc.
XA total of eight arguments (4 bits times 8 args = 32 bits in an int)
Xcan be passed to a function (although MASK, a macro used to make
Xsysent's sy_argmask field is limited to six arguments).
X
XNUM is the number (put in each nybble) represented by the SYMBOL (in
X<sys/systm.h>) that corresponds to the arg type EXPLANATION and takes
X[386|286] (depending on the model you are using) words on the user
Xstack.
X
XSo, for the open() system call: sy_argmask is 0x00000331 and sy_arg386
Xis 0x04.
X
X	open(char *path, int oflag, int mode);
X             ^^^^^^      ^^^        ^^^
X             DATAP       CONST      CONST
X
Xsy_call is the pointer to the function in kernel memory that should
Xhandle this system call request.
X
XThe sysent table on my system looks something like:
X
XSyscal Num | ret| 386| L  | SM |    Arg Types    | System Call 
Xsysent:
X    00     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _nosys
X    01     | 00 | 02 | 01 | 05 | 0 0 0 0 0 0 0 1 | _rexit
X    02     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _fork	
X    03     | 00 | 04 | 03 | 03 | 0 0 0 0 0 4 1 3 | _read	
X    04     | 00 | 04 | 03 | 03 | 0 0 0 0 0 4 1 3 | _write
X    05     | 00 | 04 | 03 | 03 | 0 0 0 0 0 3 3 1 | _open	
X    06     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _close
X    07     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _wait	
X    08     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 1 | _creat	
X    09     | 00 | 04 | 02 | 03 | 0 0 0 0 0 0 1 1 | _link	
X    0a     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _unlink	
X    0b     | 00 | 04 | 02 | 03 | 0 0 0 0 0 0 1 1 | _exec
X    0c     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _chdir	
X    0d     | 00 | 00 | 00 | 05 | 0 0 0 0 0 0 0 0 | _gtime
X    0e     | 00 | 04 | 03 | 03 | 0 0 0 0 0 3 3 1 | _mknod       
X    0f     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 1 | _chmod       
X    10     | 00 | 04 | 03 | 03 | 0 0 0 0 0 3 3 1 | _chown       
X    11     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 7 | _brk
X    12     | 00 | 04 | 02 | 03 | 0 0 0 0 0 0 1 1 | _stat
X    13     | 00 | 04 | 03 | 05 | 0 0 0 0 0 3 5 3 | _seek 
X    14     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _getpid      
X    15     | 00 | 05 | 03 | 03 | 0 0 0 0 0 3 1 1 | _smount      
X    16     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _sumount     
X    17     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 4 | _setuid      
X    18     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _getuid      
X    19     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 5 | _stime       
X    1a     | 00 | 05 | 04 | 03 | 0 0 0 0 3 1 3 3 | _ptrace      
X    1b     | 00 | 01 | 01 | 04 | 0 0 0 0 0 0 0 3 | _alarm       
X    1c     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 1 3 | _fstat       
X    1d     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _pause       
X    1e     | 00 | 04 | 02 | 03 | 0 0 0 0 0 0 1 1 | _utime       
X    1f     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 1 3 | _stty        
X    20     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 1 3 | _gtty        
X    21     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 1 | _saccess     
X    22     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _nice        
X    23     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 |
X    24     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _sync        
X    25     | 00 | 02 | 02 | 03 | 0 0 0 0 0 0 3 3 | _kill        
X    26     | 00 | 00 | 01 | 00 | 0 0 0 0 0 0 0 0 |              
X    27     | 00 | 00 | 02 | 00 | 0 0 0 0 0 0 0 0 |              
X    28     | 00 | 00 | 03 | 00 | 0 0 0 0 0 0 0 0 |              
X    29     | 00 | 02 | 02 | 03 | 0 0 0 0 0 0 3 3 | _dup         
X    2a     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _pipe        
X    2b     | 00 | 02 | 01 | 05 | 0 0 0 0 0 0 0 1 | _times       
X    2c     | 06 | 08 | 05 | 03 | 0 0 0 1 4 8 4 1 | _profil      
X    2d     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _lock        
X    2e     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 4 | _setgid      
X    2f     | 00 | 00 | 00 | 03 | 0 0 0 0 0 0 0 0 | _getgid      
X    30     | 00 | 03 | 02 | 02 | 0 0 0 0 0 0 2 3 | _ssig        
X    31     | 00 | 00 | 01 | 03 | 0 0 0 0 0 0 0 3 | _msgsys      
X    32     | 06 | 07 | 04 | 03 | 0 0 0 0 5 5 1 3 | _sysi86      
X    33     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _sysacct     
X    34     | 00 | 00 | 01 | 06 | 0 0 0 0 0 0 0 3 | _shmsys      
X    35     | 00 | 00 | 01 | 03 | 0 0 0 0 0 0 0 3 | _semsys      
X    36     | 00 | 04 | 03 | 03 | 0 0 0 0 0 7 3 3 | _ioctl       
X    37     | 00 | 00 | 04 | 00 | 0 0 0 0 0 0 0 0 |              
X    38     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    39     | 00 | 00 | 05 | 00 | 0 0 0 0 0 0 0 0 |              
X    3a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    3b     | 00 | 06 | 03 | 03 | 0 0 0 0 0 1 1 1 | _exece       
X    3c     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _umask       
X    3d     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _chroot      
X    3e     | 00 | 00 | 06 | 00 | 0 0 0 0 0 0 0 0 |              
X    3f     | 00 | 00 | 07 | 00 | 0 0 0 0 0 0 0 0 |              
X    40     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    41     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    42     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    43     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    44     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    45     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    46     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    47     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    48     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    49     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4b     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4c     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4d     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4e     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    4f     | 00 | 00 | 08 | 00 | 0 0 0 0 0 0 0 0 |              
X    50     | 00 | 00 | 09 | 00 | 0 0 0 0 0 0 0 0 |              
X    51     | 00 | 04 | 03 | 03 | 0 0 0 0 0 4 1 3 | _getdents    
X    52     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    53     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    54     | 00 | 00 | 0a | 00 | 0 0 0 0 0 0 0 0 |              
X    55     | 00 | 06 | 04 | 03 | 0 0 0 0 3 1 1 3 | _getmsg      
X    56     | 00 | 06 | 04 | 03 | 0 0 0 0 3 1 1 3 | _putmsg      
X    57     | 00 | 05 | 03 | 03 | 0 0 0 0 0 3 5 1 | _poll        
X    58     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    59     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5b     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5c     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5d     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5e     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    5f     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    60     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    61     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    62     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    63     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys       
X    64     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys
X    65     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    66     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    67     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    68     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    69     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6b     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6c     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6d     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6e     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    6f     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    70     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    71     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    72     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    73     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    74     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    75     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    76     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    77     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    78     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    79     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7b     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7c     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7d     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7e     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys      
X    7f     | 00 | 05 | 05 | 0a | 0 0 0 0 0 0 0 0 | _clocal     
X
X_v7sysent:
X
X    00     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 |
X    01     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _ftime   
X    02     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    03     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nullsys 
X    04     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    05     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    06     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    07     | 00 | 05 | 05 | 0a | 0 0 0 0 0 0 0 0 | _clocal  
X    08     | 00 | 00 | 00 | 08 | 0 0 0 0 0 0 0 0 | _cxenix  
X    09     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    0a     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    0b     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    
X_s3sysent:
X    01     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 |
X    02     | 00 | 06 | 04 | 03 | 0 0 0 0 3 3 1 1 | _statfs   
X    03     | 00 | 05 | 04 | 03 | 0 0 0 0 3 3 1 3 | _fstatfs  
X    04     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _setpgrp  
X    05     | 00 | 00 | 00 | 08 | 0 0 0 0 0 0 0 0 | _cxenix   
X    06     | 00 | 04 | 03 | 03 | 0 0 0 0 0 1 3 3 | _uadmin   
X    07     | 00 | 00 | 00 | 09 | 0 0 0 0 0 0 0 0 | _utssys   
X    08     | 00 | 03 | 03 | 03 | 0 0 0 0 0 3 3 3 | _fcntl    
X    09     | 00 | 03 | 02 | 05 | 0 0 0 0 0 0 5 3 | _ulimit   
X    0a     | 00 | 00 | 01 | 03 | 0 0 0 0 0 0 0 1 | _rmdir    
X    0b     | 00 | 00 | 02 | 03 | 0 0 0 0 0 0 3 1 | _mkdir    
X    0c     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys    
X    
X_svidsysent:
X
X    01     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 |
X    02     | 00 | 06 | 04 | 03 | 0 0 0 0 3 3 1 1 | _statfs  
X    03     | 00 | 05 | 04 | 03 | 0 0 0 0 3 3 1 3 | _fstatfs 
X    04     | 00 | 00 | 01 | 03 | 0 0 0 0 0 0 0 3 | _setpgrp 
X    05     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys   
X    06     | 00 | 00 | 03 | 03 | 0 0 0 0 0 1 3 3 | _uadmin  
X    07     | 00 | 00 | 00 | 09 | 0 0 0 0 0 0 0 0 | _utssys  
X    08     | 00 | 00 | 03 | 03 | 0 0 0 0 0 3 3 3 | _fcntl   
X    09     | 00 | 00 | 02 | 05 | 0 0 0 0 0 0 5 3 | _ulimit  
X    0a     | 00 | 00 | 01 | 03 | 0 0 0 0 0 0 0 1 | _rmdir   
X    0b     | 00 | 00 | 02 | 03 | 0 0 0 0 0 0 3 1 | _mkdir   
X    0c     | 00 | 00 | 03 | 03 | 0 0 0 0 0 0 0 0 | _nosys   
X
X_clentry: used for oem CLOCAL routines.  Empty on my system.
X
X_cxentry: used for SCO added stuff.
X
X    00     | 00 | 05 | 03 | 03 | 0 0 0 0 0 4 7 1 | _shutdown
X    01     | 00 | 04 | 03 | 03 | 0 0 0 0 0 7 3 3 | _locking
X    02     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 1 | _creatsem
X    03     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _opensem
X    04     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _sigsem
X    05     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _waitsem
X    06     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _nbwaitsem
X    07     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 3 | _rdchk
X    08     | 00 | 01 | 01 | 03 | 0 0 0 0 0 0 0 4 | _stkgrow
X    09     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys
X    0a     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 5 3 | _chsize
X    0b     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 1 | _ftime
X    0c     | 00 | 02 | 01 | 05 | 0 0 0 0 0 0 0 5 | _nap
X    0d     | 00 | 05 | 04 | 01 | 0 0 0 0 3 4 3 1 | _sdget
X    0e     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 7 | _sdfree
X    0f     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 7 | _sdenter
X    10     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 7 | _sdleave
X    11     | 00 | 02 | 01 | 03 | 0 0 0 0 0 0 0 7 | _sdgetv
X    12     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 7 | _sdwaitv
X    13     | 00 | 05 | 03 | 01 | 0 0 0 0 0 7 5 3 | _brkctl
X    14     | 00 | 00 | 00 | 00 | 0 0 0 0 0 0 0 0 | _nosys
X    15     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 1 3 | _nfs_sys
X    16     | 00 | 04 | 03 | 03 | 0 0 0 0 0 1 3 3 | _msgctl
X    17     | 00 | 03 | 02 | 03 | 0 0 0 0 0 0 3 5 | _msgget
X    18     | 00 | 05 | 04 | 03 | 0 0 0 0 3 3 1 3 | _msgsnd
X    19     | 06 | 07 | 05 | 03 | 0 0 0 3 5 3 1 3 | _msgrcv
X    1a     | 00 | 05 | 04 | 03 | 0 0 0 0 7 3 4 3 | _semctl
X    1b     | 00 | 04 | 03 | 03 | 0 0 0 0 0 3 3 5 | _semget
X    1c     | 00 | 04 | 03 | 03 | 0 0 0 0 0 4 1 3 | _semop
X    1d     | 00 | 04 | 03 | 03 | 0 0 0 0 0 1 3 3 | _shmctl
X    1e     | 00 | 04 | 03 | 03 | 0 0 0 0 0 3 4 5 | _shmget
X    1f     | 00 | 04 | 03 | 06 | 0 0 0 0 0 3 7 3 | _shmat
X    20     | 00 | 04 | 03 | 03 | 0 0 0 0 0 1 3 3 | _proctl
X    21     | 00 | 03 | 00 | 06 | 0 0 0 0 0 0 3 7 | _execseg
X    22     | 00 | 02 | 00 | 03 | 0 0 0 0 0 0 0 7 | _unexecseg
X    23     | 00 | 00 | 03 | 03 | 0 0 0 0 0 5 5 1 | _swapon
X    24     | 00 | 09 | 05 | 03 | 0 0 0 1 1 1 1 3 | _select
X
XI couldn't really figure out how uadmin() was accessed.  libc's
Xuadmin.o links in a routine that calls system call 0x37.  Hmmm...
X
XThe _cxentry is accessed by (documented in the programmer's reference
Xunder System Calls) setting a bit in the system call number.  It seems
Xas though it actually shifts the system call number up half a word and
Xputs 0x28 in the low order halfword.
X
XNow we see that select() exists as a cxenix function (number 0x24),
X
XThere is also poll(), putmsg(), and getmsg() -- streams stuff.
XSince the tty device is not a streams device (actually it looks as if
Xthe streams stuff has been nulled out -- look at the master file for
Xmore information) it is highly unlikely that these routines will do
Xanything useful.  Infact, they don't.  Change the SYSNUM (and symbols)
Xin the example open.s above to their appropriate values to try out the
Xstreams routines.
X
Xselect.s looks something like:
X
X; select
X;
X;
X;
X
X	title	select
X
X	.386
X
XSYSNUM	equ 	2428h
X
Xextrn	_errno:dword
X
Xpublic  _select
X
X_TEXT	segment  dword use32 public 'CODE'
X	assume   cs: _TEXT
X_select	proc near
X	mov	eax, SYSNUM		; Get system call number.
X
X	;
X	; I don't even pretend to understand masm syntax.  I tried
X	; the following line (and variations) without any success.
X	;
X
X;	call    far 7:0			; Switch to kernel and call SYSNUM.
X
X	;
X	; Don't laugh, it works.
X	;
X
X	db 9ah
X	dw 0,0
X	dw 7
X
X	jb	short _cerror		; below == error.
X
X	xor	eax, eax		; zero return value (no error).
X	ret				; done.
X
X_cerror:
X	mov	_errno, eax		; Save error code in _errno.
X	mov	eax, -1			; Return -1 (as error).
X	ret				; done.
X
X_select	endp
X
X_TEXT	ends
X
X	end
X
XThere is a header file you'll need in <sys/select.h> which has some
Xinformation in it.
X
XA Synopsis of the SCO XENIX implementation:
X
X	#include <sys/select.h>
X
X	nfds = select(width readfds, writefds, exceptfds, timeout)
X	int width, *readfds, *writefds, *exceptfds;
X	struct timeval *timeout;  /* timeval is a pointer to a structure */
X
XI tested select() and found it to be half way implemented.  It seems
Xas if there must be some extra field in struct cdevsw <sys/conf.h>.
X
XSo, I guess I wait 'til 3.2.
X
XPax, Keith
X
XPs, FYI.
X
XPps, if I made a mistake in my description of system call handling on
XSCO XENIX or what not, please correct me.
X
XPpps, `call far 7:0' seems really reasonable to me.
X-- 
Xag at elgar.CTS.COM         Keith Gabryelski          ...!{ucsd, crash}!elgar!ag
X
X
SHAR_EOF
chmod 0644 x386sel/select.txt || echo "restore of x386sel/select.txt fails"
echo "x - extracting x386sel/ttiocom.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > x386sel/ttiocom.c &&
X
X#include <sys/types.h>
X#include <sys/tty.h>
X#include <sys/select.h>
X
Xttiocom(ttyp, com, arg, flag)
Xstruct tty *ttyp;
Xint com, arg, flag;     /* there should be better types for this :-) */
X{
X        if (com == IOC_SELECT)
X        {
X                ttselect(ttyp, flag);
X                return(0);      /*** THIS IS IMPORTANT ***/
X        }
X        return(Ttiocom(ttyp, com ,arg, flag));
X}
X
SHAR_EOF
chmod 0644 x386sel/ttiocom.c || echo "restore of x386sel/ttiocom.c fails"
echo "x - extracting zgcc (Text)"
sed 's/^X//' << 'SHAR_EOF' > zgcc &&
X#!/bin/csh
X#zgcc -- build prototyping "LINT_ARGS"
Xecho C sources in $1';' result file $2
Xrm -f zg.t
Xforeach i(`cat $1`)
Xcc -DXENIX -DBUILDING_LINT_ARGS -Zg $argv[3-] $i > zg1.t
Xsort zg1.t > zg2.t
Xecho '/*' $i '*/' >> zg.t
Xcat zg2.t >> zg.t
Xend
Xafterlint zg.t $2
Xrm -f zg.t zg?.t
Xecho Output in $2
SHAR_EOF
chmod 0755 zgcc || echo "restore of zgcc fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0
-- 
-------------------------------------------------------------------
Warren Tucker, Tridom Corporation       ...!gatech!emory!tridom!wht 
"Might as well be frank, monsieur.  It would take a miracle to get
you out of Casablanca and the Germans have outlawed miracles."



More information about the Alt.sources mailing list