SUMMARY: BAD TRAP: Text fault

From: ken lewis (krl@asti.com)
Date: Wed Jun 24 1992 - 03:32:40 CDT


----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 35

I have learned a great deal about debugging kernels but not enough

to figure this one out. I however will be better prepared for the

next system crash!

Thanks to all...

Badri Pillai <Badri.Pillai@ecrc.de>
zrde05@trc.amoco.com (Ess)
Mike Raffety <miker@sbcoc.com>
ukw!kevin (Kevin Sheehan {Consulting Poster Child})
stern@sunne.East.Sun.COM (Hal Stern - NE Area Systems Engineer)
Perry_Hutchison.Portland@xerox.com
Wolfgang.Thaler@Eng.Sun.COM (Wolfgang Thaler)

The basics are...

1) Learn about savecore(8)

2) Learn about adb

I've included a document by Hal Stern concerning debugging kernels.

         _
      _ |_| Kenneth R. Lewis,
   _ |_| Applied Software
  |_| 1908 Cliff Valley Way
   _ _ _ Atlanta, Georgia 30329
  |_||_||_| Voice: (404) 633-8660
   _ _ _ Fax: (404) 633-0154
  |_||_||_| Internet: krl@asti.com

Be excellent to everyone.
----------
X-Sun-Data-Type: postscript-file
X-Sun-Data-Description: postscript-file
X-Sun-Data-Name: crash.ps
X-Sun-Content-Lines: 4531

%!
%%BoundingBox: (atend)
%%Pages: (atend)
%%DocumentFonts: (atend)
%%EndComments
%
% FrameMaker PostScript Prolog 2.0, for use with FrameMaker 2.0
% Copyright (c) 1986,87,89 by Frame Technology, Inc. All rights reserved.
%
% Known Problems:
% Due to bugs in Transcript, the 'PS-Adobe-' is omitted from line 1
/FMversion (2.0) def
/FrameDict 170 dict def
systemdict /errordict known not { /errordict 10 dict def
                errordict /rangecheck { stop } put } if
% The readline in 23.0 doesn't recognize cr's as nl's on AppleTalk
FrameDict /tmprangecheck errordict /rangecheck get put
errordict /rangecheck {FrameDict /bug true put} put
FrameDict /bug false put
mark
% Some PS machines read past the CR, so keep the following 3 lines together!
currentfile 5 string readline
00
0000000000
cleartomark
errordict /rangecheck FrameDict /tmprangecheck get put
FrameDict /bug get {
        /readline {
                /gstring exch def
                /gfile exch def
                /gindex 0 def
                {
                        gfile read pop
                        dup 10 eq {exit} if
                        dup 13 eq {exit} if
                        gstring exch gindex exch put
                        /gindex gindex 1 add def
                } loop
                pop
                gstring 0 gindex getinterval true
                } def
        } if
/FMVERSION {
        FMversion ne {
                /Times-Roman findfont 18 scalefont setfont
                100 100 moveto
                (FrameMaker version does not match postscript_prolog!)
                dup =
                show showpage
                } if
        } def
/FMLOCAL {
        FrameDict begin
        0 def
        end
        } def
        /gstring FMLOCAL
        /gfile FMLOCAL
        /gindex FMLOCAL
        /orgxfer FMLOCAL
        /orgproc FMLOCAL
        /organgle FMLOCAL
        /orgfreq FMLOCAL
        FrameDict /graymode true put
        /yscale FMLOCAL
        /xscale FMLOCAL
        /PrintInColor systemdict /colorimage known def
% Uncomment this line to force b&w on color printer
% /PrintInColor false def
PrintInColor
        
        {
        /HUE 0 def
        /SAT 0 def
        /BRIGHT 0 def
        % array of arrays Hue and Sat values for the separations [HUE BRIGHT]
        /Colors
        [[0 0 ] % black
         [0 0 ] % white
         [0.00 1.0] % red
         [0.37 1.0] % green
         [0.60 1.0] % blue
         [0.50 1.0] % cyan
         [0.83 1.0] % magenta
         [0.16 1.0] % comment
         ] def
      
        /BEGINBITMAPCOLOR {
                BITMAPCOLOR } def
        /BEGINBITMAPCOLORc {
                BITMAPCOLORc } def
        /K {
                Colors exch get dup
                0 get /HUE exch store
                1 get /BRIGHT exch store
                  HUE 0 eq BRIGHT 0 eq and
                        {1.0 SAT sub setgray }
                        {HUE SAT BRIGHT sethsbcolor }
                  ifelse
                } def
        /mysetgray {
                /SAT exch 1.0 exch sub store
                  HUE 0 eq BRIGHT 0 eq and
                        {1.0 SAT sub setgray }
                        {HUE SAT BRIGHT sethsbcolor }
                  ifelse
                } bind def
        }
        
        {
        /BEGINBITMAPCOLOR {
                BITMAPGRAY } def
        /BEGINBITMAPCOLORc {
                BITMAPGRAYc } def
        /mysetgray { setgray } bind def
        /K {
                pop
                } def
        }
ifelse
/max {2 copy lt {exch} if pop} bind def
/min {2 copy gt {exch} if pop} bind def
/mtx matrix defaultmatrix def
/setmanualfeed {
%%BeginFeature *ManualFeed True
         statusdict /manualfeed true put
%%EndFeature
        } def
/FMDOCUMENT {
        array /FMfonts exch def
        /#copies exch def
        0 ne dup {setmanualfeed} if
        FrameDict begin
        /manualfeed exch def
        /paperheight exch def
        /paperwidth exch def
        setpapername
        manualfeed {true} {papersize} ifelse
        {manualpapersize} {false} ifelse
        {desperatepapersize} if
        /yscale exch def
        /xscale exch def
        currenttransfer cvlit /orgxfer exch def
        currentscreen cvlit /orgproc exch def
        /organgle exch def /orgfreq exch def
        end
        } def
        /pagesave FMLOCAL
        /orgmatrix FMLOCAL
        /landscape FMLOCAL
/FMBEGINPAGE {
        FrameDict begin
        /pagesave save def
        3.86 setmiterlimit
        /landscape exch 0 ne store
        landscape {
                90 rotate 0 exch neg translate pop
                }
                { pop pop }
                ifelse
        xscale yscale scale
        /orgmatrix matrix def
        gsave
        } def
/FMENDPAGE {
        grestore
        pagesave restore
        end
        showpage
        } def
        /fontname FMLOCAL
        /fontscale FMLOCAL
        /fontnum FMLOCAL
        /fontdict FMLOCAL
/FMDEFINEFONT {
        FrameDict begin
        /fontname exch def
        /fontscale exch def
        /fontnum exch def
        /fontdict fontname findfont fontscale scalefont def
        fontdict /Encoding get StandardEncoding eq
        {
                fontdict DiacriticEncode
                /fontdict exch def
        } {
                fontdict NonDiacriticEncode
                /fontdict exch def
        } ifelse
        FMfonts fontnum
                fontnum fontdict definefont
        put
        end
        } def
/FMNORMALIZEGRAPHICS {
        newpath
        0.0 0.0 moveto
        1 setlinewidth
        0 setlinecap
        0 mysetgray
        } bind def
