home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Documentation / v7_regen.txt < prev    next >
Encoding:
Text File  |  1996-10-22  |  19.1 KB  |  595 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                 RReeggeenneerraattiinngg SSyysstteemm SSooffttwwaarree
  11.  
  12.                       _C_h_a_r_l_e_s _B_. _H_a_l_e_y
  13.                      _D_e_n_n_i_s_. _M_. _R_i_t_c_h_i_e
  14.  
  15.  
  16. IInnttrroodduuccttiioonn
  17.  
  18.      This document discusses how to assemble or compile var-
  19. ious parts of the UNIX(R) system software.  This may be nec-
  20. essary  because a command or library is accidentally deleted
  21. or otherwise destroyed; also, it may be desirable to install
  22. a  modified  version  of some command or library routine.  A
  23. few commands depend to some degree on the current configura-
  24. tion  of the system; thus in any new system modifications to
  25. some commands are advisable.  Most of the  likely  modifica-
  26. tions  relate  to the standard disk devices contained in the
  27. system.  For example, the df(1) (`disk  free')  command  has
  28. built into it the names of the standardly present disk stor-
  29. age drives (e.g. `/dev/rf0', `/dev/rp0').   Df(1)  takes  an
  30. argument to indicate which disk to examine, but it is conve-
  31. nient if its default argument is  adjusted  to  reflect  the
  32. ordinarily present devices.  The companion document `Setting
  33. up UNIX' discusses which  commands  are  likely  to  require
  34. changes.
  35.  
  36. WWhheerree CCoommmmaannddss aanndd SSuubbrroouuttiinneess LLiivvee
  37.  
  38.      The source files for commands and subroutines reside in
  39. several subdirectories of  the  directory  /usr/src.   These
  40. subdirectories, and a general description of their contents,
  41. are
  42.  
  43. cmd         Source files for commands.
  44.  
  45. libc/stdio  Source files making up the `standard  i/o  pack-
  46.             age'.
  47.  
  48. libc/sys    Source files for the C system call interfaces.
  49.  
  50. libc/gen    Source  files for most of the remaining routines
  51.             described in section 3 of the manual.
  52.  
  53. libc/crt    Source files making up  the  C  runtime  support
  54.             package,  as in call save-return and long arith-
  55.             metic.
  56.  
  57. libc/csu    Source for the C startup routines.
  58.  
  59. games       Source for (some of) the games.  No  great  care
  60.             has  been taken to try to make it obvious how to
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                              -2-
  71.  
  72.  
  73.             compile these; treat it as a game.
  74.  
  75. libF77      Source  for  the  Fortran  77  runtime  library,
  76.             exclusive of IO.
  77.  
  78. libI77      Source for the Fortran 77 IO runtime routines.
  79.  
  80. libdbm      Source  for  the `data-base manager' package _d_b_m
  81.             (3).
  82.  
  83. libfpsim    Source for the floating-point simulator routine.
  84.  
  85. libm        Source for the mathematical library.
  86.  
  87. libplot     Source for plotting routines.
  88.  
  89. CCoommmmaannddss
  90.  
  91.      The  regeneration  of most commands is straightforward.
  92. The `cmd' directory will contain either a  source  file  for
  93. the  command  or  a subdirectory containing the set of files
  94. that make up the command.  If it is a single file  the  com-
  95. mand
  96.  
  97.      cd /usr/src/cmd
  98.      cmake cmd_name
  99.  
  100. suffices. (Cmd_name is the name of the command you are play-
  101. ing with.)  The result of the cmake command will be an  exe-
  102. cutable version.  If you type
  103.  
  104.      cmake -cp cmd_name
  105.  
  106. the  result will be copied to /bin (or perhaps /etc or other
  107. places if appropriate).
  108.  
  109.      If the source files are in a subdirectory there will be
  110. a  `makefile'  (see  make(1))  to  control the regeneration.
  111. After changing to the proper directory (cd(1)) you type  one
  112. of the following:
  113.  
  114. make all    The  program  is  compiled  and loaded; the exe-
  115.             cutable is left in the current directory.
  116.  
  117. make cp     The program is compiled and loaded, and the exe-
  118.             cutable  is installed.  Everything is cleaned up
  119.             afterwards; for example .o files are deleted.
  120.  
  121. make cmp    The program is compiled and loaded, and the exe-
  122.             cutable is compared against the one in /bin.
  123.  
  124.      Some   of  the  makefiles  have  other  options.  Print
  125. (cat(1)) the ones you are interested in to find out.
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                              -3-
  137.  
  138.  
  139. TThhee AAsssseemmbblleerr
  140.  
  141.      The assembler consists of two executable files: /bin/as
  142. and  /lib/as2.   The  first  is  the 0-th pass: it reads the
  143. source program, converts it to an  intermediate  form  in  a
  144. temporary  file  `/tmp/atm0?', and estimates the final loca-
  145. tions of symbols.  It also makes two or three  other  tempo-
  146. rary  files which contain the ordinary symbol table, a table
  147. of temporary symbols (like  1:)  and  possibly  an  overflow
  148. intermediate file.  The program /lib/as2 acts as an ordinary
  149. multiple pass assembler with input taken from the files pro-
  150. duced by /bin/as.
  151.  
  152.      The    source    files    for    /bin/as    are   named
  153. `/usr/src/cmd/as/as1?.s' (there are 9 of them); /lib/as2  is
  154. produced  from  the  source  files `/usr/src/cmd/as/as2?.s';
  155. they likewise are 9 in number.  Considerable care should  be
  156. exercised  in  replacing  either component of the assembler.
  157. Remember that if the assembler is lost, the only recourse is
  158. to  replace  it from some backup storage; a broken assembler
  159. cannot assemble itself.
  160.  
  161. TThhee CC CCoommppiilleerr
  162.  
  163.      The C compiler consists of seven  routines:  `/bin/cc',
  164. which  calls the phases of the compiler proper, the compiler
  165. control line expander `/lib/cpp', the assembler (`as'),  and
  166. the  loader  (`ld').   The  phases  of  the  C  compiler are
  167. `/lib/c0',  which  is  the  first  phase  of  the  compiler;
  168. `/lib/c1',  which  is  the second phase of the compiler; and
  169. `/lib/c2', which is the optional third phase optimizer.  The
  170. loss  of  the C compiler is as serious as that of the assem-
  171. bler.
  172.  
  173.      The source for /bin/cc resides in  `/usr/src/cmd/cc.c'.
  174. Its  loss  alone  (or  that of c2) is not fatal.  If needed,
  175. prog.c can be compiled by
  176.  
  177.      /lib/cpp prog.c >temp0
  178.      /lib/c0 temp0 temp1 temp2
  179.      /lib/c1 temp1 temp2 temp3
  180.      as - temp3
  181.      ld -n /lib/crt0.o a.out -lc
  182.  
  183.  
  184.      The source for the compiler proper is in the  directory
  185. /usr/src/cmd/c.  The first phase (/lib/c0) is generated from
  186. the files c00.c, ..., c05.c, which must be compiled by the C
  187. compiler.  There is also c0.h, a header file _i_n_c_l_u_d_e_d by the
  188. C programs of the first phase.  To make a new /lib/c0 use
  189.  
  190.      make c0
  191.  
  192. Before installing the new c0, it is prudent to save the  old
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                              -4-
  203.  
  204.  
  205. one someplace.
  206.  
  207.      The  second  phase of C (/lib/c1) is generated from the
  208. source files c10.c, ..., c13.c, the include-file c1.h, and a
  209. set  of object-code tables combined into table.o.  To gener-
  210. ate a new second phase use
  211.  
  212.      make c1
  213.  
  214. It is likewise prudent to save c1 before  installing  a  new
  215. version.   In  fact in general it is wise to save the object
  216. files for the C compiler so that if disaster strikes  C  can
  217. be  reconstituted without a working version of the compiler.
  218.  
  219.      In a similar manner, the third phase of the C  compiler
  220. (/lib/c2) is made up from the files c20.c and c21.c together
  221. with c2.h.  Its loss is not critical since it is  completely
  222. optional.
  223.  
  224.      The set of tables mentioned above is generated from the
  225. file table.s.  This `.s'  file  is  not  in  fact  assembler
  226. source;  it  must  be converted by use of the _c_v_o_p_t program,
  227. whose source and object are  located  in  the  C  directory.
  228. Normally this is taken care of by make(1). You might want to
  229. look at the makefile to see what it does.
  230.  
  231. UUNNIIXX
  232.  
  233.      The source and object programs for  UNIX  are  kept  in
  234. four  subdirectories  of  _/_u_s_r_/_s_y_s_.   In  the subdirectory _h
  235. there are several files ending in  `.h';  these  are  header
  236. files  which are picked up (via `#include ...')  as required
  237. by each system module.  The subdirectory _d_e_v consists mostly
  238. of the device drivers together with a few other things.  The
  239. subdirectory _s_y_s is the rest of the system.  There are files
  240. of  the  form LIBx in the directories sys and dev. These are
  241. archives (ar(1)) which contain the object  versions  of  the
  242. routines in the directory.
  243.  
  244.      Subdirectory  _c_o_n_f  contains  the  files  which control
  245. device configuration of the system.  _L_._s specifies the  con-
  246. tents  of  the  interrupt  vectors;  _c_._c contains the tables
  247. which relate device numbers to handler  routines.   A  third
  248. file,  _m_c_h_._s,  contains all the machine-language code in the
  249. system.  A fourth file, _m_c_h_0_._s, is  generated  by  mkconf(1)
  250. and  contains  flags  indicating  what sort of tape drive is
  251. available for taking crash dumps.
  252.  
  253.      There are two ways to recreate the system. Use
  254.  
  255.      cd /usr/sys/conf
  256.      make unix
  257.  
  258. if the libraries  /usr/sys/dev/LIB2  and  /usr/sys/sys/LIB1,
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                              -5-
  269.  
  270.  
  271. and also c.o and l.o, are correct.  Use
  272.  
  273.      cd /usr/sys/conf
  274.      make all
  275.  
  276. to  recompile  everything  and  recreate  the libraries from
  277. scratch.   This  is  needed,  for  example,  when  a  header
  278. included  in  several source files is changed.  See `Setting
  279. Up UNIX' for other information about configuration and such.
  280.  
  281.      When the make is done, the new system is present in the
  282. current directory as `unix'.  It  should  be  tested  before
  283. destroying  the currently running `/unix', this is best done
  284. by doing something like
  285.  
  286.      mv /unix /ounix
  287.      mv unix /unix
  288.  
  289. If the new system doesn't work, you can still  boot  `ounix'
  290. and come up (see boot(8)).  When you have satisfied yourself
  291. that the new system works, remove /ounix.
  292.  
  293.      To install a new device driver, compile it and  put  it
  294. into  its  library.  The best way to put it into the library
  295. is to use the command
  296.  
  297.      ar uv LIB2 x.o
  298.  
  299. where x is the routine you just compiled.  (All  the  device
  300. drivers  distributed  with  the  system  are  already in the
  301. library.)
  302.  
  303.      Next, the device's interrupt vector must be entered  in
  304. l.s.    This   is  probably  already  done  by  the  routine
  305. mkconf(1), but if the device is esoteric or nonstandard  you
  306. will  have  to massage l.s by hand.  This involves placing a
  307. pointer to a callout routine and the device's priority level
  308. in  the vector.  Use some other device (like the console) as
  309. a guide.  Notice that the entries in l.s must be in order as
  310. the  assembler  does  not permit moving the location counter
  311. `.' backwards.  The assembler also does not permit  assigna-
  312. tion  of  an absolute number to `.', which is the reason for
  313. the `. = ZERO+100' subterfuge.  If a constant  smaller  than
  314. 16(10)  is  added to the priority level, this number will be
  315. available as the first argument of  the  interrupt  routine.
  316. This  stratagem  is  used when several similar devices share
  317. the same interrupt routine (as in dl11's).
  318.  
  319.      If you have to massage l.s, be sure to add the code  to
  320. actually  transfer  to  the interrupt routine. Again use the
  321. console as a guide. The apparent strangeness of this code is
  322. due  to  running the kernel in separate I&D space.  The _c_a_l_l
  323. routine saves registers as required and prepares  a  C-style
  324. call  on  the actual interrupt routine named after the `jmp'
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                              -6-
  335.  
  336.  
  337. instruction.  When the routine returns,  _c_a_l_l  restores  the
  338. registers  and  performs  an  rti instruction.  As an aside,
  339. note that external names in C programs  have  an  underscore
  340. (`_') prepended to them.
  341.  
  342.      The second step which must be performed to add a device
  343. unknown to mkconf is to add it to  the  configuration  table
  344. /usr/sys/conf/c.c.   This  file  contains two subtables, one
  345. for block-type devices, and one for character-type  devices.
  346. Block  devices  include  disks,  DECtape,  and magtape.  All
  347. other devices are character devices.   A  line  in  each  of
  348. these  tables  gives all the information the system needs to
  349. know about the device handler; the ordinal position  of  the
  350. line  in the table implies its major device number, starting
  351. at 0.
  352.  
  353.      There are four subentries per line in the block  device
  354. table,  which give its open routine, close routine, strategy
  355. routine, and device table.  The open and close routines  may
  356. be  nonexistent,  in which case the name `nulldev' is given;
  357. this routine merely returns.  The strategy routine is called
  358. to do any I/O, and the device table contains status informa-
  359. tion for the device.
  360.  
  361.      For character devices, each line in the table specifies
  362. a  routine  for  open, close, read, and write, and one which
  363. sets and returns device-specific status (used, for  example,
  364. for  stty  and gtty on typewriters).  If there is no open or
  365. close routine, `nulldev' may be given; if there is no  read,
  366. write,  or status routine, `nodev' may be given.  Nodev sets
  367. an error flag and returns.
  368.  
  369.      The final step which must be taken to install a  device
  370. is to make a special file for it.  This is done by mknod(1),
  371. to which you must specify the device class (block or charac-
  372. ter),  major  device number (relative line in the configura-
  373. tion table) and minor device number (which is made available
  374. to the driver at appropriate times).
  375.  
  376.      The  documents  `Setting up Unix' and `The Unix IO sys-
  377. tem' may aid in comprehending these steps.
  378.  
  379. TThhee LLiibbrraarryy lliibbcc..aa
  380.  
  381.      The library /lib/libc.a is where most  of  the  subrou-
  382. tines  described in sections 2 and 3 of the manual are kept.
  383. This library can be remade using the following commands:
  384.  
  385.      cd /usr/src/libc
  386.      sh compall
  387.      sh mklib
  388.      mv libc.a /lib/libc.a
  389.  
  390. If single routines need to be recompiled and replaced, use
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                              -7-
  401.  
  402.  
  403.      cc -c -O x.c
  404.      ar vr /lib/libc.a x.o
  405.      rm x.o
  406.  
  407. The above can also  be  used  to  put  new  items  into  the
  408. library.  See ar(1), lorder(1), and tsort(1).
  409.  
  410.      The  routines in /usr/src/cmd/libc/csu (C start up) are
  411. not in libc.a. These are separately assembled and  put  into
  412. /lib. The commands to do this are
  413.  
  414.      cd /usr/src/libc/csu
  415.      as - x.s
  416.      mv a.out /lib/x
  417.  
  418. where x is the routine you want.
  419.  
  420. OOtthheerr LLiibbrraarriieess
  421.  
  422.      Likewise, the directories containing the source for the
  423. other libraries have files compall (that  recompiles  every-
  424. thing) and mklib (that recreates the library).
  425.  
  426. SSyysstteemm TTuunniinngg
  427.  
  428.      There  are  several  tunable  parameters in the system.
  429. These set the size of various tables and  limits.  They  are
  430. found   in   the   file   /usr/sys/h/param.h   as  manifests
  431. (`#define's).  Their values are rather generous in the  sys-
  432. tem  as distributed.  Our typical maximum number of users is
  433. about 20, but there are many daemon processes.
  434.  
  435.      When any parameter is changed, it is prudent to  recom-
  436. pile the entire system, as discussed above.  A brief discus-
  437. sion of each follows:
  438.  
  439. NBUF        This sets the size of  the  disk  buffer  cache.
  440.             Each buffer is 512 bytes.  This number should be
  441.             around 25 plus NMOUNT, or as big as  can  be  if
  442.             the  above number of buffers cause the system to
  443.             not fit in memory.
  444.  
  445. NFILE       This sets the maximum number of open  files.  An
  446.             entry is made in this table every time a file is
  447.             `opened'  (see  open(2),  creat(2)).   Processes
  448.             share   these   table   entries   across   forks
  449.             (fork(2)). This number should be about the  same
  450.             size as NINODE below. (It can be a bit smaller.)
  451.  
  452. NMOUNT      This indicates the  maximum  number  of  mounted
  453.             file  systems. Make it big enough that you don't
  454.             run out at inconvenient times.
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                              -8-
  467.  
  468.  
  469. MAXMEM      This sets an administrative limit on the  amount
  470.             of  memory  a process may have.  It is set auto-
  471.             matically if the amount of  physical  memory  is
  472.             small, and thus should not need to be changed.
  473.  
  474. MAXUPRC     This  sets  the maximum number of processes that
  475.             any one user can be running  at  any  one  time.
  476.             This should be set just large enough that people
  477.             can get work done but not so large that  a  user
  478.             can  hog all the processes available (usually by
  479.             accident!).
  480.  
  481. NPROC       This sets the maximum number of  processes  that
  482.             can be active.  It depends on the demand pattern
  483.             of the typical user; we seem  to  need  about  8
  484.             times the number of terminals.
  485.  
  486. NINODE      This  sets the size of the inode table. There is
  487.             one entry in the  inode  table  for  every  open
  488.             device,  current  working directory, sticky text
  489.             segment, open file, and  mounted  device.   Note
  490.             that  if  two  users  have  a file open there is
  491.             still only one entry in the inode table. A  rea-
  492.             sonable rule of thumb for the size of this table
  493.             is
  494.  
  495.                  NPROC + NMOUNT + (number of terminals)
  496.  
  497.  
  498. SSIZE       The initial size of a process stack. This may be
  499.             made bigger if commonly run processes have large
  500.             data areas on the stack.
  501.  
  502. SINCR       The size of the stack growth increment.
  503.  
  504. NOFILE      This sets the maximum number of files  that  any
  505.             one process can have open.  20 is plenty.
  506.  
  507. CANBSIZ     This is the size of the typewriter canonicaliza-
  508.             tion buffer. It is in this buffer that erase and
  509.             kill  processing is done. Thus this is the maxi-
  510.             mum size of an input  typewriter  line.  256  is
  511.             usually plenty.
  512.  
  513. CMAPSIZ     The  number of fragments that memory can be bro-
  514.             ken into. This should  be  big  enough  that  it
  515.             never  runs  out.   The  theoretical  maximum is
  516.             twice the number of processes,  but  this  is  a
  517.             vast overestimate in practice.  50 seems enough.
  518.  
  519. SMAPSIZ     Same as CMAPSIZ except for secondary (swap) mem-
  520.             ory.
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                              -9-
  533.  
  534.  
  535. NCALL       This  is the size of the callout table. Callouts
  536.             are entered in this  table  when  some  sort  of
  537.             internal  system timing must be done, as in car-
  538.             riage return delays for  terminals.  The  number
  539.             must  be big enough to handle all such requests.
  540.  
  541. NTEXT       The maximum number of  simultaneously  executing
  542.             pure  programs.  This should be big enough so as
  543.             to not run out of space  under  heavy  load.   A
  544.             reasonable rule of thumb is about
  545.  
  546.                  (number of terminals) + (number of sticky programs)
  547.  
  548.  
  549. NCLIST      The number of clist segments. A clist segment is
  550.             6 characters.  NCLIST should be  big  enough  so
  551.             that  the list doesn't become exhausted when the
  552.             machine  is  busy.  The  characters  that   have
  553.             arrived  from  a  terminal and are waiting to be
  554.             given to a process live here. Thus enough  space
  555.             should  be  left so that every terminal can have
  556.             at least one average line pending (about  30  or
  557.             40 characters).
  558.  
  559. TIMEZONE    The  number  of minutes westward from Greenwich.
  560.             See `Setting Up UNIX'.
  561.  
  562. DSTFLAG     See `Setting Up UNIX' section  on  time  conver-
  563.             sion.
  564.  
  565. MSGBUFS     The maximum number of characters of system error
  566.             messages saved.  This  is  used  as  a  circular
  567.             buffer.
  568.  
  569. NCARGS      The  maximum  number of characters in an exec(2)
  570.             arglist. This number controls how many arguments
  571.             can  be  passed into a process.  5120 is practi-
  572.             cally infinite.
  573.  
  574. HZ          Set to the frequency of the system clock  (e.g.,
  575.             50 for a 50 Hz. clock).
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.