%Date:     Fri, 17 May 85 18:53:43 CDT.From:     Gregg Wonderly <gregg@okstate.csnet>ESubject:  Additional C-Kermit Implementation Notes for Version 7 UNIXM     The Version 7 implementation takes advantage of some information presentMin the UNIX kernal to obtain the count of characters available for input fromLa particular file descriptor.  The function initrawq() is used to obtain theNkernal address of this value.  It is a structure value that is associated withLthe clist for the file descriptor passed.  The struture member is the "rawq"Lcount of characters available.  The include file <sys/clist.h> on our systemHshows this value as the first "int" in the structure.  The operations inLinitrawq() cause the child process to "block", trying to read from the "tty"Mfile descriptor.  Then, by looking through the "proc" structures, we find theLproper process, and get its "wchan" pointer.  This is a pointer to the clist"in question, in the kernal memory.M     The "wchan" address can then be used as an offset by lseek to select theLproper address in the kernal (/dev/kmem) to read from.  By reading the firstK"int" at this address, we obtain a count of the characters available on theraw input queue.N     The MAKE variables PROC, NPROCNAME, BOOTNAME, are necessary to get aroundKdifferent naming conventions across systems.  The variable PROC is the nameLgiven to the process structure array on your system.  The include file <sys/Eproc.h> (or some facsimile) should contain a declaration of the form:     extern struct proc *proc;or     extern struct proc proc[];IThe name of the pointer/array, is what you are concerned with.  It may beGsomething like "_proc", "proc", or some deriviation.  You should defineJthe MAKE variable PROC to this string, whatever it may be.  On our system,NI use "PROC=proc".  If your definition is for an array, then you should defineMthe MAKE variable DIRECT to be "-DDIRECT", as it is in the MAKEFILE.  If yourOdefinition is for a pointer to the array, then you should remove the definitionNof DIRECT, so the the line reads "DIRECT=" (no value here).  This is necessaryJfor the routine to properly locate the "proc" array.  If you have an arrayKdeclaration, then the call to nlist() will return the address of the array.GHowever, if you have a pointer, then nlist() returns the address of theOpointer.  This requires one extra level of dereference to obtain the address of
the array.N     The same thing applies to the variable NPROCNAME.  On our system, this isKdefined as "NPROCNAME=nproc".  This should also be declared in <sys/proc.h>something like:     extern int nproc;KThis value is the number (Maximum that is) of process entries in the "proc"array.M     BOOTNAME is the name of the kernal image on your system.  On our system,Jit is "/edition7".  On others, it is probably "/unix", or something close.KThe nlist() function uses this file to look for the addresses of the kernalvariables "proc", and "nproc".