/FMBEGINEPSF {
        end
        /FMEPSF save def
        /showpage {} def
        FMNORMALIZEGRAPHICS
        [/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall
        fx fy translate
        rotate
        fw urx llx sub div fh ury lly sub div scale
        llx neg lly neg translate
        } bind def
/FMENDEPSF {
        FMEPSF restore
        FrameDict begin
        } bind def
FrameDict begin
/pagedimen {
        paperheight sub abs 16 lt exch
        paperwidth sub abs 16 lt and
        {/papername exch def} {pop} ifelse
        } def
/inch {72 mul} def
/setpapername {
        /papersizedict 14 dict def
        papersizedict begin
        /papername /unknown def
                /Letter 8.5 inch 11.0 inch pagedimen
                /LetterSmall 7.68 inch 10.16 inch pagedimen
                /Tabloid 11.0 inch 17.0 inch pagedimen
                /Ledger 17.0 inch 11.0 inch pagedimen
                /Legal 8.5 inch 14.0 inch pagedimen
                /Statement 5.5 inch 8.5 inch pagedimen
                /Executive 7.5 inch 10.0 inch pagedimen
                /A3 11.69 inch 16.5 inch pagedimen
                /A4 8.26 inch 11.69 inch pagedimen
                /A4Small 7.47 inch 10.85 inch pagedimen
                /B4 10.125 inch 14.33 inch pagedimen
                /B5 7.16 inch 10.125 inch pagedimen
        end
        } def
/papersize {
        papersizedict begin
                /Letter {lettertray} def
                /LetterSmall {lettertray lettersmall} def
                /Tabloid {11x17tray} def
                /Ledger {ledgertray} def
                /Legal {legaltray} def
                /Statement {statementtray} def
                /Executive {executivetray} def
                /A3 {a3tray} def
                /A4 {a4tray} def
                /A4Small {a4tray a4small} def
                /B4 {b4tray} def
                /B5 {b5tray} def
                /unknown {unknown} def
        papersizedict dup papername known {papername} {/unknown} ifelse get
        end
        statusdict begin stopped end
        } def
/manualpapersize {
        papersizedict begin
                /Letter {letter} def
                /LetterSmall {lettersmall} def
                /Tabloid {11x17} def
                /Ledger {ledger} def
                /Legal {legal} def
                /Statement {statement} def
                /Executive {executive} def
                /A3 {a3} def
                /A4 {a4} def
                /A4Small {a4small} def
                /B4 {b4} def
                /B5 {b5} def
                /unknown {unknown} def
        papersizedict dup papername known {papername} {/unknown} ifelse get
        end
        stopped
        } def
/desperatepapersize {
        statusdict /setpageparams known
                {
                paperwidth paperheight 0 1
                statusdict begin
                {setpageparams} stopped pop
                end
                } if
        } def
/savematrix {
        orgmatrix currentmatrix pop
        } bind def
/restorematrix {
        orgmatrix setmatrix
        } bind def
/dmatrix matrix def
/dpi 72 0 dmatrix defaultmatrix dtransform
    dup mul exch dup mul add sqrt def
/freq dpi 18.75 div 8 div round dup 0 eq { pop 1 } if 8 mul dpi exch div def
/sangle 1 0 dmatrix defaultmatrix dtransform exch atan def
/DiacriticEncoding [
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl
/numbersign /dollar /percent /ampersand /quotesingle /parenleft
/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
/two /three /four /five /six /seven /eight /nine /colon /semicolon
/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K
/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash
/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h
/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar
/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute
/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis
/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis
/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve
/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex
/udieresis /dagger /.notdef /cent /sterling /section /bullet
/paragraph /germandbls /registered /copyright /trademark /acute
/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef
/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown
/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef
/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde
/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright
/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis
/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl
/periodcentered /quotesinglbase /quotedblbase /perthousand
/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute
/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve
/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron
/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron
] def
        /basefontdict FMLOCAL
        /newfontdict FMLOCAL
/DiacriticEncode {
        /basefontdict exch def
        /newfontdict basefontdict maxlength dict def
        basefontdict
        {exch dup /FID ne
                {dup /Encoding eq
                        {exch pop DiacriticEncoding}
                        {exch}
                        ifelse
                        newfontdict 3 1 roll put
                        }
                {pop pop}
                ifelse
                } forall
        newfontdict
        } bind def
/NonDiacriticEncode {
        /basefontdict exch def
        /newfontdict basefontdict maxlength dict def
        basefontdict
        {exch dup /FID ne
                {exch newfontdict 3 1 roll put}
                {pop pop}
                ifelse
                } forall
        newfontdict
        } bind def
        /bwidth FMLOCAL
        /bpside FMLOCAL
        /bstring FMLOCAL
        /onbits FMLOCAL
        /offbits FMLOCAL
        /xindex FMLOCAL
        /yindex FMLOCAL
        /x FMLOCAL
        /y FMLOCAL
/setpattern {
         /bwidth exch def
         /bpside exch def
         /bstring exch def
         /onbits 0 def /offbits 0 def
         freq sangle landscape {90 add} if
                {/y exch def
                 /x exch def
                 /xindex x 1 add 2 div bpside mul cvi def
                 /yindex y 1 add 2 div bpside mul cvi def
                 bstring yindex bwidth mul xindex 8 idiv add get
                 1 7 xindex 8 mod sub bitshift and 0 ne
                 {/onbits onbits 1 add def 1}
                 {/offbits offbits 1 add def 0}
                 ifelse
                }
                setscreen
         {} settransfer
         offbits offbits onbits add div mysetgray
        /graymode false store
        } bind def
/grayness {
        mysetgray
        graymode not {
                /graymode true store
                orgxfer cvx settransfer
                orgfreq organgle orgproc cvx setscreen
                } if
        } bind def
/normalize {
        transform round exch round exch itransform
        } bind def
/dnormalize {
        dtransform round exch round exch idtransform
        } bind def
/lnormalize {
        0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop
        } bind def
/H {
        lnormalize setlinewidth
        } bind def
/Z {
        setlinecap
        } bind def
/X {
        fillprocs exch get exec
        } bind def
/V {
        gsave eofill grestore
        } bind def
/N {
        stroke
        } bind def
/M {newpath moveto} bind def
/E {lineto} bind def
/D {curveto} bind def
/O {closepath} bind def
        /n FMLOCAL
/L {
         /n exch def
        newpath
        normalize
        moveto
        2 1 n {pop normalize lineto} for
        } bind def
/Y {
        L
        closepath
        } bind def
        /x1 FMLOCAL
        /x2 FMLOCAL
        /y1 FMLOCAL
        /y2 FMLOCAL
        /rad FMLOCAL
/R {
        /y2 exch def
        /x2 exch def
        /y1 exch def
        /x1 exch def
        x1 y1
        x2 y1
        x2 y2
        x1 y2
        4 Y
        } bind def
/RR {
        /rad exch def
        normalize
        /y2 exch def
        /x2 exch def
        normalize
        /y1 exch def
        /x1 exch def
        newpath
        x1 y1 rad add moveto
        x1 y2 x2 y2 rad arcto
        x2 y2 x2 y1 rad arcto
        x2 y1 x1 y1 rad arcto
        x1 y1 x1 y2 rad arcto
        closepath
        16 {pop} repeat
        } bind def
/C {
        grestore
        gsave
        R
        clip
        } bind def
/U {
        grestore
        gsave
        } bind def
/F {
        FMfonts exch get
        setfont
        } bind def
/T {
        moveto show
        } bind def
/RF {
        rotate
        0 ne { -1 1 scale } if
        } bind def
/TF {
        gsave
        moveto
        RF
        show
        grestore
        } bind def
/P {
        moveto
        0 32 3 2 roll widthshow
        } bind def
/PF {
        gsave
        moveto
        RF
        0 32 3 2 roll widthshow
        grestore
        } bind def
/S {
        moveto
        0 exch ashow
        } bind def
/SF {
        gsave
        moveto
        RF
        0 exch ashow
        grestore
        } bind def
/B {
        moveto
        0 32 4 2 roll 0 exch awidthshow
        } bind def
/BF {
        gsave
        moveto
        RF
        0 32 4 2 roll 0 exch awidthshow
        grestore
        } bind def
        /x FMLOCAL
        /y FMLOCAL
        /dx FMLOCAL
        /dy FMLOCAL
        /dl FMLOCAL
        /t FMLOCAL
        /t2 FMLOCAL
        /Cos FMLOCAL
        /Sin FMLOCAL
        /r FMLOCAL
/W {
        dnormalize
        /dy exch def
        /dx exch def
        normalize
        /y exch def
        /x exch def
        /dl dx dx mul dy dy mul add sqrt def
        dl 0.0 gt {
                /t currentlinewidth def
                savematrix
                /Cos dx dl div def
                /Sin dy dl div def
                /r [Cos Sin Sin neg Cos 0.0 0.0] def
                /t2 t 2.5 mul 3.5 max def
                newpath
                x y translate
                r concat
                0.0 0.0 moveto
                dl t 2.7 mul sub 0.0 rlineto
                stroke
                restorematrix
                x dx add y dy add translate
                r concat
                t 0.67 mul setlinewidth
                t 1.61 mul neg 0.0 translate
                0.0 0.0 moveto
                t2 1.7 mul neg t2 2.0 div moveto
                0.0 0.0 lineto
                t2 1.7 mul neg t2 2.0 div neg lineto
                stroke
                t setlinewidth
                restorematrix
                } if
        } bind def
/G {
        gsave
        newpath
        normalize translate 0.0 0.0 moveto
        dnormalize scale
        0.0 0.0 1.0 5 3 roll arc
        closepath fill
        grestore
        } bind def
/A {
        gsave
        savematrix
        newpath
        2 index 2 div add exch 3 index 2 div sub exch
        normalize 2 index 2 div sub exch 3 index 2 div add exch
        translate
        scale
        0.0 0.0 1.0 5 3 roll arc
        restorematrix
        stroke
        grestore
        } bind def
        /x FMLOCAL
        /y FMLOCAL
        /w FMLOCAL
        /h FMLOCAL
        /xx FMLOCAL
        /yy FMLOCAL
        /ww FMLOCAL
        /hh FMLOCAL
        /FMsaveobject FMLOCAL
        /FMoptop FMLOCAL
        /FMdicttop FMLOCAL
/BEGINPRINTCODE {
        /FMdicttop countdictstack 1 add def
        /FMoptop count 4 sub def
        /FMsaveobject save def
        userdict begin
        /showpage {} def
        FMNORMALIZEGRAPHICS
        3 index neg 3 index neg translate
        } bind def
/ENDPRINTCODE {
        count -1 FMoptop {pop pop} for
        countdictstack -1 FMdicttop {pop end} for
        FMsaveobject restore
        } bind def
/gn {
        0
        { 46 mul
                cf read pop
                32 sub
                dup 46 lt {exit} if
                46 sub add
                } loop
        add
        } bind def
        /str FMLOCAL
/cfs {
        /str sl string def
        0 1 sl 1 sub {str exch val put} for
        str def
        } bind def
/ic [
        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
        0
        {0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx}
        {10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx}
        {19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}
        {13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh}
        {4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh}
        {13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl}
        {7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl}
        {0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl}
        {10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl}
        ] def
        /sl FMLOCAL
        /val FMLOCAL
        /ws FMLOCAL
        /im FMLOCAL
        /bs FMLOCAL
        /cs FMLOCAL
        /len FMLOCAL
        /pos FMLOCAL
/ms {
        /sl exch def
        /val 255 def
        /ws cfs
        /im cfs
        /val 0 def
        /bs cfs
        /cs cfs
        } bind def
400 ms
/ip {
        is
        0
        cf cs readline pop
        { ic exch get exec
                add
                } forall
        pop
        
        } bind def
/wh {
        /len exch def
        /pos exch def
        ws 0 len getinterval im pos len getinterval copy pop
        pos len
        } bind def
/bl {
        /len exch def
        /pos exch def
        bs 0 len getinterval im pos len getinterval copy pop
        pos len
        } bind def
/s1 1 string def
/fl {
        /len exch def
        /pos exch def
        /val cf s1 readhexstring pop 0 get def
        pos 1 pos len add 1 sub {im exch val put} for
        pos len
        } bind def
/hx {
        3 copy getinterval
        cf exch readhexstring pop pop
        } bind def
        /h FMLOCAL
        /w FMLOCAL
        /d FMLOCAL
        /lb FMLOCAL
        /bitmapsave FMLOCAL
        /is FMLOCAL
        /cf FMLOCAL
/wbytes {
        dup
        8 eq { pop } { 1 eq { 7 add 8 idiv } { 3 add 4 idiv } ifelse } ifelse
        } bind def
/BEGINBITMAPBWc {
        1 {} COMMONBITMAPc
        } bind def
/BEGINBITMAPGRAYc {
        8 {} COMMONBITMAPc
        } bind def
/BEGINBITMAP2BITc {
        2 {} COMMONBITMAPc
        } bind def
/COMMONBITMAPc {
        /r exch def
        /d exch def
        gsave
        translate rotate scale /h exch def /w exch def
        /lb w d wbytes def
        sl lb lt {lb ms} if
        /bitmapsave save def
        r
        /is im 0 lb getinterval def
        ws 0 lb getinterval is copy pop
        /cf currentfile def
        w h d [w 0 0 h neg 0 h]
        {ip} image
        bitmapsave restore
        grestore
        } bind def
/BEGINBITMAPBW {
        1 {} COMMONBITMAP
        } bind def
/BEGINBITMAPGRAY {
        8 {} COMMONBITMAP
        } bind def
/BEGINBITMAP2BIT {
        2 {} COMMONBITMAP
        } bind def
/COMMONBITMAP {
        /r exch def
        /d exch def
        gsave
        translate rotate scale /h exch def /w exch def
        /bitmapsave save def
        r
        /is w d wbytes string def
        /cf currentfile def
        w h d [w 0 0 h neg 0 h]
        { cf is readhexstring pop } image
        bitmapsave restore
        grestore
        } bind def
/Fmcc {
    /proc2 exch cvlit def
    /proc1 exch cvlit def
    /newproc proc1 length proc2 length add array def
    newproc 0 proc1 putinterval
    newproc proc1 length proc2 putinterval
    newproc cvx
} bind def
/colorsetup {
        currentcolortransfer
        /gryt exch def
        /blut exch def
        /grnt exch def
        /redt exch def
        /ngrayt 256 array def
        /nredt 256 array def
        /nbluet 256 array def
        /ngreent 256 array def
        0 1 255 {
                /indx exch def
                /cynu 1 red indx get 255 div sub def
                /magu 1 green indx get 255 div sub def
                /yelu 1 blue indx get 255 div sub def
                /k cynu magu min yelu min def
                /u k currentundercolorremoval exec def
                nredt indx 1 0 cynu u sub max sub redt exec put
                ngreent indx 1 0 magu u sub max sub grnt exec put
                nbluet indx 1 0 yelu u sub max sub blut exec put
                ngrayt indx 1 k currentblackgeneration exec sub gryt exec put
        } for
        {255 mul cvi nredt exch get}
        {255 mul cvi ngreent exch get}
        {255 mul cvi nbluet exch get}
        {255 mul cvi ngrayt exch get}
        setcolortransfer
        {pop 0} setundercolorremoval
        {} setblackgeneration
        } bind def
/fakecolorsetup {
        /tran 256 string def
        0 1 255 { /ind exch def
                tran ind
                red ind get 77 mul
                green ind get 151 mul
                blue ind get 28 mul
                add add 256 idiv put } for
        currenttransfer
        { 255 mul cvi tran exch get 255.0 div }
        exch Fmcc settransfer
} bind def
/BITMAPCOLOR {
        /d 8 def
        gsave
        translate rotate scale /h exch def /w exch def
        /bitmapsave save def
        colorsetup
        /is w d wbytes string def
        /cf currentfile def
        w h d [w 0 0 h neg 0 h]
        { cf is readhexstring pop } {is} {is} true 3 colorimage
        bitmapsave restore
        grestore
        } bind def
/BITMAPCOLORc {
        /d 8 def
        gsave
        translate rotate scale /h exch def /w exch def
        /lb w d wbytes def
        sl lb lt {lb ms} if
        /bitmapsave save def
        colorsetup
        /is im 0 lb getinterval def
        ws 0 lb getinterval is copy pop
        /cf currentfile def
        w h d [w 0 0 h neg 0 h]
        {ip} {is} {is} true 3 colorimage
        bitmapsave restore
        grestore
        } bind def
/BITMAPGRAY {
        8 {fakecolorsetup} COMMONBITMAP
        } bind def
/BITMAPGRAYc {
        8 {fakecolorsetup} COMMONBITMAPc
        } bind def
/ENDBITMAP {
        } bind def
end
%%EndProlog
%%BeginSetup
(2.0) FMVERSION
1 1 612 792 0 1 13 FMDOCUMENT
/fillprocs 32 array def
fillprocs 0 { 0.000000 grayness } put
fillprocs 1 { 0.100000 grayness } put
fillprocs 2 { 0.300000 grayness } put
fillprocs 3 { 0.500000 grayness } put
fillprocs 4 { 0.700000 grayness } put
fillprocs 5 { 0.900000 grayness } put
fillprocs 6 { 0.970000 grayness } put
fillprocs 7 { 1.000000 grayness } put
fillprocs 8 {<0f1e3c78f0e1c387> 8 1 setpattern } put
fillprocs 9 {<0f87c3e1f0783c1e> 8 1 setpattern } put
fillprocs 10 {<cccccccccccccccc> 8 1 setpattern } put
fillprocs 11 {<ffff0000ffff0000> 8 1 setpattern } put
fillprocs 12 {<8142241818244281> 8 1 setpattern } put
fillprocs 13 {<03060c183060c081> 8 1 setpattern } put
fillprocs 14 {<8040201008040201> 8 1 setpattern } put
fillprocs 15 {} put
fillprocs 16 { 1.000000 grayness } put
fillprocs 17 { 0.900000 grayness } put
fillprocs 18 { 0.700000 grayness } put
fillprocs 19 { 0.500000 grayness } put
fillprocs 20 { 0.300000 grayness } put
fillprocs 21 { 0.100000 grayness } put
fillprocs 22 { 0.030000 grayness } put
fillprocs 23 { 0.000000 grayness } put
fillprocs 24 {<f0e1c3870f1e3c78> 8 1 setpattern } put
fillprocs 25 {<f0783c1e0f87c3e1> 8 1 setpattern } put
fillprocs 26 {<3333333333333333> 8 1 setpattern } put
fillprocs 27 {<0000ffff0000ffff> 8 1 setpattern } put
fillprocs 28 {<7ebddbe7e7dbbd7e> 8 1 setpattern } put
fillprocs 29 {<fcf9f3e7cf9f3f7e> 8 1 setpattern } put
fillprocs 30 {<7fbfdfeff7fbfdfe> 8 1 setpattern } put
fillprocs 31 {} put
%%EndSetup
0 12 /Times-Roman FMDEFINEFONT
1 18 /Times-Bold FMDEFINEFONT
2 10 /Times-Italic FMDEFINEFONT
3 12 /Times-Bold FMDEFINEFONT
4 12 /Times-Italic FMDEFINEFONT
5 12 /Courier FMDEFINEFONT
%%Page: "1" 1
%%BeginPaperSize: Letter
%%EndPaperSize
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 1 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
1 F
0 X
(Building and Debugging SunOS Kernels ) 155.53 664 T
2 F
(Hal L. Stern) 285.93 631.33 T
(Sun Microsystems) 274.27 619.33 T
(Northeast Area Consulting Group) 242.34 607.33 T
(Lincoln, MA) 285.51 595.33 T
(hal.stern@east.sun.com) 262.46 583.33 T
(May 6, 1991) 285.38 571.33 T
0 F
2.02 (Building kernels and looking at kernel core dumps should not be strictly) 135 546 P
1.99 (reserved for people writing device drivers and porting operating systems.) 135 532 P
3.58 (Every system administrator should be familiar with the procedures for) 135 518 P
0.38 (building a kernel and analyzing a core dump from a system that has crashed) 135 504 P
-0.47 (or "hung." You will need to rebuild a kernel to perform configuration tuning,) 135 490 P
0.23 (install new hardware, or integrate operation system patches. If you are able) 135 476 P
4.16 (to analyze kernel problems, you will be able to identify troublesome) 135 462 P
1.37 (hardware, drivers or required patches. This paper describes the procedures) 135 448 P
0.19 (involved in configuring, building, debugging and analyzing a SunOS kernel) 135 434 P
(on SPARC-based machines. ) 135 420 T
3 F
(Introduction ) 108 382 T
0 F
-0.71 (This paper starts with the basics of configuring, building and booting a new kernel, and then) 108 362 P
0.1 (looks at what happens when the new kernel \050or an existing one\051 doesn\325t behave as well as) 108 348 P
(expected. ) 108 334 T
(Section 1,) 108 310 T
4 F
2.21 (Configuring and Building a Kernel) 162 310 P
0 F
2.21 (, looks at the kernel build area and the) 339.44 310 P
2.15 (procedures needed to configure, build and boot a new kernel. It is a short) 162 296 P
5.81 (summary of material that may also be found in the ) 162 282 P
4 F
5.81 (SunOS System) 465.24 282 P
(Administration Guide) 162 268 T
0 F
(. ) 266.28 268 T
(Section 2,) 108 244 T
4 F
7.6 (Kernel Configuration) 162 244 P
0 F
7.6 (, explores the kernel configuration file, device) 273.23 244 P
(identification and the configuration process in more detail.) 162 230 T
(Section 3,) 108 206 T
4 F
1.15 (Adding Devices) 162 206 P
0 F
1.15 (, contains a short summary of the steps needed to add a new) 238.76 206 P
0.94 (device to the kernel. This is a detailed explanation of the installation process) 162 192 P
-0.12 (used by many layered products such as SunLink drivers and VME bus devices.) 162 178 P
(Section 4,) 108 154 T
4 F
0.11 (Debugging and Core Dump Analysis) 162 154 P
0 F
0.11 (, starts with a summary of kernel failures,) 339.68 154 P
-0.1 (and then covers crash analysis, tracing, and debugging techniques. It also takes) 162 140 P
(a look at debugging a loadable device driver using ) 162 126 T
5 F
(adb) 406.82 126 T
0 F
(.) 428.41 126 T
1.54 (The problems and techniques discussed in this paper are meant to be representative of) 108 102 P
(actual issues facing a system administrator or kernel service developer. ) 108 88 T
FMENDPAGE
%%EndPage: "1" 2
1 10 /Courier FMDEFINEFONT
6 10 /Courier-Bold FMDEFINEFONT
%%Page: "2" 2
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 2 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
3 F
0 X
(1.) 81 712 T
(Configuring and Building a Kernel) 108 712 T
0 F
(There are many reasons to build a new SunOS kernel:) 108 692 T
(\245) 126 672 T
(Performance tuning: increasing sizes of kernel parameters.) 144 672 T
(\245) 126 656 T
-0.69 (Configuration changes: adding a new device, such as a disk, or adding a new service) 144 656 P
1.69 (such as the lightweight process library. Alternatively, you may want to build a) 144 642 P
(kernel that is as small as possible, freeing memory for use by user-level processes.) 144 628 T
(\245) 126 612 T
1.55 (Patch integration: installing a kernel object file patch, or building a new kernel) 144 612 P
(object module from source code.) 144 598 T
-0.25 (This paper assumes that you are building a kernel from an object code distribution, such as) 108 582 P
-0.43 (that in the ) 108 568 P
5 F
-1.04 (sys) 157.67 568 P
0 F
-0.43 ( kit on the SunOS installation tape. All of the examples will assume that you) 179.26 568 P
2.46 (are running on a ) 108 554 P
5 F
5.91 (sun4c) 199.12 554 P
0 F
2.46 ( machine; if you are building kernels for a ) 235.1 554 P
5 F
5.91 (sun4) 462.12 554 P
0 F
2.46 ( machine,) 490.9 554 P
(substitute the ) 108 540 T
5 F
(sun4) 174.63 540 T
0 F
( kernel architecture for ) 203.42 540 T
5 F
(sun4c) 315.98 540 T
0 F
(. ) 351.96 540 T
3 F
(1.1.) 81 516 T
(Kernel Build Area ) 108 516 T
0 F
0.69 (Kernels are configured and built in the) 108 496 P
5 F
1.65 ( /sys) 297.32 496 P
0 F
0.69 ( directory, which is a symbolic link to the) 334.95 496 P
-0.02 (directory ) 108 482 P
5 F
-0.06 (/usr/kvm/sys) 154.27 482 P
0 F
-0.02 (. Everything that is kernel architecture specific lives in) 240.62 482 P
5 F
-0.06 ( ) 502.58 482 P
0 F
-0.02 (one of) 509.72 482 P
1.88 (the subdirectories of ) 108 468 P
5 F
4.51 (/usr/kvm) 214.57 468 P
0 F
1.88 (, so this is the most logical place for the kernel files) 272.14 468 P
1.79 (themselves to reside. It\325s important to note that you should only build a kernel for a) 108 454 P
-0.05 (machine on that machine or a machine of the same kernel architecture. This is particularly) 108 440 P
3.66 (true for the members of the SPARCStation family, since the machines are binary) 108 426 P
2.99 (compatible with other SPARC machines but have their own kernel architecture. To) 108 412 P
(determine the kernel architecture of your machine, use ) 108 398 T
5 F
(arch -k) 372.78 398 T
0 F
(:) 423.15 398 T
1 F
( ) 153 375.33 T
(% ) 189 375.33 T
6 F
(arch -k) 200.99 375.33 T
1 F
(sun4c) 189 363.33 T
( ) 153 351.33 T
(% ) 189 351.33 T
6 F
(arch) 200.99 351.33 T
1 F
(sun4 ) 189 339.33 T
0 F
-0.56 (The output of ) 108 314 P
5 F
-1.34 (arch) 174.61 314 P
0 F
-0.56 ( \050with no arguments\051 shows you the binary architecture of the machine;) 203.4 314 P
2.35 (all SPARC machines will be ) 108 300 P
5 F
5.63 (sun4) 259.99 300 P
0 F
2.35 (-compatible. However, machines with the ) 288.77 300 P
5 F
5.63 (sun4c) 504.02 300 P
0 F
1.22 (kernel architecture - the SPARCStation 1, IPC, SLC and SPARCStation 2 - cannot run) 108 286 P
-0.1 (kernels built on ) 108 272 P
5 F
-0.24 (sun4) 185.32 272 P
0 F
-0.1 ( machines. The ) 214.11 272 P
5 F
-0.24 (sun4c) 289.75 272 P
0 F
-0.1 ( kernel architecture differs from the ) 325.73 272 P
5 F
-0.24 (sun4) 498.98 272 P
0 F
-0.1 ( in) 527.77 272 P
(a number of ways, including a different page size, main bus architecture, and SCSI device) 108 258 T
(driver structure. ) 108 244 T
1.38 (In the ) 108 220 P
5 F
3.33 (/sys/sun4c) 141.41 220 P
0 F
1.38 ( subdirectory, you\325ll find the ) 213.38 220 P
5 F
3.33 (OBJ) 360.88 220 P
0 F
1.38 ( directory with all of the kernel) 382.46 220 P
-0.75 (object modules, the kernel configuration file directory, and one subdirectory for each kernel) 108 206 P
1.07 (that has been built. The other subdirectories of ) 108 192 P
5 F
2.57 (/sys) 342.73 192 P
0 F
1.07 ( contain configuration, header and) 371.52 192 P
0.23 (source files. The source files included in the object code-only kernel distribution are used) 108 178 P
1.09 (to configure various options into or out of the kernel. Most of these files contain tables) 108 164 P
0.64 (whose sizes are based on the number or types of devices configured into the kernel. The) 108 150 P
0.35 (following summary describes the relevant subdirectories of ) 108 136 P
5 F
0.84 (/sys) 397.91 136 P
0 F
0.35 ( and the kernel features) 426.7 136 P
(dependent on them: ) 108 122 T
(conf.common) 108 98 T
0.79 (Common configuration files and tables, such as the system parameter file) 180 98 P
5 F
(param.c) 180 84 T
0 F
(.) 230.37 84 T
FMENDPAGE
%%EndPage: "2" 3
%%Page: "3" 3
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 3 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(net) 108 712 T
1.74 (Low-level network interfaces. This directory has configuration files that) 180 712 P
(define address families, the NIT interface, and the ARP protocol. ) 180 698 T
(netinet) 108 674 T
2.93 (Internet protocols: TCP, UDP, IP and ICMP. The source files in this) 180 674 P
-0.62 (directory can be used to change buffering and other behavior of the TCP and) 180 660 P
(UDP protocols. ) 180 646 T
(nfs) 108 622 T
(Headers for the NFS protocol. ) 180 622 T
(os) 108 598 T
0.69 (General operating system features; files in this directory build the generic) 180 598 P
-0.37 (kernel interfaces. The) 180 584 P
5 F
-0.9 ( init_sysent.c ) 283.49 584 P
0 F
-0.37 (file contains the table of system) 389.64 584 P
(call entry points. The table of filesystem types is in ) 180 570 T
5 F
(vfs_conf.c) 428.18 570 T
0 F
(.) 500.14 570 T
(rpc) 108 546 T
1.9 (Kernel\325s interface to RPC services. The kernel uses RPC to make NFS) 180 546 P
(requests and to talk to the lock manager on local and remote hosts. ) 180 532 T
(sbusdev) 108 508 T
(SBus devices. This directory does not exist on non-) 180 508 T
5 F
(sun4c) 426.85 508 T
0 F
( machines. ) 462.83 508 T
(scsi) 108 484 T
1.21 (Sun\325s Common SCSI Architecture \050SCSA\051 devices. This directory is not) 180 484 P
(used on non-) 180 470 T
5 F
(sun4c) 241.96 470 T
0 F
( machines, since they use the older SCSI architecture. ) 277.94 470 T
(sparc) 108 446 T
-0.23 (Files specific to the SPARC architecture. The assembly linkage definitions,) 180 446 P
2.55 (trap tables, processor priority levels and other CPU-specific things are) 180 432 P
(defined here. ) 180 418 T
(specfs) 108 394 T
0.75 (Special \050raw\051 filesystem code. ) 180 394 P
4 F
0.75 (specfs) 331.22 394 P
0 F
0.75 ( is the filesystem type used for swap) 360.53 394 P
(devices. ) 180 380 T
(sun) 108 356 T
1.07 (Sun-specific kernel files that are kernel architecture independent, such as) 180 356 P
0.45 (the STREAMS configuration file) 180 342 P
5 F
1.08 ( str_conf.c) 340.92 342 P
0 F
0.45 (. All of the possible root) 421.15 342 P
-0.62 (and swap devices that may be found when using a generic kernel are defined) 180 328 P
-0.31 (in the ) 180 314 P
3 F
-0.31 (swapgeneric.c ) 209.35 314 P
0 F
-0.31 (file in this directory. This file also defines the order in) 283.65 314 P
(which the devices are probed.) 180 300 T
(sun4c) 108 276 T
1.59 (Header files specific to the ) 180 276 P
5 F
3.8 (sun4c) 319.48 276 P
0 F
1.59 ( kernel architecture, including virtual) 355.46 276 P
2.46 (memory system configuration, MMU hardware and system parameters.) 180 262 P
0.16 (This directory also has the architecture-specific kernel configuration, build) 180 248 P
(and object file subdirectories. ) 180 234 T
(sundev) 108 210 T
2.03 (Sun-specific device drivers. All VME devices, such as disk controllers,) 180 210 P
1.15 (ALM boards, and various framebuffers, as well as hardware on the CPU) 180 196 P
2.54 (board such as the Zilog UART, are configured from this directory. In) 180 182 P
2.35 (addition, the older, pre-SCSA SCSI devices and host adaptors use this) 180 168 P
(directory rather than the ) 180 154 T
5 F
(scsi) 298.57 154 T
0 F
( directory. ) 327.35 154 T
(sunif) 108 130 T
0.53 (Sun network interfaces. The network interface subsumes the data link and) 180 130 P
-0.34 (physical layers of the network protocol stack. The drivers configured in this) 180 116 P
(directory include the various Intel and Lance ethernet interfaces. ) 180 102 T
(sys) 108 78 T
4.12 (Kernel header files. These should be identical to those in the ) 180 78 P
5 F
9.88 (sys) 518.41 78 P
FMENDPAGE
%%EndPage: "3" 4
%%Page: "4" 4
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 4 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.89 (subdirectory of the C compiler\325s default, ) 180 712 P
5 F
2.15 (/usr/include) 383.56 712 P
0 F
0.89 (, although this) 469.91 712 P
(directory may contain a few kernel building-specific files. ) 180 698 T
(ufs) 108 674 T
(UNIX \050local\051 file system configuration. ) 180 674 T
(vm) 108 650 T
(Header files for the virtual memory system. ) 180 650 T
(sun4c/OBJ) 108 626 T
(Object files built for the ) 180 626 T
5 F
(sun4c) 298.26 626 T
0 F
( architecture. ) 334.23 626 T
(sun4c/conf) 108 602 T
-0.47 (Kernel configuration files. New kernel configuration files are created in this) 180 602 P
0.28 (directory, which also contains the ) 180 588 P
5 F
0.66 (files) 345.93 588 P
0 F
0.28 ( table used by ) 381.91 588 P
5 F
0.66 (config) 452.3 588 P
0 F
0.28 ( to locate) 495.48 588 P
(kernel components. ) 180 574 T
(sun4c/XX) 108 550 T
2.15 (Kernel-specific build directory for the kernel named ) 180 550 P
5 F
5.17 (XX) 448.53 550 P
0 F
2.15 (. This is where) 462.92 550 P
1.24 (you\325ll build the kernel itself, and where object code for compiled source) 180 536 P
(files ends up. ) 180 522 T
-0.63 (When adding new services to the kernel, you can create new subdirectories of ) 108 498 P
5 F
-1.51 (/sys) 476.17 498 P
0 F
-0.63 (, or add) 504.95 498 P
1.74 (files to the existing subdirectories. For example, a new network protocol called ) 108 484 P
5 F
4.16 (bdlc) 511.21 484 P
0 F
1.65 (should go in a new subdirectory ) 108 470 P
5 F
3.96 (/sys/bdlc) 274.47 470 P
0 F
1.65 (, while a new Sun-specific VME device) 339.24 470 P
0.65 (driver would probably live in ) 108 456 P
5 F
1.55 (/sys/sundev) 254.81 456 P
0 F
0.65 (. We\325ll come back to this issue later when) 333.97 456 P
0.7 (we talk about adding files to the kernel. First, we\325ll take a look at building a new kernel) 108 442 P
(from the stock configuration and object files. ) 108 428 T
3 F
(1.2.) 81 404 T
(Building a Kernel ) 108 404 T
0 F
0.09 (Let\325s say you want to build a new kernel, adding in support for another SCSI disk and the) 108 384 P
0.8 (asynchronous I/O facilities. The new SCSI disk will be device ) 108 370 P
5 F
1.91 (sd1) 417.42 370 P
0 F
0.8 (, and the lightweight) 439.01 370 P
0.7 (process stuff is defined as options ) 108 356 P
5 F
1.68 (ASYNCHIO) 277.42 356 P
0 F
0.7 ( and ) 334.99 356 P
5 F
1.68 (LWP) 359.7 356 P
0 F
0.7 (. Don\325t worry about where these) 381.29 356 P
1.02 (names come from; we\325ll get to that in the next section when we look at how the kernel) 108 342 P
3.09 (configuration file is laid out. This short section is really meant to provide a quick) 108 328 P
(walkthrough of building and installing a new kernel. ) 108 314 T
3 F
(Edit Configuration File ) 108 290 T
0 F
-0.67 (The first step in building a new kernel is to create a configuration file for it. To be safe, copy) 108 270 P
-0.12 (the configuration file for the currently running kernel, and make your changes to the copy.) 108 256 P
-0.6 (Pick a name for your new kernel, and use that name for the configuration file. We\325ll assume) 108 242 P
-0.44 (that we have a system running the ) 108 228 P
5 F
-1.06 (ONEDISK) 271.12 228 P
0 F
-0.44 ( kernel, and we\325re going to make a new kernel) 321.5 228 P
(called ) 108 214 T
5 F
(TWODISK) 139.64 214 T
0 F
(: ) 190.01 214 T
1 F
(# ) 153 191.34 T
6 F
(cd /sys/sun4c/conf) 164.99 191.34 T
1 F
(# ) 153 179.34 T
6 F
(cp ONEDISK TWODISK) 164.99 179.34 T
1 F
( ) 272.93 179.34 T
0 F
0.26 (The kernel name is used to identify the configuration file and kernel build directory only;) 108 154 P
4.02 (it doesn\325t show up anywhere else. You will probably want to change the kernel) 108 140 P
0.19 (identification string to match the kernel "name" so that you can trace a kernel image back) 108 126 P
0.53 (to the configuration file that produced it. As a general rule, don\325t call a kernel "generic") 108 112 P
(unless it really does contain all possible devices and options. ) 108 98 T
FMENDPAGE
%%EndPage: "4" 5
%%Page: "5" 5
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 5 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
1.38 (Changing the kernel\325s identification string is done by editing the configuration file. To) 108 712 P
-0.37 (effect all of the kernel changes we want, we\325ll make a few changes to the configuration file) 108 698 P
(that we just created, /) 108 684 T
5 F
(sys/sun4c/conf/TWODISK) 210.26 684 T
0 F
(:) 368.57 684 T
([1]) 108 660 T
(Locate the configuration line for ) 135 660 T
5 F
(ident) 293.88 660 T
0 F
(, which looks something like: ) 329.86 660 T
1 F
(# name this kernel ONEDISK ) 189 635.33 T
(#) 189 623.33 T
( ) 153 611.33 T
(ident) 189 611.33 T
("ONEDISK" ) 225 611.33 T
0 F
1.62 (Change the string to reflect the new kernel name. In this example, we\325ll make it) 135 586 P
5 F
(TWODISK) 135 572 T
0 F
(: ) 185.37 572 T
1 F
(ident) 189 549.33 T
("TWODISK" ) 225 549.33 T
0 F
([2]) 108 524 T
4.84 (Add support for the lightweight process facility. As you page through the) 135 524 P
(configuration file, you\325ll see a section of ) 135 510 T
5 F
(options) 332.86 510 T
0 F
( lines, of the form: ) 383.23 510 T
1 F
(options RFS ) 189 485.33 T
(options WINSVJ) 189 473.33 T
(# SunView 1 journaling support ) 297 473.33 T
0 F
(Add the new options to this set of configuration lines:) 135 448 T
1 F
( ) 153 425.33 T
(options LWP) 189 425.33 T
(# lightweight process support) 297 425.33 T
(options ASYNCHIO) 189 413.33 T
(# asynchronous I/O) 297 413.33 T
0 F
([3]) 108 388 T
-0.32 (Add in support for a second SCSI disk. Go down into the section of the configuration) 135 388 P
0.26 (file that defines disk devices, and add \050or uncomment\051 a line for the new disk we\325re) 135 374 P
(adding to the kernel. You should see some lines that look like: ) 135 360 T
1 F
(disk sd0 at scsibus0 target 3 lun 0) 153 335.33 T
(# first hard SCSI disk) 380.88 335.33 T
(#disk sd1 at scsibus0 target 1 lun 0) 153 323.33 T
(# second hard SCSI disk) 380.88 323.33 T
0 F
3 (Uncomment the line for device ) 135 298 P
5 F
7.2 (sd1) 302.22 298 P
0 F
3 (, or add it if it\325s been removed from the) 323.81 298 P
3.4 (configuration file. This line defines a new disk device on the SCSI bus. It\325s) 135 284 P
0.43 (permissible to have devices in the configuration file that are not actually present on) 135 270 P
0.11 (the system; when the kernel boots it will probe each device that is configured in and) 135 256 P
4.26 (determine dynamically what is and is not attached. This process, known as) 135 242 P
4 F
1.08 (autoconfiguration) 135 228 P
0 F
1.08 (, produces the list of devices and addresses seen during the boot) 221.63 228 P
(process. ) 135 214 T
3 F
(Configure the Kernel ) 108 190 T
0 F
0.95 (Now that you have modified the kernel configuration file, you need to create an area in) 108 170 P
0.52 (which to build the kernel and a set of rules for assembling its components. The ) 108 156 P
5 F
1.24 (config) 496.82 156 P
0 F
0.35 (utility performs both functions. If a kernel build area does not exist for the kernel, ) 108 142 P
3 F
0.35 (config) 508.68 142 P
0 F
-0.47 (creates one. Be warned that ) 108 128 P
5 F
-1.12 (config) 240.87 128 P
0 F
-0.47 ( will overwrite the contents of an existing kernel build) 284.05 128 P
-0.07 (directory - if you need to save a kernel configuration for later use, be sure to choose a new) 108 114 P
(name for your new kernel rather than re-using an existing name. ) 108 100 T
5 F
0.22 (config) 108 76 P
0 F
0.09 ( builds a Makefile for the kernel using information from the kernel configuration) 151.18 76 P
FMENDPAGE
%%EndPage: "5" 6
%%Page: "6" 6
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 6 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.18 (file and the parts lists of component files in the ) 108 712 P
5 F
0.43 (/sys) 338.31 712 P
0 F
0.18 ( directories. The Makefile produced) 367.1 712 P
0.31 (by ) 108 698 P
5 F
0.75 (config) 123.31 698 P
0 F
0.31 ( contains kernel compilation options, the list of object files, and the rules and) 166.48 698 P
1.76 (dependencies needed to rebuild each of the source files in the kernel. Every time you) 108 684 P
2.81 (modify the kernel configuration, you must run ) 108 670 P
5 F
6.75 (config) 352.87 670 P
0 F
2.81 ( again, because you will be) 396.04 670 P
(changing one of the options that builds the kernel Makefile. ) 108 656 T
-0.02 (To configure the kernel, run ) 108 632 P
5 F
-0.05 (config) 245.79 632 P
0 F
-0.02 ( from the ) 288.96 632 P
5 F
-0.05 (/sys/sun4c/conf) 335.87 632 P
0 F
-0.02 ( directory where the) 443.81 632 P
5 F
(TWODISK) 108 618 T
0 F
( configuration file was created: ) 158.37 618 T
1 F
(# ) 153 595.33 T
6 F
(cd /sys/sun4c/conf) 164.99 595.33 T
1 F
( ) 272.93 595.33 T
(# ) 153 583.33 T
6 F
(config TWODISK) 164.99 583.33 T
1 F
(Doing a "make depend" ) 153 571.33 T
0 F
0.03 (There are a variety of errors that can be reported by ) 108 546 P
5 F
0.07 (config) 358.43 546 P
0 F
0.03 (: you might have defined too) 401.6 546 P
1.29 (many disks in the system, or may have asked to configure in a SCSI disk without first) 108 532 P
0.34 (defining a SCSI bus on which to attach it. ) 108 518 P
5 F
0.81 (config) 314.26 518 P
0 F
0.34 ( will identify any configuration errors) 357.44 518 P
(and abort. ) 108 504 T
5 F
1.62 (config) 108 480 P
0 F
0.68 ( first constructs header files that identify the devices configured into the kernel,) 151.18 480 P
1.69 (then it puts together a template Makefile referencing all of the object and source files) 108 466 P
-0.2 (needed to build the new kernel. Finally, the "make depend" step builds the dependency list) 108 452 P
0.39 (for each source file, adding to the list of rules in the Makefile. As you add source files to) 108 438 P
(the kernel, the "make depend" step will require more time to complete. ) 108 424 T
1.95 (Note that being able to configure the kernel doesn\325t mean that it will build correctly.) 108 400 P
5 F
6.14 (config) 108 386 P
0 F
2.56 ( doesn\325t compile anything; it just builds rules for compiling the kernel. It\325s) 151.18 386 P
(perfectly legal \050and quite common\051 to configure a kernel with a source file that has syntax) 108 372 T
(errors in it. ) 108 358 T
3 F
(Build the Kernel ) 108 334 T
0 F
0.33 (After a successful configuration, you\325re ready to build the kernel. To do so, simply move) 108 314 P
(into the kernel build directory and use the Makefile created by ) 108 300 T
5 F
(config) 410.1 300 T
0 F
(: ) 453.28 300 T
1 F
(# ) 189 277.34 T
6 F
(cd ../TWODISK) 200.99 277.34 T
1 F
(# ) 189 265.34 T
6 F
(make) 200.99 265.34 T
1 F
( ) 224.98 265.34 T
0 F
0.13 (You will see a series of ) 108 240 P
5 F
0.32 (cc) 224.04 240 P
0 F
0.13 ( commands being executed. Each of the source \050.c\051 files that is) 238.44 240 P
2.38 (needed to build the kernel is compiled, and the resulting objects are linked with the) 108 226 P
0.31 (appropriate object files in ) 108 212 P
5 F
0.74 (/sys/sun4c/OBJ) 235.13 212 P
0 F
0.31 (. When the ) 335.88 212 P
5 F
0.74 (make) 392.08 212 P
0 F
0.31 ( procedure reports that it) 420.87 212 P
-0.6 (is ) 108 198 P
4 F
-0.6 (loading vmunix) 118.4 198 P
0 F
-0.6 (, it\325s linking the kernel. The kernel build procedure finishes by telling you) 192.09 198 P
(how large the new kernel is:) 108 184 T
1 F
( ) 153 161.34 T
(text data bss dec hex ) 189 161.34 T
(1097728 163376 82280 1343384 147f98 ) 189 149.34 T
0 F
-0.56 (These values are the size \050in bytes\051 of the kernel code, initialized data and uninitialized data) 108 124 P
-0.1 (segments of the kernel. The total size reported is not the total amount of memory that will) 108 110 P
1.05 (be used by the kernel once it is running, because the kernel dynamically allocates large) 108 96 P
-0.5 (tables as part of its initialization. Furthermore, as the kernel is running, it will dynamically) 108 82 P
FMENDPAGE
%%EndPage: "6" 7
%%Page: "7" 7
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 7 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
-0.62 (allocate memory for various data buffers. Your best estimate of the actual size of the kernel) 108 712 P
-0.67 (is to subtract the amount of available memory \050after the kernel has initialized\051 from the total) 108 698 P
0.41 (memory in the system. Look for this information in the kernel\325s boot messages, recorded) 108 684 P
(in ) 108 670 T
5 F
(/var/adm/messages) 120.33 670 T
0 F
(:) 242.66 670 T
1 F
(mem = 16384K \0500x1000000\051) 153 647.33 T
(avail mem = 14671872 ) 153 635.33 T
0 F
-0.68 (Also note that you ) 108 610 P
4 F
-0.68 (only) 196.56 610 P
0 F
-0.68 ( need to run ) 217.21 610 P
5 F
-1.63 (config) 274.44 610 P
0 F
-0.68 ( when you change the kernel configuration file.) 317.61 610 P
0.33 (If you haven\325t changed the options used to build the kernel, or the list of component files) 108 596 P
-0.73 (that go into it, there\325s no need to build a new kernel Makefile and configuration header files.) 108 582 P
0.1 (You can build and re-build a kernel by simply going into the build directory and issuing a) 108 568 P
5 F
(make) 108 554 T
0 F
(: ) 136.78 554 T
1 F
(# ) 153 531.33 T
6 F
(cd /sys/sun4c/TWODISK) 164.99 531.33 T
1 F
( ) 290.92 531.33 T
(# ) 153 519.33 T
6 F
(make) 164.99 519.33 T
0 F
0.46 (If you\325re trying to iron bugs out of a device driver, you\325ll be building several versions of) 108 494 P
0.48 (the kernel from the same build directory without reconfiguring it. The kernel contains its) 108 480 P
-0.27 (identification and version number as strings in the text image; each time you build a kernel) 108 466 P
0.16 (from the same directory the version number is incremented. When you ) 108 452 P
5 F
0.39 (config) 452.21 452 P
0 F
0.16 ( a kernel,) 495.38 452 P
0.12 (the version number is reset to one. We\325ll come back to the way in which version numbers) 108 438 P
-0.03 (and identification strings make it into the kernel when we cover kernel extensions in more) 108 424 P
(detail. ) 108 410 T
3 F
(1.3.) 81 386 T
(Booting the New Kernel ) 108 386 T
0 F
-0.02 (Before you boot a new kernel, save the old one or one that you know will boot so that you) 108 366 P
1.17 (can recover if your new kernel hangs the machine, crashes or fails to run for any other) 108 352 P
0.78 (reason. The most common "safe" kernel names are ) 108 338 P
5 F
1.87 (vmunix.o) 360.81 338 P
0 F
0.78 ( or ) 418.38 338 P
5 F
1.87 (vmunix.generic) 435.92 338 P
0 F
0.78 (;) 536.67 338 P
0.27 (it\325s a good idea to keep a generic kernel around so you can recover just about any system) 108 324 P
-0.38 (configuration. The saved kernel image must be in the root directory \050/\051 so that you can boot) 108 310 P
(it in a pinch. ) 108 296 T
-0.42 (Once you\325re sure you have a fallback position with an old kernel, move the new kernel into) 108 272 P
(place: ) 108 258 T
1 F
(# ) 153 235.34 T
6 F
(cd /sys/sun4c/TWODISK ) 164.99 235.34 T
1 F
(#) 153 223.34 T
6 F
( mv vmunix /vmunix ) 159 223.34 T
0 F
0.83 (At this point, the kernel image loaded into memory and the disk image in ) 108 198 P
5 F
2 (/vmunix) 473.8 198 P
0 F
0.83 ( no) 524.17 198 P
3.1 (longer match, so commands that read the kernel memory to locate user or process) 108 184 P
0.85 (information will not work until you reboot. Pay particular attention to ) 108 170 P
5 F
2.03 (ps) 454.43 170 P
0 F
0.85 ( and ) 468.82 170 P
5 F
2.03 (uptime) 493.83 170 P
0 F
0.85 (,) 537 170 P
0.95 (since they will not be able to find process information, system information or any other) 108 156 P
0.95 (kernel data structures that they parse. If you need to run ) 108 142 P
5 F
2.29 (ps) 388.95 142 P
0 F
0.95 ( before you reboot, you can) 403.34 142 P
(explicitly specify a kernel image name using the ) 108 128 T
5 F
(-k) 343.17 128 T
0 F
( option: ) 357.56 128 T
1 F
(# ) 153 105.34 T
6 F
(ps -aguxk /vmunix.generic /dev/mem ) 164.99 105.34 T
0 F
0.28 (To avoid confusing innocent users \050or anyone else\051, you should install the kernel as close) 108 80 P
FMENDPAGE
%%EndPage: "7" 8
%%Page: "8" 8
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 8 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(as possible to the time at which you will reboot the system. ) 108 712 T
-0.41 (With the new kernel installed, reboot the system. Depending upon your level of confidence) 108 688 P
-0.21 (in the new kernel, either get coffee \050exuding confidence\051 or spread the entrails of a goat on) 108 674 P
0.31 (the console \050exuding fear\051. If the new kernel won\325t boot or crashes, you can always boot) 108 660 P
0.74 (your saved kernel image. From the boot prompt, specify the name of the fallback kernel) 108 646 P
(that you created above:) 108 632 T
1 F
(> b vmunix.generic ) 153 609.33 T
0 F
(You can get a list of bootable images by supplying a wildcard to the ) 108 584 T
5 F
(b) 437.78 584 T
0 F
( command:) 444.98 584 T
1 F
(> b *) 153 561.33 T
0 F
-0.7 (If you didn\325t save a kernel image and can\325t get the new kernel to boot, all is not lost if you\325re) 108 536 P
-0.63 (running on a diskless node. Halt the diskless machine, and log into its root filesystem server) 108 522 P
0.46 (as ) 108 508 P
4 F
0.46 (root) 121.44 508 P
0 F
0.46 (. On the server, copy a known, working version of the kernel into the client\325s root) 141.44 508 P
(filesystem, and then reboot the client: ) 108 494 T
1 F
(server# ) 153 471.33 T
6 F
(cd /export/root/deadclient) 200.97 471.33 T
1 F
(server# ) 153 459.33 T
6 F
(cp ../goodclient/vmunix vmunix ) 200.97 459.33 T
0 F
0.55 (If you\325re running on a diskful system, it\325s time to get creative moving disks around \050you) 108 434 P
0.49 (can try attaching the disk to another, working system, and copying a kernel onto the root) 108 420 P
-0.07 (partition\051 or locate your SunOS installation tapes. The miniroot on the installation tape is) 108 406 P
(a generic kernel, so you can boot it and avoid re-installing your system:) 108 392 T
(\245) 126 368 T
(Boot the miniroot from the installation tape) 144 368 T
(\245) 126 352 T
(Make sure the root filesystem on disk is clean, using ) 144 352 T
5 F
(fsck) 398.84 352 T
0 F
(.) 427.62 352 T
(\245) 126 336 T
(Copy the ) 144 336 T
5 F
(/vmunix ) 190.64 336 T
0 F
(image from the miniroot to the disk\325s root partition.) 248.21 336 T
(\245) 126 320 T
(Reboot from the disk image.) 144 320 T
0.38 (Take the same precautions with kernels that you would with any sharp object. Make sure) 108 300 P
(you have a recovery plan in place, and you should be able to experiment freely. ) 108 286 T
3 F
(2.) 81 262 T
(Kernel Configuration Details ) 108 262 T
0 F
0.85 (Now that we\325ve seen how to build, install and boot kernels, we\325ll look at the process of) 108 242 P
1.1 (kernel configuration in more detail. The heart of the configuration process is the kernel) 108 228 P
-0.7 (configuration file, which is divided into four major sections: machine type and connections,) 108 214 P
2.61 (devices, pseudo devices, and options. We won\325t go into the details of how to build) 108 200 P
0.74 (configuration lines for external devices, since this material is well covered in the ) 108 186 P
4 F
0.74 (SunOS) 507.35 186 P
3.41 (System Administration Guide) 108 172 P
0 F
3.41 (. Instead, we\325ll focus on how the various lines in the) 255.41 172 P
(configuration file turn into file names in the kernel Makefile. ) 108 158 T
3 F
(2.1.) 81 134 T
(Machine Type and Connections ) 108 134 T
0 F
0.15 (The machine type and connections section describes the CPU and bus architectures of the) 108 114 P
-0.66 (host. Connection definitions determine what other kinds of devices ) 108 100 P
5 F
-1.59 (config) 426.51 100 P
0 F
-0.66 ( will allow you) 469.69 100 P
1.92 (to add to this kernel. For example, you can\325t attempt to configure a VME-based disk) 108 86 P
FMENDPAGE
%%EndPage: "8" 9
%%Page: "9" 9
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 9 -) 296.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(controller into a desktop workstation that only has SBus slots. ) 108 712 T
0.69 (The machine definition has two parts: an architecture specification and a CPU type. The) 108 688 P
(architecture specification describes the kernel architecture of the machine. ) 108 674 T
1 F
(machine "sun4c" ) 153 651.33 T
(cpu "SUN4C_60" # Sun-4/60 ) 153 639.33 T
(cpu "SUN4C_70" # Sun-4/70 ) 153 627.33 T
0 F
0.9 (You can specify only one kernel architecture per configuration file, since all device and) 108 602 P
0 (connection information is pretty hardware specific. However, you can have different CPU) 108 588 P
0.2 (types defined in a single configuration file. This allows you to build a kernel that will run) 108 574 P
0.38 (on different generations of machines with the same kernel architecture. If you look at the) 108 560 P
5 F
16.6 (GENERIC) 108 546 P
0 F
6.92 ( configuration for ) 158.37 546 P
4 F
6.92 (sun4c) 266.72 546 P
0 F
6.92 ( machines, you\325ll see both the ) 294.7 546 P
5 F
16.6 (SUN4C_60) 482.43 546 P
0 F
0.33 (\050SPARCStation 1, IPC and SLC\051 and ) 108 532 P
5 F
0.79 (SUN4C_70) 292.22 532 P
0 F
0.33 ( \050SPARCStation 2\051 CPU types defined.) 349.79 532 P
0.43 (The same ) 108 518 P
5 F
1.04 (GENERIC) 158.16 518 P
0 F
0.43 (-derived SunOS 4.1.1 kernel will run on both SPARCStation 1 class) 208.53 518 P
(and SPARCStation 2 hosts. ) 108 504 T
3.36 (Included with the machine type section are the kernel identification string and the) 108 480 P
5 F
4.16 (maxusers) 108 466 P
0 F
1.73 ( parameter. ) 165.57 466 P
5 F
4.16 (maxusers) 225.98 466 P
0 F
1.73 ( is a misnomer: this value does not determine how) 283.55 466 P
0.14 (many users may be logged in, and it has no relationship to any licensing information. It is) 108 452 P
0.21 (used to size various kernel tables and buffer pools, and it should be made large enough to) 108 438 P
-0.23 (reflect the number of ) 108 424 P
4 F
-0.23 (virtual) 210.99 424 P
0 F
-0.23 ( users on a system. For example, an NFS server might have 40) 242.97 424 P
-0.43 (NFS clients. The aggregate disks traffic generated by those clients looks \050to the server\051 like) 108 410 P
-0.45 (the same load imposed by 40 users, so the server should be built with ) 108 396 P
5 F
-1.08 (maxusers) 437.14 396 P
0 F
-0.45 ( set to 40.) 494.71 396 P
0.38 (When memory was a scarce resource, and shaving 10 kbytes out of the kernel would add) 108 382 P
3.52 (1% to the pool of memory available for user processes \050on a 1 Mbyte machine\051,) 108 368 P
5 F
-0.91 (maxusers) 108 354 P
0 F
-0.38 ( had to be kept as small as possible. However, today\325s SunOS kernel can easily) 165.57 354 P
0.36 (grow to be over 1 Mbyte, and increasing ) 108 340 P
5 F
0.85 (maxusers) 308.37 340 P
0 F
0.36 ( to 128 or more does not consume a) 365.93 340 P
0.11 (significant portion of the system\325s memory. Many performance problems can be traced to) 108 326 P
(a system that is built with too small a value for ) 108 312 T
5 F
(maxusers) 335.54 312 T
0 F
(. ) 393.11 312 T
0.16 (On a ) 108 288 P
5 F
0.39 (sun4c) 134.3 288 P
0 F
0.16 ( machine, you\325ll find only one connection, defining the SCSI bus attached to) 170.28 288 P
(the embedded SCSI processor \050esp\051: ) 108 274 T
1 F
(scsibus0 at esp # declare first scsi bus ) 153 251.34 T
0 F
-0.48 (Connections have much more importance on VME bus machines. On a SPARCServer 490,) 108 226 P
0.2 (you\325ll find definitions for the various VME bus address spaces, as well as the I/O devices) 108 212 P
(that are on-board and on-board memory address spaces: ) 108 198 T
1 F
(controller obmem 4 at nexus ? ) 153 175.34 T
(controller obio 4 at nexus ? ) 153 163.34 T
(controller vme16d16 4 at nexus ? ) 153 151.34 T
(controller vme24d16 4 at nexus ? ) 153 139.34 T
(controller vme32d16 4 at nexus ? ) 153 127.34 T
(controller vme16d32 4 at nexus ? ) 153 115.34 T
(controller vme24d32 4 at nexus ? ) 153 103.34 T
(controller vme32d32 4 at nexus ? ) 153 91.34 T
FMENDPAGE
%%EndPage: "9" 10
%%Page: "10" 10
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 10 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.43 (The ) 108 712 P
4 F
0.43 (controller) 130.08 712 P
0 F
0.43 ( keyword indicates that this device will have other devices connected to it,) 178.05 712 P
0.55 (while the use of ) 108 698 P
4 F
0.55 (nexus) 189.46 698 P
0 F
0.55 ( is historical \050read one of the books describing implementations of) 216.76 698 P
-0.38 (BSD UNIX on DEC hardware for details\051. The number in between the controller name and) 108 684 P
-0.47 (the "at nexus" keyword indicates the CPU type for which the connection definition is valid.) 108 670 P
2.3 (CPU types are defined in ) 108 656 P
5 F
5.53 (/usr/include/machine/cpu.h) 243.09 656 P
0 F
2.3 (; these values will be) 430.19 656 P
0.06 (referenced by the ) 108 642 P
5 F
0.15 (cpu) 194.43 642 P
0 F
0.06 ( definitions just described. Even within a single kernel architecture,) 216.01 642 P
0.79 (not all CPU types support all connection types. Some systems don\325t handle 32-bit VME) 108 628 P
-0.08 (addresses, for example, so they won\325t have a ) 108 614 P
5 F
-0.19 (vme32d32) 325.2 614 P
0 F
-0.08 ( connection defined. We\325ll touch) 382.77 614 P
0.89 (on connection types again when we look at the way in which devices are defined to the) 108 600 P
(kernel, but for ) 108 586 T
5 F
(sun4c) 179.28 586 T
0 F
( machines, they aren\325t all that interesting. ) 215.26 586 T
3 F
(2.2.) 81 562 T
(Devices ) 108 562 T
0 F
-0.54 (The devices section includes one definition for each physical device attached to the system.) 108 542 P
0.86 ("Attached" is used somewhat loosely, since some devices may reside on the CPU board) 108 528 P
0.97 (rather than on some external bus. As mentioned above, the devices section may include) 108 514 P
(more devices than are really present. ) 108 500 T
-0.62 (There are two ways in which devices are defined to the kernel: a full specification including) 108 476 P
-0.4 (bus address and interrupt vector, or an "autoloading" specification. The full specification is) 108 462 P
-0.51 (typically used for devices that plug in to some external bus, such as the VME bus, while the) 108 448 P
0.07 (autoloading style is used for devices that are on the same "bus" as the CPU. The best \050and) 108 434 P
(only\051 example of the latter is the SBus. ) 108 420 T
-0.67 (A good example of a full device specification is the configuration line for the on-board Intel) 108 396 P
(ethernet interface on a SPARCServer:) 108 382 T
1 F
( device ie0 at obio ? csr 0xf6000000 priority 3 ) 153 359.33 T
0 F
1.71 (This line defines the device name ) 108 334 P
5 F
4.1 (ie0) 282.12 334 P
0 F
1.71 (, which is connected to the on-board I/O "bus") 303.71 334 P
0.49 (\050) 108 320 P
5 F
1.17 (obio) 111.99 320 P
0 F
0.49 (\051. The ) 140.78 320 P
5 F
1.17 (?) 173.4 320 P
0 F
0.49 ( indicates that this devices can be connected to the ) 180.59 320 P
5 F
1.17 (obio) 429.97 320 P
0 F
0.49 ( bus of any CPU) 458.75 320 P
1.34 (type; if this device could only be used with the SPARCServer 490, for example, the ) 108 306 P
5 F
3.21 (?) 532.8 306 P
0 F
-0.25 (would have been replaced with a ) 108 292 P
5 F
-0.59 (4) 267.06 292 P
0 F
-0.25 ( \050since ) 274.26 292 P
5 F
-0.59 (4) 308.4 292 P
0 F
-0.25 ( is the CPU type for this machine, as defined in) 315.6 292 P
0.27 (the ) 108 278 P
5 F
0.64 (cpu.h) 125.92 278 P
0 F
0.27 ( header file\051. The ) 161.9 278 P
5 F
0.64 (csr) 248.55 278 P
0 F
0.27 ( specification tells the kernel where the device will map) 270.14 278 P
1.09 (its on-board registers, and the priority is the bus priority level on which the device will) 108 264 P
0.64 (interrupt. It\325s also possible to specify the interrupt vector and interrupt routine, as in this) 108 250 P
(configuration line for an additional Intel ethernet interface that is a VME bus device: ) 108 236 T
1 F
(device ie2 at vme24d32 ? csr 0x31ff02 priority 3 ) 153 213.34 T
(vector ieintr 0x76 ) 189 201.34 T
0 F
-0.5 (The ) 108 176 P
5 F
-1.2 (sun4c) 129.15 176 P
0 F
-0.5 ( machines use the simpler "autoloading" device specification. SBus devices are) 165.13 176 P
-0 (addressed geographically \050by slot\051 rather than within some global bus address space \050as in) 108 162 P
0.45 (the VME bus\051, so no ) 108 148 P
5 F
1.07 (csr) 212.84 148 P
0 F
0.45 ( or bus type specifications are needed. Instead, the SBus driver) 234.43 148 P
(configuration simply lists the name of the device: ) 108 134 T
1 F
(device-driver audioamd # AMD79C30A sound chip ) 153 111.34 T
(device-driver le # LANCE ethernet ) 153 99.34 T
(device-driver zs # UARTs ) 153 87.34 T
FMENDPAGE
%%EndPage: "10" 11
%%Page: "11" 11
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 11 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.43 (Aside from the fact that SBus drivers have physical hardware associated with them, their) 108 712 P
(configurations are very similar to those of pseudo devices. ) 108 698 T
3 F
(2.3.) 81 674 T
(Pseudo Devices and Options ) 108 674 T
0 F
2.53 (The pseudo devices section adds device drivers that have no corresponding piece of) 108 654 P
-0.22 (hardware associated with them. Pseudo-tty drivers and the network loopback are two good) 108 640 P
0.13 (examples of pseudo devices. Consider adding a new network protocol \050like HDLC\051 to the) 108 626 P
1.66 (system: the protocol doesn\325t have any associated hardware with it, since the low-level) 108 612 P
0.33 (hardware protocol is handled by something else. The new network protocol can be added) 108 598 P
(as a pseudo device while the underlying hardware driver is added as a physical device. ) 108 584 T
0.08 (Like the SBus device configuration, adding a pseudo device to the kernel merely involves) 108 560 P
(listing the device name in the configuration file: ) 108 546 T
1 F
(pseudo-device pty # pseudo-tty\325s, also needed for SunView) 153 523.33 T
(pseudo-device ether # basic Ethernet support) 153 511.33 T
(pseudo-device win128 # up to 128 windows ) 153 499.33 T
0 F
0.22 (This example includes support for the pseudo tty drivers, used by ) 108 474 P
5 F
0.53 (rlogin) 426.89 474 P
0 F
0.22 (, ) 470.07 474 P
5 F
0.53 (telnet) 476.29 474 P
0 F
0.22 ( and) 519.46 474 P
-0.49 (the various window systems. Pseudo tty devices provide a tty interface for applications like) 108 460 P
5 F
0.5 (rlogin) 108 446 P
0 F
0.21 ( that need to talk to a tty device. There\325s no hardware under the ) 151.18 446 P
5 F
0.5 (pty) 460.83 446 P
0 F
0.21 ( driver - it\325s) 482.42 446 P
0.71 (all done in software. Pseudo devices can have entries in the ) 108 432 P
5 F
1.71 (/dev ) 403.62 432 P
0 F
0.71 (directory along with) 441.31 432 P
-0.3 (physical devices; for example, the pseudo tty devices are) 108 418 P
5 F
-0.71 ( /dev/ttyp*) 378.41 418 P
0 F
-0.3 (. If you open the) 456.85 418 P
1.24 (device directly - like a terminal device - then it will have an entry in) 108 404 P
5 F
2.98 ( /dev) 451.83 404 P
0 F
1.24 (. Network) 490.8 404 P
-0.06 (protocols that are sandwiched between low-level hardware and higher-level interfaces, for) 108 390 P
(example, do not need ) 108 376 T
5 F
(/dev) 213.59 376 T
0 F
( entries. ) 242.37 376 T
1.05 (The last line of the example above configures 128 ) 108 352 P
5 F
2.51 (win) 360.24 352 P
0 F
1.05 ( devices; the device name is the) 381.83 352 P
-0.37 (prefix and the numeric suffix indicates how many "units" the kernel should configure. Unit) 108 338 P
-0.21 (numbers are usually well-defined for physical devices, since the ) 108 324 P
5 F
-0.51 (config) 416.51 324 P
0 F
-0.21 ( utility can count) 459.68 324 P
-0.28 (how many instances of each device are included in the kernel configuration. Without some) 108 310 P
1.36 (external piece of hardware, though, there\325s nothing to count for pseudo devices, so the) 108 296 P
0.28 (name-and-number syntax is used to explicitly define the number of units. If no number is) 108 282 P
(supplied, the driver usually has some default number of units. ) 108 268 T
(The configuration of kernel options is equally simple:) 108 244 T
1 F
(options NFSCLIENT # NFS client side code) 153 221.34 T
(options NFSSERVER # NFS server side code ) 153 209.34 T
0 F
0.87 (Options are software bundles that provide specific services. In this example, we add the) 108 184 P
0.28 (NFS client and server code to the kernel. Configuring an option also enables system calls) 108 170 P
(that use the corresponding service. ) 108 156 T
5.48 (In our previous example using the asynchronous I/O option, adding ) 108 132 P
5 F
13.16 (options) 489.63 132 P
0.19 (ASYNCHIO) 108 118 P
0 F
0.08 ( to the kernel also enables the) 165.57 118 P
5 F
0.19 ( aioread\050\051) 307.95 118 P
0 F
0.08 ( and ) 380.1 118 P
5 F
0.19 (aiowrite\050\051) 403.58 118 P
0 F
0.08 ( system calls.) 475.54 118 P
-0.31 (Where is the correlation between the configuration option and the system call? The answer) 108 104 P
1.38 (is in conditional compilation: when you configure an option, the name of the option is) 108 90 P
-0.16 (passed as a ) 108 76 P
5 F
-0.38 (#define ) 163.81 76 P
0 F
-0.16 (constant to the kernel source file compilation. The asynchronous I/) 220.99 76 P
FMENDPAGE
%%EndPage: "11" 12
%%Page: "12" 12
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 12 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
-0.69 (O system calls are conditionally compiled \050look at ) 108 712 P
5 F
-1.66 (/sys/os/init_sysent.c) 346.96 712 P
0 F
-0.69 (\051 into the) 498.08 712 P
-0.31 (system call entry point table if the constant ) 108 698 P
5 F
-0.74 (ASYNCHIO) 314.72 698 P
0 F
-0.31 ( is defined. The same holds true for) 372.29 698 P
-0.65 (the NFS client and server options: the system calls that support NFS operation are compiled) 108 684 P
(into the kernel only if the appropriate options are given in the kernel configuration file. ) 108 670 T
0.4 (You can also use configuration file options to increase the default sizes of System V IPC) 108 646 P
2.26 (services. For example, the maximum size of a shared memory segment is set by the) 108 632 P
5 F
0.04 (SHMSIZE) 108 618 P
0 F
0.02 ( constant in ) 158.37 618 P
5 F
0.04 (/usr/include/sys/shm.h) 216.72 618 P
0 F
0.02 (. Override the default value of this) 375.03 618 P
(constant by redefining the option in the kernel configuration file:) 108 604 T
1 F
(options) 153 581.33 T
(SHMSIZE=2048) 225 581.33 T
0 F
0.69 (This example increases the default shared memory segment size to 2 Mbytes \050the size is) 108 556 P
(given in 1024 byte increments\051. ) 108 542 T
3 F
(2.4.) 81 518 T
(Putting the Pieces Together: config) 108 518 T
0 F
( ) 287.2 518 T
0.77 (Now you should have a pretty good idea of what goes into the kernel configuration file,) 108 498 P
-0.74 (which is the primary input of the ) 108 484 P
5 F
-1.77 (config) 263.07 484 P
0 F
-0.74 ( utility. It\325s up to ) 306.24 484 P
5 F
-1.77 (config) 386.52 484 P
0 F
-0.74 ( to determine what files) 429.7 484 P
0.6 (are needed to build the kernel, locate these files, and build a Makefile for the kernel that) 108 470 P
0.89 (includes source file dependencies and rules for compiling and linking the kernel. In this) 108 456 P
0.1 (section we\325ll look at the various files and file excerpts produced by ) 108 442 P
5 F
0.23 (config) 434.25 442 P
0 F
0.1 ( and see how) 477.43 442 P
(they fit together when the kernel is compiled and linked. ) 108 428 T
3 F
(Compiler Options ) 108 404 T
0 F
1.26 (Some of the Makefile excerpts generated by ) 108 384 P
5 F
3.03 (config) 331.66 384 P
0 F
1.26 ( are hard-coded, for example, the) 374.84 384 P
2.11 (include file search path and some basic compiler options. Other compiler options are) 108 370 P
-0.46 (defined by including ) 108 356 P
5 F
-1.11 (options) 208.89 356 P
0 F
-0.46 ( lines in the kernel configuration file. If you define the NFS) 259.26 356 P
-0.14 (options \050as above\051, then you\325ll see these constants defined to the compiler when the kernel) 108 342 P
(is built:) 108 328 T
1 F
(# ) 153 305.33 T
6 F
(cd /sys/sun4c/TWODISK) 164.99 305.33 T
1 F
( ) 290.92 305.33 T
(# ) 153 293.33 T
6 F
(make) 164.99 293.33 T
1 F
( ) 188.98 293.33 T
(... ) 153 281.33 T
(cc -sparc -c -O -Dsun4c -DTWODISK -DSUN4C_70 -DSUN4C_60) 153 269.34 T
(-DWINSVJ -DVDDRV ) 153 257.34 T
(-DASYNCHIO -DLWP -DVFSSTATS -DRFS -DCRYPT) 254.94 257.34 T
(-DTCPDEBUG -DIPCSHMEM -DIPCSEMAPHORE ) 153 245.34 T
(-DIPCMESSAGE -DSYSAUDIT) 374.88 245.34 T
(-DSYSACCT -DHSFS -DTMPFS -DNFSSERVER -DNFSCLIENT -DUFS) 153 233.34 T
(-DQUOTA ) 153 221.34 T
(-DINET -DKERNEL -I. -I.. -I../.. ) 200.97 221.34 T
(../../netinet/in_proto.c ) 153 209.34 T
0 F
-0.07 (The laundry list of ) 108 184 P
5 F
-0.16 (#define) 199.67 184 P
0 F
-0.07 ( options on the ) 250.05 184 P
5 F
-0.16 (cc) 323.74 184 P
0 F
-0.07 ( command line comes from the ) 338.13 184 P
5 F
-0.16 (options) 489.63 184 P
0 F
(and CPU type definitions in the configuration file. ) 108 170 T
3 F
(Unit Header Files ) 108 146 T
0 F
-0.47 (As mentioned above, ) 108 126 P
5 F
-1.12 (config) 211.19 126 P
0 F
-0.47 ( needs to determine how many units of each device type will) 254.36 126 P
1.11 (be configured into the kernel. The ) 108 112 P
5 F
2.66 (config) 280.85 112 P
0 F
1.11 ( utility passes this information to the kernel) 324.03 112 P
0.74 (build procedure in unit header files, which are placed into the kernel build directory, for) 108 98 P
1.43 (example, ) 108 84 P
5 F
3.43 (/sys/sun4c/TWODISK) 156.06 84 P
0 F
1.43 (. These header files each contain one line that as a) 285.59 84 P
FMENDPAGE
%%EndPage: "12" 13
7 10 /Courier-Oblique FMDEFINEFONT
%%Page: "13" 13
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 13 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
5 F
0 X
-0.19 (#define) 108 712 P
0 F
-0.08 ( constant for the number of units. The file names are the device names with a ) 158.37 712 P
3 F
-0.08 (.) 529.8 712 P
5 F
-0.19 (h) 532.8 712 P
0 F
(header file suffix. ) 108 698 T
(Consider the kernel configuration file with the following SCSI devices defined: ) 108 674 T
1 F
(scsibus0 at esp) 153 651.33 T
( # declare first scsi bus ) 297 651.33 T
(disk sd0 at scsibus0 target 3 lun 0) 153 639.33 T
( # first hard SCSI disk) 362.89 639.33 T
(disk sd1 at scsibus0 target 1 lun 0) 153 627.33 T
( # second hard SCSI disk) 362.89 627.33 T
(tape st0 at scsibus0 target 4 lun 0) 153 615.33 T
( # first SCSI tape ) 362.89 615.33 T
5 F
(config) 108 590 T
0 F
( will generate three header files for these device configurations:) 151.18 590 T
1 F
(sd.h ) 153 567.33 T
7 F
(contains) 182.98 567.33 T
1 F
(#define NSD 2) 153 555.33 T
(st.h ) 153 531.33 T
7 F
(contains) 182.98 531.33 T
1 F
( ) 230.96 531.33 T
(#define NST 1) 153 519.33 T
(sr.h ) 153 495.33 T
7 F
(contains) 182.98 495.33 T
1 F
(#define NSR 0 ) 153 483.33 T
0 F
0.38 (The constants in each file start with the letter ) 108 458 P
5 F
0.91 (N) 330.27 458 P
0 F
0.38 (, and use the capitalized device name as a) 337.46 458 P
-0.05 (suffix. Since there are two s) 108 444 P
5 F
-0.11 (d) 241.66 444 P
0 F
-0.05 ( devices in the configuration file, ) 248.85 444 P
5 F
-0.11 (sd.h ) 410.12 444 P
0 F
-0.05 (defines ) 445.99 444 P
5 F
-0.11 (NSD) 483.58 444 P
0 F
-0.05 ( as 2 as) 505.17 444 P
(well. ) 108 430 T
0.06 (One unit header file will be generated for every standard device known by ) 108 406 P
5 F
0.14 (config) 468.12 406 P
0 F
0.06 (, even) 511.3 406 P
0.12 (if it does not appear in the configuration file. There are no CD-ROM devices in the above) 108 392 P
-0.67 (configuration, but ) 108 378 P
5 F
-1.6 (config) 195.61 378 P
0 F
-0.67 ( still generates an ) 238.79 378 P
5 F
-1.6 (sr.h) 322.74 378 P
0 F
-0.67 ( file, with ) 351.52 378 P
5 F
-1.6 (NSR) 398.83 378 P
0 F
-0.67 ( set to zero. A unit header) 420.42 378 P
0.38 (file will also be generated for every pseudo-device defined, with the unit number defined) 108 364 P
0.06 (as one \050if no numeric suffix is given\051 or the number of units specified in the configuration) 108 350 P
(line. For example, defining 128 window devices with: ) 108 336 T
1 F
(pseudo-device) 153 313.33 T
( win128 ) 230.96 313.33 T
0 F
(creates the header file ) 108 288 T
5 F
(win.h) 215.89 288 T
0 F
( containing: ) 251.87 288 T
1 F
(#define NWIN 128 ) 153 265.34 T
0 F
-0.47 (The number of units defined in these header files are used to size various per-device arrays,) 108 240 P
-0.24 (and also to conditionally compile drivers into the kernel. We\325ll see how this happens when) 108 226 P
(we look at the device switch tables later on. ) 108 212 T
3 F
(Kernel Object List ) 108 188 T
0 F
0.94 (The more difficult task faced by ) 108 168 P
5 F
2.26 (config) 270.87 168 P
0 F
0.94 ( is locating all of the files needed to build the) 314.04 168 P
(kernel: ) 108 154 T
([1]) 108 130 T
5 F
1.16 (config) 135 130 P
0 F
0.48 ( starts with a list of all of the standard files that must go into every kernel.) 178.18 130 P
-0.1 (These files contain code for the basic kernel services such as the virtual memory and) 135 116 P
(process management systems. ) 135 102 T
([2]) 108 76 T
-0.44 (For every device, pseudo device and option configured into the kernel, ) 135 76 P
5 F
-1.05 (config) 472.28 76 P
0 F
-0.44 ( adds) 515.45 76 P
FMENDPAGE
%%EndPage: "13" 14
%%Page: "14" 14
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 14 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(the files needed to support them to its component list. ) 135 712 T
([3]) 108 686 T
0.41 (Once the file list has been built, ) 135 686 P
5 F
0.99 (config) 293.11 686 P
0 F
0.41 ( determines whether these files need to be) 336.28 686 P
0.12 (compiled or if they are available in object form. It turns the list of source files into a) 135 672 P
0.28 (list of object files. For every file in the list, ) 135 658 P
5 F
0.67 (config) 346.33 658 P
0 F
0.28 ( looks for the source file. If the) 389.5 658 P
0.05 (source file cannot be found, then ) 135 644 P
5 F
0.11 (config) 295.49 644 P
0 F
0.05 ( references the object file in) 338.66 644 P
5 F
0.11 ( ../OBJ) 472.44 644 P
0 F
0.05 (. If) 522.92 644 P
0.54 (the source file does exist, then ) 135 630 P
5 F
1.28 (config) 286.44 630 P
0 F
0.54 ( generates Makefile rules for compiling the) 329.61 630 P
0.94 (source file into an object file, and adds a reference to the object file in the current) 135 616 P
(\050kernel build\051 directory. ) 135 602 T
1.73 (The third step means that you can compile just a few of the standard kernel files and) 108 576 P
-0.37 (override the distributed object files in ) 108 562 P
5 F
-0.9 (/sys/sun4c/OBJ) 288.97 562 P
0 F
-0.37 ( by putting the source file in the) 389.71 562 P
0.41 ("right place." ) 108 548 P
5 F
0.99 (config) 175.57 548 P
0 F
0.41 ( will find the source file, and compile it as part of the kernel build) 218.75 548 P
0.95 (instead of using the default version in the object directory. This is how you build a bug) 108 534 P
0.26 (patch - you deposit the few files that contain the patch on a test system, and run ) 108 520 P
5 F
0.62 (config) 496.82 520 P
0 F
-0.52 (to build a kernel Makefile that incorporates your modified source files. There\325s still one big) 108 506 P
0.38 (piece missing: How does ) 108 492 P
5 F
0.92 (config) 232.8 492 P
0 F
0.38 ( know what files are needed, and what the paths are to) 275.97 492 P
-0.5 (these files? This information comes from two tables that list kernel component files and the) 108 478 P
(conditions on which they are included in the kernel build. ) 108 464 T
(The two file tables are:) 108 440 T
1 F
(/sys/conf.common/files.cmn) 153 417.33 T
(/sys/sun4c/conf/files ) 153 405.33 T
0 F
0.51 (The ) 108 380 P
5 F
1.24 (files.cmn) 130.16 380 P
0 F
0.51 ( table lists components that are needed for every kernel independent of) 194.93 380 P
0.69 (kernel architecture. The ) 108 366 P
5 F
1.66 (files) 227.3 366 P
0 F
0.69 ( table is architecture-specific, and lists files that may not) 263.28 366 P
-0.59 (exist for all systems. Most of the standard kernel files are in ) 108 352 P
5 F
-1.42 (files.cmn) 391.05 352 P
0 F
-0.59 (, while things like) 455.81 352 P
-0.32 (SBus drivers are in the architecture-specific table. ) 108 338 P
5 F
-0.76 (config) 348.24 338 P
0 F
-0.32 ( opens the architecture-specific) 391.42 338 P
(table, which includes the common table through a ) 108 324 T
5 F
(#include ) 350.17 324 T
0 F
(directive. ) 414.93 324 T
(Both tables have the same format:) 108 300 T
1 F
(net/af.c) 153 277.34 T
(standard ) 261 277.34 T
(net/if.c) 153 265.34 T
(standard ) 261 265.34 T
(lwp/alloc.c) 153 253.34 T
(optional LWP ) 261 253.34 T
(lwp/process.c) 153 241.34 T
(optional LWP ) 261 241.34 T
(lwp/schedule.c) 153 229.34 T
(optional LWP ) 261 229.34 T
(os/tty_pty.c) 153 217.34 T
(optional pty ) 261 217.34 T
(os/tty_ptyconf.c) 153 205.34 T
(optional pty ) 261 205.34 T
0 F
0.41 (The first entry on each line is the path to the source file. Path names are given relative to) 108 180 P
0.29 (the ) 108 166 P
5 F
0.69 (/sys ) 125.94 166 P
0 F
0.29 (directory, and ) 162.61 166 P
5 F
0.69 (config) 232.8 166 P
0 F
0.29 ( converts them into paths that are relative to the kernel) 275.98 166 P
-0 (build directory when it generates compilation rules. The file name is followed by either of) 108 152 P
0.14 (the keywords ) 108 138 P
4 F
0.14 (standard) 175.56 138 P
0 F
0.14 ( or ) 218.21 138 P
4 F
0.14 (optional) 234.48 138 P
0 F
0.14 (, indicating whether the file is required in all kernels or) 274.46 138 P
-0.31 (whether it gets included as a result of a configuration choice. For files that are optional, the) 108 124 P
1.95 (last items indicate the name of the device driver, pseudo device or kernel option that) 108 110 P
0.33 (requires the file. These tokens are case-sensitive; kernel options are usually in upper case) 108 96 P
0.9 (while driver names are in lower case. To be included, all of the tokens on the line must) 108 82 P
FMENDPAGE
%%EndPage: "14" 15
%%Page: "15" 15
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 15 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(appear in the kernel configuration file. ) 108 712 T
3 F
(3.) 81 688 T
(Adding Devices) 108 688 T
0 F
-0.54 (Kernel hacking includes several different kinds of work: patching a kernel bug, adding new) 108 668 P
0.02 (files or services to the kernel, and adding a driver for a new physical device. To be able to) 108 654 P
-0.68 (do any of these jobs, you\325ll need to tie together knowledge of ) 108 640 P
5 F
-1.63 (config) 397.29 640 P
0 F
-0.68 (, the files it generates) 440.47 640 P
0.22 (and your list of source files. Building a bug patch is similar to adding a new device to the) 108 626 P
-0.38 (kernel, except that you don\325t have to edit any of the kernel configuration files: just drop the) 108 612 P
2.5 (modified source file into the right directory \050as defined by the configuration tables\051,) 108 598 P
1.68 (configure the kernel and then build it. In this section, we\325ll look at all of the changes) 108 584 P
2.25 (necessary to add a new service or device driver to the kernel, and then see how the) 108 570 P
(configuration process assigns a version number to the new kernel.) 108 556 T
3 F
(3.1.) 81 532 T
(Adding Kernel Files) 108 532 T
0 F
1.1 (Let\325s say we want to add a new service called ) 108 512 P
5 F
2.64 (kom) 341.49 512 P
0 F
1.1 (, contained in a single C source file) 363.08 512 P
-0.57 (named ) 108 498 P
5 F
-1.36 (kom.c) 142.4 498 P
0 F
-0.57 (. To educate ) 178.38 498 P
5 F
-1.36 (config) 238.63 498 P
0 F
-0.57 ( about our new driver, we need to decide where the file) 281.8 498 P
-0.16 (should go in the kernel area and also whether it will be an option or device driver. If this is) 108 484 P
0.37 (a basic service that will be needed by every kernel, then it might make sense to make the) 108 470 P
0.27 (file part of the standard component list. For this example, we\325ll put the new source file in) 108 456 P
(the new directory ) 108 442 T
5 F
(/sys/kom,) 194.93 442 T
0 F
( and treat it like a device driver. ) 259.69 442 T
([1]) 108 418 T
(We create the new directory and copy the source file into it:) 135 418 T
1 F
( ) 153 393.33 T
(# ) 189 393.33 T
6 F
(mkdir /sys/kom ) 200.99 393.33 T
1 F
(# ) 189 381.33 T
6 F
(cp kom.c /sys/kom ) 200.99 381.33 T
0 F
([2]) 108 356 T
0.42 (We then need to add ) 135 356 P
5 F
1 (kom.c) 238.68 356 P
0 F
0.42 ( to the ) 274.66 356 P
5 F
1 (files) 308.89 356 P
0 F
0.42 ( table. Using our favorite text editor, we) 344.88 356 P
(edit ) 135 342 T
5 F
(/sys/sun4c/conf/files) 155.99 342 T
0 F
( and add the line:) 307.11 342 T
1 F
(kom/kom.c) 153 317.33 T
(optional kom device-driver ) 225 317.33 T
0 F
([3]) 108 292 T
1.07 (Now ) 135 292 P
5 F
2.56 (config) 162.38 292 P
0 F
1.07 ( knows how to find the driver, but we still need to include it in our) 205.55 292 P
4.71 (kernel. Assuming we\325re still working on the ) 135 278 P
5 F
11.31 (TWODISK) 382.51 278 P
0 F
4.71 ( kernel, we edit its) 432.88 278 P
4.09 (configuration file ) 135 264 P
5 F
9.83 (/sys/sun4c/conf/TWODISK) 229.79 264 P
0 F
4.09 ( and add the device driver) 395.3 264 P
(specification:) 135 250 T
1 F
( ) 153 225.34 T
(pseudo-device) 189 225.34 T
( kom) 266.96 225.34 T
(# kom driver ) 333 225.34 T
0 F
([4]) 108 200 T
0.14 (Now we run ) 135 200 P
5 F
0.34 (config) 197.71 200 P
0 F
0.14 ( and build the kernel. If the) 240.89 200 P
5 F
0.34 ( kom.c ) 375.12 200 P
0 F
0.14 (file has syntax errors or) 426.18 200 P
-0.27 (won\325t build for some other reason, the kernel build will fail and we\325ll have to edit the) 135 186 P
(source file and fix the problems. ) 135 172 T
0.23 (As mentioned above, you don\325t need to reconfigure the kernel to just rebuild it. If you fix) 108 146 P
-0.42 (a bug in the ) 108 132 P
5 F
-1 (kom.c) 165.63 132 P
0 F
-0.42 ( source file, just type ) 201.61 132 P
5 F
-1 (make) 302.8 132 P
0 F
-0.42 ( in the kernel build directory to create a new) 331.58 132 P
-0.28 (kernel - there\325s no need to re-run ) 108 118 P
5 F
-0.68 (config) 266.86 118 P
0 F
-0.28 ( because the last Makefile you built is still valid.) 310.04 118 P
(The Makefile rules are still applicable even if the source files are broken. ) 108 104 T
FMENDPAGE
%%EndPage: "15" 16
8 12 /Times-BoldItalic FMDEFINEFONT
%%Page: "16" 16
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 16 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
3 F
0 X
(3.2.) 81 712 T
(Device Switch Tables) 108 712 T
0 F
0.89 (Up to this point, we\325ve looked at how the kernel gets devices configured into it, but we) 108 692 P
1.42 (haven\325t touched on how a user gets to a particular device through the ) 108 678 P
5 F
3.4 (/dev) 460.51 678 P
0 F
1.42 ( directory.) 489.29 678 P
0.35 (Major device numbers and the device switch tables are the two major components of this) 108 664 P
1.55 (interface. In this section, we\325ll look at how the switch tables work and how the major) 108 650 P
(numbers are defined.) 108 636 T
3 F
(Block and Character Devices ) 108 612 T
0 F
-0.44 (The UNIX kernel handles two kinds of device: block and character oriented. Block devices) 108 592 P
0.3 (usually provide random access to their data, but only in block-sized chunks. Probably the) 108 578 P
-0.63 (only block devices you\325ll run into are floppy and hard disks, both of which handle their data) 108 564 P
2.37 (in sector-sized blocks. Character devices present a byte-oriented interface, sometimes) 108 550 P
0.16 (included random access as well. The tty drivers are classic character oriented devices, but) 108 536 P
-0.09 (random access isn\325t very well defined on them. A VME memory board, however, can also) 108 522 P
1.78 (be viewed as a character-oriented device, although random access is both defined and) 108 508 P
(required for this driver. ) 108 494 T
0.69 (Block devices have a ) 108 470 P
4 F
0.69 (strategy) 215.33 470 P
0 F
0.69 ( routine that maps read and write requests into disk blocks) 253.98 470 P
-0.29 (and handles a queue of requests for the device. A smart strategy routine may sort incoming) 108 456 P
2.35 (disk requests by cylinder number to minimize seek time. Obviously, this kind of re-) 108 442 P
0 (ordering has hideous effects on character device interfaces, where users depend on having) 108 428 P
-0.42 (their requests executed in the order in which they were executed. It\325s also worth noting that) 108 414 P
0.73 (some block-mode devices also have character-mode drivers associated with them, called) 108 400 P
8 F
1.27 (raw) 108 386 P
0 F
1.27 ( devices, that are used when the device needs to be accessed in a purely sequential) 126.66 386 P
0.43 (fashion. If you want to read an entire disk using ) 108 372 P
5 F
1.02 (dd) 344.43 372 P
0 F
0.43 (, for example, you\325d use the raw disk) 358.82 372 P
(device instead of the block device. ) 108 358 T
3 F
(Switch Tables ) 108 334 T
0 F
0.23 (The kernel\325s interface to block and character devices is the ) 108 314 P
5 F
0.54 (bdevsw) 395.35 314 P
0 F
0.23 ( and ) 438.53 314 P
5 F
0.54 (cdevsw) 462.3 314 P
0 F
0.23 ( device) 505.47 314 P
0.9 (switch tables. These tables define the kernel entry points for each services - read, write,) 108 300 P
0.17 (open, close, and so on - provided by the device drivers. The ) 108 286 P
5 F
0.42 (bdevsw) 399.53 286 P
0 F
0.17 ( switch entry for the) 442.71 286 P
(floppy driver, for example, looks like:) 108 272 T
1 F
( { fdopen, fdclose, fdstrategy, fddump, /*16*/) 153 249.34 T
( fdsize, 0 }, ) 153 237.34 T
0 F
0.12 (The number in comment brackets is the major device number for the floppy. If you take a) 108 212 P
(look at the floppy\325s entry in ) 108 198 T
5 F
(/dev,) 244.58 198 T
0 F
( you\325ll notice that the major device numbers match: ) 280.56 198 T
1 F
(# ) 153 175.34 T
6 F
(ls -l /dev/fd0) 164.99 175.34 T
1 F
(brw-rw-rw- 2 root 16, 2 Oct 16 12:22 /dev/fd0 ) 153 163.34 T
0 F
1.85 (The leading ) 108 138 P
5 F
4.44 (b) 171.66 138 P
0 F
1.85 ( indicates that this is a block device. We\325ll see where the major device) 178.85 138 P
(numbers come from later in this section. ) 108 124 T
(A typical character device switch table entry is a little different: ) 108 100 T
1 F
({ ptcopen, ptcclose, ptcread, ptcwrite, /*21*/ ) 153 77.34 T
FMENDPAGE
%%EndPage: "16" 17
%%Page: "17" 17
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 17 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
1 F
0 X
( ptcioctl, nulldev, ptcselect, 0, 0, 0, ) 153 713.33 T
(}, ) 398.86 713.33 T
0 F
1.41 (This entry defines the interface to the pseudo-tty device driver. Note that the character) 108 688 P
-0.04 (device switch doesn\325t have ) 108 674 P
4 F
-0.04 (strategy) 240.38 674 P
0 F
-0.04 ( or ) 279.03 674 P
4 F
-0.04 (dump) 294.93 674 P
0 F
-0.04 ( routines in it, but it does have support for the) 321.58 674 P
-0.69 (familiar ) 108 660 P
4 F
-0.69 (ioctl\050\051) 148.28 660 P
0 F
-0.69 ( and ) 177.59 660 P
4 F
-0.69 (select\050\051) 199.52 660 P
0 F
-0.69 ( routines. Like the block-mode device, the character device entry) 234.82 660 P
-0.14 (has a major device number in comments, which corresponds to its major device number in) 108 646 P
(its ) 108 632 T
5 F
(/dev ) 122.33 632 T
0 F
(directory entry: ) 158.31 632 T
1 F
(# ) 153 609.33 T
6 F
(ls -l /dev/ptyp0) 164.99 609.33 T
1 F
(crw-rw-rw- 1 root 21, 0 Feb 26 15:03 /dev/ptyp0 ) 153 597.33 T
0 F
1.96 (Both the ) 108 572 P
5 F
4.7 (cdevsw) 155.9 572 P
0 F
1.96 ( and ) 199.07 572 P
5 F
4.7 (bdevsw) 226.31 572 P
0 F
1.96 ( tables are in the file ) 269.49 572 P
5 F
4.7 (/sys/sun/conf.c) 381.83 572 P
0 F
1.96 (, which is) 489.77 572 P
(included in a standard binary kernel distribution. ) 108 558 T
3 F
(Major Device Numbers ) 108 534 T
0 F
0.24 (Major device numbers are the link between the user and kernel device interfaces. When a) 108 514 P
-0.19 (user opens up a device, the kernel uses the major number of the device as an index into the) 108 500 P
-0.54 (appropriate character or block device table to find the device-specific ) 108 486 P
4 F
-0.54 (open\050\051) 438.36 486 P
0 F
-0.54 ( routine. If you) 469.66 486 P
-0.16 (open ) 108 472 P
5 F
-0.38 (/dev/ptyp0) 134.16 472 P
0 F
-0.16 (, which has major device number 21, the kernel finds the open routine) 206.12 472 P
(in entry 21 in ) 108 458 T
5 F
(cdevsw) 175.29 458 T
0 F
(, and invokes that routine to complete the ) 218.47 458 T
4 F
(open\050\051) 420.01 458 T
0 F
( system call. ) 451.31 458 T
2.51 (Major device numbers are therefore implicitly defined by the order of entries in the) 108 434 P
5 F
-0.82 (bdevsw) 108 420 P
0 F
-0.34 ( and ) 151.18 420 P
5 F
-0.82 (cdevsw) 173.81 420 P
0 F
-0.34 ( tables. If you follow the numbers in table comments, you\325ll see that) 216.98 420 P
0.28 (they increase linearly as you go through the table. Because of this positional definition of) 108 406 P
0.93 (major device numbers, you must maintain the number and order of devices in the table.) 108 392 P
0.58 (Otherwise, you will break all device interfaces. If a device is not present in the kernel, it) 108 378 P
-0.41 (should be represented by a placeholder entry that uses the ) 108 364 P
5 F
-0.97 (nodev) 383.73 364 P
0 F
-0.41 ( entry points \050here shown) 419.71 364 P
(for the ) 108 350 T
5 F
(bdevsw) 142.64 350 T
0 F
(\051:) 185.81 350 T
1 F
( ) 153 327.33 T
({ nodev, nodev, nodev, nodev, /*0*/ ) 189 327.33 T
( 0, 0 },) 189 315.33 T
0 F
-0.22 ( If you attempt to use a device that has ) 108 290 P
4 F
-0.22 (nodev\050\051) 293.7 290 P
0 F
-0.22 ( placeholders in the switch table, the system) 330.33 290 P
(call will return a "No such device" error. ) 108 276 T
0.4 (This points out an interesting problem in building a kernel: device driver entry points are) 108 252 P
-0.19 (defined in the switch tables, which must contain entries for all devices, but if a device type) 108 238 P
-0.55 (isn\325t included in the configuration file, ) 108 224 P
5 F
-1.32 (config) 292.92 224 P
0 F
-0.55 ( won\325t include its associated object module) 336.1 224 P
1.39 (in the kernel build. How do you prevent undefined routine references \050to unconfigured) 108 210 P
(devices\051 from the switch tables? ) 108 196 T
0.44 (The keys are the ) 108 172 P
5 F
1.07 (nodev) 191.7 172 P
0 F
0.44 ( entry point and the unit header files. In the ) 227.68 172 P
5 F
1.07 (conf.c) 442.3 172 P
0 F
0.44 ( file, you\325ll) 485.48 172 P
(see a long list of conditional compilations of the form: ) 108 158 T
1 F
(#include "sd.h" ) 153 135.34 T
(#if NSD > 0 ) 153 123.34 T
(extern int sdopen\050\051, sdclose\050\051, sdstrategy\050\051, ) 153 111.34 T
( sdread\050\051, sdwrite\050\051; ) 189 99.34 T
(extern int sddump\050\051, sdioctl\050\051, sdsize\050\051; ) 153 87.34 T
(#else ) 153 75.34 T
FMENDPAGE
%%EndPage: "17" 18
%%Page: "18" 18
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 18 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
1 F
0 X
(#define sdopen nodev ) 153 713.33 T
(#define sdclose nodev ) 153 701.33 T
(#define sdstrategy nodev ) 153 689.33 T
(#define sdread nodev ) 153 677.33 T
(#define sdwrite nodev ) 153 665.33 T
(#define sddump nodev ) 153 653.33 T
(#define sdioctl nodev ) 153 641.33 T
(#define sdsize 0 ) 153 629.33 T
(#endif ) 153 617.33 T
0 F
1.12 (If the number of SCSI disk devices defined in the unit header file is non-zero, then the) 108 592 P
5 F
2.19 (conf.c) 108 578 P
0 F
0.91 ( file makes the external references to the driver entry points. If the device isn\325t) 151.18 578 P
0.43 (used, however, all of the entry points are aliased to ) 108 564 P
4 F
0.43 (nodev\050\051) 359.46 564 P
0 F
0.43 (. The ) 396.08 564 P
5 F
1.03 (bdevsw) 424.59 564 P
0 F
0.43 ( table entry for) 467.77 564 P
0.29 (the ) 108 550 P
5 F
0.69 (sd) 125.94 550 P
0 F
0.29 ( device, then, either points to the actual driver or is just a placeholder that refers to) 140.34 550 P
4 F
-0.65 (nodev\050\051) 108 536 P
0 F
-0.65 (. If no ) 144.63 536 P
5 F
-1.57 (sd) 174.65 536 P
0 F
-0.65 ( devices are configured into the kernel, the) 189.04 536 P
5 F
-1.57 ( sd.o ) 388.97 536 P
0 F
-0.65 (module is not compiled) 429.01 536 P
(into the kernel, and no external references are made to it from the switch tables. ) 108 522 T
3 F
(3.3.) 81 498 T
(Adding a New Device) 108 498 T
0 F
0.27 (To add a new device, you must edit ) 108 478 P
5 F
0.64 (conf.c) 283.67 478 P
0 F
0.27 ( and either replace or add a new entry in the) 326.85 478 P
0.54 (appropriate switch table. Let\325s say we want to add a device for the ) 108 464 P
5 F
1.29 (kom) 436.09 464 P
0 F
0.54 ( character device) 457.68 464 P
2.36 (we configured in a previous section. In ) 108 450 P
5 F
5.67 (conf.c) 314.4 450 P
0 F
2.36 (, we first have to add a conditional) 357.58 450 P
(compilation stanza: ) 108 436 T
1 F
(#include "kom.h" ) 153 413.33 T
(#if NKOM > 0 ) 153 401.33 T
(extern int komopen\050\051, komclose\050\051, komread\050\051, komwrite\050\051;) 153 389.33 T
(extern int komioctl\050\051, komselect\050\051;) 153 377.33 T
(#else) 153 365.33 T
(#define komopen nodev) 153 353.33 T
(#define komclose nodev) 153 341.33 T
(#define komread nodev) 153 329.33 T
(#define komwrite nodev) 153 317.33 T
(#define komioctl nodev) 153 305.33 T
(#define komselect nodev) 153 293.33 T
(#endif ) 153 281.33 T
0 F
2.62 (The ) 108 256 P
5 F
6.3 (kom.h) 132.27 256 P
0 F
2.62 ( header file will be created by ) 168.25 256 P
5 F
6.3 (config) 332.16 256 P
0 F
2.62 ( when it sees the pseudo-device) 375.33 256 P
0.71 (configuration line. Our driver, in file ) 108 242 P
5 F
1.71 (kom.c) 291.47 242 P
0 F
0.71 (, should define all of these entry points and) 327.45 242 P
-0.21 (contain the code to implement them. If the user chooses to exclude the ) 108 228 P
5 F
-0.5 (kom) 446.41 228 P
0 F
-0.21 ( driver, then its) 468 228 P
(entry points will become aliased to ) 108 214 T
4 F
(nodev\050\051) 278.56 214 T
0 F
(. ) 315.19 214 T
0.58 (With the external references set up, we need to add an entry to the ) 108 190 P
5 F
1.38 (cdevsw) 436.14 190 P
0 F
0.58 ( for our new) 479.32 190 P
-0.74 (driver. We can either choose an unused entry, or add a new one to the end. ) 108 176 P
3 F
-0.74 (NOTE:) 456.88 176 P
0 F
-0.74 ( We can\325t) 494.86 176 P
-0.34 (just drop our new entry into the middle of the table, because this will skew all of the device) 108 162 P
3.66 (numbers that follow our addition. The major device numbers are strictly position-) 108 148 P
(dependent, so we must either replace an entry or add to the end of the table. ) 108 134 T
(We\325ll add our driver to the end of the table: ) 108 110 T
1 F
({ komopen, komclose, komread, komwrite, /*104*/) 153 87.34 T
( komioctl, nulldev, komselect, nulldev, 0, nulldev. ) 153 75.34 T
(},) 470.83 75.34 T
FMENDPAGE
%%EndPage: "18" 19
8 10 /Times-Roman FMDEFINEFONT
%%Page: "19" 19
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 19 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.63 (The major device number - 104 - was derived by adding one to the major number of the) 108 712 P
0.79 (device ahead of ours in the ) 108 698 P
5 F
1.88 (cdevsw) 244.6 698 P
0 F
0.79 ( table. Note that routines that are undefined for this) 287.78 698 P
0.61 (driver are now listed as ) 108 684 P
5 F
1.47 (nulldev) 225.97 684 P
0 F
0.61 ( instead of ) 276.34 684 P
5 F
1.47 (nodev) 331.14 684 P
0 F
0.61 (; ) 367.12 684 P
5 F
1.47 (nodev) 374.06 684 P
0 F
0.61 ( means the entire device is) 410.04 684 P
-0.67 (missing \050and returns an error\051 while ) 108 670 P
5 F
-1.62 (nulldev) 279.16 670 P
0 F
-0.67 ( just stubs out a particular function \050and does) 329.53 670 P
(not return an error\051. ) 108 656 T
-0.47 (Now the kernel knows how to find our device, and the kernel build procedure knows where) 108 632 P
-0.3 (to find the object or source code for the driver. We just need to give the user an interface to) 108 618 P
-0.42 (the device, by creating entries in ) 108 604 P
5 F
-1.01 (/dev) 264.35 604 P
0 F
-0.42 ( for it. Let\325s assume that the ) 293.13 604 P
5 F
-1.01 (kom) 427.42 604 P
0 F
-0.42 ( driver defines four) 449.01 604 P
(units by default, so we\325ll create four minor units of major unit 104: ) 108 590 T
1 F
(# ) 153 567.33 T
6 F
(cd /dev ) 164.99 567.33 T
1 F
(# ) 153 555.33 T
6 F
(mknod kom0 c 104 0 ) 164.99 555.33 T
1 F
(# ) 153 543.33 T
6 F
(mknod kom1 c 104 1 ) 164.99 543.33 T
1 F
(# ) 153 531.33 T
6 F
(mknod kom2 c 104 2 ) 164.99 531.33 T
1 F
(# ) 153 519.33 T
6 F
(mknod kom3 c 104 3 ) 164.99 519.33 T
0 F
(In a user application, we can access the kom device using ) 108 494 T
4 F
(open) 387.11 494 T
0 F
(\050\051:) 410.43 494 T
1 F
( fd = open\050"/dev/kom0", O_RDONLY\051; ) 153 471.33 T
0 F
-0.62 (and have the kernel locate the open routine for character device 104; it then calls ) 108 446 P
4 F
-0.62 (komopen\050\051) 488.72 446 P
0 F
2.5 (with the arguments passed in the system call. Our device-specific open routine does) 108 432 P
0.33 (whatever initialization is required, and the user is ready to read from the device using the) 108 418 P
(file descriptor passed back by ) 108 404 T
4 F
(open\050\051) 253.55 404 T
0 F
(. ) 284.86 404 T
3 F
(3.4.) 81 380 T
(Kernel Version Numbers ) 108 380 T
0 F
0.11 (Each time you build the kernel, the version number is incremented and a timestamp is put) 108 360 P
0.01 (into it. You\325ll see this information in the ) 108 346 P
5 F
0.04 (/etc/motd ) 305.01 346 P
0 F
0.01 (file when you log into the system.) 377.01 346 P
-0.25 (When building the kernel, a short source file called ) 108 332 P
5 F
-0.61 (vers.c) 354.2 332 P
0 F
-0.25 ( is created and compiled. This) 397.37 332 P
1.3 (file contains timestamp, version and kernel name information taken from the following) 108 318 P
(files:) 108 304 T
1 F
(/sys/conf.common/RELEASE) 153 281.33 T
8 F
(SunOS release number \050eg, 4.1\051) 333 281.33 T
1 F
(/sys/sun4c/TWODISK/version) 153 269.34 T
8 F
(Kernel version number ) 333 269.34 T
1 F
(/sys/conf.common/newvers.sh) 153 257.34 T
8 F
(Script for building) 333 257.34 T
1 F
( vers.c ) 406.85 257.34 T
0 F
1.77 (You may want to change the default version and timestamp information, or add more) 108 232 P
-0.69 (information that identifies particular changes you have made to the kernel. Some OEMs use) 108 218 P
0.33 (this feature to change the name of the operating system, or to add their own comments to) 108 204 P
(the timestamp. ) 108 190 T
0.49 (If you modify ) 108 166 P
5 F
1.19 (newvers.sh) 179.1 166 P
0 F
0.49 (, don\325t remove the word ) 251.07 166 P
5 F
1.19 (SunOS) 372.12 166 P
0 F
0.49 ( from the timestamp unless) 408.1 166 P
0.51 (you also change the boot script that creates) 108 152 P
5 F
1.22 ( /etc/motd) 321.25 152 P
0 F
0.51 (. The boot procedure searches) 394.43 152 P
(the kernel for the string ) 108 138 T
5 F
(SunOS) 223.58 138 T
0 F
(, and copies the entire string into ) 259.56 138 T
5 F
(/etc/motd) 419.46 138 T
0 F
(. ) 484.22 138 T
3 F
(4.) 81 114 T
(Debugging and Core Dump Analysis) 108 114 T
0 F
1.38 (Getting a kernel built and installed is the easy part of integrating new system services.) 108 94 P
0.35 (Debugging problems within the kernel is one of the more difficult problems in the UNIX) 108 80 P
FMENDPAGE
%%EndPage: "19" 20
%%Page: "20" 20
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 20 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.21 (world. There is both a lack of nice tools \050like ) 108 712 P
5 F
0.5 (dbxtool) 328.91 712 P
0 F
0.21 ( or Saber C\051 and a lack of a well-) 379.28 712 P
2.27 (behaved, time-sequenced execution environment. In a user application, you have fine) 108 698 P
-0.05 (control over the order of statement execution and the global state. The kernel, on the other) 108 684 P
1.53 (hand, is a collection of service routines that get called on demand by interrupt or user) 108 670 P
-0.51 (requests. You could be in middle of your new device driver when a higher priority interrupt) 108 656 P
-0.09 (comes in and changes some global state. For example, you may assume that you\325ll be able) 108 642 P
0.6 (to use some buffer once you\325re in your driver. However, if another device interrupts and) 108 628 P
-0.21 (grabs that buffer before you do, any number of unpleasant things may happen if you fail to) 108 614 P
(check for this condition \050or prevent it\051 in your driver. ) 108 600 T
0.23 (This section first looks at common debugging techniques, including the use of ) 108 576 P
5 F
0.55 (printf) 488.84 576 P
0 F
0.23 (\050\051) 532.01 576 P
0.61 (inside the kernel and the ) 108 562 P
5 F
1.47 (kadb) 231.3 562 P
0 F
0.61 ( debugger. Then we\325ll look at core dumps in some detail,) 260.08 562 P
0.88 (including an explanation of bad traps and panics. This short introduction should explain) 108 548 P
(why kernel hackers are the way they are.) 108 534 T
3 F
(4.1.) 81 510 T
(Debugging Techniques) 108 510 T
0 F
2.69 (There are several ways to debug a device driver or kernel service: you can include) 108 490 P
0.44 (debugging code that prints messages about variables and state information, you can trace) 108 476 P
1.03 (the calls made by a driver, or you use the kernel debugger ) 108 462 P
5 F
2.47 (kadb) 401.14 462 P
0 F
1.03 ( to stop in a particular) 429.92 462 P
0.28 (routine and single-step through a problematic piece of code. Each approach has its merits) 108 448 P
2.36 (and its best applications: time constraints may make debugging statements or single-) 108 434 P
1.18 (stepping infeasible. This section covers each technique and offers some suggestions for) 108 420 P
(choosing when to use each approach.) 108 406 T
3 F
(Using printf\050\051) 108 382 T
0 F
0.33 (The most common, and sometimes most dangerous way to trace kernel calling sequences) 108 362 P
0.29 (and variables is with the friendly ) 108 348 P
5 F
0.69 (printf) 270.29 348 P
0 F
0.29 (\050\051 statement. Output from ) 313.46 348 P
5 F
0.69 (print) 440.2 348 P
0 F
0.29 (\050\051 calls in the) 476.18 348 P
0.25 (kernel is sent to the ) 108 334 P
5 F
0.6 (/var/adm/messages) 205.51 334 P
0 F
0.25 ( file, and appears in the console window \050or) 327.84 334 P
-0.43 (console device, if you have a terminal attached as a console\051. The major problem with this) 108 320 P
0.1 (approach is that calling the print routine many times can take several seconds. If you put) 108 306 P
5 F
-1.47 (printf) 108 292 P
0 F
-0.61 (\050\051 calls inside of a device driver that has tight timing constraints, you will probably) 151.18 292 P
(violate those constraints and break the driver in new ways.) 108 278 T
1.21 (You can put ) 108 254 P
5 F
2.91 (printf) 173.26 254 P
0 F
1.21 (\050\051 calls in code that is called at user level, and inside of interrupt) 216.44 254 P
0.31 (routines that have no time dependencies and run at low interrupt priority \050below the level) 108 240 P
-0.46 (of the UART chip\051. Adding debug statements to the top levels of a device driver\325s ) 108 226 P
5 F
-1.1 (read) 503.23 226 P
0 F
-0.46 (\050\051) 532.01 226 P
-0.38 (routine, for example, is unlikely to cause side effects, because the time required to print the) 108 212 P
-0.35 (debug messages will simply slow down the user process making the ) 108 198 P
5 F
-0.83 (read) 433.65 198 P
0 F
-0.35 (\050\051 system call. If) 462.43 198 P
1.33 (you put these debug statements in the interrupt handler, though, you may exceed some) 108 184 P
-0.34 (timeout period set by the device, or you may miss another interrupt during the time that the) 108 170 P
(kernel is printing the debug output. ) 108 156 T
0.68 (Serial devices and network interfaces are poor candidates for debugging with ) 108 132 P
5 F
1.63 (printf) 488.84 132 P
0 F
0.68 (\050\051) 532.01 132 P
2.44 (calls. Parts of the serial line drivers will be run at high interrupt priority, so calling) 108 118 P
5 F
-0.59 (printf) 108 104 P
0 F
-0.25 (\050\051 from inside the driver may create race conditions when the processor priority is) 151.18 104 P
-0.71 (temporarily lowered to print the debug message. Both serial drivers and network interfaces) 108 90 P
0.52 (rely on efficient execution of interrupt code, so adding the overhead of console output to) 108 76 P
FMENDPAGE
%%EndPage: "20" 21
%%Page: "21" 21
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 21 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
-0.34 (these routines makes it more likely that they\325ll miss incoming data or packets. If you need) 108 712 P
(to examine a calling sequence in a driver like this, use an in-memory call tracer.) 108 698 T
3 F
(Call Tracer) 108 674 T
0 F
1.36 (A call tracer records the sequence of routines called within a driver in a small, kernel-) 108 654 P
0.44 (resident buffer. You can examine the calling sequence by dumping the trace buffer using) 108 640 P
5 F
(adb) 108 626 T
0 F
(. Here\325s an overly simple example of a call tracer for the ) 129.59 626 T
5 F
(zz) 409.68 626 T
0 F
( device driver:) 424.07 626 T
1 F
(#define ZZ_MAXCALLS) 153 603.33 T
(1024) 297 603.33 T
(int) 153 591.33 T
(zz_calls[ZZ_MAXCALLS];) 189 591.33 T
(int) 153 579.33 T
(zz_debug = 0;) 189 579.33 T
(int) 153 567.33 T
(zz_depth = 0;) 189 567.33 T
(#define ZZ_TRACE\050x\051 if \050zz_debug && \050zz_depth<ZZ_MAXCALLS\051\051 \134) 153 555.33 T
({ zz_calls[zz_depth] = x; zz_depth++; }) 225 543.33 T
2 F
(in interrupt routine) 153 519.33 T
1 F
( zz_intr\050\051:) 230.19 519.33 T
(ZZ_TRACE\0501\051;) 153 507.33 T
2 F
(in read routine) 153 483.33 T
1 F
( zz_read\050\051:) 212.97 483.33 T
(ZZ_TRACE\0502\051;) 153 471.33 T
2 F
(in write routine) 153 447.33 T
7 F
( ) 215.2 447.33 T
1 F
(zz_write\050\051:) 221.19 447.33 T
(ZZ_TRACE\0503\051;) 153 435.33 T
0 F
0.45 (We define an identifier for each routine that we want to trace; these identifiers are poked) 108 410 P
0.62 (into the ) 108 396 P
5 F
1.49 (zz_calls) 148.56 396 P
0 F
0.62 ( history array whenever a ) 206.13 396 P
5 F
1.49 (ZZ_TRACE) 334.12 396 P
0 F
0.62 (\050\051 macro appears in the driver.) 391.69 396 P
0.1 (To debug a section of code with this driver, you first set ) 108 382 P
5 F
0.24 (zz_debug=1) 380.7 382 P
0 F
0.1 ( in the live kernel,) 452.65 382 P
-0.64 (and then let the driver run \050and hopefully crash and burn as well\051. Within ) 108 368 P
5 F
-1.54 (adb) 453.06 368 P
0 F
-0.64 (, you can then) 474.65 368 P
(examine the calling sequence by dumping ) 108 354 T
5 F
(zz_calls) 312.52 354 T
0 F
(:) 370.09 354 T
1 F
(# ) 153 331.33 T
6 F
(adb -k -w /vmunix /dev/mem) 164.99 331.33 T
1 F
(physmem ff3) 153 319.33 T
6 F
(zz_debug/W 1) 153 307.33 T
1 F
(zz_debug: 0x0 = 0x1) 153 295.33 T
7 F
(...use driver....) 153 283.33 T
6 F
(zz_calls,8/D) 153 271.34 T
1 F
(zz_calls:) 153 259.34 T
(2) 225 259.34 T
(1) 261 259.34 T
(1) 297 259.34 T
(1) 333 259.34 T
(3) 225 247.34 T
(1) 261 247.34 T
(1) 297 247.34 T
(2) 333 247.34 T
0 F
2.18 (In this case, you can tell that the driver\325s read routine was called, followed by three) 108 222 P
0.52 (interrupts, and then a call to the write routine. You may want to add timestamps to the) 108 208 P
0.21 (call history, so you can tell how much time elapsed between calls \050if you\325re trying to find) 108 194 P
0.67 (timing problems\051. It\325s critical that the tracing macro check the current stack usage, and) 108 180 P
0.37 (stop tracing calls when the call history array is full. Overflowing an array in the kernel is) 108 166 P
-0.1 (just as dangerous as doing so in a user-level process: it causes data corruption, unexpected) 108 152 P
(results, or a core dump.) 108 138 T
(If you want to run the driver again, you can reset the call history counter using ) 108 114 T
5 F
(adb) 487.39 114 T
0 F
(:) 508.98 114 T
1 F
(# ) 153 91.34 T
6 F
(adb -k -w /vmunix /dev/mem) 164.99 91.34 T
1 F
(physmem ff3) 153 79.34 T
FMENDPAGE
%%EndPage: "21" 22
%%Page: "22" 22
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 22 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
6 F
0 X
(zz_depth/W 0) 153 713.33 T
1 F
(zz_depth: 0x400 = 0x0) 153 701.33 T
7 F
(...use driver again...) 153 689.33 T
0 F
-0.57 (Resetting the trace counter to zero allows you to fill the array up again with fresh trace data.) 108 664 P
3 F
(The kadb Debugger) 108 640 T
0 F
-0.23 (Not every problem can be debugged using ) 108 620 P
5 F
-0.56 (printf) 312.53 620 P
0 F
-0.23 (\050\051 calls or a call tracer, particularly if it) 355.71 620 P
0.69 (involves device setup and initialization code. You can\325t use ) 108 606 P
5 F
1.66 (adb) 402.68 606 P
0 F
0.69 ( until your system is up) 424.27 606 P
1.48 (and running. If you can\325t get a new kernel to boot properly, you need to use ) 108 592 P
5 F
3.55 (kadb) 497.41 592 P
0 F
1.48 ( to) 526.19 592 P
-0.67 (examine the kernel during its nascent configuration stages. k) 108 578 P
5 F
-1.6 (adb) 393.47 578 P
0 F
-0.67 ( is similar to adb in its user) 415.06 578 P
-0.13 (interface \050or lack of one\051. The major difference is that ) 108 564 P
5 F
-0.32 (kadb) 368.1 564 P
0 F
-0.13 ( is a bootable image: you load) 396.89 564 P
1.27 (it first, and then it loads the kernel so that you can debug the kernel before the system) 108 550 P
(becomes functional. ) 108 536 T
(Boot ) 108 512 T
5 F
(kadb) 134.33 512 T
0 F
( from the PROM monitor:) 163.11 512 T
1 F
(> b kadb) 153 489.33 T
0 F
0.02 (If you are debugging a diskless client, you\325ll probably have to specify the boot device and) 108 464 P
5 F
(kadb) 108 450 T
0 F
( image:) 136.78 450 T
1 F
(> b le\050\051kadb) 153 427.33 T
0 F
0.56 (If you want to set breakpoints before the kernel is loaded, boot ) 108 402 P
5 F
1.34 (kadb) 418.16 402 P
0 F
0.56 ( interactively using) 446.94 402 P
(the -) 108 388 T
5 F
(d) 129.65 388 T
0 F
( option:) 136.84 388 T
1 F
(> b kadb -d) 153 365.33 T
0 F
-0.55 (Once ) 108 340 P
5 F
-1.32 (kadb) 135.75 340 P
0 F
-0.55 ( is up and running, you can escape from the kernel back into the debugger using) 164.54 340 P
0.26 (the L1-A abort sequence \050or the BREAK key on a terminal\051. Within ) 108 326 P
5 F
0.63 (kadb) 447.07 326 P
0 F
0.26 (, aborting the) 475.85 326 P
0.17 (system again takes you back to the PROM monitor. See the manual pages for ) 108 312 P
5 F
0.4 (kadb) 490.73 312 P
0 F
0.17 ( and) 519.52 312 P
-0.37 (adb for more information on setting breakpoints, single stepping and continuing execution.) 108 298 P
3 F
(4.2.) 81 274 T
(Core Dumps) 108 274 T
0 F
0.82 (The debugging techniques described in the previous section are useful if you are adding) 108 254 P
-0.56 (code or new devices to the operating system. However, you may experience system crashes) 108 240 P
0.82 (or hangs with purely "standard" software and hardware. These problems fall into three) 108 226 P
0.09 (classes: panics, bad traps and system hangs. The best way to debug any of these problems) 108 212 P
(is with a core dump.) 108 198 T
3 F
(Saving Core Dumps) 108 174 T
0 F
0.94 (A core dump is a set of two files - ) 108 154 P
5 F
2.26 (vmunix) 283.31 154 P
0 F
0.94 (.) 326.49 154 P
4 F
0.94 (n) 329.49 154 P
0 F
0.94 ( and) 335.48 154 P
5 F
2.26 ( vmcore) 356.74 154 P
0 F
0.94 (.) 409.38 154 P
4 F
0.94 (n) 412.38 154 P
0 F
0.94 ( - that contain the kernel) 418.37 154 P
-0.41 (image that was executing and a complete physical memory image from the time the system) 108 140 P
0.52 (crashed. When the kernel produces a core dump, these two files are written to the end of) 108 126 P
-0.51 (the swap space. When the system reboots, the ) 108 112 P
5 F
-1.23 (savecore) 326.42 112 P
0 F
-0.51 ( utility is used to copy them from) 383.99 112 P
(the swap device into the ) 108 98 T
5 F
(vmunix) 226.91 98 T
0 F
( and ) 270.09 98 T
5 F
(vmcore) 293.41 98 T
0 F
( disk files.) 336.58 98 T
FMENDPAGE
%%EndPage: "22" 23
%%Page: "23" 23
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 23 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.65 (To successfully save a core dump, you should have a swap space that is at least one and) 108 712 P
1.57 (one-half times as large as the physical memory on your machine. The core dump gets) 108 698 P
-0.28 (written to the end of the swap devices so that the system can reboot and start basic services) 108 684 P
1.2 (using the swap space at the beginning of the swap device; if there\325s any overlap you\325ll) 108 670 P
(damage the core dump. ) 108 656 T
0.31 (To save a core dump upon reboot, make sure you uncomment the ) 108 632 P
5 F
0.74 (savecore) 428.49 632 P
0 F
0.31 ( invocation) 486.05 632 P
(in ) 108 618 T
5 F
(/etc/rc.local) 120.33 618 T
0 F
(:) 213.88 618 T
1 F
(# Default is to not do a savecore) 153 595.33 T
(#) 153 583.33 T
(mkdir -p /var/crash/\324hostname\324) 153 571.33 T
(# echo -n \325checking for crash dump... \325) 153 559.33 T
(intr savecore /var/crash/\324hostname\324) 153 547.33 T
(# echo \325\325) 153 535.33 T
0 F
0.41 (The core dump may be as large as your physical memory size plus the size of the kernel.) 108 510 P
1.33 (Ensure that you have sufficient free space in the crash dump directory, and change the) 108 496 P
0.54 (default dump directory if you are short of space. The core dump is copied after NFS and) 108 482 P
1.76 (other system services are started, so you can put the core dumps on an NFS-mounted) 108 468 P
(partition \050if you have ) 108 454 T
4 F
(root) 212.6 454 T
0 F
( access permission to the filesystem\051. ) 232.59 454 T
3 F
(Types of Failures) 108 430 T
0 F
-0.3 (Now that you know how to retrieve a core dump, it\325s useful to know how and why they are) 108 410 P
1.12 (produced in the first place. Core dumps are produced whenever the system panics, as a) 108 396 P
1.11 (result of an unexpected hardware event or a software-detected error. Probably the more) 108 382 P
1.44 (familiar event is a "panic" message, produced whenever the kernel encounters a "can\325t) 108 368 P
(happen" state. A typical panic message is:) 108 354 T
1 F
(panic: iechkcca) 153 331.33 T
0 F
-0.28 (The panic messages are often cryptic, but are unique and have well-defined conditions that) 108 306 P
0.63 (cause them. Usually, a panic occurs when the kernel\325s "reality check" fails: the system\325s) 108 292 P
1.08 (view of the world \050in software\051 does not agree with what the hardware is telling it. For) 108 278 P
-0.16 (example, the kernel might think that a disk isn\325t busy, but when it goes to start a command) 108 264 P
-0.11 (on the disk controller, the controller reports that the drive is in use. Somewhere, the kernel) 108 250 P
(marked the device inactive when it really wasn\325t. ) 108 236 T
3.21 (Panics may also be caused by race conditions that are exposed by new and faster) 108 212 P
0.55 (processors. The previous panic example, ) 108 198 P
5 F
1.32 (iechkcca) 308.92 198 P
0 F
0.55 (, is produced when the CPU checks) 366.49 198 P
-0.48 (the condition codes on the Intel ethernet chip and finds that they don\325t agree with what they) 108 184 P
4 F
0.43 (should) 108 170 P
0 F
0.43 ( have been. The problem really lies in a race condition between the Intel hardware) 139.99 170 P
-0.71 (and the CPU: the Intel chip takes a little while to change the condition codes, and if the CPU) 108 156 P
-0.1 (checks them again before the chip has had a chance to reset them, it appears that the codes) 108 142 P
(were never reset. A faster CPU will "beat" the Intel chip. ) 108 128 T
-0.3 (Core dumps are also produced by "bad traps." A bad trap is an unexpected hardware event,) 108 104 P
-0.5 (and usually implies a kernel address translation fault. This is a fancy way of saying that bad) 108 90 P
2.33 (traps are generally kernel-level segmentation violations or bus errors. A user process) 108 76 P
FMENDPAGE
%%EndPage: "23" 24
%%Page: "24" 24
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 24 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
0.64 (dumps core when it causes a segmentation violation - and the kernel does the same. The) 108 712 P
0.79 (most common cause of a bad trap is a dereferenced null pointer in some kernel code. In) 108 698 P
-0.46 (addition to producing a core dump, the bad trap handler also prints a stack traceback so that) 108 684 P
1.72 (you can tell where the system encountered the problem. No traceback is produced for) 108 670 P
(panics.) 108 656 T
-0.31 (You can use panics to take a snapshot of the system for analysis that might otherwise mask) 108 632 P
-0.09 (the problem you\325re trying to detect. For example, if you\325re trying to find a timing problem) 108 618 P
-0.53 (or a race condition, you may want to cause a system panic when you detect that the kernel\325s) 108 604 P
3.36 (state has become inconsistent with reality. Detecting these sorts of problems using) 108 590 P
2.44 (debugging output is hard, because the race conditions can be eliminated through the) 108 576 P
1.44 (addition of a the printf\050\051 calls. Force a panic in your code, and analyze the core dump) 108 562 P
(outside of these time constraints.) 108 548 T
3 F
(4.3.) 81 524 T
(Analyzing Core Dumps) 108 524 T
0 F
(Use the ) 108 504 T
5 F
(adb) 147.3 504 T
0 F
( debugger to analyze core dumps saved by ) 168.89 504 T
5 F
(savecore) 375.39 504 T
0 F
(:) 432.96 504 T
1 F
(# ) 153 481.33 T
6 F
(adb -k vmunix.0 vmcore.0) 164.99 481.33 T
1 F
(physmem ff3) 153 469.33 T
5 F
0.32 (adb) 108 444 P
0 F
0.14 ( takes the kernel image name and the core dump file as arguments; the -) 129.59 444 P
5 F
0.32 (k) 475.89 444 P
0 F
0.14 ( option tells) 483.08 444 P
-0.34 (adb to perform kernel memory mapping on the core file. Use the ) 108 430 P
5 F
-0.82 ($c ) 416.66 430 P
0 F
-0.34 (command to generate) 437.43 430 P
(a traceback of the kernel\325s stack at the time the system crashed:) 108 416 T
1 F
(sunwr8# ) 126 393.33 T
6 F
(adb -k vmunix.2 vmcore.2) 173.97 393.33 T
1 F
(physmem) 126 381.33 T
( bec) 167.98 381.33 T
6 F
($c) 126 369.33 T
1 F
(_panic\0500xf81372b3,0xf8252c34,0x10,0x80,0xf8253\051 + 6c) 126 357.33 T
(_trap\0500x9,0xf8252c34,0x10,0x80,0x2,0x0\051) 126 345.33 T
(+ 184) 359.87 345.33 T
(fault_60\050?\051) 126 333.33 T
(_uiomove\0500x0,0x0,0x1,0xf8252eac,0xf8252ea4,0xd\051) 126 321.33 T
(+ a4) 407.85 321.33 T
(_lbwrite\0500x0,0xf8252eac,0x340,0xff052ff0,0xf8147a34,0xd\051 + c4) 126 309.33 T
(_spec_rdwr\0500xff052e44,0xf8252eac,0x1,0x0,0x1040,0x6801\051) 126 297.33 T
(+ 1bc) 455.82 297.33 T
(_vno_rw\0500xf8161bb4,0x1,0xf8252eac,0xd,0xff052e44,0x0\051 +) 126 285.33 T
(a4) 455.82 285.33 T
(_rwuio\0500xf8161bb4,0xf8252eac,0xf8252ea4,0xd,0xd,0xf8252eac\051) 126 273.34 T
(+) 485.8 273.34 T
(2b0) 497.8 273.34 T
(_write\0500xf8252fe0,0x20,0xf8121f28,0xf8121f48,0xf8253000\051 + 34) 126 261.34 T
(_syscall\0500xf8253000\051 + 3b4) 126 249.34 T
0 F
(There are two things worth noting about using ) 108 224 T
5 F
(adb) 333.19 224 T
0 F
( on SPARC systems:) 354.78 224 T
(\245) 126 200 T
-0.66 (It\325s difficult for ) 144 200 P
5 F
-1.59 (adb) 219.62 200 P
0 F
-0.66 ( to determine what arguments were passed to a routine, because) 241.21 200 P
1.56 (arguments are passed in register windows and not in the stack. Therefore, ) 144 186 P
5 F
3.74 (adb) 518.41 186 P
0 F
0.24 (shows five or six arguments for each routine, even if the routine only takes one or) 144 172 P
(two arguments. ) 144 158 T
(\245) 126 142 T
-0.31 (The traceback for a panic will be accurate, but on a bad trap, the kernel\325s stack may) 144 142 P
0.54 (have already been damaged. It\325s possible that the stack reflects a point before the) 144 128 P
0.66 (trap actually occurred. The example above was produced by a "bad trap" panic,) 144 114 P
(and it shows a damaged stack.) 144 100 T
0.05 (How do we know that stack was damaged? First of all, the ) 108 84 P
5 F
0.11 (fault_60) 392.02 84 P
0 F
0.05 (\050\051 routine is shown) 449.59 84 P
FMENDPAGE
%%EndPage: "24" 25
%%Page: "25" 25
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 25 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
1.24 (without any arguments; this could indicate that ) 108 712 P
5 F
2.97 (adb) 344.86 712 P
0 F
1.24 ( isn\325t clear on how this routine got) 366.45 712 P
-0.43 (called \050maybe because it wasn\325t called by the code that produced the trap\051. Also, the panic) 108 698 P
0.56 (occurred in a well-known kernel routine \050) 108 684 P
5 F
1.34 (uiomove) 311.18 684 P
0 F
0.56 (\051, which is strange if the routine was) 361.55 684 P
-0.1 (called with well-defined arguments \050that is, we didn\325t ask ) 108 670 P
5 F
-0.23 (uiomove) 386.27 670 P
0 F
-0.1 ( to copy data to a null) 436.64 670 P
(pointer\051. ) 108 656 T
1.65 (The best way to sort out a bad trap panic is to resort to the traceback recorded in the) 108 632 P
-0.31 (messages file ) 108 618 P
5 F
-0.74 (/var/adm/messages) 174.66 618 P
0 F
-0.31 (. If you don\325t have the messages file corresponding) 297 618 P
(to the core dump, you can look at the kernel\325s message buffer using ) 108 604 T
5 F
(adb) 435.76 604 T
0 F
(:) 457.34 604 T
1 F
(sunwr8# ) 126 581.33 T
6 F
(adb -k vmunix.2 vmcore.2) 173.97 581.33 T
1 F
(physmem bec) 126 569.33 T
6 F
(msgbuf,80/s) 126 557.33 T
1 F
(....lots of messages from system boot....) 126 545.33 T
(Apr 18 11:14:08 sunwr8 vmunix: BAD TRAP ) 126 533.33 T
(Apr 18 11:14:08 sunwr8 vmunix: pid 257, \324iclient\325: Data fault ) 126 521.33 T
(Apr 18 11:14:08 sunwr8 vmunix: kernel write fault at addr=0x10,) 126 509.33 T
( pme=0x0 ) 126 497.33 T
(Apr 18 11:14:08 sunwr8 vmunix: Sync Error Reg 80<INVALID> ) 126 485.33 T
(Apr 18 11:14:08 sunwr8 vmunix: pc=0xf80bde44, sp=0xf8252c80,) 126 473.33 T
( psr=0x4000c0, context=0x3 ) 126 461.33 T
(Apr 18 11:14:08 sunwr8 vmunix: g1-g7: f8000000, f8141000, ff050d90,) 126 449.33 T
( ff0552a0, f8253000, 0, f813ac00 ) 126 437.33 T
(Apr 18 11:14:08 sunwr8 vmunix: Begin traceback... sp = f8252c80 ) 126 425.33 T
(Apr 18 11:14:08 sunwr8 vmunix: Called from f808dbd8, fp=f8252ce0,) 126 413.33 T
( args=0 f8252eac 340 ff052ff0 f8147a34 d ) 126 401.33 T
(Apr 18 11:14:08 sunwr8 vmunix: Called from f8065094, fp=f8252d68,) 126 389.33 T
( args=ff052e44 f8252eac 1 0 1040 6801 ) 126 377.33 T
0 F
-0.33 (The traceback indicates the program counter \050pc\051 address at which the trap occurred. We\325ll) 108 352 P
(use pass this address to ) 108 338 T
5 F
(adb) 222.26 338 T
0 F
( to locate the real kernel location causing the problem:) 243.85 338 T
6 F
(f80bde44,4?ia) 126 315.33 T
1 F
(_lbwrite+0xd0: ) 126 303.33 T
(st) 215.95 303.33 T
( %i3, [%i0 + 0x10]) 227.94 303.33 T
(_lbwrite+0xd4:) 126 291.33 T
( st) 209.95 291.33 T
( %g0, [%i0 + 0x18] ) 227.94 291.33 T
(_lbwrite+0xd8:) 126 279.34 T
( st) 209.95 279.34 T
( %i5, [%i0 + 0x14]) 227.94 279.34 T
(_lbwrite+0xdc: ) 126 267.34 T
(ld) 215.95 267.34 T
( [%i4 + 0x1c], %l2 ) 227.94 267.34 T
0 F
1.3 (What this shows us is that the panic didn\325t occur in ) 108 242 P
5 F
3.12 (uiomove) 370.48 242 P
0 F
1.3 (\050\051, but instead happened) 420.85 242 P
-0.48 (inside of the ) 108 228 P
5 F
-1.15 (lbwrite) 168.85 228 P
0 F
-0.48 (\050\051 routine. Taking the program counter address from the traceback,) 219.22 228 P
0.09 (we used adb to disassemble the code at this address, and ) 108 214 P
5 F
0.21 (adb) 382.12 214 P
0 F
0.09 (\325s symbolic output shows us) 403.71 214 P
-0.2 (the routine name in which the trap occurred. We can deduce two things from the traceback) 108 200 P
(and instruction disassembly:) 108 186 T
(\245) 126 162 T
-0.1 (The panic was caused by a null pointer dereference. Notice that the fault address is) 144 162 P
1.15 (0x10, and the instruction causing the fault was writing into an address offset by) 144 148 P
(0x10. The address itself is probably a pointer with a NULL value.) 144 134 T
(\245) 126 118 T
0.81 (The same store instruction shows up with the same register three times in a row.) 144 118 P
0.04 (This part of the code must have been filling in a structure without first checking to) 144 104 P
(see if the structure existed. ) 144 90 T
FMENDPAGE
%%EndPage: "25" 26
%%Page: "26" 26
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 26 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
-0.63 (As confirmation of these ideas, let\325s look at the code for ) 108 712 P
5 F
-1.5 (lbwrite) 373.57 712 P
0 F
-0.63 (\050\051 and the data structures) 423.94 712 P
(that it is manipulating:) 108 698 T
1 F
( struct lb_unit { ) 153 675.33 T
(int) 189 663.33 T
(state;) 225 663.33 T
(/* state of device */) 333 663.33 T
( ) 153 651.33 T
(char) 189 651.33 T
(*name;) 225 651.33 T
(/* name of this endpoint */ ) 333 651.33 T
(char) 189 639.33 T
(*peer_name;) 225 639.33 T
(/* name of peer */) 333 639.33 T
(int) 189 627.33 T
(nm_size;) 225 627.33 T
(/* size of name */ ) 333 627.33 T
(struct lb_unit) 189 615.33 T
( *peer;) 272.95 615.33 T
(/* peer unit */ ) 333 615.33 T
(int) 189 603.33 T
(buflen; ) 225 603.33 T
(char ) 189 591.33 T
(*buf; ) 225 591.33 T
(};) 153 579.33 T
(lbwrite\050\051 ) 153 555.33 T
({ ) 153 543.33 T
(struct lb_unit *lbdest;) 189 543.33 T
( ) 153 531.33 T
(.... ) 189 531.33 T
(lbdest = lbp->peer;) 189 519.33 T
( ) 153 507.33 T
(lbdest->peer = lbp; ) 189 507.33 T
(lbdest->buf = NULL;) 189 495.33 T
( ) 153 483.33 T
(lbdest->buflen = 0; ) 189 483.33 T
(} ) 153 471.33 T
0 F
1.43 (Now the pieces fit together: the driver was attempting to use the ) 108 446 P
5 F
3.44 (lbdest) 435.66 446 P
0 F
1.43 ( pointer, but) 478.83 446 P
5 F
0.15 (lbdest) 108 432 P
0 F
0.06 ( is NULL. Notice that the ) 151.18 432 P
5 F
0.15 (peer) 277.14 432 P
0 F
0.06 ( element of the ) 305.93 432 P
5 F
0.15 (lb_unit) 380.8 432 P
0 F
0.06 ( structure has an offset) 431.17 432 P
(of 16 bytes \0500x10\051 - the same offset that appeared in the traceback.) 108 418 T
3 F
(4.4.) 81 394 T
(Debugging Hung Systems) 108 394 T
0 F
-0.45 (Panics let you know rather emphatically that there is a problem. System hangs, on the other) 108 374 P
0.1 (hang, are much harder to detect and debug. A system hang can be caused when the kernel) 108 360 P
-0.21 (runs out of memory, or when many processes become deadlocked on the same resource. A) 108 346 P
-0.01 (system that is hung may respond to keyboard input, or answer ) 108 332 P
5 F
-0.03 (ping) 408.33 332 P
0 F
-0.01 ( requests, but most or) 437.11 332 P
0.05 (all of the processes on the system will end up waiting on some resource. The first step in) 108 318 P
(determining what made the system hang is to force a core dump.) 108 304 T
0.19 (When you take a system into the PROM monitor, the g0 command will force a ") 108 280 P
5 F
0.45 (panic:) 496.82 280 P
-0.12 (zero) 108 266 P
0 F
-0.05 (," followed by a core dump and reboot. On a SPARCStation, put the monitor in new) 136.78 266 P
(command mode and perform a ) 108 252 T
5 F
(sync) 258.22 252 T
0 F
(:) 287 252 T
7 F
(sun4 system:) 153 229.34 T
1 F
(> ) 153 217.34 T
6 F
(g0) 164.99 217.34 T
1 F
(panic: zero) 153 205.34 T
7 F
(sun4c system:) 153 181.34 T
1 F
(> ) 153 169.34 T
6 F
(n) 164.99 169.34 T
1 F
(ok ) 153 157.34 T
6 F
(sync) 170.99 157.34 T
0 F
0.9 (You can run ) 108 132 P
5 F
2.15 (ps) 172.98 132 P
0 F
0.9 (, ) 187.37 132 P
5 F
2.15 (netstat) 194.26 132 P
0 F
0.9 (, ) 244.63 132 P
5 F
2.15 (ipcs) 251.53 132 P
0 F
0.9 ( and other kernel memory reading utilities on the) 280.31 132 P
1.45 (core dump from a hung system to see what process and resource states were when) 108 118 P
1.38 (the system became unusable. For example, let\325s assume that we\325re debugging the) 108 104 P
5 F
1.65 (zz) 108 90 P
0 F
0.69 ( device driver, and the system has become deadlocked when several processes try) 122.39 90 P
0.96 (to use it. Using the -) 108 76 P
5 F
2.32 (k) 218.03 76 P
0 F
0.96 ( flag with ) 225.22 76 P
5 F
2.32 (ps) 277.08 76 P
0 F
0.96 (, we can look at the process information in the) 291.48 76 P
FMENDPAGE
%%EndPage: "26" 27
2 8 /Courier FMDEFINEFONT
7 8 /Courier-Bold FMDEFINEFONT
%%Page: "27" 27
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 27 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(core dump files) 108 712 T
1 F
(:) 182.61 712 T
( ) 108 687.33 T
2 F
( %) 114 687.33 T
7 F
( ps -agxlk vmunix.2 vmcore.2) 123.59 687.33 T
2 F
( F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND ) 108 676.67 T
( 80003 0 0 0 0 -25 0 0 0 runout D ? 0:58 swapper ) 108 666.67 T
( 20088000 0 1 0 0 5 0 52 0 child IW ? 0:00 /sbin/init - ) 108 656.67 T
( 80003 0 2 0 0 -24 0 0 0 child D ? 0:02 pagedaemon ) 108 646.67 T
( 88000 0 52 1 0 1 0 68 0 select IW ? 0:00 portmap ) 108 636.67 T
( 88000 3 55 1 0 1 0 36 0 select IW ? 0:00 ypbind) 108 626.67 T
( 20008001 1461 155 149 5 1 01824 1804 Sysbase S co 2:02 zzdriver) 108 616.67 T
( 20008000 1461 149 112 1 5 0 28 0 child IW co 0:00 zztest) 108 606.67 T
( 20008001 1461 153 149 5 1 01824 1804 Sysbase S co 2:02 zzdriver ) 108 596.67 T
( 20008001 1461 154 149 5 1 01824 1804 Sysbase S co 2:02 zzdriver) 108 586.67 T
0 F
0.04 (There are three processes - 153, 154 and 155 - stuck in wait states. Using ) 108 552 P
5 F
0.1 (adb) 462.01 552 P
0 F
0.04 ( on the core) 483.59 552 P
(dump, let\325s see where they got deadlocked:) 108 538 T
1 F
(# ) 108 515.33 T
6 F
(adb -k vmunix.2 vmcore.2) 119.99 515.33 T
1 F
(physmem ff3) 108 503.33 T
6 F
(0t155$<setproc) 108 491.33 T
1 F
( ) 108 479.33 T
(pid 155) 189 479.33 T
6 F
($c) 108 467.33 T
1 F
( ) 119.99 467.33 T
(sw_bad\050?\051) 108 455.33 T
(_swtch\0500x800ae6,0xf813ef90,0x4000e6,0xff01dc48,0x1,0xf8245000\051 + 80) 108 443.33 T
(_sleep\0500xf813ef90,0x11c,0xf8116c00,0x0,0xa00,0xf8165ee0\051 + 188) 108 431.33 T
(_zz_checkstate\0500xff01cb80,0xa,0x2,0x440,0x1c,0xff01dc48\051 + d4) 108 419.33 T
(_zz_read\0500xa,0xf8244ea4,0x0,0x0,0xff01cb80,0x4000e1\051 + 30) 108 407.33 T
(_spec_rdwr\0500xff092c74,0xf8244ea4,0x0,0x0,0x640,0x0\051 + 128) 108 395.33 T
(_vno_rw\0500xf81614d0,0x0,0xf8244ea4,0x2000,0xff092c74,0x0\051 + a4) 108 383.33 T
(_rwuio\0500xf81614d0,0xf8244ea4,0xf8244eb8,0x2000,0x2000\051 + 2b0) 108 371.33 T
(_read\0500xf8244fe0,0x18,0xf811ff30,0xf811ff48,0xf8245000\051 + 34) 108 359.33 T
(_syscall\0500xf8245000\051 + 3b4 ) 108 347.33 T
0 F
0.95 (The ) 108 322 P
5 F
2.28 (setproc) 130.6 322 P
0 F
0.95 ( macro locates the specified process and sets up the kernel to point to its) 180.97 322 P
0.28 (address space. The traceback shows that the processes called ) 108 308 P
5 F
0.67 (read) 404.91 308 P
0 F
0.28 (\050\051 to get data from the) 433.69 308 P
0 (device; ) 108 294 P
5 F
0.01 (read) 145.64 294 P
0 F
0 (\050\051 passed the generic system call down to the ) 174.42 294 P
5 F
0.01 (zz_read) 392.62 294 P
0 F
0 (\050\051 routine for the ) 443 294 P
5 F
0.01 (zz) 525.61 294 P
0 F
0.71 (device. However, ) 108 280 P
5 F
1.7 (zz_read) 196.67 280 P
0 F
0.71 (\050\051 must have decided that it needed to check the state of the) 247.04 280 P
1.28 (device, and when doing the state verification it called ) 108 266 P
5 F
3.08 (sleep) 378.67 266 P
0 F
1.28 (\050\051. The processes that are) 414.65 266 P
(deadlocked may all be sleeping on the same event, which probably never occurred. ) 108 252 T
-0.04 (You can use ) 108 228 P
5 F
-0.09 (adb) 170.18 228 P
0 F
-0.04 ( on a live system to look at the same process and state information as the) 191.76 228 P
0.31 (system is running; this may help you diagnose why one a process goes to sleep and starts) 108 214 P
0.02 (the chain of events that leads to a deadlock. There are a wide variety of macros in /usr/lib/) 108 200 P
5 F
-1.66 (adb) 108 186 P
0 F
-0.69 ( \050) 129.59 186 P
5 F
-1.66 (setproc) 135.89 186 P
0 F
-0.69 ( is one of them\051; use these macros to examine various kernel data structures) 186.26 186 P
(on a live system or in a core dump. ) 108 172 T
3 F
(4.5.) 81 148 T
(Debugging Loadable Drivers) 108 148 T
0 F
-0.69 (Loadable drivers present an interesting problem for debugging: because they are linked into) 108 128 P
2.37 (the kernel once it is already running, their symbols are not part of the symbol table) 108 114 P
-0.04 (contained in the) 108 100 P
5 F
-0.09 ( /vmunix) 184.54 100 P
0 F
-0.04 ( image. To debug a loadable driver on a live system, you must) 242.01 100 P
0.45 (build a new kernel image that contains symbols from the loadable driver and the running) 108 86 P
FMENDPAGE
%%EndPage: "27" 28
%%Page: "28" 28
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 28 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
0 X
(kernel image. To do so, use the incremental linking feature of the SunOS linker.) 108 712 T
-0.45 (Let\325s say you\325ve built and installed a loadable driver called ) 108 688 P
5 F
-1.09 (hello) 390.6 688 P
0 F
-0.45 (. The ) 426.58 688 P
5 F
-1.09 (modstat) 458.42 688 P
0 F
-0.45 ( utility) 508.79 688 P
(shows you where it was linked into the kernel:) 108 674 T
1 F
(# ) 126 651.33 T
6 F
(modstat) 137.99 651.33 T
1 F
(Id Type Loadaddr Size B-major C-major Sysnum Mod Name) 126 639.33 T
( 1 Sys ff0ea000 1000 190 hello) 126 627.33 T
0 F
-0.08 (The ) 108 602 P
4 F
-0.08 (loadaddr) 129.57 602 P
0 F
-0.08 ( reported by ) 173.55 602 P
5 F
-0.19 (modstat) 234.27 602 P
0 F
-0.08 ( is the relocation address of the module. We can have) 284.64 602 P
5 F
-0.26 (ld) 108 588 P
0 F
-0.11 ( build a new kernel image from the ) 122.39 588 P
5 F
-0.26 (/vmunix) 292.73 588 P
0 F
-0.11 ( file and the) 343.1 588 P
5 F
-0.26 ( hello.o) 399.73 588 P
0 F
-0.11 ( object file, using) 457.04 588 P
(this load address to specify where the ) 108 574 T
5 F
(hello.o) 290.86 574 T
0 F
( code should be placed:) 341.24 574 T
1 F
(# ) 153 551.33 T
6 F
(ld -A /vmunix -T ff0ea000 hello.o -o vmunix.hello) 164.99 551.33 T
1 F
(# ) 153 539.33 T
6 F
(adb -k -w vmunix.hello /dev/mem) 164.99 539.33 T
1 F
(physmem ffe) 153 527.33 T
0 F
0.21 (The -) 108 502 P
5 F
0.49 (A ) 133.85 502 P
0 F
0.21 (flag tells the linker that we\325re adding a new object file to the existing executable;) 148.73 502 P
1.77 (the ) 108 488 P
5 F
4.26 (-T) 127.43 488 P
0 F
1.77 ( flag tells ) 141.82 488 P
5 F
4.26 (ld) 194.78 488 P
0 F
1.77 ( where to put the new code. We deposit the new kernel image in) 209.17 488 P
5 F
3.25 (vmunix.hello) 108 474 P
0 F
1.35 (, and then use that image with ) 194.35 474 P
5 F
3.25 (adb) 350.39 474 P
0 F
1.35 (. The version of the kernel that is) 371.98 474 P
-0.68 (loaded in-core will match the symbol table in ) 108 460 P
5 F
-1.62 (vmunix.hello) 325.45 460 P
0 F
-0.68 (, so we can look at symbols) 411.8 460 P
(and code from ) 108 446 T
5 F
(hello.o ) 180.27 446 T
0 F
(using ) 237.84 446 T
5 F
(adb) 266.83 446 T
0 F
(.) 288.42 446 T
3 F
(Further Reading) 108 422 T
0 F
-0.67 (Any short tutorial like this is necessarily incomplete. For information, refer to the following) 108 402 P
(sources:) 108 388 T
4 F
0.44 (The Sun Technology Papers) 108 364 P
0 F
0.44 (, edited by Mark Hall and John Barry \050Spring-Verlag, 1990\051.) 244.24 364 P
-0.26 (This book has an excellent description of the SPARC architecture and how the first) 144 350 P
(SunOS port to SPARC was accomplished. ) 144 336 T
4 F
0.18 (UNIX System Administration Handbook) 108 312 P
0 F
0.18 (, by Evi Nemeth, Garth Snyder and Scott Seebass) 300.75 312 P
(\050Prentice-Hall, 1989\051. A little bit of everything for the system administrator.) 144 298 T
4 F
5.51 (System Performance Tuning) 108 274 P
0 F
5.51 (, by Mike Loukides \050O\325Reilly & Associates, 1990\051.) 254.93 274 P
0.2 (Throughout the book and in an appendix there are descriptions of just about every) 144 260 P
(knob that can be turned in SunOS and System V Release 4.) 144 246 T
4 F
-0.33 (Writing a Unix Device Driver) 108 222 P
0 F
-0.33 (, by Janet Egan and Thomas Teixeira \050WIley & Sons, 1988\051.) 249.89 222 P
-0.06 (The book focuses on System V Release 3 and MASSCOMP\325s RTU UNIX system,) 144 208 P
(but there are some good examples in it, including a fairly elaborate call tracer.) 144 194 T
4 F
-0.52 (Writing Device Drivers) 108 170 P
0 F
-0.52 (, in the SunOS 4.1.1 Documentation Set \050Sun Microsystems, 1990\051.) 219.54 170 P
-0.62 (A good place to look for memory maps, kernel address space layout, kernel services) 144 156 P
(used by device drivers and other Sun-specific details.) 144 142 T
4 F
1.43 (The Design and Implementation of the 4.3 BSD UNIX Operating System) 108 118 P
0 F
1.43 (, by Marshall) 473.51 118 P
2.49 (McKusick, Mike Karels, Sam Leffler and John Quarterman \050Addison-Wesley,) 144 104 P
-0.15 (1989\051. This book explains where all of the "historical" names and techniques come) 144 90 P
(from.) 144 76 T
FMENDPAGE
%%EndPage: "28" 29
%%Page: "29" 29
612 792 0 FMBEGINPAGE
0 0 612 792 C
0 0 612 792 R
7 X
0 K
V
72 45 540 57.02 R
V
0 F
0 X
(- 29 -) 293.01 49.02 T
72 72 540 720 R
7 X
V
3 F
0 X
(Acknowledgments) 108 712 T
0 F
-0.69 (Many people contributed to this paper. Michael Bender \050Sun\051 provided the ideas and scripts) 108 692 P
0.21 (for the loadable driver debugging discussion. Janice McLaughlin \050Sun\051 suggested the call) 108 678 P
0.36 (tracer, and helped analyze several of the problems we uncovered with it. Rohit Aggrawal) 108 664 P
0.78 (and Saul Wold \050Sun\051; Randy Rohrbach \050Foxboro Company\051; and Paul Bradford \050Bytex\051) 108 650 P
2.58 (participated in discussions of debugging methods and actually tried out some of my) 108 636 P
1.33 (suggestions. Rohit Aggrawal, Chuck Kollars and Chris Drake \050Sun\051 reviewed the early) 108 622 P
(versions of this manuscript; the paper has benefited significantly from their comments.) 108 608 T
FMENDPAGE
%%EndPage: "29" 30
%%Trailer
%%BoundingBox: 0 0 612 792
%%Pages: 29 1
%%DocumentFonts: Times-Roman
%%+ Times-Bold
%%+ Times-Italic
%%+ Courier
%%+ Courier-Bold
%%+ Courier-Oblique
%%+ Times-BoldItalic



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:44 CDT