diff --git a/xv6.pdf b/xv6.pdf deleted file mode 100644 index 51e8834..0000000 Binary files a/xv6.pdf and /dev/null differ diff --git a/xv6.ps b/xv6.ps deleted file mode 100644 index d573f61..0000000 --- a/xv6.ps +++ /dev/null @@ -1,23941 +0,0 @@ -%!PS-Adobe-3.0 -% Produced by xpdf/pdftops 3.02 -%%Creator: mpage 2.5.5 November 2006 -%%Title: (mpage) -%%LanguageLevel: 2 -%%DocumentSuppliedResources: (atend) -%%DocumentMedia: plain 612 792 0 () () -%%BoundingBox: 0 0 612 792 -%%Pages: 80 -%%EndComments -%%BeginDefaults -%%PageMedia: plain -%%EndDefaults -%%BeginProlog -%%BeginResource: procset xpdf 3.02 0 -%%Copyright: Copyright 1996-2007 Glyph & Cog, LLC -/xpdf 75 dict def xpdf begin -% PDF special state -/pdfDictSize 15 def -/pdfSetup { - 3 1 roll 2 array astore - /setpagedevice where { - pop 3 dict begin - /PageSize exch def - /ImagingBBox null def - /Policies 1 dict dup begin /PageSize 3 def end def - { /Duplex true def } if - currentdict end setpagedevice - } { - pop pop - } ifelse -} def -/pdfStartPage { - pdfDictSize dict begin - /pdfFillCS [] def - /pdfFillXform {} def - /pdfStrokeCS [] def - /pdfStrokeXform {} def - /pdfFill [0] def - /pdfStroke [0] def - /pdfFillOP false def - /pdfStrokeOP false def - /pdfLastFill false def - /pdfLastStroke false def - /pdfTextMat [1 0 0 1 0 0] def - /pdfFontSize 0 def - /pdfCharSpacing 0 def - /pdfTextRender 0 def - /pdfTextRise 0 def - /pdfWordSpacing 0 def - /pdfHorizScaling 1 def - /pdfTextClipPath [] def -} def -/pdfEndPage { end } def -% PDF color state -/cs { /pdfFillXform exch def dup /pdfFillCS exch def - setcolorspace } def -/CS { /pdfStrokeXform exch def dup /pdfStrokeCS exch def - setcolorspace } def -/sc { pdfLastFill not { pdfFillCS setcolorspace } if - dup /pdfFill exch def aload pop pdfFillXform setcolor - /pdfLastFill true def /pdfLastStroke false def } def -/SC { pdfLastStroke not { pdfStrokeCS setcolorspace } if - dup /pdfStroke exch def aload pop pdfStrokeXform setcolor - /pdfLastStroke true def /pdfLastFill false def } def -/op { /pdfFillOP exch def - pdfLastFill { pdfFillOP setoverprint } if } def -/OP { /pdfStrokeOP exch def - pdfLastStroke { pdfStrokeOP setoverprint } if } def -/fCol { - pdfLastFill not { - pdfFillCS setcolorspace - pdfFill aload pop pdfFillXform setcolor - pdfFillOP setoverprint - /pdfLastFill true def /pdfLastStroke false def - } if -} def -/sCol { - pdfLastStroke not { - pdfStrokeCS setcolorspace - pdfStroke aload pop pdfStrokeXform setcolor - pdfStrokeOP setoverprint - /pdfLastStroke true def /pdfLastFill false def - } if -} def -% build a font -/pdfMakeFont { - 4 3 roll findfont - 4 2 roll matrix scale makefont - dup length dict begin - { 1 index /FID ne { def } { pop pop } ifelse } forall - /Encoding exch def - currentdict - end - definefont pop -} def -/pdfMakeFont16 { - exch findfont - dup length dict begin - { 1 index /FID ne { def } { pop pop } ifelse } forall - /WMode exch def - currentdict - end - definefont pop -} def -% graphics state operators -/q { gsave pdfDictSize dict begin } def -/Q { - end grestore - /pdfLastFill where { - pop - pdfLastFill { - pdfFillOP setoverprint - } { - pdfStrokeOP setoverprint - } ifelse - } if -} def -/cm { concat } def -/d { setdash } def -/i { setflat } def -/j { setlinejoin } def -/J { setlinecap } def -/M { setmiterlimit } def -/w { setlinewidth } def -% path segment operators -/m { moveto } def -/l { lineto } def -/c { curveto } def -/re { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto - neg 0 rlineto closepath } def -/h { closepath } def -% path painting operators -/S { sCol stroke } def -/Sf { fCol stroke } def -/f { fCol fill } def -/f* { fCol eofill } def -% clipping operators -/W { clip newpath } def -/W* { eoclip newpath } def -/Ws { strokepath clip newpath } def -% text state operators -/Tc { /pdfCharSpacing exch def } def -/Tf { dup /pdfFontSize exch def - dup pdfHorizScaling mul exch matrix scale - pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put - exch findfont exch makefont setfont } def -/Tr { /pdfTextRender exch def } def -/Ts { /pdfTextRise exch def } def -/Tw { /pdfWordSpacing exch def } def -/Tz { /pdfHorizScaling exch def } def -% text positioning operators -/Td { pdfTextMat transform moveto } def -/Tm { /pdfTextMat exch def } def -% text string operators -/cshow where { - pop - /cshow2 { - dup { - pop pop - 1 string dup 0 3 index put 3 index exec - } exch cshow - pop pop - } def -}{ - /cshow2 { - currentfont /FontType get 0 eq { - 0 2 2 index length 1 sub { - 2 copy get exch 1 add 2 index exch get - 2 copy exch 256 mul add - 2 string dup 0 6 5 roll put dup 1 5 4 roll put - 3 index exec - } for - } { - dup { - 1 string dup 0 3 index put 3 index exec - } forall - } ifelse - pop pop - } def -} ifelse -/awcp { - exch { - false charpath - 5 index 5 index rmoveto - 6 index eq { 7 index 7 index rmoveto } if - } exch cshow2 - 6 {pop} repeat -} def -/Tj { - fCol - 1 index stringwidth pdfTextMat idtransform pop - sub 1 index length dup 0 ne { div } { pop pop 0 } ifelse - pdfWordSpacing pdfHorizScaling mul 0 pdfTextMat dtransform 32 - 4 3 roll pdfCharSpacing pdfHorizScaling mul add 0 - pdfTextMat dtransform - 6 5 roll Tj1 -} def -/Tj16 { - fCol - 2 index stringwidth pdfTextMat idtransform pop - sub exch div - pdfWordSpacing pdfHorizScaling mul 0 pdfTextMat dtransform 32 - 4 3 roll pdfCharSpacing pdfHorizScaling mul add 0 - pdfTextMat dtransform - 6 5 roll Tj1 -} def -/Tj16V { - fCol - 2 index stringwidth pdfTextMat idtransform exch pop - sub exch div - 0 pdfWordSpacing pdfTextMat dtransform 32 - 4 3 roll pdfCharSpacing add 0 exch - pdfTextMat dtransform - 6 5 roll Tj1 -} def -/Tj1 { - 0 pdfTextRise pdfTextMat dtransform rmoveto - currentpoint 8 2 roll - pdfTextRender 1 and 0 eq { - 6 copy awidthshow - } if - pdfTextRender 3 and dup 1 eq exch 2 eq or { - 7 index 7 index moveto - 6 copy - currentfont /FontType get 3 eq { fCol } { sCol } ifelse - false awcp currentpoint stroke moveto - } if - pdfTextRender 4 and 0 ne { - 8 6 roll moveto - false awcp - /pdfTextClipPath [ pdfTextClipPath aload pop - {/moveto cvx} - {/lineto cvx} - {/curveto cvx} - {/closepath cvx} - pathforall ] def - currentpoint newpath moveto - } { - 8 {pop} repeat - } ifelse - 0 pdfTextRise neg pdfTextMat dtransform rmoveto -} def -/TJm { pdfFontSize 0.001 mul mul neg 0 - pdfTextMat dtransform rmoveto } def -/TJmV { pdfFontSize 0.001 mul mul neg 0 exch - pdfTextMat dtransform rmoveto } def -/Tclip { pdfTextClipPath cvx exec clip newpath - /pdfTextClipPath [] def } def -% Level 2 image operators -/pdfImBuf 100 string def -/pdfIm { - image - { currentfile pdfImBuf readline - not { pop exit } if - (%-EOD-) eq { exit } if } loop -} def -/pdfImM { - fCol imagemask - { currentfile pdfImBuf readline - not { pop exit } if - (%-EOD-) eq { exit } if } loop -} def -/pr { 2 index 2 index 3 2 roll putinterval 4 add } def -/pdfImClip { - gsave - 0 2 4 index length 1 sub { - dup 4 index exch 2 copy - get 5 index div put - 1 add 3 index exch 2 copy - get 3 index div put - } for - pop pop rectclip -} def -/pdfImClipEnd { grestore } def -% shading operators -/colordelta { - false 0 1 3 index length 1 sub { - dup 4 index exch get 3 index 3 2 roll get sub abs 0.004 gt { - pop true - } if - } for - exch pop exch pop -} def -/funcCol { func n array astore } def -/funcSH { - dup 0 eq { - true - } { - dup 6 eq { - false - } { - 4 index 4 index funcCol dup - 6 index 4 index funcCol dup - 3 1 roll colordelta 3 1 roll - 5 index 5 index funcCol dup - 3 1 roll colordelta 3 1 roll - 6 index 8 index funcCol dup - 3 1 roll colordelta 3 1 roll - colordelta or or or - } ifelse - } ifelse - { - 1 add - 4 index 3 index add 0.5 mul exch 4 index 3 index add 0.5 mul exch - 6 index 6 index 4 index 4 index 4 index funcSH - 2 index 6 index 6 index 4 index 4 index funcSH - 6 index 2 index 4 index 6 index 4 index funcSH - 5 3 roll 3 2 roll funcSH pop pop - } { - pop 3 index 2 index add 0.5 mul 3 index 2 index add 0.5 mul - funcCol sc - dup 4 index exch mat transform m - 3 index 3 index mat transform l - 1 index 3 index mat transform l - mat transform l pop pop h f* - } ifelse -} def -/axialCol { - dup 0 lt { - pop t0 - } { - dup 1 gt { - pop t1 - } { - dt mul t0 add - } ifelse - } ifelse - func n array astore -} def -/axialSH { - dup 0 eq { - true - } { - dup 8 eq { - false - } { - 2 index axialCol 2 index axialCol colordelta - } ifelse - } ifelse - { - 1 add 3 1 roll 2 copy add 0.5 mul - dup 4 3 roll exch 4 index axialSH - exch 3 2 roll axialSH - } { - pop 2 copy add 0.5 mul - axialCol sc - exch dup dx mul x0 add exch dy mul y0 add - 3 2 roll dup dx mul x0 add exch dy mul y0 add - dx abs dy abs ge { - 2 copy yMin sub dy mul dx div add yMin m - yMax sub dy mul dx div add yMax l - 2 copy yMax sub dy mul dx div add yMax l - yMin sub dy mul dx div add yMin l - h f* - } { - exch 2 copy xMin sub dx mul dy div add xMin exch m - xMax sub dx mul dy div add xMax exch l - exch 2 copy xMax sub dx mul dy div add xMax exch l - xMin sub dx mul dy div add xMin exch l - h f* - } ifelse - } ifelse -} def -/radialCol { - dup t0 lt { - pop t0 - } { - dup t1 gt { - pop t1 - } if - } ifelse - func n array astore -} def -/radialSH { - dup 0 eq { - true - } { - dup 8 eq { - false - } { - 2 index dt mul t0 add radialCol - 2 index dt mul t0 add radialCol colordelta - } ifelse - } ifelse - { - 1 add 3 1 roll 2 copy add 0.5 mul - dup 4 3 roll exch 4 index radialSH - exch 3 2 roll radialSH - } { - pop 2 copy add 0.5 mul dt mul t0 add - radialCol sc - encl { - exch dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - 0 360 arc h - dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - 360 0 arcn h f - } { - 2 copy - dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - a1 a2 arcn - dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - a2 a1 arcn h - dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - a1 a2 arc - dup dx mul x0 add exch dup dy mul y0 add exch dr mul r0 add - a2 a1 arc h f - } ifelse - } ifelse -} def -end -%%EndResource -%%EndProlog -%%BeginSetup -xpdf begin -%%BeginResource: font APYGPQ+LucidaSans-Typewriter83 -%!FontType1-1.0: APYGPQ+LucidaSans-Typewriter83 -12 dict begin -/FontInfo 10 dict dup begin -/Notice (Copyright (c) 1991 Bigelow & Holmes Inc. and Y&Y, Inc. (508) 371-3286. All Rights Reserved.) readonly def -/FullName (Lucida Sans Typewriter 83) readonly def -/FamilyName (LucidaSansTypewriter83) readonly def -/isFixedPitch true def -/ItalicAngle 0 def -/UnderlinePosition 0 def -/UnderlineThickness 0 def -end readonly def -/FontName /APYGPQ+LucidaSans-Typewriter83 def -/PaintType 0 def -/FontType 1 def -/FontMatrix [0.00083333 0 0 0.00083333 0 0] readonly def -/FontBBox [0 -170 501 652] readonly def -/StrokeWidth 0 def -/Encoding 256 array -0 1 255 {1 index exch /.notdef put} for -dup 32 /space put -dup 33 /exclam put -dup 34 /quotedbl put -dup 35 /numbersign put -dup 36 /dollar put -dup 37 /percent put -dup 38 /ampersand put -dup 39 /quoteright put -dup 40 /parenleft put -dup 41 /parenright put -dup 42 /asterisk put -dup 43 /plus put -dup 44 /comma put -dup 45 /hyphen put -dup 46 /period put -dup 47 /slash put -dup 48 /zero put -dup 49 /one put -dup 50 /two put -dup 51 /three put -dup 52 /four put -dup 53 /five put -dup 54 /six put -dup 55 /seven put -dup 56 /eight put -dup 57 /nine put -dup 58 /colon put -dup 59 /semicolon put -dup 60 /less put -dup 61 /equal put -dup 62 /greater put -dup 63 /question put -dup 64 /at put -dup 65 /A put -dup 66 /B put -dup 67 /C put -dup 68 /D put -dup 69 /E put -dup 70 /F put -dup 71 /G put -dup 72 /H put -dup 73 /I put -dup 74 /J put -dup 75 /K put -dup 76 /L put -dup 77 /M put -dup 78 /N put -dup 79 /O put -dup 80 /P put -dup 81 /Q put -dup 82 /R put -dup 83 /S put -dup 84 /T put -dup 85 /U put -dup 86 /V put -dup 87 /W put -dup 88 /X put -dup 89 /Y put -dup 90 /Z put -dup 91 /bracketleft put -dup 92 /backslash put -dup 93 /bracketright put -dup 94 /asciicircum put -dup 95 /underscore put -dup 96 /quoteleft put -dup 97 /a put -dup 98 /b put -dup 99 /c put -dup 100 /d put -dup 101 /e put -dup 102 /f put -dup 103 /g put -dup 104 /h put -dup 105 /i put -dup 106 /j put -dup 107 /k put -dup 108 /l put -dup 109 /m put -dup 110 /n put -dup 111 /o put -dup 112 /p put -dup 113 /q put -dup 114 /r put -dup 115 /s put -dup 116 /t put -dup 117 /u put -dup 118 /v put -dup 119 /w put -dup 120 /x put -dup 121 /y put -dup 122 /z put -dup 123 /braceleft put -dup 124 /bar put -dup 125 /braceright put -dup 126 /asciitilde put -readonly def -currentdict end -currentfile eexec -5AA4F71255501637F1A431BAB555283D093E1B588B45B0281559110D21315C62 -BD638C6B34BA54AA75227715D9947EBCD51A104CAEA657499E94138F5645BF68 -368BB1B1EC8E4776F067FFF2CE9B89FB7E63A7DB304498C1036D399C47A4CB79 -BD517EDB02BEB90195FD7DDAF3E839BCE2DB156D9337DBB2305A465B3E0FFB97 -1985C79DC71C47E26F9F0F042B2CDEE97B679358059256FB93D662D43C7ECB5B -1A564DFCECB963478373C69F52172F071E0AA6082A3E10D9E1CE2851CFA210EE -7BD5FCB1AAE15E89D1FB339D587D218B89C18A32F47C7451A80CB1FC07CF5EF5 -C2A9054AD59AE4D5522D8745045620C9C40EAB675A6FE53511D83C04968F37DE -389C3A7A551DC79580FF1B382205C5951A9F8E7B6CEF33E027D608C14A394033 -1E603A09B3061B66BB71AC1D2A232B5F2BC9481D7D44F334ACCBBF6537EF8BC7 -075D89E6422C4E0A415BF3A1B001A284566A4DF8C6877CB0C70D67F5E7FA25E1 -90435DC2AFD452D1184CEA4CBF9F81F8CD7BE3B6EBA8395A40925FDDEB186DE2 -AB0372CF67C17BEE733C73CA29E00C3909E960A0417FCACC7211EBF3DD7225F0 -6F4FB7DBA35BF59A21014E1066BF090958F991C2BFD22CCA4189376B0BBFE928 -8CE7E8D06A551258E5938EB0F85097E557F3C3BA2177A88670054C2473FD9D0F -D9E6EE78BE4DE7D3B32C0A4890438F857B2B893F8CA4A75001BA5A42D90EC4F2 -B0D3E24CE17100E1A20EADBD615C9B006D73287E8A5580ED034E01BB6AFBB7A0 -C1A5D5BE8ED4D234E62C1E772182E6F6963800F7A410EE3FBBC30A5FFB47BBA3 -62C0896EF2CC54DC4ED804FFB912F5407AB4542A2E55201ABBBCED278812B35E -9703C069C38BF54D0E32CD1C0F7873115DFA318F164F6E50342252E9EFE643D5 -E9C5F46AE46E7E21C3DBA8384CD35EE082D11FE17BF955D48E02736A05C23160 -7592275355E00E6967AC691913925629C1F41E0F49804C413205EF4DD853CD4A -AFEFEEB55FAA06A85289F680D6670531DF5F087ABFA6D1B9A2C381186F70CB3C -CE3FC0A3BCABEE4281A7C3DAC0B396BA8CF66077B079929DEFBE76C413ABC1B9 -E14159DE9583E6E10894C743E1C9D3CE4C3676B5A85ACA7E16E3A19B674051C5 -465EC644D5F2AA776BBEC2DA4B1977A85FA5C08E9E4286DD9BD6116B110B7724 -6AD93C41A70B08EE2FA8E1FCCBC5091B57F55D942459893BE6CC261B726BF304 -78E3F84A7C65A1ADB01906F84FEE55EA3E57A3AF2DA474592C95726288B797BF -F751385F38BA7F09673B57BF2ADD79F0A4A6069CD3C238EEB149D77528B84CDD -E31D788A4A5476B55DE425A4A120EEF60DEDE1F42FFE488A01D1ED003AEBE51F -082784D7A5892C9F5806C2914FCB8CA5C4CCDFEF5D4E14DEA1777FEAE33C139B -355BE39D995C9449B3E55807C695200EF55EA2F7EA676A6770164CB127DA7C07 -260FAEC3E976FFF9A350B8641A4D7B8EB2AF8ADBD241670C96F33EF95252FA03 -F0F65E148FA2466B74557628163CCF600D8C8858D515F09312E45FF4938FFDC6 -2BE334D3D9BDF1293532963B6EE923E356E17762BEF9E43461CFCF403CF9307F -AC186610ACF18D27F662455921F450FD6B210EDC50F0C450BA94577C18EABFB0 -A4F21370E1E3194DB8B48668BF3342A5B33D10631C2CC5FC0F2495302A7EDDE9 -B46C85BA080BF1BF5AE4E492ACFBEBC7A358D213D0325ADB982E378B621963DD -E8B0326C8E8162D878D685D25409F83A57577F1C3A0D46D9B6805C68AFEDBC48 -09E4883C54C678FECB4F587F41EBBD6F7B1F656FA528BA27273B92EA24AEA34C -D31FAB98A48968B19BFBC34DCC9CBC40F4EA35783B607966EEBD88E0752F06EB -BF3FE55F88183F5A21AB5B3CC322E5C56CCDD19E40EBE24617D02E4AB3E15CDE -E92DA46DE2357F366ECA16119EA107853FDFE570B7CBEF695FFBCF049E902B4E -CCC477AF9B9875B6D079FF00A302DAD67363BF90E38CD58C46961F7A53CE0C23 -06B0125C2DFF62A9879D24D9A524BDD035375F95790071CB9ABC08D5FF89A3D5 -583C4C33D9F20AEF1B7A12CE819A6194F7116BC7B171C1BF0454763D10EDCE92 -DBB45261F97E88977722DF2C624DBEAF95D18E5CEFCF466C58958C36A48D4190 -01E72651FD55FC8684C19C3183B306D3A061F16CFA7086C3F51CCBA865D88C9A -589F25A52DB95453BBD66E89CB1E6C8059858A4898772A5307A3592889AF708B -EC8CA855D6DD899181CF8DC664EFDF9A8DC9286918B7CD63490660C033471AA8 -2910D2ADF17271D6A680EB97891D247EAFF2A4EC3BF4FF395BCC292402ACBA77 -F7CE635F25EA8D29CCF6DF4121DE62533AD46D3A84E68AD70991E5FEF9EA2EBE -19C2071821C214700AC9D23586F03E97D71ADC38BC97A4CBE534D318853DD3E1 -968978C85F9EDC6ADE6F0BB3E97A1F3ED7BB9936365D0D15DE805EF048E26BBD -9A671078FCED2DBFF6A2FA1361EF137091FFD933EB556768D1B33A4E05048FBC -0E7C672B080578E8F478BB66DAAA9EC09C4F779553D34C0A6A2D9A685A4C040C -99AAE40D8DB6529065539BFA4681AFDFCC4BE7405875F78865D70BE1815B9E3A -D243E623E80332D958019217B70E799BD5AF9779DE42F7291E824AF4F8D0E26D -E76420BD441F4F7516A667BBDD083B40C5FF9476D707B1C10EA2F8C80BE8C9DE -4DA48BD4AE3E661841CBB3AC4EEE0BEAEC612C7C9C748D0697819680D70F91B6 -F58FE67C3B4F8E64587CAC7BDB08C3A2E594B1AC8E97E77E427A8FEC289B5533 -60CDEA1957D4527DAC116E46169D1B70D742494A567425D0417F3134E623A56C -CE14F537A4A8163C335D2FB084AAC9B5440BD23BFF9F708B1C7CB2DF361B639A -B2796CA3BD382D8F26E991C83F1D7449E3C9869B23494A02606E7DA6528797EF -85ACD89D7553701C04F77C5886CD5EC47AE302F3785944090BFC60818B486514 -1322587334EA1DCA899E1B6FB0653BBB16A15781C25B258028CEB1AAAC52016E -A8F2F36A157759A3232654C0576C51F06A370BA928CEB3B6481D57745A5CCAC4 -63B5E306C676DE356BD593692C80026EC4F5DD0B89785A2D8650289F2FEDF380 -23F066B6C104EA6789AD199F36300032371B0AE9BCC92AE9E94280AB95E7BE99 -E69EEE109E5A34D8D192181AD22D814F49DFED9B87149C8C3FA247710B996F6B -52DF6C1ACB344F56878C706E0B4EA2C33274FC47A03E549CCB29D26C1CC50450 -C4F1178015B818357F327FC4098FB65247ACA89F7852A8C5BEF8A61D928D3E29 -792F36AF218C14E22095213B9BF70F4A2AB9F8D41ABAE3F70BFD3E64434ECC5B -8AF293E0657F662F071403F7B2BB2DC191361860DDC9761CF201A9E5DD64D0F1 -EDC9592D92EB02933A4E063E224301316A22F1676DE180193B1063733D5FBF31 -85C98ED0D8C1C459F41A6DF1A614740EF25462C7748AC4615A4C983E88089255 -ECBF5A92B7DDAC6E9BC0C1AC135977F1536CE490985B364118E7753B1B5D40B0 -40DE97B0EFB6A1E09894B24A32B1B2E2ABC02C64D2ECCCB43B8D2CE9BC9ACCC8 -F570F3AA2252EB95EE46B9452DF2EC804879265A0AB41B42BE6BE78777EF9487 -74F81B1B5D92DC44926F3C8421A432589B8C4B6D98BA9602EDB7CF5BDD7DFBDE -B6C37D3FD4112313F2D404AD0770C84E9E9BC3AE4E0A12348B096EE17F95BCBC -874F5F024D3B1E4515FA9457AD089F1C14A6ED93B0A1520C3C8435D8B9CC4FC3 -39DF5D18913CECA2F9FD3DFA46424594315D1400DAC9F2A09299F4C9D7D41E34 -661E0D305E9F62FC4E36BD2FB79021D8CDAABCFAE932E23F74CDA3600121BC33 -517A1F8CF50CFF67224D8F919290534C8CFDF8EA8C688E409BF3E831FBA6B2AC -0BCB08B086D6B8F6243182E8BEF410B7551E32AB6CF2AC674A3A3A926EDEE757 -F19BFCA5BBAABB1523917BCCFA765E1360DEF6269CDB2F18A55AFA721C9C78E5 -27EB85923D08AC830462E485F9A73F4B092703DF336CDCFD15031619597C731A -37E3D119025984C85D76C493BDD17187D760AD92E22CFCFE8145D07CD8400522 -0777845D8746C9A6D111E5F1EF2419276113092AA4F5D41526D6F40C40CD93C4 -4896F797DE2387E2382D8F5A068EE0290C64154C77B0D79399D85E81BB3B028F -96E0CE1AF4021CAAAD279F78B18B54977BE8B5046ADAACC7464AD41B0C0D4E68 -FA2E980EF83C094CB09BFE4FAB84C02C70B88B9D071684DE404BDD0FA567FB66 -EF04E703C9F8580B0A095FF6076E4935A125265C35A49D263E4D3226C1BEE986 -8DEEA8F6ED7541C2EE75BC8FB8330223ACDB932803B4007435B0F36940C86510 -AEED548FD5B9E056EBF6F2484FF612D7681E04D1E87D708D95C64E58385045AC -2A87E7F6AABA9DAC680524CE99C5E7A4DA70A14873FE4A9E4F58CA6BEB0D109E -627947411DE2130D783D43CC6D3D6725F79E5BC46E14385EF63D569BFEDDBFC5 -CE454F9B754EBC68A1DE413063FF6005E027DB80750003B112C93CBEABAA04FC -E07F75A62E7BC5B34E802BAD054E3DD77A436B6A5FCC5B006E38D628F69E0409 -BA8E2D97754CE7C8B00DB026D10E4FDDC3369316BB4E0B944EEC0BF4A5544EF5 -1FA02D9B429267F2C9E852125E556A0D1116D04C2A97BD27C518ED07E952EB11 -2C0B1960FBB05CB5BEBF5C91D1703A671AFF159DF7BA512726FC058213635BA4 -11D64072880D65AEA08C585BE4BBA690528242774855410872E61DA5279908E4 -ABE0948928C1E2E47C61FCB67C9A83E489454F29E18A4E646A6BC5E367D6D84C -4B70D67CDCAA9B729085EB85582265C17E56FD97C71EB9F3472EF2422269D69F -AA40ECB9062D232AAF45AAE6EA95223C95F48F435666C06EA821A00F4F614D6D -457A3CD5AA85614D60B54BC13ABB3264EC1D822FA53ADDC1E7551A9C3CED3A60 -840A2A924BBF48CC951ED9ACBB4B7759CA3A75345DFEA4BD12543421C6E65FC3 -8007DB5EA10F40B4E0797E171F42A0A70486132291040C587F79549AE2A98FA4 -DC43764E8ED321DC920EDF6A79C34839E3C5BB11E7F3CC939AFF71AE82D8BB2B -2C4CDEE000FAC57BD089D8D5C2D6317F85546F65828A62D32C3D43A2A21EAD07 -7338893F0FC2B7C2C2F0D7F8C066549174C6C411D066AD5CBEC6892C2B092866 -3117CE0F58AFA7A2B061DA228B8CB96E533415F9D9E5F80A3E49529418775E22 -59AC479B3BC8A9A1F01CAEE5D95897730BB50C0CAA2D8974EC9B90339D08A840 -DA8E831BC7D2544A636AC9693861A4A37C8EF436896C65398718B4903598FB0A -60DA2F1C172D2362FD0CBC94197EA355ABFEBD7E8E6B95ADC8C219FAAC322876 -312B362C88BC3422379422D3DD17841A2C9D1F32FC15EEE6E780745CAD5A61D4 -FA61A2C3394585C89B5D78165009CA3620F333A6F360E06118C4B7BF69E6675B -57BB57D837E05E1F1F11A3C1276901B507B967BA69B7DE18A17BA10E0DC02828 -811E45FFD3A83CD75E69CB8F8B50F820F7AC6F1DF9776584E7778D683BC6CD2D -A9D611470E6E7AA289576EBEF0202221847E2A46286DAA4366188B425AC2D3D3 -D883B9412725017F3B6C2F35316AA01EAFDEADE1806C48AF7E82EFDDF2A00245 -DA561354F1761D126C030ED21705D89E255931B47EDB1A52C57183DDD4D33F99 -BAB362278939C80F739554D6BFC7119D941A68F33ECC2901AD2B34C0306C47EE -2372E7FE3DEEC8B02789420272BB7CC2FF4DF6D23569A118046033C811232A1D -5BCA1D629A4FF3A2C2492C0243B70C8D090778A766474FBEA9DAB50C3D29B7C5 -66FBB2D444B3C06B7C9241DF74C77DB5ADF648822014C49F9141CA9323594675 -E9640F26D24BF6B9E540034F1ACE1AD766E450865F9DA29B2F8BDF66B4FF8025 -BA11D57A064CCA9B211DAF756A18621F877942D8A30ED103C6186884D68153DD -BBAF399F3D0DF5169B0E94A214B7D18F672A48B937A13133ABC5E9033734B0A2 -12A7B4DD72BE1886ADE94B968D11D29CCDA8251C2A284287037543A6E240CF67 -0EAB7EF796BD4DBD313FD3DC6D3535674184EABDAD1DA7B0A3AAD4B78CF82241 -E378FBF975403D8FAC2AA692686545D1550E8B9F457A396B3F68493A342D1982 -3E6E24DDA7D014EA1A297C38078A3404F0D87CD299DF9BF3C93FB8F236BBCA14 -F71300C5710A43605ABA308D54DBC954C66F03123393A7379C4F20DBBB03DDD5 -C273C234E8EBE27F93347F1E5B3EC0FFCE0440A205DBA5CAC312245AF05BFCC3 -734795D36BE536F56BBE0E6A42E9E9DD7EFC0B6A032E250BE71996B41B743D7D -B2C6DF05A46CAB1FE425D0AEE07284E7A556AADB19B9DB7F4FDE477C87DF72D8 -EEC435D249CC2D564C57F2379E9912A0AAF33661D0CCD213BD1A38EAE0D4535C -08BB493031B1FFD9C030B98C455C9B04304B1E628CB95FFC7FA6AAA12C2D2C83 -9166660FDD6DFC6C0CD04FB951C6BE616A258EDFAAEE4AD926608A4A36B1CD55 -9023D8647CABD029C539163705156A854D36D83EC488258C38C9B1126555D7AC -68B4B770A5800B06D374230A78C9107963B637E39D6DC7497883032EC3055DE6 -CA392F3B2ABA182FC0C468549655B8392E94DB4D85AA14DA0E3B2D3B3DFCAEE3 -F5CF755FF7A7CE0CD930DE5AF138A6262898C2316902934912FAE3924A9833BD -8D5B85F35EA4558E1FB9FFAF597F802F89AFFB5B289884A9F9BAED04084DD7E3 -A985178519BD80E3224F8533AA2D954F75096E490ECB780E6CCFF07D91E02D2C -67AF4A699F81E84134E3EA69467F5514E5F3A73A9936839729E9347BC77B709F -19137F238C2ADAE3858F31034BBEEEE79079F4B2EBE3081701B1B2FB0F114899 -C59DB78F99ED4B980DA4F04251CEE1F478A470C3954E5E83212726EC6673273F -A2285C9AD2BCE145C5EBBB946EA0D58449BE7C77332D1F222EC6C5DF2D559BAD -6E0A3122812688D9D2807F09FC09285FC0B2D3FA570E49A776B00DE85965843A -B9C936AB2C2D8960EE0FABE64C7C983C546795A4C258E4E73AADF310673C9A2D -534055FFC79B03C3E455643AFB8629AC355BAA755FB8DD4AACCBB21F2CCF8FB1 -E51E0B5C608EA149C6E6CFE107113C36FC9C85AED43723B11AED08B1B8661C0D -EB0C7DD1EC047371DE2A4C24A789CA5B186A1AEC4258814A37FE30706D29ED48 -7639345B0CDB29BF192345D5AD372BA3E696964D91CF03748F3950BD649FC102 -A1E09A59AB246350BE4A7831D126472D627758741C8F38B6A01C0DF4C2F27C68 -6ABA6364D88DF009855B73630A4C3FAC44D2F0E2488EB71808D003C12632EE18 -039732BAC01B13E1A4D8C80C8BEF266CD168CB79462C44D0F891B60E0B15CCD8 -81949F998147933D377B10CF3AC3845FC2AA53ACA02AD96DCE8314416D09F2C1 -050AD9AA80448527A9947CC7B9B365C23E950A02FF730D1C3C91CBF14A746E6B -7A2B87FD9561A4FD6254E9A2A3004B0C9A0C2E59CB914178FB114BECC02CD370 -2DAFA039EAD3D35D6CEDB468C1C42404B88BFB70C275D8636293D1A71CB48CAA -D971DDB3252B324A5499E419CCE408BC03B688F0D8774D28D7E5D740110DC5CB -22B3CD013F61BAE5983B56D23143BC45C94CE85769C1846B1E2BFC36DF7BD587 -37919D573819EC3EFAF1EB66E2A07469CE0CE596546EBAB2EEEA5F73645429AC -551E5C8F16966BC0D32D6E1C9C3EF288EF36F977EF3751931BC881935DFC6C40 -E547AD3A923DC51D1072B085F1B23CA0E191BF3D010EA0A01C83C973B835ED74 -7DFB263E2848A83AB9E06F5071F6D252A1FF14ED1A6AA8BC3DA3996207675678 -CFCFB1E134A18D1CC3ABC395CF287E139C4338CBFFAB27345A1541073127C242 -1DA55018AB81A6B3738BF659347D8D70D86B8F4C40B8A9E991DF788399B5F13B -50ED46EEE43CADED29594102E07602154608111060499F7C1C03E5372B415F33 -5A741E8EA5E3F41AF934063C94641F1129204EC1019488EA4FF89D7B003CD643 -7D2314441404815203F7FBC2DD130A5E1C5610457E583363D8B439B75C41C3B2 -05E2348A4A826D4DE429E1B61FABE14FD4ECA2C3DB124E738FF3662840AA03B8 -EF40A8D5C60E86C341D1755EF63F1D82DCA856402B949945265283420BB2B4A4 -FBF7023F2C0B36348145F92EF66D292BE48545C5555E670B5EFB973B29FFE465 -92247869BF8E3F0644CD5754A3D35FA3A1DE5BCCC43F0BE41BA782892DCAE8E5 -5EB501686B68B9C2CDDEA53787D795F59E9C827321CF42062C503F4D4B591BD4 -0F2F661B5487F7ECA6694169D335ED8EC725E53AB0CEB25CAEB9F832E93715D8 -8C8BB6F6742B14CD5F3E837A636DB41DD9C109E9771A2F8C7D7A7D12BBCF650A -BB131F547A894CC90508A936EA97154E81443C052AD474592314BE31FBAB4A79 -4C1992A35BAAE07F6816D542463726930BF25F75AD69AA44E90F55EC8A1AB06B -232EE37734835402F80EBD4E69C375D3E704A38A6DCC903119A7E23217250899 -FA9F1F37773894E24C7054D4B736742FBB054CA11BA2D3F4C3BADC74A84C904D -6A83ED9B0BEA6694C35AE8CCB0D36B92DDFC9962D2C110D99C53CD82B57C855A -B7DB749998FF87F09C6DE41CC2302131B0876A2559E4C24FB292BB477839BD18 -05028C9D217AEFF5FA65147FE25C45E9AB9503C0C90DE3F6FB98284B41192882 -21572BD89F5E970D9ECFAC501145CD0FD0ABC38DA574C0E634B14149F3A80995 -2F6CEBA40F796D7765E629C7020A5F2E5F50ECA761629A52507344F027284E93 -97F9361949AE79D2F7D911AB1F4BA65168A682D09BBDB02979B71223175EC6DD -3FFD963B5D061B59181FCFA92434BA11A578CB8442AFCBA65580C69849A6EADD -8F1D2613362869F8E16D26770C001C1F55B93EA982B6C5CAC6BA6E92A95C03B3 -A8276A01E6FBDCADF623A538CEA34178B6690DF25563B350C18B816A724E2F7D -EB84ECDABF1C2D8AA75437368AA7041E02BFA94446AFD657B423AC4DAD19B2A1 -BDEE4F3A4BBCCE651986FC707BD35922488EC1F354A05EF6497B51277E75FCEE -92177CF4CEC6FCDAF8F899B9B9A71719493D537B7DC78B384487F6D4B898D2EF -99B796B4BED49575CBE63FE809B385FC6CC84AF3AA9F87121CF7D8BEA3C6E986 -A0781F7C920943F43C3F01981C13688F7904CA925A57C527149975371BE9AB45 -FBDB098AA2C62BDA5F44BB282D022DD64CB3FE1568AB770058E372A132456331 -71FDE3E5EA752F47931DD50BD2DC54E52C69EB63E21095DC53C056CBCC05A162 -B4950FFD705C1CE37BFB3E7426260469A80204CE9B68D1C127433ACE8C3FDB27 -FD6F9C6AD71662DA823259BC1B073F829750CB8C2A50E69799F1D58DA0CCBAA8 -EC92AF28104003E13AAEEA0BEEE540696613808D91319FB12E7812FBB2CAAEB3 -A2D3EC0E6D78E720176FD3938D4C62AE1678681E98B6F82F2772356DA8FB9D82 -EB298D383F7D0C3BE5D219DD0AC897B8A2E705F15B2F9AC9306BF39AB6F50BB1 -DADA17AB813BA25513DCA43E685D04D0B44CFC212366D3A1AFC58B4B18D3D4A9 -ECD8D864890F8C03A37E4BEA20866DEF9877065A2C3F666C2862922DC4A021AD -A75DB963BF97B8AFF3D63B89707C86B4E0E5B93BFCA9407021848444ED229F16 -0B2E8889AE97BD4AC2194546FF3555245087A98FEE7B2A38401C8BE18E9D7224 -5437ED0E4E2A8876E0C8633323A2E9A7CD8C704C858FD25311262EFC6534D7A8 -9E0857B5C6282E98938B5D8E216923B0A0A75D84B1807CDFEF19D33A15C47D2A -6DF303E5A179C1752489A9A5FBAF7F00077047551702CD0C08C30E79BAB4BBCA -10AD85AA96D1EC193E05C68B9D46E44B844CA8216A9F535B737606703F07EDEE -B3825E3473244C3F2C5EA13AFD2927C769E48B6A90B41A77D57ED5D1DE504461 -C6D373489B465F0F70F107EE46D5DCABDA14BEFDAA37CE0AF78D5F416AA1456E -3DA7E189860395CFF6236CEDBBC2E0189D3BB92FC5C958A63A641CBD415D2EAF -BC219AD89CA3A17DD335495FF452FBAF85BE0293D9E5E9927196192FE3CD25C2 -C461C62B001A3723A322AF77250B8AB1D83C16858E3FC30EFE7E338663AD9F84 -EC41DCC80171C45D187E8D5C2E7E431E899C4E0644E66958EBADA5F0F6E64D21 -B2539F89570D2C1F17CDBCF5F6CB16A9787C9A4834B2F2A516D909A141F2C614 -B4B7698315DEA7CF292A85578A127BD7E0CFC5D92C57B7EBB10111BA4165E32D -162A740EE2D921BD28B8A7300B198297A58C947919A8A64722764632D9390804 -EB5CB88B984E29A580AB26B544965E3143BCDD2EF47C2738364B3F896E76C1A9 -010B624DCB2EF607984D7657ACB93E87A4E5A280745975644ED00326C559570F -C5CF308F470074A121BDCF2CFB73E0B2A872EDDD0CE746B9DA409DEFC535EB20 -5EB9D59C076EBF6F94D31EBA64ED9BF53B69ECEF4AC19B4F9CFC0BC991581179 -94C3190C95E4F261468E0AB12BFC9C20E7B1C522959E7E761F6C5229EBCF3A86 -FCE964B1371DA44FD114FBF539608B82C6B40AF191818F8B9270530914021CCF -A9F233CF6431C7D23AED734BA58A3C5959E5A2F14FCBAEED5866BB194D8CE6CA -39ABC81C4961FAF1F6C8D66998A2861F0C42B5F95D21DE751130274176C6D363 -E832D3F711916611F6F409AA859A323183B4444EA38E79062F77F30C723A3FD9 -EC9D4D27C8C25555769B2226B66601F7DA8A94A02463E541D8352FCBDDBF1297 -BB482169E9C831640C7BA586DCF00125BC2A7448C384BA5EA898F91152FE0848 -70C084B63689E76B656231CE960D4CA628E1C070AD9A1CE3467DC83453D92E34 -2123676178D378B7D234A7280E83DBA97551467C9457BABEE8835FBB594D03F3 -0C7FF2FA6E308FE763C7C894259FA5D3C66814F6A4C3EFA30A7A4C3E081373EE -3C2EA9F831EA2A7BDDB473401CEFE0DF0EA110ECB4DDC952C05F74461BD3D9C6 -80E3BB0E6E1B6D0AAFBD5A524A3732940CB4854CDEFEC572FEEE79120D436E84 -4186D94ED3B9854450097DB09C514BFBF558BCE425003F6CEF7A5417C8960126 -BC49E6FE3CE87834CC68D540D8E12F502BD63972C802D9715ED49C7B52DE87DA -AA4710B679718F9A71C0A39085D972BE32596C509D27CE809F02960FA7560D66 -678BA0AF4D0A19CA679033B1217D852DB0B6768A6821C72321FA7194E5A62D99 -AF7AE2958947C9965A1838DB932444D886247EE953A1C8A7ED765BF1DE6CD137 -7C749F346437471DD0F0DCCE249D368608BDE06D1FBC1C0236AE40135687A8EC -6D084CDC52FB99D2963FCEF40DC6E0D23AD138F38813DB0AE9B7F731312B7831 -D84A6BA2AA09637C743F686AC572B97D8D72F825E522AD2E3B943476F664A8E9 -63313AE3DAF935EC8CA6B4FC9D396270D24D5705AD16564CBF21A9AA234B6C01 -C5B6C8CDAFF4E3462B74369FB0A63B1EB1DF9696EC7860B3F6E573E34D5E953A -0B25044729B9B19854EF5A3CABAA30D2A62F60588D7171A7732171EAF9EED5D5 -B9DB771F1AEEA1F8F658BBF35E31D88FE3511B9860154DC2A96C1C3FB233A716 -516F36767EBF1D6FECE4DDE153B4E538004E0B66FF827D52A72DDF4699D4EEED -960F974C6ED54F50D9608DEA1785164C73D0B25CA313B3630171177B8EA6A2DC -3D5704DF7A0CD5098BEE074480E862F18D47FBE0F6964125DF29C23D087D0F9A -25292369A7335F33210A4660F425EFD0FD0C3F6534A12ED913697ED4444FC93B -51CF9FFFC2AB8256303E690A71E9EA8B7766E282847681497B52C297F25E60A3 -79B1D70FE503F87E9EBB5FCF1FED71321A2D21B3BFAC5A17F66A2A5CC5BD6D0F -E968A013C33EFC735A161F340F56237CAC1B347F88A4D62249023F6763111497 -4A6F068F4A49B55791D039667EC08BEEECF3E919C4F29FAE5DECE224856FD035 -999318F9B69125586FE6972508505DDE0F129687AB056E5322C1D967FE606151 -71DC9FF6098CE976C0F7BEBD4A5B16E18C1E085894C43C4A1E311B1FA34B75AC -1F444AD9912718855B50CA02AE362D66643EBFF19EA6BE2C8EA4D4339D59C52B -BCBAC2375DF2219D9D56BAA08C4577FB159143886605FC91A09885F9C2E44064 -943BC2B9040E0031BC0744B89782BCDB129A4DDAE418A03FE6EE8705089CD7B3 -C87B18939CCE4361A4C1FFD24072E620D121EBEE435489E8907DF63FF2BD505B -FF50E33DD3B3258F32D96823BCFE4519C7B77C20D2AFE9D00036EFFCE8E586E9 -667891E4D513C3BDC4615AE8369FADF56829F68139416A40C65D736601E47B0C -793C8A7493FC11C9461685966FC974DE827E81ABBC881EAE43712C3DBA1AE5CE -BB1E7FDB696C3221681D75DD419972E6AAA0AF20F8B3826AACBD3B808BEBA198 -D90A5B27CB07C2F753AF493D1863BE77EC132A394F3DAF1F9E3DD07B6BC23765 -6A392A8611D16434BDA4CE27DE4BAA3DBF95BAA05C873CA0A36177F502F87E94 -75662F5368EC605F1E00A98F6B50FB7F522A26C1C9E73D025C3A6428DB735344 -64F704E272CC268798D13D0D93B619E550F1B80562A440E7F2462D9907AEC25F -F3A6E0A4D95B253E3144404DE918C1C40D79B578D8A2C85F943DDC9DB69727CB -957ACF72D67F50D228219C582C434B24C6E3AA6BF2A8194A85D775086929A82B -F0528989A483CE5C7723A2570529C1BDF292FDD988F59D80187A25C47501C2E3 -84C702FE7F4D6C4C6B41F778367897EC91D5A4F8A3FCF300FFA584127C3BC171 -730BCCBB51AD8A85A3810F846797476EA45C4E7A250215A79CD055BBF8B97BAE -DBEB87DA404BAE058875D793264C15010DDC6F6DBD9C45BC5307F6DB4AF867DF -236EBE6CECAA1CFD3CE15FE3EB91ACBDF5433AD03CB971E78823FABF2B3C3BA7 -8ADA62C7B4FB2E65F0D7D4411634645764E198861B589F8529DC2CB6B180889A -E35B5B1BAC735866A4C49A386C1A98A59343060D7995E7C86C3380E65670E94E -4B7C2D2FB94EBDE96773547CFA5053B3B31188BAA0B57A12A2FF6EE7945D5A17 -ED1FE90E30859D3E14EA58A9FD90D5514A115EF7B11C94ADEC8608F60F06D2B0 -46DC9861614ADBD91032A92543BDDF359DA8073FD08E64F9B4D0A7B1DFD6F52A -168E09CD5E2BF9EDA46E77AEA46C25BAC9E0D8220E30D92892426B964E894015 -2F0240EFB5D931EB16EE2423B659D360433A7DCEBA96C031FDA734F0C6E89ED3 -B00946763285821FD3A63D5E0153A4B02E5CC633F6979385C908E73DB718E004 -92105D0F71028D2CD5C0A3E3F06614716B2D48B4A51E9E9D77B058F38B0F7855 -EEC100CF05536D9AC7433A3BF58D4B068E923D4B471B9A0FDA85EECEC3ED9158 -389A10E55F4DE52D2EB5B3CB5D9CC1C24B51F1A19C2F629122B05C03FC8B2A57 -18B06EBDE41C4871BFB1E6A24A85535DF5E088B94EAD6222E07DE110F1B51DB0 -8C1586F7C9711317DF20336D6DE4A2C04A4A1B121F09A2C340B22CA9F26AE7A8 -616DDE1A2D87F9729F82E20BA099D1EAC7F726CCA9D5FA93092DC3886D2529A9 -41B75B58FF112B5F97BD4301627CB3DEE6DEFC44E0392874FB86C51CE77C1969 -2A66E623BF9A64265EF5A68C3B86EFEFEB04C920D16D9F9E037E9FCC621726D5 -69449BBCB0330CAC67F0597509316FE77395FD3ACA40FFDE9CF1976DDF047674 -93683ADF1B1EF9977B03DBF04B2D213C5A67FBA1F99F752C217D672117B9087A -6A5DDA70150BF9988514E786D28336B903B3C96A746E911D7155E49470DC2F37 -41D47249C723DC2E1846A35A67820DEFCCC9462B67B26201EA4D5625CE2DE401 -D186126A214ADCB090CA7D8DAED3A1D8FABCDD8DFE1F0837CCC087A486622C2C -281CC8260608D0896A49019EDF7FDF57D5CE0279E7F491E8370B4954779B4B53 -C6D7B6E2F349283AA0467D9BB06FDDD321BA05F988C5518DA8E48D66D24136BC -271123C27D43408927F0DCBC5DB8D8CAD7E61C46BEEE70F137B087A6899EB040 -145D9AD63C840BC5D030ACDBE4B87A23AF641A64E796336FB31B00B0674AA9CD -B19BDFF46C93DDBA27ED0D8BBF5E6DD642736D594B616C3B26A59C463FB4253A -136DDD4592D6223940C98E4BCE603CCD05D30B3A26B1A4B2C8BEEC799E61907B -855B2CE81549AF2EA116F9DD3A35446CD662EFF77C49DB0BF7B3BBF496D750B6 -E2025B2F041092F322ECF8CD037C5829568CCDE9823BF7F37756DFB7F6D05CC0 -E5B6B6F95A839DF60F9CA9E03AE4E9944ECC2957141606326763789EE4B4D7FC -154A7C3C509362E80D9D2E84967E60B2A14940B08805625EA09988A68BE7AACB -6770F8C05B472FF649514CB7DADE001B7B85E5A849ABC018F34E59292A527A99 -1E2734A3D8D3EF87CDD665814A7CFCB663ACEE51E9E61BF232FFD8F917A5AE70 -57ACF846460F772202A834BE3DB233E117DCFC0A039E04AE30EB0AA3C773CE6A -9EA4E2686283660E068FF095BC780A6F1D4857D7C0789D599798AAF9C71AB082 -6555100BC97C54577AD82D5E063017207922DBE0BF744D51E31A921B27954B60 -95B3695098C47CD0996438CC0F89198ABCA22FEEC261BD0C0B617DC02F553837 -4DD1EC502C935A8DDAF7C73791D7DA2764AA3863D43A5E3EF39AB099CA249A7C -D4CAE2FB83851EFE6863256E432D5F0DC898029C3A069C6EFB8C342B8507182A -44292E6F4E75397621A3DF4F94557AA746C9049B5B86ECE49BFA031F30B3D505 -D42215F78BD2D50E86142B28C2B06A2FD427E5F1C569E58587BB3B531AD4E8AD -10065410A4B3BFEF97070CC87FCAB12C9F0FCB5F1716E00975B2EBE522586123 -A7C33B060079D22EF11DD55A719819AF9CA90B587A11C56F8F9A846BCDB3C930 -AD1E3A490DA0643CB34758E109DD6C91B22C2AD4859101DB53723D3C9C48CC41 -7FF3D9FE1FE57922335D28EC50F0CEE33DCF55A87A0FD383EBDC3D33C8FFFBC7 -05D658873D655635A841C5D8A52294A060DA01A586F63E3EACF1AC7941CDAA7A -1A4DDF5DC5018186B40713A69B759150B3BC3561CA963516783A7BF2D182CFD6 -2529AC360ABDD6863B33C84B3DE527E64E5F1C0B72BAF23B1FF7276773FC2951 -523ACE4D620FC9A1FC5966ABC74D421DAA156B9955B579C781AD87124687BBA2 -DD1116F80D7F6980E10CC387AFF901B19F6CD0667C82932D9123287301A5FD9E -660D5F9E5ABB4A42936BC6DDAE92198CF969FB3D397BA6B1DFE1233752272225 -2B8F0BF0765ED694D50D0BE4F8C09F85713E37E85A3BFD559DAF869E3B6ECF7E -080D71A25B2FF6E38D966C75233D12E3C15A8B4002A985DE92DACB4AD2F6D9C9 -69B09914EC2719A160CDF0BD16E56898B0BD07C1B7747D1C6E591FD66DE00A64 -C5ACDE5D0488D9AAC392DAD684B5F681A554CD6EA6159B6807D861E2FAB69482 -DDB29C8D046AD8A6707BC19DD9494B8E44 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000000000 -cleartomark -%%EndResource -/F8_0 /APYGPQ+LucidaSans-Typewriter83 1 1 -[ /.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/quoteright - /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 - /quoteleft/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/bullet - /Euro/bullet/quotesinglbase/florin/quotedblbase/ellipsis/dagger/daggerdbl - /circumflex/perthousand/Scaron/guilsinglleft/OE/bullet/Zcaron/bullet - /bullet/quoteleft/quoteright/quotedblleft/quotedblright/bullet/endash/emdash - /tilde/trademark/scaron/guilsinglright/oe/bullet/zcaron/Ydieresis - /space/exclamdown/cent/sterling/currency/yen/brokenbar/section - /dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron - /degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered - /cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown - /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla - /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis - /Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply - /Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls - /agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla - /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis - /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide - /oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis] -pdfMakeFont -612 792 false pdfSetup -%%EndSetup -%%Page: 1 1 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 README Page 1) 144.161 Tj -0 -28.4801 Td -(xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson\ -'s Unix) 305.796 Tj -0 -37.9735 Td -(Version 6 \(v6\). xv6 loosely follows the structure and style \ -of v6,) 292.6905 Tj -0 -47.4668 Td -(but is implemented for a modern x86-based multiprocessor using \ -ANSI C.) 305.796 Tj -0 -66.4535 Td -(ACKNOWLEDGMENTS) 65.5277 Tj -0 -85.4402 Td -(xv6 is inspired by John Lions's Commentary on UNIX 6th Edition \ -\(Peer) 297.059 Tj -0 -94.9336 Td -(to Peer Communications; ISBN: 1-57398-013-7; 1st edition \(June\ - 14,) 288.322 Tj -0 -104.4269 Td -(2000\)\). See also http://pdos.csail.mit.edu/6.828/2007/v6.html\ -, which) 297.059 Tj -0 -113.9203 Td -(provides pointers to on-line resources for v6.) 200.9517 Tj -0 -132.907 Td -(xv6 borrows code from the following sources:) 192.2146 Tj -17.4613 -142.4004 Td -(JOS \(asm.h, elf.h, mmu.h, bootasm.S, ide.c, console.c, and oth\ -ers\)) 288.322 Tj -17.4613 -151.8937 Td -(Plan 9 \(bootother.S, mp.h, mp.c, lapic.c\)) 179.1091 Tj -17.4613 -161.3871 Td -(FreeBSD \(ioapic.c\)) 78.6333 Tj -17.4613 -170.8804 Td -(NetBSD \(console.c\)) 78.6333 Tj -0 -189.8667 Td -(The following people made contributions:) 174.7406 Tj -17.4613 -199.3601 Td -(Russ Cox \(context switching, locking\)) 161.635 Tj -17.4613 -208.8535 Td -(Cliff Frey \(MP\)) 65.5277 Tj -17.4613 -218.3468 Td -(Xiao Yu \(MP\)) 52.4222 Tj -0 -237.3335 Td -(The code in the files that constitute xv6 is) 192.2146 Tj -0 -246.8269 Td -(Copyright 2006-2007 Frans Kaashoek, Robert Morris, and Russ Cox\ -.) 279.5849 Tj -0 -265.8136 Td -(ERROR REPORTS) 56.7907 Tj -0 -284.8003 Td -(If you spot errors or have suggestions for improvement, please \ -send) 292.6905 Tj -0 -294.2936 Td -(email to Frans Kaashoek and Robert Morris \(kaashoek,rtm@csail.\ -mit.edu\). ) 314.533 Tj -0 -313.2803 Td -(BUILDING AND RUNNING XV6) 104.8443 Tj -0 -332.267 Td -(To build xv6 on an x86 ELF machine \(like Linux or FreeBSD\), r\ -un "make".) 310.1645 Tj -0 -341.7604 Td -(On non-x86 or non-ELF machines \(like OS X, even on x86\), you \ -will) 283.9534 Tj -0 -351.2538 Td -(need to install a cross-compiler gcc suite capable of producing\ - x86 ELF) 310.1645 Tj -0 -360.7471 Td -(binaries. See http://pdos.csail.mit.edu/6.828/2007/tools.html.) 275.2164 Tj -0 -370.2405 Td -(Then run "make TOOLPREFIX=i386-jos-elf-".) 179.1091 Tj -0 -389.2272 Td -(To run xv6, you can use Bochs or QEMU, both PC simulators.) 253.3738 Tj -0 -398.7205 Td -(Bochs makes debugging easier, but QEMU is much faster. ) 240.2683 Tj -0 -408.2139 Td -(To run in Bochs, run "make bochs" and then type "c" at the boch\ -s prompt.) 314.533 Tj -0 -417.7073 Td -(To run in QEMU, run "make qemu". Both log the xv6 screen outpu\ -t to ) 297.059 Tj -0 -427.2006 Td -(standard output.) 69.8962 Tj -0 -446.1873 Td -(To create a typeset version of the code, run "make xv6.pdf".) 262.1109 Tj -0 -455.6807 Td -(This requires the "mpage" text formatting utility.) 218.4257 Tj -0 -465.174 Td -(See http://www.mesa.nl/pub/mpage/.) 148.5295 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 table of contents Page 1) 192.2146 Tj -0 -28.4801 Td -(The numbers to the left of the file names in the table are shee\ -t numbers.) 318.9016 Tj -0 -37.9735 Td -(The source code has been printed in a double column format with\ - fifty) 301.4275 Tj -0 -47.4668 Td -(lines per column, giving one hundred lines per sheet \(or page\)\ -.) 275.2164 Tj -0 -56.9602 Td -(Thus there is a convenient relationship between line numbers an\ -d sheet numbers.) 345.1126 Tj -0 -85.4403 Td -(# basic headers) 65.5277 Tj --4514.2 TJm -(# system calls) 61.1592 Tj --5015.87 TJm -(# pipes) 30.5796 Tj -0 -94.9336 Td -(01 types.h) 43.6851 Tj --7022.54 TJm -(24 traps.h) 43.6851 Tj --7022.54 TJm -(51 pipe.c) 39.3166 Tj -0 -104.427 Td -(01 param.h) 43.6851 Tj --7022.54 TJm -(24 vectors.pl) 56.7907 Tj -0 -113.9204 Td -(02 defs.h) 39.3166 Tj --7524.2 TJm -(25 trapasm.S) 52.4222 Tj --6019.2 TJm -(# string operations) 83.0018 Tj -0 -123.4137 Td -(04 x86.h) 34.9481 Tj --8025.87 TJm -(25 trap.c) 39.3166 Tj --7524.2 TJm -(53 string.c) 48.0537 Tj -0 -132.9071 Td -(06 asm.h) 34.9481 Tj --8025.87 TJm -(27 syscall.h) 52.4222 Tj -0 -142.4004 Td -(06 mmu.h) 34.9481 Tj --8025.87 TJm -(27 syscall.c) 52.4222 Tj --6019.2 TJm -(# low-level hardware) 87.3703 Tj -0 -151.8938 Td -(08 elf.h) 34.9481 Tj --8025.87 TJm -(29 sysproc.c) 52.4222 Tj --6019.2 TJm -(54 mp.h) 30.5796 Tj -209.536 -161.3872 Td -(55 mp.c) 30.5796 Tj -0 -170.8805 Td -(# startup) 39.3166 Tj --7524.2 TJm -(# file system) 56.7907 Tj --5517.54 TJm -(56 lapic.c) 43.6851 Tj -0 -180.3739 Td -(09 bootasm.S) 52.4222 Tj --6019.2 TJm -(30 buf.h) 34.9481 Tj --8025.87 TJm -(58 ioapic.c) 48.0537 Tj -0 -189.8672 Td -(10 bootother.S) 61.1592 Tj --5015.87 TJm -(30 fcntl.h) 43.6851 Tj --7022.54 TJm -(59 picirq.c) 48.0537 Tj -0 -199.3606 Td -(11 bootmain.c) 56.7907 Tj --5517.54 TJm -(31 stat.h) 39.3166 Tj --7524.2 TJm -(61 kbd.h) 34.9481 Tj -0 -208.854 Td -(12 main.c) 39.3166 Tj --7524.2 TJm -(31 fs.h) 30.5796 Tj --8527.54 TJm -(62 kbd.c) 34.9481 Tj -104.768 -218.3473 Td -(32 file.h) 39.3166 Tj --7524.2 TJm -(63 console.c) 52.4222 Tj -0 -227.8407 Td -(# locks) 30.5796 Tj --8527.54 TJm -(33 ide.c) 34.9481 Tj --8025.87 TJm -(66 timer.c) 43.6851 Tj -0 -237.334 Td -(13 spinlock.h) 56.7907 Tj --5517.54 TJm -(35 bio.c) 34.9481 Tj -0 -246.8274 Td -(13 spinlock.c) 56.7907 Tj --5517.54 TJm -(36 fs.c) 30.5796 Tj --8527.54 TJm -(# user-level) 52.4222 Tj -104.768 -256.3208 Td -(44 file.c) 39.3166 Tj --7524.2 TJm -(67 initcode.S) 56.7907 Tj -0 -265.8141 Td -(# processes) 48.0537 Tj --6520.87 TJm -(45 sysfile.c) 52.4222 Tj --6019.2 TJm -(67 usys.S) 39.3166 Tj -0 -275.3075 Td -(15 proc.h) 39.3166 Tj --7524.2 TJm -(50 exec.c) 39.3166 Tj --7524.2 TJm -(68 init.c) 39.3166 Tj -0 -284.8008 Td -(16 proc.c) 39.3166 Tj -209.536 -284.8008 Td -(68 sh.c) 30.5796 Tj -0 -294.2942 Td -(22 swtch.S) 43.6851 Tj -0 -303.7876 Td -(22 kalloc.c) 48.0537 Tj -0 -341.7606 Td -(The source listing is preceded by a cross-reference that lists \ -every defined ) 336.3756 Tj -0 -351.2539 Td -(constant, struct, global variable, and function in xv6. Each e\ -ntry gives,) 323.2701 Tj -0 -360.7473 Td -(on the same line as the name, the line number \(or, in a few ca\ -ses, numbers\)) 327.6386 Tj -0 -370.2406 Td -(where the name is defined. Successive lines in an entry list t\ -he line) 305.796 Tj -0 -379.734 Td -(numbers where the name is used. For example, this entry:) 249.0053 Tj -17.4613 -398.7207 Td -(swtch 2208) 43.6851 Tj -34.9226 -408.2141 Td -(0318 1928 1967 2207) 83.0018 Tj -34.9226 -417.7074 Td -(2208) 17.4741 Tj --0 -436.6941 Td -(indicates that swtch is defined on line 2208 and is mentioned o\ -n five lines) 327.6386 Tj --0 -446.1875 Td -(on sheets 03, 19, and 22.) 109.2129 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 2 2 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 1) 187.8461 Tj -0 -28.4801 Td -(acquire 1373) 52.4222 Tj --12038.8 TJm -(bmap 4010) 39.3166 Tj -17.4613 -37.9735 Td -(0321 1373 1377 1759) 83.0018 Tj --8527.14 TJm -(4010 4036 4119 4169) 83.0018 Tj -17.4613 -47.4664 Td -(1917 1975 2018 2033) 83.0018 Tj --8527.14 TJm -(4222) 17.4741 Tj -17.4613 -56.9594 Td -(2066 2079 2123 2158) 83.0018 Tj --6520.6 TJm -(bootmain 1116) 56.7907 Tj -17.4613 -66.4524 Td -(2315 2362 2616 2971) 83.0018 Tj --8527.14 TJm -(0976 1116) 39.3166 Tj -17.4613 -75.9453 Td -(3407 3465 3570 3629) 83.0018 Tj --6520.6 TJm -(bootothers 1267) 65.5277 Tj -17.4613 -85.4383 Td -(3857 3890 3910 3939) 83.0018 Tj --8527.14 TJm -(1207 1234 1267) 61.1592 Tj -17.4613 -94.9313 Td -(3954 3964 4425 4441) 83.0018 Tj --6520.6 TJm -(BPB 3188) 34.9481 Tj -17.4613 -104.4243 Td -(4456 5213 5234 5255) 83.0018 Tj --8527.14 TJm -(3188 3191 3712 3714) 83.0018 Tj -17.4613 -113.9172 Td -(6360 6516 6558 6606) 83.0018 Tj --8527.14 TJm -(3740) 17.4741 Tj -0 -123.4106 Td -(allocproc 1754) 61.1592 Tj --11035.5 TJm -(bread 3602) 43.6851 Tj -17.4613 -132.9039 Td -(1754 1807 1860) 61.1592 Tj --11035.5 TJm -(0211 3602 3682 3693) 83.0018 Tj -0 -142.3973 Td -(alltraps 2506) 56.7907 Tj --13543.7 TJm -(3713 3739 3811 3832) 83.0018 Tj -17.4613 -151.8907 Td -(2459 2467 2480 2485) 83.0018 Tj --8527.14 TJm -(3917 4026 4068 4119) 83.0018 Tj -17.4613 -161.3836 Td -(2505 2506) 39.3166 Tj --13543.8 TJm -(4169 4222) 39.3166 Tj -0 -170.877 Td -(ALT 6110) 34.9481 Tj --14045.5 TJm -(brelse 3624) 48.0537 Tj -17.4613 -180.3703 Td -(6110 6138 6140) 61.1592 Tj --11035.5 TJm -(0212 3624 3627 3684) 83.0018 Tj -0 -189.8633 Td -(argfd 4563) 43.6851 Tj --15048.7 TJm -(3696 3719 3723 3746) 83.0018 Tj -17.4613 -199.3567 Td -(4563 4606 4621 4633) 83.0018 Tj --8527.14 TJm -(3817 3820 3841 3925) 83.0018 Tj -17.4613 -208.8497 Td -(4644 4656) 39.3166 Tj --13543.8 TJm -(4032 4074 4122 4173) 83.0018 Tj -0 -218.343 Td -(argint 2794) 48.0537 Tj --14547 TJm -(4233 4237) 39.3166 Tj -17.4613 -227.8364 Td -(0339 2794 2808 2824) 83.0018 Tj --6520.6 TJm -(BSIZE 3158) 43.6851 Tj -17.4613 -237.3293 Td -(2931 2956 2969 4568) 83.0018 Tj --8527.14 TJm -(3158 3168 3182 3188) 83.0018 Tj -17.4613 -246.8223 Td -(4621 4633 4858 4921) 83.0018 Tj --8527.14 TJm -(3694 4119 4120 4121) 83.0018 Tj -17.4613 -256.3153 Td -(4922 4957) 39.3166 Tj --13543.8 TJm -(4165 4166 4169 4170) 83.0018 Tj -0 -265.8086 Td -(argptr 2804) 48.0537 Tj --14547 TJm -(4171 4221 4222 4224) 83.0018 Tj -17.4613 -275.302 Td -(0340 2804 4621 4633) 83.0018 Tj --6520.6 TJm -(buf 3000) 34.9481 Tj -17.4613 -284.795 Td -(4656 4982) 39.3166 Tj --13543.8 TJm -(0200 0211 0212 0213) 83.0018 Tj -0 -294.2883 Td -(argstr 2821) 48.0537 Tj --14547 TJm -(0253 3000 3004 3005) 83.0018 Tj -17.4613 -303.7817 Td -(0341 2821 4668 4758) 83.0018 Tj --8527.14 TJm -(3006 3310 3325 3328) 83.0018 Tj -17.4613 -313.2747 Td -(4858 4906 4920 4935) 83.0018 Tj --8527.14 TJm -(3375 3404 3454 3456) 83.0018 Tj -17.4613 -322.7676 Td -(4957) 17.4741 Tj --16052.1 TJm -(3459 3527 3531 3535) 83.0018 Tj -0 -332.2606 Td -(BACK 6861) 39.3166 Tj --15550.3 TJm -(3541 3553 3565 3568) 83.0018 Tj -17.4613 -341.754 Td -(6861 6974 7120 7389) 83.0018 Tj --8527.14 TJm -(3601 3604 3614 3624) 83.0018 Tj -0 -351.2473 Td -(backcmd 6896 7114) 74.2647 Tj --11537 TJm -(3669 3680 3691 3707) 83.0018 Tj -17.4613 -360.7407 Td -(6896 6909 6975 7114) 83.0018 Tj --8527.14 TJm -(3732 3805 3829 3904) 83.0018 Tj -17.4613 -370.2337 Td -(7116 7242 7355 7390) 83.0018 Tj --8527.14 TJm -(4013 4057 4105 4155) 83.0018 Tj -0 -379.727 Td -(BACKSPACE 6450) 61.1592 Tj --13042 TJm -(4215 6328 6339 6342) 83.0018 Tj -17.4613 -389.2204 Td -(6450 6467 6526 6532) 83.0018 Tj --8527.14 TJm -(6345 6503 6524 6537) 83.0018 Tj -0 -398.7137 Td -(balloc 3704) 48.0537 Tj --14547 TJm -(6568 6601 6608 6984) 83.0018 Tj -17.4613 -408.2071 Td -(3704 3725 4017 4025) 83.0018 Tj --8527.14 TJm -(6987 6988 6989 7003) 83.0018 Tj -17.4613 -417.7001 Td -(4029) 17.4741 Tj --16052.1 TJm -(7015 7016 7019 7020) 83.0018 Tj -0 -427.1934 Td -(BBLOCK 3191) 48.0537 Tj --14547 TJm -(7021 7025) 39.3166 Tj -17.4613 -436.6868 Td -(3191 3713 3739) 61.1592 Tj --9028.94 TJm -(bwrite 3614) 48.0537 Tj -0 -446.1801 Td -(bfree 3730) 43.6851 Tj --15048.7 TJm -(0213 3614 3617 3695) 83.0018 Tj -17.4613 -455.6735 Td -(3730 4062 4072 4075) 83.0018 Tj --8527.14 TJm -(3718 3745 3816 3840) 83.0018 Tj -0 -465.1669 Td -(bget 3566) 39.3166 Tj --15550.3 TJm -(4030 4172) 39.3166 Tj -17.4613 -474.6598 Td -(3566 3596 3606) 61.1592 Tj --9028.94 TJm -(bzero 3689) 43.6851 Tj -0 -484.1532 Td -(binit 3539) 43.6851 Tj --15048.7 TJm -(3689 3736) 39.3166 Tj -17.4613 -493.6466 Td -(0210 1227 3539) 61.1592 Tj --9028.94 TJm -(B_BUSY 3009) 48.0537 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 2) 187.8461 Tj -17.4613 -28.4801 Td -(3009 3458 3576 3577) 83.0018 Tj --8527.14 TJm -(7394) 17.4741 Tj -17.4613 -37.9735 Td -(3588 3591 3616 3626) 83.0018 Tj --6520.6 TJm -(CONSOLE 3290) 52.4222 Tj -17.4613 -47.4668 Td -(3638) 17.4741 Tj --16052.1 TJm -(3290 6621 6622) 61.1592 Tj -0 -56.9602 Td -(B_DIRTY 3011) 52.4222 Tj --12038.8 TJm -(consoleinit 6616) 69.8962 Tj -17.4613 -66.4535 Td -(3011 3387 3416 3421) 83.0018 Tj --8527.14 TJm -(0216 1219 6616) 61.1592 Tj -17.4613 -75.9469 Td -(3460 3479 3618) 61.1592 Tj --9028.94 TJm -(consoleintr 6512) 69.8962 Tj -0 -85.4403 Td -(B_VALID 3010) 52.4222 Tj --14045.3 TJm -(0218 6298 6512) 61.1592 Tj -17.4613 -94.9336 Td -(3010 3420 3460 3479) 83.0018 Tj --6520.6 TJm -(consoleread 6551) 69.8962 Tj -17.4613 -104.427 Td -(3607) 17.4741 Tj --16052.1 TJm -(6551 6622) 39.3166 Tj -0 -113.9203 Td -(C 6131 6509) 48.0537 Tj --12540.5 TJm -(consolewrite 6601) 74.2647 Tj -17.4613 -123.4137 Td -(6131 6179 6204 6205) 83.0018 Tj --8527.14 TJm -(6601 6621) 39.3166 Tj -17.4613 -132.9071 Td -(6206 6207 6208 6210) 83.0018 Tj --6520.6 TJm -(consputc 6487) 56.7907 Tj -17.4613 -142.4004 Td -(6509 6519 6522 6529) 83.0018 Tj --8527.14 TJm -(6315 6345 6366 6384) 83.0018 Tj -17.4613 -151.8938 Td -(6539 6569) 39.3166 Tj --13543.8 TJm -(6387 6391 6392 6487) 83.0018 Tj -0 -161.3871 Td -(CAPSLOCK 6112) 56.7907 Tj --13543.7 TJm -(6526 6532 6538 6608) 83.0018 Tj -17.4613 -170.8805 Td -(6112 6145 6286) 61.1592 Tj --9028.94 TJm -(context 1518) 52.4222 Tj -0 -180.3739 Td -(cgaputc 6455) 52.4222 Tj --14045.3 TJm -(0201 0318 1518 1537) 83.0018 Tj -17.4613 -189.8668 Td -(6455 6496) 39.3166 Tj --13543.8 TJm -(1559 1678 1787 1788) 83.0018 Tj -0 -199.3602 Td -(cli 0520) 34.9481 Tj --16052 TJm -(1789 1790 1928 1967) 83.0018 Tj -17.4613 -208.8535 Td -(0520 0522 0915 1029) 83.0018 Tj --6520.6 TJm -(cprintf 1221 6352) 74.2647 Tj -17.4613 -218.3469 Td -(1460 6406 6490) 61.1592 Tj --11035.5 TJm -(0217 1221 1222 1258) 83.0018 Tj -0 -227.8403 Td -(cmd 6865) 34.9481 Tj --16052 TJm -(1262 1676 1680 1682) 83.0018 Tj -17.4613 -237.3336 Td -(6865 6877 6886 6887) 83.0018 Tj --8527.14 TJm -(2286 2375 2637 2653) 83.0018 Tj -17.4613 -246.827 Td -(6892 6893 6898 6902) 83.0018 Tj --8527.14 TJm -(2658 2882 3410 5619) 83.0018 Tj -17.4613 -256.3203 Td -(6906 6915 6918 6923) 83.0018 Tj --8527.14 TJm -(5639 5761 5912 6352) 83.0018 Tj -17.4613 -265.8137 Td -(6931 6937 6941 6951) 83.0018 Tj --8527.14 TJm -(6408 6409 6410 6413) 83.0018 Tj -17.4613 -275.3071 Td -(6975 6977 7052 7055) 83.0018 Tj --6520.6 TJm -(cpu 1557) 34.9481 Tj -17.4613 -284.8004 Td -(7057 7058 7059 7060) 83.0018 Tj --8527.14 TJm -(0256 1221 1222 1258) 83.0018 Tj -17.4613 -294.2938 Td -(7063 7064 7066 7068) 83.0018 Tj --8527.14 TJm -(1260 1262 1271 1306) 83.0018 Tj -17.4613 -303.7871 Td -(7069 7070 7071 7072) 83.0018 Tj --8527.14 TJm -(1365 1386 1408 1446) 83.0018 Tj -17.4613 -313.2805 Td -(7073 7074 7075 7076) 83.0018 Tj --8527.14 TJm -(1461 1462 1470 1472) 83.0018 Tj -17.4613 -322.7739 Td -(7079 7080 7082 7084) 83.0018 Tj --8527.14 TJm -(1557 1567 1571 1582) 83.0018 Tj -17.4613 -332.2672 Td -(7085 7086 7087 7088) 83.0018 Tj --8527.14 TJm -(1705 1710 1715 1724) 83.0018 Tj -17.4613 -341.7606 Td -(7089 7100 7101 7103) 83.0018 Tj --8527.14 TJm -(1725 1726 1727 1728) 83.0018 Tj -17.4613 -351.2539 Td -(7105 7106 7107 7108) 83.0018 Tj --8527.14 TJm -(1729 1928 1959 1966) 83.0018 Tj -17.4613 -360.7473 Td -(7109 7110 7113 7114) 83.0018 Tj --8527.14 TJm -(1967 1968 2615 2637) 83.0018 Tj -17.4613 -370.2407 Td -(7116 7118 7119 7120) 83.0018 Tj --8527.14 TJm -(2638 2653 2654 2658) 83.0018 Tj -17.4613 -379.734 Td -(7121 7122 7212 7213) 83.0018 Tj --8527.14 TJm -(2659 5512 5513 5761) 83.0018 Tj -17.4613 -389.2274 Td -(7214 7215 7217 7221) 83.0018 Tj --8527.14 TJm -(6408) 17.4741 Tj -17.4613 -398.7207 Td -(7224 7230 7231 7234) 83.0018 Tj --6520.6 TJm -(cpunum 5751) 48.0537 Tj -17.4613 -408.2141 Td -(7237 7239 7242 7246) 83.0018 Tj --8527.14 TJm -(0269 1255 1256 1279) 83.0018 Tj -17.4613 -417.7075 Td -(7248 7250 7253 7255) 83.0018 Tj --8527.14 TJm -(1707 5751 5923 5932) 83.0018 Tj -17.4613 -427.2008 Td -(7258 7260 7263 7264) 83.0018 Tj --6520.6 TJm -(CR0_PE 0910 1024) 69.8962 Tj -17.4613 -436.6942 Td -(7275 7278 7281 7285) 83.0018 Tj --8527.14 TJm -(0956 1056) 39.3166 Tj -17.4613 -446.1875 Td -(7300 7303 7308 7312) 83.0018 Tj --6520.6 TJm -(create 4801) 48.0537 Tj -17.4613 -455.6809 Td -(7313 7316 7321 7322) 83.0018 Tj --8527.14 TJm -(4801 4821 4834 4838) 83.0018 Tj -17.4613 -465.1743 Td -(7328 7337 7338 7344) 83.0018 Tj --8527.14 TJm -(4862 4906 4923) 61.1592 Tj -17.4613 -474.6676 Td -(7345 7351 7352 7361) 83.0018 Tj --6520.6 TJm -(CRTPORT 6451) 52.4222 Tj -17.4613 -484.161 Td -(7364 7366 7372 7373) 83.0018 Tj --8527.14 TJm -(6451 6460 6461 6462) 83.0018 Tj -17.4613 -493.6543 Td -(7378 7384 7390 7391) 83.0018 Tj --8527.14 TJm -(6463 6479 6480 6481) 83.0018 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 3 3 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 3) 187.8461 Tj -17.4613 -28.4801 Td -(6482) 17.4741 Tj --14045.6 TJm -(exit 2104) 39.3166 Tj -0 -37.9735 Td -(CTL 6109) 34.9481 Tj --16052 TJm -(0302 2104 2140 2605) 83.0018 Tj -17.4613 -47.4664 Td -(6109 6135 6139 6285) 83.0018 Tj --8527.14 TJm -(2609 2667 2676 2916) 83.0018 Tj -0 -56.9598 Td -(devsw 3283) 43.6851 Tj --15048.7 TJm -(6715 6718 6761 6826) 83.0018 Tj -17.4613 -66.4531 Td -(3283 3288 4108 4110) 83.0018 Tj --8527.14 TJm -(6831 6916 6925 6935) 83.0018 Tj -17.4613 -75.9465 Td -(4158 4160 4407 6621) 83.0018 Tj --8527.14 TJm -(6980 7028 7035) 61.1592 Tj -17.4613 -85.4399 Td -(6622) 17.4741 Tj --14045.6 TJm -(fdalloc 4582) 52.4222 Tj -0 -94.9332 Td -(dinode 3172) 48.0537 Tj --14547 TJm -(4582 4608 4874 4987) 83.0018 Tj -17.4613 -104.4266 Td -(3172 3182 3806 3812) 83.0018 Tj --6520.6 TJm -(fetchint 2766) 56.7907 Tj -17.4613 -113.9199 Td -(3830 3833 3905 3918) 83.0018 Tj --8527.14 TJm -(0342 2766 2796 4963) 83.0018 Tj -0 -123.4133 Td -(dirent 3203) 48.0537 Tj --12540.5 TJm -(fetchstr 2778) 56.7907 Tj -17.4613 -132.9067 Td -(3203 4216 4223 4224) 83.0018 Tj --8527.14 TJm -(0343 2778 2826 4969) 83.0018 Tj -17.4613 -142.4 Td -(4255 4705 4754) 61.1592 Tj --9028.94 TJm -(file 3250) 39.3166 Tj -0 -151.8934 Td -(dirlink 4252) 52.4222 Tj --14045.3 TJm -(0202 0225 0226 0227) 83.0018 Tj -17.4613 -161.3867 Td -(0234 4252 4267 4275) 83.0018 Tj --8527.14 TJm -(0229 0230 0231 0287) 83.0018 Tj -17.4613 -170.8801 Td -(4684 4833 4837 4838) 83.0018 Tj --8527.14 TJm -(1540 3250 3671 4404) 83.0018 Tj -0 -180.3735 Td -(dirlookup 4212) 61.1592 Tj --13042 TJm -(4410 4420 4423 4426) 83.0018 Tj -17.4613 -189.8664 Td -(0235 4212 4219 4259) 83.0018 Tj --8527.14 TJm -(4438 4439 4452 4454) 83.0018 Tj -17.4613 -199.3598 Td -(4374 4770 4811) 61.1592 Tj --11035.5 TJm -(4476 4502 4522 4557) 83.0018 Tj -0 -208.8532 Td -(DIRSIZ 3201) 48.0537 Tj --14547 TJm -(4563 4566 4582 4603) 83.0018 Tj -17.4613 -218.3465 Td -(3201 3205 4205 4272) 83.0018 Tj --8527.14 TJm -(4617 4629 4642 4653) 83.0018 Tj -17.4613 -227.8399 Td -(4328 4329 4391 4665) 83.0018 Tj --8527.14 TJm -(4855 4979 5156 5171) 83.0018 Tj -17.4613 -237.3332 Td -(4755 4805) 39.3166 Tj --13543.8 TJm -(6310 6878 6933 6934) 83.0018 Tj -0 -246.8266 Td -(DPL_USER 0711) 56.7907 Tj --13543.7 TJm -(7064 7072 7272) 61.1592 Tj -17.4613 -256.32 Td -(0711 1724 1725 1817) 83.0018 Tj --6520.6 TJm -(filealloc 4421) 61.1592 Tj -17.4613 -265.8133 Td -(1818 2572 2666 2675) 83.0018 Tj --8527.14 TJm -(0225 4421 4874 5177) 83.0018 Tj -0 -275.3067 Td -(E0ESC 6116) 43.6851 Tj --13042.1 TJm -(fileclose 4452) 61.1592 Tj -17.4613 -284.8 Td -(6116 6270 6274 6275) 83.0018 Tj --8527.14 TJm -(0226 2115 4452 4458) 83.0018 Tj -17.4613 -294.2934 Td -(6277 6280) 39.3166 Tj --13543.8 TJm -(4647 4876 4990 4991) 83.0018 Tj -0 -303.7868 Td -(elfhdr 0855) 48.0537 Tj --14547 TJm -(5204 5206) 39.3166 Tj -17.4613 -313.2801 Td -(0855 1118 1123 5014) 83.0018 Tj --6520.6 TJm -(filedup 4439) 52.4222 Tj -0 -322.7735 Td -(ELF_MAGIC 0852) 61.1592 Tj --13042 TJm -(0227 1880 4439 4443) 83.0018 Tj -17.4613 -332.2664 Td -(0852 1129 5028) 61.1592 Tj --11035.5 TJm -(4610) 17.4741 Tj -0 -341.7598 Td -(ELF_PROG_LOAD 0886) 78.6333 Tj --9028.81 TJm -(fileinit 4414) 56.7907 Tj -17.4613 -351.2532 Td -(0886 5036 5067) 61.1592 Tj --11035.5 TJm -(0228 1228 4414) 61.1592 Tj -0 -360.7465 Td -(EOI 5663) 34.9481 Tj --14045.5 TJm -(fileread 4502) 56.7907 Tj -17.4613 -370.2399 Td -(5663 5734 5775) 61.1592 Tj --11035.5 TJm -(0229 4502 4517 4623) 83.0018 Tj -0 -379.7332 Td -(ERROR 5681) 43.6851 Tj --13042.1 TJm -(filestat 4476) 56.7907 Tj -17.4613 -389.2266 Td -(5681 5727) 39.3166 Tj --13543.8 TJm -(0230 4476 4658) 61.1592 Tj -0 -398.72 Td -(ESR 5666) 34.9481 Tj --14045.5 TJm -(filewrite 4522) 61.1592 Tj -17.4613 -408.2133 Td -(5666 5730 5731) 61.1592 Tj --11035.5 TJm -(0231 4522 4537 4635) 83.0018 Tj -0 -417.7067 Td -(EXEC 6857) 39.3166 Tj --13543.8 TJm -(FL_IF 0660) 43.6851 Tj -17.4613 -427.2 Td -(6857 6922 7059 7365) 83.0018 Tj --8527.14 TJm -(0660 1462 1468 1821) 83.0018 Tj -0 -436.6934 Td -(exec 5009) 39.3166 Tj --15550.3 TJm -(1963 5758) 39.3166 Tj -17.4613 -446.1868 Td -(0222 4972 5009 6768) 83.0018 Tj --6520.6 TJm -(fork 1854) 39.3166 Tj -17.4613 -455.6801 Td -(6829 6830 6926 6927) 83.0018 Tj --8527.14 TJm -(0303 1854 2910 6760) 83.0018 Tj -0 -465.1735 Td -(execcmd 6869 7053) 74.2647 Tj --11537 TJm -(6823 6825 7043 7045) 83.0018 Tj -17.4613 -474.6665 Td -(6869 6910 6923 7053) 83.0018 Tj --6520.6 TJm -(fork1 7039) 43.6851 Tj -17.4613 -484.1598 Td -(7055 7321 7327 7328) 83.0018 Tj --8527.14 TJm -(6900 6942 6954 6961) 83.0018 Tj -17.4613 -493.6532 Td -(7356 7366) 39.3166 Tj --13543.8 TJm -(6976 7024 7039) 61.1592 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 4) 187.8461 Tj -0 -28.4801 Td -(forkret 1984) 52.4222 Tj --14045.3 TJm -(3317 3391) 39.3166 Tj -17.4613 -37.9735 Td -(1616 1790 1984) 61.1592 Tj --9028.94 TJm -(IDE_CMD_WRITE 3318) 78.6333 Tj -0 -47.4664 Td -(gatedesc 0801) 56.7907 Tj --13543.7 TJm -(3318 3388) 39.3166 Tj -17.4613 -56.9598 Td -(0464 0467 0801 2560) 83.0018 Tj --6520.6 TJm -(IDE_DF 3314) 48.0537 Tj -0 -66.4531 Td -(getcallerpcs 1426) 74.2647 Tj --11537 TJm -(3314 3338) 39.3166 Tj -17.4613 -75.9465 Td -(0322 1387 1426 1678) 83.0018 Tj --6520.6 TJm -(IDE_DRDY 3313) 56.7907 Tj -17.4613 -85.4399 Td -(6411) 17.4741 Tj --16052.1 TJm -(3313 3336) 39.3166 Tj -0 -94.9332 Td -(getcmd 6984) 48.0537 Tj --12540.5 TJm -(IDE_ERR 3315) 52.4222 Tj -17.4613 -104.4266 Td -(6984 7015) 39.3166 Tj --13543.8 TJm -(3315 3338) 39.3166 Tj -0 -113.9199 Td -(gettoken 7156) 56.7907 Tj --11537.1 TJm -(idtinit 2578) 52.4222 Tj -17.4613 -123.4133 Td -(7156 7241 7245 7257) 83.0018 Tj --8527.14 TJm -(0351 1259 2578) 61.1592 Tj -17.4613 -132.9067 Td -(7270 7271 7307 7311) 83.0018 Tj --6520.6 TJm -(idup 3888) 39.3166 Tj -17.4613 -142.4 Td -(7333) 17.4741 Tj --16052.1 TJm -(0237 1881 3888 4361) 83.0018 Tj -0 -151.8934 Td -(growproc 1834) 56.7907 Tj --11537.1 TJm -(iget 3853) 39.3166 Tj -17.4613 -161.3867 Td -(0304 1834 2959) 61.1592 Tj --11035.5 TJm -(3794 3818 3853 3873) 83.0018 Tj -0 -170.8801 Td -(havedisk1 3327) 61.1592 Tj --13042 TJm -(4234 4359) 39.3166 Tj -17.4613 -180.3735 Td -(3327 3364 3462) 61.1592 Tj --9028.94 TJm -(iinit 3789) 43.6851 Tj -0 -189.8664 Td -(holding 1444) 52.4222 Tj --14045.3 TJm -(0238 1229 3789) 61.1592 Tj -17.4613 -199.3598 Td -(0323 1376 1404 1444) 83.0018 Tj --6520.6 TJm -(ilock 3902) 43.6851 Tj -17.4613 -208.8532 Td -(1957) 17.4741 Tj --16052.1 TJm -(0239 3902 3908 3928) 83.0018 Tj -0 -218.3465 Td -(ialloc 3802) 48.0537 Tj --14547 TJm -(4364 4479 4511 4531) 83.0018 Tj -17.4613 -227.8399 Td -(0236 3802 3822 4820) 83.0018 Tj --8527.14 TJm -(4672 4683 4693 4762) 83.0018 Tj -17.4613 -237.3332 Td -(4821) 17.4741 Tj --16052.1 TJm -(4774 4809 4813 4823) 83.0018 Tj -0 -246.8266 Td -(IBLOCK 3185) 48.0537 Tj --14547 TJm -(4867 4937 5023 6563) 83.0018 Tj -17.4613 -256.32 Td -(3185 3811 3832 3917) 83.0018 Tj --8527.14 TJm -(6583 6610) 39.3166 Tj -0 -265.8133 Td -(ICRHI 5674) 43.6851 Tj --13042.1 TJm -(inb 0403) 34.9481 Tj -17.4613 -275.3067 Td -(5674 5737 5807 5819) 83.0018 Tj --8527.14 TJm -(0403 0928 0936 1154) 83.0018 Tj -0 -284.8 Td -(ICRLO 5667) 43.6851 Tj --15048.7 TJm -(3336 3363 5647 6264) 83.0018 Tj -17.4613 -294.2934 Td -(5667 5738 5739 5808) 83.0018 Tj --8527.14 TJm -(6267 6461 6463) 61.1592 Tj -17.4613 -303.7868 Td -(5810 5820) 39.3166 Tj --11537.3 TJm -(initlock 1361) 56.7907 Tj -0 -313.2801 Td -(ID 5660) 30.5796 Tj -174.613 -313.2801 Td -(0324 1361 1622 2283) 83.0018 Tj -17.461 -322.7735 Td -(5660 5693 5766) 61.1592 Tj --11035.5 TJm -(2574 3355 3543 3791) 83.0018 Tj --0.0003 -332.2664 Td -(ideinit 3351) 52.4222 Tj --14045.3 TJm -(4416 5185 6618 6619) 83.0018 Tj -17.461 -341.7598 Td -(0251 1230 3351) 61.1592 Tj --9028.94 TJm -(inode 3263) 43.6851 Tj --0.0003 -351.2532 Td -(ideintr 3402) 52.4222 Tj --14045.3 TJm -(0203 0234 0235 0236) 83.0018 Tj -17.461 -360.7465 Td -(0252 2624 3402) 61.1592 Tj --11035.5 TJm -(0237 0239 0240 0241) 83.0018 Tj --0.0003 -370.2399 Td -(idelock 3324) 52.4222 Tj --14045.3 TJm -(0242 0243 0245 0246) 83.0018 Tj -17.461 -379.7332 Td -(3324 3355 3407 3409) 83.0018 Tj --8527.14 TJm -(0247 0248 0249 1541) 83.0018 Tj -17.461 -389.2266 Td -(3428 3465 3480 3482) 83.0018 Tj --8527.14 TJm -(3256 3263 3284 3285) 83.0018 Tj --0.0003 -398.72 Td -(iderw 3454) 43.6851 Tj --15048.7 TJm -(3674 3785 3794 3801) 83.0018 Tj -17.461 -408.2133 Td -(0253 3454 3459 3461) 83.0018 Tj --8527.14 TJm -(3827 3852 3855 3861) 83.0018 Tj -17.461 -417.7067 Td -(3608 3619) 39.3166 Tj --13543.8 TJm -(3887 3888 3902 3934) 83.0018 Tj --0.0003 -427.2 Td -(idestart 3375) 56.7907 Tj --13543.7 TJm -(3952 3974 4010 4054) 83.0018 Tj -17.461 -436.6934 Td -(3328 3375 3378 3426) 83.0018 Tj --8527.14 TJm -(4085 4102 4152 4211) 83.0018 Tj -17.461 -446.1868 Td -(3475) 17.4741 Tj --16052.1 TJm -(4212 4252 4256 4353) 83.0018 Tj --0.0003 -455.6801 Td -(idewait 3332) 52.4222 Tj --14045.3 TJm -(4356 4388 4395 4666) 83.0018 Tj -17.461 -465.1735 Td -(3332 3358 3380 3416) 83.0018 Tj --8527.14 TJm -(4702 4753 4800 4804) 83.0018 Tj --0.0003 -474.6665 Td -(IDE_BSY 3312) 52.4222 Tj --14045.3 TJm -(4856 4904 4915 4933) 83.0018 Tj -17.461 -484.1598 Td -(3312 3336) 39.3166 Tj --13543.8 TJm -(5015 6551 6601) 61.1592 Tj --0.0003 -493.6532 Td -(IDE_CMD_READ 3317) 74.2647 Tj --9530.47 TJm -(INPUT_BUF 6500) 61.1592 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 4 4 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 5) 187.8461 Tj -17.4613 -28.4801 Td -(6500 6503 6524 6536) 83.0018 Tj --8527.14 TJm -(2432 2627 6625 6626) 83.0018 Tj -17.4613 -37.9735 Td -(6537 6539 6568) 61.1592 Tj --9028.94 TJm -(IRQ_SLAVE 5960) 61.1592 Tj -0 -47.4664 Td -(insl 0412) 39.3166 Tj --15550.3 TJm -(5960 5964 6002 6017) 83.0018 Tj -17.4613 -56.9598 Td -(0412 0414 1173 3417) 83.0018 Tj --6520.6 TJm -(IRQ_SPURIOUS 2436) 74.2647 Tj -0 -66.4531 Td -(INT_DISABLED 5869) 74.2647 Tj --11537 TJm -(2436 2636 5707) 61.1592 Tj -17.4613 -75.9465 Td -(5869 5917) 39.3166 Tj --11537.3 TJm -(IRQ_TIMER 2431) 61.1592 Tj -0 -85.4399 Td -(IOAPIC 5858) 48.0537 Tj --14547 TJm -(2431 2614 2671 5714) 83.0018 Tj -17.4613 -94.9332 Td -(5858 5908) 39.3166 Tj --13543.8 TJm -(6680) 17.4741 Tj -0 -104.4266 Td -(ioapic 5877) 48.0537 Tj --12540.5 TJm -(isdirempty 4702) 65.5277 Tj -17.4613 -113.9199 Td -(5607 5629 5630 5874) 83.0018 Tj --8527.14 TJm -(4702 4709 4778) 61.1592 Tj -17.4613 -123.4133 Td -(5877 5886 5887 5893) 83.0018 Tj --6520.6 TJm -(ismp 5514) 39.3166 Tj -17.4613 -132.9067 Td -(5894 5908) 39.3166 Tj --13543.8 TJm -(0277 1231 5514 5612) 83.0018 Tj -0 -142.4 Td -(ioapicenable 5923) 74.2647 Tj --11537 TJm -(5905 5925) 39.3166 Tj -17.4613 -151.8934 Td -(0256 3357 5923 6626) 83.0018 Tj --6520.6 TJm -(itrunc 4054) 48.0537 Tj -0 -161.3867 Td -(ioapicid 5516) 56.7907 Tj --13543.7 TJm -(3674 3961 4054) 61.1592 Tj -17.4613 -170.8801 Td -(0257 5516 5630 5911) 83.0018 Tj --6520.6 TJm -(iunlock 3934) 52.4222 Tj -17.4613 -180.3735 Td -(5912) 17.4741 Tj --16052.1 TJm -(0241 3934 3937 3976) 83.0018 Tj -0 -189.8664 Td -(ioapicinit 5901) 65.5277 Tj --12540.3 TJm -(4371 4481 4514 4534) 83.0018 Tj -17.4613 -199.3598 Td -(0258 1218 5901 5912) 83.0018 Tj --8527.14 TJm -(4679 4880 4942 6556) 83.0018 Tj -0 -208.8532 Td -(ioapicread 5884) 65.5277 Tj --12540.3 TJm -(6605) 17.4741 Tj -17.4613 -218.3465 Td -(5884 5909 5910) 61.1592 Tj --9028.94 TJm -(iunlockput 3974) 65.5277 Tj -0 -227.8399 Td -(ioapicwrite 5891) 69.8962 Tj --12038.7 TJm -(0242 3974 4366 4375) 83.0018 Tj -17.4613 -237.3332 Td -(5891 5917 5918 5931) 83.0018 Tj --8527.14 TJm -(4378 4674 4685 4688) 83.0018 Tj -17.4613 -246.8266 Td -(5932) 17.4741 Tj --16052.1 TJm -(4696 4766 4771 4779) 83.0018 Tj -0 -256.32 Td -(IO_PIC1 5957) 52.4222 Tj --14045.3 TJm -(4780 4791 4795 4812) 83.0018 Tj -17.4613 -265.8133 Td -(5957 5970 5985 5994) 83.0018 Tj --8527.14 TJm -(4816 4840 4869 4877) 83.0018 Tj -17.4613 -275.3067 Td -(5997 6002 6012 6026) 83.0018 Tj --8527.14 TJm -(4908 4925 4939 5077) 83.0018 Tj -17.4613 -284.8 Td -(6027) 17.4741 Tj --16052.1 TJm -(5118) 17.4741 Tj -0 -294.2934 Td -(IO_PIC2 5958) 52.4222 Tj --12038.8 TJm -(iupdate 3827) 52.4222 Tj -17.4613 -303.7868 Td -(5958 5971 5986 6015) 83.0018 Tj --8527.14 TJm -(0243 3827 3963 4080) 83.0018 Tj -17.4613 -313.2801 Td -(6016 6017 6020 6029) 83.0018 Tj --8527.14 TJm -(4178 4678 4695 4789) 83.0018 Tj -17.4613 -322.7735 Td -(6030) 17.4741 Tj --16052.1 TJm -(4794 4827 4831) 61.1592 Tj -0 -332.2664 Td -(IO_RTC 5786) 48.0537 Tj --12540.5 TJm -(I_BUSY 3277) 48.0537 Tj -17.4613 -341.7598 Td -(5786 5799 5800) 61.1592 Tj --11035.5 TJm -(3277 3911 3913 3936) 83.0018 Tj -0 -351.2532 Td -(IO_TIMER1 6659) 61.1592 Tj --13042 TJm -(3940 3957 3959) 61.1592 Tj -17.4613 -360.7465 Td -(6659 6668 6678 6679) 83.0018 Tj --6520.6 TJm -(I_VALID 3278) 52.4222 Tj -0 -370.2399 Td -(IPB 3182) 34.9481 Tj --16052 TJm -(3278 3916 3926 3955) 83.0018 Tj -17.4613 -379.7332 Td -(3182 3185 3191 3812) 83.0018 Tj --6520.6 TJm -(kalloc 2354) 48.0537 Tj -17.4613 -389.2266 Td -(3833 3918) 39.3166 Tj --13543.8 TJm -(0261 1283 1772 1812) 83.0018 Tj -0 -398.72 Td -(iput 3952) 39.3166 Tj --15550.3 TJm -(1838 1865 2354 2360) 83.0018 Tj -17.4613 -408.2133 Td -(0240 2120 3952 3958) 83.0018 Tj --8527.14 TJm -(2375 5058 5179) 61.1592 Tj -17.4613 -417.7067 Td -(3977 4260 4382 4471) 83.0018 Tj --6520.6 TJm -(KBDATAP 6104) 52.4222 Tj -17.4613 -427.2 Td -(4689 4943) 39.3166 Tj --13543.8 TJm -(6104 6267) 39.3166 Tj -0 -436.6934 Td -(IRQ_COM1 2433) 56.7907 Tj --11537.1 TJm -(kbdgetc 6256) 52.4222 Tj -17.4613 -446.1868 Td -(2433 2631) 39.3166 Tj --13543.8 TJm -(6256 6298) 39.3166 Tj -0 -455.6801 Td -(IRQ_ERROR 2435) 61.1592 Tj --11035.5 TJm -(kbdintr 6296) 52.4222 Tj -17.4613 -465.1735 Td -(2435 5727) 39.3166 Tj --13543.8 TJm -(0266 2628 6296) 61.1592 Tj -0 -474.6665 Td -(IRQ_IDE 2434) 52.4222 Tj --12038.8 TJm -(KBSTATP 6102) 52.4222 Tj -17.4613 -484.1598 Td -(2434 2623 3356 3357) 83.0018 Tj --8527.14 TJm -(6102 6264) 39.3166 Tj -0 -493.6532 Td -(IRQ_KBD 2432) 52.4222 Tj --12038.8 TJm -(KBS_DIB 6103) 52.4222 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 6) 187.8461 Tj -17.4613 -28.4801 Td -(6103 6265) 39.3166 Tj --13543.8 TJm -(0453 0461 0954 1054) 83.0018 Tj -0 -37.9735 Td -(KEY_DEL 6128) 52.4222 Tj --14045.3 TJm -(1711) 17.4741 Tj -17.4613 -47.4664 Td -(6128 6169 6191 6215) 83.0018 Tj --6520.6 TJm -(lidt 0467) 39.3166 Tj -0 -56.9598 Td -(KEY_DN 6122) 48.0537 Tj --14547 TJm -(0467 0475 2580) 61.1592 Tj -17.4613 -66.4531 Td -(6122 6165 6187 6211) 83.0018 Tj --6520.6 TJm -(LINT0 5679) 43.6851 Tj -0 -75.9465 Td -(KEY_END 6120) 52.4222 Tj --14045.3 TJm -(5679 5718) 39.3166 Tj -17.4613 -85.4399 Td -(6120 6168 6190 6214) 83.0018 Tj --6520.6 TJm -(LINT1 5680) 43.6851 Tj -0 -94.9332 Td -(KEY_HOME 6119) 56.7907 Tj --13543.7 TJm -(5680 5719) 39.3166 Tj -17.4613 -104.4266 Td -(6119 6168 6190 6214) 83.0018 Tj --6520.6 TJm -(LIST 6860) 39.3166 Tj -0 -113.9199 Td -(KEY_INS 6127) 52.4222 Tj --14045.3 TJm -(6860 6940 7107 7383) 83.0018 Tj -17.4613 -123.4133 Td -(6127 6169 6191 6215) 83.0018 Tj --6520.6 TJm -(listcmd 6890 7101) 74.2647 Tj -0 -132.9067 Td -(KEY_LF 6123) 48.0537 Tj --14547 TJm -(6890 6911 6941 7101) 83.0018 Tj -17.4613 -142.4 Td -(6123 6167 6189 6213) 83.0018 Tj --8527.14 TJm -(7103 7246 7357 7384) 83.0018 Tj -0 -151.8934 Td -(KEY_PGDN 6126) 56.7907 Tj --11537.1 TJm -(loadgs 0514) 48.0537 Tj -17.4613 -161.3867 Td -(6126 6166 6188 6212) 83.0018 Tj --8527.14 TJm -(0514 1712) 39.3166 Tj -0 -170.8801 Td -(KEY_PGUP 6125) 56.7907 Tj --11537.1 TJm -(ltr 0479) 34.9481 Tj -17.4613 -180.3735 Td -(6125 6166 6188 6212) 83.0018 Tj --8527.14 TJm -(0479 0481 1730) 61.1592 Tj -0 -189.8664 Td -(KEY_RT 6124) 48.0537 Tj --12540.5 TJm -(MAXARGS 6863) 52.4222 Tj -17.4613 -199.3598 Td -(6124 6167 6189 6213) 83.0018 Tj --8527.14 TJm -(6863 6871 6872 7340) 83.0018 Tj -0 -208.8532 Td -(KEY_UP 6121) 48.0537 Tj --12540.5 TJm -(MAXFILE 3169) 52.4222 Tj -17.4613 -218.3465 Td -(6121 6165 6187 6211) 83.0018 Tj --8527.14 TJm -(3169 4165 4166) 61.1592 Tj -0 -227.8399 Td -(kfree 2305) 43.6851 Tj --13042.1 TJm -(memcmp 5311) 48.0537 Tj -17.4613 -237.3332 Td -(0262 1843 1866 2169) 83.0018 Tj --8527.14 TJm -(0330 5311 5543 5588) 83.0018 Tj -17.4613 -246.8266 Td -(2170 2287 2305 2310) 83.0018 Tj --6520.6 TJm -(memmove 5327) 52.4222 Tj -17.4613 -256.32 Td -(5107 5117 5202 5223) 83.0018 Tj --8527.14 TJm -(0331 1276 1814 1841) 83.0018 Tj -0 -265.8133 Td -(kill 2075) 39.3166 Tj --15550.3 TJm -(1871 3683 3839 3924) 83.0018 Tj -17.4613 -275.3067 Td -(0305 2075 2658 2933) 83.0018 Tj --8527.14 TJm -(4121 4171 4329 4331) 83.0018 Tj -17.4613 -284.8 Td -(6767) 17.4741 Tj --16052.1 TJm -(5088 5327 6474) 61.1592 Tj -0 -294.2934 Td -(kinit 2277) 43.6851 Tj --13042.1 TJm -(memset 5304) 48.0537 Tj -17.4613 -303.7868 Td -(0263 1224 2277) 61.1592 Tj --11035.5 TJm -(0332 1789 1813 1816) 83.0018 Tj -0 -313.2801 Td -(ksegment 1703) 56.7907 Tj --13543.7 TJm -(1842 2313 3694 3814) 83.0018 Tj -17.4613 -322.7735 Td -(0309 1216 1257 1703) 83.0018 Tj --8527.14 TJm -(4784 4959 5061 5075) 83.0018 Tj -0 -332.2664 Td -(KSTACKSIZE 0152) 65.5277 Tj --12540.3 TJm -(5304 6476 6987 7058) 83.0018 Tj -17.4613 -341.7598 Td -(0152 1283 1284 1729) 83.0018 Tj --8527.14 TJm -(7069 7085 7106 7119) 83.0018 Tj -17.4613 -351.2532 Td -(1772 1776 1866 2170) 83.0018 Tj --6520.6 TJm -(microdelay 5781) 65.5277 Tj -0 -360.7465 Td -(lapiceoi 5772) 56.7907 Tj --13543.7 TJm -(0274 5781 5809 5811) 83.0018 Tj -17.4613 -370.2399 Td -(0271 2621 2625 2629) 83.0018 Tj --8527.14 TJm -(5821) 17.4741 Tj -17.4613 -379.7332 Td -(2633 2639 5772) 61.1592 Tj --9028.94 TJm -(min 3673) 34.9481 Tj -0 -389.2266 Td -(lapicinit 5701) 61.1592 Tj --13042 TJm -(3673 4120 4170) 61.1592 Tj -17.4613 -398.72 Td -(0272 1215 1256 5701) 83.0018 Tj --6520.6 TJm -(mp 5402) 30.5796 Tj -0 -408.2133 Td -(lapicstartap 5791) 74.2647 Tj --11537 TJm -(5402 5507 5536 5542) 83.0018 Tj -17.4613 -417.7067 Td -(0273 1286 5791) 61.1592 Tj --11035.5 TJm -(5543 5544 5555 5560) 83.0018 Tj -0 -427.2 Td -(lapicw 5690) 48.0537 Tj --14547 TJm -(5564 5565 5568 5569) 83.0018 Tj -17.4613 -436.6934 Td -(5690 5707 5713 5714) 83.0018 Tj --8527.14 TJm -(5580 5583 5585 5587) 83.0018 Tj -17.4613 -446.1868 Td -(5715 5718 5719 5724) 83.0018 Tj --8527.14 TJm -(5594 5604 5610 5643) 83.0018 Tj -17.4613 -455.6801 Td -(5727 5730 5731 5734) 83.0018 Tj --6520.6 TJm -(mpbcpu 5519) 48.0537 Tj -17.4613 -465.1735 Td -(5737 5738 5743 5775) 83.0018 Tj --8527.14 TJm -(0278 1215 1255 5519) 83.0018 Tj -17.4613 -474.6668 Td -(5807 5808 5810 5819) 83.0018 Tj --6520.6 TJm -(MPBUS 5452) 43.6851 Tj -17.4613 -484.1602 Td -(5820) 17.4741 Tj --16052.1 TJm -(5452 5633) 39.3166 Tj -0 -493.6536 Td -(lgdt 0453) 39.3166 Tj --13543.8 TJm -(mpconf 5413) 48.0537 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 5 5 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 7) 187.8461 Tj -17.4613 -28.4801 Td -(5413 5579 5582 5587) 83.0018 Tj --8527.14 TJm -(4076) 17.4741 Tj -17.4613 -37.9735 Td -(5605) 17.4741 Tj --14045.6 TJm -(NELEM 0362) 43.6851 Tj -0 -47.4664 Td -(mpconfig 5580) 56.7907 Tj --13543.7 TJm -(0362 1672 2879 4961) 83.0018 Tj -17.4613 -56.9598 Td -(5580 5610) 39.3166 Tj --11537.3 TJm -(nextpid 1615) 52.4222 Tj -0 -66.4531 Td -(mpinit 5601) 48.0537 Tj --14547 TJm -(1615 1768) 39.3166 Tj -17.4613 -75.9465 Td -(0279 1214 5601 5619) 83.0018 Tj --6520.6 TJm -(NFILE 0155) 43.6851 Tj -17.4613 -85.4399 Td -(5620 5639 5640) 61.1592 Tj --11035.5 TJm -(0155 4410 4426) 61.1592 Tj -0 -94.9332 Td -(MPIOAPIC 5453) 56.7907 Tj --11537.1 TJm -(NINDIRECT 3168) 61.1592 Tj -17.4613 -104.4266 Td -(5453 5628) 39.3166 Tj --13543.8 TJm -(3168 3169 4022 4070) 83.0018 Tj -0 -113.9199 Td -(mpioapic 5439) 56.7907 Tj --11537.1 TJm -(NINODE 0157) 48.0537 Tj -17.4613 -123.4133 Td -(5439 5607 5629 5631) 83.0018 Tj --8527.14 TJm -(0157 3785 3861) 61.1592 Tj -0 -132.9067 Td -(MPIOINTR 5454) 56.7907 Tj --11537.1 TJm -(NO 6106) 30.5796 Tj -17.4613 -142.4 Td -(5454 5634) 39.3166 Tj --13543.8 TJm -(6106 6152 6155 6157) 83.0018 Tj -0 -151.8934 Td -(MPLINTR 5455) 52.4222 Tj --14045.3 TJm -(6158 6159 6160 6162) 83.0018 Tj -17.4613 -161.3867 Td -(5455 5635) 39.3166 Tj --13543.8 TJm -(6174 6177 6179 6180) 83.0018 Tj -0 -170.8801 Td -(mpmain 1253) 48.0537 Tj --14547 TJm -(6181 6182 6184 6202) 83.0018 Tj -17.4613 -180.3735 Td -(1208 1237 1253 1258) 83.0018 Tj --8527.14 TJm -(6203 6205 6206 6207) 83.0018 Tj -17.4613 -189.8668 Td -(1285) 17.4741 Tj --16052.1 TJm -(6208) 17.4741 Tj -0 -199.3602 Td -(MPPROC 5451) 48.0537 Tj --12540.5 TJm -(NOFILE 0154) 48.0537 Tj -17.4613 -208.8535 Td -(5451 5616) 39.3166 Tj --13543.8 TJm -(0154 1540 1878 2113) 83.0018 Tj -0 -218.3469 Td -(mpproc 5428) 48.0537 Tj --14547 TJm -(4570 4586) 39.3166 Tj -17.4613 -227.8403 Td -(5428 5606 5617 5626) 83.0018 Tj --6520.6 TJm -(NPROC 0150) 43.6851 Tj -0 -237.3336 Td -(mpsearch 5556) 56.7907 Tj --13543.7 TJm -(0150 1610 1669 1760) 83.0018 Tj -17.4613 -246.827 Td -(5556 5585) 39.3166 Tj --13543.8 TJm -(1918 2057 2080 2129) 83.0018 Tj -0 -256.3203 Td -(mpsearch1 5537) 61.1592 Tj --13042 TJm -(2162) 17.4741 Tj -17.4613 -265.8137 Td -(5537 5564 5568 5571) 83.0018 Tj --6520.6 TJm -(NSEGS 1508) 43.6851 Tj -0 -275.3071 Td -(namecmp 4203) 52.4222 Tj --14045.3 TJm -(1508 1561) 39.3166 Tj -17.4613 -284.8004 Td -(0244 4203 4228 4765) 83.0018 Tj --6520.6 TJm -(nulterminate 7352) 74.2647 Tj -0 -294.2938 Td -(namei 4389) 43.6851 Tj --15048.7 TJm -(7215 7230 7352 7373) 83.0018 Tj -17.4613 -303.7871 Td -(0245 1826 4389 4670) 83.0018 Tj --8527.14 TJm -(7379 7380 7385 7386) 83.0018 Tj -17.4613 -313.2805 Td -(4865 4935 5021) 61.1592 Tj --11035.5 TJm -(7391) 17.4741 Tj -0 -322.7739 Td -(nameiparent 4396) 69.8962 Tj --10032.1 TJm -(NUMLOCK 6113) 52.4222 Tj -17.4613 -332.2668 Td -(0246 4354 4369 4381) 83.0018 Tj --8527.14 TJm -(6113 6146) 39.3166 Tj -17.4613 -341.7602 Td -(4396 4681 4760 4807) 83.0018 Tj --6520.6 TJm -(outb 0421) 39.3166 Tj -0 -351.2536 Td -(namex 4354) 43.6851 Tj --15048.7 TJm -(0421 0933 0941 1164) 83.0018 Tj -17.4613 -360.7469 Td -(4354 4392 4398) 61.1592 Tj --11035.5 TJm -(1165 1166 1167 1168) 83.0018 Tj -0 -370.2403 Td -(NBUF 0156) 39.3166 Tj --15550.3 TJm -(1169 3361 3370 3381) 83.0018 Tj -17.4613 -379.7336 Td -(0156 3531 3553) 61.1592 Tj --11035.5 TJm -(3382 3383 3384 3385) 83.0018 Tj -0 -389.227 Td -(NCPU 0153) 39.3166 Tj --15550.3 TJm -(3386 3388 3391 5646) 83.0018 Tj -17.4613 -398.7204 Td -(0153 1571 5512) 61.1592 Tj --11035.5 TJm -(5647 5799 5800 5970) 83.0018 Tj -0 -408.2137 Td -(ncpu 5515) 39.3166 Tj --15550.3 TJm -(5971 5985 5986 5994) 83.0018 Tj -17.4613 -417.7071 Td -(1222 1278 1572 3357) 83.0018 Tj --8527.14 TJm -(5997 6002 6012 6015) 83.0018 Tj -17.4613 -427.2004 Td -(5515 5618 5619 5623) 83.0018 Tj --8527.14 TJm -(6016 6017 6020 6026) 83.0018 Tj -17.4613 -436.6938 Td -(5624 5625) 39.3166 Tj --13543.8 TJm -(6027 6029 6030 6460) 83.0018 Tj -0 -446.1872 Td -(NDEV 0158) 39.3166 Tj --15550.3 TJm -(6462 6479 6480 6481) 83.0018 Tj -17.4613 -455.6805 Td -(0158 4108 4158 4407) 83.0018 Tj --8527.14 TJm -(6482 6677 6678 6679) 83.0018 Tj -0 -465.1739 Td -(NDIRECT 3167) 52.4222 Tj --12038.8 TJm -(outsl 0433) 43.6851 Tj -17.4613 -474.6668 Td -(3167 3169 3178 3274) 83.0018 Tj --8527.14 TJm -(0433 0435 3389) 61.1592 Tj -17.4613 -484.1602 Td -(4015 4020 4024 4025) 83.0018 Tj --6520.6 TJm -(outw 0427) 39.3166 Tj -17.4613 -493.6536 Td -(4060 4067 4068 4075) 83.0018 Tj --8527.14 TJm -(0427 0982 0984 1082) 83.0018 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 8) 187.8461 Tj -17.4613 -28.4801 Td -(1084) 17.4741 Tj --16052.1 TJm -(7201 7225 7240 7244) 83.0018 Tj -0 -37.9735 Td -(O_CREATE 3053) 56.7907 Tj --13543.7 TJm -(7256 7269 7305 7309) 83.0018 Tj -17.4613 -47.4664 Td -(3053 4861 7278 7281) 83.0018 Tj --8527.14 TJm -(7324 7332) 39.3166 Tj -0 -56.9598 Td -(O_RDONLY 3050) 56.7907 Tj --11537.1 TJm -(picenable 5975) 61.1592 Tj -17.4613 -66.4531 Td -(3050 4868 7275) 61.1592 Tj --11035.5 TJm -(0283 3356 5975 6625) 83.0018 Tj -0 -75.9465 Td -(O_RDWR 3052) 48.0537 Tj --14547 TJm -(6680) 17.4741 Tj -17.4613 -85.4399 Td -(3052 4886 6814 6816) 83.0018 Tj --6520.6 TJm -(picinit 5982) 52.4222 Tj -17.4613 -94.9332 Td -(7007) 17.4741 Tj --16052.1 TJm -(0284 1217 5982) 61.1592 Tj -0 -104.4266 Td -(O_WRONLY 3051) 56.7907 Tj --11537.1 TJm -(picsetmask 5967) 65.5277 Tj -17.4613 -113.9199 Td -(3051 4885 4886 7278) 83.0018 Tj --8527.14 TJm -(5967 5977 6033) 61.1592 Tj -17.4613 -123.4133 Td -(7281) 17.4741 Tj --14045.6 TJm -(pinit 1620) 43.6851 Tj -0 -132.9067 Td -(PAGE 0151) 39.3166 Tj --15550.3 TJm -(0306 1225 1620) 61.1592 Tj -17.4613 -142.4 Td -(0151 0152 1811 2284) 83.0018 Tj --6520.6 TJm -(PIPE 6859) 39.3166 Tj -17.4613 -151.8934 Td -(2285 2309 2359 5054) 83.0018 Tj --8527.14 TJm -(6859 6950 7086 7377) 83.0018 Tj -17.4613 -161.3867 Td -(5057 5179 5202 5223) 83.0018 Tj --6520.6 TJm -(pipe 5161) 39.3166 Tj -0 -170.8801 Td -(panic 6401 7032) 65.5277 Tj --12540.3 TJm -(0204 0288 0289 0290) 83.0018 Tj -17.4613 -180.3735 Td -(0219 1377 1405 1469) 83.0018 Tj --8527.14 TJm -(3255 4469 4509 4529) 83.0018 Tj -17.4613 -189.8668 Td -(1471 1958 1960 1962) 83.0018 Tj --8527.14 TJm -(5161 5173 5179 5185) 83.0018 Tj -17.4613 -199.3602 Td -(1964 2006 2009 2110) 83.0018 Tj --8527.14 TJm -(5189 5193 5211 5230) 83.0018 Tj -17.4613 -208.8535 Td -(2140 2310 2321 2360) 83.0018 Tj --8527.14 TJm -(5251 6763 6952 6953) 83.0018 Tj -17.4613 -218.3469 Td -(2655 3378 3459 3461) 83.0018 Tj --6520.6 TJm -(pipealloc 5171) 61.1592 Tj -17.4613 -227.8403 Td -(3463 3596 3617 3627) 83.0018 Tj --8527.14 TJm -(0287 4984 5171) 61.1592 Tj -17.4613 -237.3336 Td -(3725 3743 3822 3873) 83.0018 Tj --6520.6 TJm -(pipeclose 5211) 61.1592 Tj -17.4613 -246.827 Td -(3908 3928 3937 3958) 83.0018 Tj --8527.14 TJm -(0288 4469 5211) 61.1592 Tj -17.4613 -256.3203 Td -(4036 4219 4267 4275) 83.0018 Tj --6520.6 TJm -(pipecmd 6884 7080) 74.2647 Tj -17.4613 -265.8137 Td -(4443 4458 4517 4537) 83.0018 Tj --8527.14 TJm -(6884 6912 6951 7080) 83.0018 Tj -17.4613 -275.3071 Td -(4709 4777 4786 4821) 83.0018 Tj --8527.14 TJm -(7082 7258 7358 7378) 83.0018 Tj -17.4613 -284.8004 Td -(4834 4838 5620 5640) 83.0018 Tj --6520.6 TJm -(piperead 5251) 56.7907 Tj -17.4613 -294.2938 Td -(6401 6408 6901 6920) 83.0018 Tj --8527.14 TJm -(0289 4509 5251) 61.1592 Tj -17.4613 -303.7871 Td -(6953 7032 7045 7228) 83.0018 Tj --6520.6 TJm -(PIPESIZE 5159) 56.7907 Tj -17.4613 -313.2805 Td -(7272 7306 7310 7336) 83.0018 Tj --8527.14 TJm -(5159 5163 5236 5244) 83.0018 Tj -17.4613 -322.7739 Td -(7341) 17.4741 Tj --16052.1 TJm -(5266) 17.4741 Tj -0 -332.2668 Td -(panicked 6317) 56.7907 Tj --11537.1 TJm -(pipewrite 5230) 61.1592 Tj -17.4613 -341.7602 Td -(6317 6414 6489) 61.1592 Tj --11035.5 TJm -(0290 4529 5230) 61.1592 Tj -0 -351.2536 Td -(parseblock 7301) 65.5277 Tj --10533.8 TJm -(popcli 1466) 48.0537 Tj -17.4613 -360.7469 Td -(7301 7306 7325) 61.1592 Tj --11035.5 TJm -(0327 1421 1466 1469) 83.0018 Tj -0 -370.2403 Td -(parsecmd 7218) 56.7907 Tj --13543.7 TJm -(1471 1731) 39.3166 Tj -17.4613 -379.7336 Td -(6902 7025 7218) 61.1592 Tj --9028.94 TJm -(printint 6325) 56.7907 Tj -0 -389.227 Td -(parseexec 7317) 61.1592 Tj --13042 TJm -(6325 6374 6378) 61.1592 Tj -17.4613 -398.7204 Td -(7214 7255 7317) 61.1592 Tj --9028.94 TJm -(proc 1529) 39.3166 Tj -0 -408.2137 Td -(parseline 7235) 61.1592 Tj --13042 TJm -(0205 0301 0342 0343) 83.0018 Tj -17.4613 -417.7071 Td -(7212 7224 7235 7246) 83.0018 Tj --8527.14 TJm -(1204 1357 1529 1535) 83.0018 Tj -17.4613 -427.2004 Td -(7308) 17.4741 Tj --16052.1 TJm -(1568 1583 1605 1610) 83.0018 Tj -0 -436.6938 Td -(parsepipe 7251) 61.1592 Tj --13042 TJm -(1613 1665 1669 1716) 83.0018 Tj -17.4613 -446.1872 Td -(7213 7239 7251 7258) 83.0018 Tj --8527.14 TJm -(1724 1725 1729 1753) 83.0018 Tj -0 -455.6805 Td -(parseredirs 7264) 69.8962 Tj --12038.7 TJm -(1756 1760 1804 1838) 83.0018 Tj -17.4613 -465.1739 Td -(7264 7312 7331 7342) 83.0018 Tj --8527.14 TJm -(1841 1842 1843 1844) 83.0018 Tj -0 -474.6668 Td -(PCINT 5678) 43.6851 Tj --15048.7 TJm -(1845 1857 1864 1871) 83.0018 Tj -17.4613 -484.1602 Td -(5678 5724) 39.3166 Tj --13543.8 TJm -(1872 1873 1879 1880) 83.0018 Tj -0 -493.6536 Td -(peek 7201) 39.3166 Tj --15550.3 TJm -(1881 1910 1918 1925) 83.0018 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 6 6 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 9) 187.8461 Tj -17.4613 -28.4801 Td -(1928 1932 1961 1967) 83.0018 Tj --8527.14 TJm -(5862 5917 5918 5931) 83.0018 Tj -17.4613 -37.9735 Td -(1976 2005 2023 2024) 83.0018 Tj --8527.14 TJm -(5932) 17.4741 Tj -17.4613 -47.4668 Td -(2028 2055 2057 2077) 83.0018 Tj --6520.6 TJm -(REG_VER 5861) 52.4222 Tj -17.4613 -56.9602 Td -(2080 2106 2109 2114) 83.0018 Tj --8527.14 TJm -(5861 5909) 39.3166 Tj -17.4613 -66.4535 Td -(2115 2116 2120 2121) 83.0018 Tj --6520.6 TJm -(release 1402) 52.4222 Tj -17.4613 -75.9469 Td -(2126 2129 2130 2138) 83.0018 Tj --8527.14 TJm -(0325 1402 1405 1763) 83.0018 Tj -17.4613 -85.4403 Td -(2155 2162 2163 2182) 83.0018 Tj --8527.14 TJm -(1769 1934 1978 1987) 83.0018 Tj -17.4613 -94.9336 Td -(2188 2554 2604 2606) 83.0018 Tj --8527.14 TJm -(2019 2032 2068 2086) 83.0018 Tj -17.4613 -104.427 Td -(2608 2651 2658 2659) 83.0018 Tj --8527.14 TJm -(2090 2176 2183 2343) 83.0018 Tj -17.4613 -113.9203 Td -(2660 2666 2671 2675) 83.0018 Tj --8527.14 TJm -(2369 2373 2619 2975) 83.0018 Tj -17.4613 -123.4137 Td -(2754 2766 2778 2796) 83.0018 Tj --8527.14 TJm -(2980 3409 3428 3482) 83.0018 Tj -17.4613 -132.9071 Td -(2810 2812 2826 2878) 83.0018 Tj --8527.14 TJm -(3578 3592 3641 3864) 83.0018 Tj -17.4613 -142.4004 Td -(2880 2883 2884 2905) 83.0018 Tj --8527.14 TJm -(3880 3892 3914 3942) 83.0018 Tj -17.4613 -151.8938 Td -(2939 2958 2974 3306) 83.0018 Tj --8527.14 TJm -(3960 3969 4429 4433) 83.0018 Tj -17.4613 -161.3871 Td -(3667 4361 4555 4570) 83.0018 Tj --8527.14 TJm -(4445 4460 4466 5222) 83.0018 Tj -17.4613 -170.8805 Td -(4587 4588 4646 4943) 83.0018 Tj --8527.14 TJm -(5225 5238 5247 5258) 83.0018 Tj -17.4613 -180.3739 Td -(4944 4963 4969 4989) 83.0018 Tj --8527.14 TJm -(5269 6398 6547 6562) 83.0018 Tj -17.4613 -189.8672 Td -(5003 5104 5107 5108) 83.0018 Tj --8527.14 TJm -(6582 6609) 39.3166 Tj -17.4613 -199.3606 Td -(5109 5110 5111 5154) 83.0018 Tj --6520.6 TJm -(ROOTDEV 0159) 52.4222 Tj -17.4613 -208.8539 Td -(5237 5257 5510 5606) 83.0018 Tj --8527.14 TJm -(0159 4359) 39.3166 Tj -17.4613 -218.3473 Td -(5617 5618 5619 5622) 83.0018 Tj --6520.6 TJm -(ROOTINO 3157) 52.4222 Tj -17.4613 -227.8407 Td -(6312 6561) 39.3166 Tj --13543.8 TJm -(3157 4359) 39.3166 Tj -0 -237.334 Td -(procdump 1654) 56.7907 Tj --11537.1 TJm -(run 2262) 34.9481 Tj -17.4613 -246.8274 Td -(0307 1654 6520) 61.1592 Tj --11035.5 TJm -(1661 2262 2263 2269) 83.0018 Tj -0 -256.3207 Td -(proghdr 0874) 52.4222 Tj --14045.3 TJm -(2307 2316 2317 2319) 83.0018 Tj -17.4613 -265.8141 Td -(0874 1119 1133 5016) 83.0018 Tj --8527.14 TJm -(2357) 17.4741 Tj -0 -275.3075 Td -(pushcli 1455) 52.4222 Tj --12038.8 TJm -(runcmd 6906) 48.0537 Tj -17.4613 -284.8008 Td -(0326 1375 1455 1723) 83.0018 Tj --8527.14 TJm -(6906 6920 6937 6943) 83.0018 Tj -0 -294.2942 Td -(readeflags 0485) 65.5277 Tj --12540.3 TJm -(6945 6959 6966 6977) 83.0018 Tj -17.4613 -303.7875 Td -(0485 1459 1468 1963) 83.0018 Tj --8527.14 TJm -(7025) 17.4741 Tj -17.4613 -313.2809 Td -(5758) 17.4741 Tj --14045.6 TJm -(RUNNING 1526) 52.4222 Tj -0 -322.7743 Td -(readi 4102) 43.6851 Tj --15048.7 TJm -(1526 1661 1927 1961) 83.0018 Tj -17.4613 -332.2672 Td -(0247 4102 4266 4512) 83.0018 Tj --8527.14 TJm -(2671) 17.4741 Tj -17.4613 -341.7606 Td -(4708 4709 5026 5034) 83.0018 Tj --6520.6 TJm -(safestrcpy 5375) 65.5277 Tj -17.4613 -351.2539 Td -(5065 5073) 39.3166 Tj --13543.8 TJm -(0333 1825 5104 5375) 83.0018 Tj -0 -360.7473 Td -(readsb 3678) 48.0537 Tj --12540.5 TJm -(sched 1953) 43.6851 Tj -17.4613 -370.2407 Td -(3678 3711 3738 3809) 83.0018 Tj --8527.14 TJm -(1953 1958 1960 1962) 83.0018 Tj -0 -379.734 Td -(readsect 1160) 56.7907 Tj --13543.7 TJm -(1964 1977 2025 2139) 83.0018 Tj -17.4613 -389.2274 Td -(1160 1195) 39.3166 Tj --11537.3 TJm -(scheduler 1908) 61.1592 Tj -0 -398.7207 Td -(readseg 1179) 52.4222 Tj --14045.3 TJm -(0308 1263 1559 1908) 83.0018 Tj -17.4613 -408.2141 Td -(1113 1126 1137 1179) 83.0018 Tj --8527.14 TJm -(1928 1967) 39.3166 Tj -0 -417.7075 Td -(REDIR 6858) 43.6851 Tj --13042.1 TJm -(SCROLLLOCK 6114) 65.5277 Tj -17.4613 -427.2008 Td -(6858 6930 7070 7371) 83.0018 Tj --8527.14 TJm -(6114 6147) 39.3166 Tj -0 -436.6942 Td -(redircmd 6875 7064) 78.6333 Tj --9028.81 TJm -(SECTSIZE 1111) 56.7907 Tj -17.4613 -446.1875 Td -(6875 6913 6931 7064) 83.0018 Tj --8527.14 TJm -(1111 1173 1186 1189) 83.0018 Tj -17.4613 -455.6809 Td -(7066 7275 7278 7281) 83.0018 Tj --8527.14 TJm -(1194) 17.4741 Tj -17.4613 -465.1743 Td -(7359 7372) 39.3166 Tj --11537.3 TJm -(SEG 0701) 34.9481 Tj -0 -474.6672 Td -(REG_ID 5860) 48.0537 Tj --14547 TJm -(0701 1708 1709 1710) 83.0018 Tj -17.4613 -484.1606 Td -(5860 5910) 39.3166 Tj --13543.8 TJm -(1724 1725) 39.3166 Tj -0 -493.654 Td -(REG_TABLE 5862) 61.1592 Tj --11035.5 TJm -(SEG16 0706) 43.6851 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 10) 192.2146 Tj -17.4613 -28.4801 Td -(0706 1726) 39.3166 Tj --13543.8 TJm -(3665 4085 4476 4553) 83.0018 Tj -0 -37.9735 Td -(segdesc 0677) 52.4222 Tj --14045.3 TJm -(4654 6803) 39.3166 Tj -17.4613 -47.4664 Td -(0450 0453 0677 0701) 83.0018 Tj --6520.6 TJm -(stati 4085) 43.6851 Tj -17.4613 -56.9598 Td -(0706 1561) 39.3166 Tj --13543.8 TJm -(0248 4085 4480) 61.1592 Tj -0 -66.4531 Td -(SEG_ASM 0608) 52.4222 Tj --12038.8 TJm -(STA_R 0617 0718) 65.5277 Tj -17.4613 -75.9465 Td -(0608 0992 0993 1092) 83.0018 Tj --8527.14 TJm -(0617 0718 0992 1092) 83.0018 Tj -17.4613 -85.4399 Td -(1093) 17.4741 Tj --16052.1 TJm -(1708 1724) 39.3166 Tj -0 -94.9332 Td -(SEG_KCODE 0907 1021 1502 2500) 126.6869 Tj --3510.47 TJm -(STA_W 0616 0717) 65.5277 Tj -17.4613 -104.4266 Td -(0961 1061 1502 1708) 83.0018 Tj --8527.14 TJm -(0616 0717 0993 1093) 83.0018 Tj -17.4613 -113.9199 Td -(2571 2572) 39.3166 Tj --13543.8 TJm -(1709 1710 1725) 61.1592 Tj -0 -123.4133 Td -(SEG_KCPU 1504 2502) 78.6333 Tj --9028.81 TJm -(STA_X 0613 0714) 65.5277 Tj -17.4613 -132.9067 Td -(1504 1710 1712 2518) 83.0018 Tj --8527.14 TJm -(0613 0714 0992 1092) 83.0018 Tj -0 -142.4 Td -(SEG_KDATA 0908 1022 1503 2501) 126.6869 Tj --5517.01 TJm -(1708 1724) 39.3166 Tj -17.4613 -151.8934 Td -(0966 1066 1503 1709) 83.0018 Tj --6520.6 TJm -(sti 0526) 34.9481 Tj -17.4613 -161.3867 Td -(1728 2515) 39.3166 Tj --13543.8 TJm -(0526 0528 1473 1914) 83.0018 Tj -0 -170.8801 Td -(SEG_NULLASM 0604) 69.8962 Tj --10032.1 TJm -(stosb 0442) 43.6851 Tj -17.4613 -180.3735 Td -(0604 0991 1091) 61.1592 Tj --11035.5 TJm -(0442 0444 1139 5306) 83.0018 Tj -0 -189.8664 Td -(SEG_TSS 1507) 52.4222 Tj --12038.8 TJm -(strlen 5389) 48.0537 Tj -17.4613 -199.3598 Td -(1507 1726 1727 1730) 83.0018 Tj --8527.14 TJm -(0334 5046 5086 5389) 83.0018 Tj -0 -208.8532 Td -(SEG_UCODE 1505) 61.1592 Tj --13042 TJm -(7019 7223) 39.3166 Tj -17.4613 -218.3465 Td -(1505 1724 1817) 61.1592 Tj --9028.94 TJm -(strncmp 5351) 52.4222 Tj -0 -227.8399 Td -(SEG_UDATA 1506) 61.1592 Tj --13042 TJm -(0335 4205 5351) 61.1592 Tj -17.4613 -237.3332 Td -(1506 1725 1818) 61.1592 Tj --9028.94 TJm -(strncpy 5361) 52.4222 Tj -0 -246.8266 Td -(SETGATE 0821) 52.4222 Tj --14045.3 TJm -(0336 4272 5361) 61.1592 Tj -17.4613 -256.32 Td -(0821 2571 2572) 61.1592 Tj --9028.94 TJm -(STS_IG32 0732) 56.7907 Tj -0 -265.8133 Td -(SHIFT 6108) 43.6851 Tj --15048.7 TJm -(0732 0827) 39.3166 Tj -17.4613 -275.3067 Td -(6108 6136 6137 6285) 83.0018 Tj --6520.6 TJm -(STS_T32A 0729) 56.7907 Tj -0 -284.8 Td -(skipelem 4315) 56.7907 Tj --13543.7 TJm -(0729 1726) 39.3166 Tj -17.4613 -294.2934 Td -(4315 4363) 39.3166 Tj --11537.3 TJm -(STS_TG32 0733) 56.7907 Tj -0 -303.7868 Td -(sleep 2003) 43.6851 Tj --15048.7 TJm -(0733 0827) 39.3166 Tj -17.4613 -313.2801 Td -(0311 1659 2003 2006) 83.0018 Tj --6520.6 TJm -(sum 5525) 34.9481 Tj -17.4613 -322.7735 Td -(2009 2188 2978 3480) 83.0018 Tj --8527.14 TJm -(5525 5527 5529 5531) 83.0018 Tj -17.4613 -332.2668 Td -(3581 3912 5242 5261) 83.0018 Tj --8527.14 TJm -(5532 5543 5592) 61.1592 Tj -17.4613 -341.7602 Td -(6566 6779) 39.3166 Tj --11537.3 TJm -(superblock 3161) 65.5277 Tj -0 -351.2536 Td -(spinlock 1301) 56.7907 Tj --13543.7 TJm -(3161 3678 3708 3733) 83.0018 Tj -17.4613 -360.7469 Td -(0206 0311 0321 0323) 83.0018 Tj --8527.14 TJm -(3807) 17.4741 Tj -17.4613 -370.2403 Td -(0324 0325 0354 1301) 83.0018 Tj --6520.6 TJm -(SVR 5664) 34.9481 Tj -17.4613 -379.7336 Td -(1358 1361 1373 1402) 83.0018 Tj --8527.14 TJm -(5664 5707) 39.3166 Tj -17.4613 -389.227 Td -(1444 1606 1609 2003) 83.0018 Tj --6520.6 TJm -(swtch 2208) 43.6851 Tj -17.4613 -398.7204 Td -(2260 2268 2557 2562) 83.0018 Tj --8527.14 TJm -(0318 1928 1967 2207) 83.0018 Tj -17.4613 -408.2137 Td -(3309 3324 3526 3530) 83.0018 Tj --8527.14 TJm -(2208) 17.4741 Tj -17.4613 -417.7071 Td -(3668 3784 4405 4409) 83.0018 Tj --6520.6 TJm -(SYSCALL 6753 6760 6761 6762 6763 67) 152.898 Tj -17.4613 -427.2004 Td -(5157 5162 6308 6320) 83.0018 Tj --8527.14 TJm -(6760 6761 6762 6763) 83.0018 Tj -17.4613 -436.6938 Td -(6502) 17.4741 Tj --16052.1 TJm -(6764 6765 6766 6767) 83.0018 Tj -0 -446.1872 Td -(start 0914 1028 6707) 87.3703 Tj --10032 TJm -(6768 6769 6770 6771) 83.0018 Tj -17.4613 -455.6805 Td -(0913 0914 0975 1027) 83.0018 Tj --8527.14 TJm -(6772 6773 6774 6775) 83.0018 Tj -17.4613 -465.1739 Td -(1028 1075 1076 6706) 83.0018 Tj --8527.14 TJm -(6776 6777 6778 6779) 83.0018 Tj -17.4613 -474.6672 Td -(6707) 17.4741 Tj --14045.6 TJm -(syscall 2874) 52.4222 Tj -0 -484.1606 Td -(stat 3104) 39.3166 Tj --15550.3 TJm -(0344 2607 2756 2874) 83.0018 Tj -17.4613 -493.654 Td -(0207 0230 0248 3104) 83.0018 Tj --6520.6 TJm -(SYS_chdir 2716) 61.1592 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 7 7 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 11) 192.2146 Tj -17.4613 -28.4801 Td -(2716 2851) 39.3166 Tj --13543.8 TJm -(2841 2863 4851) 61.1592 Tj -0 -37.9735 Td -(sys_chdir 4930) 61.1592 Tj --11035.5 TJm -(SYS_pipe 2704) 56.7907 Tj -17.4613 -47.4664 Td -(2829 2851 4930) 61.1592 Tj --11035.5 TJm -(2704 2864) 39.3166 Tj -0 -56.9598 Td -(SYS_close 2707) 61.1592 Tj --11035.5 TJm -(sys_pipe 4976) 56.7907 Tj -17.4613 -66.4531 Td -(2707 2852) 39.3166 Tj --13543.8 TJm -(2842 2864 4976) 61.1592 Tj -0 -75.9465 Td -(sys_close 4639) 61.1592 Tj --11035.5 TJm -(SYS_read 2706) 56.7907 Tj -17.4613 -85.4399 Td -(2830 2852 4639) 61.1592 Tj --11035.5 TJm -(2706 2865) 39.3166 Tj -0 -94.9332 Td -(SYS_dup 2717) 52.4222 Tj --12038.8 TJm -(sys_read 4615) 56.7907 Tj -17.4613 -104.4266 Td -(2717 2853) 39.3166 Tj --13543.8 TJm -(2843 2865 4615) 61.1592 Tj -0 -113.9199 Td -(sys_dup 4601) 52.4222 Tj --12038.8 TJm -(SYS_sbrk 2719) 56.7907 Tj -17.4613 -123.4133 Td -(2831 2853 4601) 61.1592 Tj --11035.5 TJm -(2719 2866) 39.3166 Tj -0 -132.9067 Td -(SYS_exec 2709) 56.7907 Tj --11537.1 TJm -(sys_sbrk 2951) 56.7907 Tj -17.4613 -142.4 Td -(2709 2854 6711) 61.1592 Tj --11035.5 TJm -(2844 2866 2951) 61.1592 Tj -0 -151.8934 Td -(sys_exec 4951) 56.7907 Tj --11537.1 TJm -(SYS_sleep 2720) 61.1592 Tj -17.4613 -161.3867 Td -(2832 2854 4951) 61.1592 Tj --11035.5 TJm -(2720 2867) 39.3166 Tj -0 -170.8801 Td -(SYS_exit 2702) 56.7907 Tj --11537.1 TJm -(sys_sleep 2965) 61.1592 Tj -17.4613 -180.3735 Td -(2702 2855 6716) 61.1592 Tj --11035.5 TJm -(2845 2867 2965) 61.1592 Tj -0 -189.8664 Td -(sys_exit 2914) 56.7907 Tj --11537.1 TJm -(SYS_unlink 2712) 65.5277 Tj -17.4613 -199.3598 Td -(2833 2855 2914) 61.1592 Tj --11035.5 TJm -(2712 2868) 39.3166 Tj -0 -208.8532 Td -(SYS_fork 2701) 56.7907 Tj --11537.1 TJm -(sys_unlink 4751) 65.5277 Tj -17.4613 -218.3465 Td -(2701 2856) 39.3166 Tj --13543.8 TJm -(2846 2868 4751) 61.1592 Tj -0 -227.8399 Td -(sys_fork 2908) 56.7907 Tj --11537.1 TJm -(SYS_wait 2703) 56.7907 Tj -17.4613 -237.3332 Td -(2834 2856 2908) 61.1592 Tj --11035.5 TJm -(2703 2869) 39.3166 Tj -0 -246.8266 Td -(SYS_fstat 2713) 61.1592 Tj --11035.5 TJm -(sys_wait 2921) 56.7907 Tj -17.4613 -256.32 Td -(2713 2857) 39.3166 Tj --13543.8 TJm -(2847 2869 2921) 61.1592 Tj -0 -265.8133 Td -(sys_fstat 4651) 61.1592 Tj --11035.5 TJm -(SYS_write 2705) 61.1592 Tj -17.4613 -275.3067 Td -(2835 2857 4651) 61.1592 Tj --11035.5 TJm -(2705 2870) 39.3166 Tj -0 -284.8 Td -(SYS_getpid 2718) 65.5277 Tj --10533.8 TJm -(sys_write 4627) 61.1592 Tj -17.4613 -294.2934 Td -(2718 2858) 39.3166 Tj --13543.8 TJm -(2848 2870 4627) 61.1592 Tj -0 -303.7868 Td -(sys_getpid 2937) 65.5277 Tj --10533.8 TJm -(taskstate 0751) 61.1592 Tj -17.4613 -313.2801 Td -(2836 2858 2937) 61.1592 Tj --11035.5 TJm -(0751 1560) 39.3166 Tj -0 -322.7735 Td -(SYS_kill 2708) 56.7907 Tj --11537.1 TJm -(TDCR 5685) 39.3166 Tj -17.4613 -332.2664 Td -(2708 2859) 39.3166 Tj --13543.8 TJm -(5685 5713) 39.3166 Tj -0 -341.7598 Td -(sys_kill 2927) 56.7907 Tj --11537.1 TJm -(ticks 2563) 43.6851 Tj -17.4613 -351.2532 Td -(2837 2859 2927) 61.1592 Tj --11035.5 TJm -(0352 2563 2617 2618) 83.0018 Tj -0 -360.7465 Td -(SYS_link 2714) 56.7907 Tj --13543.7 TJm -(2972 2973 2978) 61.1592 Tj -17.4613 -370.2399 Td -(2714 2860) 39.3166 Tj --11537.3 TJm -(tickslock 2562) 61.1592 Tj -0 -379.7332 Td -(sys_link 4663) 56.7907 Tj --13543.7 TJm -(0354 2562 2574 2616) 83.0018 Tj -17.4613 -389.2266 Td -(2838 2860 4663) 61.1592 Tj --11035.5 TJm -(2619 2971 2975 2978) 83.0018 Tj -0 -398.72 Td -(SYS_mkdir 2715) 61.1592 Tj --13042 TJm -(2980) 17.4741 Tj -17.4613 -408.2133 Td -(2715 2861) 39.3166 Tj --11537.3 TJm -(TICR 5683) 39.3166 Tj -0 -417.7067 Td -(sys_mkdir 4901) 61.1592 Tj --13042 TJm -(5683 5715) 39.3166 Tj -17.4613 -427.2 Td -(2839 2861 4901) 61.1592 Tj --9028.94 TJm -(TIMER 5675) 43.6851 Tj -0 -436.6934 Td -(SYS_mknod 2711) 61.1592 Tj --13042 TJm -(5675 5714) 39.3166 Tj -17.4613 -446.1868 Td -(2711 2862) 39.3166 Tj --11537.3 TJm -(timerinit 6674) 61.1592 Tj -0 -455.6801 Td -(sys_mknod 4913) 61.1592 Tj --13042 TJm -(0347 1232 6674) 61.1592 Tj -17.4613 -465.1735 Td -(2840 2862 4913) 61.1592 Tj --9028.94 TJm -(TIMER_16BIT 6671) 69.8962 Tj -0 -474.6665 Td -(SYS_open 2710) 56.7907 Tj --13543.7 TJm -(6671 6677) 39.3166 Tj -17.4613 -484.1598 Td -(2710 2863) 39.3166 Tj --11537.3 TJm -(TIMER_DIV 6666) 61.1592 Tj -0 -493.6532 Td -(sys_open 4851) 56.7907 Tj --13543.7 TJm -(6666 6678 6679) 61.1592 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 cross-references Page 12) 192.2146 Tj -0 -28.4801 Td -(TIMER_FREQ 6665) 65.5277 Tj --12540.3 TJm -(5931 5997 6016) 61.1592 Tj -17.4613 -37.9735 Td -(6665 6666) 39.3166 Tj --11537.3 TJm -(T_SYSCALL 2426) 61.1592 Tj -0 -47.4664 Td -(TIMER_MODE 6668) 65.5277 Tj --12540.3 TJm -(2426 2572 2603 6712) 83.0018 Tj -17.4613 -56.9598 Td -(6668 6677) 39.3166 Tj --13543.8 TJm -(6717 6757) 39.3166 Tj -0 -66.4531 Td -(TIMER_RATEGEN 6670) 78.6333 Tj --9028.81 TJm -(usegment 1721) 56.7907 Tj -17.4613 -75.9465 Td -(6670 6677) 39.3166 Tj --13543.8 TJm -(0310 1721 1846 1926) 83.0018 Tj -0 -85.4399 Td -(TIMER_SEL0 6669) 65.5277 Tj --12540.3 TJm -(5112) 17.4741 Tj -17.4613 -94.9332 Td -(6669 6677) 39.3166 Tj --11537.3 TJm -(userinit 1802) 56.7907 Tj -0 -104.4266 Td -(TPR 5662) 34.9481 Tj --16052 TJm -(0312 1233 1802) 61.1592 Tj -17.4613 -113.9199 Td -(5662 5743) 39.3166 Tj --11537.3 TJm -(VER 5661) 34.9481 Tj -0 -123.4133 Td -(trap 2601) 39.3166 Tj --15550.3 TJm -(5661 5723) 39.3166 Tj -17.4613 -132.9067 Td -(2452 2454 2524 2601) 83.0018 Tj --6520.6 TJm -(wait 2153) 39.3166 Tj -17.4613 -142.4 Td -(2653 2655 2658) 61.1592 Tj --11035.5 TJm -(0313 2153 2923 6762) 83.0018 Tj -0 -151.8934 Td -(trapframe 0552) 61.1592 Tj --13042 TJm -(6833 6944 6970 6971) 83.0018 Tj -17.4613 -161.3867 Td -(0552 1536 1780 2601) 83.0018 Tj --8527.14 TJm -(7026) 17.4741 Tj -0 -170.8801 Td -(trapret 2529) 52.4222 Tj --12038.8 TJm -(waitdisk 1151) 56.7907 Tj -17.4613 -180.3735 Td -(1617 1785 2528 2529) 83.0018 Tj --8527.14 TJm -(1151 1163 1172) 61.1592 Tj -0 -189.8664 Td -(tvinit 2566) 48.0537 Tj --12540.5 TJm -(wakeup 2064) 48.0537 Tj -17.4613 -199.3598 Td -(0353 1226 2566) 61.1592 Tj --11035.5 TJm -(0314 2064 2618 3422) 83.0018 Tj -0 -208.8532 Td -(T_DEV 3102) 43.6851 Tj --15048.7 TJm -(3639 3941 3966 5216) 83.0018 Tj -17.4613 -218.3465 Td -(3102 4107 4157 4923) 83.0018 Tj --8527.14 TJm -(5219 5241 5246 5268) 83.0018 Tj -0 -227.8399 Td -(T_DIR 3100) 43.6851 Tj --15048.7 TJm -(6541) 17.4741 Tj -17.4613 -237.3332 Td -(3100 4218 4365 4673) 83.0018 Tj --6520.6 TJm -(wakeup1 2053) 52.4222 Tj -17.4613 -246.8266 Td -(4778 4787 4829 4868) 83.0018 Tj --8527.14 TJm -(2053 2067 2126 2133) 83.0018 Tj -17.4613 -256.32 Td -(4906 4938) 39.3166 Tj --11537.3 TJm -(writei 4152) 48.0537 Tj -0 -265.8133 Td -(T_FILE 3101) 48.0537 Tj --14547 TJm -(0249 4152 4274 4532) 83.0018 Tj -17.4613 -275.3067 Td -(3101 4814 4862) 61.1592 Tj --11035.5 TJm -(4785 4786) 39.3166 Tj -0 -284.8 Td -(T_IRQ0 2429) 48.0537 Tj --12540.5 TJm -(xchg 0501) 39.3166 Tj -17.4613 -294.2934 Td -(2429 2614 2623 2627) 83.0018 Tj --8527.14 TJm -(0501 1260 1382 1419) 83.0018 Tj -17.4613 -303.7868 Td -(2631 2635 2636 2671) 83.0018 Tj --6520.6 TJm -(yield 1973) 43.6851 Tj -17.4613 -313.2801 Td -(5707 5714 5727 5917) 83.0018 Tj --8527.14 TJm -(0315 1973 2672) 61.1592 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 8 8 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/types.h Page 1) 166.0035 Tj -0 -28.4801 Td -(0100 typedef unsigned int uint;) 144.161 Tj -0 -37.9735 Td -(0101 typedef unsigned short ushort;) 152.898 Tj -0 -47.4668 Td -(0102 typedef unsigned char uchar;) 148.5295 Tj -0 -56.9602 Td -(0103 ) 21.8426 Tj -0 -66.4535 Td -(0104 ) 21.8426 Tj -0 -75.9469 Td -(0105 ) 21.8426 Tj -0 -85.4403 Td -(0106 ) 21.8426 Tj -0 -94.9336 Td -(0107 ) 21.8426 Tj -0 -104.427 Td -(0108 ) 21.8426 Tj -0 -113.9203 Td -(0109 ) 21.8426 Tj -0 -123.4137 Td -(0110 ) 21.8426 Tj -0 -132.9071 Td -(0111 ) 21.8426 Tj -0 -142.4004 Td -(0112 ) 21.8426 Tj -0 -151.8938 Td -(0113 ) 21.8426 Tj -0 -161.3871 Td -(0114 ) 21.8426 Tj -0 -170.8805 Td -(0115 ) 21.8426 Tj -0 -180.3739 Td -(0116 ) 21.8426 Tj -0 -189.8672 Td -(0117 ) 21.8426 Tj -0 -199.3606 Td -(0118 ) 21.8426 Tj -0 -208.8539 Td -(0119 ) 21.8426 Tj -0 -218.3473 Td -(0120 ) 21.8426 Tj -0 -227.8407 Td -(0121 ) 21.8426 Tj -0 -237.334 Td -(0122 ) 21.8426 Tj -0 -246.8274 Td -(0123 ) 21.8426 Tj -0 -256.3207 Td -(0124 ) 21.8426 Tj -0 -265.8141 Td -(0125 ) 21.8426 Tj -0 -275.3075 Td -(0126 ) 21.8426 Tj -0 -284.8008 Td -(0127 ) 21.8426 Tj -0 -294.2942 Td -(0128 ) 21.8426 Tj -0 -303.7875 Td -(0129 ) 21.8426 Tj -0 -313.2809 Td -(0130 ) 21.8426 Tj -0 -322.7743 Td -(0131 ) 21.8426 Tj -0 -332.2676 Td -(0132 ) 21.8426 Tj -0 -341.761 Td -(0133 ) 21.8426 Tj -0 -351.2543 Td -(0134 ) 21.8426 Tj -0 -360.7477 Td -(0135 ) 21.8426 Tj -0 -370.2411 Td -(0136 ) 21.8426 Tj -0 -379.7344 Td -(0137 ) 21.8426 Tj -0 -389.2278 Td -(0138 ) 21.8426 Tj -0 -398.7211 Td -(0139 ) 21.8426 Tj -0 -408.2145 Td -(0140 ) 21.8426 Tj -0 -417.7079 Td -(0141 ) 21.8426 Tj -0 -427.2012 Td -(0142 ) 21.8426 Tj -0 -436.6946 Td -(0143 ) 21.8426 Tj -0 -446.1879 Td -(0144 ) 21.8426 Tj -0 -455.6813 Td -(0145 ) 21.8426 Tj -0 -465.1747 Td -(0146 ) 21.8426 Tj -0 -474.668 Td -(0147 ) 21.8426 Tj -0 -484.1614 Td -(0148 ) 21.8426 Tj -0 -493.6547 Td -(0149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 01) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/param.h Page 1) 166.0035 Tj -0 -28.4801 Td -(0150 #define NPROC 64 // maximum number of processes) 262.1109 Tj -0 -37.9735 Td -(0151 #define PAGE 4096 // granularity of user-space memo\ -ry allocation) 332.0071 Tj -0 -47.4668 Td -(0152 #define KSTACKSIZE PAGE // size of per-process kernel sta\ -ck) 283.9534 Tj -0 -56.9602 Td -(0153 #define NCPU 8 // maximum number of CPUs) 240.2683 Tj -0 -66.4535 Td -(0154 #define NOFILE 16 // open files per process) 240.2683 Tj -0 -75.9469 Td -(0155 #define NFILE 100 // open files per system) 235.8998 Tj -0 -85.4403 Td -(0156 #define NBUF 10 // size of disk block cache) 249.0053 Tj -0 -94.9336 Td -(0157 #define NINODE 50 // maximum number of active i-nod\ -es) 283.9534 Tj -0 -104.427 Td -(0158 #define NDEV 10 // maximum major device number) 262.1109 Tj -0 -113.9203 Td -(0159 #define ROOTDEV 1 // device number of file system r\ -oot disk) 310.1645 Tj -0 -123.4137 Td -(0160 ) 21.8426 Tj -0 -132.9071 Td -(0161 ) 21.8426 Tj -0 -142.4004 Td -(0162 ) 21.8426 Tj -0 -151.8938 Td -(0163 ) 21.8426 Tj -0 -161.3871 Td -(0164 ) 21.8426 Tj -0 -170.8805 Td -(0165 ) 21.8426 Tj -0 -180.3739 Td -(0166 ) 21.8426 Tj -0 -189.8672 Td -(0167 ) 21.8426 Tj -0 -199.3606 Td -(0168 ) 21.8426 Tj -0 -208.8539 Td -(0169 ) 21.8426 Tj -0 -218.3473 Td -(0170 ) 21.8426 Tj -0 -227.8407 Td -(0171 ) 21.8426 Tj -0 -237.334 Td -(0172 ) 21.8426 Tj -0 -246.8274 Td -(0173 ) 21.8426 Tj -0 -256.3207 Td -(0174 ) 21.8426 Tj -0 -265.8141 Td -(0175 ) 21.8426 Tj -0 -275.3075 Td -(0176 ) 21.8426 Tj -0 -284.8008 Td -(0177 ) 21.8426 Tj -0 -294.2942 Td -(0178 ) 21.8426 Tj -0 -303.7875 Td -(0179 ) 21.8426 Tj -0 -313.2809 Td -(0180 ) 21.8426 Tj -0 -322.7743 Td -(0181 ) 21.8426 Tj -0 -332.2676 Td -(0182 ) 21.8426 Tj -0 -341.761 Td -(0183 ) 21.8426 Tj -0 -351.2543 Td -(0184 ) 21.8426 Tj -0 -360.7477 Td -(0185 ) 21.8426 Tj -0 -370.2411 Td -(0186 ) 21.8426 Tj -0 -379.7344 Td -(0187 ) 21.8426 Tj -0 -389.2278 Td -(0188 ) 21.8426 Tj -0 -398.7211 Td -(0189 ) 21.8426 Tj -0 -408.2145 Td -(0190 ) 21.8426 Tj -0 -417.7079 Td -(0191 ) 21.8426 Tj -0 -427.2012 Td -(0192 ) 21.8426 Tj -0 -436.6946 Td -(0193 ) 21.8426 Tj -0 -446.1879 Td -(0194 ) 21.8426 Tj -0 -455.6813 Td -(0195 ) 21.8426 Tj -0 -465.1747 Td -(0196 ) 21.8426 Tj -0 -474.668 Td -(0197 ) 21.8426 Tj -0 -484.1614 Td -(0198 ) 21.8426 Tj -0 -493.6547 Td -(0199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 01) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 9 9 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/defs.h Page 1) 161.635 Tj -0 -28.4801 Td -(0200 struct buf;) 69.8962 Tj -0 -37.9735 Td -(0201 struct context;) 87.3703 Tj -0 -47.4668 Td -(0202 struct file;) 74.2647 Tj -0 -56.9602 Td -(0203 struct inode;) 78.6333 Tj -0 -66.4535 Td -(0204 struct pipe;) 74.2647 Tj -0 -75.9469 Td -(0205 struct proc;) 74.2647 Tj -0 -85.4403 Td -(0206 struct spinlock;) 91.7388 Tj -0 -94.9336 Td -(0207 struct stat;) 74.2647 Tj -0 -104.427 Td -(0208 ) 21.8426 Tj -0 -113.9203 Td -(0209 // bio.c) 56.7907 Tj -0 -123.4137 Td -(0210 void binit\(void\);) 144.161 Tj -0 -132.9071 Td -(0211 struct buf* bread\(uint, uint\);) 170.3721 Tj -0 -142.4004 Td -(0212 void brelse\(struct buf*\);) 179.1091 Tj -0 -151.8938 Td -(0213 void bwrite\(struct buf*\);) 179.1091 Tj -0 -161.3871 Td -(0214 ) 21.8426 Tj -0 -170.8805 Td -(0215 // console.c) 74.2647 Tj -0 -180.3739 Td -(0216 void consoleinit\(void\);) 170.3721 Tj -0 -189.8672 Td -(0217 void cprintf\(char*, ...\);) 179.1091 Tj -0 -199.3606 Td -(0218 void consoleintr\(int\(*\)\(void\)\);) 205.3202 Tj -0 -208.8539 Td -(0219 void panic\(char*\) __attribute__\(\(noreturn\)\ -\);) 262.1109 Tj -0 -218.3473 Td -(0220 ) 21.8426 Tj -0 -227.8407 Td -(0221 // exec.c) 61.1592 Tj -0 -237.334 Td -(0222 int exec\(char*, char**\);) 179.1091 Tj -0 -246.8274 Td -(0223 ) 21.8426 Tj -0 -256.3207 Td -(0224 // file.c) 61.1592 Tj -0 -265.8141 Td -(0225 struct file* filealloc\(void\);) 161.635 Tj -0 -275.3075 Td -(0226 void fileclose\(struct file*\);) 196.5831 Tj -0 -284.8008 Td -(0227 struct file* filedup\(struct file*\);) 187.8461 Tj -0 -294.2942 Td -(0228 void fileinit\(void\);) 157.2665 Tj -0 -303.7875 Td -(0229 int fileread\(struct file*, char*, int n\);) 253.3738 Tj -0 -313.2809 Td -(0230 int filestat\(struct file*, struct stat*\);) 253.3738 Tj -0 -322.7743 Td -(0231 int filewrite\(struct file*, char*, int n\);) 257.7424 Tj -0 -332.2676 Td -(0232 ) 21.8426 Tj -0 -341.761 Td -(0233 // fs.c) 52.4222 Tj -0 -351.2543 Td -(0234 int dirlink\(struct inode*, char*, uint\);) 249.0053 Tj -0 -360.7477 Td -(0235 struct inode* dirlookup\(struct inode*, char*, uint*\);) 262.1109 Tj -0 -370.2411 Td -(0236 struct inode* ialloc\(uint, short\);) 179.1091 Tj -0 -379.7344 Td -(0237 struct inode* idup\(struct inode*\);) 179.1091 Tj -0 -389.2278 Td -(0238 void iinit\(void\);) 144.161 Tj -0 -398.7211 Td -(0239 void ilock\(struct inode*\);) 183.4776 Tj -0 -408.2145 Td -(0240 void iput\(struct inode*\);) 179.1091 Tj -0 -417.7079 Td -(0241 void iunlock\(struct inode*\);) 192.2146 Tj -0 -427.2012 Td -(0242 void iunlockput\(struct inode*\);) 205.3202 Tj -0 -436.6946 Td -(0243 void iupdate\(struct inode*\);) 192.2146 Tj -0 -446.1879 Td -(0244 int namecmp\(const char*, const char*\);) 240.2683 Tj -0 -455.6813 Td -(0245 struct inode* namei\(char*\);) 148.5295 Tj -0 -465.1747 Td -(0246 struct inode* nameiparent\(char*, char*\);) 205.3202 Tj -0 -474.668 Td -(0247 int readi\(struct inode*, char*, uint, uint\);) 266.4794 Tj -0 -484.1614 Td -(0248 void stati\(struct inode*, struct stat*\);) 244.6368 Tj -0 -493.6547 Td -(0249 int writei\(struct inode*, char*, uint, uint\)\ -;) 270.8479 Tj -0 -522.1348 Td -(Sheet 02) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/defs.h Page 2) 161.635 Tj -0 -28.4801 Td -(0250 // ide.c) 56.7907 Tj -0 -37.9735 Td -(0251 void ideinit\(void\);) 152.898 Tj -0 -47.4668 Td -(0252 void ideintr\(void\);) 152.898 Tj -0 -56.9602 Td -(0253 void iderw\(struct buf*\);) 174.7406 Tj -0 -66.4535 Td -(0254 ) 21.8426 Tj -0 -75.9469 Td -(0255 // ioapic.c) 69.8962 Tj -0 -85.4403 Td -(0256 void ioapicenable\(int irq, int cpu\);) 227.1628 Tj -0 -94.9336 Td -(0257 extern uchar ioapicid;) 131.0554 Tj -0 -104.427 Td -(0258 void ioapicinit\(void\);) 166.0035 Tj -0 -113.9203 Td -(0259 ) 21.8426 Tj -0 -123.4137 Td -(0260 // kalloc.c) 69.8962 Tj -0 -132.9071 Td -(0261 char* kalloc\(int\);) 144.161 Tj -0 -142.4004 Td -(0262 void kfree\(char*, int\);) 170.3721 Tj -0 -151.8938 Td -(0263 void kinit\(void\);) 144.161 Tj -0 -161.3871 Td -(0264 ) 21.8426 Tj -0 -170.8805 Td -(0265 // kbd.c) 56.7907 Tj -0 -180.3739 Td -(0266 void kbdintr\(void\);) 152.898 Tj -0 -189.8672 Td -(0267 ) 21.8426 Tj -0 -199.3606 Td -(0268 // lapic.c) 65.5277 Tj -0 -208.8539 Td -(0269 int cpunum\(void\);) 148.5295 Tj -0 -218.3473 Td -(0270 extern volatile uint* lapic;) 157.2665 Tj -0 -227.8407 Td -(0271 void lapiceoi\(void\);) 157.2665 Tj -0 -237.334 Td -(0272 void lapicinit\(int\);) 157.2665 Tj -0 -246.8274 Td -(0273 void lapicstartap\(uchar, uint\);) 205.3202 Tj -0 -256.3207 Td -(0274 void microdelay\(int\);) 161.635 Tj -0 -265.8141 Td -(0275 ) 21.8426 Tj -0 -275.3075 Td -(0276 // mp.c) 52.4222 Tj -0 -284.8008 Td -(0277 extern int ismp;) 113.5814 Tj -0 -294.2942 Td -(0278 int mpbcpu\(void\);) 148.5295 Tj -0 -303.7875 Td -(0279 void mpinit\(void\);) 148.5295 Tj -0 -313.2809 Td -(0280 void mpstartthem\(void\);) 170.3721 Tj -0 -322.7743 Td -(0281 ) 21.8426 Tj -0 -332.2676 Td -(0282 // picirq.c) 69.8962 Tj -0 -341.761 Td -(0283 void picenable\(int\);) 157.2665 Tj -0 -351.2543 Td -(0284 void picinit\(void\);) 152.898 Tj -0 -360.7477 Td -(0285 ) 21.8426 Tj -0 -370.2411 Td -(0286 // pipe.c) 61.1592 Tj -0 -379.7344 Td -(0287 int pipealloc\(struct file**, struct file**\);) 266.4794 Tj -0 -389.2278 Td -(0288 void pipeclose\(struct pipe*, int\);) 218.4257 Tj -0 -398.7211 Td -(0289 int piperead\(struct pipe*, char*, int\);) 244.6368 Tj -0 -408.2145 Td -(0290 int pipewrite\(struct pipe*, char*, int\);) 249.0053 Tj -0 -417.7079 Td -(0291 ) 21.8426 Tj -0 -427.2012 Td -(0292 ) 21.8426 Tj -0 -436.6946 Td -(0293 ) 21.8426 Tj -0 -446.1879 Td -(0294 ) 21.8426 Tj -0 -455.6813 Td -(0295 ) 21.8426 Tj -0 -465.1747 Td -(0296 ) 21.8426 Tj -0 -474.668 Td -(0297 ) 21.8426 Tj -0 -484.1614 Td -(0298 ) 21.8426 Tj -0 -493.6547 Td -(0299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 02) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 10 10 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/defs.h Page 3) 161.635 Tj -0 -28.4801 Td -(0300 // proc.c) 61.1592 Tj -0 -37.9735 Td -(0301 struct proc* copyproc\(struct proc*\);) 192.2146 Tj -0 -47.4668 Td -(0302 void exit\(void\);) 139.7925 Tj -0 -56.9602 Td -(0303 int fork\(void\);) 139.7925 Tj -0 -66.4535 Td -(0304 int growproc\(int\);) 152.898 Tj -0 -75.9469 Td -(0305 int kill\(int\);) 135.4239 Tj -0 -85.4403 Td -(0306 void pinit\(void\);) 144.161 Tj -0 -94.9336 Td -(0307 void procdump\(void\);) 157.2665 Tj -0 -104.427 Td -(0308 void scheduler\(void\) __attribute__\(\(noretur\ -n\)\);) 275.2164 Tj -0 -113.9203 Td -(0309 void ksegment\(void\);) 157.2665 Tj -0 -123.4137 Td -(0310 void usegment\(void\);) 157.2665 Tj -0 -132.9071 Td -(0311 void sleep\(void*, struct spinlock*\);) 227.1628 Tj -0 -142.4004 Td -(0312 void userinit\(void\);) 157.2665 Tj -0 -151.8938 Td -(0313 int wait\(void\);) 139.7925 Tj -0 -161.3871 Td -(0314 void wakeup\(void*\);) 152.898 Tj -0 -170.8805 Td -(0315 void yield\(void\);) 144.161 Tj -0 -180.3739 Td -(0316 ) 21.8426 Tj -0 -189.8672 Td -(0317 // swtch.S) 65.5277 Tj -0 -199.3606 Td -(0318 void swtch\(struct context**, struct context*\)\ -;) 270.8479 Tj -0 -208.8539 Td -(0319 ) 21.8426 Tj -0 -218.3473 Td -(0320 // spinlock.c) 78.6333 Tj -0 -227.8407 Td -(0321 void acquire\(struct spinlock*\);) 205.3202 Tj -0 -237.334 Td -(0322 void getcallerpcs\(void*, uint*\);) 209.6887 Tj -0 -246.8274 Td -(0323 int holding\(struct spinlock*\);) 205.3202 Tj -0 -256.3207 Td -(0324 void initlock\(struct spinlock*, char*\);) 240.2683 Tj -0 -265.8141 Td -(0325 void release\(struct spinlock*\);) 205.3202 Tj -0 -275.3075 Td -(0326 void pushcli\(\);) 135.4239 Tj -0 -284.8008 Td -(0327 void popcli\(\);) 131.0554 Tj -0 -294.2942 Td -(0328 ) 21.8426 Tj -0 -303.7875 Td -(0329 // string.c) 69.8962 Tj -0 -313.2809 Td -(0330 int memcmp\(const void*, const void*, uint\);) 262.1109 Tj -0 -322.7743 Td -(0331 void* memmove\(void*, const void*, uint\);) 240.2683 Tj -0 -332.2676 Td -(0332 void* memset\(void*, int, uint\);) 200.9517 Tj -0 -341.761 Td -(0333 char* safestrcpy\(char*, const char*, int\);) 249.0053 Tj -0 -351.2543 Td -(0334 int strlen\(const char*\);) 179.1091 Tj -0 -360.7477 Td -(0335 int strncmp\(const char*, const char*, uint\);) 266.4794 Tj -0 -370.2411 Td -(0336 char* strncpy\(char*, const char*, int\);) 235.8998 Tj -0 -379.7344 Td -(0337 ) 21.8426 Tj -0 -389.2278 Td -(0338 // syscall.c) 74.2647 Tj -0 -398.7211 Td -(0339 int argint\(int, int*\);) 170.3721 Tj -0 -408.2145 Td -(0340 int argptr\(int, char**, int\);) 200.9517 Tj -0 -417.7079 Td -(0341 int argstr\(int, char**\);) 179.1091 Tj -0 -427.2012 Td -(0342 int fetchint\(struct proc*, uint, int*\);) 244.6368 Tj -0 -436.6946 Td -(0343 int fetchstr\(struct proc*, uint, char**\);) 253.3738 Tj -0 -446.1879 Td -(0344 void syscall\(void\);) 152.898 Tj -0 -455.6813 Td -(0345 ) 21.8426 Tj -0 -465.1747 Td -(0346 // timer.c) 65.5277 Tj -0 -474.668 Td -(0347 void timerinit\(void\);) 161.635 Tj -0 -484.1614 Td -(0348 ) 21.8426 Tj -0 -493.6547 Td -(0349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 03) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/defs.h Page 4) 161.635 Tj -0 -28.4801 Td -(0350 // trap.c) 61.1592 Tj -0 -37.9735 Td -(0351 void idtinit\(void\);) 152.898 Tj -0 -47.4668 Td -(0352 extern int ticks;) 117.9499 Tj -0 -56.9602 Td -(0353 void tvinit\(void\);) 148.5295 Tj -0 -66.4535 Td -(0354 extern struct spinlock tickslock;) 166.0035 Tj -0 -75.9469 Td -(0355 ) 21.8426 Tj -0 -85.4403 Td -(0356 // uart.c) 61.1592 Tj -0 -94.9336 Td -(0357 void uartinit\(void\);) 157.2665 Tj -0 -104.427 Td -(0358 void uartintr\(void\);) 157.2665 Tj -0 -113.9203 Td -(0359 void uartputc\(int\);) 152.898 Tj -0 -123.4137 Td -(0360 ) 21.8426 Tj -0 -132.9071 Td -(0361 // number of elements in fixed-size array) 200.9517 Tj -0 -142.4004 Td -(0362 #define NELEM\(x\) \(sizeof\(x\)/sizeof\(\(x\)[0]\)\)) 209.6887 Tj -0 -151.8938 Td -(0363 ) 21.8426 Tj -0 -161.3871 Td -(0364 ) 21.8426 Tj -0 -170.8805 Td -(0365 ) 21.8426 Tj -0 -180.3739 Td -(0366 ) 21.8426 Tj -0 -189.8672 Td -(0367 ) 21.8426 Tj -0 -199.3606 Td -(0368 ) 21.8426 Tj -0 -208.8539 Td -(0369 ) 21.8426 Tj -0 -218.3473 Td -(0370 ) 21.8426 Tj -0 -227.8407 Td -(0371 ) 21.8426 Tj -0 -237.334 Td -(0372 ) 21.8426 Tj -0 -246.8274 Td -(0373 ) 21.8426 Tj -0 -256.3207 Td -(0374 ) 21.8426 Tj -0 -265.8141 Td -(0375 ) 21.8426 Tj -0 -275.3075 Td -(0376 ) 21.8426 Tj -0 -284.8008 Td -(0377 ) 21.8426 Tj -0 -294.2942 Td -(0378 ) 21.8426 Tj -0 -303.7875 Td -(0379 ) 21.8426 Tj -0 -313.2809 Td -(0380 ) 21.8426 Tj -0 -322.7743 Td -(0381 ) 21.8426 Tj -0 -332.2676 Td -(0382 ) 21.8426 Tj -0 -341.761 Td -(0383 ) 21.8426 Tj -0 -351.2543 Td -(0384 ) 21.8426 Tj -0 -360.7477 Td -(0385 ) 21.8426 Tj -0 -370.2411 Td -(0386 ) 21.8426 Tj -0 -379.7344 Td -(0387 ) 21.8426 Tj -0 -389.2278 Td -(0388 ) 21.8426 Tj -0 -398.7211 Td -(0389 ) 21.8426 Tj -0 -408.2145 Td -(0390 ) 21.8426 Tj -0 -417.7079 Td -(0391 ) 21.8426 Tj -0 -427.2012 Td -(0392 ) 21.8426 Tj -0 -436.6946 Td -(0393 ) 21.8426 Tj -0 -446.1879 Td -(0394 ) 21.8426 Tj -0 -455.6813 Td -(0395 ) 21.8426 Tj -0 -465.1747 Td -(0396 ) 21.8426 Tj -0 -474.668 Td -(0397 ) 21.8426 Tj -0 -484.1614 Td -(0398 ) 21.8426 Tj -0 -493.6547 Td -(0399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 03) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 11 11 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/x86.h Page 1) 157.2665 Tj -0 -28.4801 Td -(0400 // Routines to let C code use special x86 instructions.) 262.1109 Tj -0 -37.9735 Td -(0401 ) 21.8426 Tj -0 -47.4668 Td -(0402 static inline uchar) 104.8443 Tj -0 -56.9602 Td -(0403 inb\(ushort port\)) 91.7388 Tj -0 -66.4535 Td -(0404 {) 26.2111 Tj -0 -75.9469 Td -(0405 uchar data;) 78.6333 Tj -0 -85.4403 Td -(0406 ) 21.8426 Tj -0 -94.9336 Td -(0407 asm volatile\("in %1,%0" : "=a" \(data\) : "d" \(port\)\)\ -;) 257.7424 Tj -0 -104.427 Td -(0408 return data;) 83.0018 Tj -0 -113.9203 Td -(0409 }) 26.2111 Tj -0 -123.4137 Td -(0410 ) 21.8426 Tj -0 -132.9071 Td -(0411 static inline void) 100.4758 Tj -0 -142.4004 Td -(0412 insl\(int port, void *addr, int cnt\)) 174.7406 Tj -0 -151.8938 Td -(0413 {) 26.2111 Tj -0 -161.3871 Td -(0414 asm volatile\("cld; rep insl" :) 161.635 Tj -0 -170.8805 Td -(0415 "=D" \(addr\), "=c" \(cnt\) :) 196.5831 Tj -0 -180.3739 Td -(0416 "d" \(port\), "0" \(addr\), "1" \(cnt\) :) 240.2683 Tj -0 -189.8672 Td -(0417 "memory", "cc"\);) 157.2665 Tj -0 -199.3606 Td -(0418 }) 26.2111 Tj -0 -208.8539 Td -(0419 ) 21.8426 Tj -0 -218.3473 Td -(0420 static inline void) 100.4758 Tj -0 -227.8407 Td -(0421 outb\(ushort port, uchar data\)) 148.5295 Tj -0 -237.334 Td -(0422 {) 26.2111 Tj -0 -246.8274 Td -(0423 asm volatile\("out %0,%1" : : "a" \(data\), "d" \(port\)\ -\);) 262.1109 Tj -0 -256.3207 Td -(0424 }) 26.2111 Tj -0 -265.8141 Td -(0425 ) 21.8426 Tj -0 -275.3075 Td -(0426 static inline void) 100.4758 Tj -0 -284.8008 Td -(0427 outw\(ushort port, ushort data\)) 152.898 Tj -0 -294.2942 Td -(0428 {) 26.2111 Tj -0 -303.7875 Td -(0429 asm volatile\("out %0,%1" : : "a" \(data\), "d" \(port\)\ -\);) 262.1109 Tj -0 -313.2809 Td -(0430 }) 26.2111 Tj -0 -322.7743 Td -(0431 ) 21.8426 Tj -0 -332.2676 Td -(0432 static inline void) 100.4758 Tj -0 -341.761 Td -(0433 outsl\(int port, const void *addr, int cnt\)) 205.3202 Tj -0 -351.2543 Td -(0434 {) 26.2111 Tj -0 -360.7477 Td -(0435 asm volatile\("cld; rep outsl" :) 166.0035 Tj -0 -370.2411 Td -(0436 "=S" \(addr\), "=c" \(cnt\) :) 196.5831 Tj -0 -379.7344 Td -(0437 "d" \(port\), "0" \(addr\), "1" \(cnt\) :) 240.2683 Tj -0 -389.2278 Td -(0438 "cc"\);) 113.5814 Tj -0 -398.7211 Td -(0439 }) 26.2111 Tj -0 -408.2145 Td -(0440 ) 21.8426 Tj -0 -417.7079 Td -(0441 static inline void) 100.4758 Tj -0 -427.2012 Td -(0442 stosb\(void *addr, int data, int cnt\)) 179.1091 Tj -0 -436.6946 Td -(0443 {) 26.2111 Tj -0 -446.1879 Td -(0444 asm volatile\("cld; rep stosb" :) 166.0035 Tj -0 -455.6813 Td -(0445 "=D" \(addr\), "=c" \(cnt\) :) 196.5831 Tj -0 -465.1747 Td -(0446 "0" \(addr\), "1" \(cnt\), "a" \(data\) :) 240.2683 Tj -0 -474.668 Td -(0447 "memory", "cc"\);) 157.2665 Tj -0 -484.1614 Td -(0448 }) 26.2111 Tj -0 -493.6547 Td -(0449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 04) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/x86.h Page 2) 157.2665 Tj -0 -28.4801 Td -(0450 struct segdesc;) 87.3703 Tj -0 -37.9735 Td -(0451 ) 21.8426 Tj -0 -47.4668 Td -(0452 static inline void) 100.4758 Tj -0 -56.9602 Td -(0453 lgdt\(struct segdesc *p, int size\)) 166.0035 Tj -0 -66.4535 Td -(0454 {) 26.2111 Tj -0 -75.9469 Td -(0455 volatile ushort pd[3];) 126.6869 Tj -0 -85.4403 Td -(0456 ) 21.8426 Tj -0 -94.9336 Td -(0457 pd[0] = size-1;) 96.1073 Tj -0 -104.427 Td -(0458 pd[1] = \(uint\)p;) 100.4758 Tj -0 -113.9203 Td -(0459 pd[2] = \(uint\)p >> 16;) 126.6869 Tj -0 -123.4137 Td -(0460 ) 21.8426 Tj -0 -132.9071 Td -(0461 asm volatile\("lgdt \(%0\)" : : "r" \(pd\)\);) 200.9517 Tj -0 -142.4004 Td -(0462 }) 26.2111 Tj -0 -151.8938 Td -(0463 ) 21.8426 Tj -0 -161.3871 Td -(0464 struct gatedesc;) 91.7388 Tj -0 -170.8805 Td -(0465 ) 21.8426 Tj -0 -180.3739 Td -(0466 static inline void) 100.4758 Tj -0 -189.8672 Td -(0467 lidt\(struct gatedesc *p, int size\)) 170.3721 Tj -0 -199.3606 Td -(0468 {) 26.2111 Tj -0 -208.8539 Td -(0469 volatile ushort pd[3];) 126.6869 Tj -0 -218.3473 Td -(0470 ) 21.8426 Tj -0 -227.8407 Td -(0471 pd[0] = size-1;) 96.1073 Tj -0 -237.334 Td -(0472 pd[1] = \(uint\)p;) 100.4758 Tj -0 -246.8274 Td -(0473 pd[2] = \(uint\)p >> 16;) 126.6869 Tj -0 -256.3207 Td -(0474 ) 21.8426 Tj -0 -265.8141 Td -(0475 asm volatile\("lidt \(%0\)" : : "r" \(pd\)\);) 200.9517 Tj -0 -275.3075 Td -(0476 }) 26.2111 Tj -0 -284.8008 Td -(0477 ) 21.8426 Tj -0 -294.2942 Td -(0478 static inline void) 100.4758 Tj -0 -303.7875 Td -(0479 ltr\(ushort sel\)) 87.3703 Tj -0 -313.2809 Td -(0480 {) 26.2111 Tj -0 -322.7743 Td -(0481 asm volatile\("ltr %0" : : "r" \(sel\)\);) 192.2146 Tj -0 -332.2676 Td -(0482 }) 26.2111 Tj -0 -341.761 Td -(0483 ) 21.8426 Tj -0 -351.2543 Td -(0484 static inline uint) 100.4758 Tj -0 -360.7477 Td -(0485 readeflags\(void\)) 91.7388 Tj -0 -370.2411 Td -(0486 {) 26.2111 Tj -0 -379.7344 Td -(0487 uint eflags;) 83.0018 Tj -0 -389.2278 Td -(0488 asm volatile\("pushfl; popl %0" : "=r" \(eflags\)\);) 240.2683 Tj -0 -398.7211 Td -(0489 return eflags;) 91.7388 Tj -0 -408.2145 Td -(0490 }) 26.2111 Tj -0 -417.7079 Td -(0491 ) 21.8426 Tj -0 -427.2012 Td -(0492 ) 21.8426 Tj -0 -436.6946 Td -(0493 ) 21.8426 Tj -0 -446.1879 Td -(0494 ) 21.8426 Tj -0 -455.6813 Td -(0495 ) 21.8426 Tj -0 -465.1747 Td -(0496 ) 21.8426 Tj -0 -474.668 Td -(0497 ) 21.8426 Tj -0 -484.1614 Td -(0498 ) 21.8426 Tj -0 -493.6547 Td -(0499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 04) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 12 12 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/x86.h Page 3) 157.2665 Tj -0 -28.4801 Td -(0500 static inline uint) 100.4758 Tj -0 -37.9735 Td -(0501 xchg\(volatile uint *addr, uint newval\)) 187.8461 Tj -0 -47.4668 Td -(0502 {) 26.2111 Tj -0 -56.9602 Td -(0503 uint result;) 83.0018 Tj -0 -66.4535 Td -(0504 ) 21.8426 Tj -0 -75.9469 Td -(0505 // The + in "+m" denotes a read-modify-write operand.) 262.1109 Tj -0 -85.4403 Td -(0506 asm volatile\("lock; xchgl %0, %1" :) 183.4776 Tj -0 -94.9336 Td -(0507 "+m" \(*addr\), "=a" \(result\) :) 214.0572 Tj -0 -104.427 Td -(0508 "1" \(newval\) :) 148.5295 Tj -0 -113.9203 Td -(0509 "cc"\);) 113.5814 Tj -0 -123.4137 Td -(0510 return result;) 91.7388 Tj -0 -132.9071 Td -(0511 }) 26.2111 Tj -0 -142.4004 Td -(0512 ) 21.8426 Tj -0 -151.8938 Td -(0513 static inline void) 100.4758 Tj -0 -161.3871 Td -(0514 loadgs\(ushort v\)) 91.7388 Tj -0 -170.8805 Td -(0515 {) 26.2111 Tj -0 -180.3739 Td -(0516 asm volatile\("movw %0, %%gs" : : "r" \(v\)\);) 214.0572 Tj -0 -189.8672 Td -(0517 }) 26.2111 Tj -0 -199.3606 Td -(0518 ) 21.8426 Tj -0 -208.8539 Td -(0519 static inline void) 100.4758 Tj -0 -218.3473 Td -(0520 cli\(void\)) 61.1592 Tj -0 -227.8407 Td -(0521 {) 26.2111 Tj -0 -237.334 Td -(0522 asm volatile\("cli"\);) 117.9499 Tj -0 -246.8274 Td -(0523 }) 26.2111 Tj -0 -256.3207 Td -(0524 ) 21.8426 Tj -0 -265.8141 Td -(0525 static inline void) 100.4758 Tj -0 -275.3075 Td -(0526 sti\(void\)) 61.1592 Tj -0 -284.8008 Td -(0527 {) 26.2111 Tj -0 -294.2942 Td -(0528 asm volatile\("sti"\);) 117.9499 Tj -0 -303.7875 Td -(0529 }) 26.2111 Tj -0 -313.2809 Td -(0530 ) 21.8426 Tj -0 -322.7743 Td -(0531 ) 21.8426 Tj -0 -332.2676 Td -(0532 ) 21.8426 Tj -0 -341.761 Td -(0533 ) 21.8426 Tj -0 -351.2543 Td -(0534 ) 21.8426 Tj -0 -360.7477 Td -(0535 ) 21.8426 Tj -0 -370.2411 Td -(0536 ) 21.8426 Tj -0 -379.7344 Td -(0537 ) 21.8426 Tj -0 -389.2278 Td -(0538 ) 21.8426 Tj -0 -398.7211 Td -(0539 ) 21.8426 Tj -0 -408.2145 Td -(0540 ) 21.8426 Tj -0 -417.7079 Td -(0541 ) 21.8426 Tj -0 -427.2012 Td -(0542 ) 21.8426 Tj -0 -436.6946 Td -(0543 ) 21.8426 Tj -0 -446.1879 Td -(0544 ) 21.8426 Tj -0 -455.6813 Td -(0545 ) 21.8426 Tj -0 -465.1747 Td -(0546 ) 21.8426 Tj -0 -474.668 Td -(0547 ) 21.8426 Tj -0 -484.1614 Td -(0548 ) 21.8426 Tj -0 -493.6547 Td -(0549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 05) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/x86.h Page 4) 157.2665 Tj -0 -28.4801 Td -(0550 // Layout of the trap frame built on the stack by the) 253.3738 Tj -0 -37.9735 Td -(0551 // hardware and by trapasm.S, and passed to trap\(\).) 244.6368 Tj -0 -47.4668 Td -(0552 struct trapframe {) 100.4758 Tj -0 -56.9602 Td -(0553 // registers as pushed by pusha) 166.0035 Tj -0 -66.4535 Td -(0554 uint edi;) 69.8962 Tj -0 -75.9469 Td -(0555 uint esi;) 69.8962 Tj -0 -85.4403 Td -(0556 uint ebp;) 69.8962 Tj -0 -94.9336 Td -(0557 uint oesp; // useless & ignored) 187.8461 Tj -0 -104.427 Td -(0558 uint ebx;) 69.8962 Tj -0 -113.9203 Td -(0559 uint edx;) 69.8962 Tj -0 -123.4137 Td -(0560 uint ecx;) 69.8962 Tj -0 -132.9071 Td -(0561 uint eax;) 69.8962 Tj -0 -142.4004 Td -(0562 ) 21.8426 Tj -0 -151.8938 Td -(0563 // rest of trap frame) 122.3184 Tj -0 -161.3871 Td -(0564 ushort gs;) 74.2647 Tj -0 -170.8805 Td -(0565 ushort padding1;) 100.4758 Tj -0 -180.3739 Td -(0566 ushort fs;) 74.2647 Tj -0 -189.8672 Td -(0567 ushort padding2;) 100.4758 Tj -0 -199.3606 Td -(0568 ushort es;) 74.2647 Tj -0 -208.8539 Td -(0569 ushort padding3;) 100.4758 Tj -0 -218.3473 Td -(0570 ushort ds;) 74.2647 Tj -0 -227.8407 Td -(0571 ushort padding4;) 100.4758 Tj -0 -237.334 Td -(0572 uint trapno;) 83.0018 Tj -0 -246.8274 Td -(0573 ) 21.8426 Tj -0 -256.3207 Td -(0574 // below here defined by x86 hardware) 192.2146 Tj -0 -265.8141 Td -(0575 uint err;) 69.8962 Tj -0 -275.3075 Td -(0576 uint eip;) 69.8962 Tj -0 -284.8008 Td -(0577 ushort cs;) 74.2647 Tj -0 -294.2942 Td -(0578 ushort padding5;) 100.4758 Tj -0 -303.7875 Td -(0579 uint eflags;) 83.0018 Tj -0 -313.2809 Td -(0580 ) 21.8426 Tj -0 -322.7743 Td -(0581 // below here only when crossing rings, such as from use\ -r to kernel) 323.2701 Tj -0 -332.2676 Td -(0582 uint esp;) 69.8962 Tj -0 -341.761 Td -(0583 ushort ss;) 74.2647 Tj -0 -351.2543 Td -(0584 ushort padding6;) 100.4758 Tj -0 -360.7477 Td -(0585 };) 30.5796 Tj -0 -370.2411 Td -(0586 ) 21.8426 Tj -0 -379.7344 Td -(0587 ) 21.8426 Tj -0 -389.2278 Td -(0588 ) 21.8426 Tj -0 -398.7211 Td -(0589 ) 21.8426 Tj -0 -408.2145 Td -(0590 ) 21.8426 Tj -0 -417.7079 Td -(0591 ) 21.8426 Tj -0 -427.2012 Td -(0592 ) 21.8426 Tj -0 -436.6946 Td -(0593 ) 21.8426 Tj -0 -446.1879 Td -(0594 ) 21.8426 Tj -0 -455.6813 Td -(0595 ) 21.8426 Tj -0 -465.1747 Td -(0596 ) 21.8426 Tj -0 -474.668 Td -(0597 ) 21.8426 Tj -0 -484.1614 Td -(0598 ) 21.8426 Tj -0 -493.6547 Td -(0599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 05) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 13 13 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/asm.h Page 1) 157.2665 Tj -0 -28.4801 Td -(0600 //) 30.5796 Tj -0 -37.9735 Td -(0601 // assembler macros to create x86 segments) 205.3202 Tj -0 -47.4668 Td -(0602 //) 30.5796 Tj -0 -56.9602 Td -(0603 ) 21.8426 Tj -0 -66.4535 Td -(0604 #define SEG_NULLASM \ - \\) 305.796 Tj -0 -75.9469 Td -(0605 .word 0, 0; \ - \\) 305.796 Tj -0 -85.4403 Td -(0606 .byte 0, 0, 0, 0) 126.6869 Tj -0 -94.9336 Td -(0607 ) 21.8426 Tj -0 -104.427 Td -(0608 #define SEG_ASM\(type,base,lim\) \ - \\) 305.796 Tj -0 -113.9203 Td -(0609 .word \(\(\(lim\) >> 12\) & 0xffff\), \(\(base\) &\ - 0xffff\); \\) 305.796 Tj -0 -123.4137 Td -(0610 .byte \(\(\(base\) >> 16\) & 0xff\), \(0x90 | \(ty\ -pe\)\), \\) 305.796 Tj -0 -132.9071 Td -(0611 \(0xC0 | \(\(\(lim\) >> 28\) & 0xf\)\), \(\ -\(\(base\) >> 24\) & 0xff\)) 332.0071 Tj -0 -142.4004 Td -(0612 ) 21.8426 Tj -0 -151.8938 Td -(0613 #define STA_X 0x8 // Executable segment) 235.8998 Tj -0 -161.3871 Td -(0614 #define STA_E 0x4 // Expand down \(non-executabl\ -e segments\)) 318.9016 Tj -0 -170.8805 Td -(0615 #define STA_C 0x4 // Conforming code segment \(e\ -xecutable only\)) 336.3756 Tj -0 -180.3739 Td -(0616 #define STA_W 0x2 // Writeable \(non-executable \ -segments\)) 310.1645 Tj -0 -189.8672 Td -(0617 #define STA_R 0x2 // Readable \(executable segme\ -nts\)) 288.322 Tj -0 -199.3606 Td -(0618 #define STA_A 0x1 // Accessed) 192.2146 Tj -0 -208.8539 Td -(0619 ) 21.8426 Tj -0 -218.3473 Td -(0620 ) 21.8426 Tj -0 -227.8407 Td -(0621 ) 21.8426 Tj -0 -237.334 Td -(0622 ) 21.8426 Tj -0 -246.8274 Td -(0623 ) 21.8426 Tj -0 -256.3207 Td -(0624 ) 21.8426 Tj -0 -265.8141 Td -(0625 ) 21.8426 Tj -0 -275.3075 Td -(0626 ) 21.8426 Tj -0 -284.8008 Td -(0627 ) 21.8426 Tj -0 -294.2942 Td -(0628 ) 21.8426 Tj -0 -303.7875 Td -(0629 ) 21.8426 Tj -0 -313.2809 Td -(0630 ) 21.8426 Tj -0 -322.7743 Td -(0631 ) 21.8426 Tj -0 -332.2676 Td -(0632 ) 21.8426 Tj -0 -341.761 Td -(0633 ) 21.8426 Tj -0 -351.2543 Td -(0634 ) 21.8426 Tj -0 -360.7477 Td -(0635 ) 21.8426 Tj -0 -370.2411 Td -(0636 ) 21.8426 Tj -0 -379.7344 Td -(0637 ) 21.8426 Tj -0 -389.2278 Td -(0638 ) 21.8426 Tj -0 -398.7211 Td -(0639 ) 21.8426 Tj -0 -408.2145 Td -(0640 ) 21.8426 Tj -0 -417.7079 Td -(0641 ) 21.8426 Tj -0 -427.2012 Td -(0642 ) 21.8426 Tj -0 -436.6946 Td -(0643 ) 21.8426 Tj -0 -446.1879 Td -(0644 ) 21.8426 Tj -0 -455.6813 Td -(0645 ) 21.8426 Tj -0 -465.1747 Td -(0646 ) 21.8426 Tj -0 -474.668 Td -(0647 ) 21.8426 Tj -0 -484.1614 Td -(0648 ) 21.8426 Tj -0 -493.6547 Td -(0649 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 06) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mmu.h Page 1) 157.2665 Tj -0 -28.4801 Td -(0650 // This file contains definitions for the) 200.9517 Tj -0 -37.9735 Td -(0651 // x86 memory management unit \(MMU\).) 179.1091 Tj -0 -47.4668 Td -(0652 ) 21.8426 Tj -0 -56.9602 Td -(0653 // Eflags register) 100.4758 Tj -0 -66.4535 Td -(0654 #define FL_CF 0x00000001 // Carry Flag) 253.3738 Tj -0 -75.9469 Td -(0655 #define FL_PF 0x00000004 // Parity Flag) 257.7424 Tj -0 -85.4403 Td -(0656 #define FL_AF 0x00000010 // Auxiliary carry\ - Flag) 297.059 Tj -0 -94.9336 Td -(0657 #define FL_ZF 0x00000040 // Zero Flag) 249.0053 Tj -0 -104.427 Td -(0658 #define FL_SF 0x00000080 // Sign Flag) 249.0053 Tj -0 -113.9203 Td -(0659 #define FL_TF 0x00000100 // Trap Flag) 249.0053 Tj -0 -123.4137 Td -(0660 #define FL_IF 0x00000200 // Interrupt Enabl\ -e) 279.5849 Tj -0 -132.9071 Td -(0661 #define FL_DF 0x00000400 // Direction Flag) 270.8479 Tj -0 -142.4004 Td -(0662 #define FL_OF 0x00000800 // Overflow Flag) 266.4794 Tj -0 -151.8938 Td -(0663 #define FL_IOPL_MASK 0x00003000 // I/O Privilege L\ -evel bitmask) 327.6386 Tj -0 -161.3871 Td -(0664 #define FL_IOPL_0 0x00000000 // IOPL == 0) 257.7424 Tj -0 -170.8805 Td -(0665 #define FL_IOPL_1 0x00001000 // IOPL == 1) 257.7424 Tj -0 -180.3739 Td -(0666 #define FL_IOPL_2 0x00002000 // IOPL == 2) 257.7424 Tj -0 -189.8672 Td -(0667 #define FL_IOPL_3 0x00003000 // IOPL == 3) 257.7424 Tj -0 -199.3606 Td -(0668 #define FL_NT 0x00004000 // Nested Task) 257.7424 Tj -0 -208.8539 Td -(0669 #define FL_RF 0x00010000 // Resume Flag) 257.7424 Tj -0 -218.3473 Td -(0670 #define FL_VM 0x00020000 // Virtual 8086 mo\ -de) 283.9534 Tj -0 -227.8407 Td -(0671 #define FL_AC 0x00040000 // Alignment Check) 275.2164 Tj -0 -237.334 Td -(0672 #define FL_VIF 0x00080000 // Virtual Interru\ -pt Flag) 305.796 Tj -0 -246.8274 Td -(0673 #define FL_VIP 0x00100000 // Virtual Interru\ -pt Pending) 318.9016 Tj -0 -256.3207 Td -(0674 #define FL_ID 0x00200000 // ID flag) 240.2683 Tj -0 -265.8141 Td -(0675 ) 21.8426 Tj -0 -275.3075 Td -(0676 // Segment Descriptor) 113.5814 Tj -0 -284.8008 Td -(0677 struct segdesc {) 91.7388 Tj -0 -294.2942 Td -(0678 uint lim_15_0 : 16; // Low bits of segment limit) 244.6368 Tj -0 -303.7875 Td -(0679 uint base_15_0 : 16; // Low bits of segment base address) 275.2164 Tj -0 -313.2809 Td -(0680 uint base_23_16 : 8; // Middle bits of segment base addr\ -ess) 288.322 Tj -0 -322.7743 Td -(0681 uint type : 4; // Segment type \(see STS_ constant\ -s\)) 279.5849 Tj -0 -332.2676 Td -(0682 uint s : 1; // 0 = system, 1 = application) 253.3738 Tj -0 -341.761 Td -(0683 uint dpl : 2; // Descriptor Privilege Level) 249.0053 Tj -0 -351.2543 Td -(0684 uint p : 1; // Present) 166.0035 Tj -0 -360.7477 Td -(0685 uint lim_19_16 : 4; // High bits of segment limit) 249.0053 Tj -0 -370.2411 Td -(0686 uint avl : 1; // Unused \(available for software \ -use\)) 288.322 Tj -0 -379.7344 Td -(0687 uint rsv1 : 1; // Reserved) 170.3721 Tj -0 -389.2278 Td -(0688 uint db : 1; // 0 = 16-bit segment, 1 = 32-bit s\ -egment) 301.4275 Tj -0 -398.7211 Td -(0689 uint g : 1; // Granularity: limit scaled by 4K \ -when set) 310.1645 Tj -0 -408.2145 Td -(0690 uint base_31_24 : 8; // High bits of segment base addres\ -s) 279.5849 Tj -0 -417.7079 Td -(0691 };) 30.5796 Tj -0 -427.2012 Td -(0692 ) 21.8426 Tj -0 -436.6946 Td -(0693 ) 21.8426 Tj -0 -446.1879 Td -(0694 ) 21.8426 Tj -0 -455.6813 Td -(0695 ) 21.8426 Tj -0 -465.1747 Td -(0696 ) 21.8426 Tj -0 -474.668 Td -(0697 ) 21.8426 Tj -0 -484.1614 Td -(0698 ) 21.8426 Tj -0 -493.6547 Td -(0699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 06) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 14 14 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mmu.h Page 2) 157.2665 Tj -0 -28.4801 Td -(0700 // Normal segment) 96.1073 Tj -0 -37.9735 Td -(0701 #define SEG\(type, base, lim, dpl\) \(struct segdesc\) \ -\\) 262.1109 Tj -0 -47.4668 Td -(0702 { \(\(lim\) >> 12\) & 0xffff, \(uint\)\(base\) & 0xffff, \ - \\) 262.1109 Tj -0 -56.9602 Td -(0703 \(\(uint\)\(base\) >> 16\) & 0xff, type, 1, dpl, 1, \ - \\) 262.1109 Tj -0 -66.4535 Td -(0704 \(uint\)\(lim\) >> 28, 0, 0, 1, 1, \(uint\)\(base\) >> 2\ -4 }) 253.3738 Tj -0 -75.9469 Td -(0705 ) 21.8426 Tj -0 -85.4403 Td -(0706 #define SEG16\(type, base, lim, dpl\) \(struct segdesc\) \ -\\) 262.1109 Tj -0 -94.9336 Td -(0707 { \(lim\) & 0xffff, \(uint\)\(base\) & 0xffff, \ - \\) 262.1109 Tj -0 -104.427 Td -(0708 \(\(uint\)\(base\) >> 16\) & 0xff, type, 1, dpl, 1, \ - \\) 262.1109 Tj -0 -113.9203 Td -(0709 \(uint\)\(lim\) >> 16, 0, 0, 1, 0, \(uint\)\(base\) >> 2\ -4 }) 253.3738 Tj -0 -123.4137 Td -(0710 ) 21.8426 Tj -0 -132.9071 Td -(0711 #define DPL_USER 0x3 // User DPL) 192.2146 Tj -0 -142.4004 Td -(0712 ) 21.8426 Tj -0 -151.8938 Td -(0713 // Application segment type bits) 161.635 Tj -0 -161.3871 Td -(0714 #define STA_X 0x8 // Executable segment) 235.8998 Tj -0 -170.8805 Td -(0715 #define STA_E 0x4 // Expand down \(non-executabl\ -e segments\)) 318.9016 Tj -0 -180.3739 Td -(0716 #define STA_C 0x4 // Conforming code segment \(e\ -xecutable only\)) 336.3756 Tj -0 -189.8672 Td -(0717 #define STA_W 0x2 // Writeable \(non-executable \ -segments\)) 310.1645 Tj -0 -199.3606 Td -(0718 #define STA_R 0x2 // Readable \(executable segme\ -nts\)) 288.322 Tj -0 -208.8539 Td -(0719 #define STA_A 0x1 // Accessed) 192.2146 Tj -0 -218.3473 Td -(0720 ) 21.8426 Tj -0 -227.8407 Td -(0721 // System segment type bits) 139.7925 Tj -0 -237.334 Td -(0722 #define STS_T16A 0x1 // Available 16-bit TSS) 244.6368 Tj -0 -246.8274 Td -(0723 #define STS_LDT 0x2 // Local Descriptor Table) 253.3738 Tj -0 -256.3207 Td -(0724 #define STS_T16B 0x3 // Busy 16-bit TSS) 222.7942 Tj -0 -265.8141 Td -(0725 #define STS_CG16 0x4 // 16-bit Call Gate) 227.1628 Tj -0 -275.3075 Td -(0726 #define STS_TG 0x5 // Task Gate / Coum Transmitio\ -ns) 283.9534 Tj -0 -284.8008 Td -(0727 #define STS_IG16 0x6 // 16-bit Interrupt Gate) 249.0053 Tj -0 -294.2942 Td -(0728 #define STS_TG16 0x7 // 16-bit Trap Gate) 227.1628 Tj -0 -303.7875 Td -(0729 #define STS_T32A 0x9 // Available 32-bit TSS) 244.6368 Tj -0 -313.2809 Td -(0730 #define STS_T32B 0xB // Busy 32-bit TSS) 222.7942 Tj -0 -322.7743 Td -(0731 #define STS_CG32 0xC // 32-bit Call Gate) 227.1628 Tj -0 -332.2676 Td -(0732 #define STS_IG32 0xE // 32-bit Interrupt Gate) 249.0053 Tj -0 -341.761 Td -(0733 #define STS_TG32 0xF // 32-bit Trap Gate) 227.1628 Tj -0 -351.2543 Td -(0734 ) 21.8426 Tj -0 -360.7477 Td -(0735 ) 21.8426 Tj -0 -370.2411 Td -(0736 ) 21.8426 Tj -0 -379.7344 Td -(0737 ) 21.8426 Tj -0 -389.2278 Td -(0738 ) 21.8426 Tj -0 -398.7211 Td -(0739 ) 21.8426 Tj -0 -408.2145 Td -(0740 ) 21.8426 Tj -0 -417.7079 Td -(0741 ) 21.8426 Tj -0 -427.2012 Td -(0742 ) 21.8426 Tj -0 -436.6946 Td -(0743 ) 21.8426 Tj -0 -446.1879 Td -(0744 ) 21.8426 Tj -0 -455.6813 Td -(0745 ) 21.8426 Tj -0 -465.1747 Td -(0746 ) 21.8426 Tj -0 -474.668 Td -(0747 ) 21.8426 Tj -0 -484.1614 Td -(0748 ) 21.8426 Tj -0 -493.6547 Td -(0749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 07) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mmu.h Page 3) 157.2665 Tj -0 -28.4801 Td -(0750 // Task state segment format) 144.161 Tj -0 -37.9735 Td -(0751 struct taskstate {) 100.4758 Tj -0 -47.4668 Td -(0752 uint link; // Old ts selector) 192.2146 Tj -0 -56.9602 Td -(0753 uint esp0; // Stack pointers and segment selecto\ -rs) 283.9534 Tj -0 -66.4535 Td -(0754 ushort ss0; // after an increase in privilege l\ -evel) 292.6905 Tj -0 -75.9469 Td -(0755 ushort padding1;) 100.4758 Tj -0 -85.4403 Td -(0756 uint *esp1;) 78.6333 Tj -0 -94.9336 Td -(0757 ushort ss1;) 78.6333 Tj -0 -104.427 Td -(0758 ushort padding2;) 100.4758 Tj -0 -113.9203 Td -(0759 uint *esp2;) 78.6333 Tj -0 -123.4137 Td -(0760 ushort ss2;) 78.6333 Tj -0 -132.9071 Td -(0761 ushort padding3;) 100.4758 Tj -0 -142.4004 Td -(0762 void *cr3; // Page directory base) 209.6887 Tj -0 -151.8938 Td -(0763 uint *eip; // Saved state from last task switch) 270.8479 Tj -0 -161.3871 Td -(0764 uint eflags;) 83.0018 Tj -0 -170.8805 Td -(0765 uint eax; // More saved state \(registers\)) 249.0053 Tj -0 -180.3739 Td -(0766 uint ecx;) 69.8962 Tj -0 -189.8672 Td -(0767 uint edx;) 69.8962 Tj -0 -199.3606 Td -(0768 uint ebx;) 69.8962 Tj -0 -208.8539 Td -(0769 uint *esp;) 74.2647 Tj -0 -218.3473 Td -(0770 uint *ebp;) 74.2647 Tj -0 -227.8407 Td -(0771 uint esi;) 69.8962 Tj -0 -237.334 Td -(0772 uint edi;) 69.8962 Tj -0 -246.8274 Td -(0773 ushort es; // Even more saved state \(segment se\ -lectors\)) 305.796 Tj -0 -256.3207 Td -(0774 ushort padding4;) 100.4758 Tj -0 -265.8141 Td -(0775 ushort cs;) 74.2647 Tj -0 -275.3075 Td -(0776 ushort padding5;) 100.4758 Tj -0 -284.8008 Td -(0777 ushort ss;) 74.2647 Tj -0 -294.2942 Td -(0778 ushort padding6;) 100.4758 Tj -0 -303.7875 Td -(0779 ushort ds;) 74.2647 Tj -0 -313.2809 Td -(0780 ushort padding7;) 100.4758 Tj -0 -322.7743 Td -(0781 ushort fs;) 74.2647 Tj -0 -332.2676 Td -(0782 ushort padding8;) 100.4758 Tj -0 -341.761 Td -(0783 ushort gs;) 74.2647 Tj -0 -351.2543 Td -(0784 ushort padding9;) 100.4758 Tj -0 -360.7477 Td -(0785 ushort ldt;) 78.6333 Tj -0 -370.2411 Td -(0786 ushort padding10;) 104.8443 Tj -0 -379.7344 Td -(0787 ushort t; // Trap on task switch) 209.6887 Tj -0 -389.2278 Td -(0788 ushort iomb; // I/O map base address) 214.0572 Tj -0 -398.7211 Td -(0789 };) 30.5796 Tj -0 -408.2145 Td -(0790 ) 21.8426 Tj -0 -417.7079 Td -(0791 ) 21.8426 Tj -0 -427.2012 Td -(0792 ) 21.8426 Tj -0 -436.6946 Td -(0793 ) 21.8426 Tj -0 -446.1879 Td -(0794 ) 21.8426 Tj -0 -455.6813 Td -(0795 ) 21.8426 Tj -0 -465.1747 Td -(0796 ) 21.8426 Tj -0 -474.668 Td -(0797 ) 21.8426 Tj -0 -484.1614 Td -(0798 ) 21.8426 Tj -0 -493.6547 Td -(0799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 07) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 15 15 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mmu.h Page 4) 157.2665 Tj -0 -28.4801 Td -(0800 // Gate descriptors for interrupts and traps) 214.0572 Tj -0 -37.9735 Td -(0801 struct gatedesc {) 96.1073 Tj -0 -47.4668 Td -(0802 uint off_15_0 : 16; // low 16 bits of offset in segmen\ -t) 279.5849 Tj -0 -56.9602 Td -(0803 uint cs : 16; // code segment selector) 231.5313 Tj -0 -66.4535 Td -(0804 uint args : 5; // # args, 0 for interrupt/trap ga\ -tes) 288.322 Tj -0 -75.9469 Td -(0805 uint rsv1 : 3; // reserved\(should be zero I gues\ -s\)) 279.5849 Tj -0 -85.4403 Td -(0806 uint type : 4; // type\(STS_{TG,IG32,TG32}\)) 244.6368 Tj -0 -94.9336 Td -(0807 uint s : 1; // must be 0 \(system\)) 218.4257 Tj -0 -104.427 Td -(0808 uint dpl : 2; // descriptor\(meaning new\) privi\ -lege level) 310.1645 Tj -0 -113.9203 Td -(0809 uint p : 1; // Present) 170.3721 Tj -0 -123.4137 Td -(0810 uint off_31_16 : 16; // high bits of offset in segment) 270.8479 Tj -0 -132.9071 Td -(0811 };) 30.5796 Tj -0 -142.4004 Td -(0812 ) 21.8426 Tj -0 -151.8938 Td -(0813 // Set up a normal interrupt/trap gate descriptor.) 240.2683 Tj -0 -161.3871 Td -(0814 // - istrap: 1 for a trap \(= exception\) gate, 0 for an i\ -nterrupt gate.) 327.6386 Tj -0 -170.8805 Td -(0815 // interrupt gate clears FL_IF, trap gate leaves FL_IF a\ -lone) 292.6905 Tj -0 -180.3739 Td -(0816 // - sel: Code segment selector for interrupt/trap handler) 275.2164 Tj -0 -189.8672 Td -(0817 // - off: Offset in code segment for interrupt/trap handle\ -r) 279.5849 Tj -0 -199.3606 Td -(0818 // - dpl: Descriptor Privilege Level -) 187.8461 Tj -0 -208.8539 Td -(0819 // the privilege level required for software to inv\ -oke) 288.322 Tj -0 -218.3473 Td -(0820 // this interrupt/trap gate explicitly using an int\ - instruction.) 332.0071 Tj -0 -227.8407 Td -(0821 #define SETGATE\(gate, istrap, sel, off, d\) \ - \\) 279.5849 Tj -0 -237.334 Td -(0822 { \ -\\) 279.5849 Tj -0 -246.8274 Td -(0823 \(gate\).off_15_0 = \(uint\) \(off\) & 0xffff; \ - \\) 279.5849 Tj -0 -256.3207 Td -(0824 \(gate\).cs = \(sel\); \ - \\) 279.5849 Tj -0 -265.8141 Td -(0825 \(gate\).args = 0; \ - \\) 279.5849 Tj -0 -275.3075 Td -(0826 \(gate\).rsv1 = 0; \ - \\) 279.5849 Tj -0 -284.8008 Td -(0827 \(gate\).type = \(istrap\) ? STS_TG32 : STS_IG32; \ - \\) 279.5849 Tj -0 -294.2942 Td -(0828 \(gate\).s = 0; \ - \\) 279.5849 Tj -0 -303.7875 Td -(0829 \(gate\).dpl = \(d\); \ - \\) 279.5849 Tj -0 -313.2809 Td -(0830 \(gate\).p = 1; \ - \\) 279.5849 Tj -0 -322.7743 Td -(0831 \(gate\).off_31_16 = \(uint\) \(off\) >> 16; \ - \\) 279.5849 Tj -0 -332.2676 Td -(0832 }) 26.2111 Tj -0 -341.761 Td -(0833 ) 21.8426 Tj -0 -351.2543 Td -(0834 ) 21.8426 Tj -0 -360.7477 Td -(0835 ) 21.8426 Tj -0 -370.2411 Td -(0836 ) 21.8426 Tj -0 -379.7344 Td -(0837 ) 21.8426 Tj -0 -389.2278 Td -(0838 ) 21.8426 Tj -0 -398.7211 Td -(0839 ) 21.8426 Tj -0 -408.2145 Td -(0840 ) 21.8426 Tj -0 -417.7079 Td -(0841 ) 21.8426 Tj -0 -427.2012 Td -(0842 ) 21.8426 Tj -0 -436.6946 Td -(0843 ) 21.8426 Tj -0 -446.1879 Td -(0844 ) 21.8426 Tj -0 -455.6813 Td -(0845 ) 21.8426 Tj -0 -465.1747 Td -(0846 ) 21.8426 Tj -0 -474.668 Td -(0847 ) 21.8426 Tj -0 -484.1614 Td -(0848 ) 21.8426 Tj -0 -493.6547 Td -(0849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 08) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/elf.h Page 1) 157.2665 Tj -0 -28.4801 Td -(0850 // Format of an ELF executable file) 174.7406 Tj -0 -37.9735 Td -(0851 ) 21.8426 Tj -0 -47.4668 Td -(0852 #define ELF_MAGIC 0x464C457FU // "\\x7FELF" in little end\ -ian) 283.9534 Tj -0 -56.9602 Td -(0853 ) 21.8426 Tj -0 -66.4535 Td -(0854 // File header) 83.0018 Tj -0 -75.9469 Td -(0855 struct elfhdr {) 87.3703 Tj -0 -85.4403 Td -(0856 uint magic; // must equal ELF_MAGIC) 187.8461 Tj -0 -94.9336 Td -(0857 uchar elf[12];) 91.7388 Tj -0 -104.427 Td -(0858 ushort type;) 83.0018 Tj -0 -113.9203 Td -(0859 ushort machine;) 96.1073 Tj -0 -123.4137 Td -(0860 uint version;) 87.3703 Tj -0 -132.9071 Td -(0861 uint entry;) 78.6333 Tj -0 -142.4004 Td -(0862 uint phoff;) 78.6333 Tj -0 -151.8938 Td -(0863 uint shoff;) 78.6333 Tj -0 -161.3871 Td -(0864 uint flags;) 78.6333 Tj -0 -170.8805 Td -(0865 ushort ehsize;) 91.7388 Tj -0 -180.3739 Td -(0866 ushort phentsize;) 104.8443 Tj -0 -189.8672 Td -(0867 ushort phnum;) 87.3703 Tj -0 -199.3606 Td -(0868 ushort shentsize;) 104.8443 Tj -0 -208.8539 Td -(0869 ushort shnum;) 87.3703 Tj -0 -218.3473 Td -(0870 ushort shstrndx;) 100.4758 Tj -0 -227.8407 Td -(0871 };) 30.5796 Tj -0 -237.334 Td -(0872 ) 21.8426 Tj -0 -246.8274 Td -(0873 // Program section header) 131.0554 Tj -0 -256.3207 Td -(0874 struct proghdr {) 91.7388 Tj -0 -265.8141 Td -(0875 uint type;) 74.2647 Tj -0 -275.3075 Td -(0876 uint offset;) 83.0018 Tj -0 -284.8008 Td -(0877 uint va;) 65.5277 Tj -0 -294.2942 Td -(0878 uint pa;) 65.5277 Tj -0 -303.7875 Td -(0879 uint filesz;) 83.0018 Tj -0 -313.2809 Td -(0880 uint memsz;) 78.6333 Tj -0 -322.7743 Td -(0881 uint flags;) 78.6333 Tj -0 -332.2676 Td -(0882 uint align;) 78.6333 Tj -0 -341.761 Td -(0883 };) 30.5796 Tj -0 -351.2543 Td -(0884 ) 21.8426 Tj -0 -360.7477 Td -(0885 // Values for Proghdr type) 135.4239 Tj -0 -370.2411 Td -(0886 #define ELF_PROG_LOAD 1) 166.0035 Tj -0 -379.7344 Td -(0887 ) 21.8426 Tj -0 -389.2278 Td -(0888 // Flag bits for Proghdr flags) 152.898 Tj -0 -398.7211 Td -(0889 #define ELF_PROG_FLAG_EXEC 1) 166.0035 Tj -0 -408.2145 Td -(0890 #define ELF_PROG_FLAG_WRITE 2) 166.0035 Tj -0 -417.7079 Td -(0891 #define ELF_PROG_FLAG_READ 4) 166.0035 Tj -0 -427.2012 Td -(0892 ) 21.8426 Tj -0 -436.6946 Td -(0893 ) 21.8426 Tj -0 -446.1879 Td -(0894 ) 21.8426 Tj -0 -455.6813 Td -(0895 ) 21.8426 Tj -0 -465.1747 Td -(0896 ) 21.8426 Tj -0 -474.668 Td -(0897 ) 21.8426 Tj -0 -484.1614 Td -(0898 ) 21.8426 Tj -0 -493.6547 Td -(0899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 08) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 16 16 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootasm.S Page 1) 174.7406 Tj -0 -28.4801 Td -(0900 #include "asm.h") 91.7388 Tj -0 -37.9735 Td -(0901 ) 21.8426 Tj -0 -47.4668 Td -(0902 # Start the first CPU: switch to 32-bit protected mode, ju\ -mp into C.) 318.9016 Tj -0 -56.9602 Td -(0903 # The BIOS loads this code from the first sector of the ha\ -rd disk into) 327.6386 Tj -0 -66.4535 Td -(0904 # memory at physical address 0x7c00 and starts executing i\ -n real mode) 323.2701 Tj -0 -75.9469 Td -(0905 # with %cs=0 %ip=7c00.) 117.9499 Tj -0 -85.4403 Td -(0906 ) 21.8426 Tj -0 -94.9336 Td -(0907 #define SEG_KCODE 1 // kernel code) 174.7406 Tj -0 -104.427 Td -(0908 #define SEG_KDATA 2 // kernel data+stack) 200.9517 Tj -0 -113.9203 Td -(0909 ) 21.8426 Tj -0 -123.4137 Td -(0910 #define CR0_PE 1 // protected mode enable bit) 235.8998 Tj -0 -132.9071 Td -(0911 ) 21.8426 Tj -0 -142.4004 Td -(0912 .code16 # Assemble for 16-bit mode) 266.4794 Tj -0 -151.8938 Td -(0913 .globl start) 74.2647 Tj -0 -161.3871 Td -(0914 start:) 48.0537 Tj -0 -170.8805 Td -(0915 cli # Disable interrupts) 240.2683 Tj -0 -180.3739 Td -(0916 ) 21.8426 Tj -0 -189.8672 Td -(0917 # Set up the important data segment registers \(DS, ES, \ -SS\).) 288.322 Tj -0 -199.3606 Td -(0918 xorw %ax,%ax # Segment number zero) 244.6368 Tj -0 -208.8539 Td -(0919 movw %ax,%ds # -> Data Segment) 227.1628 Tj -0 -218.3473 Td -(0920 movw %ax,%es # -> Extra Segment) 231.5313 Tj -0 -227.8407 Td -(0921 movw %ax,%ss # -> Stack Segment) 231.5313 Tj -0 -237.334 Td -(0922 ) 21.8426 Tj -0 -246.8274 Td -(0923 # Enable A20:) 87.3703 Tj -0 -256.3207 Td -(0924 # For backwards compatibility with the earliest PCs, p\ -hysical) 305.796 Tj -0 -265.8141 Td -(0925 # address line 20 is tied low, so that addresses highe\ -r than) 301.4275 Tj -0 -275.3075 Td -(0926 # 1MB wrap around to zero by default. This code undoe\ -s this.) 305.796 Tj -0 -284.8008 Td -(0927 seta20.1:) 61.1592 Tj -0 -294.2942 Td -(0928 inb $0x64,%al # Wait for not busy) 253.3738 Tj -0 -303.7875 Td -(0929 testb $0x2,%al) 100.4758 Tj -0 -313.2809 Td -(0930 jnz seta20.1) 100.4758 Tj -0 -322.7743 Td -(0931 ) 21.8426 Tj -0 -332.2676 Td -(0932 movb $0xd1,%al # 0xd1 -> port 0x64) 253.3738 Tj -0 -341.761 Td -(0933 outb %al,$0x64) 104.8443 Tj -0 -351.2543 Td -(0934 ) 21.8426 Tj -0 -360.7477 Td -(0935 seta20.2:) 61.1592 Tj -0 -370.2411 Td -(0936 inb $0x64,%al # Wait for not busy) 253.3738 Tj -0 -379.7344 Td -(0937 testb $0x2,%al) 100.4758 Tj -0 -389.2278 Td -(0938 jnz seta20.2) 100.4758 Tj -0 -398.7211 Td -(0939 ) 21.8426 Tj -0 -408.2145 Td -(0940 movb $0xdf,%al # 0xdf -> port 0x60) 253.3738 Tj -0 -417.7079 Td -(0941 outb %al,$0x60) 104.8443 Tj -0 -427.2012 Td -(0942 ) 21.8426 Tj -0 -436.6946 Td -(0943 ) 21.8426 Tj -0 -446.1879 Td -(0944 ) 21.8426 Tj -0 -455.6813 Td -(0945 ) 21.8426 Tj -0 -465.1747 Td -(0946 ) 21.8426 Tj -0 -474.668 Td -(0947 ) 21.8426 Tj -0 -484.1614 Td -(0948 ) 21.8426 Tj -0 -493.6547 Td -(0949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 09) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootasm.S Page 2) 174.7406 Tj -0 -28.4801 Td -(0950 # Switch from real to protected mode, using a bootstrap \ -GDT) 288.322 Tj -0 -37.9735 Td -(0951 # and segment translation that makes virtual addresses) 266.4794 Tj -0 -47.4668 Td -(0952 # identical to physical addresses, so that the) 231.5313 Tj -0 -56.9602 Td -(0953 # effective memory map does not change during the switch\ -.) 279.5849 Tj -0 -66.4535 Td -(0954 lgdt gdtdesc) 96.1073 Tj -0 -75.9469 Td -(0955 movl %cr0, %eax) 109.2129 Tj -0 -85.4403 Td -(0956 orl $CR0_PE, %eax) 122.3184 Tj -0 -94.9336 Td -(0957 movl %eax, %cr0) 109.2129 Tj -0 -104.427 Td -(0958 ) 21.8426 Tj -0 -113.9203 Td -(0959 # Jump to next instruction, but in 32-bit code segment.) 270.8479 Tj -0 -123.4137 Td -(0960 # Switches processor into 32-bit mode.) 196.5831 Tj -0 -132.9071 Td -(0961 ljmp $\(SEG_KCODE<<3\), $start32) 174.7406 Tj -0 -142.4004 Td -(0962 ) 21.8426 Tj -0 -151.8938 Td -(0963 .code32 # Assemble for 32-bit mode) 266.4794 Tj -0 -161.3871 Td -(0964 start32:) 56.7907 Tj -0 -170.8805 Td -(0965 # Set up the protected-mode data segment registers) 249.0053 Tj -0 -180.3739 Td -(0966 movw $\(SEG_KDATA<<3\), %ax # Our data segment sel\ -ector) 288.322 Tj -0 -189.8672 Td -(0967 movw %ax, %ds # -> DS: Data Segment) 262.1109 Tj -0 -199.3606 Td -(0968 movw %ax, %es # -> ES: Extra Segment) 266.4794 Tj -0 -208.8539 Td -(0969 movw %ax, %ss # -> SS: Stack Segment) 266.4794 Tj -0 -218.3473 Td -(0970 movw $0, %ax # Zero segments not read\ -y for use) 314.533 Tj -0 -227.8407 Td -(0971 movw %ax, %fs # -> FS) 200.9517 Tj -0 -237.334 Td -(0972 movw %ax, %gs # -> GS) 200.9517 Tj -0 -246.8274 Td -(0973 ) 21.8426 Tj -0 -256.3207 Td -(0974 # Set up the stack pointer and call into C.) 218.4257 Tj -0 -265.8141 Td -(0975 movl $start, %esp) 117.9499 Tj -0 -275.3075 Td -(0976 call bootmain) 100.4758 Tj -0 -284.8008 Td -(0977 ) 21.8426 Tj -0 -294.2942 Td -(0978 # If bootmain returns \(it shouldn't\), trigger a Bochs) 262.1109 Tj -0 -303.7875 Td -(0979 # breakpoint if running under Bochs, then loop.) 235.8998 Tj -0 -313.2809 Td -(0980 movw $0x8a00, %ax # 0x8a00 -> port 0x8a00) 270.8479 Tj -0 -322.7743 Td -(0981 movw %ax, %dx) 100.4758 Tj -0 -332.2676 Td -(0982 outw %ax, %dx) 100.4758 Tj -0 -341.761 Td -(0983 movw $0x8e00, %ax # 0x8e00 -> port 0x8a00) 270.8479 Tj -0 -351.2543 Td -(0984 outw %ax, %dx) 100.4758 Tj -0 -360.7477 Td -(0985 spin:) 43.6851 Tj -0 -370.2411 Td -(0986 jmp spin) 83.0018 Tj -0 -379.7344 Td -(0987 ) 21.8426 Tj -0 -389.2278 Td -(0988 # Bootstrap GDT) 87.3703 Tj -0 -398.7211 Td -(0989 .p2align 2 # force 4 byte a\ -lignment) 310.1645 Tj -0 -408.2145 Td -(0990 gdt:) 39.3166 Tj -0 -417.7079 Td -(0991 SEG_NULLASM # null seg) 249.0053 Tj -0 -427.2012 Td -(0992 SEG_ASM\(STA_X|STA_R, 0x0, 0xffffffff\) # code seg) 249.0053 Tj -0 -436.6946 Td -(0993 SEG_ASM\(STA_W, 0x0, 0xffffffff\) # data seg) 249.0053 Tj -0 -446.1879 Td -(0994 ) 21.8426 Tj -0 -455.6813 Td -(0995 gdtdesc:) 56.7907 Tj -0 -465.1747 Td -(0996 .word \(gdtdesc - gdt - 1\) \ - # sizeof\(gdt\) - 1) 345.1126 Tj -0 -474.668 Td -(0997 .long gdt # address gdt) 262.1109 Tj -0 -484.1614 Td -(0998 ) 21.8426 Tj -0 -493.6547 Td -(0999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 09) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 17 17 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootother.S Page 1) 183.4776 Tj -0 -28.4801 Td -(1000 #include "asm.h") 91.7388 Tj -0 -37.9735 Td -(1001 ) 21.8426 Tj -0 -47.4668 Td -(1002 # Each non-boot CPU \("AP"\) is started up in response to \ -a STARTUP) 305.796 Tj -0 -56.9602 Td -(1003 # IPI from the boot CPU. Section B.4.2 of the Multi-Proce\ -ssor) 292.6905 Tj -0 -66.4535 Td -(1004 # Specification says that the AP will start in real mode w\ -ith CS:IP) 314.533 Tj -0 -75.9469 Td -(1005 # set to XY00:0000, where XY is an 8-bit value sent with t\ -he) 283.9534 Tj -0 -85.4403 Td -(1006 # STARTUP. Thus this code must start at a 4096-byte bounda\ -ry.) 288.322 Tj -0 -94.9336 Td -(1007 #) 26.2111 Tj -0 -104.427 Td -(1008 # Because this code sets DS to zero, it must sit) 231.5313 Tj -0 -113.9203 Td -(1009 # at an address in the low 2^16 bytes.) 187.8461 Tj -0 -123.4137 Td -(1010 #) 26.2111 Tj -0 -132.9071 Td -(1011 # Bootothers \(in main.c\) sends the STARTUPs, one at a ti\ -me.) 279.5849 Tj -0 -142.4004 Td -(1012 # It puts this code \(start\) at 0x7000.) 187.8461 Tj -0 -151.8938 Td -(1013 # It puts the correct %esp in start-4,) 187.8461 Tj -0 -161.3871 Td -(1014 # and the place to jump to in start-8.) 187.8461 Tj -0 -170.8805 Td -(1015 #) 26.2111 Tj -0 -180.3739 Td -(1016 # This code is identical to bootasm.S except:) 218.4257 Tj -0 -189.8672 Td -(1017 # - it does not need to enable A20) 179.1091 Tj -0 -199.3606 Td -(1018 # - it uses the address at start-4 for the %esp) 235.8998 Tj -0 -208.8539 Td -(1019 # - it jumps to the address at start-8 instead of callin\ -g bootmain) 318.9016 Tj -0 -218.3473 Td -(1020 ) 21.8426 Tj -0 -227.8407 Td -(1021 #define SEG_KCODE 1 // kernel code) 174.7406 Tj -0 -237.334 Td -(1022 #define SEG_KDATA 2 // kernel data+stack) 200.9517 Tj -0 -246.8274 Td -(1023 ) 21.8426 Tj -0 -256.3207 Td -(1024 #define CR0_PE 1 // protected mode enable bit) 235.8998 Tj -0 -265.8141 Td -(1025 ) 21.8426 Tj -0 -275.3075 Td -(1026 .code16 # Assemble for 16-bit mode) 266.4794 Tj -0 -284.8008 Td -(1027 .globl start) 74.2647 Tj -0 -294.2942 Td -(1028 start:) 48.0537 Tj -0 -303.7875 Td -(1029 cli # Disable interrupts) 240.2683 Tj -0 -313.2809 Td -(1030 ) 21.8426 Tj -0 -322.7743 Td -(1031 # Set up the important data segment registers \(DS, ES, \ -SS\).) 288.322 Tj -0 -332.2676 Td -(1032 xorw %ax,%ax # Segment number zero) 244.6368 Tj -0 -341.761 Td -(1033 movw %ax,%ds # -> Data Segment) 227.1628 Tj -0 -351.2543 Td -(1034 movw %ax,%es # -> Extra Segment) 231.5313 Tj -0 -360.7477 Td -(1035 movw %ax,%ss # -> Stack Segment) 231.5313 Tj -0 -370.2411 Td -(1036 ) 21.8426 Tj -0 -379.7344 Td -(1037 ) 21.8426 Tj -0 -389.2278 Td -(1038 ) 21.8426 Tj -0 -398.7211 Td -(1039 ) 21.8426 Tj -0 -408.2145 Td -(1040 ) 21.8426 Tj -0 -417.7079 Td -(1041 ) 21.8426 Tj -0 -427.2012 Td -(1042 ) 21.8426 Tj -0 -436.6946 Td -(1043 ) 21.8426 Tj -0 -446.1879 Td -(1044 ) 21.8426 Tj -0 -455.6813 Td -(1045 ) 21.8426 Tj -0 -465.1747 Td -(1046 ) 21.8426 Tj -0 -474.668 Td -(1047 ) 21.8426 Tj -0 -484.1614 Td -(1048 ) 21.8426 Tj -0 -493.6547 Td -(1049 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 10) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootother.S Page 2) 183.4776 Tj -0 -28.4801 Td -(1050 # Switch from real to protected mode, using a bootstrap \ -GDT) 288.322 Tj -0 -37.9735 Td -(1051 # and segment translation that makes virtual addresses) 266.4794 Tj -0 -47.4668 Td -(1052 # identical to physical addresses, so that the) 231.5313 Tj -0 -56.9602 Td -(1053 # effective memory map does not change during the switch\ -.) 279.5849 Tj -0 -66.4535 Td -(1054 lgdt gdtdesc) 96.1073 Tj -0 -75.9469 Td -(1055 movl %cr0, %eax) 109.2129 Tj -0 -85.4403 Td -(1056 orl $CR0_PE, %eax) 122.3184 Tj -0 -94.9336 Td -(1057 movl %eax, %cr0) 109.2129 Tj -0 -104.427 Td -(1058 ) 21.8426 Tj -0 -113.9203 Td -(1059 # Jump to next instruction, but in 32-bit code segment.) 270.8479 Tj -0 -123.4137 Td -(1060 # Switches processor into 32-bit mode.) 196.5831 Tj -0 -132.9071 Td -(1061 ljmp $\(SEG_KCODE<<3\), $start32) 174.7406 Tj -0 -142.4004 Td -(1062 ) 21.8426 Tj -0 -151.8938 Td -(1063 .code32 # Assemble for 32-bit mode) 266.4794 Tj -0 -161.3871 Td -(1064 start32:) 56.7907 Tj -0 -170.8805 Td -(1065 # Set up the protected-mode data segment registers) 249.0053 Tj -0 -180.3739 Td -(1066 movw $\(SEG_KDATA<<3\), %ax # Our data segment sel\ -ector) 288.322 Tj -0 -189.8672 Td -(1067 movw %ax, %ds # -> DS: Data Segment) 262.1109 Tj -0 -199.3606 Td -(1068 movw %ax, %es # -> ES: Extra Segment) 266.4794 Tj -0 -208.8539 Td -(1069 movw %ax, %ss # -> SS: Stack Segment) 266.4794 Tj -0 -218.3473 Td -(1070 movw $0, %ax # Zero segments not read\ -y for use) 314.533 Tj -0 -227.8407 Td -(1071 movw %ax, %fs # -> FS) 200.9517 Tj -0 -237.334 Td -(1072 movw %ax, %gs # -> GS) 200.9517 Tj -0 -246.8274 Td -(1073 ) 21.8426 Tj -0 -256.3207 Td -(1074 # Set up the stack pointer and call into C.) 218.4257 Tj -0 -265.8141 Td -(1075 movl start-4, %esp) 122.3184 Tj -0 -275.3075 Td -(1076 call) 48.0537 Tj --2507.8 TJm -(*\(start-8\)) 43.6851 Tj -0 -284.8008 Td -(1077 ) 21.8426 Tj -0 -294.2942 Td -(1078 # If the call returns \(it shouldn't\), trigger a Bochs) 262.1109 Tj -0 -303.7875 Td -(1079 # breakpoint if running under Bochs, then loop.) 235.8998 Tj -0 -313.2809 Td -(1080 movw $0x8a00, %ax # 0x8a00 -> port 0x8a00) 270.8479 Tj -0 -322.7743 Td -(1081 movw %ax, %dx) 100.4758 Tj -0 -332.2676 Td -(1082 outw %ax, %dx) 100.4758 Tj -0 -341.761 Td -(1083 movw $0x8e00, %ax # 0x8e00 -> port 0x8a00) 270.8479 Tj -0 -351.2543 Td -(1084 outw %ax, %dx) 100.4758 Tj -0 -360.7477 Td -(1085 spin:) 43.6851 Tj -0 -370.2411 Td -(1086 jmp spin) 83.0018 Tj -0 -379.7344 Td -(1087 ) 21.8426 Tj -0 -389.2278 Td -(1088 # Bootstrap GDT) 87.3703 Tj -0 -398.7211 Td -(1089 .p2align 2 # force 4 byte a\ -lignment) 310.1645 Tj -0 -408.2145 Td -(1090 gdt:) 39.3166 Tj -0 -417.7079 Td -(1091 SEG_NULLASM # null seg) 249.0053 Tj -0 -427.2012 Td -(1092 SEG_ASM\(STA_X|STA_R, 0x0, 0xffffffff\) # code seg) 249.0053 Tj -0 -436.6946 Td -(1093 SEG_ASM\(STA_W, 0x0, 0xffffffff\) # data seg) 249.0053 Tj -0 -446.1879 Td -(1094 ) 21.8426 Tj -0 -455.6813 Td -(1095 gdtdesc:) 56.7907 Tj -0 -465.1747 Td -(1096 .word \(gdtdesc - gdt - 1\) \ - # sizeof\(gdt\) - 1) 345.1126 Tj -0 -474.668 Td -(1097 .long gdt # address gdt) 262.1109 Tj -0 -484.1614 Td -(1098 ) 21.8426 Tj -0 -493.6547 Td -(1099 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 10) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 18 18 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootmain.c Page 1) 179.1091 Tj -0 -28.4801 Td -(1100 // Boot loader.) 87.3703 Tj -0 -37.9735 Td -(1101 //) 30.5796 Tj -0 -47.4668 Td -(1102 // Part of the boot sector, along with bootasm.S, which ca\ -lls bootmain\(\).) 340.7441 Tj -0 -56.9602 Td -(1103 // bootasm.S has put the processor into protected 32-bit m\ -ode.) 292.6905 Tj -0 -66.4535 Td -(1104 // bootmain\(\) loads an ELF kernel image from the disk st\ -arting at) 305.796 Tj -0 -75.9469 Td -(1105 // sector 1 and then jumps to the kernel entry routine.) 262.1109 Tj -0 -85.4403 Td -(1106 ) 21.8426 Tj -0 -94.9336 Td -(1107 #include "types.h") 100.4758 Tj -0 -104.427 Td -(1108 #include "elf.h") 91.7388 Tj -0 -113.9203 Td -(1109 #include "x86.h") 91.7388 Tj -0 -123.4137 Td -(1110 ) 21.8426 Tj -0 -132.9071 Td -(1111 #define SECTSIZE 512) 113.5814 Tj -0 -142.4004 Td -(1112 ) 21.8426 Tj -0 -151.8938 Td -(1113 void readseg\(uchar*, uint, uint\);) 166.0035 Tj -0 -161.3871 Td -(1114 ) 21.8426 Tj -0 -170.8805 Td -(1115 void) 39.3166 Tj -0 -180.3739 Td -(1116 bootmain\(void\)) 83.0018 Tj -0 -189.8672 Td -(1117 {) 26.2111 Tj -0 -199.3606 Td -(1118 struct elfhdr *elf;) 113.5814 Tj -0 -208.8539 Td -(1119 struct proghdr *ph, *eph;) 139.7925 Tj -0 -218.3473 Td -(1120 void \(*entry\)\(void\);) 117.9499 Tj -0 -227.8407 Td -(1121 uchar* va;) 74.2647 Tj -0 -237.334 Td -(1122 ) 21.8426 Tj -0 -246.8274 Td -(1123 elf = \(struct elfhdr*\)0x10000; // scratch space) 240.2683 Tj -0 -256.3207 Td -(1124 ) 21.8426 Tj -0 -265.8141 Td -(1125 // Read 1st page off disk) 139.7925 Tj -0 -275.3075 Td -(1126 readseg\(\(uchar*\)elf, 4096, 0\);) 161.635 Tj -0 -284.8008 Td -(1127 ) 21.8426 Tj -0 -294.2942 Td -(1128 // Is this an ELF executable?) 157.2665 Tj -0 -303.7875 Td -(1129 if\(elf->magic != ELF_MAGIC\)) 148.5295 Tj -0 -313.2809 Td -(1130 return; // let bootasm.S handle error) 205.3202 Tj -0 -322.7743 Td -(1131 ) 21.8426 Tj -0 -332.2676 Td -(1132 // Load each program segment \(ignores ph flags\).) 240.2683 Tj -0 -341.761 Td -(1133 ph = \(struct proghdr*\)\(\(uchar*\)elf + elf->phoff\);) 244.6368 Tj -0 -351.2543 Td -(1134 eph = ph + elf->phnum;) 126.6869 Tj -0 -360.7477 Td -(1135 for\(; ph < eph; ph++\) {) 131.0554 Tj -0 -370.2411 Td -(1136 va = \(uchar*\)\(ph->va & 0xFFFFFF\);) 183.4776 Tj -0 -379.7344 Td -(1137 readseg\(va, ph->filesz, ph->offset\);) 196.5831 Tj -0 -389.2278 Td -(1138 if\(ph->memsz > ph->filesz\)) 152.898 Tj -0 -398.7211 Td -(1139 stosb\(va + ph->filesz, 0, ph->memsz - ph->filesz\);) 266.4794 Tj -0 -408.2145 Td -(1140 }) 34.9481 Tj -0 -417.7079 Td -(1141 ) 21.8426 Tj -0 -427.2012 Td -(1142 // Call the entry point from the ELF header.) 222.7942 Tj -0 -436.6946 Td -(1143 // Does not return!) 113.5814 Tj -0 -446.1879 Td -(1144 entry = \(void\(*\)\(void\)\)\(elf->entry & 0xFFFFFF\);) 235.8998 Tj -0 -455.6813 Td -(1145 entry\(\);) 65.5277 Tj -0 -465.1747 Td -(1146 }) 26.2111 Tj -0 -474.668 Td -(1147 ) 21.8426 Tj -0 -484.1614 Td -(1148 ) 21.8426 Tj -0 -493.6547 Td -(1149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 11) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bootmain.c Page 2) 179.1091 Tj -0 -28.4801 Td -(1150 void) 39.3166 Tj -0 -37.9735 Td -(1151 waitdisk\(void\)) 83.0018 Tj -0 -47.4668 Td -(1152 {) 26.2111 Tj -0 -56.9602 Td -(1153 // Wait for disk ready.) 131.0554 Tj -0 -66.4535 Td -(1154 while\(\(inb\(0x1F7\) & 0xC0\) != 0x40\)) 179.1091 Tj -0 -75.9469 Td -(1155 ;) 43.6851 Tj -0 -85.4403 Td -(1156 }) 26.2111 Tj -0 -94.9336 Td -(1157 ) 21.8426 Tj -0 -104.427 Td -(1158 // Read a single sector at offset into dst.) 209.6887 Tj -0 -113.9203 Td -(1159 void) 39.3166 Tj -0 -123.4137 Td -(1160 readsect\(void *dst, uint offset\)) 161.635 Tj -0 -132.9071 Td -(1161 {) 26.2111 Tj -0 -142.4004 Td -(1162 // Issue command.) 104.8443 Tj -0 -151.8938 Td -(1163 waitdisk\(\);) 78.6333 Tj -0 -161.3871 Td -(1164 outb\(0x1F2, 1\); // count = 1) 161.635 Tj -0 -170.8805 Td -(1165 outb\(0x1F3, offset\);) 117.9499 Tj -0 -180.3739 Td -(1166 outb\(0x1F4, offset >> 8\);) 139.7925 Tj -0 -189.8672 Td -(1167 outb\(0x1F5, offset >> 16\);) 144.161 Tj -0 -199.3606 Td -(1168 outb\(0x1F6, \(offset >> 24\) | 0xE0\);) 183.4776 Tj -0 -208.8539 Td -(1169 outb\(0x1F7, 0x20\); // cmd 0x20 - read sectors) 231.5313 Tj -0 -218.3473 Td -(1170 ) 21.8426 Tj -0 -227.8407 Td -(1171 // Read data.) 87.3703 Tj -0 -237.334 Td -(1172 waitdisk\(\);) 78.6333 Tj -0 -246.8274 Td -(1173 insl\(0x1F0, dst, SECTSIZE/4\);) 157.2665 Tj -0 -256.3207 Td -(1174 }) 26.2111 Tj -0 -265.8141 Td -(1175 ) 21.8426 Tj -0 -275.3075 Td -(1176 // Read 'count' bytes at 'offset' from kernel into virtual\ - address 'va'.) 336.3756 Tj -0 -284.8008 Td -(1177 // Might copy more than asked.) 152.898 Tj -0 -294.2942 Td -(1178 void) 39.3166 Tj -0 -303.7875 Td -(1179 readseg\(uchar* va, uint count, uint offset\)) 209.6887 Tj -0 -313.2809 Td -(1180 {) 26.2111 Tj -0 -322.7743 Td -(1181 uchar* eva;) 78.6333 Tj -0 -332.2676 Td -(1182 ) 21.8426 Tj -0 -341.761 Td -(1183 eva = va + count;) 104.8443 Tj -0 -351.2543 Td -(1184 ) 21.8426 Tj -0 -360.7477 Td -(1185 // Round down to sector boundary.) 174.7406 Tj -0 -370.2411 Td -(1186 va -= offset % SECTSIZE;) 135.4239 Tj -0 -379.7344 Td -(1187 ) 21.8426 Tj -0 -389.2278 Td -(1188 // Translate from bytes to sectors; kernel starts at sec\ -tor 1.) 301.4275 Tj -0 -398.7211 Td -(1189 offset = \(offset / SECTSIZE\) + 1;) 174.7406 Tj -0 -408.2145 Td -(1190 ) 21.8426 Tj -0 -417.7079 Td -(1191 // If this is too slow, we could read lots of sectors at\ - a time.) 310.1645 Tj -0 -427.2012 Td -(1192 // We'd write more to memory than asked, but it doesn't \ -matter --) 314.533 Tj -0 -436.6946 Td -(1193 // we load in increasing order.) 166.0035 Tj -0 -446.1879 Td -(1194 for\(; va < eva; va += SECTSIZE, offset++\)) 209.6887 Tj -0 -455.6813 Td -(1195 readsect\(va, offset\);) 131.0554 Tj -0 -465.1747 Td -(1196 }) 26.2111 Tj -0 -474.668 Td -(1197 ) 21.8426 Tj -0 -484.1614 Td -(1198 ) 21.8426 Tj -0 -493.6547 Td -(1199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 11) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 19 19 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/main.c Page 1) 161.635 Tj -0 -28.4801 Td -(1200 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(1201 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(1202 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(1203 #include "mmu.h") 91.7388 Tj -0 -66.4535 Td -(1204 #include "proc.h") 96.1073 Tj -0 -75.9469 Td -(1205 #include "x86.h") 91.7388 Tj -0 -85.4403 Td -(1206 ) 21.8426 Tj -0 -94.9336 Td -(1207 static void bootothers\(void\);) 148.5295 Tj -0 -104.427 Td -(1208 static void mpmain\(void\) __attribute__\(\(noreturn\)\);) 244.6368 Tj -0 -113.9203 Td -(1209 ) 21.8426 Tj -0 -123.4137 Td -(1210 // Bootstrap processor starts running C code here.) 240.2683 Tj -0 -132.9071 Td -(1211 int) 34.9481 Tj -0 -142.4004 Td -(1212 main\(void\)) 65.5277 Tj -0 -151.8938 Td -(1213 {) 26.2111 Tj -0 -161.3871 Td -(1214 mpinit\(\); // collect info about this machine) 222.7942 Tj -0 -170.8805 Td -(1215 lapicinit\(mpbcpu\(\)\);) 117.9499 Tj -0 -180.3739 Td -(1216 ksegment\(\);) 78.6333 Tj -0 -189.8672 Td -(1217 picinit\(\); // interrupt controller) 205.3202 Tj -0 -199.3606 Td -(1218 ioapicinit\(\); // another interrupt controller) 240.2683 Tj -0 -208.8539 Td -(1219 consoleinit\(\); // I/O devices & their interrupts) 249.0053 Tj -0 -218.3473 Td -(1220 uartinit\(\); // serial port) 166.0035 Tj -0 -227.8407 Td -(1221 cprintf\("cpus %p cpu %p\\n", cpus, cpu\);) 192.2146 Tj -0 -237.334 Td -(1222 cprintf\("\\ncpu%d: starting xv6\\n\\n", cpu->id\);) 231.5313 Tj -0 -246.8274 Td -(1223 ) 21.8426 Tj -0 -256.3207 Td -(1224 kinit\(\); // physical memory allocator) 227.1628 Tj -0 -265.8141 Td -(1225 pinit\(\); // process table) 174.7406 Tj -0 -275.3075 Td -(1226 tvinit\(\); // trap vectors) 170.3721 Tj -0 -284.8008 Td -(1227 binit\(\); // buffer cache) 170.3721 Tj -0 -294.2942 Td -(1228 fileinit\(\); // file table) 161.635 Tj -0 -303.7875 Td -(1229 iinit\(\); // inode cache) 166.0035 Tj -0 -313.2809 Td -(1230 ideinit\(\); // disk) 135.4239 Tj -0 -322.7743 Td -(1231 if\(!ismp\)) 69.8962 Tj -0 -332.2676 Td -(1232 timerinit\(\); // uniprocessor timer) 196.5831 Tj -0 -341.761 Td -(1233 userinit\(\); // first user process) 196.5831 Tj -0 -351.2543 Td -(1234 bootothers\(\); // start other processors) 214.0572 Tj -0 -360.7477 Td -(1235 ) 21.8426 Tj -0 -370.2411 Td -(1236 // Finish setting up this processor in mpmain.) 231.5313 Tj -0 -379.7344 Td -(1237 mpmain\(\);) 69.8962 Tj -0 -389.2278 Td -(1238 }) 26.2111 Tj -0 -398.7211 Td -(1239 ) 21.8426 Tj -0 -408.2145 Td -(1240 ) 21.8426 Tj -0 -417.7079 Td -(1241 ) 21.8426 Tj -0 -427.2012 Td -(1242 ) 21.8426 Tj -0 -436.6946 Td -(1243 ) 21.8426 Tj -0 -446.1879 Td -(1244 ) 21.8426 Tj -0 -455.6813 Td -(1245 ) 21.8426 Tj -0 -465.1747 Td -(1246 ) 21.8426 Tj -0 -474.668 Td -(1247 ) 21.8426 Tj -0 -484.1614 Td -(1248 ) 21.8426 Tj -0 -493.6547 Td -(1249 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 12) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/main.c Page 2) 161.635 Tj -0 -28.4801 Td -(1250 // Bootstrap processor gets here after setting up the hard\ -ware.) 297.059 Tj -0 -37.9735 Td -(1251 // Additional processors start here.) 179.1091 Tj -0 -47.4668 Td -(1252 static void) 69.8962 Tj -0 -56.9602 Td -(1253 mpmain\(void\)) 74.2647 Tj -0 -66.4535 Td -(1254 {) 26.2111 Tj -0 -75.9469 Td -(1255 if\(cpunum\(\) != mpbcpu\(\)\)) 135.4239 Tj -0 -85.4403 Td -(1256 lapicinit\(cpunum\(\)\);) 126.6869 Tj -0 -94.9336 Td -(1257 ksegment\(\);) 78.6333 Tj -0 -104.427 Td -(1258 cprintf\("cpu%d: mpmain\\n", cpu->id\);) 187.8461 Tj -0 -113.9203 Td -(1259 idtinit\(\);) 74.2647 Tj -0 -123.4137 Td -(1260 xchg\(&cpu->booted, 1\);) 126.6869 Tj -0 -132.9071 Td -(1261 ) 21.8426 Tj -0 -142.4004 Td -(1262 cprintf\("cpu%d: scheduling\\n", cpu->id\);) 205.3202 Tj -0 -151.8938 Td -(1263 scheduler\(\);) 83.0018 Tj -0 -161.3871 Td -(1264 }) 26.2111 Tj -0 -170.8805 Td -(1265 ) 21.8426 Tj -0 -180.3739 Td -(1266 static void) 69.8962 Tj -0 -189.8672 Td -(1267 bootothers\(void\)) 91.7388 Tj -0 -199.3606 Td -(1268 {) 26.2111 Tj -0 -208.8539 Td -(1269 extern uchar _binary_bootother_start[], _binary_bootothe\ -r_size[];) 314.533 Tj -0 -218.3473 Td -(1270 uchar *code;) 83.0018 Tj -0 -227.8407 Td -(1271 struct cpu *c;) 91.7388 Tj -0 -237.334 Td -(1272 char *stack;) 83.0018 Tj -0 -246.8274 Td -(1273 ) 21.8426 Tj -0 -256.3207 Td -(1274 // Write bootstrap code to unused memory at 0x7000.) 253.3738 Tj -0 -265.8141 Td -(1275 code = \(uchar*\)0x7000;) 126.6869 Tj -0 -275.3075 Td -(1276 memmove\(code, _binary_bootother_start, \(uint\)_binary_\ -bootother_size\);) 332.0071 Tj -0 -284.8008 Td -(1277 ) 21.8426 Tj -0 -294.2942 Td -(1278 for\(c = cpus; c < cpus+ncpu; c++\){) 179.1091 Tj -0 -303.7875 Td -(1279 if\(c == cpus+cpunum\(\)\) // We've started already.) 253.3738 Tj -0 -313.2809 Td -(1280 continue;) 87.3703 Tj -0 -322.7743 Td -(1281 ) 21.8426 Tj -0 -332.2676 Td -(1282 // Fill in %esp, %eip and start code on cpu.) 231.5313 Tj -0 -341.761 Td -(1283 stack = kalloc\(KSTACKSIZE\);) 157.2665 Tj -0 -351.2543 Td -(1284 *\(void**\)\(code-4\) = stack + KSTACKSIZE;) 209.6887 Tj -0 -360.7477 Td -(1285 *\(void**\)\(code-8\) = mpmain;) 157.2665 Tj -0 -370.2411 Td -(1286 lapicstartap\(c->id, \(uint\)code\);) 179.1091 Tj -0 -379.7344 Td -(1287 ) 21.8426 Tj -0 -389.2278 Td -(1288 // Wait for cpu to get through bootstrap.) 218.4257 Tj -0 -398.7211 Td -(1289 while\(c->booted == 0\)) 131.0554 Tj -0 -408.2145 Td -(1290 ;) 52.4222 Tj -0 -417.7079 Td -(1291 }) 34.9481 Tj -0 -427.2012 Td -(1292 }) 26.2111 Tj -0 -436.6946 Td -(1293 ) 21.8426 Tj -0 -446.1879 Td -(1294 ) 21.8426 Tj -0 -455.6813 Td -(1295 ) 21.8426 Tj -0 -465.1747 Td -(1296 ) 21.8426 Tj -0 -474.668 Td -(1297 ) 21.8426 Tj -0 -484.1614 Td -(1298 ) 21.8426 Tj -0 -493.6547 Td -(1299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 12) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 20 20 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/spinlock.h Page 1) 179.1091 Tj -0 -28.4801 Td -(1300 // Mutual exclusion lock.) 131.0554 Tj -0 -37.9735 Td -(1301 struct spinlock {) 96.1073 Tj -0 -47.4668 Td -(1302 uint locked; // Is the lock held?) 200.9517 Tj -0 -56.9602 Td -(1303 ) 21.8426 Tj -0 -66.4535 Td -(1304 // For debugging:) 104.8443 Tj -0 -75.9469 Td -(1305 char *name; // Name of lock.) 183.4776 Tj -0 -85.4403 Td -(1306 struct cpu *cpu; // The cpu holding the lock.) 235.8998 Tj -0 -94.9336 Td -(1307 uint pcs[10]; // The call stack \(an array of progr\ -am counters\)) 323.2701 Tj -0 -104.427 Td -(1308 // that locked the lock.) 218.4257 Tj -0 -113.9203 Td -(1309 };) 30.5796 Tj -0 -123.4137 Td -(1310 ) 21.8426 Tj -0 -132.9071 Td -(1311 ) 21.8426 Tj -0 -142.4004 Td -(1312 ) 21.8426 Tj -0 -151.8938 Td -(1313 ) 21.8426 Tj -0 -161.3871 Td -(1314 ) 21.8426 Tj -0 -170.8805 Td -(1315 ) 21.8426 Tj -0 -180.3739 Td -(1316 ) 21.8426 Tj -0 -189.8672 Td -(1317 ) 21.8426 Tj -0 -199.3606 Td -(1318 ) 21.8426 Tj -0 -208.8539 Td -(1319 ) 21.8426 Tj -0 -218.3473 Td -(1320 ) 21.8426 Tj -0 -227.8407 Td -(1321 ) 21.8426 Tj -0 -237.334 Td -(1322 ) 21.8426 Tj -0 -246.8274 Td -(1323 ) 21.8426 Tj -0 -256.3207 Td -(1324 ) 21.8426 Tj -0 -265.8141 Td -(1325 ) 21.8426 Tj -0 -275.3075 Td -(1326 ) 21.8426 Tj -0 -284.8008 Td -(1327 ) 21.8426 Tj -0 -294.2942 Td -(1328 ) 21.8426 Tj -0 -303.7875 Td -(1329 ) 21.8426 Tj -0 -313.2809 Td -(1330 ) 21.8426 Tj -0 -322.7743 Td -(1331 ) 21.8426 Tj -0 -332.2676 Td -(1332 ) 21.8426 Tj -0 -341.761 Td -(1333 ) 21.8426 Tj -0 -351.2543 Td -(1334 ) 21.8426 Tj -0 -360.7477 Td -(1335 ) 21.8426 Tj -0 -370.2411 Td -(1336 ) 21.8426 Tj -0 -379.7344 Td -(1337 ) 21.8426 Tj -0 -389.2278 Td -(1338 ) 21.8426 Tj -0 -398.7211 Td -(1339 ) 21.8426 Tj -0 -408.2145 Td -(1340 ) 21.8426 Tj -0 -417.7079 Td -(1341 ) 21.8426 Tj -0 -427.2012 Td -(1342 ) 21.8426 Tj -0 -436.6946 Td -(1343 ) 21.8426 Tj -0 -446.1879 Td -(1344 ) 21.8426 Tj -0 -455.6813 Td -(1345 ) 21.8426 Tj -0 -465.1747 Td -(1346 ) 21.8426 Tj -0 -474.668 Td -(1347 ) 21.8426 Tj -0 -484.1614 Td -(1348 ) 21.8426 Tj -0 -493.6547 Td -(1349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 13) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/spinlock.c Page 1) 179.1091 Tj -0 -28.4801 Td -(1350 // Mutual exclusion spin locks.) 157.2665 Tj -0 -37.9735 Td -(1351 ) 21.8426 Tj -0 -47.4668 Td -(1352 #include "types.h") 100.4758 Tj -0 -56.9602 Td -(1353 #include "defs.h") 96.1073 Tj -0 -66.4535 Td -(1354 #include "param.h") 100.4758 Tj -0 -75.9469 Td -(1355 #include "x86.h") 91.7388 Tj -0 -85.4403 Td -(1356 #include "mmu.h") 91.7388 Tj -0 -94.9336 Td -(1357 #include "proc.h") 96.1073 Tj -0 -104.427 Td -(1358 #include "spinlock.h") 113.5814 Tj -0 -113.9203 Td -(1359 ) 21.8426 Tj -0 -123.4137 Td -(1360 void) 39.3166 Tj -0 -132.9071 Td -(1361 initlock\(struct spinlock *lk, char *name\)) 200.9517 Tj -0 -142.4004 Td -(1362 {) 26.2111 Tj -0 -151.8938 Td -(1363 lk->name = name;) 100.4758 Tj -0 -161.3871 Td -(1364 lk->locked = 0;) 96.1073 Tj -0 -170.8805 Td -(1365 lk->cpu = 0;) 83.0018 Tj -0 -180.3739 Td -(1366 }) 26.2111 Tj -0 -189.8672 Td -(1367 ) 21.8426 Tj -0 -199.3606 Td -(1368 // Acquire the lock.) 109.2129 Tj -0 -208.8539 Td -(1369 // Loops \(spins\) until the lock is acquired.) 214.0572 Tj -0 -218.3473 Td -(1370 // Holding a lock for a long time may cause) 209.6887 Tj -0 -227.8407 Td -(1371 // other CPUs to waste time spinning to acquire it.) 244.6368 Tj -0 -237.334 Td -(1372 void) 39.3166 Tj -0 -246.8274 Td -(1373 acquire\(struct spinlock *lk\)) 144.161 Tj -0 -256.3207 Td -(1374 {) 26.2111 Tj -0 -265.8141 Td -(1375 pushcli\(\);) 74.2647 Tj -0 -275.3075 Td -(1376 if\(holding\(lk\)\)) 96.1073 Tj -0 -284.8008 Td -(1377 panic\("acquire"\);) 113.5814 Tj -0 -294.2942 Td -(1378 ) 21.8426 Tj -0 -303.7875 Td -(1379 // The xchg is atomic.) 126.6869 Tj -0 -313.2809 Td -(1380 // It also serializes, so that reads after acquire are n\ -ot) 283.9534 Tj -0 -322.7743 Td -(1381 // reordered before it.) 131.0554 Tj -0 -332.2676 Td -(1382 while\(xchg\(&lk->locked, 1\) != 0\)) 170.3721 Tj -0 -341.761 Td -(1383 ;) 43.6851 Tj -0 -351.2543 Td -(1384 ) 21.8426 Tj -0 -360.7477 Td -(1385 // Record info about lock acquisition for debugging.) 257.7424 Tj -0 -370.2411 Td -(1386 lk->cpu = cpu;) 91.7388 Tj -0 -379.7344 Td -(1387 getcallerpcs\(&lk, lk->pcs\);) 148.5295 Tj -0 -389.2278 Td -(1388 }) 26.2111 Tj -0 -398.7211 Td -(1389 ) 21.8426 Tj -0 -408.2145 Td -(1390 ) 21.8426 Tj -0 -417.7079 Td -(1391 ) 21.8426 Tj -0 -427.2012 Td -(1392 ) 21.8426 Tj -0 -436.6946 Td -(1393 ) 21.8426 Tj -0 -446.1879 Td -(1394 ) 21.8426 Tj -0 -455.6813 Td -(1395 ) 21.8426 Tj -0 -465.1747 Td -(1396 ) 21.8426 Tj -0 -474.668 Td -(1397 ) 21.8426 Tj -0 -484.1614 Td -(1398 ) 21.8426 Tj -0 -493.6547 Td -(1399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 13) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 21 21 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/spinlock.c Page 2) 179.1091 Tj -0 -28.4801 Td -(1400 // Release the lock.) 109.2129 Tj -0 -37.9735 Td -(1401 void) 39.3166 Tj -0 -47.4668 Td -(1402 release\(struct spinlock *lk\)) 144.161 Tj -0 -56.9602 Td -(1403 {) 26.2111 Tj -0 -66.4535 Td -(1404 if\(!holding\(lk\)\)) 100.4758 Tj -0 -75.9469 Td -(1405 panic\("release"\);) 113.5814 Tj -0 -85.4403 Td -(1406 ) 21.8426 Tj -0 -94.9336 Td -(1407 lk->pcs[0] = 0;) 96.1073 Tj -0 -104.427 Td -(1408 lk->cpu = 0;) 83.0018 Tj -0 -113.9203 Td -(1409 ) 21.8426 Tj -0 -123.4137 Td -(1410 // The xchg serializes, so that reads before release are) 275.2164 Tj -0 -132.9071 Td -(1411 // not reordered after it. The 1996 PentiumPro manual \(\ -Volume 3,) 314.533 Tj -0 -142.4004 Td -(1412 // 7.2\) says reads can be carried out speculatively and\ - in) 283.9534 Tj -0 -151.8938 Td -(1413 // any order, which implies we need to serialize here.) 266.4794 Tj -0 -161.3871 Td -(1414 // But the 2007 Intel 64 Architecture Memory Ordering Wh\ -ite) 288.322 Tj -0 -170.8805 Td -(1415 // Paper says that Intel 64 and IA-32 will not move a lo\ -ad) 283.9534 Tj -0 -180.3739 Td -(1416 // after a store. So lock->locked = 0 would work here.) 266.4794 Tj -0 -189.8672 Td -(1417 // The xchg being asm volatile ensures gcc emits it afte\ -r) 279.5849 Tj -0 -199.3606 Td -(1418 // the above assignments \(and after the critical sectio\ -n\).) 283.9534 Tj -0 -208.8539 Td -(1419 xchg\(&lk->locked, 0\);) 122.3184 Tj -0 -218.3473 Td -(1420 ) 21.8426 Tj -0 -227.8407 Td -(1421 popcli\(\);) 69.8962 Tj -0 -237.334 Td -(1422 }) 26.2111 Tj -0 -246.8274 Td -(1423 ) 21.8426 Tj -0 -256.3207 Td -(1424 // Record the current call stack in pcs[] by following the\ - %ebp chain.) 327.6386 Tj -0 -265.8141 Td -(1425 void) 39.3166 Tj -0 -275.3075 Td -(1426 getcallerpcs\(void *v, uint pcs[]\)) 166.0035 Tj -0 -284.8008 Td -(1427 {) 26.2111 Tj -0 -294.2942 Td -(1428 uint *ebp;) 74.2647 Tj -0 -303.7875 Td -(1429 int i;) 56.7907 Tj -0 -313.2809 Td -(1430 ) 21.8426 Tj -0 -322.7743 Td -(1431 ebp = \(uint*\)v - 2;) 113.5814 Tj -0 -332.2676 Td -(1432 for\(i = 0; i < 10; i++\){) 135.4239 Tj -0 -341.761 Td -(1433 if\(ebp == 0 || ebp == \(uint*\)0xffffffff\)) 214.0572 Tj -0 -351.2543 Td -(1434 break;) 74.2647 Tj -0 -360.7477 Td -(1435 pcs[i] = ebp[1]; // saved %eip) 187.8461 Tj -0 -370.2411 Td -(1436 ebp = \(uint*\)ebp[0]; // saved %ebp) 187.8461 Tj -0 -379.7344 Td -(1437 }) 34.9481 Tj -0 -389.2278 Td -(1438 for\(; i < 10; i++\)) 109.2129 Tj -0 -398.7211 Td -(1439 pcs[i] = 0;) 87.3703 Tj -0 -408.2145 Td -(1440 }) 26.2111 Tj -0 -417.7079 Td -(1441 ) 21.8426 Tj -0 -427.2012 Td -(1442 // Check whether this cpu is holding the lock.) 222.7942 Tj -0 -436.6946 Td -(1443 int) 34.9481 Tj -0 -446.1879 Td -(1444 holding\(struct spinlock *lock\)) 152.898 Tj -0 -455.6813 Td -(1445 {) 26.2111 Tj -0 -465.1747 Td -(1446 return lock->locked && lock->cpu == cpu;) 205.3202 Tj -0 -474.668 Td -(1447 }) 26.2111 Tj -0 -484.1614 Td -(1448 ) 21.8426 Tj -0 -493.6547 Td -(1449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 14) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/spinlock.c Page 3) 179.1091 Tj -0 -28.4801 Td -(1450 // Pushcli/popcli are like cli/sti except that they are ma\ -tched:) 301.4275 Tj -0 -37.9735 Td -(1451 // it takes two popcli to undo two pushcli. Also, if inte\ -rrupts) 301.4275 Tj -0 -47.4668 Td -(1452 // are off, then pushcli, popcli leaves them off.) 235.8998 Tj -0 -56.9602 Td -(1453 ) 21.8426 Tj -0 -66.4535 Td -(1454 void) 39.3166 Tj -0 -75.9469 Td -(1455 pushcli\(void\)) 78.6333 Tj -0 -85.4403 Td -(1456 {) 26.2111 Tj -0 -94.9336 Td -(1457 int eflags;) 78.6333 Tj -0 -104.427 Td -(1458 ) 21.8426 Tj -0 -113.9203 Td -(1459 eflags = readeflags\(\);) 126.6869 Tj -0 -123.4137 Td -(1460 cli\(\);) 56.7907 Tj -0 -132.9071 Td -(1461 if\(cpu->ncli++ == 0\)) 117.9499 Tj -0 -142.4004 Td -(1462 cpu->intena = eflags & FL_IF;) 166.0035 Tj -0 -151.8938 Td -(1463 }) 26.2111 Tj -0 -161.3871 Td -(1464 ) 21.8426 Tj -0 -170.8805 Td -(1465 void) 39.3166 Tj -0 -180.3739 Td -(1466 popcli\(void\)) 74.2647 Tj -0 -189.8672 Td -(1467 {) 26.2111 Tj -0 -199.3606 Td -(1468 if\(readeflags\(\)&FL_IF\)) 126.6869 Tj -0 -208.8539 Td -(1469 panic\("popcli - interruptible"\);) 179.1091 Tj -0 -218.3473 Td -(1470 if\(--cpu->ncli < 0\)) 113.5814 Tj -0 -227.8407 Td -(1471 panic\("popcli"\);) 109.2129 Tj -0 -237.334 Td -(1472 if\(cpu->ncli == 0 && cpu->intena\)) 174.7406 Tj -0 -246.8274 Td -(1473 sti\(\);) 65.5277 Tj -0 -256.3207 Td -(1474 }) 26.2111 Tj -0 -265.8141 Td -(1475 ) 21.8426 Tj -0 -275.3075 Td -(1476 ) 21.8426 Tj -0 -284.8008 Td -(1477 ) 21.8426 Tj -0 -294.2942 Td -(1478 ) 21.8426 Tj -0 -303.7875 Td -(1479 ) 21.8426 Tj -0 -313.2809 Td -(1480 ) 21.8426 Tj -0 -322.7743 Td -(1481 ) 21.8426 Tj -0 -332.2676 Td -(1482 ) 21.8426 Tj -0 -341.761 Td -(1483 ) 21.8426 Tj -0 -351.2543 Td -(1484 ) 21.8426 Tj -0 -360.7477 Td -(1485 ) 21.8426 Tj -0 -370.2411 Td -(1486 ) 21.8426 Tj -0 -379.7344 Td -(1487 ) 21.8426 Tj -0 -389.2278 Td -(1488 ) 21.8426 Tj -0 -398.7211 Td -(1489 ) 21.8426 Tj -0 -408.2145 Td -(1490 ) 21.8426 Tj -0 -417.7079 Td -(1491 ) 21.8426 Tj -0 -427.2012 Td -(1492 ) 21.8426 Tj -0 -436.6946 Td -(1493 ) 21.8426 Tj -0 -446.1879 Td -(1494 ) 21.8426 Tj -0 -455.6813 Td -(1495 ) 21.8426 Tj -0 -465.1747 Td -(1496 ) 21.8426 Tj -0 -474.668 Td -(1497 ) 21.8426 Tj -0 -484.1614 Td -(1498 ) 21.8426 Tj -0 -493.6547 Td -(1499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 14) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 22 22 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.h Page 1) 161.635 Tj -0 -28.4801 Td -(1500 // Segments in proc->gdt.) 131.0554 Tj -0 -37.9735 Td -(1501 // Also known to bootasm.S and trapasm.S) 196.5831 Tj -0 -47.4668 Td -(1502 #define SEG_KCODE 1 // kernel code) 174.7406 Tj -0 -56.9602 Td -(1503 #define SEG_KDATA 2 // kernel data+stack) 200.9517 Tj -0 -66.4535 Td -(1504 #define SEG_KCPU 3 // kernel per-cpu data) 209.6887 Tj -0 -75.9469 Td -(1505 #define SEG_UCODE 4) 104.8443 Tj -0 -85.4403 Td -(1506 #define SEG_UDATA 5) 104.8443 Tj -0 -94.9336 Td -(1507 #define SEG_TSS 6 // this process's task state) 235.8998 Tj -0 -104.427 Td -(1508 #define NSEGS 7) 104.8443 Tj -0 -113.9203 Td -(1509 ) 21.8426 Tj -0 -123.4137 Td -(1510 // Saved registers for kernel context switches.) 227.1628 Tj -0 -132.9071 Td -(1511 // Don't need to save all the segment registers \(%cs, etc\ -\),) 279.5849 Tj -0 -142.4004 Td -(1512 // because they are constant across kernel contexts.) 249.0053 Tj -0 -151.8938 Td -(1513 // Don't need to save %eax, %ecx, %edx, because the) 244.6368 Tj -0 -161.3871 Td -(1514 // x86 convention is that the caller has saved them.) 249.0053 Tj -0 -170.8805 Td -(1515 // Contexts are stored at the bottom of the stack they) 257.7424 Tj -0 -180.3739 Td -(1516 // describe; the stack pointer is the address of the conte\ -xt.) 288.322 Tj -0 -189.8672 Td -(1517 // The layout of the context must match the code in swtch.\ -S.) 283.9534 Tj -0 -199.3606 Td -(1518 struct context {) 91.7388 Tj -0 -208.8539 Td -(1519 uint edi;) 69.8962 Tj -0 -218.3473 Td -(1520 uint esi;) 69.8962 Tj -0 -227.8407 Td -(1521 uint ebx;) 69.8962 Tj -0 -237.334 Td -(1522 uint ebp;) 69.8962 Tj -0 -246.8274 Td -(1523 uint eip;) 69.8962 Tj -0 -256.3207 Td -(1524 };) 30.5796 Tj -0 -265.8141 Td -(1525 ) 21.8426 Tj -0 -275.3075 Td -(1526 enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNI\ -NG, ZOMBIE };) 332.0071 Tj -0 -284.8008 Td -(1527 ) 21.8426 Tj -0 -294.2942 Td -(1528 // Per-process state) 109.2129 Tj -0 -303.7875 Td -(1529 struct proc {) 78.6333 Tj -0 -313.2809 Td -(1530 char *mem; // Start of process memory \ -\(kernel address\)) 345.1126 Tj -0 -322.7743 Td -(1531 uint sz; // Size of process memory \(\ -bytes\)) 301.4275 Tj -0 -332.2676 Td -(1532 char *kstack; // Bottom of kernel stack f\ -or this process) 340.7441 Tj -0 -341.761 Td -(1533 enum procstate state; // Process state) 227.1628 Tj -0 -351.2543 Td -(1534 volatile int pid; // Process ID) 214.0572 Tj -0 -360.7477 Td -(1535 struct proc *parent; // Parent process) 231.5313 Tj -0 -370.2411 Td -(1536 struct trapframe *tf; // Trap frame for current s\ -yscall) 301.4275 Tj -0 -379.7344 Td -(1537 struct context *context; // Switch here to run proce\ -ss) 283.9534 Tj -0 -389.2278 Td -(1538 void *chan; // If non-zero, sleeping on\ - chan) 297.059 Tj -0 -398.7211 Td -(1539 int killed; // If non-zero, have been k\ -illed) 297.059 Tj -0 -408.2145 Td -(1540 struct file *ofile[NOFILE]; // Open files) 214.0572 Tj -0 -417.7079 Td -(1541 struct inode *cwd; // Current directory) 244.6368 Tj -0 -427.2012 Td -(1542 char name[16]; // Process name \(debugging\ -\)) 275.2164 Tj -0 -436.6946 Td -(1543 };) 30.5796 Tj -0 -446.1879 Td -(1544 ) 21.8426 Tj -0 -455.6813 Td -(1545 ) 21.8426 Tj -0 -465.1747 Td -(1546 ) 21.8426 Tj -0 -474.668 Td -(1547 ) 21.8426 Tj -0 -484.1614 Td -(1548 ) 21.8426 Tj -0 -493.6547 Td -(1549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 15) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.h Page 2) 161.635 Tj -0 -28.4801 Td -(1550 // Process memory is laid out contiguously, low addresses \ -first:) 301.4275 Tj -0 -37.9735 Td -(1551 // text) 61.1592 Tj -0 -47.4668 Td -(1552 // original data and bss) 135.4239 Tj -0 -56.9602 Td -(1553 // fixed-size stack) 113.5814 Tj -0 -66.4535 Td -(1554 // expandable heap) 109.2129 Tj -0 -75.9469 Td -(1555 ) 21.8426 Tj -0 -85.4403 Td -(1556 // Per-CPU state) 91.7388 Tj -0 -94.9336 Td -(1557 struct cpu {) 74.2647 Tj -0 -104.427 Td -(1558 uchar id; // Local APIC ID; index int\ -o cpus[] below) 336.3756 Tj -0 -113.9203 Td -(1559 struct context *scheduler; // Switch here to enter sch\ -eduler) 301.4275 Tj -0 -123.4137 Td -(1560 struct taskstate ts; // Used by x86 to find stac\ -k for interrupt) 340.7441 Tj -0 -132.9071 Td -(1561 struct segdesc gdt[NSEGS]; // x86 global descriptor ta\ -ble) 288.322 Tj -0 -142.4004 Td -(1562 volatile uint booted; // Has the CPU started?) 257.7424 Tj -0 -151.8938 Td -(1563 int ncli; // Depth of pushcli nesting\ -.) 279.5849 Tj -0 -161.3871 Td -(1564 int intena; // Were interrupts enabled \ -before pushcli?) 340.7441 Tj -0 -170.8805 Td -(1565 ) 21.8426 Tj -0 -180.3739 Td -(1566 // Cpu-local storage variables; see below) 209.6887 Tj -0 -189.8672 Td -(1567 struct cpu *cpu;) 100.4758 Tj -0 -199.3606 Td -(1568 struct proc *proc;) 109.2129 Tj -0 -208.8539 Td -(1569 };) 30.5796 Tj -0 -218.3473 Td -(1570 ) 21.8426 Tj -0 -227.8407 Td -(1571 extern struct cpu cpus[NCPU];) 148.5295 Tj -0 -237.334 Td -(1572 extern int ncpu;) 91.7388 Tj -0 -246.8274 Td -(1573 ) 21.8426 Tj -0 -256.3207 Td -(1574 // Per-CPU variables, holding pointers to the) 218.4257 Tj -0 -265.8141 Td -(1575 // current cpu and to the current process.) 205.3202 Tj -0 -275.3075 Td -(1576 // The asm suffix tells gcc to use "%gs:0" to refer to cpu) 275.2164 Tj -0 -284.8008 Td -(1577 // and "%gs:4" to refer to proc. ksegment sets up the) 257.7424 Tj -0 -294.2942 Td -(1578 // %gs segment register so that %gs refers to the memory) 266.4794 Tj -0 -303.7875 Td -(1579 // holding those two variables in the local cpu's struct c\ -pu.) 288.322 Tj -0 -313.2809 Td -(1580 // This is similar to how thread-local variables are imple\ -mented) 301.4275 Tj -0 -322.7743 Td -(1581 // in thread libraries such as Linux pthreads.) 222.7942 Tj -0 -332.2676 Td -(1582 extern struct cpu *cpu asm\("%gs:0"\); // This cpu.) 262.1109 Tj -0 -341.761 Td -(1583 extern struct proc *proc asm\("%gs:4"\); // Current pr\ -oc on this cpu.) 332.0071 Tj -0 -351.2543 Td -(1584 ) 21.8426 Tj -0 -360.7477 Td -(1585 ) 21.8426 Tj -0 -370.2411 Td -(1586 ) 21.8426 Tj -0 -379.7344 Td -(1587 ) 21.8426 Tj -0 -389.2278 Td -(1588 ) 21.8426 Tj -0 -398.7211 Td -(1589 ) 21.8426 Tj -0 -408.2145 Td -(1590 ) 21.8426 Tj -0 -417.7079 Td -(1591 ) 21.8426 Tj -0 -427.2012 Td -(1592 ) 21.8426 Tj -0 -436.6946 Td -(1593 ) 21.8426 Tj -0 -446.1879 Td -(1594 ) 21.8426 Tj -0 -455.6813 Td -(1595 ) 21.8426 Tj -0 -465.1747 Td -(1596 ) 21.8426 Tj -0 -474.668 Td -(1597 ) 21.8426 Tj -0 -484.1614 Td -(1598 ) 21.8426 Tj -0 -493.6547 Td -(1599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 15) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 23 23 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 1) 161.635 Tj -0 -28.4801 Td -(1600 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(1601 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(1602 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(1603 #include "mmu.h") 91.7388 Tj -0 -66.4535 Td -(1604 #include "x86.h") 91.7388 Tj -0 -75.9469 Td -(1605 #include "proc.h") 96.1073 Tj -0 -85.4403 Td -(1606 #include "spinlock.h") 113.5814 Tj -0 -94.9336 Td -(1607 ) 21.8426 Tj -0 -104.427 Td -(1608 struct {) 56.7907 Tj -0 -113.9203 Td -(1609 struct spinlock lock;) 122.3184 Tj -0 -123.4137 Td -(1610 struct proc proc[NPROC];) 135.4239 Tj -0 -132.9071 Td -(1611 } ptable;) 61.1592 Tj -0 -142.4004 Td -(1612 ) 21.8426 Tj -0 -151.8938 Td -(1613 static struct proc *initproc;) 148.5295 Tj -0 -161.3871 Td -(1614 ) 21.8426 Tj -0 -170.8805 Td -(1615 int nextpid = 1;) 91.7388 Tj -0 -180.3739 Td -(1616 extern void forkret\(void\);) 135.4239 Tj -0 -189.8672 Td -(1617 extern void trapret\(void\);) 135.4239 Tj -0 -199.3606 Td -(1618 ) 21.8426 Tj -0 -208.8539 Td -(1619 void) 39.3166 Tj -0 -218.3473 Td -(1620 pinit\(void\)) 69.8962 Tj -0 -227.8407 Td -(1621 {) 26.2111 Tj -0 -237.334 Td -(1622 initlock\(&ptable.lock, "ptable"\);) 174.7406 Tj -0 -246.8274 Td -(1623 }) 26.2111 Tj -0 -256.3207 Td -(1624 ) 21.8426 Tj -0 -265.8141 Td -(1625 ) 21.8426 Tj -0 -275.3075 Td -(1626 ) 21.8426 Tj -0 -284.8008 Td -(1627 ) 21.8426 Tj -0 -294.2942 Td -(1628 ) 21.8426 Tj -0 -303.7875 Td -(1629 ) 21.8426 Tj -0 -313.2809 Td -(1630 ) 21.8426 Tj -0 -322.7743 Td -(1631 ) 21.8426 Tj -0 -332.2676 Td -(1632 ) 21.8426 Tj -0 -341.761 Td -(1633 ) 21.8426 Tj -0 -351.2543 Td -(1634 ) 21.8426 Tj -0 -360.7477 Td -(1635 ) 21.8426 Tj -0 -370.2411 Td -(1636 ) 21.8426 Tj -0 -379.7344 Td -(1637 ) 21.8426 Tj -0 -389.2278 Td -(1638 ) 21.8426 Tj -0 -398.7211 Td -(1639 ) 21.8426 Tj -0 -408.2145 Td -(1640 ) 21.8426 Tj -0 -417.7079 Td -(1641 ) 21.8426 Tj -0 -427.2012 Td -(1642 ) 21.8426 Tj -0 -436.6946 Td -(1643 ) 21.8426 Tj -0 -446.1879 Td -(1644 ) 21.8426 Tj -0 -455.6813 Td -(1645 ) 21.8426 Tj -0 -465.1747 Td -(1646 ) 21.8426 Tj -0 -474.668 Td -(1647 ) 21.8426 Tj -0 -484.1614 Td -(1648 ) 21.8426 Tj -0 -493.6547 Td -(1649 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 16) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 2) 161.635 Tj -0 -28.4801 Td -(1650 // Print a process listing to console. For debugging.) 257.7424 Tj -0 -37.9735 Td -(1651 // Runs when user types ^P on console.) 187.8461 Tj -0 -47.4668 Td -(1652 // No lock to avoid wedging a stuck machine further.) 249.0053 Tj -0 -56.9602 Td -(1653 void) 39.3166 Tj -0 -66.4535 Td -(1654 procdump\(void\)) 83.0018 Tj -0 -75.9469 Td -(1655 {) 26.2111 Tj -0 -85.4403 Td -(1656 static char *states[] = {) 139.7925 Tj -0 -94.9336 Td -(1657 [UNUSED] "unused",) 122.3184 Tj -0 -104.427 Td -(1658 [EMBRYO] "embryo",) 122.3184 Tj -0 -113.9203 Td -(1659 [SLEEPING] "sleep ",) 122.3184 Tj -0 -123.4137 Td -(1660 [RUNNABLE] "runble",) 122.3184 Tj -0 -132.9071 Td -(1661 [RUNNING] "run ",) 122.3184 Tj -0 -142.4004 Td -(1662 [ZOMBIE] "zombie") 117.9499 Tj -0 -151.8938 Td -(1663 };) 39.3166 Tj -0 -161.3871 Td -(1664 int i;) 56.7907 Tj -0 -170.8805 Td -(1665 struct proc *p;) 96.1073 Tj -0 -180.3739 Td -(1666 char *state;) 83.0018 Tj -0 -189.8672 Td -(1667 uint pc[10];) 83.0018 Tj -0 -199.3606 Td -(1668 ) 21.8426 Tj -0 -208.8539 Td -(1669 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\){) 253.3738 Tj -0 -218.3473 Td -(1670 if\(p->state == UNUSED\)) 135.4239 Tj -0 -227.8407 Td -(1671 continue;) 87.3703 Tj -0 -237.334 Td -(1672 if\(p->state >= 0 && p->state < NELEM\(states\) && sta\ -tes[p->state]\)) 323.2701 Tj -0 -246.8274 Td -(1673 state = states[p->state];) 157.2665 Tj -0 -256.3207 Td -(1674 else) 56.7907 Tj -0 -265.8141 Td -(1675 state = "???";) 109.2129 Tj -0 -275.3075 Td -(1676 cprintf\("%d %s %s", p->pid, state, p->name\);) 231.5313 Tj -0 -284.8008 Td -(1677 if\(p->state == SLEEPING\){) 148.5295 Tj -0 -294.2942 Td -(1678 getcallerpcs\(\(uint*\)p->context->ebp+2, pc\);) 235.8998 Tj -0 -303.7875 Td -(1679 for\(i=0; i<10 && pc[i] != 0; i++\)) 192.2146 Tj -0 -313.2809 Td -(1680 cprintf\(" %p", pc[i]\);) 152.898 Tj -0 -322.7743 Td -(1681 }) 43.6851 Tj -0 -332.2676 Td -(1682 cprintf\("\\n"\);) 100.4758 Tj -0 -341.761 Td -(1683 }) 34.9481 Tj -0 -351.2543 Td -(1684 }) 26.2111 Tj -0 -360.7477 Td -(1685 ) 21.8426 Tj -0 -370.2411 Td -(1686 ) 21.8426 Tj -0 -379.7344 Td -(1687 ) 21.8426 Tj -0 -389.2278 Td -(1688 ) 21.8426 Tj -0 -398.7211 Td -(1689 ) 21.8426 Tj -0 -408.2145 Td -(1690 ) 21.8426 Tj -0 -417.7079 Td -(1691 ) 21.8426 Tj -0 -427.2012 Td -(1692 ) 21.8426 Tj -0 -436.6946 Td -(1693 ) 21.8426 Tj -0 -446.1879 Td -(1694 ) 21.8426 Tj -0 -455.6813 Td -(1695 ) 21.8426 Tj -0 -465.1747 Td -(1696 ) 21.8426 Tj -0 -474.668 Td -(1697 ) 21.8426 Tj -0 -484.1614 Td -(1698 ) 21.8426 Tj -0 -493.6547 Td -(1699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 16) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 24 24 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 3) 161.635 Tj -0 -28.4801 Td -(1700 // Set up CPU's kernel segment descriptors.) 209.6887 Tj -0 -37.9735 Td -(1701 // Run once at boot time on each CPU.) 183.4776 Tj -0 -47.4668 Td -(1702 void) 39.3166 Tj -0 -56.9602 Td -(1703 ksegment\(void\)) 83.0018 Tj -0 -66.4535 Td -(1704 {) 26.2111 Tj -0 -75.9469 Td -(1705 struct cpu *c;) 91.7388 Tj -0 -85.4403 Td -(1706 ) 21.8426 Tj -0 -94.9336 Td -(1707 c = &cpus[cpunum\(\)];) 117.9499 Tj -0 -104.427 Td -(1708 c->gdt[SEG_KCODE] = SEG\(STA_X|STA_R, 0, 0x100000 + 64*1\ -024-1, 0\);) 314.533 Tj -0 -113.9203 Td -(1709 c->gdt[SEG_KDATA] = SEG\(STA_W, 0, 0xffffffff, 0\);) 244.6368 Tj -0 -123.4137 Td -(1710 c->gdt[SEG_KCPU] = SEG\(STA_W, &c->cpu, 8, 0\);) 227.1628 Tj -0 -132.9071 Td -(1711 lgdt\(c->gdt, sizeof\(c->gdt\)\);) 157.2665 Tj -0 -142.4004 Td -(1712 loadgs\(SEG_KCPU << 3\);) 126.6869 Tj -0 -151.8938 Td -(1713 ) 21.8426 Tj -0 -161.3871 Td -(1714 // Initialize cpu-local storage.) 170.3721 Tj -0 -170.8805 Td -(1715 cpu = c;) 65.5277 Tj -0 -180.3739 Td -(1716 proc = 0;) 69.8962 Tj -0 -189.8672 Td -(1717 }) 26.2111 Tj -0 -199.3606 Td -(1718 ) 21.8426 Tj -0 -208.8539 Td -(1719 // Set up CPU's segment descriptors and current process ta\ -sk state.) 314.533 Tj -0 -218.3473 Td -(1720 void) 39.3166 Tj -0 -227.8407 Td -(1721 usegment\(void\)) 83.0018 Tj -0 -237.334 Td -(1722 {) 26.2111 Tj -0 -246.8274 Td -(1723 pushcli\(\);) 74.2647 Tj -0 -256.3207 Td -(1724 cpu->gdt[SEG_UCODE] = SEG\(STA_X|STA_R, proc->mem, proc-\ ->sz-1, DPL_USER\);) 345.1126 Tj -0 -265.8141 Td -(1725 cpu->gdt[SEG_UDATA] = SEG\(STA_W, proc->mem, proc->sz-1,\ - DPL_USER\);) 318.9016 Tj -0 -275.3075 Td -(1726 cpu->gdt[SEG_TSS] = SEG16\(STS_T32A, &cpu->ts, sizeof\(c\ -pu->ts\)-1, 0\);) 327.6386 Tj -0 -284.8008 Td -(1727 cpu->gdt[SEG_TSS].s = 0;) 135.4239 Tj -0 -294.2942 Td -(1728 cpu->ts.ss0 = SEG_KDATA << 3;) 157.2665 Tj -0 -303.7875 Td -(1729 cpu->ts.esp0 = \(uint\)proc->kstack + KSTACKSIZE;) 235.8998 Tj -0 -313.2809 Td -(1730 ltr\(SEG_TSS << 3\);) 109.2129 Tj -0 -322.7743 Td -(1731 popcli\(\);) 69.8962 Tj -0 -332.2676 Td -(1732 }) 26.2111 Tj -0 -341.761 Td -(1733 ) 21.8426 Tj -0 -351.2543 Td -(1734 ) 21.8426 Tj -0 -360.7477 Td -(1735 ) 21.8426 Tj -0 -370.2411 Td -(1736 ) 21.8426 Tj -0 -379.7344 Td -(1737 ) 21.8426 Tj -0 -389.2278 Td -(1738 ) 21.8426 Tj -0 -398.7211 Td -(1739 ) 21.8426 Tj -0 -408.2145 Td -(1740 ) 21.8426 Tj -0 -417.7079 Td -(1741 ) 21.8426 Tj -0 -427.2012 Td -(1742 ) 21.8426 Tj -0 -436.6946 Td -(1743 ) 21.8426 Tj -0 -446.1879 Td -(1744 ) 21.8426 Tj -0 -455.6813 Td -(1745 ) 21.8426 Tj -0 -465.1747 Td -(1746 ) 21.8426 Tj -0 -474.668 Td -(1747 ) 21.8426 Tj -0 -484.1614 Td -(1748 ) 21.8426 Tj -0 -493.6547 Td -(1749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 17) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 4) 161.635 Tj -0 -28.4801 Td -(1750 // Look in the process table for an UNUSED proc.) 231.5313 Tj -0 -37.9735 Td -(1751 // If found, change state to EMBRYO and return it.) 240.2683 Tj -0 -47.4668 Td -(1752 // Otherwise return 0.) 117.9499 Tj -0 -56.9602 Td -(1753 static struct proc*) 104.8443 Tj -0 -66.4535 Td -(1754 allocproc\(void\)) 87.3703 Tj -0 -75.9469 Td -(1755 {) 26.2111 Tj -0 -85.4403 Td -(1756 struct proc *p;) 96.1073 Tj -0 -94.9336 Td -(1757 char *sp;) 69.8962 Tj -0 -104.427 Td -(1758 ) 21.8426 Tj -0 -113.9203 Td -(1759 acquire\(&ptable.lock\);) 126.6869 Tj -0 -123.4137 Td -(1760 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\)) 249.0053 Tj -0 -132.9071 Td -(1761 if\(p->state == UNUSED\)) 135.4239 Tj -0 -142.4004 Td -(1762 goto found;) 96.1073 Tj -0 -151.8938 Td -(1763 release\(&ptable.lock\);) 126.6869 Tj -0 -161.3871 Td -(1764 return 0;) 69.8962 Tj -0 -170.8805 Td -(1765 ) 21.8426 Tj -0 -180.3739 Td -(1766 found:) 48.0537 Tj -0 -189.8672 Td -(1767 p->state = EMBRYO;) 109.2129 Tj -0 -199.3606 Td -(1768 p->pid = nextpid++;) 113.5814 Tj -0 -208.8539 Td -(1769 release\(&ptable.lock\);) 126.6869 Tj -0 -218.3473 Td -(1770 ) 21.8426 Tj -0 -227.8407 Td -(1771 // Allocate kernel stack if necessary.) 196.5831 Tj -0 -237.334 Td -(1772 if\(\(p->kstack = kalloc\(KSTACKSIZE\)\) == 0\){) 214.0572 Tj -0 -246.8274 Td -(1773 p->state = UNUSED;) 117.9499 Tj -0 -256.3207 Td -(1774 return 0;) 78.6333 Tj -0 -265.8141 Td -(1775 }) 34.9481 Tj -0 -275.3075 Td -(1776 sp = p->kstack + KSTACKSIZE;) 152.898 Tj -0 -284.8008 Td -(1777 ) 21.8426 Tj -0 -294.2942 Td -(1778 // Leave room for trap frame.) 157.2665 Tj -0 -303.7875 Td -(1779 sp -= sizeof *p->tf;) 117.9499 Tj -0 -313.2809 Td -(1780 p->tf = \(struct trapframe*\)sp;) 161.635 Tj -0 -322.7743 Td -(1781 ) 21.8426 Tj -0 -332.2676 Td -(1782 // Set up new context to start executing at forkret,) 257.7424 Tj -0 -341.761 Td -(1783 // which returns to trapret \(see below\).) 205.3202 Tj -0 -351.2543 Td -(1784 sp -= 4;) 65.5277 Tj -0 -360.7477 Td -(1785 *\(uint*\)sp = \(uint\)trapret;) 148.5295 Tj -0 -370.2411 Td -(1786 ) 21.8426 Tj -0 -379.7344 Td -(1787 sp -= sizeof *p->context;) 139.7925 Tj -0 -389.2278 Td -(1788 p->context = \(struct context*\)sp;) 174.7406 Tj -0 -398.7211 Td -(1789 memset\(p->context, 0, sizeof *p->context\);) 214.0572 Tj -0 -408.2145 Td -(1790 p->context->eip = \(uint\)forkret;) 170.3721 Tj -0 -417.7079 Td -(1791 return p;) 69.8962 Tj -0 -427.2012 Td -(1792 }) 26.2111 Tj -0 -436.6946 Td -(1793 ) 21.8426 Tj -0 -446.1879 Td -(1794 ) 21.8426 Tj -0 -455.6813 Td -(1795 ) 21.8426 Tj -0 -465.1747 Td -(1796 ) 21.8426 Tj -0 -474.668 Td -(1797 ) 21.8426 Tj -0 -484.1614 Td -(1798 ) 21.8426 Tj -0 -493.6547 Td -(1799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 17) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 25 25 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 5) 161.635 Tj -0 -28.4801 Td -(1800 // Set up first user process.) 148.5295 Tj -0 -37.9735 Td -(1801 void) 39.3166 Tj -0 -47.4668 Td -(1802 userinit\(void\)) 83.0018 Tj -0 -56.9602 Td -(1803 {) 26.2111 Tj -0 -66.4535 Td -(1804 struct proc *p;) 96.1073 Tj -0 -75.9469 Td -(1805 extern char _binary_initcode_start[], _binary_initcode_s\ -ize[];) 301.4275 Tj -0 -85.4403 Td -(1806 ) 21.8426 Tj -0 -94.9336 Td -(1807 p = allocproc\(\);) 100.4758 Tj -0 -104.427 Td -(1808 initproc = p;) 87.3703 Tj -0 -113.9203 Td -(1809 ) 21.8426 Tj -0 -123.4137 Td -(1810 // Initialize memory from initcode.S) 187.8461 Tj -0 -132.9071 Td -(1811 p->sz = PAGE;) 87.3703 Tj -0 -142.4004 Td -(1812 p->mem = kalloc\(p->sz\);) 131.0554 Tj -0 -151.8938 Td -(1813 memset\(p->mem, 0, p->sz\);) 139.7925 Tj -0 -161.3871 Td -(1814 memmove\(p->mem, _binary_initcode_start, \(int\)_binary_\ -initcode_size\);) 327.6386 Tj -0 -170.8805 Td -(1815 ) 21.8426 Tj -0 -180.3739 Td -(1816 memset\(p->tf, 0, sizeof\(*p->tf\)\);) 174.7406 Tj -0 -189.8672 Td -(1817 p->tf->cs = \(SEG_UCODE << 3\) | DPL_USER;) 205.3202 Tj -0 -199.3606 Td -(1818 p->tf->ds = \(SEG_UDATA << 3\) | DPL_USER;) 205.3202 Tj -0 -208.8539 Td -(1819 p->tf->es = p->tf->ds;) 126.6869 Tj -0 -218.3473 Td -(1820 p->tf->ss = p->tf->ds;) 126.6869 Tj -0 -227.8407 Td -(1821 p->tf->eflags = FL_IF;) 126.6869 Tj -0 -237.334 Td -(1822 p->tf->esp = p->sz;) 113.5814 Tj -0 -246.8274 Td -(1823 p->tf->eip = 0; // beginning of initcode.S) 218.4257 Tj -0 -256.3207 Td -(1824 ) 21.8426 Tj -0 -265.8141 Td -(1825 safestrcpy\(p->name, "initcode", sizeof\(p->name\)\);) 244.6368 Tj -0 -275.3075 Td -(1826 p->cwd = namei\("/"\);) 117.9499 Tj -0 -284.8008 Td -(1827 ) 21.8426 Tj -0 -294.2942 Td -(1828 p->state = RUNNABLE;) 117.9499 Tj -0 -303.7875 Td -(1829 }) 26.2111 Tj -0 -313.2809 Td -(1830 ) 21.8426 Tj -0 -322.7743 Td -(1831 // Grow current process's memory by n bytes.) 214.0572 Tj -0 -332.2676 Td -(1832 // Return 0 on success, -1 on failure.) 187.8461 Tj -0 -341.761 Td -(1833 int) 34.9481 Tj -0 -351.2543 Td -(1834 growproc\(int n\)) 87.3703 Tj -0 -360.7477 Td -(1835 {) 26.2111 Tj -0 -370.2411 Td -(1836 char *newmem;) 87.3703 Tj -0 -379.7344 Td -(1837 ) 21.8426 Tj -0 -389.2278 Td -(1838 newmem = kalloc\(proc->sz + n\);) 161.635 Tj -0 -398.7211 Td -(1839 if\(newmem == 0\)) 96.1073 Tj -0 -408.2145 Td -(1840 return -1;) 83.0018 Tj -0 -417.7079 Td -(1841 memmove\(newmem, proc->mem, proc->sz\);) 192.2146 Tj -0 -427.2012 Td -(1842 memset\(newmem + proc->sz, 0, n\);) 170.3721 Tj -0 -436.6946 Td -(1843 kfree\(proc->mem, proc->sz\);) 148.5295 Tj -0 -446.1879 Td -(1844 proc->mem = newmem;) 113.5814 Tj -0 -455.6813 Td -(1845 proc->sz += n;) 91.7388 Tj -0 -465.1747 Td -(1846 usegment\(\);) 78.6333 Tj -0 -474.668 Td -(1847 return 0;) 69.8962 Tj -0 -484.1614 Td -(1848 }) 26.2111 Tj -0 -493.6547 Td -(1849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 18) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 6) 161.635 Tj -0 -28.4801 Td -(1850 // Create a new process copying p as the parent.) 231.5313 Tj -0 -37.9735 Td -(1851 // Sets up stack to return as if from system call.) 240.2683 Tj -0 -47.4668 Td -(1852 // Caller must set state of returned proc to RUNNABLE.) 257.7424 Tj -0 -56.9602 Td -(1853 int) 34.9481 Tj -0 -66.4535 Td -(1854 fork\(void\)) 65.5277 Tj -0 -75.9469 Td -(1855 {) 26.2111 Tj -0 -85.4403 Td -(1856 int i, pid;) 78.6333 Tj -0 -94.9336 Td -(1857 struct proc *np;) 100.4758 Tj -0 -104.427 Td -(1858 ) 21.8426 Tj -0 -113.9203 Td -(1859 // Allocate process.) 117.9499 Tj -0 -123.4137 Td -(1860 if\(\(np = allocproc\(\)\) == 0\)) 148.5295 Tj -0 -132.9071 Td -(1861 return -1;) 83.0018 Tj -0 -142.4004 Td -(1862 ) 21.8426 Tj -0 -151.8938 Td -(1863 // Copy process state from p.) 157.2665 Tj -0 -161.3871 Td -(1864 np->sz = proc->sz;) 109.2129 Tj -0 -170.8805 Td -(1865 if\(\(np->mem = kalloc\(np->sz\)\) == 0\){) 187.8461 Tj -0 -180.3739 Td -(1866 kfree\(np->kstack, KSTACKSIZE\);) 170.3721 Tj -0 -189.8672 Td -(1867 np->kstack = 0;) 104.8443 Tj -0 -199.3606 Td -(1868 np->state = UNUSED;) 122.3184 Tj -0 -208.8539 Td -(1869 return -1;) 83.0018 Tj -0 -218.3473 Td -(1870 }) 34.9481 Tj -0 -227.8407 Td -(1871 memmove\(np->mem, proc->mem, np->sz\);) 187.8461 Tj -0 -237.334 Td -(1872 np->parent = proc;) 109.2129 Tj -0 -246.8274 Td -(1873 *np->tf = *proc->tf;) 117.9499 Tj -0 -256.3207 Td -(1874 ) 21.8426 Tj -0 -265.8141 Td -(1875 // Clear %eax so that fork returns 0 in the child.) 249.0053 Tj -0 -275.3075 Td -(1876 np->tf->eax = 0;) 100.4758 Tj -0 -284.8008 Td -(1877 ) 21.8426 Tj -0 -294.2942 Td -(1878 for\(i = 0; i < NOFILE; i++\)) 148.5295 Tj -0 -303.7875 Td -(1879 if\(proc->ofile[i]\)) 117.9499 Tj -0 -313.2809 Td -(1880 np->ofile[i] = filedup\(proc->ofile[i]\);) 218.4257 Tj -0 -322.7743 Td -(1881 np->cwd = idup\(proc->cwd\);) 144.161 Tj -0 -332.2676 Td -(1882 ) 21.8426 Tj -0 -341.761 Td -(1883 pid = np->pid;) 91.7388 Tj -0 -351.2543 Td -(1884 np->state = RUNNABLE;) 122.3184 Tj -0 -360.7477 Td -(1885 ) 21.8426 Tj -0 -370.2411 Td -(1886 return pid;) 78.6333 Tj -0 -379.7344 Td -(1887 }) 26.2111 Tj -0 -389.2278 Td -(1888 ) 21.8426 Tj -0 -398.7211 Td -(1889 ) 21.8426 Tj -0 -408.2145 Td -(1890 ) 21.8426 Tj -0 -417.7079 Td -(1891 ) 21.8426 Tj -0 -427.2012 Td -(1892 ) 21.8426 Tj -0 -436.6946 Td -(1893 ) 21.8426 Tj -0 -446.1879 Td -(1894 ) 21.8426 Tj -0 -455.6813 Td -(1895 ) 21.8426 Tj -0 -465.1747 Td -(1896 ) 21.8426 Tj -0 -474.668 Td -(1897 ) 21.8426 Tj -0 -484.1614 Td -(1898 ) 21.8426 Tj -0 -493.6547 Td -(1899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 18) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 26 26 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 7) 161.635 Tj -0 -28.4801 Td -(1900 // Per-CPU process scheduler.) 148.5295 Tj -0 -37.9735 Td -(1901 // Each CPU calls scheduler\(\) after setting itself up.) 257.7424 Tj -0 -47.4668 Td -(1902 // Scheduler never returns. It loops, doing:) 218.4257 Tj -0 -56.9602 Td -(1903 // - choose a process to run) 148.5295 Tj -0 -66.4535 Td -(1904 // - swtch to start running that process) 200.9517 Tj -0 -75.9469 Td -(1905 // - eventually that process transfers control) 227.1628 Tj -0 -85.4403 Td -(1906 // via swtch back to the scheduler.) 196.5831 Tj -0 -94.9336 Td -(1907 void) 39.3166 Tj -0 -104.427 Td -(1908 scheduler\(void\)) 87.3703 Tj -0 -113.9203 Td -(1909 {) 26.2111 Tj -0 -123.4137 Td -(1910 struct proc *p;) 96.1073 Tj -0 -132.9071 Td -(1911 ) 21.8426 Tj -0 -142.4004 Td -(1912 for\(;;\){) 65.5277 Tj -0 -151.8938 Td -(1913 // Enable interrupts on this processor.) 209.6887 Tj -0 -161.3871 Td -(1914 sti\(\);) 65.5277 Tj -0 -170.8805 Td -(1915 ) 21.8426 Tj -0 -180.3739 Td -(1916 // Loop over process table looking for process to run.) 275.2164 Tj -0 -189.8672 Td -(1917 acquire\(&ptable.lock\);) 135.4239 Tj -0 -199.3606 Td -(1918 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\){) 262.1109 Tj -0 -208.8539 Td -(1919 if\(p->state != RUNNABLE\)) 152.898 Tj -0 -218.3473 Td -(1920 continue;) 96.1073 Tj -0 -227.8407 Td -(1921 ) 21.8426 Tj -0 -237.334 Td -(1922 // Switch to chosen process. It is the process's jo\ -b) 279.5849 Tj -0 -246.8274 Td -(1923 // to release ptable.lock and then reacquire it) 253.3738 Tj -0 -256.3207 Td -(1924 // before jumping back to us.) 174.7406 Tj -0 -265.8141 Td -(1925 proc = p;) 87.3703 Tj -0 -275.3075 Td -(1926 usegment\(\);) 96.1073 Tj -0 -284.8008 Td -(1927 p->state = RUNNING;) 131.0554 Tj -0 -294.2942 Td -(1928 swtch\(&cpu->scheduler, proc->context\);) 214.0572 Tj -0 -303.7875 Td -(1929 ) 21.8426 Tj -0 -313.2809 Td -(1930 // Process is done running for now.) 200.9517 Tj -0 -322.7743 Td -(1931 // It should have changed its p->state before coming\ - back.) 301.4275 Tj -0 -332.2676 Td -(1932 proc = 0;) 87.3703 Tj -0 -341.761 Td -(1933 }) 43.6851 Tj -0 -351.2543 Td -(1934 release\(&ptable.lock\);) 135.4239 Tj -0 -360.7477 Td -(1935 ) 21.8426 Tj -0 -370.2411 Td -(1936 }) 34.9481 Tj -0 -379.7344 Td -(1937 }) 26.2111 Tj -0 -389.2278 Td -(1938 ) 21.8426 Tj -0 -398.7211 Td -(1939 ) 21.8426 Tj -0 -408.2145 Td -(1940 ) 21.8426 Tj -0 -417.7079 Td -(1941 ) 21.8426 Tj -0 -427.2012 Td -(1942 ) 21.8426 Tj -0 -436.6946 Td -(1943 ) 21.8426 Tj -0 -446.1879 Td -(1944 ) 21.8426 Tj -0 -455.6813 Td -(1945 ) 21.8426 Tj -0 -465.1747 Td -(1946 ) 21.8426 Tj -0 -474.668 Td -(1947 ) 21.8426 Tj -0 -484.1614 Td -(1948 ) 21.8426 Tj -0 -493.6547 Td -(1949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 19) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 8) 161.635 Tj -0 -28.4801 Td -(1950 // Enter scheduler. Must hold only ptable.lock) 227.1628 Tj -0 -37.9735 Td -(1951 // and have changed proc->state.) 161.635 Tj -0 -47.4668 Td -(1952 void) 39.3166 Tj -0 -56.9602 Td -(1953 sched\(void\)) 69.8962 Tj -0 -66.4535 Td -(1954 {) 26.2111 Tj -0 -75.9469 Td -(1955 int intena;) 78.6333 Tj -0 -85.4403 Td -(1956 ) 21.8426 Tj -0 -94.9336 Td -(1957 if\(!holding\(&ptable.lock\)\)) 144.161 Tj -0 -104.427 Td -(1958 panic\("sched ptable.lock"\);) 157.2665 Tj -0 -113.9203 Td -(1959 if\(cpu->ncli != 1\)) 109.2129 Tj -0 -123.4137 Td -(1960 panic\("sched locks"\);) 131.0554 Tj -0 -132.9071 Td -(1961 if\(proc->state == RUNNING\)) 144.161 Tj -0 -142.4004 Td -(1962 panic\("sched running"\);) 139.7925 Tj -0 -151.8938 Td -(1963 if\(readeflags\(\)&FL_IF\)) 126.6869 Tj -0 -161.3871 Td -(1964 panic\("sched interruptible"\);) 166.0035 Tj -0 -170.8805 Td -(1965 ) 21.8426 Tj -0 -180.3739 Td -(1966 intena = cpu->intena;) 122.3184 Tj -0 -189.8672 Td -(1967 swtch\(&proc->context, cpu->scheduler\);) 196.5831 Tj -0 -199.3606 Td -(1968 cpu->intena = intena;) 122.3184 Tj -0 -208.8539 Td -(1969 }) 26.2111 Tj -0 -218.3473 Td -(1970 ) 21.8426 Tj -0 -227.8407 Td -(1971 // Give up the CPU for one scheduling round.) 214.0572 Tj -0 -237.334 Td -(1972 void) 39.3166 Tj -0 -246.8274 Td -(1973 yield\(void\)) 69.8962 Tj -0 -256.3207 Td -(1974 {) 26.2111 Tj -0 -265.8141 Td -(1975 acquire\(&ptable.lock\); ) 135.4239 Tj -0 -275.3075 Td -(1976 proc->state = RUNNABLE;) 131.0554 Tj -0 -284.8008 Td -(1977 sched\(\);) 65.5277 Tj -0 -294.2942 Td -(1978 release\(&ptable.lock\);) 126.6869 Tj -0 -303.7875 Td -(1979 }) 26.2111 Tj -0 -313.2809 Td -(1980 ) 21.8426 Tj -0 -322.7743 Td -(1981 // A fork child's very first scheduling by scheduler\(\)) 257.7424 Tj -0 -332.2676 Td -(1982 // will swtch here. "Return" to user space.) 214.0572 Tj -0 -341.761 Td -(1983 void) 39.3166 Tj -0 -351.2543 Td -(1984 forkret\(void\)) 78.6333 Tj -0 -360.7477 Td -(1985 {) 26.2111 Tj -0 -370.2411 Td -(1986 // Still holding ptable.lock from scheduler.) 222.7942 Tj -0 -379.7344 Td -(1987 release\(&ptable.lock\);) 126.6869 Tj -0 -389.2278 Td -(1988 ) 21.8426 Tj -0 -398.7211 Td -(1989 // Return to "caller", actually trapret \(see allocproc\)\ -.) 275.2164 Tj -0 -408.2145 Td -(1990 }) 26.2111 Tj -0 -417.7079 Td -(1991 ) 21.8426 Tj -0 -427.2012 Td -(1992 ) 21.8426 Tj -0 -436.6946 Td -(1993 ) 21.8426 Tj -0 -446.1879 Td -(1994 ) 21.8426 Tj -0 -455.6813 Td -(1995 ) 21.8426 Tj -0 -465.1747 Td -(1996 ) 21.8426 Tj -0 -474.668 Td -(1997 ) 21.8426 Tj -0 -484.1614 Td -(1998 ) 21.8426 Tj -0 -493.6547 Td -(1999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 19) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 27 27 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 9) 161.635 Tj -0 -28.4801 Td -(2000 // Atomically release lock and sleep on chan.) 218.4257 Tj -0 -37.9735 Td -(2001 // Reacquires lock when awakened.) 166.0035 Tj -0 -47.4668 Td -(2002 void) 39.3166 Tj -0 -56.9602 Td -(2003 sleep\(void *chan, struct spinlock *lk\)) 187.8461 Tj -0 -66.4535 Td -(2004 {) 26.2111 Tj -0 -75.9469 Td -(2005 if\(proc == 0\)) 87.3703 Tj -0 -85.4403 Td -(2006 panic\("sleep"\);) 104.8443 Tj -0 -94.9336 Td -(2007 ) 21.8426 Tj -0 -104.427 Td -(2008 if\(lk == 0\)) 78.6333 Tj -0 -113.9203 Td -(2009 panic\("sleep without lk"\);) 152.898 Tj -0 -123.4137 Td -(2010 ) 21.8426 Tj -0 -132.9071 Td -(2011 // Must acquire ptable.lock in order to) 200.9517 Tj -0 -142.4004 Td -(2012 // change p->state and then call sched.) 200.9517 Tj -0 -151.8938 Td -(2013 // Once we hold ptable.lock, we can be) 196.5831 Tj -0 -161.3871 Td -(2014 // guaranteed that we won't miss any wakeup) 218.4257 Tj -0 -170.8805 Td -(2015 // \(wakeup runs with ptable.lock locked\),) 209.6887 Tj -0 -180.3739 Td -(2016 // so it's okay to release lk.) 161.635 Tj -0 -189.8672 Td -(2017 if\(lk != &ptable.lock\){ ) 139.7925 Tj -0 -199.3606 Td -(2018 acquire\(&ptable.lock\); ) 144.161 Tj -0 -208.8539 Td -(2019 release\(lk\);) 91.7388 Tj -0 -218.3473 Td -(2020 }) 34.9481 Tj -0 -227.8407 Td -(2021 ) 21.8426 Tj -0 -237.334 Td -(2022 // Go to sleep.) 96.1073 Tj -0 -246.8274 Td -(2023 proc->chan = chan;) 109.2129 Tj -0 -256.3207 Td -(2024 proc->state = SLEEPING;) 131.0554 Tj -0 -265.8141 Td -(2025 sched\(\);) 65.5277 Tj -0 -275.3075 Td -(2026 ) 21.8426 Tj -0 -284.8008 Td -(2027 // Tidy up.) 78.6333 Tj -0 -294.2942 Td -(2028 proc->chan = 0;) 96.1073 Tj -0 -303.7875 Td -(2029 ) 21.8426 Tj -0 -313.2809 Td -(2030 // Reacquire original lock.) 148.5295 Tj -0 -322.7743 Td -(2031 if\(lk != &ptable.lock\){ ) 139.7925 Tj -0 -332.2676 Td -(2032 release\(&ptable.lock\);) 135.4239 Tj -0 -341.761 Td -(2033 acquire\(lk\);) 91.7388 Tj -0 -351.2543 Td -(2034 }) 34.9481 Tj -0 -360.7477 Td -(2035 }) 26.2111 Tj -0 -370.2411 Td -(2036 ) 21.8426 Tj -0 -379.7344 Td -(2037 ) 21.8426 Tj -0 -389.2278 Td -(2038 ) 21.8426 Tj -0 -398.7211 Td -(2039 ) 21.8426 Tj -0 -408.2145 Td -(2040 ) 21.8426 Tj -0 -417.7079 Td -(2041 ) 21.8426 Tj -0 -427.2012 Td -(2042 ) 21.8426 Tj -0 -436.6946 Td -(2043 ) 21.8426 Tj -0 -446.1879 Td -(2044 ) 21.8426 Tj -0 -455.6813 Td -(2045 ) 21.8426 Tj -0 -465.1747 Td -(2046 ) 21.8426 Tj -0 -474.668 Td -(2047 ) 21.8426 Tj -0 -484.1614 Td -(2048 ) 21.8426 Tj -0 -493.6547 Td -(2049 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 20) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 10) 166.0035 Tj -0 -28.4801 Td -(2050 // Wake up all processes sleeping on chan.) 205.3202 Tj -0 -37.9735 Td -(2051 // The ptable lock must be held.) 161.635 Tj -0 -47.4668 Td -(2052 static void) 69.8962 Tj -0 -56.9602 Td -(2053 wakeup1\(void *chan\)) 104.8443 Tj -0 -66.4535 Td -(2054 {) 26.2111 Tj -0 -75.9469 Td -(2055 struct proc *p;) 96.1073 Tj -0 -85.4403 Td -(2056 ) 21.8426 Tj -0 -94.9336 Td -(2057 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\)) 249.0053 Tj -0 -104.427 Td -(2058 if\(p->state == SLEEPING && p->chan == chan\)) 227.1628 Tj -0 -113.9203 Td -(2059 p->state = RUNNABLE;) 135.4239 Tj -0 -123.4137 Td -(2060 }) 26.2111 Tj -0 -132.9071 Td -(2061 ) 21.8426 Tj -0 -142.4004 Td -(2062 // Wake up all processes sleeping on chan.) 205.3202 Tj -0 -151.8938 Td -(2063 void) 39.3166 Tj -0 -161.3871 Td -(2064 wakeup\(void *chan\)) 100.4758 Tj -0 -170.8805 Td -(2065 {) 26.2111 Tj -0 -180.3739 Td -(2066 acquire\(&ptable.lock\);) 126.6869 Tj -0 -189.8672 Td -(2067 wakeup1\(chan\);) 91.7388 Tj -0 -199.3606 Td -(2068 release\(&ptable.lock\);) 126.6869 Tj -0 -208.8539 Td -(2069 }) 26.2111 Tj -0 -218.3473 Td -(2070 ) 21.8426 Tj -0 -227.8407 Td -(2071 // Kill the process with the given pid.) 192.2146 Tj -0 -237.334 Td -(2072 // Process won't exit until it returns) 187.8461 Tj -0 -246.8274 Td -(2073 // to user space \(see trap in trap.c\).) 187.8461 Tj -0 -256.3207 Td -(2074 int) 34.9481 Tj -0 -265.8141 Td -(2075 kill\(int pid\)) 78.6333 Tj -0 -275.3075 Td -(2076 {) 26.2111 Tj -0 -284.8008 Td -(2077 struct proc *p;) 96.1073 Tj -0 -294.2942 Td -(2078 ) 21.8426 Tj -0 -303.7875 Td -(2079 acquire\(&ptable.lock\);) 126.6869 Tj -0 -313.2809 Td -(2080 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\){) 253.3738 Tj -0 -322.7743 Td -(2081 if\(p->pid == pid\){) 117.9499 Tj -0 -332.2676 Td -(2082 p->killed = 1;) 109.2129 Tj -0 -341.761 Td -(2083 // Wake process from sleep if necessary.) 222.7942 Tj -0 -351.2543 Td -(2084 if\(p->state == SLEEPING\)) 152.898 Tj -0 -360.7477 Td -(2085 p->state = RUNNABLE;) 144.161 Tj -0 -370.2411 Td -(2086 release\(&ptable.lock\);) 144.161 Tj -0 -379.7344 Td -(2087 return 0;) 87.3703 Tj -0 -389.2278 Td -(2088 }) 43.6851 Tj -0 -398.7211 Td -(2089 }) 34.9481 Tj -0 -408.2145 Td -(2090 release\(&ptable.lock\);) 126.6869 Tj -0 -417.7079 Td -(2091 return -1;) 74.2647 Tj -0 -427.2012 Td -(2092 }) 26.2111 Tj -0 -436.6946 Td -(2093 ) 21.8426 Tj -0 -446.1879 Td -(2094 ) 21.8426 Tj -0 -455.6813 Td -(2095 ) 21.8426 Tj -0 -465.1747 Td -(2096 ) 21.8426 Tj -0 -474.668 Td -(2097 ) 21.8426 Tj -0 -484.1614 Td -(2098 ) 21.8426 Tj -0 -493.6547 Td -(2099 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 20) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 28 28 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 11) 166.0035 Tj -0 -28.4801 Td -(2100 // Exit the current process. Does not return.) 222.7942 Tj -0 -37.9735 Td -(2101 // An exited process remains in the zombie state) 231.5313 Tj -0 -47.4668 Td -(2102 // until its parent calls wait\(\) to find out it exited.) 262.1109 Tj -0 -56.9602 Td -(2103 void) 39.3166 Tj -0 -66.4535 Td -(2104 exit\(void\)) 65.5277 Tj -0 -75.9469 Td -(2105 {) 26.2111 Tj -0 -85.4403 Td -(2106 struct proc *p;) 96.1073 Tj -0 -94.9336 Td -(2107 int fd;) 61.1592 Tj -0 -104.427 Td -(2108 ) 21.8426 Tj -0 -113.9203 Td -(2109 if\(proc == initproc\)) 117.9499 Tj -0 -123.4137 Td -(2110 panic\("init exiting"\);) 135.4239 Tj -0 -132.9071 Td -(2111 ) 21.8426 Tj -0 -142.4004 Td -(2112 // Close all open files.) 135.4239 Tj -0 -151.8938 Td -(2113 for\(fd = 0; fd < NOFILE; fd++\){) 166.0035 Tj -0 -161.3871 Td -(2114 if\(proc->ofile[fd]\){) 126.6869 Tj -0 -170.8805 Td -(2115 fileclose\(proc->ofile[fd]\);) 166.0035 Tj -0 -180.3739 Td -(2116 proc->ofile[fd] = 0;) 135.4239 Tj -0 -189.8672 Td -(2117 }) 43.6851 Tj -0 -199.3606 Td -(2118 }) 34.9481 Tj -0 -208.8539 Td -(2119 ) 21.8426 Tj -0 -218.3473 Td -(2120 iput\(proc->cwd\);) 100.4758 Tj -0 -227.8407 Td -(2121 proc->cwd = 0;) 91.7388 Tj -0 -237.334 Td -(2122 ) 21.8426 Tj -0 -246.8274 Td -(2123 acquire\(&ptable.lock\);) 126.6869 Tj -0 -256.3207 Td -(2124 ) 21.8426 Tj -0 -265.8141 Td -(2125 // Parent might be sleeping in wait\(\).) 196.5831 Tj -0 -275.3075 Td -(2126 wakeup1\(proc->parent\);) 126.6869 Tj -0 -284.8008 Td -(2127 ) 21.8426 Tj -0 -294.2942 Td -(2128 // Pass abandoned children to init.) 183.4776 Tj -0 -303.7875 Td -(2129 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\){) 253.3738 Tj -0 -313.2809 Td -(2130 if\(p->parent == proc\){) 135.4239 Tj -0 -322.7743 Td -(2131 p->parent = initproc;) 139.7925 Tj -0 -332.2676 Td -(2132 if\(p->state == ZOMBIE\)) 144.161 Tj -0 -341.761 Td -(2133 wakeup1\(initproc\);) 135.4239 Tj -0 -351.2543 Td -(2134 }) 43.6851 Tj -0 -360.7477 Td -(2135 }) 34.9481 Tj -0 -370.2411 Td -(2136 ) 21.8426 Tj -0 -379.7344 Td -(2137 // Jump into the scheduler, never to return.) 222.7942 Tj -0 -389.2278 Td -(2138 proc->state = ZOMBIE;) 122.3184 Tj -0 -398.7211 Td -(2139 sched\(\);) 65.5277 Tj -0 -408.2145 Td -(2140 panic\("zombie exit"\);) 122.3184 Tj -0 -417.7079 Td -(2141 }) 26.2111 Tj -0 -427.2012 Td -(2142 ) 21.8426 Tj -0 -436.6946 Td -(2143 ) 21.8426 Tj -0 -446.1879 Td -(2144 ) 21.8426 Tj -0 -455.6813 Td -(2145 ) 21.8426 Tj -0 -465.1747 Td -(2146 ) 21.8426 Tj -0 -474.668 Td -(2147 ) 21.8426 Tj -0 -484.1614 Td -(2148 ) 21.8426 Tj -0 -493.6547 Td -(2149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 21) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/proc.c Page 12) 166.0035 Tj -0 -28.4801 Td -(2150 // Wait for a child process to exit and return its pid.) 262.1109 Tj -0 -37.9735 Td -(2151 // Return -1 if this process has no children.) 218.4257 Tj -0 -47.4668 Td -(2152 int) 34.9481 Tj -0 -56.9602 Td -(2153 wait\(void\)) 65.5277 Tj -0 -66.4535 Td -(2154 {) 26.2111 Tj -0 -75.9469 Td -(2155 struct proc *p;) 96.1073 Tj -0 -85.4403 Td -(2156 int havekids, pid;) 109.2129 Tj -0 -94.9336 Td -(2157 ) 21.8426 Tj -0 -104.427 Td -(2158 acquire\(&ptable.lock\);) 126.6869 Tj -0 -113.9203 Td -(2159 for\(;;\){) 65.5277 Tj -0 -123.4137 Td -(2160 // Scan through table looking for zombie children.) 257.7424 Tj -0 -132.9071 Td -(2161 havekids = 0;) 96.1073 Tj -0 -142.4004 Td -(2162 for\(p = ptable.proc; p < &ptable.proc[NPROC]; p++\){) 262.1109 Tj -0 -151.8938 Td -(2163 if\(p->parent != proc\)) 139.7925 Tj -0 -161.3871 Td -(2164 continue;) 96.1073 Tj -0 -170.8805 Td -(2165 havekids = 1;) 104.8443 Tj -0 -180.3739 Td -(2166 if\(p->state == ZOMBIE\){) 148.5295 Tj -0 -189.8672 Td -(2167 // Found one.) 113.5814 Tj -0 -199.3606 Td -(2168 pid = p->pid;) 113.5814 Tj -0 -208.8539 Td -(2169 kfree\(p->mem, p->sz\);) 148.5295 Tj -0 -218.3473 Td -(2170 kfree\(p->kstack, KSTACKSIZE\);) 183.4776 Tj -0 -227.8407 Td -(2171 p->state = UNUSED;) 135.4239 Tj -0 -237.334 Td -(2172 p->pid = 0;) 104.8443 Tj -0 -246.8274 Td -(2173 p->parent = 0;) 117.9499 Tj -0 -256.3207 Td -(2174 p->name[0] = 0;) 122.3184 Tj -0 -265.8141 Td -(2175 p->killed = 0;) 117.9499 Tj -0 -275.3075 Td -(2176 release\(&ptable.lock\);) 152.898 Tj -0 -284.8008 Td -(2177 return pid;) 104.8443 Tj -0 -294.2942 Td -(2178 }) 52.4222 Tj -0 -303.7875 Td -(2179 }) 43.6851 Tj -0 -313.2809 Td -(2180 ) 21.8426 Tj -0 -322.7743 Td -(2181 // No point waiting if we don't have any children.) 257.7424 Tj -0 -332.2676 Td -(2182 if\(!havekids || proc->killed\){) 170.3721 Tj -0 -341.761 Td -(2183 release\(&ptable.lock\);) 144.161 Tj -0 -351.2543 Td -(2184 return -1;) 91.7388 Tj -0 -360.7477 Td -(2185 }) 43.6851 Tj -0 -370.2411 Td -(2186 ) 21.8426 Tj -0 -379.7344 Td -(2187 // Wait for children to exit. \(See wakeup1 call in p\ -roc_exit.\)) 314.533 Tj -0 -389.2278 Td -(2188 sleep\(proc, &ptable.lock\); ) 161.635 Tj -0 -398.7211 Td -(2189 }) 34.9481 Tj -0 -408.2145 Td -(2190 }) 26.2111 Tj -0 -417.7079 Td -(2191 ) 21.8426 Tj -0 -427.2012 Td -(2192 ) 21.8426 Tj -0 -436.6946 Td -(2193 ) 21.8426 Tj -0 -446.1879 Td -(2194 ) 21.8426 Tj -0 -455.6813 Td -(2195 ) 21.8426 Tj -0 -465.1747 Td -(2196 ) 21.8426 Tj -0 -474.668 Td -(2197 ) 21.8426 Tj -0 -484.1614 Td -(2198 ) 21.8426 Tj -0 -493.6547 Td -(2199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 21) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 29 29 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/swtch.S Page 1) 166.0035 Tj -0 -28.4801 Td -(2200 # Context switch) 91.7388 Tj -0 -37.9735 Td -(2201 #) 26.2111 Tj -0 -47.4668 Td -(2202 # void swtch\(struct context **old, struct context *new\)\ -;) 275.2164 Tj -0 -56.9602 Td -(2203 #) 26.2111 Tj -0 -66.4535 Td -(2204 # Save current register context in old) 187.8461 Tj -0 -75.9469 Td -(2205 # and then load register context from new.) 205.3202 Tj -0 -85.4403 Td -(2206 ) 21.8426 Tj -0 -94.9336 Td -(2207 .globl swtch) 74.2647 Tj -0 -104.427 Td -(2208 swtch:) 48.0537 Tj -0 -113.9203 Td -(2209 movl 4\(%esp\), %eax) 109.2129 Tj -0 -123.4137 Td -(2210 movl 8\(%esp\), %edx) 109.2129 Tj -0 -132.9071 Td -(2211 ) 21.8426 Tj -0 -142.4004 Td -(2212 # Save old callee-save registers) 170.3721 Tj -0 -151.8938 Td -(2213 pushl %ebp) 74.2647 Tj -0 -161.3871 Td -(2214 pushl %ebx) 74.2647 Tj -0 -170.8805 Td -(2215 pushl %esi) 74.2647 Tj -0 -180.3739 Td -(2216 pushl %edi) 74.2647 Tj -0 -189.8672 Td -(2217 ) 21.8426 Tj -0 -199.3606 Td -(2218 # Switch stacks) 96.1073 Tj -0 -208.8539 Td -(2219 movl %esp, \(%eax\)) 104.8443 Tj -0 -218.3473 Td -(2220 movl %edx, %esp) 96.1073 Tj -0 -227.8407 Td -(2221 ) 21.8426 Tj -0 -237.334 Td -(2222 # Load new callee-save registers) 170.3721 Tj -0 -246.8274 Td -(2223 popl %edi) 69.8962 Tj -0 -256.3207 Td -(2224 popl %esi) 69.8962 Tj -0 -265.8141 Td -(2225 popl %ebx) 69.8962 Tj -0 -275.3075 Td -(2226 popl %ebp) 69.8962 Tj -0 -284.8008 Td -(2227 ret) 43.6851 Tj -0 -294.2942 Td -(2228 ) 21.8426 Tj -0 -303.7875 Td -(2229 ) 21.8426 Tj -0 -313.2809 Td -(2230 ) 21.8426 Tj -0 -322.7743 Td -(2231 ) 21.8426 Tj -0 -332.2676 Td -(2232 ) 21.8426 Tj -0 -341.761 Td -(2233 ) 21.8426 Tj -0 -351.2543 Td -(2234 ) 21.8426 Tj -0 -360.7477 Td -(2235 ) 21.8426 Tj -0 -370.2411 Td -(2236 ) 21.8426 Tj -0 -379.7344 Td -(2237 ) 21.8426 Tj -0 -389.2278 Td -(2238 ) 21.8426 Tj -0 -398.7211 Td -(2239 ) 21.8426 Tj -0 -408.2145 Td -(2240 ) 21.8426 Tj -0 -417.7079 Td -(2241 ) 21.8426 Tj -0 -427.2012 Td -(2242 ) 21.8426 Tj -0 -436.6946 Td -(2243 ) 21.8426 Tj -0 -446.1879 Td -(2244 ) 21.8426 Tj -0 -455.6813 Td -(2245 ) 21.8426 Tj -0 -465.1747 Td -(2246 ) 21.8426 Tj -0 -474.668 Td -(2247 ) 21.8426 Tj -0 -484.1614 Td -(2248 ) 21.8426 Tj -0 -493.6547 Td -(2249 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 22) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/kalloc.c Page 1) 170.3721 Tj -0 -28.4801 Td -(2250 // Physical memory allocator, intended to allocate) 240.2683 Tj -0 -37.9735 Td -(2251 // memory for user processes. Allocates in 4096-byte "page\ -s".) 288.322 Tj -0 -47.4668 Td -(2252 // Free list is kept sorted and combines adjacent pages in\ -to) 283.9534 Tj -0 -56.9602 Td -(2253 // long runs, to make it easier to allocate big segments.) 270.8479 Tj -0 -66.4535 Td -(2254 // One reason the page size is 4k is that the x86 segment \ -size) 292.6905 Tj -0 -75.9469 Td -(2255 // granularity is 4k.) 113.5814 Tj -0 -85.4403 Td -(2256 ) 21.8426 Tj -0 -94.9336 Td -(2257 #include "types.h") 100.4758 Tj -0 -104.427 Td -(2258 #include "defs.h") 96.1073 Tj -0 -113.9203 Td -(2259 #include "param.h") 100.4758 Tj -0 -123.4137 Td -(2260 #include "spinlock.h") 113.5814 Tj -0 -132.9071 Td -(2261 ) 21.8426 Tj -0 -142.4004 Td -(2262 struct run {) 74.2647 Tj -0 -151.8938 Td -(2263 struct run *next;) 104.8443 Tj -0 -161.3871 Td -(2264 int len; // bytes) 104.8443 Tj -0 -170.8805 Td -(2265 };) 30.5796 Tj -0 -180.3739 Td -(2266 ) 21.8426 Tj -0 -189.8672 Td -(2267 struct {) 56.7907 Tj -0 -199.3606 Td -(2268 struct spinlock lock;) 122.3184 Tj -0 -208.8539 Td -(2269 struct run *freelist;) 122.3184 Tj -0 -218.3473 Td -(2270 } kmem;) 52.4222 Tj -0 -227.8407 Td -(2271 ) 21.8426 Tj -0 -237.334 Td -(2272 // Initialize free list of physical pages.) 205.3202 Tj -0 -246.8274 Td -(2273 // This code cheats by just considering one megabyte of) 262.1109 Tj -0 -256.3207 Td -(2274 // pages after end. Real systems would determine the) 253.3738 Tj -0 -265.8141 Td -(2275 // amount of memory available in the system and use it all\ -.) 279.5849 Tj -0 -275.3075 Td -(2276 void) 39.3166 Tj -0 -284.8008 Td -(2277 kinit\(void\)) 69.8962 Tj -0 -294.2942 Td -(2278 {) 26.2111 Tj -0 -303.7875 Td -(2279 extern char end[];) 109.2129 Tj -0 -313.2809 Td -(2280 uint len;) 69.8962 Tj -0 -322.7743 Td -(2281 char *p;) 65.5277 Tj -0 -332.2676 Td -(2282 ) 21.8426 Tj -0 -341.761 Td -(2283 initlock\(&kmem.lock, "kmem"\);) 157.2665 Tj -0 -351.2543 Td -(2284 p = \(char*\)\(\(\(uint\)end + PAGE\) & ~\(PAGE-1\)\);) 222.7942 Tj -0 -360.7477 Td -(2285 len = 256*PAGE; // assume computer has 256 pages of RAM,\ - 1 MB) 297.059 Tj -0 -370.2411 Td -(2286 cprintf\("mem = %d\\n", len\);) 148.5295 Tj -0 -379.7344 Td -(2287 kfree\(p, len\);) 91.7388 Tj -0 -389.2278 Td -(2288 }) 26.2111 Tj -0 -398.7211 Td -(2289 ) 21.8426 Tj -0 -408.2145 Td -(2290 ) 21.8426 Tj -0 -417.7079 Td -(2291 ) 21.8426 Tj -0 -427.2012 Td -(2292 ) 21.8426 Tj -0 -436.6946 Td -(2293 ) 21.8426 Tj -0 -446.1879 Td -(2294 ) 21.8426 Tj -0 -455.6813 Td -(2295 ) 21.8426 Tj -0 -465.1747 Td -(2296 ) 21.8426 Tj -0 -474.668 Td -(2297 ) 21.8426 Tj -0 -484.1614 Td -(2298 ) 21.8426 Tj -0 -493.6547 Td -(2299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 22) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 30 30 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/kalloc.c Page 2) 170.3721 Tj -0 -28.4801 Td -(2300 // Free the len bytes of memory pointed at by v,) 231.5313 Tj -0 -37.9735 Td -(2301 // which normally should have been returned by a) 231.5313 Tj -0 -47.4668 Td -(2302 // call to kalloc\(len\). \(The exception is when) 227.1628 Tj -0 -56.9602 Td -(2303 // initializing the allocator; see kinit above.\)) 231.5313 Tj -0 -66.4535 Td -(2304 void) 39.3166 Tj -0 -75.9469 Td -(2305 kfree\(char *v, int len\)) 122.3184 Tj -0 -85.4403 Td -(2306 {) 26.2111 Tj -0 -94.9336 Td -(2307 struct run *r, *rend, **rp, *p, *pend;) 196.5831 Tj -0 -104.427 Td -(2308 ) 21.8426 Tj -0 -113.9203 Td -(2309 if\(len <= 0 || len % PAGE\)) 144.161 Tj -0 -123.4137 Td -(2310 panic\("kfree"\);) 104.8443 Tj -0 -132.9071 Td -(2311 ) 21.8426 Tj -0 -142.4004 Td -(2312 // Fill with junk to catch dangling refs.) 209.6887 Tj -0 -151.8938 Td -(2313 memset\(v, 1, len\);) 109.2129 Tj -0 -161.3871 Td -(2314 ) 21.8426 Tj -0 -170.8805 Td -(2315 acquire\(&kmem.lock\);) 117.9499 Tj -0 -180.3739 Td -(2316 p = \(struct run*\)v;) 113.5814 Tj -0 -189.8672 Td -(2317 pend = \(struct run*\)\(v + len\);) 161.635 Tj -0 -199.3606 Td -(2318 for\(rp=&kmem.freelist; \(r=*rp\) != 0 && r <= pend; rp=\ -&r->next\){) 305.796 Tj -0 -208.8539 Td -(2319 rend = \(struct run*\)\(\(char*\)r + r->len\);) 214.0572 Tj -0 -218.3473 Td -(2320 if\(r <= p && p < rend\)) 135.4239 Tj -0 -227.8407 Td -(2321 panic\("freeing free page"\);) 166.0035 Tj -0 -237.334 Td -(2322 if\(rend == p\){ // r before p: expand r to include p) 266.4794 Tj -0 -246.8274 Td -(2323 r->len += len;) 109.2129 Tj -0 -256.3207 Td -(2324 if\(r->next && r->next == pend\){ // r now next to \ -r->next?) 301.4275 Tj -0 -265.8141 Td -(2325 r->len += r->next->len;) 157.2665 Tj -0 -275.3075 Td -(2326 r->next = r->next->next;) 161.635 Tj -0 -284.8008 Td -(2327 }) 52.4222 Tj -0 -294.2942 Td -(2328 goto out;) 87.3703 Tj -0 -303.7875 Td -(2329 }) 43.6851 Tj -0 -313.2809 Td -(2330 if\(pend == r\){ // p before r: expand p to include, \ -replace r) 305.796 Tj -0 -322.7743 Td -(2331 p->len = len + r->len;) 144.161 Tj -0 -332.2676 Td -(2332 p->next = r->next;) 126.6869 Tj -0 -341.761 Td -(2333 *rp = p;) 83.0018 Tj -0 -351.2543 Td -(2334 goto out;) 87.3703 Tj -0 -360.7477 Td -(2335 }) 43.6851 Tj -0 -370.2411 Td -(2336 }) 34.9481 Tj -0 -379.7344 Td -(2337 // Insert p before r in list.) 157.2665 Tj -0 -389.2278 Td -(2338 p->len = len;) 87.3703 Tj -0 -398.7211 Td -(2339 p->next = r;) 83.0018 Tj -0 -408.2145 Td -(2340 *rp = p;) 65.5277 Tj -0 -417.7079 Td -(2341 ) 21.8426 Tj -0 -427.2012 Td -(2342 out:) 43.6851 Tj -0 -436.6946 Td -(2343 release\(&kmem.lock\);) 117.9499 Tj -0 -446.1879 Td -(2344 }) 26.2111 Tj -0 -455.6813 Td -(2345 ) 21.8426 Tj -0 -465.1747 Td -(2346 ) 21.8426 Tj -0 -474.668 Td -(2347 ) 21.8426 Tj -0 -484.1614 Td -(2348 ) 21.8426 Tj -0 -493.6547 Td -(2349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 23) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/kalloc.c Page 3) 170.3721 Tj -0 -28.4801 Td -(2350 // Allocate n bytes of physical memory.) 192.2146 Tj -0 -37.9735 Td -(2351 // Returns a kernel-segment pointer.) 179.1091 Tj -0 -47.4668 Td -(2352 // Returns 0 if the memory cannot be allocated.) 227.1628 Tj -0 -56.9602 Td -(2353 char*) 43.6851 Tj -0 -66.4535 Td -(2354 kalloc\(int n\)) 78.6333 Tj -0 -75.9469 Td -(2355 {) 26.2111 Tj -0 -85.4403 Td -(2356 char *p;) 65.5277 Tj -0 -94.9336 Td -(2357 struct run *r, **rp;) 117.9499 Tj -0 -104.427 Td -(2358 ) 21.8426 Tj -0 -113.9203 Td -(2359 if\(n % PAGE || n <= 0\)) 126.6869 Tj -0 -123.4137 Td -(2360 panic\("kalloc"\);) 109.2129 Tj -0 -132.9071 Td -(2361 ) 21.8426 Tj -0 -142.4004 Td -(2362 acquire\(&kmem.lock\);) 117.9499 Tj -0 -151.8938 Td -(2363 for\(rp=&kmem.freelist; \(r=*rp\) != 0; rp=&r->next\){) 249.0053 Tj -0 -161.3871 Td -(2364 if\(r->len >= n\){) 109.2129 Tj -0 -170.8805 Td -(2365 r->len -= n;) 100.4758 Tj -0 -180.3739 Td -(2366 p = \(char*\)r + r->len;) 144.161 Tj -0 -189.8672 Td -(2367 if\(r->len == 0\)) 113.5814 Tj -0 -199.3606 Td -(2368 *rp = r->next;) 117.9499 Tj -0 -208.8539 Td -(2369 release\(&kmem.lock\);) 135.4239 Tj -0 -218.3473 Td -(2370 return p;) 87.3703 Tj -0 -227.8407 Td -(2371 }) 43.6851 Tj -0 -237.334 Td -(2372 }) 34.9481 Tj -0 -246.8274 Td -(2373 release\(&kmem.lock\);) 117.9499 Tj -0 -256.3207 Td -(2374 ) 21.8426 Tj -0 -265.8141 Td -(2375 cprintf\("kalloc: out of memory\\n"\);) 183.4776 Tj -0 -275.3075 Td -(2376 return 0;) 69.8962 Tj -0 -284.8008 Td -(2377 }) 26.2111 Tj -0 -294.2942 Td -(2378 ) 21.8426 Tj -0 -303.7875 Td -(2379 ) 21.8426 Tj -0 -313.2809 Td -(2380 ) 21.8426 Tj -0 -322.7743 Td -(2381 ) 21.8426 Tj -0 -332.2676 Td -(2382 ) 21.8426 Tj -0 -341.761 Td -(2383 ) 21.8426 Tj -0 -351.2543 Td -(2384 ) 21.8426 Tj -0 -360.7477 Td -(2385 ) 21.8426 Tj -0 -370.2411 Td -(2386 ) 21.8426 Tj -0 -379.7344 Td -(2387 ) 21.8426 Tj -0 -389.2278 Td -(2388 ) 21.8426 Tj -0 -398.7211 Td -(2389 ) 21.8426 Tj -0 -408.2145 Td -(2390 ) 21.8426 Tj -0 -417.7079 Td -(2391 ) 21.8426 Tj -0 -427.2012 Td -(2392 ) 21.8426 Tj -0 -436.6946 Td -(2393 ) 21.8426 Tj -0 -446.1879 Td -(2394 ) 21.8426 Tj -0 -455.6813 Td -(2395 ) 21.8426 Tj -0 -465.1747 Td -(2396 ) 21.8426 Tj -0 -474.668 Td -(2397 ) 21.8426 Tj -0 -484.1614 Td -(2398 ) 21.8426 Tj -0 -493.6547 Td -(2399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 23) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 31 31 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/traps.h Page 1) 166.0035 Tj -0 -28.4801 Td -(2400 // x86 trap and interrupt constants.) 179.1091 Tj -0 -37.9735 Td -(2401 ) 21.8426 Tj -0 -47.4668 Td -(2402 // Processor-defined:) 113.5814 Tj -0 -56.9602 Td -(2403 #define T_DIVIDE 0 // divide error) 227.1628 Tj -0 -66.4535 Td -(2404 #define T_DEBUG 1 // debug exception) 240.2683 Tj -0 -75.9469 Td -(2405 #define T_NMI 2 // non-maskable interrupt) 270.8479 Tj -0 -85.4403 Td -(2406 #define T_BRKPT 3 // breakpoint) 218.4257 Tj -0 -94.9336 Td -(2407 #define T_OFLOW 4 // overflow) 209.6887 Tj -0 -104.427 Td -(2408 #define T_BOUND 5 // bounds check) 227.1628 Tj -0 -113.9203 Td -(2409 #define T_ILLOP 6 // illegal opcode) 235.8998 Tj -0 -123.4137 Td -(2410 #define T_DEVICE 7 // device not available) 262.1109 Tj -0 -132.9071 Td -(2411 #define T_DBLFLT 8 // double fault) 227.1628 Tj -0 -142.4004 Td -(2412 // #define T_COPROC 9 // reserved \(not used sin\ -ce 486\)) 301.4275 Tj -0 -151.8938 Td -(2413 #define T_TSS 10 // invalid task switch seg\ -ment) 292.6905 Tj -0 -161.3871 Td -(2414 #define T_SEGNP 11 // segment not present) 257.7424 Tj -0 -170.8805 Td -(2415 #define T_STACK 12 // stack exception) 240.2683 Tj -0 -180.3739 Td -(2416 #define T_GPFLT 13 // general protection faul\ -t) 279.5849 Tj -0 -189.8672 Td -(2417 #define T_PGFLT 14 // page fault) 218.4257 Tj -0 -199.3606 Td -(2418 // #define T_RES 15 // reserved) 209.6887 Tj -0 -208.8539 Td -(2419 #define T_FPERR 16 // floating point error) 262.1109 Tj -0 -218.3473 Td -(2420 #define T_ALIGN 17 // aligment check) 235.8998 Tj -0 -227.8407 Td -(2421 #define T_MCHK 18 // machine check) 231.5313 Tj -0 -237.334 Td -(2422 #define T_SIMDERR 19 // SIMD floating point err\ -or) 283.9534 Tj -0 -246.8274 Td -(2423 ) 21.8426 Tj -0 -256.3207 Td -(2424 // These are arbitrarily chosen, but with care not to over\ -lap) 288.322 Tj -0 -265.8141 Td -(2425 // processor defined exceptions or interrupt vectors.) 253.3738 Tj -0 -275.3075 Td -(2426 #define T_SYSCALL 64 // system call) 218.4257 Tj -0 -284.8008 Td -(2427 #define T_DEFAULT 500 // catchall) 209.6887 Tj -0 -294.2942 Td -(2428 ) 21.8426 Tj -0 -303.7875 Td -(2429 #define T_IRQ0 32 // IRQ 0 corresponds to in\ -t T_IRQ) 305.796 Tj -0 -313.2809 Td -(2430 ) 21.8426 Tj -0 -322.7743 Td -(2431 #define IRQ_TIMER 0) 135.4239 Tj -0 -332.2676 Td -(2432 #define IRQ_KBD 1) 135.4239 Tj -0 -341.761 Td -(2433 #define IRQ_COM1 4) 135.4239 Tj -0 -351.2543 Td -(2434 #define IRQ_IDE 14) 135.4239 Tj -0 -360.7477 Td -(2435 #define IRQ_ERROR 19) 135.4239 Tj -0 -370.2411 Td -(2436 #define IRQ_SPURIOUS 31) 135.4239 Tj -0 -379.7344 Td -(2437 ) 21.8426 Tj -0 -389.2278 Td -(2438 ) 21.8426 Tj -0 -398.7211 Td -(2439 ) 21.8426 Tj -0 -408.2145 Td -(2440 ) 21.8426 Tj -0 -417.7079 Td -(2441 ) 21.8426 Tj -0 -427.2012 Td -(2442 ) 21.8426 Tj -0 -436.6946 Td -(2443 ) 21.8426 Tj -0 -446.1879 Td -(2444 ) 21.8426 Tj -0 -455.6813 Td -(2445 ) 21.8426 Tj -0 -465.1747 Td -(2446 ) 21.8426 Tj -0 -474.668 Td -(2447 ) 21.8426 Tj -0 -484.1614 Td -(2448 ) 21.8426 Tj -0 -493.6547 Td -(2449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 24) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/vectors.pl Page 1) 179.1091 Tj -0 -28.4801 Td -(2450 #!/usr/bin/perl -w) 100.4758 Tj -0 -37.9735 Td -(2451 ) 21.8426 Tj -0 -47.4668 Td -(2452 # Generate vectors.S, the trap/interrupt entry points.) 257.7424 Tj -0 -56.9602 Td -(2453 # There has to be one entry point per interrupt number) 257.7424 Tj -0 -66.4535 Td -(2454 # since otherwise there's no way for trap\(\) to discover) 262.1109 Tj -0 -75.9469 Td -(2455 # the interrupt number.) 122.3184 Tj -0 -85.4403 Td -(2456 ) 21.8426 Tj -0 -94.9336 Td -(2457 print "# generated by vectors.pl - do not edit\\n";) 240.2683 Tj -0 -104.427 Td -(2458 print "# handlers\\n";) 113.5814 Tj -0 -113.9203 Td -(2459 print ".globl alltraps\\n";) 135.4239 Tj -0 -123.4137 Td -(2460 for\(my $i = 0; $i < 256; $i++\){) 157.2665 Tj -0 -132.9071 Td -(2461 print ".globl vector$i\\n";) 152.898 Tj -0 -142.4004 Td -(2462 print "vector$i:\\n";) 126.6869 Tj -0 -151.8938 Td -(2463 if\(!\($i == 8 || \($i >= 10 && $i <= 14\) || $i == 17\ -\)\){) 270.8479 Tj -0 -161.3871 Td -(2464 print " pushl \\$0\\n";) 152.898 Tj -0 -170.8805 Td -(2465 }) 43.6851 Tj -0 -180.3739 Td -(2466 print " pushl \\$$i\\n";) 139.7925 Tj -0 -189.8672 Td -(2467 print " jmp alltraps\\n";) 148.5295 Tj -0 -199.3606 Td -(2468 }) 26.2111 Tj -0 -208.8539 Td -(2469 ) 21.8426 Tj -0 -218.3473 Td -(2470 print "\\n# vector table\\n";) 139.7925 Tj -0 -227.8407 Td -(2471 print ".data\\n";) 91.7388 Tj -0 -237.334 Td -(2472 print ".globl vectors\\n";) 131.0554 Tj -0 -246.8274 Td -(2473 print "vectors:\\n";) 104.8443 Tj -0 -256.3207 Td -(2474 for\(my $i = 0; $i < 256; $i++\){) 157.2665 Tj -0 -265.8141 Td -(2475 print " .long vector$i\\n";) 157.2665 Tj -0 -275.3075 Td -(2476 }) 26.2111 Tj -0 -284.8008 Td -(2477 ) 21.8426 Tj -0 -294.2942 Td -(2478 # sample output:) 91.7388 Tj -0 -303.7875 Td -(2479 # # handlers) 83.0018 Tj -0 -313.2809 Td -(2480 # .globl alltraps) 104.8443 Tj -0 -322.7743 Td -(2481 # .globl vector0) 100.4758 Tj -0 -332.2676 Td -(2482 # vector0:) 74.2647 Tj -0 -341.761 Td -(2483 # pushl $0) 83.0018 Tj -0 -351.2543 Td -(2484 # pushl $0) 83.0018 Tj -0 -360.7477 Td -(2485 # jmp alltraps) 100.4758 Tj -0 -370.2411 Td -(2486 # ...) 52.4222 Tj -0 -379.7344 Td -(2487 #) 26.2111 Tj -0 -389.2278 Td -(2488 # # vector table) 100.4758 Tj -0 -398.7211 Td -(2489 # .data) 61.1592 Tj -0 -408.2145 Td -(2490 # .globl vectors) 100.4758 Tj -0 -417.7079 Td -(2491 # vectors:) 74.2647 Tj -0 -427.2012 Td -(2492 # .long vector0) 104.8443 Tj -0 -436.6946 Td -(2493 # .long vector1) 104.8443 Tj -0 -446.1879 Td -(2494 # .long vector2) 104.8443 Tj -0 -455.6813 Td -(2495 # ...) 52.4222 Tj -0 -465.1747 Td -(2496 ) 21.8426 Tj -0 -474.668 Td -(2497 ) 21.8426 Tj -0 -484.1614 Td -(2498 ) 21.8426 Tj -0 -493.6547 Td -(2499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 24) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 32 32 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/trapasm.S Page 1) 174.7406 Tj -0 -28.4801 Td -(2500 #define SEG_KCODE 1 // kernel code) 174.7406 Tj -0 -37.9735 Td -(2501 #define SEG_KDATA 2 // kernel data+stack) 200.9517 Tj -0 -47.4668 Td -(2502 #define SEG_KCPU 3 // kernel per-cpu data) 209.6887 Tj -0 -56.9602 Td -(2503 ) 21.8426 Tj -0 -66.4535 Td -(2504 # vectors.S sends all traps here.) 174.7406 Tj -0 -75.9469 Td -(2505 .globl alltraps) 87.3703 Tj -0 -85.4403 Td -(2506 alltraps:) 61.1592 Tj -0 -94.9336 Td -(2507 # Build trap frame.) 113.5814 Tj -0 -104.427 Td -(2508 pushl %ds) 69.8962 Tj -0 -113.9203 Td -(2509 pushl %es) 69.8962 Tj -0 -123.4137 Td -(2510 pushl %fs) 69.8962 Tj -0 -132.9071 Td -(2511 pushl %gs) 69.8962 Tj -0 -142.4004 Td -(2512 pushal) 56.7907 Tj -0 -151.8938 Td -(2513 ) 21.8426 Tj -0 -161.3871 Td -(2514 # Set up data and per-cpu segments.) 183.4776 Tj -0 -170.8805 Td -(2515 movw $\(SEG_KDATA<<3\), %ax) 139.7925 Tj -0 -180.3739 Td -(2516 movw %ax, %ds) 87.3703 Tj -0 -189.8672 Td -(2517 movw %ax, %es) 87.3703 Tj -0 -199.3606 Td -(2518 movw $\(SEG_KCPU<<3\), %ax) 135.4239 Tj -0 -208.8539 Td -(2519 movw %ax, %fs) 87.3703 Tj -0 -218.3473 Td -(2520 movw %ax, %gs) 87.3703 Tj -0 -227.8407 Td -(2521 ) 21.8426 Tj -0 -237.334 Td -(2522 # Call trap\(tf\), where tf=%esp) 161.635 Tj -0 -246.8274 Td -(2523 pushl %esp) 74.2647 Tj -0 -256.3207 Td -(2524 call trap) 69.8962 Tj -0 -265.8141 Td -(2525 addl $4, %esp) 87.3703 Tj -0 -275.3075 Td -(2526 ) 21.8426 Tj -0 -284.8008 Td -(2527 # Return falls through to trapret...) 187.8461 Tj -0 -294.2942 Td -(2528 .globl trapret) 83.0018 Tj -0 -303.7875 Td -(2529 trapret:) 56.7907 Tj -0 -313.2809 Td -(2530 popal) 52.4222 Tj -0 -322.7743 Td -(2531 popl %gs) 65.5277 Tj -0 -332.2676 Td -(2532 popl %fs) 65.5277 Tj -0 -341.761 Td -(2533 popl %es) 65.5277 Tj -0 -351.2543 Td -(2534 popl %ds) 65.5277 Tj -0 -360.7477 Td -(2535 addl $0x8, %esp # trapno and errcode) 192.2146 Tj -0 -370.2411 Td -(2536 iret) 48.0537 Tj -0 -379.7344 Td -(2537 ) 21.8426 Tj -0 -389.2278 Td -(2538 ) 21.8426 Tj -0 -398.7211 Td -(2539 ) 21.8426 Tj -0 -408.2145 Td -(2540 ) 21.8426 Tj -0 -417.7079 Td -(2541 ) 21.8426 Tj -0 -427.2012 Td -(2542 ) 21.8426 Tj -0 -436.6946 Td -(2543 ) 21.8426 Tj -0 -446.1879 Td -(2544 ) 21.8426 Tj -0 -455.6813 Td -(2545 ) 21.8426 Tj -0 -465.1747 Td -(2546 ) 21.8426 Tj -0 -474.668 Td -(2547 ) 21.8426 Tj -0 -484.1614 Td -(2548 ) 21.8426 Tj -0 -493.6547 Td -(2549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 25) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/trap.c Page 1) 161.635 Tj -0 -28.4801 Td -(2550 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(2551 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(2552 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(2553 #include "mmu.h") 91.7388 Tj -0 -66.4535 Td -(2554 #include "proc.h") 96.1073 Tj -0 -75.9469 Td -(2555 #include "x86.h") 91.7388 Tj -0 -85.4403 Td -(2556 #include "traps.h") 100.4758 Tj -0 -94.9336 Td -(2557 #include "spinlock.h") 113.5814 Tj -0 -104.427 Td -(2558 ) 21.8426 Tj -0 -113.9203 Td -(2559 // Interrupt descriptor table \(shared by all CPUs\).) 244.6368 Tj -0 -123.4137 Td -(2560 struct gatedesc idt[256];) 131.0554 Tj -0 -132.9071 Td -(2561 extern uint vectors[]; // in vectors.S: array of 256 entr\ -y pointers) 318.9016 Tj -0 -142.4004 Td -(2562 struct spinlock tickslock;) 135.4239 Tj -0 -151.8938 Td -(2563 int ticks;) 65.5277 Tj -0 -161.3871 Td -(2564 ) 21.8426 Tj -0 -170.8805 Td -(2565 void) 39.3166 Tj -0 -180.3739 Td -(2566 tvinit\(void\)) 74.2647 Tj -0 -189.8672 Td -(2567 {) 26.2111 Tj -0 -199.3606 Td -(2568 int i;) 56.7907 Tj -0 -208.8539 Td -(2569 ) 21.8426 Tj -0 -218.3473 Td -(2570 for\(i = 0; i < 256; i++\)) 135.4239 Tj -0 -227.8407 Td -(2571 SETGATE\(idt[i], 0, SEG_KCODE<<3, vectors[i], 0\);) 249.0053 Tj -0 -237.334 Td -(2572 SETGATE\(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSC\ -ALL], DPL_USER\);) 340.7441 Tj -0 -246.8274 Td -(2573 ) 21.8426 Tj -0 -256.3207 Td -(2574 initlock\(&tickslock, "time"\);) 157.2665 Tj -0 -265.8141 Td -(2575 }) 26.2111 Tj -0 -275.3075 Td -(2576 ) 21.8426 Tj -0 -284.8008 Td -(2577 void) 39.3166 Tj -0 -294.2942 Td -(2578 idtinit\(void\)) 78.6333 Tj -0 -303.7875 Td -(2579 {) 26.2111 Tj -0 -313.2809 Td -(2580 lidt\(idt, sizeof\(idt\)\);) 131.0554 Tj -0 -322.7743 Td -(2581 }) 26.2111 Tj -0 -332.2676 Td -(2582 ) 21.8426 Tj -0 -341.761 Td -(2583 ) 21.8426 Tj -0 -351.2543 Td -(2584 ) 21.8426 Tj -0 -360.7477 Td -(2585 ) 21.8426 Tj -0 -370.2411 Td -(2586 ) 21.8426 Tj -0 -379.7344 Td -(2587 ) 21.8426 Tj -0 -389.2278 Td -(2588 ) 21.8426 Tj -0 -398.7211 Td -(2589 ) 21.8426 Tj -0 -408.2145 Td -(2590 ) 21.8426 Tj -0 -417.7079 Td -(2591 ) 21.8426 Tj -0 -427.2012 Td -(2592 ) 21.8426 Tj -0 -436.6946 Td -(2593 ) 21.8426 Tj -0 -446.1879 Td -(2594 ) 21.8426 Tj -0 -455.6813 Td -(2595 ) 21.8426 Tj -0 -465.1747 Td -(2596 ) 21.8426 Tj -0 -474.668 Td -(2597 ) 21.8426 Tj -0 -484.1614 Td -(2598 ) 21.8426 Tj -0 -493.6547 Td -(2599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 25) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 33 33 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/trap.c Page 2) 161.635 Tj -0 -28.4801 Td -(2600 void) 39.3166 Tj -0 -37.9735 Td -(2601 trap\(struct trapframe *tf\)) 135.4239 Tj -0 -47.4668 Td -(2602 {) 26.2111 Tj -0 -56.9602 Td -(2603 if\(tf->trapno == T_SYSCALL\){) 152.898 Tj -0 -66.4535 Td -(2604 if\(proc->killed\)) 109.2129 Tj -0 -75.9469 Td -(2605 exit\(\);) 78.6333 Tj -0 -85.4403 Td -(2606 proc->tf = tf;) 100.4758 Tj -0 -94.9336 Td -(2607 syscall\(\);) 83.0018 Tj -0 -104.427 Td -(2608 if\(proc->killed\)) 109.2129 Tj -0 -113.9203 Td -(2609 exit\(\);) 78.6333 Tj -0 -123.4137 Td -(2610 return;) 69.8962 Tj -0 -132.9071 Td -(2611 }) 34.9481 Tj -0 -142.4004 Td -(2612 ) 21.8426 Tj -0 -151.8938 Td -(2613 switch\(tf->trapno\){) 113.5814 Tj -0 -161.3871 Td -(2614 case T_IRQ0 + IRQ_TIMER:) 135.4239 Tj -0 -170.8805 Td -(2615 if\(cpu->id == 0\){) 113.5814 Tj -0 -180.3739 Td -(2616 acquire\(&tickslock\);) 135.4239 Tj -0 -189.8672 Td -(2617 ticks++;) 83.0018 Tj -0 -199.3606 Td -(2618 wakeup\(&ticks\);) 113.5814 Tj -0 -208.8539 Td -(2619 release\(&tickslock\);) 135.4239 Tj -0 -218.3473 Td -(2620 }) 43.6851 Tj -0 -227.8407 Td -(2621 lapiceoi\(\);) 87.3703 Tj -0 -237.334 Td -(2622 break;) 65.5277 Tj -0 -246.8274 Td -(2623 case T_IRQ0 + IRQ_IDE:) 126.6869 Tj -0 -256.3207 Td -(2624 ideintr\(\);) 83.0018 Tj -0 -265.8141 Td -(2625 lapiceoi\(\);) 87.3703 Tj -0 -275.3075 Td -(2626 break;) 65.5277 Tj -0 -284.8008 Td -(2627 case T_IRQ0 + IRQ_KBD:) 126.6869 Tj -0 -294.2942 Td -(2628 kbdintr\(\);) 83.0018 Tj -0 -303.7875 Td -(2629 lapiceoi\(\);) 87.3703 Tj -0 -313.2809 Td -(2630 break;) 65.5277 Tj -0 -322.7743 Td -(2631 case T_IRQ0 + IRQ_COM1:) 131.0554 Tj -0 -332.2676 Td -(2632 uartintr\(\);) 87.3703 Tj -0 -341.761 Td -(2633 lapiceoi\(\);) 87.3703 Tj -0 -351.2543 Td -(2634 break;) 65.5277 Tj -0 -360.7477 Td -(2635 case T_IRQ0 + 7:) 100.4758 Tj -0 -370.2411 Td -(2636 case T_IRQ0 + IRQ_SPURIOUS:) 148.5295 Tj -0 -379.7344 Td -(2637 cprintf\("cpu%d: spurious interrupt at %x:%x\\n",) 244.6368 Tj -0 -389.2278 Td -(2638 cpu->id, tf->cs, tf->eip\);) 187.8461 Tj -0 -398.7211 Td -(2639 lapiceoi\(\);) 87.3703 Tj -0 -408.2145 Td -(2640 break;) 65.5277 Tj -0 -417.7079 Td -(2641 ) 21.8426 Tj -0 -427.2012 Td -(2642 ) 21.8426 Tj -0 -436.6946 Td -(2643 ) 21.8426 Tj -0 -446.1879 Td -(2644 ) 21.8426 Tj -0 -455.6813 Td -(2645 ) 21.8426 Tj -0 -465.1747 Td -(2646 ) 21.8426 Tj -0 -474.668 Td -(2647 ) 21.8426 Tj -0 -484.1614 Td -(2648 ) 21.8426 Tj -0 -493.6547 Td -(2649 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 26) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/trap.c Page 3) 161.635 Tj -0 -28.4801 Td -(2650 default:) 65.5277 Tj -0 -37.9735 Td -(2651 if\(proc == 0 || \(tf->cs&3\) == 0\){) 183.4776 Tj -0 -47.4668 Td -(2652 // In kernel, it must be our mistake.) 209.6887 Tj -0 -56.9602 Td -(2653 cprintf\("unexpected trap %d from cpu %d eip %x\\n",) 266.4794 Tj -0 -66.4535 Td -(2654 tf->trapno, cpu->id, tf->eip\);) 214.0572 Tj -0 -75.9469 Td -(2655 panic\("trap"\);) 109.2129 Tj -0 -85.4403 Td -(2656 }) 43.6851 Tj -0 -94.9336 Td -(2657 // In user space, assume process misbehaved.) 231.5313 Tj -0 -104.427 Td -(2658 cprintf\("pid %d %s: trap %d err %d on cpu %d eip %x -\ -- kill proc\\n",) 336.3756 Tj -0 -113.9203 Td -(2659 proc->pid, proc->name, tf->trapno, tf->err, cp\ -u->id, tf->eip\);) 345.1126 Tj -0 -123.4137 Td -(2660 proc->killed = 1;) 113.5814 Tj -0 -132.9071 Td -(2661 }) 34.9481 Tj -0 -142.4004 Td -(2662 ) 21.8426 Tj -0 -151.8938 Td -(2663 // Force process exit if it has been killed and is in us\ -er space.) 314.533 Tj -0 -161.3871 Td -(2664 // \(If it is still executing in the kernel, let it keep\ - running) 305.796 Tj -0 -170.8805 Td -(2665 // until it gets to the regular system call return.\)) 257.7424 Tj -0 -180.3739 Td -(2666 if\(proc && proc->killed && \(tf->cs&3\) == DPL_USER\)) 249.0053 Tj -0 -189.8672 Td -(2667 exit\(\);) 69.8962 Tj -0 -199.3606 Td -(2668 ) 21.8426 Tj -0 -208.8539 Td -(2669 // Force process to give up CPU on clock tick.) 231.5313 Tj -0 -218.3473 Td -(2670 // If interrupts were on while locks held, would need to\ - check nlock.) 332.0071 Tj -0 -227.8407 Td -(2671 if\(proc && proc->state == RUNNING && tf->trapno == T_IR\ -Q0+IRQ_TIMER\)) 327.6386 Tj -0 -237.334 Td -(2672 yield\(\);) 74.2647 Tj -0 -246.8274 Td -(2673 ) 21.8426 Tj -0 -256.3207 Td -(2674 // Check if the process has been killed since we yielded) 275.2164 Tj -0 -265.8141 Td -(2675 if\(proc && proc->killed && \(tf->cs&3\) == DPL_USER\)) 249.0053 Tj -0 -275.3075 Td -(2676 exit\(\);) 69.8962 Tj -0 -284.8008 Td -(2677 }) 26.2111 Tj -0 -294.2942 Td -(2678 ) 21.8426 Tj -0 -303.7875 Td -(2679 ) 21.8426 Tj -0 -313.2809 Td -(2680 ) 21.8426 Tj -0 -322.7743 Td -(2681 ) 21.8426 Tj -0 -332.2676 Td -(2682 ) 21.8426 Tj -0 -341.761 Td -(2683 ) 21.8426 Tj -0 -351.2543 Td -(2684 ) 21.8426 Tj -0 -360.7477 Td -(2685 ) 21.8426 Tj -0 -370.2411 Td -(2686 ) 21.8426 Tj -0 -379.7344 Td -(2687 ) 21.8426 Tj -0 -389.2278 Td -(2688 ) 21.8426 Tj -0 -398.7211 Td -(2689 ) 21.8426 Tj -0 -408.2145 Td -(2690 ) 21.8426 Tj -0 -417.7079 Td -(2691 ) 21.8426 Tj -0 -427.2012 Td -(2692 ) 21.8426 Tj -0 -436.6946 Td -(2693 ) 21.8426 Tj -0 -446.1879 Td -(2694 ) 21.8426 Tj -0 -455.6813 Td -(2695 ) 21.8426 Tj -0 -465.1747 Td -(2696 ) 21.8426 Tj -0 -474.668 Td -(2697 ) 21.8426 Tj -0 -484.1614 Td -(2698 ) 21.8426 Tj -0 -493.6547 Td -(2699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 26) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 34 34 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/syscall.h Page 1) 174.7406 Tj -0 -28.4801 Td -(2700 // System call numbers) 117.9499 Tj -0 -37.9735 Td -(2701 #define SYS_fork 1) 113.5814 Tj -0 -47.4668 Td -(2702 #define SYS_exit 2) 113.5814 Tj -0 -56.9602 Td -(2703 #define SYS_wait 3) 113.5814 Tj -0 -66.4535 Td -(2704 #define SYS_pipe 4) 113.5814 Tj -0 -75.9469 Td -(2705 #define SYS_write 5) 113.5814 Tj -0 -85.4403 Td -(2706 #define SYS_read 6) 113.5814 Tj -0 -94.9336 Td -(2707 #define SYS_close 7) 113.5814 Tj -0 -104.427 Td -(2708 #define SYS_kill 8) 113.5814 Tj -0 -113.9203 Td -(2709 #define SYS_exec 9) 113.5814 Tj -0 -123.4137 Td -(2710 #define SYS_open 10) 113.5814 Tj -0 -132.9071 Td -(2711 #define SYS_mknod 11) 113.5814 Tj -0 -142.4004 Td -(2712 #define SYS_unlink 12) 113.5814 Tj -0 -151.8938 Td -(2713 #define SYS_fstat 13) 113.5814 Tj -0 -161.3871 Td -(2714 #define SYS_link 14) 113.5814 Tj -0 -170.8805 Td -(2715 #define SYS_mkdir 15) 113.5814 Tj -0 -180.3739 Td -(2716 #define SYS_chdir 16) 113.5814 Tj -0 -189.8672 Td -(2717 #define SYS_dup 17) 113.5814 Tj -0 -199.3606 Td -(2718 #define SYS_getpid 18) 113.5814 Tj -0 -208.8539 Td -(2719 #define SYS_sbrk 19) 113.5814 Tj -0 -218.3473 Td -(2720 #define SYS_sleep 20) 113.5814 Tj -0 -227.8407 Td -(2721 ) 21.8426 Tj -0 -237.334 Td -(2722 ) 21.8426 Tj -0 -246.8274 Td -(2723 ) 21.8426 Tj -0 -256.3207 Td -(2724 ) 21.8426 Tj -0 -265.8141 Td -(2725 ) 21.8426 Tj -0 -275.3075 Td -(2726 ) 21.8426 Tj -0 -284.8008 Td -(2727 ) 21.8426 Tj -0 -294.2942 Td -(2728 ) 21.8426 Tj -0 -303.7875 Td -(2729 ) 21.8426 Tj -0 -313.2809 Td -(2730 ) 21.8426 Tj -0 -322.7743 Td -(2731 ) 21.8426 Tj -0 -332.2676 Td -(2732 ) 21.8426 Tj -0 -341.761 Td -(2733 ) 21.8426 Tj -0 -351.2543 Td -(2734 ) 21.8426 Tj -0 -360.7477 Td -(2735 ) 21.8426 Tj -0 -370.2411 Td -(2736 ) 21.8426 Tj -0 -379.7344 Td -(2737 ) 21.8426 Tj -0 -389.2278 Td -(2738 ) 21.8426 Tj -0 -398.7211 Td -(2739 ) 21.8426 Tj -0 -408.2145 Td -(2740 ) 21.8426 Tj -0 -417.7079 Td -(2741 ) 21.8426 Tj -0 -427.2012 Td -(2742 ) 21.8426 Tj -0 -436.6946 Td -(2743 ) 21.8426 Tj -0 -446.1879 Td -(2744 ) 21.8426 Tj -0 -455.6813 Td -(2745 ) 21.8426 Tj -0 -465.1747 Td -(2746 ) 21.8426 Tj -0 -474.668 Td -(2747 ) 21.8426 Tj -0 -484.1614 Td -(2748 ) 21.8426 Tj -0 -493.6547 Td -(2749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 27) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/syscall.c Page 1) 174.7406 Tj -0 -28.4801 Td -(2750 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(2751 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(2752 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(2753 #include "mmu.h") 91.7388 Tj -0 -66.4535 Td -(2754 #include "proc.h") 96.1073 Tj -0 -75.9469 Td -(2755 #include "x86.h") 91.7388 Tj -0 -85.4403 Td -(2756 #include "syscall.h") 109.2129 Tj -0 -94.9336 Td -(2757 ) 21.8426 Tj -0 -104.427 Td -(2758 // User code makes a system call with INT T_SYSCALL.) 249.0053 Tj -0 -113.9203 Td -(2759 // System call number in %eax.) 152.898 Tj -0 -123.4137 Td -(2760 // Arguments on the stack, from the user call to the C) 257.7424 Tj -0 -132.9071 Td -(2761 // library system call function. The saved user %esp point\ -s) 279.5849 Tj -0 -142.4004 Td -(2762 // to a saved program counter, and then the first argument\ -.) 279.5849 Tj -0 -151.8938 Td -(2763 ) 21.8426 Tj -0 -161.3871 Td -(2764 // Fetch the int at addr from process p.) 196.5831 Tj -0 -170.8805 Td -(2765 int) 34.9481 Tj -0 -180.3739 Td -(2766 fetchint\(struct proc *p, uint addr, int *ip\)) 214.0572 Tj -0 -189.8672 Td -(2767 {) 26.2111 Tj -0 -199.3606 Td -(2768 if\(addr >= p->sz || addr+4 > p->sz\)) 183.4776 Tj -0 -208.8539 Td -(2769 return -1;) 83.0018 Tj -0 -218.3473 Td -(2770 *ip = *\(int*\)\(p->mem + addr\);) 157.2665 Tj -0 -227.8407 Td -(2771 return 0;) 69.8962 Tj -0 -237.334 Td -(2772 }) 26.2111 Tj -0 -246.8274 Td -(2773 ) 21.8426 Tj -0 -256.3207 Td -(2774 // Fetch the nul-terminated string at addr from process p.) 275.2164 Tj -0 -265.8141 Td -(2775 // Doesn't actually copy the string - just sets *pp to poi\ -nt at it.) 314.533 Tj -0 -275.3075 Td -(2776 // Returns length of string, not including nul.) 227.1628 Tj -0 -284.8008 Td -(2777 int) 34.9481 Tj -0 -294.2942 Td -(2778 fetchstr\(struct proc *p, uint addr, char **pp\)) 222.7942 Tj -0 -303.7875 Td -(2779 {) 26.2111 Tj -0 -313.2809 Td -(2780 char *s, *ep;) 87.3703 Tj -0 -322.7743 Td -(2781 ) 21.8426 Tj -0 -332.2676 Td -(2782 if\(addr >= p->sz\)) 104.8443 Tj -0 -341.761 Td -(2783 return -1;) 83.0018 Tj -0 -351.2543 Td -(2784 *pp = p->mem + addr;) 117.9499 Tj -0 -360.7477 Td -(2785 ep = p->mem + p->sz;) 117.9499 Tj -0 -370.2411 Td -(2786 for\(s = *pp; s < ep; s++\)) 139.7925 Tj -0 -379.7344 Td -(2787 if\(*s == 0\)) 87.3703 Tj -0 -389.2278 Td -(2788 return s - *pp;) 113.5814 Tj -0 -398.7211 Td -(2789 return -1;) 74.2647 Tj -0 -408.2145 Td -(2790 }) 26.2111 Tj -0 -417.7079 Td -(2791 ) 21.8426 Tj -0 -427.2012 Td -(2792 // Fetch the nth 32-bit system call argument.) 218.4257 Tj -0 -436.6946 Td -(2793 int) 34.9481 Tj -0 -446.1879 Td -(2794 argint\(int n, int *ip\)) 117.9499 Tj -0 -455.6813 Td -(2795 {) 26.2111 Tj -0 -465.1747 Td -(2796 return fetchint\(proc, proc->tf->esp + 4 + 4*n, ip\);) 253.3738 Tj -0 -474.668 Td -(2797 }) 26.2111 Tj -0 -484.1614 Td -(2798 ) 21.8426 Tj -0 -493.6547 Td -(2799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 27) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 35 35 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/syscall.c Page 2) 174.7406 Tj -0 -28.4801 Td -(2800 // Fetch the nth word-sized system call argument as a poin\ -ter) 288.322 Tj -0 -37.9735 Td -(2801 // to a block of memory of size n bytes. Check that the p\ -ointer) 301.4275 Tj -0 -47.4668 Td -(2802 // lies within the process address space.) 200.9517 Tj -0 -56.9602 Td -(2803 int) 34.9481 Tj -0 -66.4535 Td -(2804 argptr\(int n, char **pp, int size\)) 170.3721 Tj -0 -75.9469 Td -(2805 {) 26.2111 Tj -0 -85.4403 Td -(2806 int i;) 56.7907 Tj -0 -94.9336 Td -(2807 ) 21.8426 Tj -0 -104.427 Td -(2808 if\(argint\(n, &i\) < 0\)) 122.3184 Tj -0 -113.9203 Td -(2809 return -1;) 83.0018 Tj -0 -123.4137 Td -(2810 if\(\(uint\)i >= proc->sz || \(uint\)i+size >= proc->sz\)) 253.3738 Tj -0 -132.9071 Td -(2811 return -1;) 83.0018 Tj -0 -142.4004 Td -(2812 *pp = proc->mem + i;) 117.9499 Tj -0 -151.8938 Td -(2813 return 0;) 69.8962 Tj -0 -161.3871 Td -(2814 }) 26.2111 Tj -0 -170.8805 Td -(2815 ) 21.8426 Tj -0 -180.3739 Td -(2816 // Fetch the nth word-sized system call argument as a stri\ -ng pointer.) 323.2701 Tj -0 -189.8672 Td -(2817 // Check that the pointer is valid and the string is nul-t\ -erminated.) 318.9016 Tj -0 -199.3606 Td -(2818 // \(There is no shared writable memory, so the string can\ -'t change) 310.1645 Tj -0 -208.8539 Td -(2819 // between this check and being used by the kernel.\)) 249.0053 Tj -0 -218.3473 Td -(2820 int) 34.9481 Tj -0 -227.8407 Td -(2821 argstr\(int n, char **pp\)) 126.6869 Tj -0 -237.334 Td -(2822 {) 26.2111 Tj -0 -246.8274 Td -(2823 int addr;) 69.8962 Tj -0 -256.3207 Td -(2824 if\(argint\(n, &addr\) < 0\)) 135.4239 Tj -0 -265.8141 Td -(2825 return -1;) 83.0018 Tj -0 -275.3075 Td -(2826 return fetchstr\(proc, addr, pp\);) 170.3721 Tj -0 -284.8008 Td -(2827 }) 26.2111 Tj -0 -294.2942 Td -(2828 ) 21.8426 Tj -0 -303.7875 Td -(2829 extern int sys_chdir\(void\);) 139.7925 Tj -0 -313.2809 Td -(2830 extern int sys_close\(void\);) 139.7925 Tj -0 -322.7743 Td -(2831 extern int sys_dup\(void\);) 131.0554 Tj -0 -332.2676 Td -(2832 extern int sys_exec\(void\);) 135.4239 Tj -0 -341.761 Td -(2833 extern int sys_exit\(void\);) 135.4239 Tj -0 -351.2543 Td -(2834 extern int sys_fork\(void\);) 135.4239 Tj -0 -360.7477 Td -(2835 extern int sys_fstat\(void\);) 139.7925 Tj -0 -370.2411 Td -(2836 extern int sys_getpid\(void\);) 144.161 Tj -0 -379.7344 Td -(2837 extern int sys_kill\(void\);) 135.4239 Tj -0 -389.2278 Td -(2838 extern int sys_link\(void\);) 135.4239 Tj -0 -398.7211 Td -(2839 extern int sys_mkdir\(void\);) 139.7925 Tj -0 -408.2145 Td -(2840 extern int sys_mknod\(void\);) 139.7925 Tj -0 -417.7079 Td -(2841 extern int sys_open\(void\);) 135.4239 Tj -0 -427.2012 Td -(2842 extern int sys_pipe\(void\);) 135.4239 Tj -0 -436.6946 Td -(2843 extern int sys_read\(void\);) 135.4239 Tj -0 -446.1879 Td -(2844 extern int sys_sbrk\(void\);) 135.4239 Tj -0 -455.6813 Td -(2845 extern int sys_sleep\(void\);) 139.7925 Tj -0 -465.1747 Td -(2846 extern int sys_unlink\(void\);) 144.161 Tj -0 -474.668 Td -(2847 extern int sys_wait\(void\);) 135.4239 Tj -0 -484.1614 Td -(2848 extern int sys_write\(void\);) 139.7925 Tj -0 -493.6547 Td -(2849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 28) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/syscall.c Page 3) 174.7406 Tj -0 -28.4801 Td -(2850 static int \(*syscalls[]\)\(void\) = {) 170.3721 Tj -0 -37.9735 Td -(2851 [SYS_chdir] sys_chdir,) 126.6869 Tj -0 -47.4668 Td -(2852 [SYS_close] sys_close,) 126.6869 Tj -0 -56.9602 Td -(2853 [SYS_dup] sys_dup,) 117.9499 Tj -0 -66.4535 Td -(2854 [SYS_exec] sys_exec,) 122.3184 Tj -0 -75.9469 Td -(2855 [SYS_exit] sys_exit,) 122.3184 Tj -0 -85.4403 Td -(2856 [SYS_fork] sys_fork,) 122.3184 Tj -0 -94.9336 Td -(2857 [SYS_fstat] sys_fstat,) 126.6869 Tj -0 -104.427 Td -(2858 [SYS_getpid] sys_getpid,) 131.0554 Tj -0 -113.9203 Td -(2859 [SYS_kill] sys_kill,) 122.3184 Tj -0 -123.4137 Td -(2860 [SYS_link] sys_link,) 122.3184 Tj -0 -132.9071 Td -(2861 [SYS_mkdir] sys_mkdir,) 126.6869 Tj -0 -142.4004 Td -(2862 [SYS_mknod] sys_mknod,) 126.6869 Tj -0 -151.8938 Td -(2863 [SYS_open] sys_open,) 122.3184 Tj -0 -161.3871 Td -(2864 [SYS_pipe] sys_pipe,) 122.3184 Tj -0 -170.8805 Td -(2865 [SYS_read] sys_read,) 122.3184 Tj -0 -180.3739 Td -(2866 [SYS_sbrk] sys_sbrk,) 122.3184 Tj -0 -189.8672 Td -(2867 [SYS_sleep] sys_sleep,) 126.6869 Tj -0 -199.3606 Td -(2868 [SYS_unlink] sys_unlink,) 131.0554 Tj -0 -208.8539 Td -(2869 [SYS_wait] sys_wait,) 122.3184 Tj -0 -218.3473 Td -(2870 [SYS_write] sys_write,) 126.6869 Tj -0 -227.8407 Td -(2871 };) 30.5796 Tj -0 -237.334 Td -(2872 ) 21.8426 Tj -0 -246.8274 Td -(2873 void) 39.3166 Tj -0 -256.3207 Td -(2874 syscall\(void\)) 78.6333 Tj -0 -265.8141 Td -(2875 {) 26.2111 Tj -0 -275.3075 Td -(2876 int num;) 65.5277 Tj -0 -284.8008 Td -(2877 ) 21.8426 Tj -0 -294.2942 Td -(2878 num = proc->tf->eax;) 117.9499 Tj -0 -303.7875 Td -(2879 if\(num >= 0 && num < NELEM\(syscalls\) && syscalls[num]\ -\)) 266.4794 Tj -0 -313.2809 Td -(2880 proc->tf->eax = syscalls[num]\(\);) 179.1091 Tj -0 -322.7743 Td -(2881 else {) 56.7907 Tj -0 -332.2676 Td -(2882 cprintf\("%d %s: unknown sys call %d\\n",) 209.6887 Tj -0 -341.761 Td -(2883 proc->pid, proc->name, num\);) 196.5831 Tj -0 -351.2543 Td -(2884 proc->tf->eax = -1;) 122.3184 Tj -0 -360.7477 Td -(2885 }) 34.9481 Tj -0 -370.2411 Td -(2886 }) 26.2111 Tj -0 -379.7344 Td -(2887 ) 21.8426 Tj -0 -389.2278 Td -(2888 ) 21.8426 Tj -0 -398.7211 Td -(2889 ) 21.8426 Tj -0 -408.2145 Td -(2890 ) 21.8426 Tj -0 -417.7079 Td -(2891 ) 21.8426 Tj -0 -427.2012 Td -(2892 ) 21.8426 Tj -0 -436.6946 Td -(2893 ) 21.8426 Tj -0 -446.1879 Td -(2894 ) 21.8426 Tj -0 -455.6813 Td -(2895 ) 21.8426 Tj -0 -465.1747 Td -(2896 ) 21.8426 Tj -0 -474.668 Td -(2897 ) 21.8426 Tj -0 -484.1614 Td -(2898 ) 21.8426 Tj -0 -493.6547 Td -(2899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 28) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 36 36 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysproc.c Page 1) 174.7406 Tj -0 -28.4801 Td -(2900 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(2901 #include "x86.h") 91.7388 Tj -0 -47.4668 Td -(2902 #include "defs.h") 96.1073 Tj -0 -56.9602 Td -(2903 #include "param.h") 100.4758 Tj -0 -66.4535 Td -(2904 #include "mmu.h") 91.7388 Tj -0 -75.9469 Td -(2905 #include "proc.h") 96.1073 Tj -0 -85.4403 Td -(2906 ) 21.8426 Tj -0 -94.9336 Td -(2907 int) 34.9481 Tj -0 -104.427 Td -(2908 sys_fork\(void\)) 83.0018 Tj -0 -113.9203 Td -(2909 {) 26.2111 Tj -0 -123.4137 Td -(2910 return fork\(\);) 91.7388 Tj -0 -132.9071 Td -(2911 }) 26.2111 Tj -0 -142.4004 Td -(2912 ) 21.8426 Tj -0 -151.8938 Td -(2913 int) 34.9481 Tj -0 -161.3871 Td -(2914 sys_exit\(void\)) 83.0018 Tj -0 -170.8805 Td -(2915 {) 26.2111 Tj -0 -180.3739 Td -(2916 exit\(\);) 61.1592 Tj -0 -189.8672 Td -(2917 return 0; // not reached) 139.7925 Tj -0 -199.3606 Td -(2918 }) 26.2111 Tj -0 -208.8539 Td -(2919 ) 21.8426 Tj -0 -218.3473 Td -(2920 int) 34.9481 Tj -0 -227.8407 Td -(2921 sys_wait\(void\)) 83.0018 Tj -0 -237.334 Td -(2922 {) 26.2111 Tj -0 -246.8274 Td -(2923 return wait\(\);) 91.7388 Tj -0 -256.3207 Td -(2924 }) 26.2111 Tj -0 -265.8141 Td -(2925 ) 21.8426 Tj -0 -275.3075 Td -(2926 int) 34.9481 Tj -0 -284.8008 Td -(2927 sys_kill\(void\)) 83.0018 Tj -0 -294.2942 Td -(2928 {) 26.2111 Tj -0 -303.7875 Td -(2929 int pid;) 65.5277 Tj -0 -313.2809 Td -(2930 ) 21.8426 Tj -0 -322.7743 Td -(2931 if\(argint\(0, &pid\) < 0\)) 131.0554 Tj -0 -332.2676 Td -(2932 return -1;) 83.0018 Tj -0 -341.761 Td -(2933 return kill\(pid\);) 104.8443 Tj -0 -351.2543 Td -(2934 }) 26.2111 Tj -0 -360.7477 Td -(2935 ) 21.8426 Tj -0 -370.2411 Td -(2936 int) 34.9481 Tj -0 -379.7344 Td -(2937 sys_getpid\(void\)) 91.7388 Tj -0 -389.2278 Td -(2938 {) 26.2111 Tj -0 -398.7211 Td -(2939 return proc->pid;) 104.8443 Tj -0 -408.2145 Td -(2940 }) 26.2111 Tj -0 -417.7079 Td -(2941 ) 21.8426 Tj -0 -427.2012 Td -(2942 ) 21.8426 Tj -0 -436.6946 Td -(2943 ) 21.8426 Tj -0 -446.1879 Td -(2944 ) 21.8426 Tj -0 -455.6813 Td -(2945 ) 21.8426 Tj -0 -465.1747 Td -(2946 ) 21.8426 Tj -0 -474.668 Td -(2947 ) 21.8426 Tj -0 -484.1614 Td -(2948 ) 21.8426 Tj -0 -493.6547 Td -(2949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 29) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysproc.c Page 2) 174.7406 Tj -0 -28.4801 Td -(2950 int) 34.9481 Tj -0 -37.9735 Td -(2951 sys_sbrk\(void\)) 83.0018 Tj -0 -47.4668 Td -(2952 {) 26.2111 Tj -0 -56.9602 Td -(2953 int addr;) 69.8962 Tj -0 -66.4535 Td -(2954 int n;) 56.7907 Tj -0 -75.9469 Td -(2955 ) 21.8426 Tj -0 -85.4403 Td -(2956 if\(argint\(0, &n\) < 0\)) 122.3184 Tj -0 -94.9336 Td -(2957 return -1;) 83.0018 Tj -0 -104.427 Td -(2958 addr = proc->sz;) 100.4758 Tj -0 -113.9203 Td -(2959 if\(growproc\(n\) < 0\)) 113.5814 Tj -0 -123.4137 Td -(2960 return -1;) 83.0018 Tj -0 -132.9071 Td -(2961 return addr;) 83.0018 Tj -0 -142.4004 Td -(2962 }) 26.2111 Tj -0 -151.8938 Td -(2963 ) 21.8426 Tj -0 -161.3871 Td -(2964 int) 34.9481 Tj -0 -170.8805 Td -(2965 sys_sleep\(void\)) 87.3703 Tj -0 -180.3739 Td -(2966 {) 26.2111 Tj -0 -189.8672 Td -(2967 int n, ticks0;) 91.7388 Tj -0 -199.3606 Td -(2968 ) 21.8426 Tj -0 -208.8539 Td -(2969 if\(argint\(0, &n\) < 0\)) 122.3184 Tj -0 -218.3473 Td -(2970 return -1;) 83.0018 Tj -0 -227.8407 Td -(2971 acquire\(&tickslock\);) 117.9499 Tj -0 -237.334 Td -(2972 ticks0 = ticks;) 96.1073 Tj -0 -246.8274 Td -(2973 while\(ticks - ticks0 < n\){) 144.161 Tj -0 -256.3207 Td -(2974 if\(proc->killed\){) 113.5814 Tj -0 -265.8141 Td -(2975 release\(&tickslock\);) 135.4239 Tj -0 -275.3075 Td -(2976 return -1;) 91.7388 Tj -0 -284.8008 Td -(2977 }) 43.6851 Tj -0 -294.2942 Td -(2978 sleep\(&ticks, &tickslock\);) 152.898 Tj -0 -303.7875 Td -(2979 }) 34.9481 Tj -0 -313.2809 Td -(2980 release\(&tickslock\);) 117.9499 Tj -0 -322.7743 Td -(2981 return 0;) 69.8962 Tj -0 -332.2676 Td -(2982 }) 26.2111 Tj -0 -341.761 Td -(2983 ) 21.8426 Tj -0 -351.2543 Td -(2984 ) 21.8426 Tj -0 -360.7477 Td -(2985 ) 21.8426 Tj -0 -370.2411 Td -(2986 ) 21.8426 Tj -0 -379.7344 Td -(2987 ) 21.8426 Tj -0 -389.2278 Td -(2988 ) 21.8426 Tj -0 -398.7211 Td -(2989 ) 21.8426 Tj -0 -408.2145 Td -(2990 ) 21.8426 Tj -0 -417.7079 Td -(2991 ) 21.8426 Tj -0 -427.2012 Td -(2992 ) 21.8426 Tj -0 -436.6946 Td -(2993 ) 21.8426 Tj -0 -446.1879 Td -(2994 ) 21.8426 Tj -0 -455.6813 Td -(2995 ) 21.8426 Tj -0 -465.1747 Td -(2996 ) 21.8426 Tj -0 -474.668 Td -(2997 ) 21.8426 Tj -0 -484.1614 Td -(2998 ) 21.8426 Tj -0 -493.6547 Td -(2999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 29) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 37 37 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/buf.h Page 1) 157.2665 Tj -0 -28.4801 Td -(3000 struct buf {) 74.2647 Tj -0 -37.9735 Td -(3001 int flags;) 74.2647 Tj -0 -47.4668 Td -(3002 uint dev;) 69.8962 Tj -0 -56.9602 Td -(3003 uint sector;) 83.0018 Tj -0 -66.4535 Td -(3004 struct buf *prev; // LRU cache list) 183.4776 Tj -0 -75.9469 Td -(3005 struct buf *next;) 104.8443 Tj -0 -85.4403 Td -(3006 struct buf *qnext; // disk queue) 170.3721 Tj -0 -94.9336 Td -(3007 uchar data[512];) 100.4758 Tj -0 -104.427 Td -(3008 };) 30.5796 Tj -0 -113.9203 Td -(3009 #define B_BUSY 0x1 // buffer is locked by some process) 266.4794 Tj -0 -123.4137 Td -(3010 #define B_VALID 0x2 // buffer has been read from disk) 257.7424 Tj -0 -132.9071 Td -(3011 #define B_DIRTY 0x4 // buffer needs to be written to disk) 275.2164 Tj -0 -142.4004 Td -(3012 ) 21.8426 Tj -0 -151.8938 Td -(3013 ) 21.8426 Tj -0 -161.3871 Td -(3014 ) 21.8426 Tj -0 -170.8805 Td -(3015 ) 21.8426 Tj -0 -180.3739 Td -(3016 ) 21.8426 Tj -0 -189.8672 Td -(3017 ) 21.8426 Tj -0 -199.3606 Td -(3018 ) 21.8426 Tj -0 -208.8539 Td -(3019 ) 21.8426 Tj -0 -218.3473 Td -(3020 ) 21.8426 Tj -0 -227.8407 Td -(3021 ) 21.8426 Tj -0 -237.334 Td -(3022 ) 21.8426 Tj -0 -246.8274 Td -(3023 ) 21.8426 Tj -0 -256.3207 Td -(3024 ) 21.8426 Tj -0 -265.8141 Td -(3025 ) 21.8426 Tj -0 -275.3075 Td -(3026 ) 21.8426 Tj -0 -284.8008 Td -(3027 ) 21.8426 Tj -0 -294.2942 Td -(3028 ) 21.8426 Tj -0 -303.7875 Td -(3029 ) 21.8426 Tj -0 -313.2809 Td -(3030 ) 21.8426 Tj -0 -322.7743 Td -(3031 ) 21.8426 Tj -0 -332.2676 Td -(3032 ) 21.8426 Tj -0 -341.761 Td -(3033 ) 21.8426 Tj -0 -351.2543 Td -(3034 ) 21.8426 Tj -0 -360.7477 Td -(3035 ) 21.8426 Tj -0 -370.2411 Td -(3036 ) 21.8426 Tj -0 -379.7344 Td -(3037 ) 21.8426 Tj -0 -389.2278 Td -(3038 ) 21.8426 Tj -0 -398.7211 Td -(3039 ) 21.8426 Tj -0 -408.2145 Td -(3040 ) 21.8426 Tj -0 -417.7079 Td -(3041 ) 21.8426 Tj -0 -427.2012 Td -(3042 ) 21.8426 Tj -0 -436.6946 Td -(3043 ) 21.8426 Tj -0 -446.1879 Td -(3044 ) 21.8426 Tj -0 -455.6813 Td -(3045 ) 21.8426 Tj -0 -465.1747 Td -(3046 ) 21.8426 Tj -0 -474.668 Td -(3047 ) 21.8426 Tj -0 -484.1614 Td -(3048 ) 21.8426 Tj -0 -493.6547 Td -(3049 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 30) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fcntl.h Page 1) 166.0035 Tj -0 -28.4801 Td -(3050 #define O_RDONLY 0x000) 122.3184 Tj -0 -37.9735 Td -(3051 #define O_WRONLY 0x001) 122.3184 Tj -0 -47.4668 Td -(3052 #define O_RDWR 0x002) 122.3184 Tj -0 -56.9602 Td -(3053 #define O_CREATE 0x200) 122.3184 Tj -0 -66.4535 Td -(3054 ) 21.8426 Tj -0 -75.9469 Td -(3055 ) 21.8426 Tj -0 -85.4403 Td -(3056 ) 21.8426 Tj -0 -94.9336 Td -(3057 ) 21.8426 Tj -0 -104.427 Td -(3058 ) 21.8426 Tj -0 -113.9203 Td -(3059 ) 21.8426 Tj -0 -123.4137 Td -(3060 ) 21.8426 Tj -0 -132.9071 Td -(3061 ) 21.8426 Tj -0 -142.4004 Td -(3062 ) 21.8426 Tj -0 -151.8938 Td -(3063 ) 21.8426 Tj -0 -161.3871 Td -(3064 ) 21.8426 Tj -0 -170.8805 Td -(3065 ) 21.8426 Tj -0 -180.3739 Td -(3066 ) 21.8426 Tj -0 -189.8672 Td -(3067 ) 21.8426 Tj -0 -199.3606 Td -(3068 ) 21.8426 Tj -0 -208.8539 Td -(3069 ) 21.8426 Tj -0 -218.3473 Td -(3070 ) 21.8426 Tj -0 -227.8407 Td -(3071 ) 21.8426 Tj -0 -237.334 Td -(3072 ) 21.8426 Tj -0 -246.8274 Td -(3073 ) 21.8426 Tj -0 -256.3207 Td -(3074 ) 21.8426 Tj -0 -265.8141 Td -(3075 ) 21.8426 Tj -0 -275.3075 Td -(3076 ) 21.8426 Tj -0 -284.8008 Td -(3077 ) 21.8426 Tj -0 -294.2942 Td -(3078 ) 21.8426 Tj -0 -303.7875 Td -(3079 ) 21.8426 Tj -0 -313.2809 Td -(3080 ) 21.8426 Tj -0 -322.7743 Td -(3081 ) 21.8426 Tj -0 -332.2676 Td -(3082 ) 21.8426 Tj -0 -341.761 Td -(3083 ) 21.8426 Tj -0 -351.2543 Td -(3084 ) 21.8426 Tj -0 -360.7477 Td -(3085 ) 21.8426 Tj -0 -370.2411 Td -(3086 ) 21.8426 Tj -0 -379.7344 Td -(3087 ) 21.8426 Tj -0 -389.2278 Td -(3088 ) 21.8426 Tj -0 -398.7211 Td -(3089 ) 21.8426 Tj -0 -408.2145 Td -(3090 ) 21.8426 Tj -0 -417.7079 Td -(3091 ) 21.8426 Tj -0 -427.2012 Td -(3092 ) 21.8426 Tj -0 -436.6946 Td -(3093 ) 21.8426 Tj -0 -446.1879 Td -(3094 ) 21.8426 Tj -0 -455.6813 Td -(3095 ) 21.8426 Tj -0 -465.1747 Td -(3096 ) 21.8426 Tj -0 -474.668 Td -(3097 ) 21.8426 Tj -0 -484.1614 Td -(3098 ) 21.8426 Tj -0 -493.6547 Td -(3099 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 30) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 38 38 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/stat.h Page 1) 161.635 Tj -0 -28.4801 Td -(3100 #define T_DIR 1 // Directory) 157.2665 Tj -0 -37.9735 Td -(3101 #define T_FILE 2 // File) 135.4239 Tj -0 -47.4668 Td -(3102 #define T_DEV 3 // Special device) 179.1091 Tj -0 -56.9602 Td -(3103 ) 21.8426 Tj -0 -66.4535 Td -(3104 struct stat {) 78.6333 Tj -0 -75.9469 Td -(3105 short type; // Type of file) 152.898 Tj -0 -85.4403 Td -(3106 int dev; // Device number) 157.2665 Tj -0 -94.9336 Td -(3107 uint ino; // Inode number on device) 196.5831 Tj -0 -104.427 Td -(3108 short nlink; // Number of links to file) 200.9517 Tj -0 -113.9203 Td -(3109 uint size; // Size of file in bytes) 192.2146 Tj -0 -123.4137 Td -(3110 };) 30.5796 Tj -0 -132.9071 Td -(3111 ) 21.8426 Tj -0 -142.4004 Td -(3112 ) 21.8426 Tj -0 -151.8938 Td -(3113 ) 21.8426 Tj -0 -161.3871 Td -(3114 ) 21.8426 Tj -0 -170.8805 Td -(3115 ) 21.8426 Tj -0 -180.3739 Td -(3116 ) 21.8426 Tj -0 -189.8672 Td -(3117 ) 21.8426 Tj -0 -199.3606 Td -(3118 ) 21.8426 Tj -0 -208.8539 Td -(3119 ) 21.8426 Tj -0 -218.3473 Td -(3120 ) 21.8426 Tj -0 -227.8407 Td -(3121 ) 21.8426 Tj -0 -237.334 Td -(3122 ) 21.8426 Tj -0 -246.8274 Td -(3123 ) 21.8426 Tj -0 -256.3207 Td -(3124 ) 21.8426 Tj -0 -265.8141 Td -(3125 ) 21.8426 Tj -0 -275.3075 Td -(3126 ) 21.8426 Tj -0 -284.8008 Td -(3127 ) 21.8426 Tj -0 -294.2942 Td -(3128 ) 21.8426 Tj -0 -303.7875 Td -(3129 ) 21.8426 Tj -0 -313.2809 Td -(3130 ) 21.8426 Tj -0 -322.7743 Td -(3131 ) 21.8426 Tj -0 -332.2676 Td -(3132 ) 21.8426 Tj -0 -341.761 Td -(3133 ) 21.8426 Tj -0 -351.2543 Td -(3134 ) 21.8426 Tj -0 -360.7477 Td -(3135 ) 21.8426 Tj -0 -370.2411 Td -(3136 ) 21.8426 Tj -0 -379.7344 Td -(3137 ) 21.8426 Tj -0 -389.2278 Td -(3138 ) 21.8426 Tj -0 -398.7211 Td -(3139 ) 21.8426 Tj -0 -408.2145 Td -(3140 ) 21.8426 Tj -0 -417.7079 Td -(3141 ) 21.8426 Tj -0 -427.2012 Td -(3142 ) 21.8426 Tj -0 -436.6946 Td -(3143 ) 21.8426 Tj -0 -446.1879 Td -(3144 ) 21.8426 Tj -0 -455.6813 Td -(3145 ) 21.8426 Tj -0 -465.1747 Td -(3146 ) 21.8426 Tj -0 -474.668 Td -(3147 ) 21.8426 Tj -0 -484.1614 Td -(3148 ) 21.8426 Tj -0 -493.6547 Td -(3149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 31) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.h Page 1) 152.898 Tj -0 -28.4801 Td -(3150 // On-disk file system format.) 152.898 Tj -0 -37.9735 Td -(3151 // Both the kernel and user programs use this header file.) 275.2164 Tj -0 -47.4668 Td -(3152 ) 21.8426 Tj -0 -56.9602 Td -(3153 // Block 0 is unused.) 113.5814 Tj -0 -66.4535 Td -(3154 // Block 1 is super block.) 135.4239 Tj -0 -75.9469 Td -(3155 // Inodes start at block 2.) 139.7925 Tj -0 -85.4403 Td -(3156 ) 21.8426 Tj -0 -94.9336 Td -(3157 #define ROOTINO 1 // root i-number) 174.7406 Tj -0 -104.427 Td -(3158 #define BSIZE 512 // block size) 161.635 Tj -0 -113.9203 Td -(3159 ) 21.8426 Tj -0 -123.4137 Td -(3160 // File system super block) 135.4239 Tj -0 -132.9071 Td -(3161 struct superblock {) 104.8443 Tj -0 -142.4004 Td -(3162 uint size; // Size of file system image \(blocks\ -\)) 275.2164 Tj -0 -151.8938 Td -(3163 uint nblocks; // Number of data blocks) 218.4257 Tj -0 -161.3871 Td -(3164 uint ninodes; // Number of inodes.) 200.9517 Tj -0 -170.8805 Td -(3165 };) 30.5796 Tj -0 -180.3739 Td -(3166 ) 21.8426 Tj -0 -189.8672 Td -(3167 #define NDIRECT 12) 100.4758 Tj -0 -199.3606 Td -(3168 #define NINDIRECT \(BSIZE / sizeof\(uint\)\)) 196.5831 Tj -0 -208.8539 Td -(3169 #define MAXFILE \(NDIRECT + NINDIRECT\)) 183.4776 Tj -0 -218.3473 Td -(3170 ) 21.8426 Tj -0 -227.8407 Td -(3171 // On-disk inode structure) 135.4239 Tj -0 -237.334 Td -(3172 struct dinode {) 87.3703 Tj -0 -246.8274 Td -(3173 short type; // File type) 179.1091 Tj -0 -256.3207 Td -(3174 short major; // Major device number \(T_DEV onl\ -y\)) 279.5849 Tj -0 -265.8141 Td -(3175 short minor; // Minor device number \(T_DEV onl\ -y\)) 279.5849 Tj -0 -275.3075 Td -(3176 short nlink; // Number of links to inode in fil\ -e system) 310.1645 Tj -0 -284.8008 Td -(3177 uint size; // Size of file \(bytes\)) 227.1628 Tj -0 -294.2942 Td -(3178 uint addrs[NDIRECT+1]; // Data block addresses) 240.2683 Tj -0 -303.7875 Td -(3179 };) 30.5796 Tj -0 -313.2809 Td -(3180 ) 21.8426 Tj -0 -322.7743 Td -(3181 // Inodes per block.) 109.2129 Tj -0 -332.2676 Td -(3182 #define IPB \(BSIZE / sizeof\(struct dinode\)\)) 253.3738 Tj -0 -341.761 Td -(3183 ) 21.8426 Tj -0 -351.2543 Td -(3184 // Block containing inode i) 139.7925 Tj -0 -360.7477 Td -(3185 #define IBLOCK\(i\) \(\(i\) / IPB + 2\)) 183.4776 Tj -0 -370.2411 Td -(3186 ) 21.8426 Tj -0 -379.7344 Td -(3187 // Bitmap bits per block) 126.6869 Tj -0 -389.2278 Td -(3188 #define BPB \(BSIZE*8\)) 157.2665 Tj -0 -398.7211 Td -(3189 ) 21.8426 Tj -0 -408.2145 Td -(3190 // Block containing bit for block b) 174.7406 Tj -0 -417.7079 Td -(3191 #define BBLOCK\(b, ninodes\) \(b/BPB + \(ninodes\)/IPB + 3\ -\)) 257.7424 Tj -0 -427.2012 Td -(3192 ) 21.8426 Tj -0 -436.6946 Td -(3193 ) 21.8426 Tj -0 -446.1879 Td -(3194 ) 21.8426 Tj -0 -455.6813 Td -(3195 ) 21.8426 Tj -0 -465.1747 Td -(3196 ) 21.8426 Tj -0 -474.668 Td -(3197 ) 21.8426 Tj -0 -484.1614 Td -(3198 ) 21.8426 Tj -0 -493.6547 Td -(3199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 31) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 39 39 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.h Page 2) 152.898 Tj -0 -28.4801 Td -(3200 // Directory is a file containing a sequence of dirent str\ -uctures.) 310.1645 Tj -0 -37.9735 Td -(3201 #define DIRSIZ 14) 96.1073 Tj -0 -47.4668 Td -(3202 ) 21.8426 Tj -0 -56.9602 Td -(3203 struct dirent {) 87.3703 Tj -0 -66.4535 Td -(3204 ushort inum;) 83.0018 Tj -0 -75.9469 Td -(3205 char name[DIRSIZ];) 109.2129 Tj -0 -85.4403 Td -(3206 };) 30.5796 Tj -0 -94.9336 Td -(3207 ) 21.8426 Tj -0 -104.427 Td -(3208 ) 21.8426 Tj -0 -113.9203 Td -(3209 ) 21.8426 Tj -0 -123.4137 Td -(3210 ) 21.8426 Tj -0 -132.9071 Td -(3211 ) 21.8426 Tj -0 -142.4004 Td -(3212 ) 21.8426 Tj -0 -151.8938 Td -(3213 ) 21.8426 Tj -0 -161.3871 Td -(3214 ) 21.8426 Tj -0 -170.8805 Td -(3215 ) 21.8426 Tj -0 -180.3739 Td -(3216 ) 21.8426 Tj -0 -189.8672 Td -(3217 ) 21.8426 Tj -0 -199.3606 Td -(3218 ) 21.8426 Tj -0 -208.8539 Td -(3219 ) 21.8426 Tj -0 -218.3473 Td -(3220 ) 21.8426 Tj -0 -227.8407 Td -(3221 ) 21.8426 Tj -0 -237.334 Td -(3222 ) 21.8426 Tj -0 -246.8274 Td -(3223 ) 21.8426 Tj -0 -256.3207 Td -(3224 ) 21.8426 Tj -0 -265.8141 Td -(3225 ) 21.8426 Tj -0 -275.3075 Td -(3226 ) 21.8426 Tj -0 -284.8008 Td -(3227 ) 21.8426 Tj -0 -294.2942 Td -(3228 ) 21.8426 Tj -0 -303.7875 Td -(3229 ) 21.8426 Tj -0 -313.2809 Td -(3230 ) 21.8426 Tj -0 -322.7743 Td -(3231 ) 21.8426 Tj -0 -332.2676 Td -(3232 ) 21.8426 Tj -0 -341.761 Td -(3233 ) 21.8426 Tj -0 -351.2543 Td -(3234 ) 21.8426 Tj -0 -360.7477 Td -(3235 ) 21.8426 Tj -0 -370.2411 Td -(3236 ) 21.8426 Tj -0 -379.7344 Td -(3237 ) 21.8426 Tj -0 -389.2278 Td -(3238 ) 21.8426 Tj -0 -398.7211 Td -(3239 ) 21.8426 Tj -0 -408.2145 Td -(3240 ) 21.8426 Tj -0 -417.7079 Td -(3241 ) 21.8426 Tj -0 -427.2012 Td -(3242 ) 21.8426 Tj -0 -436.6946 Td -(3243 ) 21.8426 Tj -0 -446.1879 Td -(3244 ) 21.8426 Tj -0 -455.6813 Td -(3245 ) 21.8426 Tj -0 -465.1747 Td -(3246 ) 21.8426 Tj -0 -474.668 Td -(3247 ) 21.8426 Tj -0 -484.1614 Td -(3248 ) 21.8426 Tj -0 -493.6547 Td -(3249 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 32) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/file.h Page 1) 161.635 Tj -0 -28.4801 Td -(3250 struct file {) 78.6333 Tj -0 -37.9735 Td -(3251 enum { FD_NONE, FD_PIPE, FD_INODE } type;) 209.6887 Tj -0 -47.4668 Td -(3252 int ref; // reference count) 148.5295 Tj -0 -56.9602 Td -(3253 char readable;) 91.7388 Tj -0 -66.4535 Td -(3254 char writable;) 91.7388 Tj -0 -75.9469 Td -(3255 struct pipe *pipe;) 109.2129 Tj -0 -85.4403 Td -(3256 struct inode *ip;) 104.8443 Tj -0 -94.9336 Td -(3257 uint off;) 69.8962 Tj -0 -104.427 Td -(3258 };) 30.5796 Tj -0 -113.9203 Td -(3259 ) 21.8426 Tj -0 -123.4137 Td -(3260 ) 21.8426 Tj -0 -132.9071 Td -(3261 // in-core file system types) 144.161 Tj -0 -142.4004 Td -(3262 ) 21.8426 Tj -0 -151.8938 Td -(3263 struct inode {) 83.0018 Tj -0 -161.3871 Td -(3264 uint dev; // Device number) 187.8461 Tj -0 -170.8805 Td -(3265 uint inum; // Inode number) 183.4776 Tj -0 -180.3739 Td -(3266 int ref; // Reference count) 196.5831 Tj -0 -189.8672 Td -(3267 int flags; // I_BUSY, I_VALID) 196.5831 Tj -0 -199.3606 Td -(3268 ) 21.8426 Tj -0 -208.8539 Td -(3269 short type; // copy of disk inode) 209.6887 Tj -0 -218.3473 Td -(3270 short major;) 83.0018 Tj -0 -227.8407 Td -(3271 short minor;) 83.0018 Tj -0 -237.334 Td -(3272 short nlink;) 83.0018 Tj -0 -246.8274 Td -(3273 uint size;) 74.2647 Tj -0 -256.3207 Td -(3274 uint addrs[NDIRECT+1];) 126.6869 Tj -0 -265.8141 Td -(3275 };) 30.5796 Tj -0 -275.3075 Td -(3276 ) 21.8426 Tj -0 -284.8008 Td -(3277 #define I_BUSY 0x1) 100.4758 Tj -0 -294.2942 Td -(3278 #define I_VALID 0x2) 104.8443 Tj -0 -303.7875 Td -(3279 ) 21.8426 Tj -0 -313.2809 Td -(3280 ) 21.8426 Tj -0 -322.7743 Td -(3281 // device implementations) 131.0554 Tj -0 -332.2676 Td -(3282 ) 21.8426 Tj -0 -341.761 Td -(3283 struct devsw {) 83.0018 Tj -0 -351.2543 Td -(3284 int \(*read\)\(struct inode*, char*, int\);) 200.9517 Tj -0 -360.7477 Td -(3285 int \(*write\)\(struct inode*, char*, int\);) 205.3202 Tj -0 -370.2411 Td -(3286 };) 30.5796 Tj -0 -379.7344 Td -(3287 ) 21.8426 Tj -0 -389.2278 Td -(3288 extern struct devsw devsw[];) 144.161 Tj -0 -398.7211 Td -(3289 ) 21.8426 Tj -0 -408.2145 Td -(3290 #define CONSOLE 1) 96.1073 Tj -0 -417.7079 Td -(3291 ) 21.8426 Tj -0 -427.2012 Td -(3292 ) 21.8426 Tj -0 -436.6946 Td -(3293 ) 21.8426 Tj -0 -446.1879 Td -(3294 ) 21.8426 Tj -0 -455.6813 Td -(3295 ) 21.8426 Tj -0 -465.1747 Td -(3296 ) 21.8426 Tj -0 -474.668 Td -(3297 ) 21.8426 Tj -0 -484.1614 Td -(3298 ) 21.8426 Tj -0 -493.6547 Td -(3299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 32) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 40 40 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ide.c Page 1) 157.2665 Tj -0 -28.4801 Td -(3300 // Simple PIO-based \(non-DMA\) IDE driver code.) 222.7942 Tj -0 -37.9735 Td -(3301 ) 21.8426 Tj -0 -47.4668 Td -(3302 #include "types.h") 100.4758 Tj -0 -56.9602 Td -(3303 #include "defs.h") 96.1073 Tj -0 -66.4535 Td -(3304 #include "param.h") 100.4758 Tj -0 -75.9469 Td -(3305 #include "mmu.h") 91.7388 Tj -0 -85.4403 Td -(3306 #include "proc.h") 96.1073 Tj -0 -94.9336 Td -(3307 #include "x86.h") 91.7388 Tj -0 -104.427 Td -(3308 #include "traps.h") 100.4758 Tj -0 -113.9203 Td -(3309 #include "spinlock.h") 113.5814 Tj -0 -123.4137 Td -(3310 #include "buf.h") 91.7388 Tj -0 -132.9071 Td -(3311 ) 21.8426 Tj -0 -142.4004 Td -(3312 #define IDE_BSY 0x80) 135.4239 Tj -0 -151.8938 Td -(3313 #define IDE_DRDY 0x40) 135.4239 Tj -0 -161.3871 Td -(3314 #define IDE_DF 0x20) 135.4239 Tj -0 -170.8805 Td -(3315 #define IDE_ERR 0x01) 135.4239 Tj -0 -180.3739 Td -(3316 ) 21.8426 Tj -0 -189.8672 Td -(3317 #define IDE_CMD_READ 0x20) 135.4239 Tj -0 -199.3606 Td -(3318 #define IDE_CMD_WRITE 0x30) 135.4239 Tj -0 -208.8539 Td -(3319 ) 21.8426 Tj -0 -218.3473 Td -(3320 // idequeue points to the buf now being read/written to th\ -e disk.) 305.796 Tj -0 -227.8407 Td -(3321 // idequeue->qnext points to the next buf to be processed.) 275.2164 Tj -0 -237.334 Td -(3322 // You must hold idelock while manipulating queue.) 240.2683 Tj -0 -246.8274 Td -(3323 ) 21.8426 Tj -0 -256.3207 Td -(3324 static struct spinlock idelock;) 157.2665 Tj -0 -265.8141 Td -(3325 static struct buf *idequeue;) 144.161 Tj -0 -275.3075 Td -(3326 ) 21.8426 Tj -0 -284.8008 Td -(3327 static int havedisk1;) 113.5814 Tj -0 -294.2942 Td -(3328 static void idestart\(struct buf*\);) 170.3721 Tj -0 -303.7875 Td -(3329 ) 21.8426 Tj -0 -313.2809 Td -(3330 // Wait for IDE disk to become ready.) 183.4776 Tj -0 -322.7743 Td -(3331 static int) 65.5277 Tj -0 -332.2676 Td -(3332 idewait\(int checkerr\)) 113.5814 Tj -0 -341.761 Td -(3333 {) 26.2111 Tj -0 -351.2543 Td -(3334 int r;) 56.7907 Tj -0 -360.7477 Td -(3335 ) 21.8426 Tj -0 -370.2411 Td -(3336 while\(\(\(r = inb\(0x1f7\)\) & \(IDE_BSY|IDE_DRDY\)\) !\ -= IDE_DRDY\)) 283.9534 Tj -0 -379.7344 Td -(3337 ;) 43.6851 Tj -0 -389.2278 Td -(3338 if\(checkerr && \(r & \(IDE_DF|IDE_ERR\)\) != 0\)) 218.4257 Tj -0 -398.7211 Td -(3339 return -1;) 83.0018 Tj -0 -408.2145 Td -(3340 return 0;) 69.8962 Tj -0 -417.7079 Td -(3341 }) 26.2111 Tj -0 -427.2012 Td -(3342 ) 21.8426 Tj -0 -436.6946 Td -(3343 ) 21.8426 Tj -0 -446.1879 Td -(3344 ) 21.8426 Tj -0 -455.6813 Td -(3345 ) 21.8426 Tj -0 -465.1747 Td -(3346 ) 21.8426 Tj -0 -474.668 Td -(3347 ) 21.8426 Tj -0 -484.1614 Td -(3348 ) 21.8426 Tj -0 -493.6547 Td -(3349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 33) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ide.c Page 2) 157.2665 Tj -0 -28.4801 Td -(3350 void) 39.3166 Tj -0 -37.9735 Td -(3351 ideinit\(void\)) 78.6333 Tj -0 -47.4668 Td -(3352 {) 26.2111 Tj -0 -56.9602 Td -(3353 int i;) 56.7907 Tj -0 -66.4535 Td -(3354 ) 21.8426 Tj -0 -75.9469 Td -(3355 initlock\(&idelock, "ide"\);) 144.161 Tj -0 -85.4403 Td -(3356 picenable\(IRQ_IDE\);) 113.5814 Tj -0 -94.9336 Td -(3357 ioapicenable\(IRQ_IDE, ncpu - 1\);) 170.3721 Tj -0 -104.427 Td -(3358 idewait\(0\);) 78.6333 Tj -0 -113.9203 Td -(3359 ) 21.8426 Tj -0 -123.4137 Td -(3360 // Check if disk 1 is present) 157.2665 Tj -0 -132.9071 Td -(3361 outb\(0x1f6, 0xe0 | \(1<<4\)\);) 148.5295 Tj -0 -142.4004 Td -(3362 for\(i=0; i<1000; i++\){) 126.6869 Tj -0 -151.8938 Td -(3363 if\(inb\(0x1f7\) != 0\){) 126.6869 Tj -0 -161.3871 Td -(3364 havedisk1 = 1;) 109.2129 Tj -0 -170.8805 Td -(3365 break;) 74.2647 Tj -0 -180.3739 Td -(3366 }) 43.6851 Tj -0 -189.8672 Td -(3367 }) 34.9481 Tj -0 -199.3606 Td -(3368 ) 21.8426 Tj -0 -208.8539 Td -(3369 // Switch back to disk 0.) 139.7925 Tj -0 -218.3473 Td -(3370 outb\(0x1f6, 0xe0 | \(0<<4\)\);) 148.5295 Tj -0 -227.8407 Td -(3371 }) 26.2111 Tj -0 -237.334 Td -(3372 ) 21.8426 Tj -0 -246.8274 Td -(3373 // Start the request for b. Caller must hold idelock.) 257.7424 Tj -0 -256.3207 Td -(3374 static void) 69.8962 Tj -0 -265.8141 Td -(3375 idestart\(struct buf *b\)) 122.3184 Tj -0 -275.3075 Td -(3376 {) 26.2111 Tj -0 -284.8008 Td -(3377 if\(b == 0\)) 74.2647 Tj -0 -294.2942 Td -(3378 panic\("idestart"\);) 117.9499 Tj -0 -303.7875 Td -(3379 ) 21.8426 Tj -0 -313.2809 Td -(3380 idewait\(0\);) 78.6333 Tj -0 -322.7743 Td -(3381 outb\(0x3f6, 0\); // generate interrupt) 196.5831 Tj -0 -332.2676 Td -(3382 outb\(0x1f2, 1\); // number of sectors) 192.2146 Tj -0 -341.761 Td -(3383 outb\(0x1f3, b->sector & 0xff\);) 161.635 Tj -0 -351.2543 Td -(3384 outb\(0x1f4, \(b->sector >> 8\) & 0xff\);) 192.2146 Tj -0 -360.7477 Td -(3385 outb\(0x1f5, \(b->sector >> 16\) & 0xff\);) 196.5831 Tj -0 -370.2411 Td -(3386 outb\(0x1f6, 0xe0 | \(\(b->dev&1\)<<4\) | \(\(b->sector>\ ->24\)&0x0f\)\);) 297.059 Tj -0 -379.7344 Td -(3387 if\(b->flags & B_DIRTY\){) 131.0554 Tj -0 -389.2278 Td -(3388 outb\(0x1f7, IDE_CMD_WRITE\);) 157.2665 Tj -0 -398.7211 Td -(3389 outsl\(0x1f0, b->data, 512/4\);) 166.0035 Tj -0 -408.2145 Td -(3390 } else {) 65.5277 Tj -0 -417.7079 Td -(3391 outb\(0x1f7, IDE_CMD_READ\);) 152.898 Tj -0 -427.2012 Td -(3392 }) 34.9481 Tj -0 -436.6946 Td -(3393 }) 26.2111 Tj -0 -446.1879 Td -(3394 ) 21.8426 Tj -0 -455.6813 Td -(3395 ) 21.8426 Tj -0 -465.1747 Td -(3396 ) 21.8426 Tj -0 -474.668 Td -(3397 ) 21.8426 Tj -0 -484.1614 Td -(3398 ) 21.8426 Tj -0 -493.6547 Td -(3399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 33) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 41 41 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ide.c Page 3) 157.2665 Tj -0 -28.4801 Td -(3400 // Interrupt handler.) 113.5814 Tj -0 -37.9735 Td -(3401 void) 39.3166 Tj -0 -47.4668 Td -(3402 ideintr\(void\)) 78.6333 Tj -0 -56.9602 Td -(3403 {) 26.2111 Tj -0 -66.4535 Td -(3404 struct buf *b;) 91.7388 Tj -0 -75.9469 Td -(3405 ) 21.8426 Tj -0 -85.4403 Td -(3406 // Take first buffer off queue.) 166.0035 Tj -0 -94.9336 Td -(3407 acquire\(&idelock\);) 109.2129 Tj -0 -104.427 Td -(3408 if\(\(b = idequeue\) == 0\){) 135.4239 Tj -0 -113.9203 Td -(3409 release\(&idelock\);) 117.9499 Tj -0 -123.4137 Td -(3410 cprintf\("Spurious IDE interrupt.\\n"\);) 200.9517 Tj -0 -132.9071 Td -(3411 return;) 69.8962 Tj -0 -142.4004 Td -(3412 }) 34.9481 Tj -0 -151.8938 Td -(3413 idequeue = b->qnext;) 117.9499 Tj -0 -161.3871 Td -(3414 ) 21.8426 Tj -0 -170.8805 Td -(3415 // Read data if needed.) 131.0554 Tj -0 -180.3739 Td -(3416 if\(!\(b->flags & B_DIRTY\) && idewait\(1\) >= 0\)) 222.7942 Tj -0 -189.8672 Td -(3417 insl\(0x1f0, b->data, 512/4\);) 161.635 Tj -0 -199.3606 Td -(3418 ) 21.8426 Tj -0 -208.8539 Td -(3419 // Wake process waiting for this buf.) 192.2146 Tj -0 -218.3473 Td -(3420 b->flags |= B_VALID;) 117.9499 Tj -0 -227.8407 Td -(3421 b->flags &= ~B_DIRTY;) 122.3184 Tj -0 -237.334 Td -(3422 wakeup\(b\);) 74.2647 Tj -0 -246.8274 Td -(3423 ) 21.8426 Tj -0 -256.3207 Td -(3424 // Start disk on next buf in queue.) 183.4776 Tj -0 -265.8141 Td -(3425 if\(idequeue != 0\)) 104.8443 Tj -0 -275.3075 Td -(3426 idestart\(idequeue\);) 122.3184 Tj -0 -284.8008 Td -(3427 ) 21.8426 Tj -0 -294.2942 Td -(3428 release\(&idelock\);) 109.2129 Tj -0 -303.7875 Td -(3429 }) 26.2111 Tj -0 -313.2809 Td -(3430 ) 21.8426 Tj -0 -322.7743 Td -(3431 ) 21.8426 Tj -0 -332.2676 Td -(3432 ) 21.8426 Tj -0 -341.761 Td -(3433 ) 21.8426 Tj -0 -351.2543 Td -(3434 ) 21.8426 Tj -0 -360.7477 Td -(3435 ) 21.8426 Tj -0 -370.2411 Td -(3436 ) 21.8426 Tj -0 -379.7344 Td -(3437 ) 21.8426 Tj -0 -389.2278 Td -(3438 ) 21.8426 Tj -0 -398.7211 Td -(3439 ) 21.8426 Tj -0 -408.2145 Td -(3440 ) 21.8426 Tj -0 -417.7079 Td -(3441 ) 21.8426 Tj -0 -427.2012 Td -(3442 ) 21.8426 Tj -0 -436.6946 Td -(3443 ) 21.8426 Tj -0 -446.1879 Td -(3444 ) 21.8426 Tj -0 -455.6813 Td -(3445 ) 21.8426 Tj -0 -465.1747 Td -(3446 ) 21.8426 Tj -0 -474.668 Td -(3447 ) 21.8426 Tj -0 -484.1614 Td -(3448 ) 21.8426 Tj -0 -493.6547 Td -(3449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 34) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ide.c Page 4) 157.2665 Tj -0 -28.4801 Td -(3450 // Sync buf with disk.) 117.9499 Tj -0 -37.9735 Td -(3451 // If B_DIRTY is set, write buf to disk, clear B_DIRTY, se\ -t B_VALID.) 318.9016 Tj -0 -47.4668 Td -(3452 // Else if B_VALID is not set, read buf from disk, set B_V\ -ALID.) 297.059 Tj -0 -56.9602 Td -(3453 void) 39.3166 Tj -0 -66.4535 Td -(3454 iderw\(struct buf *b\)) 109.2129 Tj -0 -75.9469 Td -(3455 {) 26.2111 Tj -0 -85.4403 Td -(3456 struct buf **pp;) 100.4758 Tj -0 -94.9336 Td -(3457 ) 21.8426 Tj -0 -104.427 Td -(3458 if\(!\(b->flags & B_BUSY\)\)) 135.4239 Tj -0 -113.9203 Td -(3459 panic\("iderw: buf not busy"\);) 166.0035 Tj -0 -123.4137 Td -(3460 if\(\(b->flags & \(B_VALID|B_DIRTY\)\) == B_VALID\)) 227.1628 Tj -0 -132.9071 Td -(3461 panic\("iderw: nothing to do"\);) 170.3721 Tj -0 -142.4004 Td -(3462 if\(b->dev != 0 && !havedisk1\)) 157.2665 Tj -0 -151.8938 Td -(3463 panic\("idrw: ide disk 1 not present"\);) 205.3202 Tj -0 -161.3871 Td -(3464 ) 21.8426 Tj -0 -170.8805 Td -(3465 acquire\(&idelock\);) 109.2129 Tj -0 -180.3739 Td -(3466 ) 21.8426 Tj -0 -189.8672 Td -(3467 // Append b to idequeue.) 135.4239 Tj -0 -199.3606 Td -(3468 b->qnext = 0;) 87.3703 Tj -0 -208.8539 Td -(3469 for\(pp=&idequeue; *pp; pp=&\(*pp\)->qnext\)) 205.3202 Tj -0 -218.3473 Td -(3470 ;) 43.6851 Tj -0 -227.8407 Td -(3471 *pp = b;) 65.5277 Tj -0 -237.334 Td -(3472 ) 21.8426 Tj -0 -246.8274 Td -(3473 // Start disk if necessary.) 148.5295 Tj -0 -256.3207 Td -(3474 if\(idequeue == b\)) 104.8443 Tj -0 -265.8141 Td -(3475 idestart\(b\);) 91.7388 Tj -0 -275.3075 Td -(3476 ) 21.8426 Tj -0 -284.8008 Td -(3477 // Wait for request to finish.) 161.635 Tj -0 -294.2942 Td -(3478 // Assuming will not sleep too long: ignore proc->killed\ -.) 279.5849 Tj -0 -303.7875 Td -(3479 while\(\(b->flags & \(B_VALID|B_DIRTY\)\) != B_VALID\)) 240.2683 Tj -0 -313.2809 Td -(3480 sleep\(b, &idelock\);) 122.3184 Tj -0 -322.7743 Td -(3481 ) 21.8426 Tj -0 -332.2676 Td -(3482 release\(&idelock\);) 109.2129 Tj -0 -341.761 Td -(3483 }) 26.2111 Tj -0 -351.2543 Td -(3484 ) 21.8426 Tj -0 -360.7477 Td -(3485 ) 21.8426 Tj -0 -370.2411 Td -(3486 ) 21.8426 Tj -0 -379.7344 Td -(3487 ) 21.8426 Tj -0 -389.2278 Td -(3488 ) 21.8426 Tj -0 -398.7211 Td -(3489 ) 21.8426 Tj -0 -408.2145 Td -(3490 ) 21.8426 Tj -0 -417.7079 Td -(3491 ) 21.8426 Tj -0 -427.2012 Td -(3492 ) 21.8426 Tj -0 -436.6946 Td -(3493 ) 21.8426 Tj -0 -446.1879 Td -(3494 ) 21.8426 Tj -0 -455.6813 Td -(3495 ) 21.8426 Tj -0 -465.1747 Td -(3496 ) 21.8426 Tj -0 -474.668 Td -(3497 ) 21.8426 Tj -0 -484.1614 Td -(3498 ) 21.8426 Tj -0 -493.6547 Td -(3499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 34) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 42 42 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bio.c Page 1) 157.2665 Tj -0 -28.4801 Td -(3500 // Buffer cache.) 91.7388 Tj -0 -37.9735 Td -(3501 //) 30.5796 Tj -0 -47.4668 Td -(3502 // The buffer cache is a linked list of buf structures hol\ -ding) 292.6905 Tj -0 -56.9602 Td -(3503 // cached copies of disk block contents. Caching disk blo\ -cks) 288.322 Tj -0 -66.4535 Td -(3504 // in memory reduces the number of disk reads and also pro\ -vides) 297.059 Tj -0 -75.9469 Td -(3505 // a synchronization point for disk blocks used by multipl\ -e processes.) 327.6386 Tj -0 -85.4403 Td -(3506 //) 30.5796 Tj -0 -94.9336 Td -(3507 // Interface:) 78.6333 Tj -0 -104.427 Td -(3508 // * To get a buffer for a particular disk block, call bre\ -ad.) 288.322 Tj -0 -113.9203 Td -(3509 // * After changing buffer data, call bwrite to flush it t\ -o disk.) 305.796 Tj -0 -123.4137 Td -(3510 // * When done with the buffer, call brelse.) 214.0572 Tj -0 -132.9071 Td -(3511 // * Do not use the buffer after calling brelse.) 231.5313 Tj -0 -142.4004 Td -(3512 // * Only one process at a time can use a buffer,) 235.8998 Tj -0 -151.8938 Td -(3513 // so do not keep them longer than necessary.) 235.8998 Tj -0 -161.3871 Td -(3514 //) 30.5796 Tj -0 -170.8805 Td -(3515 // The implementation uses three state flags internally:) 266.4794 Tj -0 -180.3739 Td -(3516 // * B_BUSY: the block has been returned from bread) 244.6368 Tj -0 -189.8672 Td -(3517 // and has not been passed back to brelse.) 222.7942 Tj -0 -199.3606 Td -(3518 // * B_VALID: the buffer data has been initialized) 240.2683 Tj -0 -208.8539 Td -(3519 // with the associated disk block contents.) 227.1628 Tj -0 -218.3473 Td -(3520 // * B_DIRTY: the buffer data has been modified) 227.1628 Tj -0 -227.8407 Td -(3521 // and needs to be written to disk.) 192.2146 Tj -0 -237.334 Td -(3522 ) 21.8426 Tj -0 -246.8274 Td -(3523 #include "types.h") 100.4758 Tj -0 -256.3207 Td -(3524 #include "defs.h") 96.1073 Tj -0 -265.8141 Td -(3525 #include "param.h") 100.4758 Tj -0 -275.3075 Td -(3526 #include "spinlock.h") 113.5814 Tj -0 -284.8008 Td -(3527 #include "buf.h") 91.7388 Tj -0 -294.2942 Td -(3528 ) 21.8426 Tj -0 -303.7875 Td -(3529 struct {) 56.7907 Tj -0 -313.2809 Td -(3530 struct spinlock lock;) 122.3184 Tj -0 -322.7743 Td -(3531 struct buf buf[NBUF];) 122.3184 Tj -0 -332.2676 Td -(3532 ) 21.8426 Tj -0 -341.761 Td -(3533 // Linked list of all buffers, through prev/next.) 244.6368 Tj -0 -351.2543 Td -(3534 // head.next is most recently used.) 183.4776 Tj -0 -360.7477 Td -(3535 struct buf head;) 100.4758 Tj -0 -370.2411 Td -(3536 } bcache;) 61.1592 Tj -0 -379.7344 Td -(3537 ) 21.8426 Tj -0 -389.2278 Td -(3538 void) 39.3166 Tj -0 -398.7211 Td -(3539 binit\(void\)) 69.8962 Tj -0 -408.2145 Td -(3540 {) 26.2111 Tj -0 -417.7079 Td -(3541 struct buf *b;) 91.7388 Tj -0 -427.2012 Td -(3542 ) 21.8426 Tj -0 -436.6946 Td -(3543 initlock\(&bcache.lock, "bcache"\);) 174.7406 Tj -0 -446.1879 Td -(3544 ) 21.8426 Tj -0 -455.6813 Td -(3545 ) 21.8426 Tj -0 -465.1747 Td -(3546 ) 21.8426 Tj -0 -474.668 Td -(3547 ) 21.8426 Tj -0 -484.1614 Td -(3548 ) 21.8426 Tj -0 -493.6547 Td -(3549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 35) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bio.c Page 2) 157.2665 Tj -0 -28.4801 Td -(3550 // Create linked list of buffers) 170.3721 Tj -0 -37.9735 Td -(3551 bcache.head.prev = &bcache.head;) 170.3721 Tj -0 -47.4668 Td -(3552 bcache.head.next = &bcache.head;) 170.3721 Tj -0 -56.9602 Td -(3553 for\(b = bcache.buf; b < bcache.buf+NBUF; b++\){) 231.5313 Tj -0 -66.4535 Td -(3554 b->next = bcache.head.next;) 157.2665 Tj -0 -75.9469 Td -(3555 b->prev = &bcache.head;) 139.7925 Tj -0 -85.4403 Td -(3556 b->dev = -1;) 91.7388 Tj -0 -94.9336 Td -(3557 bcache.head.next->prev = b;) 157.2665 Tj -0 -104.427 Td -(3558 bcache.head.next = b;) 131.0554 Tj -0 -113.9203 Td -(3559 }) 34.9481 Tj -0 -123.4137 Td -(3560 }) 26.2111 Tj -0 -132.9071 Td -(3561 ) 21.8426 Tj -0 -142.4004 Td -(3562 // Look through buffer cache for sector on device dev.) 257.7424 Tj -0 -151.8938 Td -(3563 // If not found, allocate fresh block.) 187.8461 Tj -0 -161.3871 Td -(3564 // In either case, return locked buffer.) 196.5831 Tj -0 -170.8805 Td -(3565 static struct buf*) 100.4758 Tj -0 -180.3739 Td -(3566 bget\(uint dev, uint sector\)) 139.7925 Tj -0 -189.8672 Td -(3567 {) 26.2111 Tj -0 -199.3606 Td -(3568 struct buf *b;) 91.7388 Tj -0 -208.8539 Td -(3569 ) 21.8426 Tj -0 -218.3473 Td -(3570 acquire\(&bcache.lock\);) 126.6869 Tj -0 -227.8407 Td -(3571 ) 21.8426 Tj -0 -237.334 Td -(3572 loop:) 48.0537 Tj -0 -246.8274 Td -(3573 // Try for cached block.) 135.4239 Tj -0 -256.3207 Td -(3574 for\(b = bcache.head.next; b != &bcache.head; b = b->nex\ -t\){) 283.9534 Tj -0 -265.8141 Td -(3575 if\(b->dev == dev && b->sector == sector\){) 218.4257 Tj -0 -275.3075 Td -(3576 if\(!\(b->flags & B_BUSY\)\){) 157.2665 Tj -0 -284.8008 Td -(3577 b->flags |= B_BUSY;) 139.7925 Tj -0 -294.2942 Td -(3578 release\(&bcache.lock\);) 152.898 Tj -0 -303.7875 Td -(3579 return b;) 96.1073 Tj -0 -313.2809 Td -(3580 }) 52.4222 Tj -0 -322.7743 Td -(3581 sleep\(b, &bcache.lock\);) 148.5295 Tj -0 -332.2676 Td -(3582 goto loop;) 91.7388 Tj -0 -341.761 Td -(3583 }) 43.6851 Tj -0 -351.2543 Td -(3584 }) 34.9481 Tj -0 -360.7477 Td -(3585 ) 21.8426 Tj -0 -370.2411 Td -(3586 // Allocate fresh block.) 135.4239 Tj -0 -379.7344 Td -(3587 for\(b = bcache.head.prev; b != &bcache.head; b = b->pre\ -v\){) 283.9534 Tj -0 -389.2278 Td -(3588 if\(\(b->flags & B_BUSY\) == 0\){) 166.0035 Tj -0 -398.7211 Td -(3589 b->dev = dev;) 104.8443 Tj -0 -408.2145 Td -(3590 b->sector = sector;) 131.0554 Tj -0 -417.7079 Td -(3591 b->flags = B_BUSY;) 126.6869 Tj -0 -427.2012 Td -(3592 release\(&bcache.lock\);) 144.161 Tj -0 -436.6946 Td -(3593 return b;) 87.3703 Tj -0 -446.1879 Td -(3594 }) 43.6851 Tj -0 -455.6813 Td -(3595 }) 34.9481 Tj -0 -465.1747 Td -(3596 panic\("bget: no buffers"\);) 144.161 Tj -0 -474.668 Td -(3597 }) 26.2111 Tj -0 -484.1614 Td -(3598 ) 21.8426 Tj -0 -493.6547 Td -(3599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 35) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 43 43 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/bio.c Page 3) 157.2665 Tj -0 -28.4801 Td -(3600 // Return a B_BUSY buf with the contents of the indicated \ -disk sector.) 327.6386 Tj -0 -37.9735 Td -(3601 struct buf*) 69.8962 Tj -0 -47.4668 Td -(3602 bread\(uint dev, uint sector\)) 144.161 Tj -0 -56.9602 Td -(3603 {) 26.2111 Tj -0 -66.4535 Td -(3604 struct buf *b;) 91.7388 Tj -0 -75.9469 Td -(3605 ) 21.8426 Tj -0 -85.4403 Td -(3606 b = bget\(dev, sector\);) 126.6869 Tj -0 -94.9336 Td -(3607 if\(!\(b->flags & B_VALID\)\)) 139.7925 Tj -0 -104.427 Td -(3608 iderw\(b\);) 78.6333 Tj -0 -113.9203 Td -(3609 return b;) 69.8962 Tj -0 -123.4137 Td -(3610 }) 26.2111 Tj -0 -132.9071 Td -(3611 ) 21.8426 Tj -0 -142.4004 Td -(3612 // Write b's contents to disk. Must be locked.) 227.1628 Tj -0 -151.8938 Td -(3613 void) 39.3166 Tj -0 -161.3871 Td -(3614 bwrite\(struct buf *b\)) 113.5814 Tj -0 -170.8805 Td -(3615 {) 26.2111 Tj -0 -180.3739 Td -(3616 if\(\(b->flags & B_BUSY\) == 0\)) 152.898 Tj -0 -189.8672 Td -(3617 panic\("bwrite"\);) 109.2129 Tj -0 -199.3606 Td -(3618 b->flags |= B_DIRTY;) 117.9499 Tj -0 -208.8539 Td -(3619 iderw\(b\);) 69.8962 Tj -0 -218.3473 Td -(3620 }) 26.2111 Tj -0 -227.8407 Td -(3621 ) 21.8426 Tj -0 -237.334 Td -(3622 // Release the buffer b.) 126.6869 Tj -0 -246.8274 Td -(3623 void) 39.3166 Tj -0 -256.3207 Td -(3624 brelse\(struct buf *b\)) 113.5814 Tj -0 -265.8141 Td -(3625 {) 26.2111 Tj -0 -275.3075 Td -(3626 if\(\(b->flags & B_BUSY\) == 0\)) 152.898 Tj -0 -284.8008 Td -(3627 panic\("brelse"\);) 109.2129 Tj -0 -294.2942 Td -(3628 ) 21.8426 Tj -0 -303.7875 Td -(3629 acquire\(&bcache.lock\);) 126.6869 Tj -0 -313.2809 Td -(3630 ) 21.8426 Tj -0 -322.7743 Td -(3631 b->next->prev = b->prev;) 135.4239 Tj -0 -332.2676 Td -(3632 b->prev->next = b->next;) 135.4239 Tj -0 -341.761 Td -(3633 b->next = bcache.head.next;) 148.5295 Tj -0 -351.2543 Td -(3634 b->prev = &bcache.head;) 131.0554 Tj -0 -360.7477 Td -(3635 bcache.head.next->prev = b;) 148.5295 Tj -0 -370.2411 Td -(3636 bcache.head.next = b;) 122.3184 Tj -0 -379.7344 Td -(3637 ) 21.8426 Tj -0 -389.2278 Td -(3638 b->flags &= ~B_BUSY;) 117.9499 Tj -0 -398.7211 Td -(3639 wakeup\(b\);) 74.2647 Tj -0 -408.2145 Td -(3640 ) 21.8426 Tj -0 -417.7079 Td -(3641 release\(&bcache.lock\);) 126.6869 Tj -0 -427.2012 Td -(3642 }) 26.2111 Tj -0 -436.6946 Td -(3643 ) 21.8426 Tj -0 -446.1879 Td -(3644 ) 21.8426 Tj -0 -455.6813 Td -(3645 ) 21.8426 Tj -0 -465.1747 Td -(3646 ) 21.8426 Tj -0 -474.668 Td -(3647 ) 21.8426 Tj -0 -484.1614 Td -(3648 ) 21.8426 Tj -0 -493.6547 Td -(3649 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 36) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 1) 152.898 Tj -0 -28.4801 Td -(3650 // File system implementation. Four layers:) 214.0572 Tj -0 -37.9735 Td -(3651 // + Blocks: allocator for raw disk blocks.) 218.4257 Tj -0 -47.4668 Td -(3652 // + Files: inode allocator, reading, writing, metadata.) 275.2164 Tj -0 -56.9602 Td -(3653 // + Directories: inode with special contents \(list of \ -other inodes!\)) 332.0071 Tj -0 -66.4535 Td -(3654 // + Names: paths like /usr/rtm/xv6/fs.c for convenient \ -naming.) 305.796 Tj -0 -75.9469 Td -(3655 //) 30.5796 Tj -0 -85.4403 Td -(3656 // Disk layout is: superblock, inodes, block in-use bitmap\ -, data blocks.) 336.3756 Tj -0 -94.9336 Td -(3657 //) 30.5796 Tj -0 -104.427 Td -(3658 // This file contains the low-level file system manipulati\ -on) 283.9534 Tj -0 -113.9203 Td -(3659 // routines. The \(higher-level\) system call implementat\ -ions) 283.9534 Tj -0 -123.4137 Td -(3660 // are in sysfile.c.) 109.2129 Tj -0 -132.9071 Td -(3661 ) 21.8426 Tj -0 -142.4004 Td -(3662 #include "types.h") 100.4758 Tj -0 -151.8938 Td -(3663 #include "defs.h") 96.1073 Tj -0 -161.3871 Td -(3664 #include "param.h") 100.4758 Tj -0 -170.8805 Td -(3665 #include "stat.h") 96.1073 Tj -0 -180.3739 Td -(3666 #include "mmu.h") 91.7388 Tj -0 -189.8672 Td -(3667 #include "proc.h") 96.1073 Tj -0 -199.3606 Td -(3668 #include "spinlock.h") 113.5814 Tj -0 -208.8539 Td -(3669 #include "buf.h") 91.7388 Tj -0 -218.3473 Td -(3670 #include "fs.h") 87.3703 Tj -0 -227.8407 Td -(3671 #include "file.h") 96.1073 Tj -0 -237.334 Td -(3672 ) 21.8426 Tj -0 -246.8274 Td -(3673 #define min\(a, b\) \(\(a\) < \(b\) ? \(a\) : \(b\)\)) 200.9517 Tj -0 -256.3207 Td -(3674 static void itrunc\(struct inode*\);) 170.3721 Tj -0 -265.8141 Td -(3675 ) 21.8426 Tj -0 -275.3075 Td -(3676 // Read the super block.) 126.6869 Tj -0 -284.8008 Td -(3677 static void) 69.8962 Tj -0 -294.2942 Td -(3678 readsb\(int dev, struct superblock *sb\)) 187.8461 Tj -0 -303.7875 Td -(3679 {) 26.2111 Tj -0 -313.2809 Td -(3680 struct buf *bp;) 96.1073 Tj -0 -322.7743 Td -(3681 ) 21.8426 Tj -0 -332.2676 Td -(3682 bp = bread\(dev, 1\);) 113.5814 Tj -0 -341.761 Td -(3683 memmove\(sb, bp->data, sizeof\(*sb\)\);) 183.4776 Tj -0 -351.2543 Td -(3684 brelse\(bp\);) 78.6333 Tj -0 -360.7477 Td -(3685 }) 26.2111 Tj -0 -370.2411 Td -(3686 ) 21.8426 Tj -0 -379.7344 Td -(3687 // Zero a block.) 91.7388 Tj -0 -389.2278 Td -(3688 static void) 69.8962 Tj -0 -398.7211 Td -(3689 bzero\(int dev, int bno\)) 122.3184 Tj -0 -408.2145 Td -(3690 {) 26.2111 Tj -0 -417.7079 Td -(3691 struct buf *bp;) 96.1073 Tj -0 -427.2012 Td -(3692 ) 21.8426 Tj -0 -436.6946 Td -(3693 bp = bread\(dev, bno\);) 122.3184 Tj -0 -446.1879 Td -(3694 memset\(bp->data, 0, BSIZE\);) 148.5295 Tj -0 -455.6813 Td -(3695 bwrite\(bp\);) 78.6333 Tj -0 -465.1747 Td -(3696 brelse\(bp\);) 78.6333 Tj -0 -474.668 Td -(3697 }) 26.2111 Tj -0 -484.1614 Td -(3698 ) 21.8426 Tj -0 -493.6547 Td -(3699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 36) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 44 44 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 2) 152.898 Tj -0 -28.4801 Td -(3700 // Blocks.) 65.5277 Tj -0 -37.9735 Td -(3701 ) 21.8426 Tj -0 -47.4668 Td -(3702 // Allocate a disk block.) 131.0554 Tj -0 -56.9602 Td -(3703 static uint) 69.8962 Tj -0 -66.4535 Td -(3704 balloc\(uint dev\)) 91.7388 Tj -0 -75.9469 Td -(3705 {) 26.2111 Tj -0 -85.4403 Td -(3706 int b, bi, m;) 87.3703 Tj -0 -94.9336 Td -(3707 struct buf *bp;) 96.1073 Tj -0 -104.427 Td -(3708 struct superblock sb;) 122.3184 Tj -0 -113.9203 Td -(3709 ) 21.8426 Tj -0 -123.4137 Td -(3710 bp = 0;) 61.1592 Tj -0 -132.9071 Td -(3711 readsb\(dev, &sb\);) 104.8443 Tj -0 -142.4004 Td -(3712 for\(b = 0; b < sb.size; b += BPB\){) 179.1091 Tj -0 -151.8938 Td -(3713 bp = bread\(dev, BBLOCK\(b, sb.ninodes\)\);) 209.6887 Tj -0 -161.3871 Td -(3714 for\(bi = 0; bi < BPB; bi++\){) 161.635 Tj -0 -170.8805 Td -(3715 m = 1 << \(bi % 8\);) 126.6869 Tj -0 -180.3739 Td -(3716 if\(\(bp->data[bi/8] & m\) == 0\){ // Is block free\ -?) 262.1109 Tj -0 -189.8672 Td -(3717 bp->data[bi/8] |= m; // Mark block in use on disk\ -.) 279.5849 Tj -0 -199.3606 Td -(3718 bwrite\(bp\);) 104.8443 Tj -0 -208.8539 Td -(3719 brelse\(bp\);) 104.8443 Tj -0 -218.3473 Td -(3720 return b + bi;) 117.9499 Tj -0 -227.8407 Td -(3721 }) 52.4222 Tj -0 -237.334 Td -(3722 }) 43.6851 Tj -0 -246.8274 Td -(3723 brelse\(bp\);) 87.3703 Tj -0 -256.3207 Td -(3724 }) 34.9481 Tj -0 -265.8141 Td -(3725 panic\("balloc: out of blocks"\);) 166.0035 Tj -0 -275.3075 Td -(3726 }) 26.2111 Tj -0 -284.8008 Td -(3727 ) 21.8426 Tj -0 -294.2942 Td -(3728 // Free a disk block.) 113.5814 Tj -0 -303.7875 Td -(3729 static void) 69.8962 Tj -0 -313.2809 Td -(3730 bfree\(int dev, uint b\)) 117.9499 Tj -0 -322.7743 Td -(3731 {) 26.2111 Tj -0 -332.2676 Td -(3732 struct buf *bp;) 96.1073 Tj -0 -341.761 Td -(3733 struct superblock sb;) 122.3184 Tj -0 -351.2543 Td -(3734 int bi, m;) 74.2647 Tj -0 -360.7477 Td -(3735 ) 21.8426 Tj -0 -370.2411 Td -(3736 bzero\(dev, b\);) 91.7388 Tj -0 -379.7344 Td -(3737 ) 21.8426 Tj -0 -389.2278 Td -(3738 readsb\(dev, &sb\);) 104.8443 Tj -0 -398.7211 Td -(3739 bp = bread\(dev, BBLOCK\(b, sb.ninodes\)\);) 200.9517 Tj -0 -408.2145 Td -(3740 bi = b % BPB;) 87.3703 Tj -0 -417.7079 Td -(3741 m = 1 << \(bi % 8\);) 109.2129 Tj -0 -427.2012 Td -(3742 if\(\(bp->data[bi/8] & m\) == 0\)) 157.2665 Tj -0 -436.6946 Td -(3743 panic\("freeing free block"\);) 161.635 Tj -0 -446.1879 Td -(3744 bp->data[bi/8] &= ~m; // Mark block free on disk.) 249.0053 Tj -0 -455.6813 Td -(3745 bwrite\(bp\);) 78.6333 Tj -0 -465.1747 Td -(3746 brelse\(bp\);) 78.6333 Tj -0 -474.668 Td -(3747 }) 26.2111 Tj -0 -484.1614 Td -(3748 ) 21.8426 Tj -0 -493.6547 Td -(3749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 37) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 3) 152.898 Tj -0 -28.4801 Td -(3750 // Inodes.) 65.5277 Tj -0 -37.9735 Td -(3751 //) 30.5796 Tj -0 -47.4668 Td -(3752 // An inode is a single, unnamed file in the file system.) 270.8479 Tj -0 -56.9602 Td -(3753 // The inode disk structure holds metadata \(the type, dev\ -ice numbers,) 323.2701 Tj -0 -66.4535 Td -(3754 // and data size\) along with a list of blocks where the a\ -ssociated) 310.1645 Tj -0 -75.9469 Td -(3755 // data can be found.) 113.5814 Tj -0 -85.4403 Td -(3756 //) 30.5796 Tj -0 -94.9336 Td -(3757 // The inodes are laid out sequentially on disk immediatel\ -y after) 305.796 Tj -0 -104.427 Td -(3758 // the superblock. The kernel keeps a cache of the in-use) 275.2164 Tj -0 -113.9203 Td -(3759 // on-disk structures to provide a place for synchronizing\ - access) 305.796 Tj -0 -123.4137 Td -(3760 // to inodes shared between multiple processes.) 227.1628 Tj -0 -132.9071 Td -(3761 //) 30.5796 Tj -0 -142.4004 Td -(3762 // ip->ref counts the number of pointer references to this\ - cached) 305.796 Tj -0 -151.8938 Td -(3763 // inode; references are typically kept in struct file and\ - in proc->cwd.) 336.3756 Tj -0 -161.3871 Td -(3764 // When ip->ref falls to zero, the inode is no longer cach\ -ed.) 288.322 Tj -0 -170.8805 Td -(3765 // It is an error to use an inode without holding a refere\ -nce to it.) 318.9016 Tj -0 -180.3739 Td -(3766 //) 30.5796 Tj -0 -189.8672 Td -(3767 // Processes are only allowed to read and write inode) 253.3738 Tj -0 -199.3606 Td -(3768 // metadata and contents when holding the inode's lock,) 262.1109 Tj -0 -208.8539 Td -(3769 // represented by the I_BUSY flag in the in-memory copy.) 266.4794 Tj -0 -218.3473 Td -(3770 // Because inode locks are held during disk accesses,) 253.3738 Tj -0 -227.8407 Td -(3771 // they are implemented using a flag rather than with) 253.3738 Tj -0 -237.334 Td -(3772 // spin locks. Callers are responsible for locking) 244.6368 Tj -0 -246.8274 Td -(3773 // inodes before passing them to routines in this file; le\ -aving) 297.059 Tj -0 -256.3207 Td -(3774 // this responsibility with the caller makes it possible f\ -or them) 305.796 Tj -0 -265.8141 Td -(3775 // to create arbitrarily-sized atomic operations.) 235.8998 Tj -0 -275.3075 Td -(3776 //) 30.5796 Tj -0 -284.8008 Td -(3777 // To give maximum control over locking to the callers,) 262.1109 Tj -0 -294.2942 Td -(3778 // the routines in this file that return inode pointers) 262.1109 Tj -0 -303.7875 Td -(3779 // return pointers to *unlocked* inodes. It is the caller\ -s') 283.9534 Tj -0 -313.2809 Td -(3780 // responsibility to lock them before using them. A non-z\ -ero) 288.322 Tj -0 -322.7743 Td -(3781 // ip->ref keeps these unlocked inodes in the cache.) 249.0053 Tj -0 -332.2676 Td -(3782 ) 21.8426 Tj -0 -341.761 Td -(3783 struct {) 56.7907 Tj -0 -351.2543 Td -(3784 struct spinlock lock;) 122.3184 Tj -0 -360.7477 Td -(3785 struct inode inode[NINODE];) 148.5295 Tj -0 -370.2411 Td -(3786 } icache;) 61.1592 Tj -0 -379.7344 Td -(3787 ) 21.8426 Tj -0 -389.2278 Td -(3788 void) 39.3166 Tj -0 -398.7211 Td -(3789 iinit\(void\)) 69.8962 Tj -0 -408.2145 Td -(3790 {) 26.2111 Tj -0 -417.7079 Td -(3791 initlock\(&icache.lock, "icache"\);) 174.7406 Tj -0 -427.2012 Td -(3792 }) 26.2111 Tj -0 -436.6946 Td -(3793 ) 21.8426 Tj -0 -446.1879 Td -(3794 static struct inode* iget\(uint dev, uint inum\);) 227.1628 Tj -0 -455.6813 Td -(3795 ) 21.8426 Tj -0 -465.1747 Td -(3796 ) 21.8426 Tj -0 -474.668 Td -(3797 ) 21.8426 Tj -0 -484.1614 Td -(3798 ) 21.8426 Tj -0 -493.6547 Td -(3799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 37) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 45 45 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 4) 152.898 Tj -0 -28.4801 Td -(3800 // Allocate a new inode with the given type on device dev.) 275.2164 Tj -0 -37.9735 Td -(3801 struct inode*) 78.6333 Tj -0 -47.4668 Td -(3802 ialloc\(uint dev, short type\)) 144.161 Tj -0 -56.9602 Td -(3803 {) 26.2111 Tj -0 -66.4535 Td -(3804 int inum;) 69.8962 Tj -0 -75.9469 Td -(3805 struct buf *bp;) 96.1073 Tj -0 -85.4403 Td -(3806 struct dinode *dip;) 113.5814 Tj -0 -94.9336 Td -(3807 struct superblock sb;) 122.3184 Tj -0 -104.427 Td -(3808 ) 21.8426 Tj -0 -113.9203 Td -(3809 readsb\(dev, &sb\);) 104.8443 Tj -0 -123.4137 Td -(3810 for\(inum = 1; inum < sb.ninodes; inum++\){ // loop ove\ -r inode blocks) 327.6386 Tj -0 -132.9071 Td -(3811 bp = bread\(dev, IBLOCK\(inum\)\);) 170.3721 Tj -0 -142.4004 Td -(3812 dip = \(struct dinode*\)bp->data + inum%IPB;) 222.7942 Tj -0 -151.8938 Td -(3813 if\(dip->type == 0\){ // a free inode) 196.5831 Tj -0 -161.3871 Td -(3814 memset\(dip, 0, sizeof\(*dip\)\);) 174.7406 Tj -0 -170.8805 Td -(3815 dip->type = type;) 122.3184 Tj -0 -180.3739 Td -(3816 bwrite\(bp\); // mark it allocated on the disk) 249.0053 Tj -0 -189.8672 Td -(3817 brelse\(bp\);) 96.1073 Tj -0 -199.3606 Td -(3818 return iget\(dev, inum\);) 148.5295 Tj -0 -208.8539 Td -(3819 }) 43.6851 Tj -0 -218.3473 Td -(3820 brelse\(bp\);) 87.3703 Tj -0 -227.8407 Td -(3821 }) 34.9481 Tj -0 -237.334 Td -(3822 panic\("ialloc: no inodes"\);) 148.5295 Tj -0 -246.8274 Td -(3823 }) 26.2111 Tj -0 -256.3207 Td -(3824 ) 21.8426 Tj -0 -265.8141 Td -(3825 // Copy inode, which has changed, from memory to disk.) 257.7424 Tj -0 -275.3075 Td -(3826 void) 39.3166 Tj -0 -284.8008 Td -(3827 iupdate\(struct inode *ip\)) 131.0554 Tj -0 -294.2942 Td -(3828 {) 26.2111 Tj -0 -303.7875 Td -(3829 struct buf *bp;) 96.1073 Tj -0 -313.2809 Td -(3830 struct dinode *dip;) 113.5814 Tj -0 -322.7743 Td -(3831 ) 21.8426 Tj -0 -332.2676 Td -(3832 bp = bread\(ip->dev, IBLOCK\(ip->inum\)\);) 196.5831 Tj -0 -341.761 Td -(3833 dip = \(struct dinode*\)bp->data + ip->inum%IPB;) 231.5313 Tj -0 -351.2543 Td -(3834 dip->type = ip->type;) 122.3184 Tj -0 -360.7477 Td -(3835 dip->major = ip->major;) 131.0554 Tj -0 -370.2411 Td -(3836 dip->minor = ip->minor;) 131.0554 Tj -0 -379.7344 Td -(3837 dip->nlink = ip->nlink;) 131.0554 Tj -0 -389.2278 Td -(3838 dip->size = ip->size;) 122.3184 Tj -0 -398.7211 Td -(3839 memmove\(dip->addrs, ip->addrs, sizeof\(ip->addrs\)\);) 249.0053 Tj -0 -408.2145 Td -(3840 bwrite\(bp\);) 78.6333 Tj -0 -417.7079 Td -(3841 brelse\(bp\);) 78.6333 Tj -0 -427.2012 Td -(3842 }) 26.2111 Tj -0 -436.6946 Td -(3843 ) 21.8426 Tj -0 -446.1879 Td -(3844 ) 21.8426 Tj -0 -455.6813 Td -(3845 ) 21.8426 Tj -0 -465.1747 Td -(3846 ) 21.8426 Tj -0 -474.668 Td -(3847 ) 21.8426 Tj -0 -484.1614 Td -(3848 ) 21.8426 Tj -0 -493.6547 Td -(3849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 38) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 5) 152.898 Tj -0 -28.4801 Td -(3850 // Find the inode with number inum on device dev) 231.5313 Tj -0 -37.9735 Td -(3851 // and return the in-memory copy.) 166.0035 Tj -0 -47.4668 Td -(3852 static struct inode*) 109.2129 Tj -0 -56.9602 Td -(3853 iget\(uint dev, uint inum\)) 131.0554 Tj -0 -66.4535 Td -(3854 {) 26.2111 Tj -0 -75.9469 Td -(3855 struct inode *ip, *empty;) 139.7925 Tj -0 -85.4403 Td -(3856 ) 21.8426 Tj -0 -94.9336 Td -(3857 acquire\(&icache.lock\);) 126.6869 Tj -0 -104.427 Td -(3858 ) 21.8426 Tj -0 -113.9203 Td -(3859 // Try for cached inode.) 135.4239 Tj -0 -123.4137 Td -(3860 empty = 0;) 74.2647 Tj -0 -132.9071 Td -(3861 for\(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; \ -ip++\){) 297.059 Tj -0 -142.4004 Td -(3862 if\(ip->ref > 0 && ip->dev == dev && ip->inum == inum\)\ -{) 275.2164 Tj -0 -151.8938 Td -(3863 ip->ref++;) 91.7388 Tj -0 -161.3871 Td -(3864 release\(&icache.lock\);) 144.161 Tj -0 -170.8805 Td -(3865 return ip;) 91.7388 Tj -0 -180.3739 Td -(3866 }) 43.6851 Tj -0 -189.8672 Td -(3867 if\(empty == 0 && ip->ref == 0\) // Remember empty \ -slot.) 288.322 Tj -0 -199.3606 Td -(3868 empty = ip;) 96.1073 Tj -0 -208.8539 Td -(3869 }) 34.9481 Tj -0 -218.3473 Td -(3870 ) 21.8426 Tj -0 -227.8407 Td -(3871 // Allocate fresh inode.) 135.4239 Tj -0 -237.334 Td -(3872 if\(empty == 0\)) 91.7388 Tj -0 -246.8274 Td -(3873 panic\("iget: no inodes"\);) 148.5295 Tj -0 -256.3207 Td -(3874 ) 21.8426 Tj -0 -265.8141 Td -(3875 ip = empty;) 78.6333 Tj -0 -275.3075 Td -(3876 ip->dev = dev;) 91.7388 Tj -0 -284.8008 Td -(3877 ip->inum = inum;) 100.4758 Tj -0 -294.2942 Td -(3878 ip->ref = 1;) 83.0018 Tj -0 -303.7875 Td -(3879 ip->flags = 0;) 91.7388 Tj -0 -313.2809 Td -(3880 release\(&icache.lock\);) 126.6869 Tj -0 -322.7743 Td -(3881 ) 21.8426 Tj -0 -332.2676 Td -(3882 return ip;) 74.2647 Tj -0 -341.761 Td -(3883 }) 26.2111 Tj -0 -351.2543 Td -(3884 ) 21.8426 Tj -0 -360.7477 Td -(3885 // Increment reference count for ip.) 179.1091 Tj -0 -370.2411 Td -(3886 // Returns ip to enable ip = idup\(ip1\) idiom.) 218.4257 Tj -0 -379.7344 Td -(3887 struct inode*) 78.6333 Tj -0 -389.2278 Td -(3888 idup\(struct inode *ip\)) 117.9499 Tj -0 -398.7211 Td -(3889 {) 26.2111 Tj -0 -408.2145 Td -(3890 acquire\(&icache.lock\);) 126.6869 Tj -0 -417.7079 Td -(3891 ip->ref++;) 74.2647 Tj -0 -427.2012 Td -(3892 release\(&icache.lock\);) 126.6869 Tj -0 -436.6946 Td -(3893 return ip;) 74.2647 Tj -0 -446.1879 Td -(3894 }) 26.2111 Tj -0 -455.6813 Td -(3895 ) 21.8426 Tj -0 -465.1747 Td -(3896 ) 21.8426 Tj -0 -474.668 Td -(3897 ) 21.8426 Tj -0 -484.1614 Td -(3898 ) 21.8426 Tj -0 -493.6547 Td -(3899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 38) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 46 46 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 6) 152.898 Tj -0 -28.4801 Td -(3900 // Lock the given inode.) 126.6869 Tj -0 -37.9735 Td -(3901 void) 39.3166 Tj -0 -47.4668 Td -(3902 ilock\(struct inode *ip\)) 122.3184 Tj -0 -56.9602 Td -(3903 {) 26.2111 Tj -0 -66.4535 Td -(3904 struct buf *bp;) 96.1073 Tj -0 -75.9469 Td -(3905 struct dinode *dip;) 113.5814 Tj -0 -85.4403 Td -(3906 ) 21.8426 Tj -0 -94.9336 Td -(3907 if\(ip == 0 || ip->ref < 1\)) 144.161 Tj -0 -104.427 Td -(3908 panic\("ilock"\);) 104.8443 Tj -0 -113.9203 Td -(3909 ) 21.8426 Tj -0 -123.4137 Td -(3910 acquire\(&icache.lock\);) 126.6869 Tj -0 -132.9071 Td -(3911 while\(ip->flags & I_BUSY\)) 139.7925 Tj -0 -142.4004 Td -(3912 sleep\(ip, &icache.lock\);) 144.161 Tj -0 -151.8938 Td -(3913 ip->flags |= I_BUSY;) 117.9499 Tj -0 -161.3871 Td -(3914 release\(&icache.lock\);) 126.6869 Tj -0 -170.8805 Td -(3915 ) 21.8426 Tj -0 -180.3739 Td -(3916 if\(!\(ip->flags & I_VALID\)\){) 148.5295 Tj -0 -189.8672 Td -(3917 bp = bread\(ip->dev, IBLOCK\(ip->inum\)\);) 205.3202 Tj -0 -199.3606 Td -(3918 dip = \(struct dinode*\)bp->data + ip->inum%IPB;) 240.2683 Tj -0 -208.8539 Td -(3919 ip->type = dip->type;) 131.0554 Tj -0 -218.3473 Td -(3920 ip->major = dip->major;) 139.7925 Tj -0 -227.8407 Td -(3921 ip->minor = dip->minor;) 139.7925 Tj -0 -237.334 Td -(3922 ip->nlink = dip->nlink;) 139.7925 Tj -0 -246.8274 Td -(3923 ip->size = dip->size;) 131.0554 Tj -0 -256.3207 Td -(3924 memmove\(ip->addrs, dip->addrs, sizeof\(ip->addrs\)\);) 257.7424 Tj -0 -265.8141 Td -(3925 brelse\(bp\);) 87.3703 Tj -0 -275.3075 Td -(3926 ip->flags |= I_VALID;) 131.0554 Tj -0 -284.8008 Td -(3927 if\(ip->type == 0\)) 113.5814 Tj -0 -294.2942 Td -(3928 panic\("ilock: no type"\);) 152.898 Tj -0 -303.7875 Td -(3929 }) 34.9481 Tj -0 -313.2809 Td -(3930 }) 26.2111 Tj -0 -322.7743 Td -(3931 ) 21.8426 Tj -0 -332.2676 Td -(3932 // Unlock the given inode.) 135.4239 Tj -0 -341.761 Td -(3933 void) 39.3166 Tj -0 -351.2543 Td -(3934 iunlock\(struct inode *ip\)) 131.0554 Tj -0 -360.7477 Td -(3935 {) 26.2111 Tj -0 -370.2411 Td -(3936 if\(ip == 0 || !\(ip->flags & I_BUSY\) || ip->ref < 1\)) 253.3738 Tj -0 -379.7344 Td -(3937 panic\("iunlock"\);) 113.5814 Tj -0 -389.2278 Td -(3938 ) 21.8426 Tj -0 -398.7211 Td -(3939 acquire\(&icache.lock\);) 126.6869 Tj -0 -408.2145 Td -(3940 ip->flags &= ~I_BUSY;) 122.3184 Tj -0 -417.7079 Td -(3941 wakeup\(ip\);) 78.6333 Tj -0 -427.2012 Td -(3942 release\(&icache.lock\);) 126.6869 Tj -0 -436.6946 Td -(3943 }) 26.2111 Tj -0 -446.1879 Td -(3944 ) 21.8426 Tj -0 -455.6813 Td -(3945 ) 21.8426 Tj -0 -465.1747 Td -(3946 ) 21.8426 Tj -0 -474.668 Td -(3947 ) 21.8426 Tj -0 -484.1614 Td -(3948 ) 21.8426 Tj -0 -493.6547 Td -(3949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 39) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 7) 152.898 Tj -0 -28.4801 Td -(3950 // Caller holds reference to unlocked ip. Drop reference.) 275.2164 Tj -0 -37.9735 Td -(3951 void) 39.3166 Tj -0 -47.4668 Td -(3952 iput\(struct inode *ip\)) 117.9499 Tj -0 -56.9602 Td -(3953 {) 26.2111 Tj -0 -66.4535 Td -(3954 acquire\(&icache.lock\);) 126.6869 Tj -0 -75.9469 Td -(3955 if\(ip->ref == 1 && \(ip->flags & I_VALID\) && ip->nlink\ - == 0\){) 292.6905 Tj -0 -85.4403 Td -(3956 // inode is no longer used: truncate and free inode.) 266.4794 Tj -0 -94.9336 Td -(3957 if\(ip->flags & I_BUSY\)) 135.4239 Tj -0 -104.427 Td -(3958 panic\("iput busy"\);) 131.0554 Tj -0 -113.9203 Td -(3959 ip->flags |= I_BUSY;) 126.6869 Tj -0 -123.4137 Td -(3960 release\(&icache.lock\);) 135.4239 Tj -0 -132.9071 Td -(3961 itrunc\(ip\);) 87.3703 Tj -0 -142.4004 Td -(3962 ip->type = 0;) 96.1073 Tj -0 -151.8938 Td -(3963 iupdate\(ip\);) 91.7388 Tj -0 -161.3871 Td -(3964 acquire\(&icache.lock\);) 135.4239 Tj -0 -170.8805 Td -(3965 ip->flags = 0;) 100.4758 Tj -0 -180.3739 Td -(3966 wakeup\(ip\);) 87.3703 Tj -0 -189.8672 Td -(3967 }) 34.9481 Tj -0 -199.3606 Td -(3968 ip->ref--;) 74.2647 Tj -0 -208.8539 Td -(3969 release\(&icache.lock\);) 126.6869 Tj -0 -218.3473 Td -(3970 }) 26.2111 Tj -0 -227.8407 Td -(3971 ) 21.8426 Tj -0 -237.334 Td -(3972 // Common idiom: unlock, then put.) 170.3721 Tj -0 -246.8274 Td -(3973 void) 39.3166 Tj -0 -256.3207 Td -(3974 iunlockput\(struct inode *ip\)) 144.161 Tj -0 -265.8141 Td -(3975 {) 26.2111 Tj -0 -275.3075 Td -(3976 iunlock\(ip\);) 83.0018 Tj -0 -284.8008 Td -(3977 iput\(ip\);) 69.8962 Tj -0 -294.2942 Td -(3978 }) 26.2111 Tj -0 -303.7875 Td -(3979 ) 21.8426 Tj -0 -313.2809 Td -(3980 ) 21.8426 Tj -0 -322.7743 Td -(3981 ) 21.8426 Tj -0 -332.2676 Td -(3982 ) 21.8426 Tj -0 -341.761 Td -(3983 ) 21.8426 Tj -0 -351.2543 Td -(3984 ) 21.8426 Tj -0 -360.7477 Td -(3985 ) 21.8426 Tj -0 -370.2411 Td -(3986 ) 21.8426 Tj -0 -379.7344 Td -(3987 ) 21.8426 Tj -0 -389.2278 Td -(3988 ) 21.8426 Tj -0 -398.7211 Td -(3989 ) 21.8426 Tj -0 -408.2145 Td -(3990 ) 21.8426 Tj -0 -417.7079 Td -(3991 ) 21.8426 Tj -0 -427.2012 Td -(3992 ) 21.8426 Tj -0 -436.6946 Td -(3993 ) 21.8426 Tj -0 -446.1879 Td -(3994 ) 21.8426 Tj -0 -455.6813 Td -(3995 ) 21.8426 Tj -0 -465.1747 Td -(3996 ) 21.8426 Tj -0 -474.668 Td -(3997 ) 21.8426 Tj -0 -484.1614 Td -(3998 ) 21.8426 Tj -0 -493.6547 Td -(3999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 39) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 47 47 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 8) 152.898 Tj -0 -28.4801 Td -(4000 // Inode contents) 96.1073 Tj -0 -37.9735 Td -(4001 //) 30.5796 Tj -0 -47.4668 Td -(4002 // The contents \(data\) associated with each inode is sto\ -red) 279.5849 Tj -0 -56.9602 Td -(4003 // in a sequence of blocks on the disk. The first NDIRECT\ - blocks) 305.796 Tj -0 -66.4535 Td -(4004 // are listed in ip->addrs[]. The next NINDIRECT blocks a\ -re) 283.9534 Tj -0 -75.9469 Td -(4005 // listed in the block ip->addrs[INDIRECT].) 209.6887 Tj -0 -85.4403 Td -(4006 ) 21.8426 Tj -0 -94.9336 Td -(4007 // Return the disk block address of the nth block in inode\ - ip.) 292.6905 Tj -0 -104.427 Td -(4008 // If there is no such block, bmap allocates one.) 235.8998 Tj -0 -113.9203 Td -(4009 static uint) 69.8962 Tj -0 -123.4137 Td -(4010 bmap\(struct inode *ip, uint bn\)) 157.2665 Tj -0 -132.9071 Td -(4011 {) 26.2111 Tj -0 -142.4004 Td -(4012 uint addr, *a;) 91.7388 Tj -0 -151.8938 Td -(4013 struct buf *bp;) 96.1073 Tj -0 -161.3871 Td -(4014 ) 21.8426 Tj -0 -170.8805 Td -(4015 if\(bn < NDIRECT\){) 104.8443 Tj -0 -180.3739 Td -(4016 if\(\(addr = ip->addrs[bn]\) == 0\)) 174.7406 Tj -0 -189.8672 Td -(4017 ip->addrs[bn] = addr = balloc\(ip->dev\);) 218.4257 Tj -0 -199.3606 Td -(4018 return addr;) 91.7388 Tj -0 -208.8539 Td -(4019 }) 34.9481 Tj -0 -218.3473 Td -(4020 bn -= NDIRECT;) 91.7388 Tj -0 -227.8407 Td -(4021 ) 21.8426 Tj -0 -237.334 Td -(4022 if\(bn < NINDIRECT\){) 113.5814 Tj -0 -246.8274 Td -(4023 // Load indirect block, allocating if necessary.) 249.0053 Tj -0 -256.3207 Td -(4024 if\(\(addr = ip->addrs[NDIRECT]\) == 0\)) 196.5831 Tj -0 -265.8141 Td -(4025 ip->addrs[NDIRECT] = addr = balloc\(ip->dev\);) 240.2683 Tj -0 -275.3075 Td -(4026 bp = bread\(ip->dev, addr\);) 152.898 Tj -0 -284.8008 Td -(4027 a = \(uint*\)bp->data;) 126.6869 Tj -0 -294.2942 Td -(4028 if\(\(addr = a[bn]\) == 0\){) 144.161 Tj -0 -303.7875 Td -(4029 a[bn] = addr = balloc\(ip->dev\);) 183.4776 Tj -0 -313.2809 Td -(4030 bwrite\(bp\);) 96.1073 Tj -0 -322.7743 Td -(4031 }) 43.6851 Tj -0 -332.2676 Td -(4032 brelse\(bp\);) 87.3703 Tj -0 -341.761 Td -(4033 return addr;) 91.7388 Tj -0 -351.2543 Td -(4034 }) 34.9481 Tj -0 -360.7477 Td -(4035 ) 21.8426 Tj -0 -370.2411 Td -(4036 panic\("bmap: out of range"\);) 152.898 Tj -0 -379.7344 Td -(4037 }) 26.2111 Tj -0 -389.2278 Td -(4038 ) 21.8426 Tj -0 -398.7211 Td -(4039 ) 21.8426 Tj -0 -408.2145 Td -(4040 ) 21.8426 Tj -0 -417.7079 Td -(4041 ) 21.8426 Tj -0 -427.2012 Td -(4042 ) 21.8426 Tj -0 -436.6946 Td -(4043 ) 21.8426 Tj -0 -446.1879 Td -(4044 ) 21.8426 Tj -0 -455.6813 Td -(4045 ) 21.8426 Tj -0 -465.1747 Td -(4046 ) 21.8426 Tj -0 -474.668 Td -(4047 ) 21.8426 Tj -0 -484.1614 Td -(4048 ) 21.8426 Tj -0 -493.6547 Td -(4049 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 40) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 9) 152.898 Tj -0 -28.4801 Td -(4050 // Truncate inode \(discard contents\).) 183.4776 Tj -0 -37.9735 Td -(4051 // Only called after the last dirent referring) 222.7942 Tj -0 -47.4668 Td -(4052 // to this inode has been erased on disk.) 200.9517 Tj -0 -56.9602 Td -(4053 static void) 69.8962 Tj -0 -66.4535 Td -(4054 itrunc\(struct inode *ip\)) 126.6869 Tj -0 -75.9469 Td -(4055 {) 26.2111 Tj -0 -85.4403 Td -(4056 int i, j;) 69.8962 Tj -0 -94.9336 Td -(4057 struct buf *bp;) 96.1073 Tj -0 -104.427 Td -(4058 uint *a;) 65.5277 Tj -0 -113.9203 Td -(4059 ) 21.8426 Tj -0 -123.4137 Td -(4060 for\(i = 0; i < NDIRECT; i++\){) 157.2665 Tj -0 -132.9071 Td -(4061 if\(ip->addrs[i]\){) 113.5814 Tj -0 -142.4004 Td -(4062 bfree\(ip->dev, ip->addrs[i]\);) 174.7406 Tj -0 -151.8938 Td -(4063 ip->addrs[i] = 0;) 122.3184 Tj -0 -161.3871 Td -(4064 }) 43.6851 Tj -0 -170.8805 Td -(4065 }) 34.9481 Tj -0 -180.3739 Td -(4066 ) 21.8426 Tj -0 -189.8672 Td -(4067 if\(ip->addrs[NDIRECT]\){) 131.0554 Tj -0 -199.3606 Td -(4068 bp = bread\(ip->dev, ip->addrs[NDIRECT]\);) 214.0572 Tj -0 -208.8539 Td -(4069 a = \(uint*\)bp->data;) 126.6869 Tj -0 -218.3473 Td -(4070 for\(j = 0; j < NINDIRECT; j++\){) 174.7406 Tj -0 -227.8407 Td -(4071 if\(a[j]\)) 83.0018 Tj -0 -237.334 Td -(4072 bfree\(ip->dev, a[j]\);) 148.5295 Tj -0 -246.8274 Td -(4073 }) 43.6851 Tj -0 -256.3207 Td -(4074 brelse\(bp\);) 87.3703 Tj -0 -265.8141 Td -(4075 bfree\(ip->dev, ip->addrs[NDIRECT]\);) 192.2146 Tj -0 -275.3075 Td -(4076 ip->addrs[NDIRECT] = 0;) 139.7925 Tj -0 -284.8008 Td -(4077 }) 34.9481 Tj -0 -294.2942 Td -(4078 ) 21.8426 Tj -0 -303.7875 Td -(4079 ip->size = 0;) 87.3703 Tj -0 -313.2809 Td -(4080 iupdate\(ip\);) 83.0018 Tj -0 -322.7743 Td -(4081 }) 26.2111 Tj -0 -332.2676 Td -(4082 ) 21.8426 Tj -0 -341.761 Td -(4083 // Copy stat information from inode.) 179.1091 Tj -0 -351.2543 Td -(4084 void) 39.3166 Tj -0 -360.7477 Td -(4085 stati\(struct inode *ip, struct stat *st\)) 196.5831 Tj -0 -370.2411 Td -(4086 {) 26.2111 Tj -0 -379.7344 Td -(4087 st->dev = ip->dev;) 109.2129 Tj -0 -389.2278 Td -(4088 st->ino = ip->inum;) 113.5814 Tj -0 -398.7211 Td -(4089 st->type = ip->type;) 117.9499 Tj -0 -408.2145 Td -(4090 st->nlink = ip->nlink;) 126.6869 Tj -0 -417.7079 Td -(4091 st->size = ip->size;) 117.9499 Tj -0 -427.2012 Td -(4092 }) 26.2111 Tj -0 -436.6946 Td -(4093 ) 21.8426 Tj -0 -446.1879 Td -(4094 ) 21.8426 Tj -0 -455.6813 Td -(4095 ) 21.8426 Tj -0 -465.1747 Td -(4096 ) 21.8426 Tj -0 -474.668 Td -(4097 ) 21.8426 Tj -0 -484.1614 Td -(4098 ) 21.8426 Tj -0 -493.6547 Td -(4099 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 40) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 48 48 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 10) 157.2665 Tj -0 -28.4801 Td -(4100 // Read data from inode.) 126.6869 Tj -0 -37.9735 Td -(4101 int) 34.9481 Tj -0 -47.4668 Td -(4102 readi\(struct inode *ip, char *dst, uint off, uint n\)) 249.0053 Tj -0 -56.9602 Td -(4103 {) 26.2111 Tj -0 -66.4535 Td -(4104 uint tot, m;) 83.0018 Tj -0 -75.9469 Td -(4105 struct buf *bp;) 96.1073 Tj -0 -85.4403 Td -(4106 ) 21.8426 Tj -0 -94.9336 Td -(4107 if\(ip->type == T_DEV\){) 126.6869 Tj -0 -104.427 Td -(4108 if\(ip->major < 0 || ip->major >= NDEV || !devsw[ip->m\ -ajor].read\)) 318.9016 Tj -0 -113.9203 Td -(4109 return -1;) 91.7388 Tj -0 -123.4137 Td -(4110 return devsw[ip->major].read\(ip, dst, n\);) 218.4257 Tj -0 -132.9071 Td -(4111 }) 34.9481 Tj -0 -142.4004 Td -(4112 ) 21.8426 Tj -0 -151.8938 Td -(4113 if\(off > ip->size || off + n < off\)) 183.4776 Tj -0 -161.3871 Td -(4114 return -1;) 83.0018 Tj -0 -170.8805 Td -(4115 if\(off + n > ip->size\)) 126.6869 Tj -0 -180.3739 Td -(4116 n = ip->size - off;) 122.3184 Tj -0 -189.8672 Td -(4117 ) 21.8426 Tj -0 -199.3606 Td -(4118 for\(tot=0; totdev, bmap\(ip, off/BSIZE\)\);) 218.4257 Tj -0 -218.3473 Td -(4120 m = min\(n - tot, BSIZE - off%BSIZE\);) 196.5831 Tj -0 -227.8407 Td -(4121 memmove\(dst, bp->data + off%BSIZE, m\);) 205.3202 Tj -0 -237.334 Td -(4122 brelse\(bp\);) 87.3703 Tj -0 -246.8274 Td -(4123 }) 34.9481 Tj -0 -256.3207 Td -(4124 return n;) 69.8962 Tj -0 -265.8141 Td -(4125 }) 26.2111 Tj -0 -275.3075 Td -(4126 ) 21.8426 Tj -0 -284.8008 Td -(4127 ) 21.8426 Tj -0 -294.2942 Td -(4128 ) 21.8426 Tj -0 -303.7875 Td -(4129 ) 21.8426 Tj -0 -313.2809 Td -(4130 ) 21.8426 Tj -0 -322.7743 Td -(4131 ) 21.8426 Tj -0 -332.2676 Td -(4132 ) 21.8426 Tj -0 -341.761 Td -(4133 ) 21.8426 Tj -0 -351.2543 Td -(4134 ) 21.8426 Tj -0 -360.7477 Td -(4135 ) 21.8426 Tj -0 -370.2411 Td -(4136 ) 21.8426 Tj -0 -379.7344 Td -(4137 ) 21.8426 Tj -0 -389.2278 Td -(4138 ) 21.8426 Tj -0 -398.7211 Td -(4139 ) 21.8426 Tj -0 -408.2145 Td -(4140 ) 21.8426 Tj -0 -417.7079 Td -(4141 ) 21.8426 Tj -0 -427.2012 Td -(4142 ) 21.8426 Tj -0 -436.6946 Td -(4143 ) 21.8426 Tj -0 -446.1879 Td -(4144 ) 21.8426 Tj -0 -455.6813 Td -(4145 ) 21.8426 Tj -0 -465.1747 Td -(4146 ) 21.8426 Tj -0 -474.668 Td -(4147 ) 21.8426 Tj -0 -484.1614 Td -(4148 ) 21.8426 Tj -0 -493.6547 Td -(4149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 41) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 11) 157.2665 Tj -0 -28.4801 Td -(4150 // Write data to inode.) 122.3184 Tj -0 -37.9735 Td -(4151 int) 34.9481 Tj -0 -47.4668 Td -(4152 writei\(struct inode *ip, char *src, uint off, uint n\)) 253.3738 Tj -0 -56.9602 Td -(4153 {) 26.2111 Tj -0 -66.4535 Td -(4154 uint tot, m;) 83.0018 Tj -0 -75.9469 Td -(4155 struct buf *bp;) 96.1073 Tj -0 -85.4403 Td -(4156 ) 21.8426 Tj -0 -94.9336 Td -(4157 if\(ip->type == T_DEV\){) 126.6869 Tj -0 -104.427 Td -(4158 if\(ip->major < 0 || ip->major >= NDEV || !devsw[ip->m\ -ajor].write\)) 323.2701 Tj -0 -113.9203 Td -(4159 return -1;) 91.7388 Tj -0 -123.4137 Td -(4160 return devsw[ip->major].write\(ip, src, n\);) 222.7942 Tj -0 -132.9071 Td -(4161 }) 34.9481 Tj -0 -142.4004 Td -(4162 ) 21.8426 Tj -0 -151.8938 Td -(4163 if\(off > ip->size || off + n < off\)) 183.4776 Tj -0 -161.3871 Td -(4164 return -1;) 83.0018 Tj -0 -170.8805 Td -(4165 if\(off + n > MAXFILE*BSIZE\)) 148.5295 Tj -0 -180.3739 Td -(4166 n = MAXFILE*BSIZE - off;) 144.161 Tj -0 -189.8672 Td -(4167 ) 21.8426 Tj -0 -199.3606 Td -(4168 for\(tot=0; totdev, bmap\(ip, off/BSIZE\)\);) 218.4257 Tj -0 -218.3473 Td -(4170 m = min\(n - tot, BSIZE - off%BSIZE\);) 196.5831 Tj -0 -227.8407 Td -(4171 memmove\(bp->data + off%BSIZE, src, m\);) 205.3202 Tj -0 -237.334 Td -(4172 bwrite\(bp\);) 87.3703 Tj -0 -246.8274 Td -(4173 brelse\(bp\);) 87.3703 Tj -0 -256.3207 Td -(4174 }) 34.9481 Tj -0 -265.8141 Td -(4175 ) 21.8426 Tj -0 -275.3075 Td -(4176 if\(n > 0 && off > ip->size\){) 152.898 Tj -0 -284.8008 Td -(4177 ip->size = off;) 104.8443 Tj -0 -294.2942 Td -(4178 iupdate\(ip\);) 91.7388 Tj -0 -303.7875 Td -(4179 }) 34.9481 Tj -0 -313.2809 Td -(4180 return n;) 69.8962 Tj -0 -322.7743 Td -(4181 }) 26.2111 Tj -0 -332.2676 Td -(4182 ) 21.8426 Tj -0 -341.761 Td -(4183 ) 21.8426 Tj -0 -351.2543 Td -(4184 ) 21.8426 Tj -0 -360.7477 Td -(4185 ) 21.8426 Tj -0 -370.2411 Td -(4186 ) 21.8426 Tj -0 -379.7344 Td -(4187 ) 21.8426 Tj -0 -389.2278 Td -(4188 ) 21.8426 Tj -0 -398.7211 Td -(4189 ) 21.8426 Tj -0 -408.2145 Td -(4190 ) 21.8426 Tj -0 -417.7079 Td -(4191 ) 21.8426 Tj -0 -427.2012 Td -(4192 ) 21.8426 Tj -0 -436.6946 Td -(4193 ) 21.8426 Tj -0 -446.1879 Td -(4194 ) 21.8426 Tj -0 -455.6813 Td -(4195 ) 21.8426 Tj -0 -465.1747 Td -(4196 ) 21.8426 Tj -0 -474.668 Td -(4197 ) 21.8426 Tj -0 -484.1614 Td -(4198 ) 21.8426 Tj -0 -493.6547 Td -(4199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 41) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 49 49 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 12) 157.2665 Tj -0 -28.4801 Td -(4200 // Directories) 83.0018 Tj -0 -37.9735 Td -(4201 ) 21.8426 Tj -0 -47.4668 Td -(4202 int) 34.9481 Tj -0 -56.9602 Td -(4203 namecmp\(const char *s, const char *t\)) 183.4776 Tj -0 -66.4535 Td -(4204 {) 26.2111 Tj -0 -75.9469 Td -(4205 return strncmp\(s, t, DIRSIZ\);) 157.2665 Tj -0 -85.4403 Td -(4206 }) 26.2111 Tj -0 -94.9336 Td -(4207 ) 21.8426 Tj -0 -104.427 Td -(4208 // Look for a directory entry in a directory.) 218.4257 Tj -0 -113.9203 Td -(4209 // If found, set *poff to byte offset of entry.) 227.1628 Tj -0 -123.4137 Td -(4210 // Caller must have already locked dp.) 187.8461 Tj -0 -132.9071 Td -(4211 struct inode*) 78.6333 Tj -0 -142.4004 Td -(4212 dirlookup\(struct inode *dp, char *name, uint *poff\)) 244.6368 Tj -0 -151.8938 Td -(4213 {) 26.2111 Tj -0 -161.3871 Td -(4214 uint off, inum;) 96.1073 Tj -0 -170.8805 Td -(4215 struct buf *bp;) 96.1073 Tj -0 -180.3739 Td -(4216 struct dirent *de;) 109.2129 Tj -0 -189.8672 Td -(4217 ) 21.8426 Tj -0 -199.3606 Td -(4218 if\(dp->type != T_DIR\)) 122.3184 Tj -0 -208.8539 Td -(4219 panic\("dirlookup not DIR"\);) 157.2665 Tj -0 -218.3473 Td -(4220 ) 21.8426 Tj -0 -227.8407 Td -(4221 for\(off = 0; off < dp->size; off += BSIZE\){) 218.4257 Tj -0 -237.334 Td -(4222 bp = bread\(dp->dev, bmap\(dp, off / BSIZE\)\);) 227.1628 Tj -0 -246.8274 Td -(4223 for\(de = \(struct dirent*\)bp->data;) 187.8461 Tj -0 -256.3207 Td -(4224 de < \(struct dirent*\)\(bp->data + BSIZE\);) 231.5313 Tj -0 -265.8141 Td -(4225 de++\){) 83.0018 Tj -0 -275.3075 Td -(4226 if\(de->inum == 0\)) 122.3184 Tj -0 -284.8008 Td -(4227 continue;) 96.1073 Tj -0 -294.2942 Td -(4228 if\(namecmp\(name, de->name\) == 0\){) 192.2146 Tj -0 -303.7875 Td -(4229 // entry matches path element) 183.4776 Tj -0 -313.2809 Td -(4230 if\(poff\)) 91.7388 Tj -0 -322.7743 Td -(4231 *poff = off + \(uchar*\)de - bp->data;) 222.7942 Tj -0 -332.2676 Td -(4232 inum = de->inum;) 126.6869 Tj -0 -341.761 Td -(4233 brelse\(bp\);) 104.8443 Tj -0 -351.2543 Td -(4234 return iget\(dp->dev, inum\);) 174.7406 Tj -0 -360.7477 Td -(4235 }) 52.4222 Tj -0 -370.2411 Td -(4236 }) 43.6851 Tj -0 -379.7344 Td -(4237 brelse\(bp\);) 87.3703 Tj -0 -389.2278 Td -(4238 }) 34.9481 Tj -0 -398.7211 Td -(4239 return 0;) 69.8962 Tj -0 -408.2145 Td -(4240 }) 26.2111 Tj -0 -417.7079 Td -(4241 ) 21.8426 Tj -0 -427.2012 Td -(4242 ) 21.8426 Tj -0 -436.6946 Td -(4243 ) 21.8426 Tj -0 -446.1879 Td -(4244 ) 21.8426 Tj -0 -455.6813 Td -(4245 ) 21.8426 Tj -0 -465.1747 Td -(4246 ) 21.8426 Tj -0 -474.668 Td -(4247 ) 21.8426 Tj -0 -484.1614 Td -(4248 ) 21.8426 Tj -0 -493.6547 Td -(4249 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 42) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 13) 157.2665 Tj -0 -28.4801 Td -(4250 // Write a new directory entry \(name, inum\) into the dir\ -ectory dp.) 310.1645 Tj -0 -37.9735 Td -(4251 int) 34.9481 Tj -0 -47.4668 Td -(4252 dirlink\(struct inode *dp, char *name, uint inum\)) 231.5313 Tj -0 -56.9602 Td -(4253 {) 26.2111 Tj -0 -66.4535 Td -(4254 int off;) 65.5277 Tj -0 -75.9469 Td -(4255 struct dirent de;) 104.8443 Tj -0 -85.4403 Td -(4256 struct inode *ip;) 104.8443 Tj -0 -94.9336 Td -(4257 ) 21.8426 Tj -0 -104.427 Td -(4258 // Check that name is not present.) 179.1091 Tj -0 -113.9203 Td -(4259 if\(\(ip = dirlookup\(dp, name, 0\)\) != 0\){) 200.9517 Tj -0 -123.4137 Td -(4260 iput\(ip\);) 78.6333 Tj -0 -132.9071 Td -(4261 return -1;) 83.0018 Tj -0 -142.4004 Td -(4262 }) 34.9481 Tj -0 -151.8938 Td -(4263 ) 21.8426 Tj -0 -161.3871 Td -(4264 // Look for an empty dirent.) 152.898 Tj -0 -170.8805 Td -(4265 for\(off = 0; off < dp->size; off += sizeof\(de\)\){) 240.2683 Tj -0 -180.3739 Td -(4266 if\(readi\(dp, \(char*\)&de, off, sizeof\(de\)\) != si\ -zeof\(de\)\)) 283.9534 Tj -0 -189.8672 Td -(4267 panic\("dirlink read"\);) 144.161 Tj -0 -199.3606 Td -(4268 if\(de.inum == 0\)) 109.2129 Tj -0 -208.8539 Td -(4269 break;) 74.2647 Tj -0 -218.3473 Td -(4270 }) 34.9481 Tj -0 -227.8407 Td -(4271 ) 21.8426 Tj -0 -237.334 Td -(4272 strncpy\(de.name, name, DIRSIZ\);) 166.0035 Tj -0 -246.8274 Td -(4273 de.inum = inum;) 96.1073 Tj -0 -256.3207 Td -(4274 if\(writei\(dp, \(char*\)&de, off, sizeof\(de\)\) != siz\ -eof\(de\)\)) 279.5849 Tj -0 -265.8141 Td -(4275 panic\("dirlink"\);) 113.5814 Tj -0 -275.3075 Td -(4276 ) 21.8426 Tj -0 -284.8008 Td -(4277 return 0;) 69.8962 Tj -0 -294.2942 Td -(4278 }) 26.2111 Tj -0 -303.7875 Td -(4279 ) 21.8426 Tj -0 -313.2809 Td -(4280 ) 21.8426 Tj -0 -322.7743 Td -(4281 ) 21.8426 Tj -0 -332.2676 Td -(4282 ) 21.8426 Tj -0 -341.761 Td -(4283 ) 21.8426 Tj -0 -351.2543 Td -(4284 ) 21.8426 Tj -0 -360.7477 Td -(4285 ) 21.8426 Tj -0 -370.2411 Td -(4286 ) 21.8426 Tj -0 -379.7344 Td -(4287 ) 21.8426 Tj -0 -389.2278 Td -(4288 ) 21.8426 Tj -0 -398.7211 Td -(4289 ) 21.8426 Tj -0 -408.2145 Td -(4290 ) 21.8426 Tj -0 -417.7079 Td -(4291 ) 21.8426 Tj -0 -427.2012 Td -(4292 ) 21.8426 Tj -0 -436.6946 Td -(4293 ) 21.8426 Tj -0 -446.1879 Td -(4294 ) 21.8426 Tj -0 -455.6813 Td -(4295 ) 21.8426 Tj -0 -465.1747 Td -(4296 ) 21.8426 Tj -0 -474.668 Td -(4297 ) 21.8426 Tj -0 -484.1614 Td -(4298 ) 21.8426 Tj -0 -493.6547 Td -(4299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 42) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 50 50 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 14) 157.2665 Tj -0 -28.4801 Td -(4300 // Paths) 56.7907 Tj -0 -37.9735 Td -(4301 ) 21.8426 Tj -0 -47.4668 Td -(4302 // Copy the next path element from path into name.) 240.2683 Tj -0 -56.9602 Td -(4303 // Return a pointer to the element following the copied on\ -e.) 283.9534 Tj -0 -66.4535 Td -(4304 // The returned path has no leading slashes,) 214.0572 Tj -0 -75.9469 Td -(4305 // so the caller can check *path=='\\0' to see if the name\ - is the last one.) 345.1126 Tj -0 -85.4403 Td -(4306 // If no name to remove, return 0.) 170.3721 Tj -0 -94.9336 Td -(4307 //) 30.5796 Tj -0 -104.427 Td -(4308 // Examples:) 74.2647 Tj -0 -113.9203 Td -(4309 // skipelem\("a/bb/c", name\) = "bb/c", setting name = "\ -a") 275.2164 Tj -0 -123.4137 Td -(4310 // skipelem\("///a//bb", name\) = "bb", setting name = "\ -a") 275.2164 Tj -0 -132.9071 Td -(4311 // skipelem\("a", name\) = "", setting name = "a") 235.8998 Tj -0 -142.4004 Td -(4312 // skipelem\("", name\) = skipelem\("////", name\) = 0) 249.0053 Tj -0 -151.8938 Td -(4313 //) 30.5796 Tj -0 -161.3871 Td -(4314 static char*) 74.2647 Tj -0 -170.8805 Td -(4315 skipelem\(char *path, char *name\)) 161.635 Tj -0 -180.3739 Td -(4316 {) 26.2111 Tj -0 -189.8672 Td -(4317 char *s;) 65.5277 Tj -0 -199.3606 Td -(4318 int len;) 65.5277 Tj -0 -208.8539 Td -(4319 ) 21.8426 Tj -0 -218.3473 Td -(4320 while\(*path == '/'\)) 113.5814 Tj -0 -227.8407 Td -(4321 path++;) 69.8962 Tj -0 -237.334 Td -(4322 if\(*path == 0\)) 91.7388 Tj -0 -246.8274 Td -(4323 return 0;) 78.6333 Tj -0 -256.3207 Td -(4324 s = path;) 69.8962 Tj -0 -265.8141 Td -(4325 while\(*path != '/' && *path != 0\)) 174.7406 Tj -0 -275.3075 Td -(4326 path++;) 69.8962 Tj -0 -284.8008 Td -(4327 len = path - s;) 96.1073 Tj -0 -294.2942 Td -(4328 if\(len >= DIRSIZ\)) 104.8443 Tj -0 -303.7875 Td -(4329 memmove\(name, s, DIRSIZ\);) 148.5295 Tj -0 -313.2809 Td -(4330 else {) 56.7907 Tj -0 -322.7743 Td -(4331 memmove\(name, s, len\);) 135.4239 Tj -0 -332.2676 Td -(4332 name[len] = 0;) 100.4758 Tj -0 -341.761 Td -(4333 }) 34.9481 Tj -0 -351.2543 Td -(4334 while\(*path == '/'\)) 113.5814 Tj -0 -360.7477 Td -(4335 path++;) 69.8962 Tj -0 -370.2411 Td -(4336 return path;) 83.0018 Tj -0 -379.7344 Td -(4337 }) 26.2111 Tj -0 -389.2278 Td -(4338 ) 21.8426 Tj -0 -398.7211 Td -(4339 ) 21.8426 Tj -0 -408.2145 Td -(4340 ) 21.8426 Tj -0 -417.7079 Td -(4341 ) 21.8426 Tj -0 -427.2012 Td -(4342 ) 21.8426 Tj -0 -436.6946 Td -(4343 ) 21.8426 Tj -0 -446.1879 Td -(4344 ) 21.8426 Tj -0 -455.6813 Td -(4345 ) 21.8426 Tj -0 -465.1747 Td -(4346 ) 21.8426 Tj -0 -474.668 Td -(4347 ) 21.8426 Tj -0 -484.1614 Td -(4348 ) 21.8426 Tj -0 -493.6547 Td -(4349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 43) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/fs.c Page 15) 157.2665 Tj -0 -28.4801 Td -(4350 // Look up and return the inode for a path name.) 231.5313 Tj -0 -37.9735 Td -(4351 // If parent != 0, return the inode for the parent and cop\ -y the final) 323.2701 Tj -0 -47.4668 Td -(4352 // path element into name, which must have room for DIRSIZ\ - bytes.) 305.796 Tj -0 -56.9602 Td -(4353 static struct inode*) 109.2129 Tj -0 -66.4535 Td -(4354 namex\(char *path, int nameiparent, char *name\)) 222.7942 Tj -0 -75.9469 Td -(4355 {) 26.2111 Tj -0 -85.4403 Td -(4356 struct inode *ip, *next;) 135.4239 Tj -0 -94.9336 Td -(4357 ) 21.8426 Tj -0 -104.427 Td -(4358 if\(*path == '/'\)) 100.4758 Tj -0 -113.9203 Td -(4359 ip = iget\(ROOTDEV, ROOTINO\);) 161.635 Tj -0 -123.4137 Td -(4360 else) 48.0537 Tj -0 -132.9071 Td -(4361 ip = idup\(proc->cwd\);) 131.0554 Tj -0 -142.4004 Td -(4362 ) 21.8426 Tj -0 -151.8938 Td -(4363 while\(\(path = skipelem\(path, name\)\) != 0\){) 214.0572 Tj -0 -161.3871 Td -(4364 ilock\(ip\);) 83.0018 Tj -0 -170.8805 Td -(4365 if\(ip->type != T_DIR\){) 135.4239 Tj -0 -180.3739 Td -(4366 iunlockput\(ip\);) 113.5814 Tj -0 -189.8672 Td -(4367 return 0;) 87.3703 Tj -0 -199.3606 Td -(4368 }) 43.6851 Tj -0 -208.8539 Td -(4369 if\(nameiparent && *path == '\\0'\){) 183.4776 Tj -0 -218.3473 Td -(4370 // Stop one level early.) 152.898 Tj -0 -227.8407 Td -(4371 iunlock\(ip\);) 100.4758 Tj -0 -237.334 Td -(4372 return ip;) 91.7388 Tj -0 -246.8274 Td -(4373 }) 43.6851 Tj -0 -256.3207 Td -(4374 if\(\(next = dirlookup\(ip, name, 0\)\) == 0\){) 218.4257 Tj -0 -265.8141 Td -(4375 iunlockput\(ip\);) 113.5814 Tj -0 -275.3075 Td -(4376 return 0;) 87.3703 Tj -0 -284.8008 Td -(4377 }) 43.6851 Tj -0 -294.2942 Td -(4378 iunlockput\(ip\);) 104.8443 Tj -0 -303.7875 Td -(4379 ip = next;) 83.0018 Tj -0 -313.2809 Td -(4380 }) 34.9481 Tj -0 -322.7743 Td -(4381 if\(nameiparent\){) 100.4758 Tj -0 -332.2676 Td -(4382 iput\(ip\);) 78.6333 Tj -0 -341.761 Td -(4383 return 0;) 78.6333 Tj -0 -351.2543 Td -(4384 }) 34.9481 Tj -0 -360.7477 Td -(4385 return ip;) 74.2647 Tj -0 -370.2411 Td -(4386 }) 26.2111 Tj -0 -379.7344 Td -(4387 ) 21.8426 Tj -0 -389.2278 Td -(4388 struct inode*) 78.6333 Tj -0 -398.7211 Td -(4389 namei\(char *path\)) 96.1073 Tj -0 -408.2145 Td -(4390 {) 26.2111 Tj -0 -417.7079 Td -(4391 char name[DIRSIZ];) 109.2129 Tj -0 -427.2012 Td -(4392 return namex\(path, 0, name\);) 152.898 Tj -0 -436.6946 Td -(4393 }) 26.2111 Tj -0 -446.1879 Td -(4394 ) 21.8426 Tj -0 -455.6813 Td -(4395 struct inode*) 78.6333 Tj -0 -465.1747 Td -(4396 nameiparent\(char *path, char *name\)) 174.7406 Tj -0 -474.668 Td -(4397 {) 26.2111 Tj -0 -484.1614 Td -(4398 return namex\(path, 1, name\);) 152.898 Tj -0 -493.6547 Td -(4399 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 43) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 51 51 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/file.c Page 1) 161.635 Tj -0 -28.4801 Td -(4400 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(4401 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(4402 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(4403 #include "fs.h") 87.3703 Tj -0 -66.4535 Td -(4404 #include "file.h") 96.1073 Tj -0 -75.9469 Td -(4405 #include "spinlock.h") 113.5814 Tj -0 -85.4403 Td -(4406 ) 21.8426 Tj -0 -94.9336 Td -(4407 struct devsw devsw[NDEV];) 131.0554 Tj -0 -104.427 Td -(4408 struct {) 56.7907 Tj -0 -113.9203 Td -(4409 struct spinlock lock;) 122.3184 Tj -0 -123.4137 Td -(4410 struct file file[NFILE];) 135.4239 Tj -0 -132.9071 Td -(4411 } ftable;) 61.1592 Tj -0 -142.4004 Td -(4412 ) 21.8426 Tj -0 -151.8938 Td -(4413 void) 39.3166 Tj -0 -161.3871 Td -(4414 fileinit\(void\)) 83.0018 Tj -0 -170.8805 Td -(4415 {) 26.2111 Tj -0 -180.3739 Td -(4416 initlock\(&ftable.lock, "ftable"\);) 174.7406 Tj -0 -189.8672 Td -(4417 }) 26.2111 Tj -0 -199.3606 Td -(4418 ) 21.8426 Tj -0 -208.8539 Td -(4419 // Allocate a file structure.) 148.5295 Tj -0 -218.3473 Td -(4420 struct file*) 74.2647 Tj -0 -227.8407 Td -(4421 filealloc\(void\)) 87.3703 Tj -0 -237.334 Td -(4422 {) 26.2111 Tj -0 -246.8274 Td -(4423 struct file *f;) 96.1073 Tj -0 -256.3207 Td -(4424 ) 21.8426 Tj -0 -265.8141 Td -(4425 acquire\(&ftable.lock\);) 126.6869 Tj -0 -275.3075 Td -(4426 for\(f = ftable.file; f < ftable.file + NFILE; f++\){) 253.3738 Tj -0 -284.8008 Td -(4427 if\(f->ref == 0\){) 109.2129 Tj -0 -294.2942 Td -(4428 f->ref = 1;) 96.1073 Tj -0 -303.7875 Td -(4429 release\(&ftable.lock\);) 144.161 Tj -0 -313.2809 Td -(4430 return f;) 87.3703 Tj -0 -322.7743 Td -(4431 }) 43.6851 Tj -0 -332.2676 Td -(4432 }) 34.9481 Tj -0 -341.761 Td -(4433 release\(&ftable.lock\);) 126.6869 Tj -0 -351.2543 Td -(4434 return 0;) 69.8962 Tj -0 -360.7477 Td -(4435 }) 26.2111 Tj -0 -370.2411 Td -(4436 ) 21.8426 Tj -0 -379.7344 Td -(4437 // Increment ref count for file f.) 170.3721 Tj -0 -389.2278 Td -(4438 struct file*) 74.2647 Tj -0 -398.7211 Td -(4439 filedup\(struct file *f\)) 122.3184 Tj -0 -408.2145 Td -(4440 {) 26.2111 Tj -0 -417.7079 Td -(4441 acquire\(&ftable.lock\);) 126.6869 Tj -0 -427.2012 Td -(4442 if\(f->ref < 1\)) 91.7388 Tj -0 -436.6946 Td -(4443 panic\("filedup"\);) 113.5814 Tj -0 -446.1879 Td -(4444 f->ref++;) 69.8962 Tj -0 -455.6813 Td -(4445 release\(&ftable.lock\);) 126.6869 Tj -0 -465.1747 Td -(4446 return f;) 69.8962 Tj -0 -474.668 Td -(4447 }) 26.2111 Tj -0 -484.1614 Td -(4448 ) 21.8426 Tj -0 -493.6547 Td -(4449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 44) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/file.c Page 2) 161.635 Tj -0 -28.4801 Td -(4450 // Close file f. \(Decrement ref count, close when reache\ -s 0.\)) 292.6905 Tj -0 -37.9735 Td -(4451 void) 39.3166 Tj -0 -47.4668 Td -(4452 fileclose\(struct file *f\)) 131.0554 Tj -0 -56.9602 Td -(4453 {) 26.2111 Tj -0 -66.4535 Td -(4454 struct file ff;) 96.1073 Tj -0 -75.9469 Td -(4455 ) 21.8426 Tj -0 -85.4403 Td -(4456 acquire\(&ftable.lock\);) 126.6869 Tj -0 -94.9336 Td -(4457 if\(f->ref < 1\)) 91.7388 Tj -0 -104.427 Td -(4458 panic\("fileclose"\);) 122.3184 Tj -0 -113.9203 Td -(4459 if\(--f->ref > 0\){) 104.8443 Tj -0 -123.4137 Td -(4460 release\(&ftable.lock\);) 135.4239 Tj -0 -132.9071 Td -(4461 return;) 69.8962 Tj -0 -142.4004 Td -(4462 }) 34.9481 Tj -0 -151.8938 Td -(4463 ff = *f;) 65.5277 Tj -0 -161.3871 Td -(4464 f->ref = 0;) 78.6333 Tj -0 -170.8805 Td -(4465 f->type = FD_NONE;) 109.2129 Tj -0 -180.3739 Td -(4466 release\(&ftable.lock\);) 126.6869 Tj -0 -189.8672 Td -(4467 ) 21.8426 Tj -0 -199.3606 Td -(4468 if\(ff.type == FD_PIPE\)) 126.6869 Tj -0 -208.8539 Td -(4469 pipeclose\(ff.pipe, ff.writable\);) 179.1091 Tj -0 -218.3473 Td -(4470 else if\(ff.type == FD_INODE\)) 152.898 Tj -0 -227.8407 Td -(4471 iput\(ff.ip\);) 91.7388 Tj -0 -237.334 Td -(4472 }) 26.2111 Tj -0 -246.8274 Td -(4473 ) 21.8426 Tj -0 -256.3207 Td -(4474 // Get metadata about file f.) 148.5295 Tj -0 -265.8141 Td -(4475 int) 34.9481 Tj -0 -275.3075 Td -(4476 filestat\(struct file *f, struct stat *st\)) 200.9517 Tj -0 -284.8008 Td -(4477 {) 26.2111 Tj -0 -294.2942 Td -(4478 if\(f->type == FD_INODE\){) 135.4239 Tj -0 -303.7875 Td -(4479 ilock\(f->ip\);) 96.1073 Tj -0 -313.2809 Td -(4480 stati\(f->ip, st\);) 113.5814 Tj -0 -322.7743 Td -(4481 iunlock\(f->ip\);) 104.8443 Tj -0 -332.2676 Td -(4482 return 0;) 78.6333 Tj -0 -341.761 Td -(4483 }) 34.9481 Tj -0 -351.2543 Td -(4484 return -1;) 74.2647 Tj -0 -360.7477 Td -(4485 }) 26.2111 Tj -0 -370.2411 Td -(4486 ) 21.8426 Tj -0 -379.7344 Td -(4487 ) 21.8426 Tj -0 -389.2278 Td -(4488 ) 21.8426 Tj -0 -398.7211 Td -(4489 ) 21.8426 Tj -0 -408.2145 Td -(4490 ) 21.8426 Tj -0 -417.7079 Td -(4491 ) 21.8426 Tj -0 -427.2012 Td -(4492 ) 21.8426 Tj -0 -436.6946 Td -(4493 ) 21.8426 Tj -0 -446.1879 Td -(4494 ) 21.8426 Tj -0 -455.6813 Td -(4495 ) 21.8426 Tj -0 -465.1747 Td -(4496 ) 21.8426 Tj -0 -474.668 Td -(4497 ) 21.8426 Tj -0 -484.1614 Td -(4498 ) 21.8426 Tj -0 -493.6547 Td -(4499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 44) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 52 52 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/file.c Page 3) 161.635 Tj -0 -28.4801 Td -(4500 // Read from file f. Addr is kernel address.) 218.4257 Tj -0 -37.9735 Td -(4501 int) 34.9481 Tj -0 -47.4668 Td -(4502 fileread\(struct file *f, char *addr, int n\)) 209.6887 Tj -0 -56.9602 Td -(4503 {) 26.2111 Tj -0 -66.4535 Td -(4504 int r;) 56.7907 Tj -0 -75.9469 Td -(4505 ) 21.8426 Tj -0 -85.4403 Td -(4506 if\(f->readable == 0\)) 117.9499 Tj -0 -94.9336 Td -(4507 return -1;) 83.0018 Tj -0 -104.427 Td -(4508 if\(f->type == FD_PIPE\)) 126.6869 Tj -0 -113.9203 Td -(4509 return piperead\(f->pipe, addr, n\);) 187.8461 Tj -0 -123.4137 Td -(4510 if\(f->type == FD_INODE\){) 135.4239 Tj -0 -132.9071 Td -(4511 ilock\(f->ip\);) 96.1073 Tj -0 -142.4004 Td -(4512 if\(\(r = readi\(f->ip, addr, f->off, n\)\) > 0\)) 227.1628 Tj -0 -151.8938 Td -(4513 f->off += r;) 100.4758 Tj -0 -161.3871 Td -(4514 iunlock\(f->ip\);) 104.8443 Tj -0 -170.8805 Td -(4515 return r;) 78.6333 Tj -0 -180.3739 Td -(4516 }) 34.9481 Tj -0 -189.8672 Td -(4517 panic\("fileread"\);) 109.2129 Tj -0 -199.3606 Td -(4518 }) 26.2111 Tj -0 -208.8539 Td -(4519 ) 21.8426 Tj -0 -218.3473 Td -(4520 // Write to file f. Addr is kernel address.) 214.0572 Tj -0 -227.8407 Td -(4521 int) 34.9481 Tj -0 -237.334 Td -(4522 filewrite\(struct file *f, char *addr, int n\)) 214.0572 Tj -0 -246.8274 Td -(4523 {) 26.2111 Tj -0 -256.3207 Td -(4524 int r;) 56.7907 Tj -0 -265.8141 Td -(4525 ) 21.8426 Tj -0 -275.3075 Td -(4526 if\(f->writable == 0\)) 117.9499 Tj -0 -284.8008 Td -(4527 return -1;) 83.0018 Tj -0 -294.2942 Td -(4528 if\(f->type == FD_PIPE\)) 126.6869 Tj -0 -303.7875 Td -(4529 return pipewrite\(f->pipe, addr, n\);) 192.2146 Tj -0 -313.2809 Td -(4530 if\(f->type == FD_INODE\){) 135.4239 Tj -0 -322.7743 Td -(4531 ilock\(f->ip\);) 96.1073 Tj -0 -332.2676 Td -(4532 if\(\(r = writei\(f->ip, addr, f->off, n\)\) > 0\)) 231.5313 Tj -0 -341.761 Td -(4533 f->off += r;) 100.4758 Tj -0 -351.2543 Td -(4534 iunlock\(f->ip\);) 104.8443 Tj -0 -360.7477 Td -(4535 return r;) 78.6333 Tj -0 -370.2411 Td -(4536 }) 34.9481 Tj -0 -379.7344 Td -(4537 panic\("filewrite"\);) 113.5814 Tj -0 -389.2278 Td -(4538 }) 26.2111 Tj -0 -398.7211 Td -(4539 ) 21.8426 Tj -0 -408.2145 Td -(4540 ) 21.8426 Tj -0 -417.7079 Td -(4541 ) 21.8426 Tj -0 -427.2012 Td -(4542 ) 21.8426 Tj -0 -436.6946 Td -(4543 ) 21.8426 Tj -0 -446.1879 Td -(4544 ) 21.8426 Tj -0 -455.6813 Td -(4545 ) 21.8426 Tj -0 -465.1747 Td -(4546 ) 21.8426 Tj -0 -474.668 Td -(4547 ) 21.8426 Tj -0 -484.1614 Td -(4548 ) 21.8426 Tj -0 -493.6547 Td -(4549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 45) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 1) 174.7406 Tj -0 -28.4801 Td -(4550 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(4551 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(4552 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(4553 #include "stat.h") 96.1073 Tj -0 -66.4535 Td -(4554 #include "mmu.h") 91.7388 Tj -0 -75.9469 Td -(4555 #include "proc.h") 96.1073 Tj -0 -85.4403 Td -(4556 #include "fs.h") 87.3703 Tj -0 -94.9336 Td -(4557 #include "file.h") 96.1073 Tj -0 -104.427 Td -(4558 #include "fcntl.h") 100.4758 Tj -0 -113.9203 Td -(4559 ) 21.8426 Tj -0 -123.4137 Td -(4560 // Fetch the nth word-sized system call argument as a file\ - descriptor) 323.2701 Tj -0 -132.9071 Td -(4561 // and return both the descriptor and the corresponding st\ -ruct file.) 318.9016 Tj -0 -142.4004 Td -(4562 static int) 65.5277 Tj -0 -151.8938 Td -(4563 argfd\(int n, int *pfd, struct file **pf\)) 196.5831 Tj -0 -161.3871 Td -(4564 {) 26.2111 Tj -0 -170.8805 Td -(4565 int fd;) 61.1592 Tj -0 -180.3739 Td -(4566 struct file *f;) 96.1073 Tj -0 -189.8672 Td -(4567 ) 21.8426 Tj -0 -199.3606 Td -(4568 if\(argint\(n, &fd\) < 0\)) 126.6869 Tj -0 -208.8539 Td -(4569 return -1;) 83.0018 Tj -0 -218.3473 Td -(4570 if\(fd < 0 || fd >= NOFILE || \(f=proc->ofile[fd]\) == 0\ -\)) 266.4794 Tj -0 -227.8407 Td -(4571 return -1;) 83.0018 Tj -0 -237.334 Td -(4572 if\(pfd\)) 61.1592 Tj -0 -246.8274 Td -(4573 *pfd = fd;) 83.0018 Tj -0 -256.3207 Td -(4574 if\(pf\)) 56.7907 Tj -0 -265.8141 Td -(4575 *pf = f;) 74.2647 Tj -0 -275.3075 Td -(4576 return 0;) 69.8962 Tj -0 -284.8008 Td -(4577 }) 26.2111 Tj -0 -294.2942 Td -(4578 ) 21.8426 Tj -0 -303.7875 Td -(4579 // Allocate a file descriptor for the given file.) 235.8998 Tj -0 -313.2809 Td -(4580 // Takes over file reference from caller on success.) 249.0053 Tj -0 -322.7743 Td -(4581 static int) 65.5277 Tj -0 -332.2676 Td -(4582 fdalloc\(struct file *f\)) 122.3184 Tj -0 -341.761 Td -(4583 {) 26.2111 Tj -0 -351.2543 Td -(4584 int fd;) 61.1592 Tj -0 -360.7477 Td -(4585 ) 21.8426 Tj -0 -370.2411 Td -(4586 for\(fd = 0; fd < NOFILE; fd++\){) 166.0035 Tj -0 -379.7344 Td -(4587 if\(proc->ofile[fd] == 0\){) 148.5295 Tj -0 -389.2278 Td -(4588 proc->ofile[fd] = f;) 135.4239 Tj -0 -398.7211 Td -(4589 return fd;) 91.7388 Tj -0 -408.2145 Td -(4590 }) 43.6851 Tj -0 -417.7079 Td -(4591 }) 34.9481 Tj -0 -427.2012 Td -(4592 return -1;) 74.2647 Tj -0 -436.6946 Td -(4593 }) 26.2111 Tj -0 -446.1879 Td -(4594 ) 21.8426 Tj -0 -455.6813 Td -(4595 ) 21.8426 Tj -0 -465.1747 Td -(4596 ) 21.8426 Tj -0 -474.668 Td -(4597 ) 21.8426 Tj -0 -484.1614 Td -(4598 ) 21.8426 Tj -0 -493.6547 Td -(4599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 45) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 53 53 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 2) 174.7406 Tj -0 -28.4801 Td -(4600 int) 34.9481 Tj -0 -37.9735 Td -(4601 sys_dup\(void\)) 78.6333 Tj -0 -47.4668 Td -(4602 {) 26.2111 Tj -0 -56.9602 Td -(4603 struct file *f;) 96.1073 Tj -0 -66.4535 Td -(4604 int fd;) 61.1592 Tj -0 -75.9469 Td -(4605 ) 21.8426 Tj -0 -85.4403 Td -(4606 if\(argfd\(0, 0, &f\) < 0\)) 131.0554 Tj -0 -94.9336 Td -(4607 return -1;) 83.0018 Tj -0 -104.427 Td -(4608 if\(\(fd=fdalloc\(f\)\) < 0\)) 131.0554 Tj -0 -113.9203 Td -(4609 return -1;) 83.0018 Tj -0 -123.4137 Td -(4610 filedup\(f\);) 78.6333 Tj -0 -132.9071 Td -(4611 return fd;) 74.2647 Tj -0 -142.4004 Td -(4612 }) 26.2111 Tj -0 -151.8938 Td -(4613 ) 21.8426 Tj -0 -161.3871 Td -(4614 int) 34.9481 Tj -0 -170.8805 Td -(4615 sys_read\(void\)) 83.0018 Tj -0 -180.3739 Td -(4616 {) 26.2111 Tj -0 -189.8672 Td -(4617 struct file *f;) 96.1073 Tj -0 -199.3606 Td -(4618 int n;) 56.7907 Tj -0 -208.8539 Td -(4619 char *p;) 65.5277 Tj -0 -218.3473 Td -(4620 ) 21.8426 Tj -0 -227.8407 Td -(4621 if\(argfd\(0, 0, &f\) < 0 || argint\(2, &n\) < 0 || argp\ -tr\(1, &p, n\) < 0\)) 327.6386 Tj -0 -237.334 Td -(4622 return -1;) 83.0018 Tj -0 -246.8274 Td -(4623 return fileread\(f, p, n\);) 139.7925 Tj -0 -256.3207 Td -(4624 }) 26.2111 Tj -0 -265.8141 Td -(4625 ) 21.8426 Tj -0 -275.3075 Td -(4626 int) 34.9481 Tj -0 -284.8008 Td -(4627 sys_write\(void\)) 87.3703 Tj -0 -294.2942 Td -(4628 {) 26.2111 Tj -0 -303.7875 Td -(4629 struct file *f;) 96.1073 Tj -0 -313.2809 Td -(4630 int n;) 56.7907 Tj -0 -322.7743 Td -(4631 char *p;) 65.5277 Tj -0 -332.2676 Td -(4632 ) 21.8426 Tj -0 -341.761 Td -(4633 if\(argfd\(0, 0, &f\) < 0 || argint\(2, &n\) < 0 || argp\ -tr\(1, &p, n\) < 0\)) 327.6386 Tj -0 -351.2543 Td -(4634 return -1;) 83.0018 Tj -0 -360.7477 Td -(4635 return filewrite\(f, p, n\);) 144.161 Tj -0 -370.2411 Td -(4636 }) 26.2111 Tj -0 -379.7344 Td -(4637 ) 21.8426 Tj -0 -389.2278 Td -(4638 int) 34.9481 Tj -0 -398.7211 Td -(4639 sys_close\(void\)) 87.3703 Tj -0 -408.2145 Td -(4640 {) 26.2111 Tj -0 -417.7079 Td -(4641 int fd;) 61.1592 Tj -0 -427.2012 Td -(4642 struct file *f;) 96.1073 Tj -0 -436.6946 Td -(4643 ) 21.8426 Tj -0 -446.1879 Td -(4644 if\(argfd\(0, &fd, &f\) < 0\)) 139.7925 Tj -0 -455.6813 Td -(4645 return -1;) 83.0018 Tj -0 -465.1747 Td -(4646 proc->ofile[fd] = 0;) 117.9499 Tj -0 -474.668 Td -(4647 fileclose\(f\);) 87.3703 Tj -0 -484.1614 Td -(4648 return 0;) 69.8962 Tj -0 -493.6547 Td -(4649 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 46) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 3) 174.7406 Tj -0 -28.4801 Td -(4650 int) 34.9481 Tj -0 -37.9735 Td -(4651 sys_fstat\(void\)) 87.3703 Tj -0 -47.4668 Td -(4652 {) 26.2111 Tj -0 -56.9602 Td -(4653 struct file *f;) 96.1073 Tj -0 -66.4535 Td -(4654 struct stat *st;) 100.4758 Tj -0 -75.9469 Td -(4655 ) 21.8426 Tj -0 -85.4403 Td -(4656 if\(argfd\(0, 0, &f\) < 0 || argptr\(1, \(void*\)&st, si\ -zeof\(*st\)\) < 0\)) 314.533 Tj -0 -94.9336 Td -(4657 return -1;) 83.0018 Tj -0 -104.427 Td -(4658 return filestat\(f, st\);) 131.0554 Tj -0 -113.9203 Td -(4659 }) 26.2111 Tj -0 -123.4137 Td -(4660 ) 21.8426 Tj -0 -132.9071 Td -(4661 // Create the path new as a link to the same inode as old.) 275.2164 Tj -0 -142.4004 Td -(4662 int) 34.9481 Tj -0 -151.8938 Td -(4663 sys_link\(void\)) 83.0018 Tj -0 -161.3871 Td -(4664 {) 26.2111 Tj -0 -170.8805 Td -(4665 char name[DIRSIZ], *new, *old;) 161.635 Tj -0 -180.3739 Td -(4666 struct inode *dp, *ip;) 126.6869 Tj -0 -189.8672 Td -(4667 ) 21.8426 Tj -0 -199.3606 Td -(4668 if\(argstr\(0, &old\) < 0 || argstr\(1, &new\) < 0\)) 231.5313 Tj -0 -208.8539 Td -(4669 return -1;) 83.0018 Tj -0 -218.3473 Td -(4670 if\(\(ip = namei\(old\)\) == 0\)) 144.161 Tj -0 -227.8407 Td -(4671 return -1;) 83.0018 Tj -0 -237.334 Td -(4672 ilock\(ip\);) 74.2647 Tj -0 -246.8274 Td -(4673 if\(ip->type == T_DIR\){) 126.6869 Tj -0 -256.3207 Td -(4674 iunlockput\(ip\);) 104.8443 Tj -0 -265.8141 Td -(4675 return -1;) 83.0018 Tj -0 -275.3075 Td -(4676 }) 34.9481 Tj -0 -284.8008 Td -(4677 ip->nlink++;) 83.0018 Tj -0 -294.2942 Td -(4678 iupdate\(ip\);) 83.0018 Tj -0 -303.7875 Td -(4679 iunlock\(ip\);) 83.0018 Tj -0 -313.2809 Td -(4680 ) 21.8426 Tj -0 -322.7743 Td -(4681 if\(\(dp = nameiparent\(new, name\)\) == 0\)) 196.5831 Tj -0 -332.2676 Td -(4682 goto bad;) 78.6333 Tj -0 -341.761 Td -(4683 ilock\(dp\);) 74.2647 Tj -0 -351.2543 Td -(4684 if\(dp->dev != ip->dev || dirlink\(dp, name, ip->inum\) \ -< 0\){) 283.9534 Tj -0 -360.7477 Td -(4685 iunlockput\(dp\);) 104.8443 Tj -0 -370.2411 Td -(4686 goto bad;) 78.6333 Tj -0 -379.7344 Td -(4687 }) 34.9481 Tj -0 -389.2278 Td -(4688 iunlockput\(dp\);) 96.1073 Tj -0 -398.7211 Td -(4689 iput\(ip\);) 69.8962 Tj -0 -408.2145 Td -(4690 return 0;) 69.8962 Tj -0 -417.7079 Td -(4691 ) 21.8426 Tj -0 -427.2012 Td -(4692 bad:) 39.3166 Tj -0 -436.6946 Td -(4693 ilock\(ip\);) 74.2647 Tj -0 -446.1879 Td -(4694 ip->nlink--;) 83.0018 Tj -0 -455.6813 Td -(4695 iupdate\(ip\);) 83.0018 Tj -0 -465.1747 Td -(4696 iunlockput\(ip\);) 96.1073 Tj -0 -474.668 Td -(4697 return -1;) 74.2647 Tj -0 -484.1614 Td -(4698 }) 26.2111 Tj -0 -493.6547 Td -(4699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 46) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 54 54 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 4) 174.7406 Tj -0 -28.4801 Td -(4700 // Is the directory dp empty except for "." and ".." ?) 257.7424 Tj -0 -37.9735 Td -(4701 static int) 65.5277 Tj -0 -47.4668 Td -(4702 isdirempty\(struct inode *dp\)) 144.161 Tj -0 -56.9602 Td -(4703 {) 26.2111 Tj -0 -66.4535 Td -(4704 int off;) 65.5277 Tj -0 -75.9469 Td -(4705 struct dirent de;) 104.8443 Tj -0 -85.4403 Td -(4706 ) 21.8426 Tj -0 -94.9336 Td -(4707 for\(off=2*sizeof\(de\); offsize; off+=sizeof\(de\)\ -\){) 262.1109 Tj -0 -104.427 Td -(4708 if\(readi\(dp, \(char*\)&de, off, sizeof\(de\)\) != si\ -zeof\(de\)\)) 283.9534 Tj -0 -113.9203 Td -(4709 panic\("isdirempty: readi"\);) 166.0035 Tj -0 -123.4137 Td -(4710 if\(de.inum != 0\)) 109.2129 Tj -0 -132.9071 Td -(4711 return 0;) 87.3703 Tj -0 -142.4004 Td -(4712 }) 34.9481 Tj -0 -151.8938 Td -(4713 return 1;) 69.8962 Tj -0 -161.3871 Td -(4714 }) 26.2111 Tj -0 -170.8805 Td -(4715 ) 21.8426 Tj -0 -180.3739 Td -(4716 ) 21.8426 Tj -0 -189.8672 Td -(4717 ) 21.8426 Tj -0 -199.3606 Td -(4718 ) 21.8426 Tj -0 -208.8539 Td -(4719 ) 21.8426 Tj -0 -218.3473 Td -(4720 ) 21.8426 Tj -0 -227.8407 Td -(4721 ) 21.8426 Tj -0 -237.334 Td -(4722 ) 21.8426 Tj -0 -246.8274 Td -(4723 ) 21.8426 Tj -0 -256.3207 Td -(4724 ) 21.8426 Tj -0 -265.8141 Td -(4725 ) 21.8426 Tj -0 -275.3075 Td -(4726 ) 21.8426 Tj -0 -284.8008 Td -(4727 ) 21.8426 Tj -0 -294.2942 Td -(4728 ) 21.8426 Tj -0 -303.7875 Td -(4729 ) 21.8426 Tj -0 -313.2809 Td -(4730 ) 21.8426 Tj -0 -322.7743 Td -(4731 ) 21.8426 Tj -0 -332.2676 Td -(4732 ) 21.8426 Tj -0 -341.761 Td -(4733 ) 21.8426 Tj -0 -351.2543 Td -(4734 ) 21.8426 Tj -0 -360.7477 Td -(4735 ) 21.8426 Tj -0 -370.2411 Td -(4736 ) 21.8426 Tj -0 -379.7344 Td -(4737 ) 21.8426 Tj -0 -389.2278 Td -(4738 ) 21.8426 Tj -0 -398.7211 Td -(4739 ) 21.8426 Tj -0 -408.2145 Td -(4740 ) 21.8426 Tj -0 -417.7079 Td -(4741 ) 21.8426 Tj -0 -427.2012 Td -(4742 ) 21.8426 Tj -0 -436.6946 Td -(4743 ) 21.8426 Tj -0 -446.1879 Td -(4744 ) 21.8426 Tj -0 -455.6813 Td -(4745 ) 21.8426 Tj -0 -465.1747 Td -(4746 ) 21.8426 Tj -0 -474.668 Td -(4747 ) 21.8426 Tj -0 -484.1614 Td -(4748 ) 21.8426 Tj -0 -493.6547 Td -(4749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 47) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 5) 174.7406 Tj -0 -28.4801 Td -(4750 int) 34.9481 Tj -0 -37.9735 Td -(4751 sys_unlink\(void\)) 91.7388 Tj -0 -47.4668 Td -(4752 {) 26.2111 Tj -0 -56.9602 Td -(4753 struct inode *ip, *dp;) 126.6869 Tj -0 -66.4535 Td -(4754 struct dirent de;) 104.8443 Tj -0 -75.9469 Td -(4755 char name[DIRSIZ], *path;) 139.7925 Tj -0 -85.4403 Td -(4756 uint off;) 69.8962 Tj -0 -94.9336 Td -(4757 ) 21.8426 Tj -0 -104.427 Td -(4758 if\(argstr\(0, &path\) < 0\)) 135.4239 Tj -0 -113.9203 Td -(4759 return -1;) 83.0018 Tj -0 -123.4137 Td -(4760 if\(\(dp = nameiparent\(path, name\)\) == 0\)) 200.9517 Tj -0 -132.9071 Td -(4761 return -1;) 83.0018 Tj -0 -142.4004 Td -(4762 ilock\(dp\);) 74.2647 Tj -0 -151.8938 Td -(4763 ) 21.8426 Tj -0 -161.3871 Td -(4764 // Cannot unlink "." or "..".) 157.2665 Tj -0 -170.8805 Td -(4765 if\(namecmp\(name, "."\) == 0 || namecmp\(name, ".."\) =\ -= 0\){) 275.2164 Tj -0 -180.3739 Td -(4766 iunlockput\(dp\);) 104.8443 Tj -0 -189.8672 Td -(4767 return -1;) 83.0018 Tj -0 -199.3606 Td -(4768 }) 34.9481 Tj -0 -208.8539 Td -(4769 ) 21.8426 Tj -0 -218.3473 Td -(4770 if\(\(ip = dirlookup\(dp, name, &off\)\) == 0\){) 214.0572 Tj -0 -227.8407 Td -(4771 iunlockput\(dp\);) 104.8443 Tj -0 -237.334 Td -(4772 return -1;) 83.0018 Tj -0 -246.8274 Td -(4773 }) 34.9481 Tj -0 -256.3207 Td -(4774 ilock\(ip\);) 74.2647 Tj -0 -265.8141 Td -(4775 ) 21.8426 Tj -0 -275.3075 Td -(4776 if\(ip->nlink < 1\)) 104.8443 Tj -0 -284.8008 Td -(4777 panic\("unlink: nlink < 1"\);) 157.2665 Tj -0 -294.2942 Td -(4778 if\(ip->type == T_DIR && !isdirempty\(ip\)\){) 209.6887 Tj -0 -303.7875 Td -(4779 iunlockput\(ip\);) 104.8443 Tj -0 -313.2809 Td -(4780 iunlockput\(dp\);) 104.8443 Tj -0 -322.7743 Td -(4781 return -1;) 83.0018 Tj -0 -332.2676 Td -(4782 }) 34.9481 Tj -0 -341.761 Td -(4783 ) 21.8426 Tj -0 -351.2543 Td -(4784 memset\(&de, 0, sizeof\(de\)\);) 148.5295 Tj -0 -360.7477 Td -(4785 if\(writei\(dp, \(char*\)&de, off, sizeof\(de\)\) != siz\ -eof\(de\)\)) 279.5849 Tj -0 -370.2411 Td -(4786 panic\("unlink: writei"\);) 144.161 Tj -0 -379.7344 Td -(4787 if\(ip->type == T_DIR\){) 126.6869 Tj -0 -389.2278 Td -(4788 dp->nlink--;) 91.7388 Tj -0 -398.7211 Td -(4789 iupdate\(dp\);) 91.7388 Tj -0 -408.2145 Td -(4790 }) 34.9481 Tj -0 -417.7079 Td -(4791 iunlockput\(dp\);) 96.1073 Tj -0 -427.2012 Td -(4792 ) 21.8426 Tj -0 -436.6946 Td -(4793 ip->nlink--;) 83.0018 Tj -0 -446.1879 Td -(4794 iupdate\(ip\);) 83.0018 Tj -0 -455.6813 Td -(4795 iunlockput\(ip\);) 96.1073 Tj -0 -465.1747 Td -(4796 return 0;) 69.8962 Tj -0 -474.668 Td -(4797 }) 26.2111 Tj -0 -484.1614 Td -(4798 ) 21.8426 Tj -0 -493.6547 Td -(4799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 47) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 55 55 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 6) 174.7406 Tj -0 -28.4801 Td -(4800 static struct inode*) 109.2129 Tj -0 -37.9735 Td -(4801 create\(char *path, short type, short major, short minor\)) 266.4794 Tj -0 -47.4668 Td -(4802 {) 26.2111 Tj -0 -56.9602 Td -(4803 uint off;) 69.8962 Tj -0 -66.4535 Td -(4804 struct inode *ip, *dp;) 126.6869 Tj -0 -75.9469 Td -(4805 char name[DIRSIZ];) 109.2129 Tj -0 -85.4403 Td -(4806 ) 21.8426 Tj -0 -94.9336 Td -(4807 if\(\(dp = nameiparent\(path, name\)\) == 0\)) 200.9517 Tj -0 -104.427 Td -(4808 return 0;) 78.6333 Tj -0 -113.9203 Td -(4809 ilock\(dp\);) 74.2647 Tj -0 -123.4137 Td -(4810 ) 21.8426 Tj -0 -132.9071 Td -(4811 if\(\(ip = dirlookup\(dp, name, &off\)\) != 0\){) 214.0572 Tj -0 -142.4004 Td -(4812 iunlockput\(dp\);) 104.8443 Tj -0 -151.8938 Td -(4813 ilock\(ip\);) 83.0018 Tj -0 -161.3871 Td -(4814 if\(type == T_FILE && ip->type == T_FILE\)) 214.0572 Tj -0 -170.8805 Td -(4815 return ip;) 91.7388 Tj -0 -180.3739 Td -(4816 iunlockput\(ip\);) 104.8443 Tj -0 -189.8672 Td -(4817 return 0;) 78.6333 Tj -0 -199.3606 Td -(4818 }) 34.9481 Tj -0 -208.8539 Td -(4819 ) 21.8426 Tj -0 -218.3473 Td -(4820 if\(\(ip = ialloc\(dp->dev, type\)\) == 0\)) 192.2146 Tj -0 -227.8407 Td -(4821 panic\("create: ialloc"\);) 144.161 Tj -0 -237.334 Td -(4822 ) 21.8426 Tj -0 -246.8274 Td -(4823 ilock\(ip\);) 74.2647 Tj -0 -256.3207 Td -(4824 ip->major = major;) 109.2129 Tj -0 -265.8141 Td -(4825 ip->minor = minor;) 109.2129 Tj -0 -275.3075 Td -(4826 ip->nlink = 1;) 91.7388 Tj -0 -284.8008 Td -(4827 iupdate\(ip\);) 83.0018 Tj -0 -294.2942 Td -(4828 ) 21.8426 Tj -0 -303.7875 Td -(4829 if\(type == T_DIR\){ // Create . and .. entries.) 235.8998 Tj -0 -313.2809 Td -(4830 dp->nlink++; // for "..") 148.5295 Tj -0 -322.7743 Td -(4831 iupdate\(dp\);) 91.7388 Tj -0 -332.2676 Td -(4832 // No ip->nlink++ for ".": avoid cyclic ref count.) 257.7424 Tj -0 -341.761 Td -(4833 if\(dirlink\(ip, ".", ip->inum\) < 0 || dirlink\(ip, "\ -..", dp->inum\) < 0\)) 340.7441 Tj -0 -351.2543 Td -(4834 panic\("create dots"\);) 139.7925 Tj -0 -360.7477 Td -(4835 }) 34.9481 Tj -0 -370.2411 Td -(4836 ) 21.8426 Tj -0 -379.7344 Td -(4837 if\(dirlink\(dp, name, ip->inum\) < 0\)) 183.4776 Tj -0 -389.2278 Td -(4838 panic\("create: dirlink"\);) 148.5295 Tj -0 -398.7211 Td -(4839 ) 21.8426 Tj -0 -408.2145 Td -(4840 iunlockput\(dp\);) 96.1073 Tj -0 -417.7079 Td -(4841 return ip;) 74.2647 Tj -0 -427.2012 Td -(4842 }) 26.2111 Tj -0 -436.6946 Td -(4843 ) 21.8426 Tj -0 -446.1879 Td -(4844 ) 21.8426 Tj -0 -455.6813 Td -(4845 ) 21.8426 Tj -0 -465.1747 Td -(4846 ) 21.8426 Tj -0 -474.668 Td -(4847 ) 21.8426 Tj -0 -484.1614 Td -(4848 ) 21.8426 Tj -0 -493.6547 Td -(4849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 48) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 7) 174.7406 Tj -0 -28.4801 Td -(4850 int) 34.9481 Tj -0 -37.9735 Td -(4851 sys_open\(void\)) 83.0018 Tj -0 -47.4668 Td -(4852 {) 26.2111 Tj -0 -56.9602 Td -(4853 char *path;) 78.6333 Tj -0 -66.4535 Td -(4854 int fd, omode;) 91.7388 Tj -0 -75.9469 Td -(4855 struct file *f;) 96.1073 Tj -0 -85.4403 Td -(4856 struct inode *ip;) 104.8443 Tj -0 -94.9336 Td -(4857 ) 21.8426 Tj -0 -104.427 Td -(4858 if\(argstr\(0, &path\) < 0 || argint\(1, &omode\) < 0\)) 244.6368 Tj -0 -113.9203 Td -(4859 return -1;) 83.0018 Tj -0 -123.4137 Td -(4860 ) 21.8426 Tj -0 -132.9071 Td -(4861 if\(omode & O_CREATE\){) 122.3184 Tj -0 -142.4004 Td -(4862 if\(\(ip = create\(path, T_FILE, 0, 0\)\) == 0\)) 222.7942 Tj -0 -151.8938 Td -(4863 return -1;) 91.7388 Tj -0 -161.3871 Td -(4864 } else {) 65.5277 Tj -0 -170.8805 Td -(4865 if\(\(ip = namei\(path\)\) == 0\)) 157.2665 Tj -0 -180.3739 Td -(4866 return -1;) 91.7388 Tj -0 -189.8672 Td -(4867 ilock\(ip\);) 83.0018 Tj -0 -199.3606 Td -(4868 if\(ip->type == T_DIR && omode != O_RDONLY\){) 227.1628 Tj -0 -208.8539 Td -(4869 iunlockput\(ip\);) 113.5814 Tj -0 -218.3473 Td -(4870 return -1;) 91.7388 Tj -0 -227.8407 Td -(4871 }) 43.6851 Tj -0 -237.334 Td -(4872 }) 34.9481 Tj -0 -246.8274 Td -(4873 ) 21.8426 Tj -0 -256.3207 Td -(4874 if\(\(f = filealloc\(\)\) == 0 || \(fd = fdalloc\(f\)\) \ -< 0\){) 257.7424 Tj -0 -265.8141 Td -(4875 if\(f\)) 61.1592 Tj -0 -275.3075 Td -(4876 fileclose\(f\);) 104.8443 Tj -0 -284.8008 Td -(4877 iunlockput\(ip\);) 104.8443 Tj -0 -294.2942 Td -(4878 return -1;) 83.0018 Tj -0 -303.7875 Td -(4879 }) 34.9481 Tj -0 -313.2809 Td -(4880 iunlock\(ip\);) 83.0018 Tj -0 -322.7743 Td -(4881 ) 21.8426 Tj -0 -332.2676 Td -(4882 f->type = FD_INODE;) 113.5814 Tj -0 -341.761 Td -(4883 f->ip = ip;) 78.6333 Tj -0 -351.2543 Td -(4884 f->off = 0;) 78.6333 Tj -0 -360.7477 Td -(4885 f->readable = !\(omode & O_WRONLY\);) 179.1091 Tj -0 -370.2411 Td -(4886 f->writable = \(omode & O_WRONLY\) || \(omode & O_RDWR\)\ -;) 262.1109 Tj -0 -379.7344 Td -(4887 ) 21.8426 Tj -0 -389.2278 Td -(4888 return fd;) 74.2647 Tj -0 -398.7211 Td -(4889 }) 26.2111 Tj -0 -408.2145 Td -(4890 ) 21.8426 Tj -0 -417.7079 Td -(4891 ) 21.8426 Tj -0 -427.2012 Td -(4892 ) 21.8426 Tj -0 -436.6946 Td -(4893 ) 21.8426 Tj -0 -446.1879 Td -(4894 ) 21.8426 Tj -0 -455.6813 Td -(4895 ) 21.8426 Tj -0 -465.1747 Td -(4896 ) 21.8426 Tj -0 -474.668 Td -(4897 ) 21.8426 Tj -0 -484.1614 Td -(4898 ) 21.8426 Tj -0 -493.6547 Td -(4899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 48) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 56 56 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 8) 174.7406 Tj -0 -28.4801 Td -(4900 int) 34.9481 Tj -0 -37.9735 Td -(4901 sys_mkdir\(void\)) 87.3703 Tj -0 -47.4668 Td -(4902 {) 26.2111 Tj -0 -56.9602 Td -(4903 char *path;) 78.6333 Tj -0 -66.4535 Td -(4904 struct inode *ip;) 104.8443 Tj -0 -75.9469 Td -(4905 ) 21.8426 Tj -0 -85.4403 Td -(4906 if\(argstr\(0, &path\) < 0 || \(ip = create\(path, T_DIR\ -, 0, 0\)\) == 0\)) 314.533 Tj -0 -94.9336 Td -(4907 return -1;) 83.0018 Tj -0 -104.427 Td -(4908 iunlockput\(ip\);) 96.1073 Tj -0 -113.9203 Td -(4909 return 0;) 69.8962 Tj -0 -123.4137 Td -(4910 }) 26.2111 Tj -0 -132.9071 Td -(4911 ) 21.8426 Tj -0 -142.4004 Td -(4912 int) 34.9481 Tj -0 -151.8938 Td -(4913 sys_mknod\(void\)) 87.3703 Tj -0 -161.3871 Td -(4914 {) 26.2111 Tj -0 -170.8805 Td -(4915 struct inode *ip;) 104.8443 Tj -0 -180.3739 Td -(4916 char *path;) 78.6333 Tj -0 -189.8672 Td -(4917 int len;) 65.5277 Tj -0 -199.3606 Td -(4918 int major, minor;) 104.8443 Tj -0 -208.8539 Td -(4919 ) 21.8426 Tj -0 -218.3473 Td -(4920 if\(\(len=argstr\(0, &path\)\) < 0 ||) 170.3721 Tj -0 -227.8407 Td -(4921 argint\(1, &major\) < 0 ||) 148.5295 Tj -0 -237.334 Td -(4922 argint\(2, &minor\) < 0 ||) 148.5295 Tj -0 -246.8274 Td -(4923 \(ip = create\(path, T_DEV, major, minor\)\) == 0\)) 244.6368 Tj -0 -256.3207 Td -(4924 return -1;) 83.0018 Tj -0 -265.8141 Td -(4925 iunlockput\(ip\);) 96.1073 Tj -0 -275.3075 Td -(4926 return 0;) 69.8962 Tj -0 -284.8008 Td -(4927 }) 26.2111 Tj -0 -294.2942 Td -(4928 ) 21.8426 Tj -0 -303.7875 Td -(4929 int) 34.9481 Tj -0 -313.2809 Td -(4930 sys_chdir\(void\)) 87.3703 Tj -0 -322.7743 Td -(4931 {) 26.2111 Tj -0 -332.2676 Td -(4932 char *path;) 78.6333 Tj -0 -341.761 Td -(4933 struct inode *ip;) 104.8443 Tj -0 -351.2543 Td -(4934 ) 21.8426 Tj -0 -360.7477 Td -(4935 if\(argstr\(0, &path\) < 0 || \(ip = namei\(path\)\) == \ -0\)) 253.3738 Tj -0 -370.2411 Td -(4936 return -1;) 83.0018 Tj -0 -379.7344 Td -(4937 ilock\(ip\);) 74.2647 Tj -0 -389.2278 Td -(4938 if\(ip->type != T_DIR\){) 126.6869 Tj -0 -398.7211 Td -(4939 iunlockput\(ip\);) 104.8443 Tj -0 -408.2145 Td -(4940 return -1;) 83.0018 Tj -0 -417.7079 Td -(4941 }) 34.9481 Tj -0 -427.2012 Td -(4942 iunlock\(ip\);) 83.0018 Tj -0 -436.6946 Td -(4943 iput\(proc->cwd\);) 100.4758 Tj -0 -446.1879 Td -(4944 proc->cwd = ip;) 96.1073 Tj -0 -455.6813 Td -(4945 return 0;) 69.8962 Tj -0 -465.1747 Td -(4946 }) 26.2111 Tj -0 -474.668 Td -(4947 ) 21.8426 Tj -0 -484.1614 Td -(4948 ) 21.8426 Tj -0 -493.6547 Td -(4949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 49) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sysfile.c Page 9) 174.7406 Tj -0 -28.4801 Td -(4950 int) 34.9481 Tj -0 -37.9735 Td -(4951 sys_exec\(void\)) 83.0018 Tj -0 -47.4668 Td -(4952 {) 26.2111 Tj -0 -56.9602 Td -(4953 char *path, *argv[20];) 126.6869 Tj -0 -66.4535 Td -(4954 int i;) 56.7907 Tj -0 -75.9469 Td -(4955 uint uargv, uarg;) 104.8443 Tj -0 -85.4403 Td -(4956 ) 21.8426 Tj -0 -94.9336 Td -(4957 if\(argstr\(0, &path\) < 0 || argint\(1, \(int*\)&uargv\)\ - < 0\)) 270.8479 Tj -0 -104.427 Td -(4958 return -1;) 83.0018 Tj -0 -113.9203 Td -(4959 memset\(argv, 0, sizeof\(argv\)\);) 161.635 Tj -0 -123.4137 Td -(4960 for\(i=0;; i++\){) 96.1073 Tj -0 -132.9071 Td -(4961 if\(i >= NELEM\(argv\)\)) 126.6869 Tj -0 -142.4004 Td -(4962 return -1;) 91.7388 Tj -0 -151.8938 Td -(4963 if\(fetchint\(proc, uargv+4*i, \(int*\)&uarg\) < 0\)) 240.2683 Tj -0 -161.3871 Td -(4964 return -1;) 91.7388 Tj -0 -170.8805 Td -(4965 if\(uarg == 0\){) 100.4758 Tj -0 -180.3739 Td -(4966 argv[i] = 0;) 100.4758 Tj -0 -189.8672 Td -(4967 break;) 74.2647 Tj -0 -199.3606 Td -(4968 }) 43.6851 Tj -0 -208.8539 Td -(4969 if\(fetchstr\(proc, uarg, &argv[i]\) < 0\)) 205.3202 Tj -0 -218.3473 Td -(4970 return -1;) 91.7388 Tj -0 -227.8407 Td -(4971 }) 34.9481 Tj -0 -237.334 Td -(4972 return exec\(path, argv\);) 135.4239 Tj -0 -246.8274 Td -(4973 }) 26.2111 Tj -0 -256.3207 Td -(4974 ) 21.8426 Tj -0 -265.8141 Td -(4975 int) 34.9481 Tj -0 -275.3075 Td -(4976 sys_pipe\(void\)) 83.0018 Tj -0 -284.8008 Td -(4977 {) 26.2111 Tj -0 -294.2942 Td -(4978 int *fd;) 65.5277 Tj -0 -303.7875 Td -(4979 struct file *rf, *wf;) 122.3184 Tj -0 -313.2809 Td -(4980 int fd0, fd1;) 87.3703 Tj -0 -322.7743 Td -(4981 ) 21.8426 Tj -0 -332.2676 Td -(4982 if\(argptr\(0, \(void*\)&fd, 2*sizeof\(fd[0]\)\) < 0\)) 231.5313 Tj -0 -341.761 Td -(4983 return -1;) 83.0018 Tj -0 -351.2543 Td -(4984 if\(pipealloc\(&rf, &wf\) < 0\)) 148.5295 Tj -0 -360.7477 Td -(4985 return -1;) 83.0018 Tj -0 -370.2411 Td -(4986 fd0 = -1;) 69.8962 Tj -0 -379.7344 Td -(4987 if\(\(fd0 = fdalloc\(rf\)\) < 0 || \(fd1 = fdalloc\(wf\)\ -\) < 0\){) 270.8479 Tj -0 -389.2278 Td -(4988 if\(fd0 >= 0\)) 91.7388 Tj -0 -398.7211 Td -(4989 proc->ofile[fd0] = 0;) 139.7925 Tj -0 -408.2145 Td -(4990 fileclose\(rf\);) 100.4758 Tj -0 -417.7079 Td -(4991 fileclose\(wf\);) 100.4758 Tj -0 -427.2012 Td -(4992 return -1;) 83.0018 Tj -0 -436.6946 Td -(4993 }) 34.9481 Tj -0 -446.1879 Td -(4994 fd[0] = fd0;) 83.0018 Tj -0 -455.6813 Td -(4995 fd[1] = fd1;) 83.0018 Tj -0 -465.1747 Td -(4996 return 0;) 69.8962 Tj -0 -474.668 Td -(4997 }) 26.2111 Tj -0 -484.1614 Td -(4998 ) 21.8426 Tj -0 -493.6547 Td -(4999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 49) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 57 57 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/exec.c Page 1) 161.635 Tj -0 -28.4801 Td -(5000 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(5001 #include "param.h") 100.4758 Tj -0 -47.4668 Td -(5002 #include "mmu.h") 91.7388 Tj -0 -56.9602 Td -(5003 #include "proc.h") 96.1073 Tj -0 -66.4535 Td -(5004 #include "defs.h") 96.1073 Tj -0 -75.9469 Td -(5005 #include "x86.h") 91.7388 Tj -0 -85.4403 Td -(5006 #include "elf.h") 91.7388 Tj -0 -94.9336 Td -(5007 ) 21.8426 Tj -0 -104.427 Td -(5008 int) 34.9481 Tj -0 -113.9203 Td -(5009 exec\(char *path, char **argv\)) 148.5295 Tj -0 -123.4137 Td -(5010 {) 26.2111 Tj -0 -132.9071 Td -(5011 char *mem, *s, *last;) 122.3184 Tj -0 -142.4004 Td -(5012 int i, argc, arglen, len, off;) 161.635 Tj -0 -151.8938 Td -(5013 uint sz, sp, argp;) 109.2129 Tj -0 -161.3871 Td -(5014 struct elfhdr elf;) 109.2129 Tj -0 -170.8805 Td -(5015 struct inode *ip;) 104.8443 Tj -0 -180.3739 Td -(5016 struct proghdr ph;) 109.2129 Tj -0 -189.8672 Td -(5017 ) 21.8426 Tj -0 -199.3606 Td -(5018 mem = 0;) 65.5277 Tj -0 -208.8539 Td -(5019 sz = 0;) 61.1592 Tj -0 -218.3473 Td -(5020 ) 21.8426 Tj -0 -227.8407 Td -(5021 if\(\(ip = namei\(path\)\) == 0\)) 148.5295 Tj -0 -237.334 Td -(5022 return -1;) 83.0018 Tj -0 -246.8274 Td -(5023 ilock\(ip\);) 74.2647 Tj -0 -256.3207 Td -(5024 ) 21.8426 Tj -0 -265.8141 Td -(5025 // Check ELF header) 113.5814 Tj -0 -275.3075 Td -(5026 if\(readi\(ip, \(char*\)&elf, 0, sizeof\(elf\)\) < sizeo\ -f\(elf\)\)) 275.2164 Tj -0 -284.8008 Td -(5027 goto bad;) 78.6333 Tj -0 -294.2942 Td -(5028 if\(elf.magic != ELF_MAGIC\)) 144.161 Tj -0 -303.7875 Td -(5029 goto bad;) 78.6333 Tj -0 -313.2809 Td -(5030 ) 21.8426 Tj -0 -322.7743 Td -(5031 // Compute memory size of new process.) 196.5831 Tj -0 -332.2676 Td -(5032 // Program segments.) 117.9499 Tj -0 -341.761 Td -(5033 for\(i=0, off=elf.phoff; i sz\)) 270.8479 Tj -0 -218.3473 Td -(5070 goto bad;) 87.3703 Tj -0 -227.8407 Td -(5071 if\(ph.memsz < ph.filesz\)) 144.161 Tj -0 -237.334 Td -(5072 goto bad;) 87.3703 Tj -0 -246.8274 Td -(5073 if\(readi\(ip, mem + ph.va, ph.offset, ph.filesz\) != \ -ph.filesz\)) 305.796 Tj -0 -256.3207 Td -(5074 goto bad;) 87.3703 Tj -0 -265.8141 Td -(5075 memset\(mem + ph.va + ph.filesz, 0, ph.memsz - ph.file\ -sz\);) 288.322 Tj -0 -275.3075 Td -(5076 }) 34.9481 Tj -0 -284.8008 Td -(5077 iunlockput\(ip\);) 96.1073 Tj -0 -294.2942 Td -(5078 ) 21.8426 Tj -0 -303.7875 Td -(5079 // Initialize stack.) 117.9499 Tj -0 -313.2809 Td -(5080 sp = sz;) 65.5277 Tj -0 -322.7743 Td -(5081 argp = sz - arglen - 4*\(argc+1\);) 170.3721 Tj -0 -332.2676 Td -(5082 ) 21.8426 Tj -0 -341.761 Td -(5083 // Copy argv strings and pointers to stack.) 218.4257 Tj -0 -351.2543 Td -(5084 *\(uint*\)\(mem+argp + 4*argc\) = 0; // argv[argc]) 235.8998 Tj -0 -360.7477 Td -(5085 for\(i=argc-1; i>=0; i--\){) 139.7925 Tj -0 -370.2411 Td -(5086 len = strlen\(argv[i]\) + 1;) 152.898 Tj -0 -379.7344 Td -(5087 sp -= len;) 83.0018 Tj -0 -389.2278 Td -(5088 memmove\(mem+sp, argv[i], len\);) 170.3721 Tj -0 -398.7211 Td -(5089 *\(uint*\)\(mem+argp + 4*i\) = sp; // argv[i]) 222.7942 Tj -0 -408.2145 Td -(5090 }) 34.9481 Tj -0 -417.7079 Td -(5091 ) 21.8426 Tj -0 -427.2012 Td -(5092 // Stack frame for main\(argc, argv\), below arguments.) 262.1109 Tj -0 -436.6946 Td -(5093 sp = argp;) 74.2647 Tj -0 -446.1879 Td -(5094 sp -= 4;) 65.5277 Tj -0 -455.6813 Td -(5095 *\(uint*\)\(mem+sp\) = argp;) 135.4239 Tj -0 -465.1747 Td -(5096 sp -= 4;) 65.5277 Tj -0 -474.668 Td -(5097 *\(uint*\)\(mem+sp\) = argc;) 135.4239 Tj -0 -484.1614 Td -(5098 sp -= 4;) 65.5277 Tj -0 -493.6547 Td -(5099 *\(uint*\)\(mem+sp\) = 0xffffffff; // fake return pc) 249.0053 Tj -0 -522.1348 Td -(Sheet 50) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 58 58 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/exec.c Page 3) 161.635 Tj -0 -28.4801 Td -(5100 // Save program name for debugging.) 183.4776 Tj -0 -37.9735 Td -(5101 for\(last=s=path; *s; s++\)) 139.7925 Tj -0 -47.4668 Td -(5102 if\(*s == '/'\)) 96.1073 Tj -0 -56.9602 Td -(5103 last = s+1;) 96.1073 Tj -0 -66.4535 Td -(5104 safestrcpy\(proc->name, last, sizeof\(proc->name\)\);) 244.6368 Tj -0 -75.9469 Td -(5105 ) 21.8426 Tj -0 -85.4403 Td -(5106 // Commit to the new image.) 148.5295 Tj -0 -94.9336 Td -(5107 kfree\(proc->mem, proc->sz\);) 148.5295 Tj -0 -104.427 Td -(5108 proc->mem = mem;) 100.4758 Tj -0 -113.9203 Td -(5109 proc->sz = sz;) 91.7388 Tj -0 -123.4137 Td -(5110 proc->tf->eip = elf.entry; // main) 183.4776 Tj -0 -132.9071 Td -(5111 proc->tf->esp = sp;) 113.5814 Tj -0 -142.4004 Td -(5112 usegment\(\);) 78.6333 Tj -0 -151.8938 Td -(5113 return 0;) 69.8962 Tj -0 -161.3871 Td -(5114 ) 21.8426 Tj -0 -170.8805 Td -(5115 bad:) 43.6851 Tj -0 -180.3739 Td -(5116 if\(mem\)) 61.1592 Tj -0 -189.8672 Td -(5117 kfree\(mem, sz\);) 104.8443 Tj -0 -199.3606 Td -(5118 iunlockput\(ip\);) 96.1073 Tj -0 -208.8539 Td -(5119 return -1;) 74.2647 Tj -0 -218.3473 Td -(5120 }) 26.2111 Tj -0 -227.8407 Td -(5121 ) 21.8426 Tj -0 -237.334 Td -(5122 ) 21.8426 Tj -0 -246.8274 Td -(5123 ) 21.8426 Tj -0 -256.3207 Td -(5124 ) 21.8426 Tj -0 -265.8141 Td -(5125 ) 21.8426 Tj -0 -275.3075 Td -(5126 ) 21.8426 Tj -0 -284.8008 Td -(5127 ) 21.8426 Tj -0 -294.2942 Td -(5128 ) 21.8426 Tj -0 -303.7875 Td -(5129 ) 21.8426 Tj -0 -313.2809 Td -(5130 ) 21.8426 Tj -0 -322.7743 Td -(5131 ) 21.8426 Tj -0 -332.2676 Td -(5132 ) 21.8426 Tj -0 -341.761 Td -(5133 ) 21.8426 Tj -0 -351.2543 Td -(5134 ) 21.8426 Tj -0 -360.7477 Td -(5135 ) 21.8426 Tj -0 -370.2411 Td -(5136 ) 21.8426 Tj -0 -379.7344 Td -(5137 ) 21.8426 Tj -0 -389.2278 Td -(5138 ) 21.8426 Tj -0 -398.7211 Td -(5139 ) 21.8426 Tj -0 -408.2145 Td -(5140 ) 21.8426 Tj -0 -417.7079 Td -(5141 ) 21.8426 Tj -0 -427.2012 Td -(5142 ) 21.8426 Tj -0 -436.6946 Td -(5143 ) 21.8426 Tj -0 -446.1879 Td -(5144 ) 21.8426 Tj -0 -455.6813 Td -(5145 ) 21.8426 Tj -0 -465.1747 Td -(5146 ) 21.8426 Tj -0 -474.668 Td -(5147 ) 21.8426 Tj -0 -484.1614 Td -(5148 ) 21.8426 Tj -0 -493.6547 Td -(5149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 51) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/pipe.c Page 1) 161.635 Tj -0 -28.4801 Td -(5150 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(5151 #include "defs.h") 96.1073 Tj -0 -47.4668 Td -(5152 #include "param.h") 100.4758 Tj -0 -56.9602 Td -(5153 #include "mmu.h") 91.7388 Tj -0 -66.4535 Td -(5154 #include "proc.h") 96.1073 Tj -0 -75.9469 Td -(5155 #include "fs.h") 87.3703 Tj -0 -85.4403 Td -(5156 #include "file.h") 96.1073 Tj -0 -94.9336 Td -(5157 #include "spinlock.h") 113.5814 Tj -0 -104.427 Td -(5158 ) 21.8426 Tj -0 -113.9203 Td -(5159 #define PIPESIZE 512) 109.2129 Tj -0 -123.4137 Td -(5160 ) 21.8426 Tj -0 -132.9071 Td -(5161 struct pipe {) 78.6333 Tj -0 -142.4004 Td -(5162 struct spinlock lock;) 122.3184 Tj -0 -151.8938 Td -(5163 char data[PIPESIZE];) 117.9499 Tj -0 -161.3871 Td -(5164 uint nread; // number of bytes read) 200.9517 Tj -0 -170.8805 Td -(5165 uint nwrite; // number of bytes written) 214.0572 Tj -0 -180.3739 Td -(5166 int readopen; // read fd is still open) 205.3202 Tj -0 -189.8672 Td -(5167 int writeopen; // write fd is still open) 209.6887 Tj -0 -199.3606 Td -(5168 };) 30.5796 Tj -0 -208.8539 Td -(5169 ) 21.8426 Tj -0 -218.3473 Td -(5170 int) 34.9481 Tj -0 -227.8407 Td -(5171 pipealloc\(struct file **f0, struct file **f1\)) 218.4257 Tj -0 -237.334 Td -(5172 {) 26.2111 Tj -0 -246.8274 Td -(5173 struct pipe *p;) 96.1073 Tj -0 -256.3207 Td -(5174 ) 21.8426 Tj -0 -265.8141 Td -(5175 p = 0;) 56.7907 Tj -0 -275.3075 Td -(5176 *f0 = *f1 = 0;) 91.7388 Tj -0 -284.8008 Td -(5177 if\(\(*f0 = filealloc\(\)\) == 0 || \(*f1 = filealloc\(\)\ -\) == 0\)) 275.2164 Tj -0 -294.2942 Td -(5178 goto bad;) 78.6333 Tj -0 -303.7875 Td -(5179 if\(\(p = \(struct pipe*\)kalloc\(PAGE\)\) == 0\)) 209.6887 Tj -0 -313.2809 Td -(5180 goto bad;) 78.6333 Tj -0 -322.7743 Td -(5181 p->readopen = 1;) 100.4758 Tj -0 -332.2676 Td -(5182 p->writeopen = 1;) 104.8443 Tj -0 -341.761 Td -(5183 p->nwrite = 0;) 91.7388 Tj -0 -351.2543 Td -(5184 p->nread = 0;) 87.3703 Tj -0 -360.7477 Td -(5185 initlock\(&p->lock, "pipe"\);) 148.5295 Tj -0 -370.2411 Td -(5186 \(*f0\)->type = FD_PIPE;) 126.6869 Tj -0 -379.7344 Td -(5187 \(*f0\)->readable = 1;) 117.9499 Tj -0 -389.2278 Td -(5188 \(*f0\)->writable = 0;) 117.9499 Tj -0 -398.7211 Td -(5189 \(*f0\)->pipe = p;) 100.4758 Tj -0 -408.2145 Td -(5190 \(*f1\)->type = FD_PIPE;) 126.6869 Tj -0 -417.7079 Td -(5191 \(*f1\)->readable = 0;) 117.9499 Tj -0 -427.2012 Td -(5192 \(*f1\)->writable = 1;) 117.9499 Tj -0 -436.6946 Td -(5193 \(*f1\)->pipe = p;) 100.4758 Tj -0 -446.1879 Td -(5194 return 0;) 69.8962 Tj -0 -455.6813 Td -(5195 ) 21.8426 Tj -0 -465.1747 Td -(5196 ) 21.8426 Tj -0 -474.668 Td -(5197 ) 21.8426 Tj -0 -484.1614 Td -(5198 ) 21.8426 Tj -0 -493.6547 Td -(5199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 51) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 59 59 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/pipe.c Page 2) 161.635 Tj -0 -28.4801 Td -(5200 bad:) 43.6851 Tj -0 -37.9735 Td -(5201 if\(p\)) 52.4222 Tj -0 -47.4668 Td -(5202 kfree\(\(char*\)p, PAGE\);) 135.4239 Tj -0 -56.9602 Td -(5203 if\(*f0\)) 61.1592 Tj -0 -66.4535 Td -(5204 fileclose\(*f0\);) 104.8443 Tj -0 -75.9469 Td -(5205 if\(*f1\)) 61.1592 Tj -0 -85.4403 Td -(5206 fileclose\(*f1\);) 104.8443 Tj -0 -94.9336 Td -(5207 return -1;) 74.2647 Tj -0 -104.427 Td -(5208 }) 26.2111 Tj -0 -113.9203 Td -(5209 ) 21.8426 Tj -0 -123.4137 Td -(5210 void) 39.3166 Tj -0 -132.9071 Td -(5211 pipeclose\(struct pipe *p, int writable\)) 192.2146 Tj -0 -142.4004 Td -(5212 {) 26.2111 Tj -0 -151.8938 Td -(5213 acquire\(&p->lock\);) 109.2129 Tj -0 -161.3871 Td -(5214 if\(writable\){) 87.3703 Tj -0 -170.8805 Td -(5215 p->writeopen = 0;) 113.5814 Tj -0 -180.3739 Td -(5216 wakeup\(&p->nread\);) 117.9499 Tj -0 -189.8672 Td -(5217 } else {) 65.5277 Tj -0 -199.3606 Td -(5218 p->readopen = 0;) 109.2129 Tj -0 -208.8539 Td -(5219 wakeup\(&p->nwrite\);) 122.3184 Tj -0 -218.3473 Td -(5220 }) 34.9481 Tj -0 -227.8407 Td -(5221 if\(p->readopen == 0 && p->writeopen == 0\) {) 218.4257 Tj -0 -237.334 Td -(5222 release\(&p->lock\);) 117.9499 Tj -0 -246.8274 Td -(5223 kfree\(\(char*\)p, PAGE\);) 135.4239 Tj -0 -256.3207 Td -(5224 } else) 56.7907 Tj -0 -265.8141 Td -(5225 release\(&p->lock\);) 117.9499 Tj -0 -275.3075 Td -(5226 }) 26.2111 Tj -0 -284.8008 Td -(5227 ) 21.8426 Tj -0 -294.2942 Td -(5228 ) 21.8426 Tj -0 -303.7875 Td -(5229 int) 34.9481 Tj -0 -313.2809 Td -(5230 pipewrite\(struct pipe *p, char *addr, int n\)) 214.0572 Tj -0 -322.7743 Td -(5231 {) 26.2111 Tj -0 -332.2676 Td -(5232 int i;) 56.7907 Tj -0 -341.761 Td -(5233 ) 21.8426 Tj -0 -351.2543 Td -(5234 acquire\(&p->lock\);) 109.2129 Tj -0 -360.7477 Td -(5235 for\(i = 0; i < n; i++\){) 131.0554 Tj -0 -370.2411 Td -(5236 while\(p->nwrite == p->nread + PIPESIZE\) { ) 227.1628 Tj -0 -379.7344 Td -(5237 if\(p->readopen == 0 || proc->killed\){) 209.6887 Tj -0 -389.2278 Td -(5238 release\(&p->lock\);) 135.4239 Tj -0 -398.7211 Td -(5239 return -1;) 100.4758 Tj -0 -408.2145 Td -(5240 }) 52.4222 Tj -0 -417.7079 Td -(5241 wakeup\(&p->nread\);) 126.6869 Tj -0 -427.2012 Td -(5242 sleep\(&p->nwrite, &p->lock\); ) 179.1091 Tj -0 -436.6946 Td -(5243 }) 43.6851 Tj -0 -446.1879 Td -(5244 p->data[p->nwrite++ % PIPESIZE] = addr[i];) 222.7942 Tj -0 -455.6813 Td -(5245 }) 34.9481 Tj -0 -465.1747 Td -(5246 wakeup\(&p->nread\); ) 117.9499 Tj -0 -474.668 Td -(5247 release\(&p->lock\);) 109.2129 Tj -0 -484.1614 Td -(5248 return n;) 69.8962 Tj -0 -493.6547 Td -(5249 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 52) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/pipe.c Page 3) 161.635 Tj -0 -28.4801 Td -(5250 int) 34.9481 Tj -0 -37.9735 Td -(5251 piperead\(struct pipe *p, char *addr, int n\)) 209.6887 Tj -0 -47.4668 Td -(5252 {) 26.2111 Tj -0 -56.9602 Td -(5253 int i;) 56.7907 Tj -0 -66.4535 Td -(5254 ) 21.8426 Tj -0 -75.9469 Td -(5255 acquire\(&p->lock\);) 109.2129 Tj -0 -85.4403 Td -(5256 while\(p->nread == p->nwrite && p->writeopen\){ ) 235.8998 Tj -0 -94.9336 Td -(5257 if\(proc->killed\){) 113.5814 Tj -0 -104.427 Td -(5258 release\(&p->lock\);) 126.6869 Tj -0 -113.9203 Td -(5259 return -1;) 91.7388 Tj -0 -123.4137 Td -(5260 }) 43.6851 Tj -0 -132.9071 Td -(5261 sleep\(&p->nread, &p->lock\); ) 161.635 Tj -0 -142.4004 Td -(5262 }) 34.9481 Tj -0 -151.8938 Td -(5263 for\(i = 0; i < n; i++\){ ) 139.7925 Tj -0 -161.3871 Td -(5264 if\(p->nread == p->nwrite\)) 148.5295 Tj -0 -170.8805 Td -(5265 break;) 74.2647 Tj -0 -180.3739 Td -(5266 addr[i] = p->data[p->nread++ % PIPESIZE];) 218.4257 Tj -0 -189.8672 Td -(5267 }) 34.9481 Tj -0 -199.3606 Td -(5268 wakeup\(&p->nwrite\); ) 122.3184 Tj -0 -208.8539 Td -(5269 release\(&p->lock\);) 109.2129 Tj -0 -218.3473 Td -(5270 return i;) 69.8962 Tj -0 -227.8407 Td -(5271 }) 26.2111 Tj -0 -237.334 Td -(5272 ) 21.8426 Tj -0 -246.8274 Td -(5273 ) 21.8426 Tj -0 -256.3207 Td -(5274 ) 21.8426 Tj -0 -265.8141 Td -(5275 ) 21.8426 Tj -0 -275.3075 Td -(5276 ) 21.8426 Tj -0 -284.8008 Td -(5277 ) 21.8426 Tj -0 -294.2942 Td -(5278 ) 21.8426 Tj -0 -303.7875 Td -(5279 ) 21.8426 Tj -0 -313.2809 Td -(5280 ) 21.8426 Tj -0 -322.7743 Td -(5281 ) 21.8426 Tj -0 -332.2676 Td -(5282 ) 21.8426 Tj -0 -341.761 Td -(5283 ) 21.8426 Tj -0 -351.2543 Td -(5284 ) 21.8426 Tj -0 -360.7477 Td -(5285 ) 21.8426 Tj -0 -370.2411 Td -(5286 ) 21.8426 Tj -0 -379.7344 Td -(5287 ) 21.8426 Tj -0 -389.2278 Td -(5288 ) 21.8426 Tj -0 -398.7211 Td -(5289 ) 21.8426 Tj -0 -408.2145 Td -(5290 ) 21.8426 Tj -0 -417.7079 Td -(5291 ) 21.8426 Tj -0 -427.2012 Td -(5292 ) 21.8426 Tj -0 -436.6946 Td -(5293 ) 21.8426 Tj -0 -446.1879 Td -(5294 ) 21.8426 Tj -0 -455.6813 Td -(5295 ) 21.8426 Tj -0 -465.1747 Td -(5296 ) 21.8426 Tj -0 -474.668 Td -(5297 ) 21.8426 Tj -0 -484.1614 Td -(5298 ) 21.8426 Tj -0 -493.6547 Td -(5299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 52) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 60 60 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/string.c Page 1) 170.3721 Tj -0 -28.4801 Td -(5300 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(5301 #include "x86.h") 91.7388 Tj -0 -47.4668 Td -(5302 ) 21.8426 Tj -0 -56.9602 Td -(5303 void*) 43.6851 Tj -0 -66.4535 Td -(5304 memset\(void *dst, int c, uint n\)) 161.635 Tj -0 -75.9469 Td -(5305 {) 26.2111 Tj -0 -85.4403 Td -(5306 stosb\(dst, c, n\);) 104.8443 Tj -0 -94.9336 Td -(5307 return dst;) 78.6333 Tj -0 -104.427 Td -(5308 }) 26.2111 Tj -0 -113.9203 Td -(5309 ) 21.8426 Tj -0 -123.4137 Td -(5310 int) 34.9481 Tj -0 -132.9071 Td -(5311 memcmp\(const void *v1, const void *v2, uint n\)) 222.7942 Tj -0 -142.4004 Td -(5312 {) 26.2111 Tj -0 -151.8938 Td -(5313 const uchar *s1, *s2;) 122.3184 Tj -0 -161.3871 Td -(5314 ) 21.8426 Tj -0 -170.8805 Td -(5315 s1 = v1;) 65.5277 Tj -0 -180.3739 Td -(5316 s2 = v2;) 65.5277 Tj -0 -189.8672 Td -(5317 while\(n-- > 0\){) 96.1073 Tj -0 -199.3606 Td -(5318 if\(*s1 != *s2\)) 100.4758 Tj -0 -208.8539 Td -(5319 return *s1 - *s2;) 122.3184 Tj -0 -218.3473 Td -(5320 s1++, s2++;) 87.3703 Tj -0 -227.8407 Td -(5321 }) 34.9481 Tj -0 -237.334 Td -(5322 ) 21.8426 Tj -0 -246.8274 Td -(5323 return 0;) 69.8962 Tj -0 -256.3207 Td -(5324 }) 26.2111 Tj -0 -265.8141 Td -(5325 ) 21.8426 Tj -0 -275.3075 Td -(5326 void*) 43.6851 Tj -0 -284.8008 Td -(5327 memmove\(void *dst, const void *src, uint n\)) 209.6887 Tj -0 -294.2942 Td -(5328 {) 26.2111 Tj -0 -303.7875 Td -(5329 const char *s;) 91.7388 Tj -0 -313.2809 Td -(5330 char *d;) 65.5277 Tj -0 -322.7743 Td -(5331 ) 21.8426 Tj -0 -332.2676 Td -(5332 s = src;) 65.5277 Tj -0 -341.761 Td -(5333 d = dst;) 65.5277 Tj -0 -351.2543 Td -(5334 if\(s < d && s + n > d\){) 131.0554 Tj -0 -360.7477 Td -(5335 s += n;) 69.8962 Tj -0 -370.2411 Td -(5336 d += n;) 69.8962 Tj -0 -379.7344 Td -(5337 while\(n-- > 0\)) 100.4758 Tj -0 -389.2278 Td -(5338 *--d = *--s;) 100.4758 Tj -0 -398.7211 Td -(5339 } else) 56.7907 Tj -0 -408.2145 Td -(5340 while\(n-- > 0\)) 100.4758 Tj -0 -417.7079 Td -(5341 *d++ = *s++;) 100.4758 Tj -0 -427.2012 Td -(5342 ) 21.8426 Tj -0 -436.6946 Td -(5343 return dst;) 78.6333 Tj -0 -446.1879 Td -(5344 }) 26.2111 Tj -0 -455.6813 Td -(5345 ) 21.8426 Tj -0 -465.1747 Td -(5346 ) 21.8426 Tj -0 -474.668 Td -(5347 ) 21.8426 Tj -0 -484.1614 Td -(5348 ) 21.8426 Tj -0 -493.6547 Td -(5349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 53) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/string.c Page 2) 170.3721 Tj -0 -28.4801 Td -(5350 int) 34.9481 Tj -0 -37.9735 Td -(5351 strncmp\(const char *p, const char *q, uint n\)) 218.4257 Tj -0 -47.4668 Td -(5352 {) 26.2111 Tj -0 -56.9602 Td -(5353 while\(n > 0 && *p && *p == *q\)) 161.635 Tj -0 -66.4535 Td -(5354 n--, p++, q++;) 100.4758 Tj -0 -75.9469 Td -(5355 if\(n == 0\)) 74.2647 Tj -0 -85.4403 Td -(5356 return 0;) 78.6333 Tj -0 -94.9336 Td -(5357 return \(uchar\)*p - \(uchar\)*q;) 157.2665 Tj -0 -104.427 Td -(5358 }) 26.2111 Tj -0 -113.9203 Td -(5359 ) 21.8426 Tj -0 -123.4137 Td -(5360 char*) 43.6851 Tj -0 -132.9071 Td -(5361 strncpy\(char *s, const char *t, int n\)) 187.8461 Tj -0 -142.4004 Td -(5362 {) 26.2111 Tj -0 -151.8938 Td -(5363 char *os;) 69.8962 Tj -0 -161.3871 Td -(5364 ) 21.8426 Tj -0 -170.8805 Td -(5365 os = s;) 61.1592 Tj -0 -180.3739 Td -(5366 while\(n-- > 0 && \(*s++ = *t++\) != 0\)) 187.8461 Tj -0 -189.8672 Td -(5367 ;) 43.6851 Tj -0 -199.3606 Td -(5368 while\(n-- > 0\)) 91.7388 Tj -0 -208.8539 Td -(5369 *s++ = 0;) 78.6333 Tj -0 -218.3473 Td -(5370 return os;) 74.2647 Tj -0 -227.8407 Td -(5371 }) 26.2111 Tj -0 -237.334 Td -(5372 ) 21.8426 Tj -0 -246.8274 Td -(5373 // Like strncpy but guaranteed to NUL-terminate.) 231.5313 Tj -0 -256.3207 Td -(5374 char*) 43.6851 Tj -0 -265.8141 Td -(5375 safestrcpy\(char *s, const char *t, int n\)) 200.9517 Tj -0 -275.3075 Td -(5376 {) 26.2111 Tj -0 -284.8008 Td -(5377 char *os;) 69.8962 Tj -0 -294.2942 Td -(5378 ) 21.8426 Tj -0 -303.7875 Td -(5379 os = s;) 61.1592 Tj -0 -313.2809 Td -(5380 if\(n <= 0\)) 74.2647 Tj -0 -322.7743 Td -(5381 return os;) 83.0018 Tj -0 -332.2676 Td -(5382 while\(--n > 0 && \(*s++ = *t++\) != 0\)) 187.8461 Tj -0 -341.761 Td -(5383 ;) 43.6851 Tj -0 -351.2543 Td -(5384 *s = 0;) 61.1592 Tj -0 -360.7477 Td -(5385 return os;) 74.2647 Tj -0 -370.2411 Td -(5386 }) 26.2111 Tj -0 -379.7344 Td -(5387 ) 21.8426 Tj -0 -389.2278 Td -(5388 int) 34.9481 Tj -0 -398.7211 Td -(5389 strlen\(const char *s\)) 113.5814 Tj -0 -408.2145 Td -(5390 {) 26.2111 Tj -0 -417.7079 Td -(5391 int n;) 56.7907 Tj -0 -427.2012 Td -(5392 ) 21.8426 Tj -0 -436.6946 Td -(5393 for\(n = 0; s[n]; n++\)) 122.3184 Tj -0 -446.1879 Td -(5394 ;) 43.6851 Tj -0 -455.6813 Td -(5395 return n;) 69.8962 Tj -0 -465.1747 Td -(5396 }) 26.2111 Tj -0 -474.668 Td -(5397 ) 21.8426 Tj -0 -484.1614 Td -(5398 ) 21.8426 Tj -0 -493.6547 Td -(5399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 53) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 61 61 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mp.h Page 1) 152.898 Tj -0 -28.4801 Td -(5400 // See MultiProcessor Specification Version 1.[14]) 240.2683 Tj -0 -37.9735 Td -(5401 ) 21.8426 Tj -0 -47.4668 Td -(5402 struct mp { // floating pointer) 209.6887 Tj -0 -56.9602 Td -(5403 uchar signature[4]; // "_MP_") 200.9517 Tj -0 -66.4535 Td -(5404 void *physaddr; // phys addr of MP config \ -table) 297.059 Tj -0 -75.9469 Td -(5405 uchar length; // 1) 179.1091 Tj -0 -85.4403 Td -(5406 uchar specrev; // [14]) 192.2146 Tj -0 -94.9336 Td -(5407 uchar checksum; // all bytes must add up t\ -o 0) 288.322 Tj -0 -104.427 Td -(5408 uchar type; // MP system config type) 266.4794 Tj -0 -113.9203 Td -(5409 uchar imcrp;) 83.0018 Tj -0 -123.4137 Td -(5410 uchar reserved[3];) 109.2129 Tj -0 -132.9071 Td -(5411 };) 30.5796 Tj -0 -142.4004 Td -(5412 ) 21.8426 Tj -0 -151.8938 Td -(5413 struct mpconf { // configuration table header) 253.3738 Tj -0 -161.3871 Td -(5414 uchar signature[4]; // "PCMP") 200.9517 Tj -0 -170.8805 Td -(5415 ushort length; // total table length) 253.3738 Tj -0 -180.3739 Td -(5416 uchar version; // [14]) 192.2146 Tj -0 -189.8672 Td -(5417 uchar checksum; // all bytes must add up t\ -o 0) 288.322 Tj -0 -199.3606 Td -(5418 uchar product[20]; // product id) 218.4257 Tj -0 -208.8539 Td -(5419 uint *oemtable; // OEM table pointer) 249.0053 Tj -0 -218.3473 Td -(5420 ushort oemlength; // OEM table length) 244.6368 Tj -0 -227.8407 Td -(5421 ushort entry; // entry count) 222.7942 Tj -0 -237.334 Td -(5422 uint *lapicaddr; // address of local APIC) 266.4794 Tj -0 -246.8274 Td -(5423 ushort xlength; // extended table length) 266.4794 Tj -0 -256.3207 Td -(5424 uchar xchecksum; // extended table checksum) 275.2164 Tj -0 -265.8141 Td -(5425 uchar reserved;) 96.1073 Tj -0 -275.3075 Td -(5426 };) 30.5796 Tj -0 -284.8008 Td -(5427 ) 21.8426 Tj -0 -294.2942 Td -(5428 struct mpproc { // processor table entry) 231.5313 Tj -0 -303.7875 Td -(5429 uchar type; // entry type \(0\)) 235.8998 Tj -0 -313.2809 Td -(5430 uchar apicid; // local APIC id) 231.5313 Tj -0 -322.7743 Td -(5431 uchar version; // local APIC verison) 253.3738 Tj -0 -332.2676 Td -(5432 uchar flags; // CPU flags) 214.0572 Tj -0 -341.761 Td -(5433 #define MPBOOT 0x02 // This proc is the boot\ -strap processor.) 345.1126 Tj -0 -351.2543 Td -(5434 uchar signature[4]; // CPU signature) 231.5313 Tj -0 -360.7477 Td -(5435 uint feature; // feature flags from CPUI\ -D instruction) 332.0071 Tj -0 -370.2411 Td -(5436 uchar reserved[8];) 109.2129 Tj -0 -379.7344 Td -(5437 };) 30.5796 Tj -0 -389.2278 Td -(5438 ) 21.8426 Tj -0 -398.7211 Td -(5439 struct mpioapic { // I/O APIC table entry) 227.1628 Tj -0 -408.2145 Td -(5440 uchar type; // entry type \(2\)) 235.8998 Tj -0 -417.7079 Td -(5441 uchar apicno; // I/O APIC id) 222.7942 Tj -0 -427.2012 Td -(5442 uchar version; // I/O APIC version) 244.6368 Tj -0 -436.6946 Td -(5443 uchar flags; // I/O APIC flags) 235.8998 Tj -0 -446.1879 Td -(5444 uint *addr; // I/O APIC address) 240.2683 Tj -0 -455.6813 Td -(5445 };) 30.5796 Tj -0 -465.1747 Td -(5446 ) 21.8426 Tj -0 -474.668 Td -(5447 ) 21.8426 Tj -0 -484.1614 Td -(5448 ) 21.8426 Tj -0 -493.6547 Td -(5449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 54) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mp.h Page 2) 152.898 Tj -0 -28.4801 Td -(5450 // Table entry types) 109.2129 Tj -0 -37.9735 Td -(5451 #define MPPROC 0x00 // One per processor) 214.0572 Tj -0 -47.4668 Td -(5452 #define MPBUS 0x01 // One per bus) 187.8461 Tj -0 -56.9602 Td -(5453 #define MPIOAPIC 0x02 // One per I/O APIC) 209.6887 Tj -0 -66.4535 Td -(5454 #define MPIOINTR 0x03 // One per bus interrupt source) 262.1109 Tj -0 -75.9469 Td -(5455 #define MPLINTR 0x04 // One per system interrupt source) 275.2164 Tj -0 -85.4403 Td -(5456 ) 21.8426 Tj -0 -94.9336 Td -(5457 ) 21.8426 Tj -0 -104.427 Td -(5458 ) 21.8426 Tj -0 -113.9203 Td -(5459 ) 21.8426 Tj -0 -123.4137 Td -(5460 ) 21.8426 Tj -0 -132.9071 Td -(5461 ) 21.8426 Tj -0 -142.4004 Td -(5462 ) 21.8426 Tj -0 -151.8938 Td -(5463 ) 21.8426 Tj -0 -161.3871 Td -(5464 ) 21.8426 Tj -0 -170.8805 Td -(5465 ) 21.8426 Tj -0 -180.3739 Td -(5466 ) 21.8426 Tj -0 -189.8672 Td -(5467 ) 21.8426 Tj -0 -199.3606 Td -(5468 ) 21.8426 Tj -0 -208.8539 Td -(5469 ) 21.8426 Tj -0 -218.3473 Td -(5470 ) 21.8426 Tj -0 -227.8407 Td -(5471 ) 21.8426 Tj -0 -237.334 Td -(5472 ) 21.8426 Tj -0 -246.8274 Td -(5473 ) 21.8426 Tj -0 -256.3207 Td -(5474 ) 21.8426 Tj -0 -265.8141 Td -(5475 ) 21.8426 Tj -0 -275.3075 Td -(5476 ) 21.8426 Tj -0 -284.8008 Td -(5477 ) 21.8426 Tj -0 -294.2942 Td -(5478 ) 21.8426 Tj -0 -303.7875 Td -(5479 ) 21.8426 Tj -0 -313.2809 Td -(5480 ) 21.8426 Tj -0 -322.7743 Td -(5481 ) 21.8426 Tj -0 -332.2676 Td -(5482 ) 21.8426 Tj -0 -341.761 Td -(5483 ) 21.8426 Tj -0 -351.2543 Td -(5484 ) 21.8426 Tj -0 -360.7477 Td -(5485 ) 21.8426 Tj -0 -370.2411 Td -(5486 ) 21.8426 Tj -0 -379.7344 Td -(5487 ) 21.8426 Tj -0 -389.2278 Td -(5488 ) 21.8426 Tj -0 -398.7211 Td -(5489 ) 21.8426 Tj -0 -408.2145 Td -(5490 ) 21.8426 Tj -0 -417.7079 Td -(5491 ) 21.8426 Tj -0 -427.2012 Td -(5492 ) 21.8426 Tj -0 -436.6946 Td -(5493 ) 21.8426 Tj -0 -446.1879 Td -(5494 ) 21.8426 Tj -0 -455.6813 Td -(5495 ) 21.8426 Tj -0 -465.1747 Td -(5496 ) 21.8426 Tj -0 -474.668 Td -(5497 ) 21.8426 Tj -0 -484.1614 Td -(5498 ) 21.8426 Tj -0 -493.6547 Td -(5499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 54) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 62 62 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mp.c Page 1) 152.898 Tj -0 -28.4801 Td -(5500 // Multiprocessor bootstrap.) 144.161 Tj -0 -37.9735 Td -(5501 // Search memory for MP description structures.) 227.1628 Tj -0 -47.4668 Td -(5502 // http://developer.intel.com/design/pentium/datashts/2420\ -1606.pdf) 310.1645 Tj -0 -56.9602 Td -(5503 ) 21.8426 Tj -0 -66.4535 Td -(5504 #include "types.h") 100.4758 Tj -0 -75.9469 Td -(5505 #include "defs.h") 96.1073 Tj -0 -85.4403 Td -(5506 #include "param.h") 100.4758 Tj -0 -94.9336 Td -(5507 #include "mp.h") 87.3703 Tj -0 -104.427 Td -(5508 #include "x86.h") 91.7388 Tj -0 -113.9203 Td -(5509 #include "mmu.h") 91.7388 Tj -0 -123.4137 Td -(5510 #include "proc.h") 96.1073 Tj -0 -132.9071 Td -(5511 ) 21.8426 Tj -0 -142.4004 Td -(5512 struct cpu cpus[NCPU];) 117.9499 Tj -0 -151.8938 Td -(5513 static struct cpu *bcpu;) 126.6869 Tj -0 -161.3871 Td -(5514 int ismp;) 61.1592 Tj -0 -170.8805 Td -(5515 int ncpu;) 61.1592 Tj -0 -180.3739 Td -(5516 uchar ioapicid;) 87.3703 Tj -0 -189.8672 Td -(5517 ) 21.8426 Tj -0 -199.3606 Td -(5518 int) 34.9481 Tj -0 -208.8539 Td -(5519 mpbcpu\(void\)) 74.2647 Tj -0 -218.3473 Td -(5520 {) 26.2111 Tj -0 -227.8407 Td -(5521 return bcpu-cpus;) 104.8443 Tj -0 -237.334 Td -(5522 }) 26.2111 Tj -0 -246.8274 Td -(5523 ) 21.8426 Tj -0 -256.3207 Td -(5524 static uchar) 74.2647 Tj -0 -265.8141 Td -(5525 sum\(uchar *addr, int len\)) 131.0554 Tj -0 -275.3075 Td -(5526 {) 26.2111 Tj -0 -284.8008 Td -(5527 int i, sum;) 78.6333 Tj -0 -294.2942 Td -(5528 ) 21.8426 Tj -0 -303.7875 Td -(5529 sum = 0;) 65.5277 Tj -0 -313.2809 Td -(5530 for\(i=0; iphysaddr == 0\)) 235.8998 Tj -0 -370.2411 Td -(5586 return 0;) 78.6333 Tj -0 -379.7344 Td -(5587 conf = \(struct mpconf*\)mp->physaddr;) 187.8461 Tj -0 -389.2278 Td -(5588 if\(memcmp\(conf, "PCMP", 4\) != 0\)) 170.3721 Tj -0 -398.7211 Td -(5589 return 0;) 78.6333 Tj -0 -408.2145 Td -(5590 if\(conf->version != 1 && conf->version != 4\)) 222.7942 Tj -0 -417.7079 Td -(5591 return 0;) 78.6333 Tj -0 -427.2012 Td -(5592 if\(sum\(\(uchar*\)conf, conf->length\) != 0\)) 205.3202 Tj -0 -436.6946 Td -(5593 return 0;) 78.6333 Tj -0 -446.1879 Td -(5594 *pmp = mp;) 74.2647 Tj -0 -455.6813 Td -(5595 return conf;) 83.0018 Tj -0 -465.1747 Td -(5596 }) 26.2111 Tj -0 -474.668 Td -(5597 ) 21.8426 Tj -0 -484.1614 Td -(5598 ) 21.8426 Tj -0 -493.6547 Td -(5599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 55) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 63 63 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/mp.c Page 3) 152.898 Tj -0 -28.4801 Td -(5600 void) 39.3166 Tj -0 -37.9735 Td -(5601 mpinit\(void\)) 74.2647 Tj -0 -47.4668 Td -(5602 {) 26.2111 Tj -0 -56.9602 Td -(5603 uchar *p, *e;) 87.3703 Tj -0 -66.4535 Td -(5604 struct mp *mp;) 91.7388 Tj -0 -75.9469 Td -(5605 struct mpconf *conf;) 117.9499 Tj -0 -85.4403 Td -(5606 struct mpproc *proc;) 117.9499 Tj -0 -94.9336 Td -(5607 struct mpioapic *ioapic;) 135.4239 Tj -0 -104.427 Td -(5608 ) 21.8426 Tj -0 -113.9203 Td -(5609 bcpu = &cpus[0];) 100.4758 Tj -0 -123.4137 Td -(5610 if\(\(conf = mpconfig\(&mp\)\) == 0\)) 166.0035 Tj -0 -132.9071 Td -(5611 return;) 69.8962 Tj -0 -142.4004 Td -(5612 ismp = 1;) 69.8962 Tj -0 -151.8938 Td -(5613 lapic = \(uint*\)conf->lapicaddr;) 166.0035 Tj -0 -161.3871 Td -(5614 for\(p=\(uchar*\)\(conf+1\), e=\(uchar*\)conf+conf->leng\ -th; papicid\) {) 161.635 Tj -0 -208.8539 Td -(5619 cprintf\("mpinit: ncpu=%d apicpid=%d", ncpu, proc-\ ->apicid\);) 310.1645 Tj -0 -218.3473 Td -(5620 panic\("mpinit"\);) 126.6869 Tj -0 -227.8407 Td -(5621 }) 52.4222 Tj -0 -237.334 Td -(5622 if\(proc->flags & MPBOOT\)) 152.898 Tj -0 -246.8274 Td -(5623 bcpu = &cpus[ncpu];) 139.7925 Tj -0 -256.3207 Td -(5624 cpus[ncpu].id = ncpu;) 139.7925 Tj -0 -265.8141 Td -(5625 ncpu++;) 78.6333 Tj -0 -275.3075 Td -(5626 p += sizeof\(struct mpproc\);) 166.0035 Tj -0 -284.8008 Td -(5627 continue;) 87.3703 Tj -0 -294.2942 Td -(5628 case MPIOAPIC:) 100.4758 Tj -0 -303.7875 Td -(5629 ioapic = \(struct mpioapic*\)p;) 174.7406 Tj -0 -313.2809 Td -(5630 ioapicid = ioapic->apicno;) 161.635 Tj -0 -322.7743 Td -(5631 p += sizeof\(struct mpioapic\);) 174.7406 Tj -0 -332.2676 Td -(5632 continue;) 87.3703 Tj -0 -341.761 Td -(5633 case MPBUS:) 87.3703 Tj -0 -351.2543 Td -(5634 case MPIOINTR:) 100.4758 Tj -0 -360.7477 Td -(5635 case MPLINTR:) 96.1073 Tj -0 -370.2411 Td -(5636 p += 8;) 78.6333 Tj -0 -379.7344 Td -(5637 continue;) 87.3703 Tj -0 -389.2278 Td -(5638 default:) 74.2647 Tj -0 -398.7211 Td -(5639 cprintf\("mpinit: unknown config type %x\\n", *p\);) 257.7424 Tj -0 -408.2145 Td -(5640 panic\("mpinit"\);) 117.9499 Tj -0 -417.7079 Td -(5641 }) 43.6851 Tj -0 -427.2012 Td -(5642 }) 34.9481 Tj -0 -436.6946 Td -(5643 if\(mp->imcrp\){) 91.7388 Tj -0 -446.1879 Td -(5644 // Bochs doesn't support IMCR, so this doesn't run on \ -Bochs.) 301.4275 Tj -0 -455.6813 Td -(5645 // But it would on real hardware.) 183.4776 Tj -0 -465.1747 Td -(5646 outb\(0x22, 0x70\); // Select IMCR) 187.8461 Tj -0 -474.668 Td -(5647 outb\(0x23, inb\(0x23\) | 1\); // Mask external inter\ -rupts.) 283.9534 Tj -0 -484.1614 Td -(5648 }) 34.9481 Tj -0 -493.6547 Td -(5649 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 56) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/lapic.c Page 1) 166.0035 Tj -0 -28.4801 Td -(5650 // The local APIC manages internal \(non-I/O\) interrupts.) 266.4794 Tj -0 -37.9735 Td -(5651 // See Chapter 8 & Appendix C of Intel processor manual vo\ -lume 3.) 305.796 Tj -0 -47.4668 Td -(5652 ) 21.8426 Tj -0 -56.9602 Td -(5653 #include "types.h") 100.4758 Tj -0 -66.4535 Td -(5654 #include "defs.h") 96.1073 Tj -0 -75.9469 Td -(5655 #include "traps.h") 100.4758 Tj -0 -85.4403 Td -(5656 #include "mmu.h") 91.7388 Tj -0 -94.9336 Td -(5657 #include "x86.h") 91.7388 Tj -0 -104.427 Td -(5658 ) 21.8426 Tj -0 -113.9203 Td -(5659 // Local APIC registers, divided by 4 for use as uint[] in\ -dices.) 301.4275 Tj -0 -123.4137 Td -(5660 #define ID \(0x0020/4\) // ID) 170.3721 Tj -0 -132.9071 Td -(5661 #define VER \(0x0030/4\) // Version) 192.2146 Tj -0 -142.4004 Td -(5662 #define TPR \(0x0080/4\) // Task Priority) 218.4257 Tj -0 -151.8938 Td -(5663 #define EOI \(0x00B0/4\) // EOI) 174.7406 Tj -0 -161.3871 Td -(5664 #define SVR \(0x00F0/4\) // Spurious Interrupt Vecto\ -r) 270.8479 Tj -0 -170.8805 Td -(5665 #define ENABLE 0x00000100 // Unit Enable) 231.5313 Tj -0 -180.3739 Td -(5666 #define ESR \(0x0280/4\) // Error Status) 214.0572 Tj -0 -189.8672 Td -(5667 #define ICRLO \(0x0300/4\) // Interrupt Command) 235.8998 Tj -0 -199.3606 Td -(5668 #define INIT 0x00000500 // INIT/RESET) 227.1628 Tj -0 -208.8539 Td -(5669 #define STARTUP 0x00000600 // Startup IPI) 231.5313 Tj -0 -218.3473 Td -(5670 #define DELIVS 0x00001000 // Delivery status) 249.0053 Tj -0 -227.8407 Td -(5671 #define ASSERT 0x00004000 // Assert interrupt \(vs\ - deassert\)) 314.533 Tj -0 -237.334 Td -(5672 #define LEVEL 0x00008000 // Level triggered) 249.0053 Tj -0 -246.8274 Td -(5673 #define BCAST 0x00080000 // Send to all APICs, in\ -cluding self.) 332.0071 Tj -0 -256.3207 Td -(5674 #define ICRHI \(0x0310/4\) // Interrupt Command [63:32\ -]) 270.8479 Tj -0 -265.8141 Td -(5675 #define TIMER \(0x0320/4\) // Local Vector Table 0 \(T\ -IMER\)) 283.9534 Tj -0 -275.3075 Td -(5676 #define X1 0x0000000B // divide counts by 1) 262.1109 Tj -0 -284.8008 Td -(5677 #define PERIODIC 0x00020000 // Periodic) 218.4257 Tj -0 -294.2942 Td -(5678 #define PCINT \(0x0340/4\) // Performance Counter LVT) 262.1109 Tj -0 -303.7875 Td -(5679 #define LINT0 \(0x0350/4\) // Local Vector Table 1 \(L\ -INT0\)) 283.9534 Tj -0 -313.2809 Td -(5680 #define LINT1 \(0x0360/4\) // Local Vector Table 2 \(L\ -INT1\)) 283.9534 Tj -0 -322.7743 Td -(5681 #define ERROR \(0x0370/4\) // Local Vector Table 3 \(E\ -RROR\)) 283.9534 Tj -0 -332.2676 Td -(5682 #define MASKED 0x00010000 // Interrupt masked) 253.3738 Tj -0 -341.761 Td -(5683 #define TICR \(0x0380/4\) // Timer Initial Count) 244.6368 Tj -0 -351.2543 Td -(5684 #define TCCR \(0x0390/4\) // Timer Current Count) 244.6368 Tj -0 -360.7477 Td -(5685 #define TDCR \(0x03E0/4\) // Timer Divide Configurati\ -on) 275.2164 Tj -0 -370.2411 Td -(5686 ) 21.8426 Tj -0 -379.7344 Td -(5687 volatile uint *lapic; // Initialized in mp.c) 218.4257 Tj -0 -389.2278 Td -(5688 ) 21.8426 Tj -0 -398.7211 Td -(5689 static void) 69.8962 Tj -0 -408.2145 Td -(5690 lapicw\(int index, int value\)) 144.161 Tj -0 -417.7079 Td -(5691 {) 26.2111 Tj -0 -427.2012 Td -(5692 lapic[index] = value;) 122.3184 Tj -0 -436.6946 Td -(5693 lapic[ID]; // wait for write to finish, by reading) 253.3738 Tj -0 -446.1879 Td -(5694 }) 26.2111 Tj -0 -455.6813 Td -(5695 ) 21.8426 Tj -0 -465.1747 Td -(5696 ) 21.8426 Tj -0 -474.668 Td -(5697 ) 21.8426 Tj -0 -484.1614 Td -(5698 ) 21.8426 Tj -0 -493.6547 Td -(5699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 56) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 64 64 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/lapic.c Page 2) 166.0035 Tj -0 -28.4801 Td -(5700 void) 39.3166 Tj -0 -37.9735 Td -(5701 lapicinit\(int c\)) 91.7388 Tj -0 -47.4668 Td -(5702 {) 26.2111 Tj -0 -56.9602 Td -(5703 if\(!lapic\)) 74.2647 Tj -0 -66.4535 Td -(5704 return;) 69.8962 Tj -0 -75.9469 Td -(5705 ) 21.8426 Tj -0 -85.4403 Td -(5706 // Enable local APIC; set spurious interrupt vector.) 257.7424 Tj -0 -94.9336 Td -(5707 lapicw\(SVR, ENABLE | \(T_IRQ0 + IRQ_SPURIOUS\)\);) 231.5313 Tj -0 -104.427 Td -(5708 ) 21.8426 Tj -0 -113.9203 Td -(5709 // The timer repeatedly counts down at bus frequency) 257.7424 Tj -0 -123.4137 Td -(5710 // from lapic[TICR] and then issues an interrupt.) 244.6368 Tj -0 -132.9071 Td -(5711 // If xv6 cared more about precise timekeeping,) 235.8998 Tj -0 -142.4004 Td -(5712 // TICR would be calibrated using an external time sourc\ -e.) 283.9534 Tj -0 -151.8938 Td -(5713 lapicw\(TDCR, X1\);) 104.8443 Tj -0 -161.3871 Td -(5714 lapicw\(TIMER, PERIODIC | \(T_IRQ0 + IRQ_TIMER\)\);) 235.8998 Tj -0 -170.8805 Td -(5715 lapicw\(TICR, 10000000\);) 131.0554 Tj -0 -180.3739 Td -(5716 ) 21.8426 Tj -0 -189.8672 Td -(5717 // Disable logical interrupt lines.) 183.4776 Tj -0 -199.3606 Td -(5718 lapicw\(LINT0, MASKED\);) 126.6869 Tj -0 -208.8539 Td -(5719 lapicw\(LINT1, MASKED\);) 126.6869 Tj -0 -218.3473 Td -(5720 ) 21.8426 Tj -0 -227.8407 Td -(5721 // Disable performance counter overflow interrupts) 249.0053 Tj -0 -237.334 Td -(5722 // on machines that provide that interrupt entry.) 244.6368 Tj -0 -246.8274 Td -(5723 if\(\(\(lapic[VER]>>16\) & 0xFF\) >= 4\)) 179.1091 Tj -0 -256.3207 Td -(5724 lapicw\(PCINT, MASKED\);) 135.4239 Tj -0 -265.8141 Td -(5725 ) 21.8426 Tj -0 -275.3075 Td -(5726 // Map error interrupt to IRQ_ERROR.) 187.8461 Tj -0 -284.8008 Td -(5727 lapicw\(ERROR, T_IRQ0 + IRQ_ERROR\);) 179.1091 Tj -0 -294.2942 Td -(5728 ) 21.8426 Tj -0 -303.7875 Td -(5729 // Clear error status register \(requires back-to-back w\ -rites\).) 301.4275 Tj -0 -313.2809 Td -(5730 lapicw\(ESR, 0\);) 96.1073 Tj -0 -322.7743 Td -(5731 lapicw\(ESR, 0\);) 96.1073 Tj -0 -332.2676 Td -(5732 ) 21.8426 Tj -0 -341.761 Td -(5733 // Ack any outstanding interrupts.) 179.1091 Tj -0 -351.2543 Td -(5734 lapicw\(EOI, 0\);) 96.1073 Tj -0 -360.7477 Td -(5735 ) 21.8426 Tj -0 -370.2411 Td -(5736 // Send an Init Level De-Assert to synchronise arbitrati\ -on ID's.) 310.1645 Tj -0 -379.7344 Td -(5737 lapicw\(ICRHI, 0\);) 104.8443 Tj -0 -389.2278 Td -(5738 lapicw\(ICRLO, BCAST | INIT | LEVEL\);) 187.8461 Tj -0 -398.7211 Td -(5739 while\(lapic[ICRLO] & DELIVS\)) 152.898 Tj -0 -408.2145 Td -(5740 ;) 43.6851 Tj -0 -417.7079 Td -(5741 ) 21.8426 Tj -0 -427.2012 Td -(5742 // Enable interrupts on the APIC \(but not on the proces\ -sor\).) 292.6905 Tj -0 -436.6946 Td -(5743 lapicw\(TPR, 0\);) 96.1073 Tj -0 -446.1879 Td -(5744 }) 26.2111 Tj -0 -455.6813 Td -(5745 ) 21.8426 Tj -0 -465.1747 Td -(5746 ) 21.8426 Tj -0 -474.668 Td -(5747 ) 21.8426 Tj -0 -484.1614 Td -(5748 ) 21.8426 Tj -0 -493.6547 Td -(5749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 57) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/lapic.c Page 3) 166.0035 Tj -0 -28.4801 Td -(5750 int) 34.9481 Tj -0 -37.9735 Td -(5751 cpunum\(void\)) 74.2647 Tj -0 -47.4668 Td -(5752 {) 26.2111 Tj -0 -56.9602 Td -(5753 // Cannot call cpu when interrupts are enabled:) 235.8998 Tj -0 -66.4535 Td -(5754 // result not guaranteed to last long enough to be used!) 275.2164 Tj -0 -75.9469 Td -(5755 // Would prefer to panic but even printing is chancy her\ -e:) 283.9534 Tj -0 -85.4403 Td -(5756 // almost everything, including cprintf and panic, calls\ - cpu,) 297.059 Tj -0 -94.9336 Td -(5757 // often indirectly through acquire and release.) 240.2683 Tj -0 -104.427 Td -(5758 if\(readeflags\(\)&FL_IF\){) 131.0554 Tj -0 -113.9203 Td -(5759 static int n;) 96.1073 Tj -0 -123.4137 Td -(5760 if\(n++ == 0\)) 91.7388 Tj -0 -132.9071 Td -(5761 cprintf\("cpu called from %x with interrupts enabled\ -\\n",) 288.322 Tj -0 -142.4004 Td -(5762 __builtin_return_address\(0\)\);) 183.4776 Tj -0 -151.8938 Td -(5763 }) 34.9481 Tj -0 -161.3871 Td -(5764 ) 21.8426 Tj -0 -170.8805 Td -(5765 if\(lapic\)) 69.8962 Tj -0 -180.3739 Td -(5766 return lapic[ID]>>24;) 131.0554 Tj -0 -189.8672 Td -(5767 return 0;) 69.8962 Tj -0 -199.3606 Td -(5768 }) 26.2111 Tj -0 -208.8539 Td -(5769 ) 21.8426 Tj -0 -218.3473 Td -(5770 // Acknowledge interrupt.) 131.0554 Tj -0 -227.8407 Td -(5771 void) 39.3166 Tj -0 -237.334 Td -(5772 lapiceoi\(void\)) 83.0018 Tj -0 -246.8274 Td -(5773 {) 26.2111 Tj -0 -256.3207 Td -(5774 if\(lapic\)) 69.8962 Tj -0 -265.8141 Td -(5775 lapicw\(EOI, 0\);) 104.8443 Tj -0 -275.3075 Td -(5776 }) 26.2111 Tj -0 -284.8008 Td -(5777 ) 21.8426 Tj -0 -294.2942 Td -(5778 // Spin for a given number of microseconds.) 209.6887 Tj -0 -303.7875 Td -(5779 // On real hardware would want to tune this dynamically.) 266.4794 Tj -0 -313.2809 Td -(5780 void) 39.3166 Tj -0 -322.7743 Td -(5781 microdelay\(int us\)) 100.4758 Tj -0 -332.2676 Td -(5782 {) 26.2111 Tj -0 -341.761 Td -(5783 }) 26.2111 Tj -0 -351.2543 Td -(5784 ) 21.8426 Tj -0 -360.7477 Td -(5785 ) 21.8426 Tj -0 -370.2411 Td -(5786 #define IO_RTC 0x70) 109.2129 Tj -0 -379.7344 Td -(5787 ) 21.8426 Tj -0 -389.2278 Td -(5788 // Start additional processor running bootstrap code at ad\ -dr.) 288.322 Tj -0 -398.7211 Td -(5789 // See Appendix B of MultiProcessor Specification.) 240.2683 Tj -0 -408.2145 Td -(5790 void) 39.3166 Tj -0 -417.7079 Td -(5791 lapicstartap\(uchar apicid, uint addr\)) 183.4776 Tj -0 -427.2012 Td -(5792 {) 26.2111 Tj -0 -436.6946 Td -(5793 int i;) 56.7907 Tj -0 -446.1879 Td -(5794 ushort *wrv;) 83.0018 Tj -0 -455.6813 Td -(5795 ) 21.8426 Tj -0 -465.1747 Td -(5796 // "The BSP must initialize CMOS shutdown code to 0AH) 262.1109 Tj -0 -474.668 Td -(5797 // and the warm reset vector \(DWORD based at 40:67\) to\ - point at) 305.796 Tj -0 -484.1614 Td -(5798 // the AP startup code prior to the [universal startup a\ -lgorithm].") 323.2701 Tj -0 -493.6547 Td -(5799 outb\(IO_RTC, 0xF\); // offset 0xF is shutdown code) 249.0053 Tj -0 -522.1348 Td -(Sheet 57) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 65 65 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/lapic.c Page 4) 166.0035 Tj -0 -28.4801 Td -(5800 outb\(IO_RTC+1, 0x0A\);) 122.3184 Tj -0 -37.9735 Td -(5801 wrv = \(ushort*\)\(0x40<<4 | 0x67\); // Warm reset vect\ -or) 266.4794 Tj -0 -47.4668 Td -(5802 wrv[0] = 0;) 78.6333 Tj -0 -56.9602 Td -(5803 wrv[1] = addr >> 4;) 113.5814 Tj -0 -66.4535 Td -(5804 ) 21.8426 Tj -0 -75.9469 Td -(5805 // "Universal startup algorithm.") 174.7406 Tj -0 -85.4403 Td -(5806 // Send INIT \(level-triggered\) interrupt to reset othe\ -r CPU.) 292.6905 Tj -0 -94.9336 Td -(5807 lapicw\(ICRHI, apicid<<24\);) 144.161 Tj -0 -104.427 Td -(5808 lapicw\(ICRLO, INIT | LEVEL | ASSERT\);) 192.2146 Tj -0 -113.9203 Td -(5809 microdelay\(200\);) 100.4758 Tj -0 -123.4137 Td -(5810 lapicw\(ICRLO, INIT | LEVEL\);) 152.898 Tj -0 -132.9071 Td -(5811 microdelay\(100\); // should be 10ms, but too slow in\ - Bochs!) 297.059 Tj -0 -142.4004 Td -(5812 ) 21.8426 Tj -0 -151.8938 Td -(5813 // Send startup IPI \(twice!\) to enter bootstrap code.) 262.1109 Tj -0 -161.3871 Td -(5814 // Regular hardware is supposed to only accept a STARTUP) 275.2164 Tj -0 -170.8805 Td -(5815 // when it is in the halted state due to an INIT. So th\ -e second) 310.1645 Tj -0 -180.3739 Td -(5816 // should be ignored, but it is part of the official Int\ -el algorithm.) 332.0071 Tj -0 -189.8672 Td -(5817 // Bochs complains about the second one. Too bad for Bo\ -chs.) 292.6905 Tj -0 -199.3606 Td -(5818 for\(i = 0; i < 2; i++\){) 131.0554 Tj -0 -208.8539 Td -(5819 lapicw\(ICRHI, apicid<<24\);) 152.898 Tj -0 -218.3473 Td -(5820 lapicw\(ICRLO, STARTUP | \(addr>>12\)\);) 196.5831 Tj -0 -227.8407 Td -(5821 microdelay\(200\);) 109.2129 Tj -0 -237.334 Td -(5822 }) 34.9481 Tj -0 -246.8274 Td -(5823 }) 26.2111 Tj -0 -256.3207 Td -(5824 ) 21.8426 Tj -0 -265.8141 Td -(5825 ) 21.8426 Tj -0 -275.3075 Td -(5826 ) 21.8426 Tj -0 -284.8008 Td -(5827 ) 21.8426 Tj -0 -294.2942 Td -(5828 ) 21.8426 Tj -0 -303.7875 Td -(5829 ) 21.8426 Tj -0 -313.2809 Td -(5830 ) 21.8426 Tj -0 -322.7743 Td -(5831 ) 21.8426 Tj -0 -332.2676 Td -(5832 ) 21.8426 Tj -0 -341.761 Td -(5833 ) 21.8426 Tj -0 -351.2543 Td -(5834 ) 21.8426 Tj -0 -360.7477 Td -(5835 ) 21.8426 Tj -0 -370.2411 Td -(5836 ) 21.8426 Tj -0 -379.7344 Td -(5837 ) 21.8426 Tj -0 -389.2278 Td -(5838 ) 21.8426 Tj -0 -398.7211 Td -(5839 ) 21.8426 Tj -0 -408.2145 Td -(5840 ) 21.8426 Tj -0 -417.7079 Td -(5841 ) 21.8426 Tj -0 -427.2012 Td -(5842 ) 21.8426 Tj -0 -436.6946 Td -(5843 ) 21.8426 Tj -0 -446.1879 Td -(5844 ) 21.8426 Tj -0 -455.6813 Td -(5845 ) 21.8426 Tj -0 -465.1747 Td -(5846 ) 21.8426 Tj -0 -474.668 Td -(5847 ) 21.8426 Tj -0 -484.1614 Td -(5848 ) 21.8426 Tj -0 -493.6547 Td -(5849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 58) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ioapic.c Page 1) 170.3721 Tj -0 -28.4801 Td -(5850 // The I/O APIC manages hardware interrupts for an SMP sys\ -tem.) 292.6905 Tj -0 -37.9735 Td -(5851 // http://www.intel.com/design/chipsets/datashts/29056601.\ -pdf) 288.322 Tj -0 -47.4668 Td -(5852 // See also picirq.c.) 113.5814 Tj -0 -56.9602 Td -(5853 ) 21.8426 Tj -0 -66.4535 Td -(5854 #include "types.h") 100.4758 Tj -0 -75.9469 Td -(5855 #include "defs.h") 96.1073 Tj -0 -85.4403 Td -(5856 #include "traps.h") 100.4758 Tj -0 -94.9336 Td -(5857 ) 21.8426 Tj -0 -104.427 Td -(5858 #define IOAPIC 0xFEC00000 // Default physical address o\ -f IO APIC) 314.533 Tj -0 -113.9203 Td -(5859 ) 21.8426 Tj -0 -123.4137 Td -(5860 #define REG_ID 0x00 // Register index: ID) 222.7942 Tj -0 -132.9071 Td -(5861 #define REG_VER 0x01 // Register index: version) 244.6368 Tj -0 -142.4004 Td -(5862 #define REG_TABLE 0x10 // Redirection table base) 240.2683 Tj -0 -151.8938 Td -(5863 ) 21.8426 Tj -0 -161.3871 Td -(5864 // The redirection table starts at REG_TABLE and uses) 253.3738 Tj -0 -170.8805 Td -(5865 // two registers to configure each interrupt.) 218.4257 Tj -0 -180.3739 Td -(5866 // The first \(low\) register in a pair contains configura\ -tion bits.) 310.1645 Tj -0 -189.8672 Td -(5867 // The second \(high\) register contains a bitmask telling\ - which) 292.6905 Tj -0 -199.3606 Td -(5868 // CPUs can serve that interrupt.) 166.0035 Tj -0 -208.8539 Td -(5869 #define INT_DISABLED 0x00010000 // Interrupt disabled) 266.4794 Tj -0 -218.3473 Td -(5870 #define INT_LEVEL 0x00008000 // Level-triggered \(vs\ - edge-\)) 301.4275 Tj -0 -227.8407 Td -(5871 #define INT_ACTIVELOW 0x00002000 // Active low \(vs high\ -\)) 275.2164 Tj -0 -237.334 Td -(5872 #define INT_LOGICAL 0x00000800 // Destination is CPU i\ -d \(vs APIC ID\)) 336.3756 Tj -0 -246.8274 Td -(5873 ) 21.8426 Tj -0 -256.3207 Td -(5874 volatile struct ioapic *ioapic;) 157.2665 Tj -0 -265.8141 Td -(5875 ) 21.8426 Tj -0 -275.3075 Td -(5876 // IO APIC MMIO structure: write reg, then read or write d\ -ata.) 292.6905 Tj -0 -284.8008 Td -(5877 struct ioapic {) 87.3703 Tj -0 -294.2942 Td -(5878 uint reg;) 69.8962 Tj -0 -303.7875 Td -(5879 uint pad[3];) 83.0018 Tj -0 -313.2809 Td -(5880 uint data;) 74.2647 Tj -0 -322.7743 Td -(5881 };) 30.5796 Tj -0 -332.2676 Td -(5882 ) 21.8426 Tj -0 -341.761 Td -(5883 static uint) 69.8962 Tj -0 -351.2543 Td -(5884 ioapicread\(int reg\)) 104.8443 Tj -0 -360.7477 Td -(5885 {) 26.2111 Tj -0 -370.2411 Td -(5886 ioapic->reg = reg;) 109.2129 Tj -0 -379.7344 Td -(5887 return ioapic->data;) 117.9499 Tj -0 -389.2278 Td -(5888 }) 26.2111 Tj -0 -398.7211 Td -(5889 ) 21.8426 Tj -0 -408.2145 Td -(5890 static void) 69.8962 Tj -0 -417.7079 Td -(5891 ioapicwrite\(int reg, uint data\)) 157.2665 Tj -0 -427.2012 Td -(5892 {) 26.2111 Tj -0 -436.6946 Td -(5893 ioapic->reg = reg;) 109.2129 Tj -0 -446.1879 Td -(5894 ioapic->data = data;) 117.9499 Tj -0 -455.6813 Td -(5895 }) 26.2111 Tj -0 -465.1747 Td -(5896 ) 21.8426 Tj -0 -474.668 Td -(5897 ) 21.8426 Tj -0 -484.1614 Td -(5898 ) 21.8426 Tj -0 -493.6547 Td -(5899 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 58) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 66 66 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/ioapic.c Page 2) 170.3721 Tj -0 -28.4801 Td -(5900 void) 39.3166 Tj -0 -37.9735 Td -(5901 ioapicinit\(void\)) 91.7388 Tj -0 -47.4668 Td -(5902 {) 26.2111 Tj -0 -56.9602 Td -(5903 int i, id, maxintr;) 113.5814 Tj -0 -66.4535 Td -(5904 ) 21.8426 Tj -0 -75.9469 Td -(5905 if\(!ismp\)) 69.8962 Tj -0 -85.4403 Td -(5906 return;) 69.8962 Tj -0 -94.9336 Td -(5907 ) 21.8426 Tj -0 -104.427 Td -(5908 ioapic = \(volatile struct ioapic*\)IOAPIC;) 209.6887 Tj -0 -113.9203 Td -(5909 maxintr = \(ioapicread\(REG_VER\) >> 16\) & 0xFF;) 227.1628 Tj -0 -123.4137 Td -(5910 id = ioapicread\(REG_ID\) >> 24;) 161.635 Tj -0 -132.9071 Td -(5911 if\(id != ioapicid\)) 109.2129 Tj -0 -142.4004 Td -(5912 cprintf\("ioapicinit: id isn't equal to ioapicid; not \ -a MP\\n"\);) 310.1645 Tj -0 -151.8938 Td -(5913 ) 21.8426 Tj -0 -161.3871 Td -(5914 // Mark all interrupts edge-triggered, active high, disa\ -bled,) 297.059 Tj -0 -170.8805 Td -(5915 // and not routed to any CPUs.) 161.635 Tj -0 -180.3739 Td -(5916 for\(i = 0; i <= maxintr; i++\){) 161.635 Tj -0 -189.8672 Td -(5917 ioapicwrite\(REG_TABLE+2*i, INT_DISABLED | \(T_IRQ0 + \ -i\)\);) 283.9534 Tj -0 -199.3606 Td -(5918 ioapicwrite\(REG_TABLE+2*i+1, 0\);) 179.1091 Tj -0 -208.8539 Td -(5919 }) 34.9481 Tj -0 -218.3473 Td -(5920 }) 26.2111 Tj -0 -227.8407 Td -(5921 ) 21.8426 Tj -0 -237.334 Td -(5922 void) 39.3166 Tj -0 -246.8274 Td -(5923 ioapicenable\(int irq, int cpunum\)) 166.0035 Tj -0 -256.3207 Td -(5924 {) 26.2111 Tj -0 -265.8141 Td -(5925 if\(!ismp\)) 69.8962 Tj -0 -275.3075 Td -(5926 return;) 69.8962 Tj -0 -284.8008 Td -(5927 ) 21.8426 Tj -0 -294.2942 Td -(5928 // Mark interrupt edge-triggered, active high,) 231.5313 Tj -0 -303.7875 Td -(5929 // enabled, and routed to the given cpunum,) 218.4257 Tj -0 -313.2809 Td -(5930 // which happens to be that cpu's APIC ID.) 214.0572 Tj -0 -322.7743 Td -(5931 ioapicwrite\(REG_TABLE+2*irq, T_IRQ0 + irq\);) 218.4257 Tj -0 -332.2676 Td -(5932 ioapicwrite\(REG_TABLE+2*irq+1, cpunum << 24\);) 227.1628 Tj -0 -341.761 Td -(5933 }) 26.2111 Tj -0 -351.2543 Td -(5934 ) 21.8426 Tj -0 -360.7477 Td -(5935 ) 21.8426 Tj -0 -370.2411 Td -(5936 ) 21.8426 Tj -0 -379.7344 Td -(5937 ) 21.8426 Tj -0 -389.2278 Td -(5938 ) 21.8426 Tj -0 -398.7211 Td -(5939 ) 21.8426 Tj -0 -408.2145 Td -(5940 ) 21.8426 Tj -0 -417.7079 Td -(5941 ) 21.8426 Tj -0 -427.2012 Td -(5942 ) 21.8426 Tj -0 -436.6946 Td -(5943 ) 21.8426 Tj -0 -446.1879 Td -(5944 ) 21.8426 Tj -0 -455.6813 Td -(5945 ) 21.8426 Tj -0 -465.1747 Td -(5946 ) 21.8426 Tj -0 -474.668 Td -(5947 ) 21.8426 Tj -0 -484.1614 Td -(5948 ) 21.8426 Tj -0 -493.6547 Td -(5949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 59) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/picirq.c Page 1) 170.3721 Tj -0 -28.4801 Td -(5950 // Intel 8259A programmable interrupt controllers.) 240.2683 Tj -0 -37.9735 Td -(5951 ) 21.8426 Tj -0 -47.4668 Td -(5952 #include "types.h") 100.4758 Tj -0 -56.9602 Td -(5953 #include "x86.h") 91.7388 Tj -0 -66.4535 Td -(5954 #include "traps.h") 100.4758 Tj -0 -75.9469 Td -(5955 ) 21.8426 Tj -0 -85.4403 Td -(5956 // I/O Addresses of the two programmable interrupt control\ -lers) 292.6905 Tj -0 -94.9336 Td -(5957 #define IO_PIC1 0x20 // Master \(IRQs 0-7\)) 249.0053 Tj -0 -104.427 Td -(5958 #define IO_PIC2 0xA0 // Slave \(IRQs 8-15\)) 249.0053 Tj -0 -113.9203 Td -(5959 ) 21.8426 Tj -0 -123.4137 Td -(5960 #define IRQ_SLAVE 2 // IRQ at which slave conn\ -ects to master) 336.3756 Tj -0 -132.9071 Td -(5961 ) 21.8426 Tj -0 -142.4004 Td -(5962 // Current IRQ mask.) 109.2129 Tj -0 -151.8938 Td -(5963 // Initial IRQ mask has interrupt 2 enabled \(for slave 82\ -59A\).) 292.6905 Tj -0 -161.3871 Td -(5964 static ushort irqmask = 0xFFFF & ~\(1<> 8\);) 148.5295 Tj -0 -237.334 Td -(5972 }) 26.2111 Tj -0 -246.8274 Td -(5973 ) 21.8426 Tj -0 -256.3207 Td -(5974 void) 39.3166 Tj -0 -265.8141 Td -(5975 picenable\(int irq\)) 100.4758 Tj -0 -275.3075 Td -(5976 {) 26.2111 Tj -0 -284.8008 Td -(5977 picsetmask\(irqmask & ~\(1<', '?', NO, '*', // 0x30) 270.8479 Tj -0 -322.7743 Td -(6181 NO, ' ', NO, NO, NO, NO, NO, NO,) 227.1628 Tj -0 -332.2676 Td -(6182 NO, NO, NO, NO, NO, NO, NO, '7', // 0x40) 270.8479 Tj -0 -341.761 Td -(6183 '8', '9', '-', '4', '5', '6', '+', '1',) 231.5313 Tj -0 -351.2543 Td -(6184 '2', '3', '0', '.', NO, NO, NO, NO, // 0x50) 270.8479 Tj -0 -360.7477 Td -(6185 [0x9C] '\\n', // KP_Enter) 157.2665 Tj -0 -370.2411 Td -(6186 [0xB5] '/', // KP_Div) 148.5295 Tj -0 -379.7344 Td -(6187 [0xC8] KEY_UP, [0xD0] KEY_DN,) 170.3721 Tj -0 -389.2278 Td -(6188 [0xC9] KEY_PGUP, [0xD1] KEY_PGDN,) 179.1091 Tj -0 -398.7211 Td -(6189 [0xCB] KEY_LF, [0xCD] KEY_RT,) 170.3721 Tj -0 -408.2145 Td -(6190 [0x97] KEY_HOME, [0xCF] KEY_END,) 174.7406 Tj -0 -417.7079 Td -(6191 [0xD2] KEY_INS, [0xD3] KEY_DEL) 170.3721 Tj -0 -427.2012 Td -(6192 };) 30.5796 Tj -0 -436.6946 Td -(6193 ) 21.8426 Tj -0 -446.1879 Td -(6194 ) 21.8426 Tj -0 -455.6813 Td -(6195 ) 21.8426 Tj -0 -465.1747 Td -(6196 ) 21.8426 Tj -0 -474.668 Td -(6197 ) 21.8426 Tj -0 -484.1614 Td -(6198 ) 21.8426 Tj -0 -493.6547 Td -(6199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 61) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 69 69 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/kbd.h Page 3) 157.2665 Tj -0 -28.4801 Td -(6200 static uchar ctlmap[256] =) 135.4239 Tj -0 -37.9735 Td -(6201 {) 26.2111 Tj -0 -47.4668 Td -(6202 NO, NO, NO, NO, NO, NO, NO\ -, NO,) 318.9016 Tj -0 -56.9602 Td -(6203 NO, NO, NO, NO, NO, NO, NO\ -, NO,) 318.9016 Tj -0 -66.4535 Td -(6204 C\('Q'\), C\('W'\), C\('E'\), C\('R'\), C\('T'\), C\ -\('Y'\), C\('U'\), C\('I'\),) 336.3756 Tj -0 -75.9469 Td -(6205 C\('O'\), C\('P'\), NO, NO, '\\r', NO, \ - C\('A'\), C\('S'\),) 336.3756 Tj -0 -85.4403 Td -(6206 C\('D'\), C\('F'\), C\('G'\), C\('H'\), C\('J'\), C\ -\('K'\), C\('L'\), NO,) 318.9016 Tj -0 -94.9336 Td -(6207 NO, NO, NO, C\('\\\\'\), C\('Z'\), C\('X\ -'\), C\('C'\), C\('V'\),) 336.3756 Tj -0 -104.427 Td -(6208 C\('B'\), C\('N'\), C\('M'\), NO, NO, C\('/\ -'\), NO, NO,) 318.9016 Tj -0 -113.9203 Td -(6209 [0x9C] '\\r', // KP_Enter) 157.2665 Tj -0 -123.4137 Td -(6210 [0xB5] C\('/'\), // KP_Div) 148.5295 Tj -0 -132.9071 Td -(6211 [0xC8] KEY_UP, [0xD0] KEY_DN,) 170.3721 Tj -0 -142.4004 Td -(6212 [0xC9] KEY_PGUP, [0xD1] KEY_PGDN,) 179.1091 Tj -0 -151.8938 Td -(6213 [0xCB] KEY_LF, [0xCD] KEY_RT,) 170.3721 Tj -0 -161.3871 Td -(6214 [0x97] KEY_HOME, [0xCF] KEY_END,) 174.7406 Tj -0 -170.8805 Td -(6215 [0xD2] KEY_INS, [0xD3] KEY_DEL) 170.3721 Tj -0 -180.3739 Td -(6216 };) 30.5796 Tj -0 -189.8672 Td -(6217 ) 21.8426 Tj -0 -199.3606 Td -(6218 ) 21.8426 Tj -0 -208.8539 Td -(6219 ) 21.8426 Tj -0 -218.3473 Td -(6220 ) 21.8426 Tj -0 -227.8407 Td -(6221 ) 21.8426 Tj -0 -237.334 Td -(6222 ) 21.8426 Tj -0 -246.8274 Td -(6223 ) 21.8426 Tj -0 -256.3207 Td -(6224 ) 21.8426 Tj -0 -265.8141 Td -(6225 ) 21.8426 Tj -0 -275.3075 Td -(6226 ) 21.8426 Tj -0 -284.8008 Td -(6227 ) 21.8426 Tj -0 -294.2942 Td -(6228 ) 21.8426 Tj -0 -303.7875 Td -(6229 ) 21.8426 Tj -0 -313.2809 Td -(6230 ) 21.8426 Tj -0 -322.7743 Td -(6231 ) 21.8426 Tj -0 -332.2676 Td -(6232 ) 21.8426 Tj -0 -341.761 Td -(6233 ) 21.8426 Tj -0 -351.2543 Td -(6234 ) 21.8426 Tj -0 -360.7477 Td -(6235 ) 21.8426 Tj -0 -370.2411 Td -(6236 ) 21.8426 Tj -0 -379.7344 Td -(6237 ) 21.8426 Tj -0 -389.2278 Td -(6238 ) 21.8426 Tj -0 -398.7211 Td -(6239 ) 21.8426 Tj -0 -408.2145 Td -(6240 ) 21.8426 Tj -0 -417.7079 Td -(6241 ) 21.8426 Tj -0 -427.2012 Td -(6242 ) 21.8426 Tj -0 -436.6946 Td -(6243 ) 21.8426 Tj -0 -446.1879 Td -(6244 ) 21.8426 Tj -0 -455.6813 Td -(6245 ) 21.8426 Tj -0 -465.1747 Td -(6246 ) 21.8426 Tj -0 -474.668 Td -(6247 ) 21.8426 Tj -0 -484.1614 Td -(6248 ) 21.8426 Tj -0 -493.6547 Td -(6249 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 62) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/kbd.c Page 1) 157.2665 Tj -0 -28.4801 Td -(6250 #include "types.h") 100.4758 Tj -0 -37.9735 Td -(6251 #include "x86.h") 91.7388 Tj -0 -47.4668 Td -(6252 #include "defs.h") 96.1073 Tj -0 -56.9602 Td -(6253 #include "kbd.h") 91.7388 Tj -0 -66.4535 Td -(6254 ) 21.8426 Tj -0 -75.9469 Td -(6255 int) 34.9481 Tj -0 -85.4403 Td -(6256 kbdgetc\(void\)) 78.6333 Tj -0 -94.9336 Td -(6257 {) 26.2111 Tj -0 -104.427 Td -(6258 static uint shift;) 109.2129 Tj -0 -113.9203 Td -(6259 static uchar *charcode[4] = {) 157.2665 Tj -0 -123.4137 Td -(6260 normalmap, shiftmap, ctlmap, ctlmap) 192.2146 Tj -0 -132.9071 Td -(6261 };) 39.3166 Tj -0 -142.4004 Td -(6262 uint st, data, c;) 104.8443 Tj -0 -151.8938 Td -(6263 ) 21.8426 Tj -0 -161.3871 Td -(6264 st = inb\(KBSTATP\);) 109.2129 Tj -0 -170.8805 Td -(6265 if\(\(st & KBS_DIB\) == 0\)) 131.0554 Tj -0 -180.3739 Td -(6266 return -1;) 83.0018 Tj -0 -189.8672 Td -(6267 data = inb\(KBDATAP\);) 117.9499 Tj -0 -199.3606 Td -(6268 ) 21.8426 Tj -0 -208.8539 Td -(6269 if\(data == 0xE0\){) 104.8443 Tj -0 -218.3473 Td -(6270 shift |= E0ESC;) 104.8443 Tj -0 -227.8407 Td -(6271 return 0;) 78.6333 Tj -0 -237.334 Td -(6272 } else if\(data & 0x80\){) 131.0554 Tj -0 -246.8274 Td -(6273 // Key released) 104.8443 Tj -0 -256.3207 Td -(6274 data = \(shift & E0ESC ? data : data & 0x7F\);) 231.5313 Tj -0 -265.8141 Td -(6275 shift &= ~\(shiftcode[data] | E0ESC\);) 196.5831 Tj -0 -275.3075 Td -(6276 return 0;) 78.6333 Tj -0 -284.8008 Td -(6277 } else if\(shift & E0ESC\){) 139.7925 Tj -0 -294.2942 Td -(6278 // Last character was an E0 escape; or with 0x80) 249.0053 Tj -0 -303.7875 Td -(6279 data |= 0x80;) 96.1073 Tj -0 -313.2809 Td -(6280 shift &= ~E0ESC;) 109.2129 Tj -0 -322.7743 Td -(6281 }) 34.9481 Tj -0 -332.2676 Td -(6282 ) 21.8426 Tj -0 -341.761 Td -(6283 shift |= shiftcode[data];) 139.7925 Tj -0 -351.2543 Td -(6284 shift ^= togglecode[data];) 144.161 Tj -0 -360.7477 Td -(6285 c = charcode[shift & \(CTL | SHIFT\)][data];) 214.0572 Tj -0 -370.2411 Td -(6286 if\(shift & CAPSLOCK\){) 122.3184 Tj -0 -379.7344 Td -(6287 if\('a' <= c && c <= 'z'\)) 144.161 Tj -0 -389.2278 Td -(6288 c += 'A' - 'a';) 113.5814 Tj -0 -398.7211 Td -(6289 else if\('A' <= c && c <= 'Z'\)) 166.0035 Tj -0 -408.2145 Td -(6290 c += 'a' - 'A';) 113.5814 Tj -0 -417.7079 Td -(6291 }) 34.9481 Tj -0 -427.2012 Td -(6292 return c;) 69.8962 Tj -0 -436.6946 Td -(6293 }) 26.2111 Tj -0 -446.1879 Td -(6294 ) 21.8426 Tj -0 -455.6813 Td -(6295 void) 39.3166 Tj -0 -465.1747 Td -(6296 kbdintr\(void\)) 78.6333 Tj -0 -474.668 Td -(6297 {) 26.2111 Tj -0 -484.1614 Td -(6298 consoleintr\(kbdgetc\);) 122.3184 Tj -0 -493.6547 Td -(6299 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 62) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 70 70 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 1) 174.7406 Tj -0 -28.4801 Td -(6300 // Console input and output.) 144.161 Tj -0 -37.9735 Td -(6301 // Input is from the keyboard or serial port.) 218.4257 Tj -0 -47.4668 Td -(6302 // Output is written to the screen and serial port.) 244.6368 Tj -0 -56.9602 Td -(6303 ) 21.8426 Tj -0 -66.4535 Td -(6304 #include "types.h") 100.4758 Tj -0 -75.9469 Td -(6305 #include "defs.h") 96.1073 Tj -0 -85.4403 Td -(6306 #include "param.h") 100.4758 Tj -0 -94.9336 Td -(6307 #include "traps.h") 100.4758 Tj -0 -104.427 Td -(6308 #include "spinlock.h") 113.5814 Tj -0 -113.9203 Td -(6309 #include "fs.h") 87.3703 Tj -0 -123.4137 Td -(6310 #include "file.h") 96.1073 Tj -0 -132.9071 Td -(6311 #include "mmu.h") 91.7388 Tj -0 -142.4004 Td -(6312 #include "proc.h") 96.1073 Tj -0 -151.8938 Td -(6313 #include "x86.h") 91.7388 Tj -0 -161.3871 Td -(6314 ) 21.8426 Tj -0 -170.8805 Td -(6315 static void consputc\(int\);) 135.4239 Tj -0 -180.3739 Td -(6316 ) 21.8426 Tj -0 -189.8672 Td -(6317 static int panicked = 0;) 126.6869 Tj -0 -199.3606 Td -(6318 ) 21.8426 Tj -0 -208.8539 Td -(6319 static struct {) 87.3703 Tj -0 -218.3473 Td -(6320 ) 21.8426 Tj --1504.73 TJm -(struct spinlock lock;) 91.7388 Tj -0 -227.8407 Td -(6321 ) 21.8426 Tj --1504.73 TJm -(int locking;) 52.4222 Tj -0 -237.334 Td -(6322 } cons;) 52.4222 Tj -0 -246.8274 Td -(6323 ) 21.8426 Tj -0 -256.3207 Td -(6324 static void) 69.8962 Tj -0 -265.8141 Td -(6325 printint\(int xx, int base, int sgn\)) 174.7406 Tj -0 -275.3075 Td -(6326 {) 26.2111 Tj -0 -284.8008 Td -(6327 static char digits[] = "0123456789abcdef";) 214.0572 Tj -0 -294.2942 Td -(6328 char buf[16];) 87.3703 Tj -0 -303.7875 Td -(6329 int i = 0, neg = 0;) 113.5814 Tj -0 -313.2809 Td -(6330 uint x;) 61.1592 Tj -0 -322.7743 Td -(6331 ) 21.8426 Tj -0 -332.2676 Td -(6332 if\(sgn && xx < 0\){) 109.2129 Tj -0 -341.761 Td -(6333 neg = 1;) 74.2647 Tj -0 -351.2543 Td -(6334 x = -xx;) 74.2647 Tj -0 -360.7477 Td -(6335 } else) 56.7907 Tj -0 -370.2411 Td -(6336 x = xx;) 69.8962 Tj -0 -379.7344 Td -(6337 ) 21.8426 Tj -0 -389.2278 Td -(6338 do{) 43.6851 Tj -0 -398.7211 Td -(6339 buf[i++] = digits[x % base];) 161.635 Tj -0 -408.2145 Td -(6340 }while\(\(x /= base\) != 0\);) 139.7925 Tj -0 -417.7079 Td -(6341 if\(neg\)) 61.1592 Tj -0 -427.2012 Td -(6342 buf[i++] = '-';) 104.8443 Tj -0 -436.6946 Td -(6343 ) 21.8426 Tj -0 -446.1879 Td -(6344 while\(--i >= 0\)) 96.1073 Tj -0 -455.6813 Td -(6345 consputc\(buf[i]\);) 113.5814 Tj -0 -465.1747 Td -(6346 }) 26.2111 Tj -0 -474.668 Td -(6347 ) 21.8426 Tj -0 -484.1614 Td -(6348 ) 21.8426 Tj -0 -493.6547 Td -(6349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 63) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 2) 174.7406 Tj -0 -28.4801 Td -(6350 // Print to the console. only understands %d, %x, %p, %s.) 270.8479 Tj -0 -37.9735 Td -(6351 void) 39.3166 Tj -0 -47.4668 Td -(6352 cprintf\(char *fmt, ...\)) 122.3184 Tj -0 -56.9602 Td -(6353 {) 26.2111 Tj -0 -66.4535 Td -(6354 int i, c, state, locking;) 139.7925 Tj -0 -75.9469 Td -(6355 uint *argp;) 78.6333 Tj -0 -85.4403 Td -(6356 char *s;) 65.5277 Tj -0 -94.9336 Td -(6357 ) 21.8426 Tj -0 -104.427 Td -(6358 locking = cons.locking;) 131.0554 Tj -0 -113.9203 Td -(6359 if\(locking\)) 78.6333 Tj -0 -123.4137 Td -(6360 acquire\(&cons.lock\);) 126.6869 Tj -0 -132.9071 Td -(6361 ) 21.8426 Tj -0 -142.4004 Td -(6362 argp = \(uint*\)\(void*\)\(&fmt + 1\);) 170.3721 Tj -0 -151.8938 Td -(6363 state = 0;) 74.2647 Tj -0 -161.3871 Td -(6364 for\(i = 0; \(c = fmt[i] & 0xff\) != 0; i++\){) 214.0572 Tj -0 -170.8805 Td -(6365 if\(c != '%'\){) 96.1073 Tj -0 -180.3739 Td -(6366 consputc\(c\);) 100.4758 Tj -0 -189.8672 Td -(6367 continue;) 87.3703 Tj -0 -199.3606 Td -(6368 }) 43.6851 Tj -0 -208.8539 Td -(6369 c = fmt[++i] & 0xff;) 126.6869 Tj -0 -218.3473 Td -(6370 if\(c == 0\)) 83.0018 Tj -0 -227.8407 Td -(6371 break;) 74.2647 Tj -0 -237.334 Td -(6372 switch\(c\){) 83.0018 Tj -0 -246.8274 Td -(6373 case 'd':) 78.6333 Tj -0 -256.3207 Td -(6374 printint\(*argp++, 10, 1\);) 157.2665 Tj -0 -265.8141 Td -(6375 break;) 74.2647 Tj -0 -275.3075 Td -(6376 case 'x':) 78.6333 Tj -0 -284.8008 Td -(6377 case 'p':) 78.6333 Tj -0 -294.2942 Td -(6378 printint\(*argp++, 16, 0\);) 157.2665 Tj -0 -303.7875 Td -(6379 break;) 74.2647 Tj -0 -313.2809 Td -(6380 case 's':) 78.6333 Tj -0 -322.7743 Td -(6381 if\(\(s = \(char*\)*argp++\) == 0\)) 174.7406 Tj -0 -332.2676 Td -(6382 s = "\(null\)";) 113.5814 Tj -0 -341.761 Td -(6383 for\(; *s; s++\)) 109.2129 Tj -0 -351.2543 Td -(6384 consputc\(*s\);) 113.5814 Tj -0 -360.7477 Td -(6385 break;) 74.2647 Tj -0 -370.2411 Td -(6386 case '%':) 78.6333 Tj -0 -379.7344 Td -(6387 consputc\('%'\);) 109.2129 Tj -0 -389.2278 Td -(6388 break;) 74.2647 Tj -0 -398.7211 Td -(6389 default:) 74.2647 Tj -0 -408.2145 Td -(6390 // Print unknown % sequence to draw attention.) 249.0053 Tj -0 -417.7079 Td -(6391 consputc\('%'\);) 109.2129 Tj -0 -427.2012 Td -(6392 consputc\(c\);) 100.4758 Tj -0 -436.6946 Td -(6393 break;) 74.2647 Tj -0 -446.1879 Td -(6394 }) 43.6851 Tj -0 -455.6813 Td -(6395 }) 34.9481 Tj -0 -465.1747 Td -(6396 ) 21.8426 Tj -0 -474.668 Td -(6397 if\(locking\)) 78.6333 Tj -0 -484.1614 Td -(6398 release\(&cons.lock\);) 126.6869 Tj -0 -493.6547 Td -(6399 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 63) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 71 71 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 3) 174.7406 Tj -0 -28.4801 Td -(6400 void) 39.3166 Tj -0 -37.9735 Td -(6401 panic\(char *s\)) 83.0018 Tj -0 -47.4668 Td -(6402 {) 26.2111 Tj -0 -56.9602 Td -(6403 int i;) 56.7907 Tj -0 -66.4535 Td -(6404 uint pcs[10];) 87.3703 Tj -0 -75.9469 Td -(6405 ) 21.8426 Tj -0 -85.4403 Td -(6406 cli\(\);) 56.7907 Tj -0 -94.9336 Td -(6407 cons.locking = 0;) 104.8443 Tj -0 -104.427 Td -(6408 cprintf\("cpu%d: panic: ", cpu->id\);) 183.4776 Tj -0 -113.9203 Td -(6409 cprintf\(s\);) 78.6333 Tj -0 -123.4137 Td -(6410 cprintf\("\\n"\);) 91.7388 Tj -0 -132.9071 Td -(6411 getcallerpcs\(&s, pcs\);) 126.6869 Tj -0 -142.4004 Td -(6412 for\(i=0; i<10; i++\)) 113.5814 Tj -0 -151.8938 Td -(6413 cprintf\(" %p", pcs[i]\);) 139.7925 Tj -0 -161.3871 Td -(6414 panicked = 1; // freeze other CPU) 174.7406 Tj -0 -170.8805 Td -(6415 for\(;;\)) 61.1592 Tj -0 -180.3739 Td -(6416 ;) 43.6851 Tj -0 -189.8672 Td -(6417 }) 26.2111 Tj -0 -199.3606 Td -(6418 ) 21.8426 Tj -0 -208.8539 Td -(6419 ) 21.8426 Tj -0 -218.3473 Td -(6420 ) 21.8426 Tj -0 -227.8407 Td -(6421 ) 21.8426 Tj -0 -237.334 Td -(6422 ) 21.8426 Tj -0 -246.8274 Td -(6423 ) 21.8426 Tj -0 -256.3207 Td -(6424 ) 21.8426 Tj -0 -265.8141 Td -(6425 ) 21.8426 Tj -0 -275.3075 Td -(6426 ) 21.8426 Tj -0 -284.8008 Td -(6427 ) 21.8426 Tj -0 -294.2942 Td -(6428 ) 21.8426 Tj -0 -303.7875 Td -(6429 ) 21.8426 Tj -0 -313.2809 Td -(6430 ) 21.8426 Tj -0 -322.7743 Td -(6431 ) 21.8426 Tj -0 -332.2676 Td -(6432 ) 21.8426 Tj -0 -341.761 Td -(6433 ) 21.8426 Tj -0 -351.2543 Td -(6434 ) 21.8426 Tj -0 -360.7477 Td -(6435 ) 21.8426 Tj -0 -370.2411 Td -(6436 ) 21.8426 Tj -0 -379.7344 Td -(6437 ) 21.8426 Tj -0 -389.2278 Td -(6438 ) 21.8426 Tj -0 -398.7211 Td -(6439 ) 21.8426 Tj -0 -408.2145 Td -(6440 ) 21.8426 Tj -0 -417.7079 Td -(6441 ) 21.8426 Tj -0 -427.2012 Td -(6442 ) 21.8426 Tj -0 -436.6946 Td -(6443 ) 21.8426 Tj -0 -446.1879 Td -(6444 ) 21.8426 Tj -0 -455.6813 Td -(6445 ) 21.8426 Tj -0 -465.1747 Td -(6446 ) 21.8426 Tj -0 -474.668 Td -(6447 ) 21.8426 Tj -0 -484.1614 Td -(6448 ) 21.8426 Tj -0 -493.6547 Td -(6449 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 64) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 4) 174.7406 Tj -0 -28.4801 Td -(6450 #define BACKSPACE 0x100) 122.3184 Tj -0 -37.9735 Td -(6451 #define CRTPORT 0x3d4) 113.5814 Tj -0 -47.4668 Td -(6452 static ushort *crt = \(ushort*\)0xb8000; // CGA memory) 253.3738 Tj -0 -56.9602 Td -(6453 ) 21.8426 Tj -0 -66.4535 Td -(6454 static void) 69.8962 Tj -0 -75.9469 Td -(6455 cgaputc\(int c\)) 83.0018 Tj -0 -85.4403 Td -(6456 {) 26.2111 Tj -0 -94.9336 Td -(6457 int pos;) 65.5277 Tj -0 -104.427 Td -(6458 ) 21.8426 Tj -0 -113.9203 Td -(6459 // Cursor position: col + 80*row.) 174.7406 Tj -0 -123.4137 Td -(6460 outb\(CRTPORT, 14\);) 109.2129 Tj -0 -132.9071 Td -(6461 pos = inb\(CRTPORT+1\) << 8;) 144.161 Tj -0 -142.4004 Td -(6462 outb\(CRTPORT, 15\);) 109.2129 Tj -0 -151.8938 Td -(6463 pos |= inb\(CRTPORT+1\);) 126.6869 Tj -0 -161.3871 Td -(6464 ) 21.8426 Tj -0 -170.8805 Td -(6465 if\(c == '\\n'\)) 87.3703 Tj -0 -180.3739 Td -(6466 pos += 80 - pos%80;) 122.3184 Tj -0 -189.8672 Td -(6467 else if\(c == BACKSPACE\){) 135.4239 Tj -0 -199.3606 Td -(6468 if\(pos > 0\)) 87.3703 Tj -0 -208.8539 Td -(6469 crt[--pos] = ' ' | 0x0700;) 161.635 Tj -0 -218.3473 Td -(6470 } else) 56.7907 Tj -0 -227.8407 Td -(6471 crt[pos++] = \(c&0xff\) | 0x0700; // black on white) 257.7424 Tj -0 -237.334 Td -(6472 ) 21.8426 Tj -0 -246.8274 Td -(6473 if\(\(pos/80\) >= 24\){ // Scroll up.) 179.1091 Tj -0 -256.3207 Td -(6474 memmove\(crt, crt+80, sizeof\(crt[0]\)*23*80\);) 227.1628 Tj -0 -265.8141 Td -(6475 pos -= 80;) 83.0018 Tj -0 -275.3075 Td -(6476 memset\(crt+pos, 0, sizeof\(crt[0]\)*\(24*80 - pos\)\)\ -;) 253.3738 Tj -0 -284.8008 Td -(6477 }) 34.9481 Tj -0 -294.2942 Td -(6478 ) 21.8426 Tj -0 -303.7875 Td -(6479 outb\(CRTPORT, 14\);) 109.2129 Tj -0 -313.2809 Td -(6480 outb\(CRTPORT+1, pos>>8\);) 135.4239 Tj -0 -322.7743 Td -(6481 outb\(CRTPORT, 15\);) 109.2129 Tj -0 -332.2676 Td -(6482 outb\(CRTPORT+1, pos\);) 122.3184 Tj -0 -341.761 Td -(6483 crt[pos] = ' ' | 0x0700;) 135.4239 Tj -0 -351.2543 Td -(6484 }) 26.2111 Tj -0 -360.7477 Td -(6485 ) 21.8426 Tj -0 -370.2411 Td -(6486 void) 39.3166 Tj -0 -379.7344 Td -(6487 consputc\(int c\)) 87.3703 Tj -0 -389.2278 Td -(6488 {) 26.2111 Tj -0 -398.7211 Td -(6489 if\(panicked\){) 87.3703 Tj -0 -408.2145 Td -(6490 cli\(\);) 65.5277 Tj -0 -417.7079 Td -(6491 for\(;;\)) 69.8962 Tj -0 -427.2012 Td -(6492 ;) 52.4222 Tj -0 -436.6946 Td -(6493 }) 34.9481 Tj -0 -446.1879 Td -(6494 ) 21.8426 Tj -0 -455.6813 Td -(6495 uartputc\(c\);) 83.0018 Tj -0 -465.1747 Td -(6496 cgaputc\(c\);) 78.6333 Tj -0 -474.668 Td -(6497 }) 26.2111 Tj -0 -484.1614 Td -(6498 ) 21.8426 Tj -0 -493.6547 Td -(6499 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 64) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 72 72 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 5) 174.7406 Tj -0 -28.4801 Td -(6500 #define INPUT_BUF 128) 113.5814 Tj -0 -37.9735 Td -(6501 struct {) 56.7907 Tj -0 -47.4668 Td -(6502 struct spinlock lock;) 122.3184 Tj -0 -56.9602 Td -(6503 char buf[INPUT_BUF];) 117.9499 Tj -0 -66.4535 Td -(6504 uint r; // Read index) 126.6869 Tj -0 -75.9469 Td -(6505 uint w; // Write index) 131.0554 Tj -0 -85.4403 Td -(6506 uint e; // Edit index) 126.6869 Tj -0 -94.9336 Td -(6507 } input;) 56.7907 Tj -0 -104.427 Td -(6508 ) 21.8426 Tj -0 -113.9203 Td -(6509 #define C\(x\) \(\(x\)-'@'\) // Control-x) 183.4776 Tj -0 -123.4137 Td -(6510 ) 21.8426 Tj -0 -132.9071 Td -(6511 void) 39.3166 Tj -0 -142.4004 Td -(6512 consoleintr\(int \(*getc\)\(void\)\)) 152.898 Tj -0 -151.8938 Td -(6513 {) 26.2111 Tj -0 -161.3871 Td -(6514 int c;) 56.7907 Tj -0 -170.8805 Td -(6515 ) 21.8426 Tj -0 -180.3739 Td -(6516 acquire\(&input.lock\);) 122.3184 Tj -0 -189.8672 Td -(6517 while\(\(c = getc\(\)\) >= 0\){) 139.7925 Tj -0 -199.3606 Td -(6518 switch\(c\){) 83.0018 Tj -0 -208.8539 Td -(6519 case C\('P'\): // Process listing.) 183.4776 Tj -0 -218.3473 Td -(6520 procdump\(\);) 96.1073 Tj -0 -227.8407 Td -(6521 break;) 74.2647 Tj -0 -237.334 Td -(6522 case C\('U'\): // Kill line.) 157.2665 Tj -0 -246.8274 Td -(6523 while\(input.e != input.w &&) 166.0035 Tj -0 -256.3207 Td -(6524 input.buf[\(input.e-1\) % INPUT_BUF] != '\\n'\)\ -{) 266.4794 Tj -0 -265.8141 Td -(6525 input.e--;) 100.4758 Tj -0 -275.3075 Td -(6526 consputc\(BACKSPACE\);) 144.161 Tj -0 -284.8008 Td -(6527 }) 52.4222 Tj -0 -294.2942 Td -(6528 break;) 74.2647 Tj -0 -303.7875 Td -(6529 case C\('H'\): // Backspace) 152.898 Tj -0 -313.2809 Td -(6530 if\(input.e != input.w\){) 148.5295 Tj -0 -322.7743 Td -(6531 input.e--;) 100.4758 Tj -0 -332.2676 Td -(6532 consputc\(BACKSPACE\);) 144.161 Tj -0 -341.761 Td -(6533 }) 52.4222 Tj -0 -351.2543 Td -(6534 break;) 74.2647 Tj -0 -360.7477 Td -(6535 default:) 74.2647 Tj -0 -370.2411 Td -(6536 if\(c != 0 && input.e-input.r < INPUT_BUF\){) 231.5313 Tj -0 -379.7344 Td -(6537 input.buf[input.e++ % INPUT_BUF] = c;) 218.4257 Tj -0 -389.2278 Td -(6538 consputc\(c\);) 109.2129 Tj -0 -398.7211 Td -(6539 if\(c == '\\n' || c == C\('D'\) || input.e == inpu\ -t.r+INPUT_BUF\){) 323.2701 Tj -0 -408.2145 Td -(6540 input.w = input.e;) 144.161 Tj -0 -417.7079 Td -(6541 wakeup\(&input.r\);) 139.7925 Tj -0 -427.2012 Td -(6542 }) 61.1592 Tj -0 -436.6946 Td -(6543 }) 52.4222 Tj -0 -446.1879 Td -(6544 break;) 74.2647 Tj -0 -455.6813 Td -(6545 }) 43.6851 Tj -0 -465.1747 Td -(6546 }) 34.9481 Tj -0 -474.668 Td -(6547 release\(&input.lock\);) 122.3184 Tj -0 -484.1614 Td -(6548 }) 26.2111 Tj -0 -493.6547 Td -(6549 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 65) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 6) 174.7406 Tj -0 -28.4801 Td -(6550 int) 34.9481 Tj -0 -37.9735 Td -(6551 consoleread\(struct inode *ip, char *dst, int n\)) 227.1628 Tj -0 -47.4668 Td -(6552 {) 26.2111 Tj -0 -56.9602 Td -(6553 uint target;) 83.0018 Tj -0 -66.4535 Td -(6554 int c;) 56.7907 Tj -0 -75.9469 Td -(6555 ) 21.8426 Tj -0 -85.4403 Td -(6556 iunlock\(ip\);) 83.0018 Tj -0 -94.9336 Td -(6557 target = n;) 78.6333 Tj -0 -104.427 Td -(6558 acquire\(&input.lock\);) 122.3184 Tj -0 -113.9203 Td -(6559 while\(n > 0\){) 87.3703 Tj -0 -123.4137 Td -(6560 while\(input.r == input.w\){) 152.898 Tj -0 -132.9071 Td -(6561 if\(proc->killed\){) 122.3184 Tj -0 -142.4004 Td -(6562 release\(&input.lock\);) 148.5295 Tj -0 -151.8938 Td -(6563 ilock\(ip\);) 100.4758 Tj -0 -161.3871 Td -(6564 return -1;) 100.4758 Tj -0 -170.8805 Td -(6565 }) 52.4222 Tj -0 -180.3739 Td -(6566 sleep\(&input.r, &input.lock\);) 174.7406 Tj -0 -189.8672 Td -(6567 }) 43.6851 Tj -0 -199.3606 Td -(6568 c = input.buf[input.r++ % INPUT_BUF];) 200.9517 Tj -0 -208.8539 Td -(6569 if\(c == C\('D'\)\){ // EOF) 144.161 Tj -0 -218.3473 Td -(6570 if\(n < target\){) 113.5814 Tj -0 -227.8407 Td -(6571 // Save ^D for next time, to make sure) 222.7942 Tj -0 -237.334 Td -(6572 // caller gets a 0-byte result.) 192.2146 Tj -0 -246.8274 Td -(6573 input.r--;) 100.4758 Tj -0 -256.3207 Td -(6574 }) 52.4222 Tj -0 -265.8141 Td -(6575 break;) 74.2647 Tj -0 -275.3075 Td -(6576 }) 43.6851 Tj -0 -284.8008 Td -(6577 *dst++ = c;) 87.3703 Tj -0 -294.2942 Td -(6578 --n;) 56.7907 Tj -0 -303.7875 Td -(6579 if\(c == '\\n'\)) 96.1073 Tj -0 -313.2809 Td -(6580 break;) 74.2647 Tj -0 -322.7743 Td -(6581 }) 34.9481 Tj -0 -332.2676 Td -(6582 release\(&input.lock\);) 122.3184 Tj -0 -341.761 Td -(6583 ilock\(ip\);) 74.2647 Tj -0 -351.2543 Td -(6584 ) 21.8426 Tj -0 -360.7477 Td -(6585 return target - n;) 109.2129 Tj -0 -370.2411 Td -(6586 }) 26.2111 Tj -0 -379.7344 Td -(6587 ) 21.8426 Tj -0 -389.2278 Td -(6588 ) 21.8426 Tj -0 -398.7211 Td -(6589 ) 21.8426 Tj -0 -408.2145 Td -(6590 ) 21.8426 Tj -0 -417.7079 Td -(6591 ) 21.8426 Tj -0 -427.2012 Td -(6592 ) 21.8426 Tj -0 -436.6946 Td -(6593 ) 21.8426 Tj -0 -446.1879 Td -(6594 ) 21.8426 Tj -0 -455.6813 Td -(6595 ) 21.8426 Tj -0 -465.1747 Td -(6596 ) 21.8426 Tj -0 -474.668 Td -(6597 ) 21.8426 Tj -0 -484.1614 Td -(6598 ) 21.8426 Tj -0 -493.6547 Td -(6599 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 65) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 73 73 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/console.c Page 7) 174.7406 Tj -0 -28.4801 Td -(6600 int) 34.9481 Tj -0 -37.9735 Td -(6601 consolewrite\(struct inode *ip, char *buf, int n\)) 231.5313 Tj -0 -47.4668 Td -(6602 {) 26.2111 Tj -0 -56.9602 Td -(6603 int i;) 56.7907 Tj -0 -66.4535 Td -(6604 ) 21.8426 Tj -0 -75.9469 Td -(6605 iunlock\(ip\);) 83.0018 Tj -0 -85.4403 Td -(6606 acquire\(&cons.lock\);) 117.9499 Tj -0 -94.9336 Td -(6607 for\(i = 0; i < n; i++\)) 126.6869 Tj -0 -104.427 Td -(6608 consputc\(buf[i] & 0xff\);) 144.161 Tj -0 -113.9203 Td -(6609 release\(&cons.lock\);) 117.9499 Tj -0 -123.4137 Td -(6610 ilock\(ip\);) 74.2647 Tj -0 -132.9071 Td -(6611 ) 21.8426 Tj -0 -142.4004 Td -(6612 return n;) 69.8962 Tj -0 -151.8938 Td -(6613 }) 26.2111 Tj -0 -161.3871 Td -(6614 ) 21.8426 Tj -0 -170.8805 Td -(6615 void) 39.3166 Tj -0 -180.3739 Td -(6616 consoleinit\(void\)) 96.1073 Tj -0 -189.8672 Td -(6617 {) 26.2111 Tj -0 -199.3606 Td -(6618 initlock\(&cons.lock, "console"\);) 170.3721 Tj -0 -208.8539 Td -(6619 initlock\(&input.lock, "input"\);) 166.0035 Tj -0 -218.3473 Td -(6620 ) 21.8426 Tj -0 -227.8407 Td -(6621 devsw[CONSOLE].write = consolewrite;) 187.8461 Tj -0 -237.334 Td -(6622 devsw[CONSOLE].read = consoleread;) 179.1091 Tj -0 -246.8274 Td -(6623 cons.locking = 1;) 104.8443 Tj -0 -256.3207 Td -(6624 ) 21.8426 Tj -0 -265.8141 Td -(6625 picenable\(IRQ_KBD\);) 113.5814 Tj -0 -275.3075 Td -(6626 ioapicenable\(IRQ_KBD, 0\);) 139.7925 Tj -0 -284.8008 Td -(6627 }) 26.2111 Tj -0 -294.2942 Td -(6628 ) 21.8426 Tj -0 -303.7875 Td -(6629 ) 21.8426 Tj -0 -313.2809 Td -(6630 ) 21.8426 Tj -0 -322.7743 Td -(6631 ) 21.8426 Tj -0 -332.2676 Td -(6632 ) 21.8426 Tj -0 -341.761 Td -(6633 ) 21.8426 Tj -0 -351.2543 Td -(6634 ) 21.8426 Tj -0 -360.7477 Td -(6635 ) 21.8426 Tj -0 -370.2411 Td -(6636 ) 21.8426 Tj -0 -379.7344 Td -(6637 ) 21.8426 Tj -0 -389.2278 Td -(6638 ) 21.8426 Tj -0 -398.7211 Td -(6639 ) 21.8426 Tj -0 -408.2145 Td -(6640 ) 21.8426 Tj -0 -417.7079 Td -(6641 ) 21.8426 Tj -0 -427.2012 Td -(6642 ) 21.8426 Tj -0 -436.6946 Td -(6643 ) 21.8426 Tj -0 -446.1879 Td -(6644 ) 21.8426 Tj -0 -455.6813 Td -(6645 ) 21.8426 Tj -0 -465.1747 Td -(6646 ) 21.8426 Tj -0 -474.668 Td -(6647 ) 21.8426 Tj -0 -484.1614 Td -(6648 ) 21.8426 Tj -0 -493.6547 Td -(6649 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 66) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/timer.c Page 1) 166.0035 Tj -0 -28.4801 Td -(6650 // Intel 8253/8254/82C54 Programmable Interval Timer \(PIT\ -\).) 279.5849 Tj -0 -37.9735 Td -(6651 // Only used on uniprocessors;) 152.898 Tj -0 -47.4668 Td -(6652 // SMP machines use the local APIC timer.) 200.9517 Tj -0 -56.9602 Td -(6653 ) 21.8426 Tj -0 -66.4535 Td -(6654 #include "types.h") 100.4758 Tj -0 -75.9469 Td -(6655 #include "defs.h") 96.1073 Tj -0 -85.4403 Td -(6656 #include "traps.h") 100.4758 Tj -0 -94.9336 Td -(6657 #include "x86.h") 91.7388 Tj -0 -104.427 Td -(6658 ) 21.8426 Tj -0 -113.9203 Td -(6659 #define IO_TIMER1 0x040 // 8253 Timer #1) 266.4794 Tj -0 -123.4137 Td -(6660 ) 21.8426 Tj -0 -132.9071 Td -(6661 // Frequency of all three count-down timers;) 214.0572 Tj -0 -142.4004 Td -(6662 // \(TIMER_FREQ/freq\) is the appropriate count) 218.4257 Tj -0 -151.8938 Td -(6663 // to generate a frequency of freq Hz.) 187.8461 Tj -0 -161.3871 Td -(6664 ) 21.8426 Tj -0 -170.8805 Td -(6665 #define TIMER_FREQ 1193182) 157.2665 Tj -0 -180.3739 Td -(6666 #define TIMER_DIV\(x\) \(\(TIMER_FREQ+\(x\)/2\)/\(x\)\)) 231.5313 Tj -0 -189.8672 Td -(6667 ) 21.8426 Tj -0 -199.3606 Td -(6668 #define TIMER_MODE \(IO_TIMER1 + 3\) // timer mode po\ -rt) 275.2164 Tj -0 -208.8539 Td -(6669 #define TIMER_SEL0 0x00 // select counter 0) 244.6368 Tj -0 -218.3473 Td -(6670 #define TIMER_RATEGEN 0x04 // mode 2, rate generator) 270.8479 Tj -0 -227.8407 Td -(6671 #define TIMER_16BIT 0x30 // r/w counter 16 bits, LS\ -B first) 305.796 Tj -0 -237.334 Td -(6672 ) 21.8426 Tj -0 -246.8274 Td -(6673 void) 39.3166 Tj -0 -256.3207 Td -(6674 timerinit\(void\)) 87.3703 Tj -0 -265.8141 Td -(6675 {) 26.2111 Tj -0 -275.3075 Td -(6676 // Interrupt 100 times/sec.) 148.5295 Tj -0 -284.8008 Td -(6677 outb\(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16B\ -IT\);) 288.322 Tj -0 -294.2942 Td -(6678 outb\(IO_TIMER1, TIMER_DIV\(100\) % 256\);) 196.5831 Tj -0 -303.7875 Td -(6679 outb\(IO_TIMER1, TIMER_DIV\(100\) / 256\);) 196.5831 Tj -0 -313.2809 Td -(6680 picenable\(IRQ_TIMER\);) 122.3184 Tj -0 -322.7743 Td -(6681 }) 26.2111 Tj -0 -332.2676 Td -(6682 ) 21.8426 Tj -0 -341.761 Td -(6683 ) 21.8426 Tj -0 -351.2543 Td -(6684 ) 21.8426 Tj -0 -360.7477 Td -(6685 ) 21.8426 Tj -0 -370.2411 Td -(6686 ) 21.8426 Tj -0 -379.7344 Td -(6687 ) 21.8426 Tj -0 -389.2278 Td -(6688 ) 21.8426 Tj -0 -398.7211 Td -(6689 ) 21.8426 Tj -0 -408.2145 Td -(6690 ) 21.8426 Tj -0 -417.7079 Td -(6691 ) 21.8426 Tj -0 -427.2012 Td -(6692 ) 21.8426 Tj -0 -436.6946 Td -(6693 ) 21.8426 Tj -0 -446.1879 Td -(6694 ) 21.8426 Tj -0 -455.6813 Td -(6695 ) 21.8426 Tj -0 -465.1747 Td -(6696 ) 21.8426 Tj -0 -474.668 Td -(6697 ) 21.8426 Tj -0 -484.1614 Td -(6698 ) 21.8426 Tj -0 -493.6547 Td -(6699 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 66) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 74 74 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/initcode.S Page 1) 179.1091 Tj -0 -28.4801 Td -(6700 # Initial process execs /init.) 152.898 Tj -0 -37.9735 Td -(6701 ) 21.8426 Tj -0 -47.4668 Td -(6702 #include "syscall.h") 109.2129 Tj -0 -56.9602 Td -(6703 #include "traps.h") 100.4758 Tj -0 -66.4535 Td -(6704 ) 21.8426 Tj -0 -75.9469 Td -(6705 # exec\(init, argv\)) 100.4758 Tj -0 -85.4403 Td -(6706 .globl start) 74.2647 Tj -0 -94.9336 Td -(6707 start:) 48.0537 Tj -0 -104.427 Td -(6708 pushl $argv) 78.6333 Tj -0 -113.9203 Td -(6709 pushl $init) 78.6333 Tj -0 -123.4137 Td -(6710 pushl $0 // where caller pc would be) 192.2146 Tj -0 -132.9071 Td -(6711 movl $SYS_exec, %eax) 117.9499 Tj -0 -142.4004 Td -(6712 int $T_SYSCALL) 91.7388 Tj -0 -151.8938 Td -(6713 ) 21.8426 Tj -0 -161.3871 Td -(6714 # for\(;;\) exit\(\);) 96.1073 Tj -0 -170.8805 Td -(6715 exit:) 43.6851 Tj -0 -180.3739 Td -(6716 movl $SYS_exit, %eax) 117.9499 Tj -0 -189.8672 Td -(6717 int $T_SYSCALL) 91.7388 Tj -0 -199.3606 Td -(6718 jmp exit) 65.5277 Tj -0 -208.8539 Td -(6719 ) 21.8426 Tj -0 -218.3473 Td -(6720 # char init[] = "/init\\0";) 135.4239 Tj -0 -227.8407 Td -(6721 init:) 43.6851 Tj -0 -237.334 Td -(6722 .string "/init\\0") 104.8443 Tj -0 -246.8274 Td -(6723 ) 21.8426 Tj -0 -256.3207 Td -(6724 # char *argv[] = { init, 0 };) 148.5295 Tj -0 -265.8141 Td -(6725 .p2align 2) 65.5277 Tj -0 -275.3075 Td -(6726 argv:) 43.6851 Tj -0 -284.8008 Td -(6727 .long init) 74.2647 Tj -0 -294.2942 Td -(6728 .long 0) 61.1592 Tj -0 -303.7875 Td -(6729 ) 21.8426 Tj -0 -313.2809 Td -(6730 ) 21.8426 Tj -0 -322.7743 Td -(6731 ) 21.8426 Tj -0 -332.2676 Td -(6732 ) 21.8426 Tj -0 -341.761 Td -(6733 ) 21.8426 Tj -0 -351.2543 Td -(6734 ) 21.8426 Tj -0 -360.7477 Td -(6735 ) 21.8426 Tj -0 -370.2411 Td -(6736 ) 21.8426 Tj -0 -379.7344 Td -(6737 ) 21.8426 Tj -0 -389.2278 Td -(6738 ) 21.8426 Tj -0 -398.7211 Td -(6739 ) 21.8426 Tj -0 -408.2145 Td -(6740 ) 21.8426 Tj -0 -417.7079 Td -(6741 ) 21.8426 Tj -0 -427.2012 Td -(6742 ) 21.8426 Tj -0 -436.6946 Td -(6743 ) 21.8426 Tj -0 -446.1879 Td -(6744 ) 21.8426 Tj -0 -455.6813 Td -(6745 ) 21.8426 Tj -0 -465.1747 Td -(6746 ) 21.8426 Tj -0 -474.668 Td -(6747 ) 21.8426 Tj -0 -484.1614 Td -(6748 ) 21.8426 Tj -0 -493.6547 Td -(6749 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 67) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/usys.S Page 1) 161.635 Tj -0 -28.4801 Td -(6750 #include "syscall.h") 109.2129 Tj -0 -37.9735 Td -(6751 #include "traps.h") 100.4758 Tj -0 -47.4668 Td -(6752 ) 21.8426 Tj -0 -56.9602 Td -(6753 #define SYSCALL\(name\) \\) 122.3184 Tj -0 -66.4535 Td -(6754 .globl name; \\) 91.7388 Tj -0 -75.9469 Td -(6755 name: \\) 61.1592 Tj -0 -85.4403 Td -(6756 movl $SYS_ ## name, %eax; \\) 157.2665 Tj -0 -94.9336 Td -(6757 int $T_SYSCALL; \\) 113.5814 Tj -0 -104.427 Td -(6758 ret) 52.4222 Tj -0 -113.9203 Td -(6759 ) 21.8426 Tj -0 -123.4137 Td -(6760 SYSCALL\(fork\)) 78.6333 Tj -0 -132.9071 Td -(6761 SYSCALL\(exit\)) 78.6333 Tj -0 -142.4004 Td -(6762 SYSCALL\(wait\)) 78.6333 Tj -0 -151.8938 Td -(6763 SYSCALL\(pipe\)) 78.6333 Tj -0 -161.3871 Td -(6764 SYSCALL\(read\)) 78.6333 Tj -0 -170.8805 Td -(6765 SYSCALL\(write\)) 83.0018 Tj -0 -180.3739 Td -(6766 SYSCALL\(close\)) 83.0018 Tj -0 -189.8672 Td -(6767 SYSCALL\(kill\)) 78.6333 Tj -0 -199.3606 Td -(6768 SYSCALL\(exec\)) 78.6333 Tj -0 -208.8539 Td -(6769 SYSCALL\(open\)) 78.6333 Tj -0 -218.3473 Td -(6770 SYSCALL\(mknod\)) 83.0018 Tj -0 -227.8407 Td -(6771 SYSCALL\(unlink\)) 87.3703 Tj -0 -237.334 Td -(6772 SYSCALL\(fstat\)) 83.0018 Tj -0 -246.8274 Td -(6773 SYSCALL\(link\)) 78.6333 Tj -0 -256.3207 Td -(6774 SYSCALL\(mkdir\)) 83.0018 Tj -0 -265.8141 Td -(6775 SYSCALL\(chdir\)) 83.0018 Tj -0 -275.3075 Td -(6776 SYSCALL\(dup\)) 74.2647 Tj -0 -284.8008 Td -(6777 SYSCALL\(getpid\)) 87.3703 Tj -0 -294.2942 Td -(6778 SYSCALL\(sbrk\)) 78.6333 Tj -0 -303.7875 Td -(6779 SYSCALL\(sleep\)) 83.0018 Tj -0 -313.2809 Td -(6780 ) 21.8426 Tj -0 -322.7743 Td -(6781 ) 21.8426 Tj -0 -332.2676 Td -(6782 ) 21.8426 Tj -0 -341.761 Td -(6783 ) 21.8426 Tj -0 -351.2543 Td -(6784 ) 21.8426 Tj -0 -360.7477 Td -(6785 ) 21.8426 Tj -0 -370.2411 Td -(6786 ) 21.8426 Tj -0 -379.7344 Td -(6787 ) 21.8426 Tj -0 -389.2278 Td -(6788 ) 21.8426 Tj -0 -398.7211 Td -(6789 ) 21.8426 Tj -0 -408.2145 Td -(6790 ) 21.8426 Tj -0 -417.7079 Td -(6791 ) 21.8426 Tj -0 -427.2012 Td -(6792 ) 21.8426 Tj -0 -436.6946 Td -(6793 ) 21.8426 Tj -0 -446.1879 Td -(6794 ) 21.8426 Tj -0 -455.6813 Td -(6795 ) 21.8426 Tj -0 -465.1747 Td -(6796 ) 21.8426 Tj -0 -474.668 Td -(6797 ) 21.8426 Tj -0 -484.1614 Td -(6798 ) 21.8426 Tj -0 -493.6547 Td -(6799 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 67) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 75 75 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/init.c Page 1) 161.635 Tj -0 -28.4801 Td -(6800 // init: The initial user-level program) 192.2146 Tj -0 -37.9735 Td -(6801 ) 21.8426 Tj -0 -47.4668 Td -(6802 #include "types.h") 100.4758 Tj -0 -56.9602 Td -(6803 #include "stat.h") 96.1073 Tj -0 -66.4535 Td -(6804 #include "user.h") 96.1073 Tj -0 -75.9469 Td -(6805 #include "fcntl.h") 100.4758 Tj -0 -85.4403 Td -(6806 ) 21.8426 Tj -0 -94.9336 Td -(6807 char *argv[] = { "sh", 0 };) 139.7925 Tj -0 -104.427 Td -(6808 ) 21.8426 Tj -0 -113.9203 Td -(6809 int) 34.9481 Tj -0 -123.4137 Td -(6810 main\(void\)) 65.5277 Tj -0 -132.9071 Td -(6811 {) 26.2111 Tj -0 -142.4004 Td -(6812 int pid, wpid;) 91.7388 Tj -0 -151.8938 Td -(6813 ) 21.8426 Tj -0 -161.3871 Td -(6814 if\(open\("console", O_RDWR\) < 0\){) 170.3721 Tj -0 -170.8805 Td -(6815 mknod\("console", 1, 1\);) 139.7925 Tj -0 -180.3739 Td -(6816 open\("console", O_RDWR\);) 144.161 Tj -0 -189.8672 Td -(6817 }) 34.9481 Tj -0 -199.3606 Td -(6818 dup\(0\); // stdout) 109.2129 Tj -0 -208.8539 Td -(6819 dup\(0\); // stderr) 109.2129 Tj -0 -218.3473 Td -(6820 ) 21.8426 Tj -0 -227.8407 Td -(6821 for\(;;\){) 65.5277 Tj -0 -237.334 Td -(6822 printf\(1, "init: starting sh\\n"\);) 183.4776 Tj -0 -246.8274 Td -(6823 pid = fork\(\);) 96.1073 Tj -0 -256.3207 Td -(6824 if\(pid < 0\){) 91.7388 Tj -0 -265.8141 Td -(6825 printf\(1, "init: fork failed\\n"\);) 192.2146 Tj -0 -275.3075 Td -(6826 exit\(\);) 78.6333 Tj -0 -284.8008 Td -(6827 }) 43.6851 Tj -0 -294.2942 Td -(6828 if\(pid == 0\){) 96.1073 Tj -0 -303.7875 Td -(6829 exec\("sh", argv\);) 122.3184 Tj -0 -313.2809 Td -(6830 printf\(1, "init: exec sh failed\\n"\);) 205.3202 Tj -0 -322.7743 Td -(6831 exit\(\);) 78.6333 Tj -0 -332.2676 Td -(6832 }) 43.6851 Tj -0 -341.761 Td -(6833 while\(\(wpid=wait\(\)\) >= 0 && wpid != pid\)) 214.0572 Tj -0 -351.2543 Td -(6834 printf\(1, "zombie!\\n"\);) 148.5295 Tj -0 -360.7477 Td -(6835 }) 34.9481 Tj -0 -370.2411 Td -(6836 }) 26.2111 Tj -0 -379.7344 Td -(6837 ) 21.8426 Tj -0 -389.2278 Td -(6838 ) 21.8426 Tj -0 -398.7211 Td -(6839 ) 21.8426 Tj -0 -408.2145 Td -(6840 ) 21.8426 Tj -0 -417.7079 Td -(6841 ) 21.8426 Tj -0 -427.2012 Td -(6842 ) 21.8426 Tj -0 -436.6946 Td -(6843 ) 21.8426 Tj -0 -446.1879 Td -(6844 ) 21.8426 Tj -0 -455.6813 Td -(6845 ) 21.8426 Tj -0 -465.1747 Td -(6846 ) 21.8426 Tj -0 -474.668 Td -(6847 ) 21.8426 Tj -0 -484.1614 Td -(6848 ) 21.8426 Tj -0 -493.6547 Td -(6849 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 68) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 1) 152.898 Tj -0 -28.4801 Td -(6850 // Shell.) 61.1592 Tj -0 -37.9735 Td -(6851 ) 21.8426 Tj -0 -47.4668 Td -(6852 #include "types.h") 100.4758 Tj -0 -56.9602 Td -(6853 #include "user.h") 96.1073 Tj -0 -66.4535 Td -(6854 #include "fcntl.h") 100.4758 Tj -0 -75.9469 Td -(6855 ) 21.8426 Tj -0 -85.4403 Td -(6856 // Parsed command representation) 161.635 Tj -0 -94.9336 Td -(6857 #define EXEC 1) 87.3703 Tj -0 -104.427 Td -(6858 #define REDIR 2) 87.3703 Tj -0 -113.9203 Td -(6859 #define PIPE 3) 87.3703 Tj -0 -123.4137 Td -(6860 #define LIST 4) 87.3703 Tj -0 -132.9071 Td -(6861 #define BACK 5) 87.3703 Tj -0 -142.4004 Td -(6862 ) 21.8426 Tj -0 -151.8938 Td -(6863 #define MAXARGS 10) 100.4758 Tj -0 -161.3871 Td -(6864 ) 21.8426 Tj -0 -170.8805 Td -(6865 struct cmd {) 74.2647 Tj -0 -180.3739 Td -(6866 int type;) 69.8962 Tj -0 -189.8672 Td -(6867 };) 30.5796 Tj -0 -199.3606 Td -(6868 ) 21.8426 Tj -0 -208.8539 Td -(6869 struct execcmd {) 91.7388 Tj -0 -218.3473 Td -(6870 int type;) 69.8962 Tj -0 -227.8407 Td -(6871 char *argv[MAXARGS];) 117.9499 Tj -0 -237.334 Td -(6872 char *eargv[MAXARGS];) 122.3184 Tj -0 -246.8274 Td -(6873 };) 30.5796 Tj -0 -256.3207 Td -(6874 ) 21.8426 Tj -0 -265.8141 Td -(6875 struct redircmd {) 96.1073 Tj -0 -275.3075 Td -(6876 int type;) 69.8962 Tj -0 -284.8008 Td -(6877 struct cmd *cmd;) 100.4758 Tj -0 -294.2942 Td -(6878 char *file;) 78.6333 Tj -0 -303.7875 Td -(6879 char *efile;) 83.0018 Tj -0 -313.2809 Td -(6880 int mode;) 69.8962 Tj -0 -322.7743 Td -(6881 int fd;) 61.1592 Tj -0 -332.2676 Td -(6882 };) 30.5796 Tj -0 -341.761 Td -(6883 ) 21.8426 Tj -0 -351.2543 Td -(6884 struct pipecmd {) 91.7388 Tj -0 -360.7477 Td -(6885 int type;) 69.8962 Tj -0 -370.2411 Td -(6886 struct cmd *left;) 104.8443 Tj -0 -379.7344 Td -(6887 struct cmd *right;) 109.2129 Tj -0 -389.2278 Td -(6888 };) 30.5796 Tj -0 -398.7211 Td -(6889 ) 21.8426 Tj -0 -408.2145 Td -(6890 struct listcmd {) 91.7388 Tj -0 -417.7079 Td -(6891 int type;) 69.8962 Tj -0 -427.2012 Td -(6892 struct cmd *left;) 104.8443 Tj -0 -436.6946 Td -(6893 struct cmd *right;) 109.2129 Tj -0 -446.1879 Td -(6894 };) 30.5796 Tj -0 -455.6813 Td -(6895 ) 21.8426 Tj -0 -465.1747 Td -(6896 struct backcmd {) 91.7388 Tj -0 -474.668 Td -(6897 int type;) 69.8962 Tj -0 -484.1614 Td -(6898 struct cmd *cmd;) 100.4758 Tj -0 -493.6547 Td -(6899 };) 30.5796 Tj -0 -522.1348 Td -(Sheet 68) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 76 76 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 2) 152.898 Tj -0 -28.4801 Td -(6900 int fork1\(void\); // Fork but panics on failure.) 231.5313 Tj -0 -37.9735 Td -(6901 void panic\(char*\);) 100.4758 Tj -0 -47.4668 Td -(6902 struct cmd *parsecmd\(char*\);) 144.161 Tj -0 -56.9602 Td -(6903 ) 21.8426 Tj -0 -66.4535 Td -(6904 // Execute cmd. Never returns.) 157.2665 Tj -0 -75.9469 Td -(6905 void) 39.3166 Tj -0 -85.4403 Td -(6906 runcmd\(struct cmd *cmd\)) 122.3184 Tj -0 -94.9336 Td -(6907 {) 26.2111 Tj -0 -104.427 Td -(6908 int p[2];) 69.8962 Tj -0 -113.9203 Td -(6909 struct backcmd *bcmd;) 122.3184 Tj -0 -123.4137 Td -(6910 struct execcmd *ecmd;) 122.3184 Tj -0 -132.9071 Td -(6911 struct listcmd *lcmd;) 122.3184 Tj -0 -142.4004 Td -(6912 struct pipecmd *pcmd;) 122.3184 Tj -0 -151.8938 Td -(6913 struct redircmd *rcmd;) 126.6869 Tj -0 -161.3871 Td -(6914 ) 21.8426 Tj -0 -170.8805 Td -(6915 if\(cmd == 0\)) 83.0018 Tj -0 -180.3739 Td -(6916 exit\(\);) 69.8962 Tj -0 -189.8672 Td -(6917 ) 21.8426 Tj -0 -199.3606 Td -(6918 switch\(cmd->type\){) 109.2129 Tj -0 -208.8539 Td -(6919 default:) 65.5277 Tj -0 -218.3473 Td -(6920 panic\("runcmd"\);) 109.2129 Tj -0 -227.8407 Td -(6921 ) 21.8426 Tj -0 -237.334 Td -(6922 case EXEC:) 74.2647 Tj -0 -246.8274 Td -(6923 ecmd = \(struct execcmd*\)cmd;) 161.635 Tj -0 -256.3207 Td -(6924 if\(ecmd->argv[0] == 0\)) 135.4239 Tj -0 -265.8141 Td -(6925 exit\(\);) 78.6333 Tj -0 -275.3075 Td -(6926 exec\(ecmd->argv[0], ecmd->argv\);) 179.1091 Tj -0 -284.8008 Td -(6927 printf\(2, "exec %s failed\\n", ecmd->argv[0]\);) 235.8998 Tj -0 -294.2942 Td -(6928 break;) 65.5277 Tj -0 -303.7875 Td -(6929 ) 21.8426 Tj -0 -313.2809 Td -(6930 case REDIR:) 78.6333 Tj -0 -322.7743 Td -(6931 rcmd = \(struct redircmd*\)cmd;) 166.0035 Tj -0 -332.2676 Td -(6932 close\(rcmd->fd\);) 109.2129 Tj -0 -341.761 Td -(6933 if\(open\(rcmd->file, rcmd->mode\) < 0\){) 200.9517 Tj -0 -351.2543 Td -(6934 printf\(2, "open %s failed\\n", rcmd->file\);) 231.5313 Tj -0 -360.7477 Td -(6935 exit\(\);) 78.6333 Tj -0 -370.2411 Td -(6936 }) 43.6851 Tj -0 -379.7344 Td -(6937 runcmd\(rcmd->cmd\);) 117.9499 Tj -0 -389.2278 Td -(6938 break;) 65.5277 Tj -0 -398.7211 Td -(6939 ) 21.8426 Tj -0 -408.2145 Td -(6940 case LIST:) 74.2647 Tj -0 -417.7079 Td -(6941 lcmd = \(struct listcmd*\)cmd;) 161.635 Tj -0 -427.2012 Td -(6942 if\(fork1\(\) == 0\)) 109.2129 Tj -0 -436.6946 Td -(6943 runcmd\(lcmd->left\);) 131.0554 Tj -0 -446.1879 Td -(6944 wait\(\);) 69.8962 Tj -0 -455.6813 Td -(6945 runcmd\(lcmd->right\);) 126.6869 Tj -0 -465.1747 Td -(6946 break;) 65.5277 Tj -0 -474.668 Td -(6947 ) 21.8426 Tj -0 -484.1614 Td -(6948 ) 21.8426 Tj -0 -493.6547 Td -(6949 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 69) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 3) 152.898 Tj -0 -28.4801 Td -(6950 case PIPE:) 74.2647 Tj -0 -37.9735 Td -(6951 pcmd = \(struct pipecmd*\)cmd;) 161.635 Tj -0 -47.4668 Td -(6952 if\(pipe\(p\) < 0\)) 104.8443 Tj -0 -56.9602 Td -(6953 panic\("pipe"\);) 109.2129 Tj -0 -66.4535 Td -(6954 if\(fork1\(\) == 0\){) 113.5814 Tj -0 -75.9469 Td -(6955 close\(1\);) 87.3703 Tj -0 -85.4403 Td -(6956 dup\(p[1]\);) 91.7388 Tj -0 -94.9336 Td -(6957 close\(p[0]\);) 100.4758 Tj -0 -104.427 Td -(6958 close\(p[1]\);) 100.4758 Tj -0 -113.9203 Td -(6959 runcmd\(pcmd->left\);) 131.0554 Tj -0 -123.4137 Td -(6960 }) 43.6851 Tj -0 -132.9071 Td -(6961 if\(fork1\(\) == 0\){) 113.5814 Tj -0 -142.4004 Td -(6962 close\(0\);) 87.3703 Tj -0 -151.8938 Td -(6963 dup\(p[0]\);) 91.7388 Tj -0 -161.3871 Td -(6964 close\(p[0]\);) 100.4758 Tj -0 -170.8805 Td -(6965 close\(p[1]\);) 100.4758 Tj -0 -180.3739 Td -(6966 runcmd\(pcmd->right\);) 135.4239 Tj -0 -189.8672 Td -(6967 }) 43.6851 Tj -0 -199.3606 Td -(6968 close\(p[0]\);) 91.7388 Tj -0 -208.8539 Td -(6969 close\(p[1]\);) 91.7388 Tj -0 -218.3473 Td -(6970 wait\(\);) 69.8962 Tj -0 -227.8407 Td -(6971 wait\(\);) 69.8962 Tj -0 -237.334 Td -(6972 break;) 65.5277 Tj -0 -246.8274 Td -(6973 ) 21.8426 Tj -0 -256.3207 Td -(6974 case BACK:) 74.2647 Tj -0 -265.8141 Td -(6975 bcmd = \(struct backcmd*\)cmd;) 161.635 Tj -0 -275.3075 Td -(6976 if\(fork1\(\) == 0\)) 109.2129 Tj -0 -284.8008 Td -(6977 runcmd\(bcmd->cmd\);) 126.6869 Tj -0 -294.2942 Td -(6978 break;) 65.5277 Tj -0 -303.7875 Td -(6979 }) 34.9481 Tj -0 -313.2809 Td -(6980 exit\(\);) 61.1592 Tj -0 -322.7743 Td -(6981 }) 26.2111 Tj -0 -332.2676 Td -(6982 ) 21.8426 Tj -0 -341.761 Td -(6983 int) 34.9481 Tj -0 -351.2543 Td -(6984 getcmd\(char *buf, int nbuf\)) 139.7925 Tj -0 -360.7477 Td -(6985 {) 26.2111 Tj -0 -370.2411 Td -(6986 printf\(2, "$ "\);) 100.4758 Tj -0 -379.7344 Td -(6987 memset\(buf, 0, nbuf\);) 122.3184 Tj -0 -389.2278 Td -(6988 gets\(buf, nbuf\);) 100.4758 Tj -0 -398.7211 Td -(6989 if\(buf[0] == 0\) // EOF) 126.6869 Tj -0 -408.2145 Td -(6990 return -1;) 83.0018 Tj -0 -417.7079 Td -(6991 return 0;) 69.8962 Tj -0 -427.2012 Td -(6992 }) 26.2111 Tj -0 -436.6946 Td -(6993 ) 21.8426 Tj -0 -446.1879 Td -(6994 ) 21.8426 Tj -0 -455.6813 Td -(6995 ) 21.8426 Tj -0 -465.1747 Td -(6996 ) 21.8426 Tj -0 -474.668 Td -(6997 ) 21.8426 Tj -0 -484.1614 Td -(6998 ) 21.8426 Tj -0 -493.6547 Td -(6999 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 69) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 77 77 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 4) 152.898 Tj -0 -28.4801 Td -(7000 int) 34.9481 Tj -0 -37.9735 Td -(7001 main\(void\)) 65.5277 Tj -0 -47.4668 Td -(7002 {) 26.2111 Tj -0 -56.9602 Td -(7003 static char buf[100];) 122.3184 Tj -0 -66.4535 Td -(7004 int fd;) 61.1592 Tj -0 -75.9469 Td -(7005 ) 21.8426 Tj -0 -85.4403 Td -(7006 // Assumes three file descriptors open.) 200.9517 Tj -0 -94.9336 Td -(7007 while\(\(fd = open\("console", O_RDWR\)\) >= 0\){) 218.4257 Tj -0 -104.427 Td -(7008 if\(fd >= 3\){) 91.7388 Tj -0 -113.9203 Td -(7009 close\(fd\);) 91.7388 Tj -0 -123.4137 Td -(7010 break;) 74.2647 Tj -0 -132.9071 Td -(7011 }) 43.6851 Tj -0 -142.4004 Td -(7012 }) 34.9481 Tj -0 -151.8938 Td -(7013 ) 21.8426 Tj -0 -161.3871 Td -(7014 // Read and run input commands.) 166.0035 Tj -0 -170.8805 Td -(7015 while\(getcmd\(buf, sizeof\(buf\)\) >= 0\){) 192.2146 Tj -0 -180.3739 Td -(7016 if\(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '\){) 266.4794 Tj -0 -189.8672 Td -(7017 // Clumsy but will have to do for now.) 214.0572 Tj -0 -199.3606 Td -(7018 // Chdir has no effect on the parent if run in the c\ -hild.) 297.059 Tj -0 -208.8539 Td -(7019 buf[strlen\(buf\)-1] = 0; // chop \\n) 200.9517 Tj -0 -218.3473 Td -(7020 if\(chdir\(buf+3\) < 0\)) 135.4239 Tj -0 -227.8407 Td -(7021 printf\(2, "cannot cd %s\\n", buf+3\);) 209.6887 Tj -0 -237.334 Td -(7022 continue;) 87.3703 Tj -0 -246.8274 Td -(7023 }) 43.6851 Tj -0 -256.3207 Td -(7024 if\(fork1\(\) == 0\)) 109.2129 Tj -0 -265.8141 Td -(7025 runcmd\(parsecmd\(buf\)\);) 144.161 Tj -0 -275.3075 Td -(7026 wait\(\);) 69.8962 Tj -0 -284.8008 Td -(7027 }) 34.9481 Tj -0 -294.2942 Td -(7028 exit\(\);) 61.1592 Tj -0 -303.7875 Td -(7029 }) 26.2111 Tj -0 -313.2809 Td -(7030 ) 21.8426 Tj -0 -322.7743 Td -(7031 void) 39.3166 Tj -0 -332.2676 Td -(7032 panic\(char *s\)) 83.0018 Tj -0 -341.761 Td -(7033 {) 26.2111 Tj -0 -351.2543 Td -(7034 printf\(2, "%s\\n", s\);) 122.3184 Tj -0 -360.7477 Td -(7035 exit\(\);) 61.1592 Tj -0 -370.2411 Td -(7036 }) 26.2111 Tj -0 -379.7344 Td -(7037 ) 21.8426 Tj -0 -389.2278 Td -(7038 int) 34.9481 Tj -0 -398.7211 Td -(7039 fork1\(void\)) 69.8962 Tj -0 -408.2145 Td -(7040 {) 26.2111 Tj -0 -417.7079 Td -(7041 int pid;) 65.5277 Tj -0 -427.2012 Td -(7042 ) 21.8426 Tj -0 -436.6946 Td -(7043 pid = fork\(\);) 87.3703 Tj -0 -446.1879 Td -(7044 if\(pid == -1\)) 87.3703 Tj -0 -455.6813 Td -(7045 panic\("fork"\);) 100.4758 Tj -0 -465.1747 Td -(7046 return pid;) 78.6333 Tj -0 -474.668 Td -(7047 }) 26.2111 Tj -0 -484.1614 Td -(7048 ) 21.8426 Tj -0 -493.6547 Td -(7049 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 70) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 5) 152.898 Tj -0 -28.4801 Td -(7050 // Constructors) 87.3703 Tj -0 -37.9735 Td -(7051 ) 21.8426 Tj -0 -47.4668 Td -(7052 struct cmd*) 69.8962 Tj -0 -56.9602 Td -(7053 execcmd\(void\)) 78.6333 Tj -0 -66.4535 Td -(7054 {) 26.2111 Tj -0 -75.9469 Td -(7055 struct execcmd *cmd;) 117.9499 Tj -0 -85.4403 Td -(7056 ) 21.8426 Tj -0 -94.9336 Td -(7057 cmd = malloc\(sizeof\(*cmd\)\);) 148.5295 Tj -0 -104.427 Td -(7058 memset\(cmd, 0, sizeof\(*cmd\)\);) 157.2665 Tj -0 -113.9203 Td -(7059 cmd->type = EXEC;) 104.8443 Tj -0 -123.4137 Td -(7060 return \(struct cmd*\)cmd;) 135.4239 Tj -0 -132.9071 Td -(7061 }) 26.2111 Tj -0 -142.4004 Td -(7062 ) 21.8426 Tj -0 -151.8938 Td -(7063 struct cmd*) 69.8962 Tj -0 -161.3871 Td -(7064 redircmd\(struct cmd *subcmd, char *file, char *efile, int\ - mode, int fd\)) 332.0071 Tj -0 -170.8805 Td -(7065 {) 26.2111 Tj -0 -180.3739 Td -(7066 struct redircmd *cmd;) 122.3184 Tj -0 -189.8672 Td -(7067 ) 21.8426 Tj -0 -199.3606 Td -(7068 cmd = malloc\(sizeof\(*cmd\)\);) 148.5295 Tj -0 -208.8539 Td -(7069 memset\(cmd, 0, sizeof\(*cmd\)\);) 157.2665 Tj -0 -218.3473 Td -(7070 cmd->type = REDIR;) 109.2129 Tj -0 -227.8407 Td -(7071 cmd->cmd = subcmd;) 109.2129 Tj -0 -237.334 Td -(7072 cmd->file = file;) 104.8443 Tj -0 -246.8274 Td -(7073 cmd->efile = efile;) 113.5814 Tj -0 -256.3207 Td -(7074 cmd->mode = mode;) 104.8443 Tj -0 -265.8141 Td -(7075 cmd->fd = fd;) 87.3703 Tj -0 -275.3075 Td -(7076 return \(struct cmd*\)cmd;) 135.4239 Tj -0 -284.8008 Td -(7077 }) 26.2111 Tj -0 -294.2942 Td -(7078 ) 21.8426 Tj -0 -303.7875 Td -(7079 struct cmd*) 69.8962 Tj -0 -313.2809 Td -(7080 pipecmd\(struct cmd *left, struct cmd *right\)) 214.0572 Tj -0 -322.7743 Td -(7081 {) 26.2111 Tj -0 -332.2676 Td -(7082 struct pipecmd *cmd;) 117.9499 Tj -0 -341.761 Td -(7083 ) 21.8426 Tj -0 -351.2543 Td -(7084 cmd = malloc\(sizeof\(*cmd\)\);) 148.5295 Tj -0 -360.7477 Td -(7085 memset\(cmd, 0, sizeof\(*cmd\)\);) 157.2665 Tj -0 -370.2411 Td -(7086 cmd->type = PIPE;) 104.8443 Tj -0 -379.7344 Td -(7087 cmd->left = left;) 104.8443 Tj -0 -389.2278 Td -(7088 cmd->right = right;) 113.5814 Tj -0 -398.7211 Td -(7089 return \(struct cmd*\)cmd;) 135.4239 Tj -0 -408.2145 Td -(7090 }) 26.2111 Tj -0 -417.7079 Td -(7091 ) 21.8426 Tj -0 -427.2012 Td -(7092 ) 21.8426 Tj -0 -436.6946 Td -(7093 ) 21.8426 Tj -0 -446.1879 Td -(7094 ) 21.8426 Tj -0 -455.6813 Td -(7095 ) 21.8426 Tj -0 -465.1747 Td -(7096 ) 21.8426 Tj -0 -474.668 Td -(7097 ) 21.8426 Tj -0 -484.1614 Td -(7098 ) 21.8426 Tj -0 -493.6547 Td -(7099 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 70) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 78 78 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 6) 152.898 Tj -0 -28.4801 Td -(7100 struct cmd*) 69.8962 Tj -0 -37.9735 Td -(7101 listcmd\(struct cmd *left, struct cmd *right\)) 214.0572 Tj -0 -47.4668 Td -(7102 {) 26.2111 Tj -0 -56.9602 Td -(7103 struct listcmd *cmd;) 117.9499 Tj -0 -66.4535 Td -(7104 ) 21.8426 Tj -0 -75.9469 Td -(7105 cmd = malloc\(sizeof\(*cmd\)\);) 148.5295 Tj -0 -85.4403 Td -(7106 memset\(cmd, 0, sizeof\(*cmd\)\);) 157.2665 Tj -0 -94.9336 Td -(7107 cmd->type = LIST;) 104.8443 Tj -0 -104.427 Td -(7108 cmd->left = left;) 104.8443 Tj -0 -113.9203 Td -(7109 cmd->right = right;) 113.5814 Tj -0 -123.4137 Td -(7110 return \(struct cmd*\)cmd;) 135.4239 Tj -0 -132.9071 Td -(7111 }) 26.2111 Tj -0 -142.4004 Td -(7112 ) 21.8426 Tj -0 -151.8938 Td -(7113 struct cmd*) 69.8962 Tj -0 -161.3871 Td -(7114 backcmd\(struct cmd *subcmd\)) 139.7925 Tj -0 -170.8805 Td -(7115 {) 26.2111 Tj -0 -180.3739 Td -(7116 struct backcmd *cmd;) 117.9499 Tj -0 -189.8672 Td -(7117 ) 21.8426 Tj -0 -199.3606 Td -(7118 cmd = malloc\(sizeof\(*cmd\)\);) 148.5295 Tj -0 -208.8539 Td -(7119 memset\(cmd, 0, sizeof\(*cmd\)\);) 157.2665 Tj -0 -218.3473 Td -(7120 cmd->type = BACK;) 104.8443 Tj -0 -227.8407 Td -(7121 cmd->cmd = subcmd;) 109.2129 Tj -0 -237.334 Td -(7122 return \(struct cmd*\)cmd;) 135.4239 Tj -0 -246.8274 Td -(7123 }) 26.2111 Tj -0 -256.3207 Td -(7124 ) 21.8426 Tj -0 -265.8141 Td -(7125 ) 21.8426 Tj -0 -275.3075 Td -(7126 ) 21.8426 Tj -0 -284.8008 Td -(7127 ) 21.8426 Tj -0 -294.2942 Td -(7128 ) 21.8426 Tj -0 -303.7875 Td -(7129 ) 21.8426 Tj -0 -313.2809 Td -(7130 ) 21.8426 Tj -0 -322.7743 Td -(7131 ) 21.8426 Tj -0 -332.2676 Td -(7132 ) 21.8426 Tj -0 -341.761 Td -(7133 ) 21.8426 Tj -0 -351.2543 Td -(7134 ) 21.8426 Tj -0 -360.7477 Td -(7135 ) 21.8426 Tj -0 -370.2411 Td -(7136 ) 21.8426 Tj -0 -379.7344 Td -(7137 ) 21.8426 Tj -0 -389.2278 Td -(7138 ) 21.8426 Tj -0 -398.7211 Td -(7139 ) 21.8426 Tj -0 -408.2145 Td -(7140 ) 21.8426 Tj -0 -417.7079 Td -(7141 ) 21.8426 Tj -0 -427.2012 Td -(7142 ) 21.8426 Tj -0 -436.6946 Td -(7143 ) 21.8426 Tj -0 -446.1879 Td -(7144 ) 21.8426 Tj -0 -455.6813 Td -(7145 ) 21.8426 Tj -0 -465.1747 Td -(7146 ) 21.8426 Tj -0 -474.668 Td -(7147 ) 21.8426 Tj -0 -484.1614 Td -(7148 ) 21.8426 Tj -0 -493.6547 Td -(7149 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 71) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 7) 152.898 Tj -0 -28.4801 Td -(7150 // Parsing) 65.5277 Tj -0 -37.9735 Td -(7151 ) 21.8426 Tj -0 -47.4668 Td -(7152 char whitespace[] = " \\t\\r\\n\\v";) 161.635 Tj -0 -56.9602 Td -(7153 char symbols[] = "<|>&;\(\)";) 139.7925 Tj -0 -66.4535 Td -(7154 ) 21.8426 Tj -0 -75.9469 Td -(7155 int) 34.9481 Tj -0 -85.4403 Td -(7156 gettoken\(char **ps, char *es, char **q, char **eq\)) 240.2683 Tj -0 -94.9336 Td -(7157 {) 26.2111 Tj -0 -104.427 Td -(7158 char *s;) 65.5277 Tj -0 -113.9203 Td -(7159 int ret;) 65.5277 Tj -0 -123.4137 Td -(7160 ) 21.8426 Tj -0 -132.9071 Td -(7161 s = *ps;) 65.5277 Tj -0 -142.4004 Td -(7162 while\(s < es && strchr\(whitespace, *s\)\)) 200.9517 Tj -0 -151.8938 Td -(7163 s++;) 56.7907 Tj -0 -161.3871 Td -(7164 if\(q\)) 52.4222 Tj -0 -170.8805 Td -(7165 *q = s;) 69.8962 Tj -0 -180.3739 Td -(7166 ret = *s;) 69.8962 Tj -0 -189.8672 Td -(7167 switch\(*s\){) 78.6333 Tj -0 -199.3606 Td -(7168 case 0:) 61.1592 Tj -0 -208.8539 Td -(7169 break;) 65.5277 Tj -0 -218.3473 Td -(7170 case '|':) 69.8962 Tj -0 -227.8407 Td -(7171 case '\(':) 69.8962 Tj -0 -237.334 Td -(7172 case '\)':) 69.8962 Tj -0 -246.8274 Td -(7173 case ';':) 69.8962 Tj -0 -256.3207 Td -(7174 case '&':) 69.8962 Tj -0 -265.8141 Td -(7175 case '<':) 69.8962 Tj -0 -275.3075 Td -(7176 s++;) 56.7907 Tj -0 -284.8008 Td -(7177 break;) 65.5277 Tj -0 -294.2942 Td -(7178 case '>':) 69.8962 Tj -0 -303.7875 Td -(7179 s++;) 56.7907 Tj -0 -313.2809 Td -(7180 if\(*s == '>'\){) 100.4758 Tj -0 -322.7743 Td -(7181 ret = '+';) 91.7388 Tj -0 -332.2676 Td -(7182 s++;) 65.5277 Tj -0 -341.761 Td -(7183 }) 43.6851 Tj -0 -351.2543 Td -(7184 break;) 65.5277 Tj -0 -360.7477 Td -(7185 default:) 65.5277 Tj -0 -370.2411 Td -(7186 ret = 'a';) 83.0018 Tj -0 -379.7344 Td -(7187 while\(s < es && !strchr\(whitespace, *s\) && !strchr\(\ -symbols, *s\)\)) 318.9016 Tj -0 -389.2278 Td -(7188 s++;) 65.5277 Tj -0 -398.7211 Td -(7189 break;) 65.5277 Tj -0 -408.2145 Td -(7190 }) 34.9481 Tj -0 -417.7079 Td -(7191 if\(eq\)) 56.7907 Tj -0 -427.2012 Td -(7192 *eq = s;) 74.2647 Tj -0 -436.6946 Td -(7193 ) 21.8426 Tj -0 -446.1879 Td -(7194 while\(s < es && strchr\(whitespace, *s\)\)) 200.9517 Tj -0 -455.6813 Td -(7195 s++;) 56.7907 Tj -0 -465.1747 Td -(7196 *ps = s;) 65.5277 Tj -0 -474.668 Td -(7197 return ret;) 78.6333 Tj -0 -484.1614 Td -(7198 }) 26.2111 Tj -0 -493.6547 Td -(7199 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 71) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 79 79 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 8) 152.898 Tj -0 -28.4801 Td -(7200 int) 34.9481 Tj -0 -37.9735 Td -(7201 peek\(char **ps, char *es, char *toks\)) 183.4776 Tj -0 -47.4668 Td -(7202 {) 26.2111 Tj -0 -56.9602 Td -(7203 char *s;) 65.5277 Tj -0 -66.4535 Td -(7204 ) 21.8426 Tj -0 -75.9469 Td -(7205 s = *ps;) 65.5277 Tj -0 -85.4403 Td -(7206 while\(s < es && strchr\(whitespace, *s\)\)) 200.9517 Tj -0 -94.9336 Td -(7207 s++;) 56.7907 Tj -0 -104.427 Td -(7208 *ps = s;) 65.5277 Tj -0 -113.9203 Td -(7209 return *s && strchr\(toks, *s\);) 161.635 Tj -0 -123.4137 Td -(7210 }) 26.2111 Tj -0 -132.9071 Td -(7211 ) 21.8426 Tj -0 -142.4004 Td -(7212 struct cmd *parseline\(char**, char*\);) 183.4776 Tj -0 -151.8938 Td -(7213 struct cmd *parsepipe\(char**, char*\);) 183.4776 Tj -0 -161.3871 Td -(7214 struct cmd *parseexec\(char**, char*\);) 183.4776 Tj -0 -170.8805 Td -(7215 struct cmd *nulterminate\(struct cmd*\);) 187.8461 Tj -0 -180.3739 Td -(7216 ) 21.8426 Tj -0 -189.8672 Td -(7217 struct cmd*) 69.8962 Tj -0 -199.3606 Td -(7218 parsecmd\(char *s\)) 96.1073 Tj -0 -208.8539 Td -(7219 {) 26.2111 Tj -0 -218.3473 Td -(7220 char *es;) 69.8962 Tj -0 -227.8407 Td -(7221 struct cmd *cmd;) 100.4758 Tj -0 -237.334 Td -(7222 ) 21.8426 Tj -0 -246.8274 Td -(7223 es = s + strlen\(s\);) 113.5814 Tj -0 -256.3207 Td -(7224 cmd = parseline\(&s, es\);) 135.4239 Tj -0 -265.8141 Td -(7225 peek\(&s, es, ""\);) 104.8443 Tj -0 -275.3075 Td -(7226 if\(s != es\){) 83.0018 Tj -0 -284.8008 Td -(7227 printf\(2, "leftovers: %s\\n", s\);) 179.1091 Tj -0 -294.2942 Td -(7228 panic\("syntax"\);) 109.2129 Tj -0 -303.7875 Td -(7229 }) 34.9481 Tj -0 -313.2809 Td -(7230 nulterminate\(cmd\);) 109.2129 Tj -0 -322.7743 Td -(7231 return cmd;) 78.6333 Tj -0 -332.2676 Td -(7232 }) 26.2111 Tj -0 -341.761 Td -(7233 ) 21.8426 Tj -0 -351.2543 Td -(7234 struct cmd*) 69.8962 Tj -0 -360.7477 Td -(7235 parseline\(char **ps, char *es\)) 152.898 Tj -0 -370.2411 Td -(7236 {) 26.2111 Tj -0 -379.7344 Td -(7237 struct cmd *cmd;) 100.4758 Tj -0 -389.2278 Td -(7238 ) 21.8426 Tj -0 -398.7211 Td -(7239 cmd = parsepipe\(ps, es\);) 135.4239 Tj -0 -408.2145 Td -(7240 while\(peek\(ps, es, "&"\)\){) 139.7925 Tj -0 -417.7079 Td -(7241 gettoken\(ps, es, 0, 0\);) 139.7925 Tj -0 -427.2012 Td -(7242 cmd = backcmd\(cmd\);) 122.3184 Tj -0 -436.6946 Td -(7243 }) 34.9481 Tj -0 -446.1879 Td -(7244 if\(peek\(ps, es, ";"\)\){) 126.6869 Tj -0 -455.6813 Td -(7245 gettoken\(ps, es, 0, 0\);) 139.7925 Tj -0 -465.1747 Td -(7246 cmd = listcmd\(cmd, parseline\(ps, es\)\);) 205.3202 Tj -0 -474.668 Td -(7247 }) 34.9481 Tj -0 -484.1614 Td -(7248 return cmd;) 78.6333 Tj -0 -493.6547 Td -(7249 }) 26.2111 Tj -0 -522.1348 Td -(Sheet 72) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 9) 152.898 Tj -0 -28.4801 Td -(7250 struct cmd*) 69.8962 Tj -0 -37.9735 Td -(7251 parsepipe\(char **ps, char *es\)) 152.898 Tj -0 -47.4668 Td -(7252 {) 26.2111 Tj -0 -56.9602 Td -(7253 struct cmd *cmd;) 100.4758 Tj -0 -66.4535 Td -(7254 ) 21.8426 Tj -0 -75.9469 Td -(7255 cmd = parseexec\(ps, es\);) 135.4239 Tj -0 -85.4403 Td -(7256 if\(peek\(ps, es, "|"\)\){) 126.6869 Tj -0 -94.9336 Td -(7257 gettoken\(ps, es, 0, 0\);) 139.7925 Tj -0 -104.427 Td -(7258 cmd = pipecmd\(cmd, parsepipe\(ps, es\)\);) 205.3202 Tj -0 -113.9203 Td -(7259 }) 34.9481 Tj -0 -123.4137 Td -(7260 return cmd;) 78.6333 Tj -0 -132.9071 Td -(7261 }) 26.2111 Tj -0 -142.4004 Td -(7262 ) 21.8426 Tj -0 -151.8938 Td -(7263 struct cmd*) 69.8962 Tj -0 -161.3871 Td -(7264 parseredirs\(struct cmd *cmd, char **ps, char *es\)) 235.8998 Tj -0 -170.8805 Td -(7265 {) 26.2111 Tj -0 -180.3739 Td -(7266 int tok;) 65.5277 Tj -0 -189.8672 Td -(7267 char *q, *eq;) 87.3703 Tj -0 -199.3606 Td -(7268 ) 21.8426 Tj -0 -208.8539 Td -(7269 while\(peek\(ps, es, "<>"\)\){) 144.161 Tj -0 -218.3473 Td -(7270 tok = gettoken\(ps, es, 0, 0\);) 166.0035 Tj -0 -227.8407 Td -(7271 if\(gettoken\(ps, es, &q, &eq\) != 'a'\)) 196.5831 Tj -0 -237.334 Td -(7272 panic\("missing file for redirection"\);) 214.0572 Tj -0 -246.8274 Td -(7273 switch\(tok\){) 91.7388 Tj -0 -256.3207 Td -(7274 case '<':) 78.6333 Tj -0 -265.8141 Td -(7275 cmd = redircmd\(cmd, q, eq, O_RDONLY, 0\);) 222.7942 Tj -0 -275.3075 Td -(7276 break;) 74.2647 Tj -0 -284.8008 Td -(7277 case '>':) 78.6333 Tj -0 -294.2942 Td -(7278 cmd = redircmd\(cmd, q, eq, O_WRONLY|O_CREATE, 1\);) 262.1109 Tj -0 -303.7875 Td -(7279 break;) 74.2647 Tj -0 -313.2809 Td -(7280 case '+': // >>) 109.2129 Tj -0 -322.7743 Td -(7281 cmd = redircmd\(cmd, q, eq, O_WRONLY|O_CREATE, 1\);) 262.1109 Tj -0 -332.2676 Td -(7282 break;) 74.2647 Tj -0 -341.761 Td -(7283 }) 43.6851 Tj -0 -351.2543 Td -(7284 }) 34.9481 Tj -0 -360.7477 Td -(7285 return cmd;) 78.6333 Tj -0 -370.2411 Td -(7286 }) 26.2111 Tj -0 -379.7344 Td -(7287 ) 21.8426 Tj -0 -389.2278 Td -(7288 ) 21.8426 Tj -0 -398.7211 Td -(7289 ) 21.8426 Tj -0 -408.2145 Td -(7290 ) 21.8426 Tj -0 -417.7079 Td -(7291 ) 21.8426 Tj -0 -427.2012 Td -(7292 ) 21.8426 Tj -0 -436.6946 Td -(7293 ) 21.8426 Tj -0 -446.1879 Td -(7294 ) 21.8426 Tj -0 -455.6813 Td -(7295 ) 21.8426 Tj -0 -465.1747 Td -(7296 ) 21.8426 Tj -0 -474.668 Td -(7297 ) 21.8426 Tj -0 -484.1614 Td -(7298 ) 21.8426 Tj -0 -493.6547 Td -(7299 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 72) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Page: 80 80 -%%BeginPageSetup -%%PageOrientation: Landscape -pdfStartPage -180 rotate --612 -792 translate -0 0 612 792 re W -%%EndPageSetup -[] 0 d -1 i -0 j -0 J -10 M -1 w -/DeviceGray {} cs -[0] sc -/DeviceGray {} CS -[0] SC -false op -false OP -{} settransfer -0 0 612 792 re -W -q -q -[0.1 0 0 0.1 0 0] cm -q -180 3960 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 738.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 10) 157.2665 Tj -0 -28.4801 Td -(7300 struct cmd*) 69.8962 Tj -0 -37.9735 Td -(7301 parseblock\(char **ps, char *es\)) 157.2665 Tj -0 -47.4668 Td -(7302 {) 26.2111 Tj -0 -56.9602 Td -(7303 struct cmd *cmd;) 100.4758 Tj -0 -66.4535 Td -(7304 ) 21.8426 Tj -0 -75.9469 Td -(7305 if\(!peek\(ps, es, "\("\)\)) 126.6869 Tj -0 -85.4403 Td -(7306 panic\("parseblock"\);) 126.6869 Tj -0 -94.9336 Td -(7307 gettoken\(ps, es, 0, 0\);) 131.0554 Tj -0 -104.427 Td -(7308 cmd = parseline\(ps, es\);) 135.4239 Tj -0 -113.9203 Td -(7309 if\(!peek\(ps, es, "\)"\)\)) 126.6869 Tj -0 -123.4137 Td -(7310 panic\("syntax - missing \)"\);) 161.635 Tj -0 -132.9071 Td -(7311 gettoken\(ps, es, 0, 0\);) 131.0554 Tj -0 -142.4004 Td -(7312 cmd = parseredirs\(cmd, ps, es\);) 166.0035 Tj -0 -151.8938 Td -(7313 return cmd;) 78.6333 Tj -0 -161.3871 Td -(7314 }) 26.2111 Tj -0 -170.8805 Td -(7315 ) 21.8426 Tj -0 -180.3739 Td -(7316 struct cmd*) 69.8962 Tj -0 -189.8672 Td -(7317 parseexec\(char **ps, char *es\)) 152.898 Tj -0 -199.3606 Td -(7318 {) 26.2111 Tj -0 -208.8539 Td -(7319 char *q, *eq;) 87.3703 Tj -0 -218.3473 Td -(7320 int tok, argc;) 91.7388 Tj -0 -227.8407 Td -(7321 struct execcmd *cmd;) 117.9499 Tj -0 -237.334 Td -(7322 struct cmd *ret;) 100.4758 Tj -0 -246.8274 Td -(7323 ) 21.8426 Tj -0 -256.3207 Td -(7324 if\(peek\(ps, es, "\("\)\)) 122.3184 Tj -0 -265.8141 Td -(7325 return parseblock\(ps, es\);) 152.898 Tj -0 -275.3075 Td -(7326 ) 21.8426 Tj -0 -284.8008 Td -(7327 ret = execcmd\(\);) 100.4758 Tj -0 -294.2942 Td -(7328 cmd = \(struct execcmd*\)ret;) 148.5295 Tj -0 -303.7875 Td -(7329 ) 21.8426 Tj -0 -313.2809 Td -(7330 argc = 0;) 69.8962 Tj -0 -322.7743 Td -(7331 ret = parseredirs\(ret, ps, es\);) 166.0035 Tj -0 -332.2676 Td -(7332 while\(!peek\(ps, es, "|\)&;"\)\){) 157.2665 Tj -0 -341.761 Td -(7333 if\(\(tok=gettoken\(ps, es, &q, &eq\)\) == 0\)) 214.0572 Tj -0 -351.2543 Td -(7334 break;) 74.2647 Tj -0 -360.7477 Td -(7335 if\(tok != 'a'\)) 100.4758 Tj -0 -370.2411 Td -(7336 panic\("syntax"\);) 117.9499 Tj -0 -379.7344 Td -(7337 cmd->argv[argc] = q;) 126.6869 Tj -0 -389.2278 Td -(7338 cmd->eargv[argc] = eq;) 135.4239 Tj -0 -398.7211 Td -(7339 argc++;) 69.8962 Tj -0 -408.2145 Td -(7340 if\(argc >= MAXARGS\)) 122.3184 Tj -0 -417.7079 Td -(7341 panic\("too many args"\);) 148.5295 Tj -0 -427.2012 Td -(7342 ret = parseredirs\(ret, ps, es\);) 174.7406 Tj -0 -436.6946 Td -(7343 }) 34.9481 Tj -0 -446.1879 Td -(7344 cmd->argv[argc] = 0;) 117.9499 Tj -0 -455.6813 Td -(7345 cmd->eargv[argc] = 0;) 122.3184 Tj -0 -465.1747 Td -(7346 return ret;) 78.6333 Tj -0 -474.668 Td -(7347 }) 26.2111 Tj -0 -484.1614 Td -(7348 ) 21.8426 Tj -0 -493.6547 Td -(7349 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 73) 34.9481 Tj -Q -Q -q -180 500 5760 3460 re -W -/DeviceGray {} CS -[0] SC -/DeviceGray {} cs -[0] sc -q -[10 0 0 10 0 0] cm -[1 0 0 1 0 0] Tm -0 0 Td -[0 -0.9679 1 0 564.72 392.865] Tm -0 0 Td -/F8_0 8.7022 Tf -(Sep 3 00:44 2009 xv6/sh.c Page 11) 157.2665 Tj -0 -28.4801 Td -(7350 // NUL-terminate all the counted strings.) 200.9517 Tj -0 -37.9735 Td -(7351 struct cmd*) 69.8962 Tj -0 -47.4668 Td -(7352 nulterminate\(struct cmd *cmd\)) 148.5295 Tj -0 -56.9602 Td -(7353 {) 26.2111 Tj -0 -66.4535 Td -(7354 int i;) 56.7907 Tj -0 -75.9469 Td -(7355 struct backcmd *bcmd;) 122.3184 Tj -0 -85.4403 Td -(7356 struct execcmd *ecmd;) 122.3184 Tj -0 -94.9336 Td -(7357 struct listcmd *lcmd;) 122.3184 Tj -0 -104.427 Td -(7358 struct pipecmd *pcmd;) 122.3184 Tj -0 -113.9203 Td -(7359 struct redircmd *rcmd;) 126.6869 Tj -0 -123.4137 Td -(7360 ) 21.8426 Tj -0 -132.9071 Td -(7361 if\(cmd == 0\)) 83.0018 Tj -0 -142.4004 Td -(7362 return 0;) 78.6333 Tj -0 -151.8938 Td -(7363 ) 21.8426 Tj -0 -161.3871 Td -(7364 switch\(cmd->type\){) 109.2129 Tj -0 -170.8805 Td -(7365 case EXEC:) 74.2647 Tj -0 -180.3739 Td -(7366 ecmd = \(struct execcmd*\)cmd;) 161.635 Tj -0 -189.8672 Td -(7367 for\(i=0; ecmd->argv[i]; i++\)) 161.635 Tj -0 -199.3606 Td -(7368 *ecmd->eargv[i] = 0;) 135.4239 Tj -0 -208.8539 Td -(7369 break;) 65.5277 Tj -0 -218.3473 Td -(7370 ) 21.8426 Tj -0 -227.8407 Td -(7371 case REDIR:) 78.6333 Tj -0 -237.334 Td -(7372 rcmd = \(struct redircmd*\)cmd;) 166.0035 Tj -0 -246.8274 Td -(7373 nulterminate\(rcmd->cmd\);) 144.161 Tj -0 -256.3207 Td -(7374 *rcmd->efile = 0;) 113.5814 Tj -0 -265.8141 Td -(7375 break;) 65.5277 Tj -0 -275.3075 Td -(7376 ) 21.8426 Tj -0 -284.8008 Td -(7377 case PIPE:) 74.2647 Tj -0 -294.2942 Td -(7378 pcmd = \(struct pipecmd*\)cmd;) 161.635 Tj -0 -303.7875 Td -(7379 nulterminate\(pcmd->left\);) 148.5295 Tj -0 -313.2809 Td -(7380 nulterminate\(pcmd->right\);) 152.898 Tj -0 -322.7743 Td -(7381 break;) 65.5277 Tj -0 -332.2676 Td -(7382 ) 21.8426 Tj -0 -341.761 Td -(7383 case LIST:) 74.2647 Tj -0 -351.2543 Td -(7384 lcmd = \(struct listcmd*\)cmd;) 161.635 Tj -0 -360.7477 Td -(7385 nulterminate\(lcmd->left\);) 148.5295 Tj -0 -370.2411 Td -(7386 nulterminate\(lcmd->right\);) 152.898 Tj -0 -379.7344 Td -(7387 break;) 65.5277 Tj -0 -389.2278 Td -(7388 ) 21.8426 Tj -0 -398.7211 Td -(7389 case BACK:) 74.2647 Tj -0 -408.2145 Td -(7390 bcmd = \(struct backcmd*\)cmd;) 161.635 Tj -0 -417.7079 Td -(7391 nulterminate\(bcmd->cmd\);) 144.161 Tj -0 -427.2012 Td -(7392 break;) 65.5277 Tj -0 -436.6946 Td -(7393 }) 34.9481 Tj -0 -446.1879 Td -(7394 return cmd;) 78.6333 Tj -0 -455.6813 Td -(7395 }) 26.2111 Tj -0 -465.1747 Td -(7396 ) 21.8426 Tj -0 -474.668 Td -(7397 ) 21.8426 Tj -0 -484.1614 Td -(7398 ) 21.8426 Tj -0 -493.6547 Td -(7399 ) 21.8426 Tj -0 -522.1348 Td -(Sheet 73) 34.9481 Tj -Q -Q -Q -Q -showpage -%%PageTrailer -pdfEndPage -%%Trailer -end -%%DocumentSuppliedResources: -%%+ font APYGPQ+LucidaSans-Typewriter83 -%%EOF