BSD 4_3 development
[unix-history] / usr / contrib / kermit / ckuv7.hlp
CommitLineData
ee2abe03
C
1Date: Fri, 17 May 85 18:53:43 CDT
2From: Gregg Wonderly <gregg@okstate.csnet>
3Subject: Additional C-Kermit Implementation Notes for Version 7 UNIX
4
5 The Version 7 implementation takes advantage of some information present
6in the UNIX kernal to obtain the count of characters available for input from
7a particular file descriptor. The function initrawq() is used to obtain the
8kernal address of this value. It is a structure value that is associated with
9the clist for the file descriptor passed. The struture member is the "rawq"
10count of characters available. The include file <sys/clist.h> on our system
11shows this value as the first "int" in the structure. The operations in
12initrawq() cause the child process to "block", trying to read from the "tty"
13file descriptor. Then, by looking through the "proc" structures, we find the
14proper process, and get its "wchan" pointer. This is a pointer to the clist
15in question, in the kernal memory.
16
17 The "wchan" address can then be used as an offset by lseek to select the
18proper address in the kernal (/dev/kmem) to read from. By reading the first
19"int" at this address, we obtain a count of the characters available on the
20raw input queue.
21
22 The MAKE variables PROC, NPROCNAME, BOOTNAME, are necessary to get around
23different naming conventions across systems. The variable PROC is the name
24given to the process structure array on your system. The include file <sys/
25proc.h> (or some facsimile) should contain a declaration of the form:
26
27 extern struct proc *proc;
28or
29 extern struct proc proc[];
30
31The name of the pointer/array, is what you are concerned with. It may be
32something like "_proc", "proc", or some deriviation. You should define
33the MAKE variable PROC to this string, whatever it may be. On our system,
34I use "PROC=proc". If your definition is for an array, then you should define
35the MAKE variable DIRECT to be "-DDIRECT", as it is in the MAKEFILE. If your
36definition is for a pointer to the array, then you should remove the definition
37of DIRECT, so the the line reads "DIRECT=" (no value here). This is necessary
38for the routine to properly locate the "proc" array. If you have an array
39declaration, then the call to nlist() will return the address of the array.
40However, if you have a pointer, then nlist() returns the address of the
41pointer. This requires one extra level of dereference to obtain the address of
42the array.
43
44 The same thing applies to the variable NPROCNAME. On our system, this is
45defined as "NPROCNAME=nproc". This should also be declared in <sys/proc.h>
46something like:
47
48 extern int nproc;
49
50This value is the number (Maximum that is) of process entries in the "proc"
51array.
52
53 BOOTNAME is the name of the kernal image on your system. On our system,
54it is "/edition7". On others, it is probably "/unix", or something close.
55The nlist() function uses this file to look for the addresses of the kernal
56variables "proc", and "nproc".