home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / text / faqs / 386bsd-faq.part4 < prev    next >
Encoding:
Internet Message Format  |  1994-04-02  |  33.7 KB

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