home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / NetBSD / docs-netbsd / 386BSD-FAQ / BSD-FAQ-part04 < prev    next >
Text File  |  1994-11-27  |  37KB  |  1,001 lines

  1. Archive-name: 386bsd-faq/part4
  2.  
  3. Section 3.    (Kernel Building and Maintenance)
  4.  
  5. 3.0    System Internals
  6.     
  7.     One of the interesting aspects of *BSD is the fact that it comes 
  8.     with the complete source.  This allows you to make changes to the 
  9.     system, recompile, and test out your new ideas.  This section of 
  10.     the FAQ describes many of the different aspects of this endeavor 
  11.     and common problems and pitfalls that are encountered.  Kevin Lahey 
  12.     provided the substantial portion of this section.  You can contact 
  13.     him via E-Mail at (kml@rokkaku.atl.ga.us) or contact Dave Burgess 
  14.     (burgess@cwis.unomaha.edu).
  15.  
  16. 3.1    Kernel
  17.  
  18. 3.1.1    How do I build a kernel?
  19.  
  20.     The kernel can be compiled in a variety of ways to support different 
  21.     devices and configurations.  Compilation is controlled by a config 
  22.     file that specifies the characteristics of the kernel.  A set of 
  23.     different config files is located in /sys/i386/conf or 
  24.     /sys/arch/i386/conf.  The configuration file names are in upper case.
  25.  
  26.     To build a particular kernel (in this example, we use the GENERICISA
  27.     configuration file in NetBSD or FreeBSD):
  28.  
  29.     % cd /sys/i386/conf
  30.     % config GENERICISA
  31.     % cd /sys/compile/GENERICISA
  32.     % make depend
  33.     % make
  34.  
  35.     If you are using 386bsd 0.1, you'll need patch 1 from the patchkit 
  36.     to get the compilation to work, because the version file isn't 
  37.     correctly included in the Makefile.
  38.  
  39.     In NetBSD, since there are multiple architectures supported, there
  40.     is an architecture line in the middle of the path to these files.
  41.     See the build.kernel script in section 3.8 for more information.
  42.  
  43.  
  44. 3.1.2    I want to do one of the following things:
  45.     * add a device not in the distributed kernel (third com
  46.       port, additional disk or tape, line printer driver, etc).
  47.     * use a patch from the net or the patchkit to fix a kernel bug.
  48.     * add another swap device.
  49.     * recompile the kernel to remove extraneous devices so that
  50.       it takes up less space.
  51.     * configure more pseudo-terminals to allow for more xterms
  52.       or network logins.
  53.     
  54.     You're going to have to recompile the kernel after you modify the 
  55.     config file.  See section 3.2 below for more information about the 
  56.     config file in general.
  57.     
  58.  
  59. 3.1.3    I don't have the source distribution -- how can I rebuild the
  60.     kernel?
  61.  
  62.     There are reference sites available, as well as the 'good 
  63.     net-neighbor' policy, whereby you could make arrangements with a 
  64.     net neighbor to use a large local machine as a Network File System, 
  65.     or allow you to compile a new kernel on their machine and transfer it 
  66.     to yours.  If you *still* can't fit it in, you'll have to ftp a 
  67.     compiled kernel from agate in the unofficial/patchkit-old directory 
  68.     or one of the archive sites.  You can also ask for help from 
  69.     comp.os.386bsd.questions if you get stuck and cannot make any headway.
  70.  
  71.  
  72. 3.1.4    Now that I have a kernel, how do I install it?
  73.  
  74.     Your kernel is called /386bsd or /netbsd.  Copy the new kernel from 
  75.     /sys/compile/GENERICISA/386bsd to /, assuming that it is in that 
  76.     directory.  This is relatively straightforward; there are a couple 
  77.     of things to remember, though.  First, if you really screw up the new 
  78.     kernel, you want to have something to fall back on, so be sure to 
  79.     save /386bsd to /386bsd.old before copying in a new kernel.  Second, 
  80.     if you just copy the new kernel over the currently running kernel, 
  81.     funny things can happen.  Be sure to move aside the currently running 
  82.     kernel before copying over the new one.  
  83.  
  84.     There are folks that have reported that overwriting their current 
  85.     kernel has never caused them any real problems.  On the other hand, 
  86.     if the old kernel was working and the new one doesn't, and you have 
  87.     made changes that require that old kernel, it should be available to 
  88.     the system, and saving it to /386bsd.alt or /386bsd.old are reasonable 
  89.     things to do.
  90.  
  91.     If you are really paranoid, you can mount a new fixit floppy and 
  92.     replace its kernel with the one you just built, and then boot from 
  93.     the fixit floppy to make sure everything will work.  This is a 
  94.     pretty good idea if you are making radical changes or if you are 
  95.     unsure about your changes.
  96.   
  97.  
  98. 3.1.5    After installing the patchkit and recompiling the kernel with the
  99.     option "WD8013", I am no longer able to reboot the machine.  A cold
  100.     boot (power on) runs fine, but after a reboot no boot drive is found
  101.     by the BIOS.  Besides having a 16-bit WD/SMC Ethernet card installed
  102.     the machines try to boot using either a Adaptec 1742 or 1542 SCSI
  103.     board to boot from.
  104.  
  105.     This answer was provided by Hellmuth Michaelis (hm@hcshh.hcs.de) and 
  106.     written by Rodney Grimes (rgrimes@acacia).
  107.  
  108.     Remove "option WD8013" from the config files and recompile and
  109.     reinstall the kernel. 
  110.  
  111.     The reason that option WD8013 often causes this reboot problem is 
  112.     this:
  113.     
  114.     There is a requirement that all memory within a 128k bank in the
  115.     0xA0000 to 0xFFFFF region be either 16-bit or 8-bit.  On a cold 
  116.     boot, the WD8013 boards are reset to 8-bit mode, the POST
  117.     (Power On Self Test) passes without error.  386bsd comes up, the 
  118.     if_we.c driver places the WD8013 in 16-bit mode.  Now on a soft boot
  119.     when the BIOS runs some quick POST tests it finds a problem in the 
  120.     0xA000 to 0xF000 region.  You probably get a "beep-beep" when this
  121.     happens.  It means you have a memory size conflict.
  122.     The machine has been mis-configured.
  123.     
  124.       This is a little known fact about 16-bit vs 8-bit option cards.  It
  125.     has caused more than one person to go crazy tracking down what they
  126.     swear is a bug in the program.  It is not, it is a flaw in the design
  127.     of the ISA bus.  The signal MEMCS16- must be returned the same for
  128.     every 128k block of memory:
  129.     
  130.         B0000-CFFFF    Must all be either 8-bit or 16-bit.
  131.         D0000-FFFFF    Must all be either 8-bit or 16-bit.
  132.     
  133.       In your particular configuration (WD8013 @ cc000) I suspect that
  134.     you have another board in the B0000-CFFFFF region that is 8-bit, i.e.
  135.     your Adaptec has an 8-bit BIOS on it!
  136.     
  137.       Try moving the board to the 0xD0000 region and see if it works 
  138.     there, you may still have a problem as many modern system BIOSes are
  139.     now 8-bit.  If your system BIOS is 8-bit, try shadowing the system 
  140.     BIOS region at 0xF0000 to 0xFFFFF, this effectively turns it into 
  141.     a 16-bit BIOS.  
  142.  
  143.       Do not attempt to shadow the WD8013, it well cause you many
  144.     headaches.
  145.     
  146.       As always, works for me, you mileage may vary..
  147.     
  148.  
  149. 3.1.6    My system is complaining about stray interrupt 7.  Is my machine 
  150.     going to explode or anything?
  151.  
  152.     No.  They are caused by lots of things.  They are, as far as
  153.     anyone that should be expected to know about this stuff, harmless.
  154.     There are ramifications on them being there, but for MOST users
  155.     they do not pose a real threat to your operations.  For those of
  156.     you that are doing REALLY interrupt intensive stuff, you may want
  157.     to grab a technical reference and figure out why the 8259 is not
  158.     getting reset correctly.
  159.  
  160.     In spite of the number of times this has come up (and people have
  161.     even referenced this section) there are still at least two 
  162.     questions on the net about this.  A memorable one was a guy who
  163.     was just vehement that the stray int 7 was what was keeping his
  164.     system from booting.  In fact, he went so far as to say that this
  165.     document was practically worthless because I didn't tell him how
  166.     to fix it.  Of course, once he configured his hard drive controller 
  167.     so that it was on the right interrupt, his booting problem went 
  168.     away.  I have said it before and I will say it again.  For MOST 
  169.     users they do not pose a real threat to your operations.
  170.     I have heard of three people (out of at least 2000) that have
  171.     actually have problems so bad that they couldn't proceed.  They
  172.     bought new computers, and the problem went away.
  173.  
  174.     These stray interrupts are caused by something in the PC.  
  175.     I have yet to see a convincing explanation of precisely what,
  176.     but they are definitely caused by something.  There are four
  177.     ways to deal with this problem.
  178.  
  179.     1)  Ignore them.  They are spurious and do not effect the
  180.     operation of your computer.
  181.  
  182.     2)  Implement the lpt driver.  This way, the driver traps 
  183.     (the lpt driver expects IRQ 7) and then quietly discards them.  
  184.     That is why when folks implement the lpt driver the 'problem' 
  185.     goes away.  The computer is taught how to ignore them.
  186.  
  187.     3)  Do what the original 386bsd code did.  Comment out the
  188.     diagnostic and associated code that tries to deal with them so
  189.     you don't see the error message.
  190.  
  191.     4)  Buy a new computer that doesn't cause this problem.   It is a
  192.     known hardware problem with the 8259 being reset incorrectly in
  193.     hardware.
  194.  
  195.     
  196. 3.1.7    I found a bug in the kernel.  How do I report it?
  197.  
  198.     Both NetBSD and FreeBSD include a facility called 'bugfiler'.  
  199.     While the instructions are included in both system, there is 
  200.     still some apparent confusion about when to use (and when to
  201.     NOT use) bugfiler.
  202.  
  203.     Jordan K. Hubbard (jkh@whisker.lotus.ie)  provides us with this
  204.     short article.
  205.  
  206.     To send bug reports, you want to use the sendbug(1) command.
  207.     The entire package for sending and filing these bugs is known 
  208.     as "the bugfiler", which is where the confusion stepped in, 
  209.     but sendbug is definately the command you want to use.
  210.  
  211.     Second, it doesn't take a "net connection" to use sendbug, 
  212.     since all it does is package up your "bug report form" and mail 
  213.     it to us; no direct internet connectivity is required, just mail.
  214.  
  215.     So if you can send internet mail you can use sendbug, or you can 
  216.     also send mail to the `FreeBSD-bugs@freefall.cdrom.com' address 
  217.     (do NOT send it to FreeBSD.cdrom.com since it will BOUNCE, this 
  218.     is not the place to send bugs to, just to ftp stuff from!).
  219.  
  220.     NetBSD has a similar facility, but has a different host for bug 
  221.     reports.
  222.  
  223.  
  224. 3.1.8    Can someone please give a reasonably clear set of instructions 
  225.     as to how to get a "current" version of NetBSD running?
  226.  
  227.     Marc Wandschneider <marcwan@microsoft.com> provided this description
  228.     of what he did to upgrade to the current version of NetBSD:
  229.  
  230.     1. Delete the old source tree, saving what I wanted to (a bunch
  231.     of files moved around, and just unpacking the new one over the old
  232.     will cause some problems)
  233.  
  234.     2. Unpacked the new source tree.
  235.  
  236.     3. ran the following sequence of commands:
  237.  
  238.         cd /usr/src/share/mk; make install
  239.         cd /usr/src/include; make && make install
  240.            setenv LDSTATIC -static
  241.            setenv NOPIC
  242.         cd /usr/src/lib/libc; make && make install
  243.         cd /usr/src/gnu/lib/libmalloc; make && make install
  244.            cd /usr/src/gnu/usr.bin/gas; make && make install
  245.            cd /usr/src/gnu/usr.bin/ld; make && make install
  246.         # You'll probably get some barfage from the above because 
  247.         # ld.so won't build yet.  Ignore it and install ld anyway.
  248.            cd /usr/src/gnu/usr.bin/gcc; make && make install
  249.            unsetenv NOPIC LDSTATIC
  250.            cd /usr/src/lib ; make && make install
  251.            cd /usr/src/gnu/lib ; make && make install
  252.         cd /usr/src/gnu/usr.bin/ld; make && make install
  253.            cd /usr/src; make && make install
  254.  
  255.     At some point during the installation, your system will be 
  256.     fixed enough that many of these steps will no longer be required.
  257.     For example, the new 'make' defines the variables OBJDIR and 
  258.     MACHINE_ARCH for you, so you will not need those  once you get to
  259.     that point.  Until then, the following procedure may suit your
  260.     needs better.
  261.  
  262.         #! /bin/csh
  263.  
  264.         unsetenv NOPIC LDSTATIC
  265.         setenv MACHINE_ARCH i386
  266.         # Pick one of these three setenv lines.
  267.         #  setenv MAKE "make clean "
  268.         #  setenv MAKE "make obj "
  269.             setenv MAKE  
  270.         cd /usr/src/share/mk 
  271.            make install
  272.         cd /usr/src/include 
  273.            $MAKE
  274.            make && make install
  275.         setenv LDSTATIC -static
  276.         setenv NOPIC
  277.         cd /usr/src/usr.bin/make
  278.            $MAKE 
  279.            make && make install
  280.         
  281.         cd /usr/src/usr.bin/rpcgen
  282.            $MAKE 
  283.            make && make install
  284.         
  285.         cd /usr/src/lib/libc 
  286.            $MAKE 
  287.            make && make install
  288.         
  289.         cd /usr/src/gnu/lib/libmalloc
  290.            $MAKE 
  291.            make && make install
  292.         
  293.         cd /usr/src/gnu/usr.bin/gas
  294.            $MAKE 
  295.            make && make install
  296.         
  297.         cd /usr/src/gnu/usr.bin/ld
  298.            $MAKE 
  299.            make && make install
  300.         
  301.         cd /usr/src/gnu/usr.bin/gcc2 
  302.            $MAKE 
  303.            make && make install
  304.         
  305.         #
  306.         unsetenv NOPIC LDSTATIC
  307.         
  308.         cd /usr/src/lib 
  309.            $MAKE 
  310.            make && make install
  311.         
  312.         cd /usr/src/gnu/lib 
  313.            $MAKE 
  314.            make && make install
  315.         
  316.         cd /usr/src/gnu/usr.bin/ld 
  317.            $MAKE 
  318.            make && make install
  319.         
  320.         cd /usr/src 
  321.            make && make install
  322.         
  323.         
  324.     NOTE: At some point, you might very well come across an unresolved
  325.     external __DYNAMIC in crt0.o.  If this happens, edit the makefile
  326.     for crt0.o (lib/csu/i386) and remove the -DDYNAMIC flag)
  327.     make && make install.  Then put the flag back in the makefile
  328.     (but don't rebuild it until the natural order of things dicates
  329.     that it happen)
  330.  
  331.     And Theo Deraadt provides this guidance when you get an error like 
  332.     "init_main.o: Undefined symbol _pdevinit referenced from text segment."
  333.  
  334.     You need to
  335.         (1) install new config
  336.         (2) make clean
  337.         (3) re-config your kernel
  338.     then this goes away
  339.  
  340.  
  341. 3.2    What exactly is this config file, anyway?  What are all of these 
  342.     cryptic notations?
  343.  
  344.     I've annotated the distributed GENERICISA file;  my comments are 
  345.     delineated by the '--' symbols.  
  346.  
  347.     THIS IS NOT A COOK-BOOK.  YOU WILL NEED TO DO THE RESEARCH (LIKE
  348.     LOOKING AT THE 20 OTHER CONFIG FILES) TO SEE WHAT IS CURRENT AND
  349.     WHAT YOU WILL NEED IN YOUR CONFIG FILE.
  350.  
  351.     #
  352.     # GENERICISA -- Generic ISA machine -- distribution floppy
  353.     #
  354. --  BSD can be compiled for different hardware platforms, so it is important to
  355. --  define the hardware types.  386bsd can only be built for 386 or
  356. --  compatible machines, so this is sort of superfluous, but maintains
  357. --  compatibility with standard BSD config files.
  358.     machine        "i386"
  359.     cpu        "i386"
  360. --  The ident describes the machine for which this kernel is to be built.
  361. --  It is usually the system name -- "ROKKAKU", "REF", or whatever.
  362. --  This can be used for conditional compilation, so that kernel changes
  363. --  can be compiled in only for one machine.
  364.     ident        GENERICISA
  365. --  This should indicate the timezone of the system relative the
  366. --  Greenwich.   8 is PST;  4 is EST.  Somebody else might want to discuss
  367. --  this more fully.
  368.     timezone    8 dst
  369. --  maxusers isn't strictly checked;  it is just used to size several
  370. --  system data parameters.
  371.     maxusers    10
  372. --  The options control the conditional compilation of features into the
  373. --  kernel.  The options can be listed all on a line separated by commas.
  374. --  They are #define'ed when the kernel is compiled, so that #ifdef's
  375. --  will work.  An option can be given a value by appending an equals sign
  376. --  and a value (enclosed in double quotes) to the option name.
  377.     
  378. --  Hopefully the names are at least somewhat self-explanatory.  To
  379. --  discover what everything does, you'd have to go through the kernel
  380. --  looking for all of the appropriate #ifdef's.
  381.     
  382. --  [Perhaps somebody else could list the *exact* meanings of these
  383. --  options and some of the other possible options?]
  384.     options        INET,ISOFS,NFS
  385.     options        "COMPAT_43"
  386.     options        "TCP_COMPAT_42"
  387.     
  388. --  The config line controls the location of the root, swap, and dump
  389. --  devices.  Anything not specified is defaulted.  This is where you add
  390. --  support for multiple swap devices.  Just list 'em, separated by 'and'.
  391. --  The config line below identifies the root drive as wd0 and the
  392. --  swap drives as wd0 and as0.  See the section on swap devices in FAQ_02
  393. --  for additional information.
  394.     config        "386bsd"    root on wd0 swap on wd0 and as0
  395. --  A 'controller' is a device or bus controller.  'isa' is obviously for
  396. --  the ISA bus.  'wd0' is for regular disk controllers,  'fd0' is for the
  397. --  floppies, and 'as0' is for SCSI disk controllers.
  398.     controller    isa0
  399. --  The fields work as follows:
  400.     
  401. --  a.  What do you call this device?  
  402. --  b.  What controller is this on?  As you can see, the disk controller
  403. --  talks to the ISA bus, and the disks talk to the disk controller.
  404. --  c.  Where are the registers for the controller mapped into memory?
  405. --  This is #defined in /sys/i386/isa/isa.h.
  406. --  d.  What IRQ is this device set up for?
  407. --  e.  What routine should be called on an interrupt from the device?
  408.     
  409. --             a          b           c             d           e
  410. --            vvv        vvv       vvvvvvv          vv        vvvvvv
  411.     controller    wd0    at isa? port "IO_WD1" bio irq 14 vector wdintr
  412. --  You need a 'disk' entry for every disk on the controller.  In the
  413. --  config file originally shipped with 386bsd, both hard disks were 
  414. --  incorrectly identified as wd0.  Be sure to change the second occurrence 
  415. --  to wd1, as I have done in below.
  416.     disk        wd0    at wd0 drive 0
  417.     disk        wd1    at wd0 drive 1
  418.     
  419.     controller    fd0    at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr
  420.     disk        fd0    at fd0 drive 0
  421.     disk        fd1    at fd0 drive 1
  422.  
  423. --  The 'drq' specifies the channel used for bus-mastering DMA.
  424.     controller    as0    at isa? port 0x330 bio irq 11 drq 5 vector asintr
  425.     disk        as0    at as0 drive 0
  426.     disk        as1    at as0 drive 1
  427.  
  428. --  Define other physical devices.  pc0 is the keyboard, npx0 drives the
  429. --  math coprocessor, and com* controls the com ports.
  430.     device        pc0    at isa? port "IO_KBD" tty irq 1 vector pcrint
  431.     device        npx0    at isa? port "IO_NPX" irq 13 vector npxintr
  432.     device        com1    at isa? port "IO_COM1" tty irq 4 vector comintr
  433.     device        com2    at isa? port "IO_COM2" tty irq 3 vector comintr
  434.     
  435. --  Ethernet drivers of various sorts and the particular configuration
  436. --  information they require.  For most installations, only one of these 
  437. --  devices would normally be defined.
  438.     device we0 at isa? port 0x280 net irq 2 iomem 0xd0000 iosiz 8192 vector weintr
  439.     device ne0 at isa? port 0x300 net irq 2 vector neintr
  440.     device ec0 at isa? port 0x250 net irq 2 iomem 0xd8000 iosiz 8192 vector ecintr
  441.     device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr
  442.  
  443. --  Tape driver
  444.     device        wt0    at isa? port 0x300 bio irq 5 drq 1 vector wtintr
  445.     
  446. --  The TCP/IP loop-back device, ethernet interface, slip interface, log
  447. --  device, and pseudo-terminals.
  448.     pseudo-device    loop
  449.     pseudo-device    ether
  450.     pseudo-device    sl    2
  451.     pseudo-device    log
  452.     pseudo-device    pty    4
  453.     
  454. --  Devices required by VM. 
  455.     pseudo-device    swappager
  456.     pseudo-device    vnodepager
  457.     pseudo-device    devpager
  458.  
  459.     Normally, there is an annotated configuration file called ALL which
  460.     gives a list of all of the options for the configuration file.
  461.     
  462.  
  463. 3.2.1    Okay, fine.  Why shouldn't I just add every device I can find to
  464.     the kernel, so I'll never have to recompile this again?
  465.  
  466.     Because it takes up space.  The kernel is wired into memory, so every 
  467.     byte it uses comes out of the pool of memory for everything else.  It 
  468.     can't page out sections that aren't in use.  If your kernel is larger 
  469.     than 640K, then it can't be loaded.  You'll need to use Julian Elischer's
  470.     bootblocks to put it in high memory, which seem to be fairly complex.
  471.     Installing them (once they are compiled) is as easy as using disklabel.
  472.  
  473.  
  474. 3.2.2    What should I remove from the kernel?
  475.  
  476.     What do you need?  If you only have an SCSI controller, you don't 
  477.     need the wd0 device;  if you have another kind of disk controller, 
  478.     you don't need as0.  Unless you actually HAVE more than one Ethernet 
  479.     controller, you should comment out all but one of them.  If you don't 
  480.     have an ethernet controller, you don't need any of the controllers or 
  481.     NFS compiled in.   Without a CD-ROM, ISOFS is kind of pointless.  Just 
  482.     look at what you have and think about what you really need.
  483.  
  484.  
  485. 3.2.3    I can't get enough remote login sessions or xterm sessions.  I also
  486.     can only get four seesions working at a time.  What can I do?
  487.  
  488.     Increase the count of pseudo-terminals --
  489.  
  490.     pseudo-device    pty    12  # or whatever
  491.  
  492.     Every pseudo terminal should have a /dev/pty* entry.  If you have 12
  493.     pseudo terminals, you should also have at least 12 pty devices in the
  494.     /dev directory.  The MAKEDEV script in /dev will create as many pseudo-
  495.     terminals as you tell it to.
  496.  
  497.  
  498. 3.2.4    How do I get ddb, the kernel debugger, compiled into the kernel
  499.     and running?
  500.  
  501.     Add the following line to the configuration file:
  502.  
  503.     pseudo-device    ddb
  504.  
  505.     Build the kernel, then run dbsym on it:
  506.  
  507.     % dbsym ./386bsd
  508.  
  509.     Install it and go for it.  Ctl-Alt-Esc drops you into the debugger.
  510.  
  511.     Note: DDB as shipped originally is a memory hog, and it is very
  512.     difficult to get a kernel small enough with enough fun things in it
  513.     to debug in 640K
  514.  
  515.  
  516. 3.2.5    Can I have more than one config file?  Should I rename it to something
  517.     else?  Any other hints?  
  518.  
  519.     You can create as many (or as few) config files as you desire.  The 
  520.     system, once the patchkit is applied, will have between 10 and 15, 
  521.     each of which implements certain functions or features.  In addition, 
  522.     the normal place for the patchkit to make changes to the config files 
  523.     is in the GENERICISA file.  Since this file should remain unchanged 
  524.     and available, it is always a good idea to copy this file to a 
  525.     meaningful name and modify that file.  In other words, change every 
  526.     reference in 3.1.1 from GENERICISA to HAL (or whatever you call your 
  527.     system).
  528.  
  529.     One final note.  Every /sys/compile directory takes up 800K or so;
  530.     you might want to watch to see how big these all get.
  531.  
  532.  
  533.  
  534. 3.2.6    What is the meaning of the trap codes I get in panic messages?
  535.     Sometimes this message appears in the form "trap type nn".
  536.  
  537.     That message means that the system received an unexpected (and
  538.     unwanted) trap that probably indicates some form of kernel bug.
  539.     These traps, are usually received from the kernel, in which case
  540.     the trap.h definitions should be used.
  541.  
  542.     The number (which appears in place of "nn" above) is *NOT* the 
  543.     i386 or i386 trap type, it is a BSD-defined trap type number.
  544.  
  545.     The definitions of the various trap types can be found in
  546.     /usr/include/machine/trap.h.
  547.  
  548.     two of the more common ones are:
  549.           9    T_PROTFLT    protection fault
  550.                 (The kernel tried executing code
  551.                 which was not noted as "executable".
  552.                 This happens if the kernel jumps to
  553.                 a bogus location.)
  554.          12    T_PAGEFLT    page fault
  555.                 (The kernel tried to access a bogus
  556.                 area of memory.  This can happen if
  557.                 an invalid pointer is dereferenced.)
  558.  
  559.  
  560.     This is a list of i386 trap codes (just to confuse the issue).
  561.  
  562. Trap    0    Divide Error
  563.         The DIV or IDIV instruction is executed with a zero denominator
  564.         or the quotient is too large for the destination operand.
  565.     
  566.     
  567. Trap    1    Debug Exceptions
  568.         Used in conjunction with DR6 and DR7, The following flags
  569.         need to be tested to determine what caused the trap:
  570.         BS=1                Single-step trap
  571.         B0=1 AND (GE0=1 or LE0=1)    Breakpoint, DR0, LEN0, R/W0
  572.         B1=1 AND (GE1=1 or LE1=1)    Breakpoint, DR1, LEN1, R/W1
  573.         B2=1 AND (GE2=1 or LE2=1)    Breakpoint, DR2, LEN2, R/W2
  574.         B3=1 AND (GE3=1 or LE3=1)    Breakpoint, DR3, LEN3, R/W3
  575.         BD=1                Debug registers not available,
  576.                         in use by ICE-386
  577.         BT=1                Task Switch
  578.             
  579.     
  580. Trap    2    NMI Interrupt
  581.         On PC/AT systems, the NMI input to the CPU is usually
  582.         connected to the main memory parity circuit.  By the time the
  583.         error signal is generated, the data may have already been
  584.         used in an instruction, so it isn't possible to reliably
  585.         recover.
  586.     
  587.         And some not-so-common causes (from various sources):
  588.  
  589.           PS50+ : I/O channel check, system watch-dog timer 
  590.           time-out interrupt, DMA timer time-out interrupt
  591.  
  592.           parity errors on any 8-bit or 16-bit board pulling the 
  593.           IOCHCK* line low 
  594.  
  595.           first generation of auto-switching EGA cards used NMI to trap port
  596.           access for CGA emulation (e.g., ATI's EGA Wonder)
  597.     
  598.           Zeos Notebook low battery (perhaps other battery-based 
  599.           computers)
  600.  
  601.  
  602. Trap    3    Breakpoint
  603.         The result of executing an INT 3 instruction.  MS-DOS and
  604.         Windows and some other non-386 systems use this for debugging.
  605.         Code specific to the 386 and later processors should use
  606.         the debugging features tied to Trap 1.
  607.     
  608.     
  609. Trap    4    INT0 Detected Overflow
  610.         Occurs if an INT0 instruction is executed and the overflow
  611.         flag (OF) is currently set.
  612.     
  613.     
  614. Trap    5    BOUND Range Exceeded
  615.         Occurs if the BOUND instruction is executed and the array
  616.         index points beyond the area of memory containing the array
  617.         being tested.
  618.     
  619.     
  620. Trap    6    Invalid Opcode
  621.         The value read at CS:IP is not a valid opcode.
  622.     
  623.     
  624. Trap    7    Coprocessor Not Available
  625.         This occurs if the processor fetches an instruction that is
  626.         for the coprocessor and no coprocessor is present.
  627.     
  628.     
  629. Trap    8    Double Exception (Fault)
  630.         An exception occurred while trying to execute the handler
  631.         for a prior exception.  Example, an application causes a
  632.         General Protection Fault (13) and the area of memory where
  633.         the GPF handler should be is flagged not-present (paged-out?).
  634.         The double-fault handler is invoked in these conditions.
  635.         If a fault occurs while trying to run the double-fault handler,
  636.         a triple-fault occurs and the CPU resets.
  637.     
  638.         The rules for deciding if a double-fault should occur or
  639.         if the two faults can be handled serially are discussed in
  640.         more detail in the Intel song book.
  641.     
  642.     
  643. Trap    9    Coprocessor Segment Overrun
  644.         A page or segment violation occurred while transferring
  645.         the middle part of a coprocessor operand to the NPX.
  646.     
  647.     
  648. Trap    10    Invalid Task State Segment
  649.         During a task switch, the new TSS was invalid.  Here is
  650.         a table of conditions that Invalidate the TSS:
  651.         TSS id + EXT    The limit in the TSS descriptor is < 103
  652.         LTD id + EXT    Invalid LDT selector or LDT not present
  653.         SS id + EXT    Stack segment selector is outside table limit
  654.         SS id + EXT    Stack segment is not a writable segment
  655.         SS id + EXT    Stack segment DPL does not match new CPL
  656.         SS id + EXT    Stack segment selector RPL <> CPL
  657.         CS id + EXT     Code segment is outside table limit
  658.         CS id + EXT    Code segment selector does not refer to
  659.                     code segment
  660.         CS id + EXT    DPL of non-conforming code segment <> new CPL
  661.         CS id + EXT    CPL of conforming code segment > new CPL
  662.         DS/ES/FS/GS id + EXT    DS, ES, FS or GS segment selector is
  663.                     outside table limits
  664.         DS/ES/FS/FS id + EXT    DS, ES, FS, or GS is not readable
  665.                     segment
  666.  
  667.  
  668. Trap    11    Segment Not Present
  669.         Occurs when the "present" bit of a descriptor is zero.
  670.         This can occur while loading any of these segment registers
  671.         CS, DS, ES, FS, or GS.  Loading SS causes a Stack fault.
  672.         Also occurs when attempting to use a gate descriptor that is
  673.         marked "not  Xesent", and if attempting to load the LDT with
  674.         an LLDT instruction.  Note that loading the LDT during a
  675.         task switch causes an "invalid TSS" trap.
  676.  
  677.  
  678. Trap    12    Stack Fault
  679.         A limit violation relating to an address referenced off
  680.         the SS register.  Includes POP, PUSH, ENTER and LEAVE
  681.         opcodes, as well as references such as MOV AX,[BP+8]
  682.         (which has an implied SS:).
  683.         Also causes by loading SS with a descriptor that is marked
  684.         "not present".
  685.  
  686.  
  687. Trap    13    General Protection Fault (GPF)
  688.         Americas Favorite, in the Windows 3.0 world, it is known as
  689.         the UAE error.  The instruction tried to access data out of
  690.         the bounds designated by the descriptors.  The access that
  691.         failed can be a read, write or instruction fetch.  There are
  692.         15 classifications of GPFs:
  693.         1.  Exceeding segment limit when using CS, DE, ES, FS or GS.
  694.         2.  Exceeding segment limit when referencing a descriptor
  695.             table.
  696.         3.  Transferring control to a segment that is not executable.
  697.         4.  Writing into a read-only data segment or into a code
  698.             segment.
  699.         5.  Reading from an execute-only segment.
  700.         6.  Loading the SS register with a read-only descriptor
  701.             (unless the selector comes from the TSS during a task
  702.             switch, in which case a TSS exception occurs.)
  703.         7.  Loading SS, DS, ES, FS or GS with the descriptor of a
  704.             system segment.
  705.         8.  Loading, DS, ES, FS or GS with the descriptor of an
  706.             executable segment that is not also readable.
  707.         9.  Loading SS with the descriptor of an executable segment.
  708.         10. Accessing memory via, DS, ES, FS or GS when the segment
  709.             register contains a null selector.
  710.         11. Switching to a busy task.
  711.         12. Violating privilege rules.
  712.         13. Loading CR0 with a PG=1 and PE=0.
  713.         14. Interrupt or exception via trap or interrupt gate from
  714.             V86 mode to privilege level other than zero.
  715.         15. Exceeding the instruction limit of 15 bytes (this can
  716.             only occur if redundant prefixes are placed before an
  717.             instruction).
  718.         To determine which condition caused the trap, you need
  719.         the instruction, the contents of all associated registers,
  720.         particularly the segment registers involved, then the various
  721.         LDT, GDT and page control tables.  Lots of common coding
  722.         errors cause the GPFs.  Even a stack imbalance will usually
  723.         show up as a GPF.   Even MOV AX,7 MOV ES,AX or 
  724.         MOV AX,5 PUSH AX POP DS will get a GPF error.  You can't
  725.         use a segment register for "temporary storage" of any
  726.         old value the way you could on the 8086.  The values loaded
  727.         into the segment registers are checked in protected mode.
  728.  
  729.  
  730. Trap    14    Page Fault
  731.         The page directory or page table entry needed for the address
  732.         translation has a zero in the present bit, or the current
  733.         procedure does not have sufficient privilege to access the
  734.         indicated page.
  735.  
  736. Trap    15    (reserved)
  737.  
  738.  
  739. Trap    16    Coprocessor Error
  740.         The coprocessor asserted the ERROR# input pin on the 386
  741.         (internal on the 486)
  742.  
  743.  
  744. Trap    17    Alignment Check (486 and later)
  745.         If enabled, this trap will occur if a data fetch does not
  746.         occur on a word boundary.  I don't know of any software that
  747.         activates this feature yet.  I have seen SCO UNIX get this
  748.         error on early Cyrix processors, even though SCO had not
  749.         enabled the feature.
  750.  
  751.  
  752. Trap    18-32    (reserved)
  753.  
  754. [answered by     Frank Durda IV <uhclem@nemesis.lonestar.org>    and
  755.         jim mullens jcm@ornl.gov  -or- mullens@jamsun.ic.ornl.gov]
  756.     
  757. -------------------------------------------------------------------------------
  758.  
  759. 3.2.7    I have been getting a lot of "virtual memory exhausted" errors when 
  760.     I am compiling a program with a really big static array.  I have 
  761.     128Meg of memory and 8Gig of swap.  How can this be happening?
  762.  
  763.     If you are using Csh, you can simply unlimit your processes in 
  764.     your system level /etc/csh.cshrc file or your personal .cshrc 
  765.     file.  You can also modify your kernel so that the
  766.     amount of memory available is less limiting.  J"org Wunsch 
  767.     (j@tcd-dresden.de) provides us with this brief description:
  768.  
  769.     From a recent posting i just made, regarding the problem how much
  770.     virtual memory one could get.
  771.  
  772.     | On the other hand, i've also changed the definitions you
  773.     | mentioned. But i didn't like to modify the header files, and
  774.     | actually, modifying the values is as easy as:
  775.     | 
  776.     | options        "DFLDSIZ='(16 * 1024 * 1024)'"
  777.     | options        "MAXDSIZ='(64 * 1024 * 1024)'"
  778.     | 
  779.     | Include the above lines into your kernel's config file, reconfig
  780.     | and rebuild it.
  781.     | 
  782.  
  783.     This is just a hint for those people poking around with compiling
  784.     large source files. Especially, due to some gcc problems with large
  785.     static arrays, compiling X applications with huge bitmaps would
  786.     cause virtual memory trouble. Increasing the limits (o'course, as
  787.     long as the h/w resources suffice) could help there.
  788.  
  789.     The default definitions for the above parameters are found in
  790.     /usr/include/machine/vmparam.h.
  791.  
  792.  
  793. 3.2.8    Where can I learn more about all this?
  794.  
  795.     We've skipped over a lot of details here;  the straight dope comes from
  796.     "Building Berkeley UNIX Kernels with Config", by Samuel J. Leffler and
  797.     Michael J. Karels. 
  798.  
  799.  
  800. 3.2.9    Does anyone have a system building script that takes things like 
  801.     building a new config and multiple config files into account?
  802.  
  803.     This is the program that I use to rebuild my kernel.  See the note
  804.     in the file about my 'test' program.  You may elect to build a
  805.     new config every time, or not, depending on your requirements.
  806.  
  807.  
  808.     #! /bin/sh
  809.     #
  810.     #  Script to rebuild the kernel.
  811.     #
  812.     if [ `whoami` != 'root' ] ; then
  813.       echo 'You must be root to successfully proceed from this point'
  814.       exit 1
  815.     fi
  816.     
  817.     #
  818.     #  Set up the environment
  819.     #
  820.     
  821.     if [ X$MACHINE_ARCH = "X" ] ; then
  822.       MACHINE_ARCH=i386
  823.     fi
  824.     
  825.     if [ -f /netbsd ] ; then
  826.       ARCHDIR='/arch'
  827.     fi
  828.     
  829.     #
  830.     # Rebuild Config
  831.     #
  832.     # I am using a modified test(1) that allows for file date comparisons.
  833.     # You can either get my patches (if they aren't already included),
  834.     # modify test() yourself, or get the GNU ShellUtils test(1) program.
  835.     #
  836.     
  837.     if [ /usr/src/usr.sbin/config -ot /usr/sbin/config ] ; then
  838.       echo "Config Up To Date"
  839.     else
  840.      cd /usr/src/usr.sbin/config
  841.      make clean
  842.      make depend
  843.      make
  844.      make install
  845.     fi
  846.     
  847.     cd /sys
  848.     make
  849.     make install
  850.     
  851.     #
  852.     # Modify the local Configuration File
  853.     #
  854.     echo `tput clr`
  855.     cd /sys$ARCHDIR/i386/conf
  856.     
  857.     if [ "X$CONFIG_NAME" = "X" ]; then
  858.       CONFIG_NAME=GENERIC
  859.     fi  
  860.     
  861.     if [ "X$1" = "X" ]; then
  862.       echo "Configuration Files available:"
  863.       ls [A-Z]*
  864.       echo " "
  865.       echo -n "Enter the name of the config file to use: "
  866.       read CONFIG_NAME
  867.       echo
  868.     else
  869.       CONFIG_NAME=$1
  870.     fi
  871.     
  872.     if [ ! -f $CONFIG_NAME ]; then
  873.       cp GENERIC $CONFIG_NAME
  874.     fi
  875.     
  876.     echo "Modifying $CONFIG_NAME config file"
  877.     echo -n "Press return to continue (q to quit) "
  878.     read ans
  879.     
  880.     ans=`echo $ans | cut -c1 | tr 'QqYy' 'qqqq'`
  881.     
  882.     if [ "X$ans" = "Xq" ] ; then
  883.       exit 0
  884.     fi
  885.     
  886.     vi $CONFIG_NAME
  887.     
  888.     #config.new $CONFIG_NAME
  889.     config $CONFIG_NAME
  890.     
  891.     COMPILE_DIR=/sys$ARCHDIR/i386/compile/$CONFIG_NAME
  892.     
  893.     cd $COMPILE_DIR
  894.     make depend
  895.     make
  896.     
  897.     if [ $? -ge 1 ] ; then
  898.       echo "Errors encountered"
  899.     else
  900.       if [ -f netbsd ] ; then
  901.         PROGNAME=netbsd
  902.       else
  903.         if [ -f freebsd ] ; then
  904.           PROGNAME=freebsd
  905.         else
  906.           PROGNAME=386bsd
  907.         fi
  908.       fi
  909.       echo `tput clr`
  910.       echo ""
  911.       echo "  Manual Installation is recommended.  The following files should be"
  912.       echo "copied/linked/moved to the root directory.  The following steps are"
  913.       echo "suggested:"
  914.       echo ""
  915.       echo "    mv /$PROGNAME /$PROGNAME.old"
  916.       echo "    mv $COMPILE_DIR/$PROGNAME /$PROGNAME"
  917.       echo "    reboot"
  918.       echo ""
  919.       echo "Remember that the new kernel changes will not take place until you "
  920.       echo "re-boot the system."
  921.     fi
  922.  
  923.     
  924. 3.3    X11/XFree86/XS3
  925. 3.3.1    What options should I define to get the X extensions included?
  926.  
  927.     Once you have applied the patch kit, the only thing left to do is to
  928.     modify the config file to include the following line:
  929.  
  930.     options    XSERVER, UCONSOLE
  931.  
  932.     recompile the kernel and the kernel should support X.
  933.  
  934. 3.3.2    Where can I get the FAQ for 'X'?
  935.  
  936.     Answers to frequently asked questions about XFree86 on 386BSD are
  937.     available by anonymous ftp from agate.berkeley.edu (128.32.136.1) in
  938.     /pub/386BSD/0.1-ports/XFree86-1.2/XFree86-1.2-386BSD-FAQ.  It
  939.     supplements the more introductory material distributed with XFree86 
  940.     1.2 in README.386BSD.  It also supplements Steve Kotsopoulos' more 
  941.     general 'X on Intel-based Unix' FAQ available by anonymous ftp from
  942.     export.lcs.mit.edu in /contrib/Intel-Unix-X-faq.
  943.  
  944.  
  945. 3.3.3    Why does X drop characters when using xdm?   When I run xdm 
  946.     from the console, it keeps losing keystrokes and the shift keys 
  947.     don't always work.  Why?
  948.  
  949.         You need to run xdm with the -nodaemon flag.  The reason is
  950.         xdm normally detaches from the keyboard.  This allows other
  951.         processes (like getty) to return to reading from the keyboard.
  952.         A race condition results, where some keystrokes are sent to
  953.         xdm and others are sent to other processes.  Using the
  954.         -nodaemon flag causes xdm to stay attached to the keyboard
  955.         so no other process can use it.  This answer comes from Michael 
  956.         C. Newell (root@wanderer.nsi.nasa.gov)
  957.  
  958.     This bit of trivia is also covered in detail in the X FAQ and 
  959.     the README that accompanies XFree86.
  960.  
  961.  
  962. 3.4    Compiler and Library routines
  963.  
  964.     There are several questions that could probably be included
  965.     here.  See also Section 4 for some of the more common 'missing
  966.     modules' that also happen to be library routines.
  967.  
  968.  
  969. 3.4.1    Which C compiler is shipped with my 386BSD derived system? 
  970.  
  971.     The standard compiler released with 386bsd 0.1 is GCC 1.38.  This
  972.     version is considered by many people to be the most stable of
  973.     the GCC versions.  All other Net/2 derived BSD systems have both 
  974.     1.38 and 2.4+ available.  NetBSD 0.9, for example, is completely 
  975.     compilable using GCC 2.4.5, which is included as the default
  976.     compiler.  FreeBSD also ships with the same compiler.
  977.  
  978. 3.4.2    Where is libcompat.a?
  979.  
  980.     The library libcompat.a is (working from memory here) completely
  981.     deprecated in 386bsd.  The only exceptions might be the re_comp
  982.     and re_exec routines, which are discussed in detail in section 4.
  983.     In addition, things will be added to libcompat.a as they are 
  984.     deprecated in the newer versions of NetBSD and FreeBSD.  The
  985.     getreuid() and setreuid() stuff may be heading that way (if they
  986.     aren't there already.
  987.  
  988.     The easiest way around not having a libcompat.a is to simply link 
  989.     it to a small library, since virtually every other function that
  990.     is expected in libcompat.a is already include libc.a.
  991.  
  992.  
  993. -- 
  994. ------
  995. TSgt Dave Burgess               | Dave Burgess
  996. NCOIC, USSTRATCOM/J6444         | *BSD FAQ Maintainer
  997. Offutt AFB, NE                  | Burgess@hrd769.brooks.af.mil
  998.  
  999.  
  1000.  
  1001.