Ported Plan 9
Total Page:16
File Type:pdf, Size:1020Kb
Recent Plan 9 Work at Bell Labs Geoff Collyer [email protected]−labs.com *All L=>oH=JoHEAI MKHH=O0Ell,NAM JAHIAO%'%" 75) ABSTRACT *All L=>I HA?AnJlO FoHJA@ 2l=n ' Jo nAM IOIJAmI MEJD non-2+ =H?DE JA?JKHAI. 6DEI EI = IJ=JKI HAFoHJ on JDoIA FoHJI =n@ = IKmm=HO oB MD=J DAlFA@,MD=J @E@nߣJ =n@MD=J ?oKl@. 1. Introduction 1n mO CHoKF oB 2l=n ' @ALAloFAHI =n@ KIAHI =J *All L=>I En MKHH=O 0Ell @KHEnC JDA l=IJ JMo OA=HI &ߞ oH Io, mK?D oB oKH MoHk D=I >AAn >=IA@ on FoHJI oB 2l=n ' Jo m=?DEnAI oJDAH JD=n JDA 1*M 2+. 6DEI J=lk MEll @AI?HE>A JDA FoHJI, MD=J MA KIA JDAm oHFl=nJoKIA JDAmBoH,=n@MD=J MA lA=HnA@. )I KIK=l, JDA >Klk oB 2l=n ' ?o@A EI IKBBE?EAnJlO FoHJ=>lA JD=J onlO JDA kAHnAl nAA@I Jo >A moLA@ Jo = nAM IOIJAm, =n@ ALAn JD=J onlO EnLolLAI FoFKl=JEnC = IK>@EHA?JoHO oB /sys/src/9 =n@ FoIIE>lO ?HA=JEnC = >ooJIJH=F FHoCH=m En /sys/src/boot.) FoHJ Jo = IOIJAm BoH MDE?D MA D=LA no ?omFElAH =n@ no IEmEl=H kAHnAl MoKl@ HAGKEHA IK>IJ=nJE=llOmoHA MoHk,=I@AI?HE>A@EnHABAHAn?A [$]. 2. Non−PC Ports: Common Problems and Techniques 9A FoHJA@ 2l=n ' Jo 2oMAH2+ "#, "" =n@ "# m=?DEnAI =n@ Jo )4M ' $ =n@ +oHJAN-)&m=?DEnAI. 6DAO=ll ID=HA ?AHJ=En?l=IIAIoB o>IJ=?lAI. 2.1. Memory Barriers and Caches ) B=EHlO ?ommon mAmoHO =H?DEJA?JKHA EI = JD=J store EnIJHK?JEonI GKAKA @=J= En = write buffer En JDA FHo?AIIoH, MDE?D EI CH=@K=llO @H=EnA@ Jo = BEHIJ-lALAl ?=?DA, JDAn Jo = l=HCAH >KJ IloMAH IA?on@-lALAl ?=?DA, =n@ BEn=llO Jo ,4)M. 6DA 1*M 2+ mo@Al FHoLE@AI ?=?DA-?oDAHAnJ mAmoHO, Io JD=J MA H=HAlO D=LA Jo MoHHO =>oKJ ?=?DA m=EnJAn=n?A En JDA 2+ FoHJ. +=?DA-?oDAHAnJ mAmoHO l=HCAlO DE@AI JDA IFAA@ JHE?kI FKllA@ >O mo@AHn FHo?AIIoHI, MDE?D En?lK@A =CCHAIIELA ?=?DEnC JDHoKCD mKlJEFlA lALAlI oB ?=?DA, =n@ oKJ-oB-oH@AH oH @Al=OA@ mAmoHO IJoHAI =n@ EnIJHK?JEon ANA?KJEon. -LAn on JDA 2+, MA IJEll o??=IEon=llO D=LA Jo ANA?KJA @=J= oH EnIJHK?JEon >=HHEAH EnIJHK?JEonI >O ?=llEnC coherence Jo AnIKHA JD=J FHALEoKI EnIJHK?JEonI =n@ mAmoHO IJoHAI D=LA ?omFlAJA@; BoH AN=mFlA, En JDA EmFlAmAnJ=JEon oB lo?kI Jo =??AlAH=JA noJEBE?=JEon oB oJDAH FHo?AIIoHI JHOEnCJo=?GKEHA JDA lo?k,=n@>ABoHA oH=BJAH,M) JH=nIBAHI. *O ?onJH=IJ, JDA 2oMAH2+ D=I lonC ANFoIA@ JDA =>oLA FHo?AIIoH JHE?kI Jo JDA FHoCH=m mAH, =n@ )4M FHo?AIIoHI =HA noM ?=J?DEnC KF =l=I. 5o En JDA FoHJI JD=J 1 D=LA @onA, F=HJlO oKJ oB F=H=noE=, 1 M=I B=EHlO DA=LO-D=n@A@ En JDA KIA oB >=HHEAH EnIJHK?JEonI Jo =LoE@ IKHFHEIAI. NoM JD=J JDA FoHJI =HA KF =n@ HKnnEnC, IomA oB JDoIA >=HHEAHI =HA >AEnCHAmoLA@=n@ kprof D=I>AAnDAlFBKl EnBEn@EnCDoJ IFoJI@KA Jo>=HHEAHI. 6DA BKll IAGKAn?A oB oFAH=JEonI nAA@A@ Jo CK=H=nJAA JD=J = MHEJA Jo mAmoHO =@@HAII addr D=I ?omFlAJA@ oH =J lA=IJ EI LEIE>lA Jo =ll FAHEFDAH=lI =n@ oJDAH FHo?AIIoHI En JDAIA IOIJAmIEI: ߦ =nEnIJHK?JEon>=HHEAH,JoBoH?A JDA IJoHA EnIJHK?JEonJo?omFlAJA ߦ = @=J= >=HHEAH, Jo BlKID JDA @=J= BHom JDA FHo?AIIoHߣI mAmoHO MHEJA >KBBAH Jo lALAl L@=J= ?=?DA oHmAmoHOEB Kn?=?DA@ ߦ BlKID addrߣIlALAl @=J= ?=?DA lEnA JoJDA lALAl L ?=?DA,EB =nO ߦ BlKID addrߣIlALAl @=J= oHKnEBEA@?=?DA lEnA Jo4)M oHBKHJDAH?=?DA lALAlI 6DEI IAGKAn?A ?oKl@ D=LA Jo >A ANJAn@A@ En BKJKHA Jo =@@EJEon=l lALAlI oB ?=?DA. 6DA )4M L% =H?DEJA?JKHA ?=?DA ?onJHol HACEIJAHI FAHmEJ AECDJ lALAlI oB ?=?DA 6DA BKll IAGKAn?A EI onlO nAA@A@ BoH ?=?DA@ =?JK=llO MHEJA->=?k ?=?DA@ mAmoHO, =n@ @ALE?A HACEIJAHI =HA m=FFA@ =I Kn?=?DA@, Io JDAO onlO HAGKEHA JDA >=HHEAH EnIJHK?JEonI Jo AnIKHA JD=J IJoHAID=LA ?omFlAJA@. +=?DA lEnAI=HA oBJAn! oH$">OJAIlonC. 1n = BAM ?=IAI, BoH AN=mFlA =BJAH ,M) EnFKJ, EJߣI nA?AII=HO Jo EnL=lE@=JA ?=?DA lEnAI H=JDAHJD=nBlKIDEnCJDAm. 9DAnALAHFoIIE>lA,MAߣLA ?onBECKHA@?=?DAIJo>A MHEJA->=?k BoHm=NEmKmIFAA@. 9A EmFoHJA@ 75* ?o@A BHom JDA 2+ FoHJ Jo JDA )4M FoHJI =n@ D=@ Jo BEHIJ =@@ >=HHEAHI =n@ ?=?DA BlKIDEnC Jo EJ. 6DA 75* En-mAmoHO @=J= IJHK?JKHAI m=EnJ=EnA@ F=HJlO >O JDA 75* @HELAHI =n@ F=HJlO >O JDA DoIJ ?onJHollAHI =HA ?KHHAnJlO =llo?=JA@ BHom Kn?=?DA@ mAmoHO >A?=KIA m=n=CEnC JDA ?=?DAI En JDA FHAIAn?A oB IK?D mENA@ @=J= IJHK?JKHAI M=I Joo D=H@: ?onIE@AH = @=J= IJHK?JKHA, JDA BEHIJ F=HJ m=EnJ=EnA@ >O D=H@M=HA, JDA IA? on@ m=EnJ=EnA@ >O IoBJM=HA, =n@ JDA >oKn@=HO >AJMAAn JDAm EI noJ = ?=?DA-lEnA >oKn@=HO,OAJ JDA @=J= IJHK?JKHA EIHAGKEHA@>OD=H@M=HA Jo>A =lECnA@Jo= FoMAHoB . 2.2. Kernel Memory Mapping 1n JDA 8EHJAN =n@ )4M FoHJI, JDA m=NEmKm FDOIE?=l mAmoHO M=I # M* oH lAII JDoKCD noJ =lM=OI IJ=HJEnC =J FDOIE?=l =@@HAII zAHo, Io >O m=FFEnC JDA kAHnAl >=IA KZ-4O Jo LEHJK=l =@@HAIIAI 0x80000000 2oMAH2+, 0xC0000000 61 OM)2!# IOIJAm-on-=-?DEF 5o+ oH 0x60000000 M=HLAll KEHkMoo@ 5o+, MA =HA =>lA Jo =@@HAII =ll oB FDOIE?=l mAmoHO BHom JDA kAHnAl KIEnC JHELE=l LAHIEonI oB kmap =n@ kunmap, KnlEkA JDA 2+ kAHnAl, MDE?D EI m=FFA@ =J LEHJK=l 0xF0000000 OAJ nAA@I Jo >A =>lA Jo =@@HAII KF Jo !.%# /* oB mAmoHO KIEnC kAHnAl LEHJK=l =@@HAIIAI JDoIA =>oLA KZ-4O. 6DA @EBBAHAnJ >=IAI MAHA ?DoIAn Jo FAHmEJ L=HEoKI @ALE?AI Jo >A E@AnJEJO-m=FFA@BoHIEmFlE?EJO. 2.3. Kernel Debugging 6DA 8EHJAN =n@ 1/-2L >o=H@I En?lK@A = noHm=l 1nJAl-& #-?omF=JE>lA IAHE=l FoHJ =n@ = BAM L-,I Kn@AH IoBJM=HA ?onJHol, MDE?D IEmFlEBEAI EnEJE=l FoHJEnC =n@ @A>KCCEnC. 6DA )4M >o=H@I oJDAH JD=n 1/-2L D=LA ?om>EnA@ J6)/ =n@ IAHE=l FoHJI MEJD IFA?E=l ?=>lAI MEJD = 75* ?onnA?JoH =J JDA oJDAH An@. usb/serial noM knoMI DoM Jo @HELA JDAIA FoHJI=n@JDAHA =HA M59En@oMI@HELAHIJoo. On JDA )4M FoHJI MA D=LA An=>lA@ D=H@M=HA M=J?D@oC JEmAHI Io JD=J EB JDA kAHnAl CoAI oBB JDA H=ElI, JDA IOIJAm MEll HAIAJ EJIAlB, JDKI HAJKHnEnC ?onJHol Jo 7->ooJ. Das U−boot EI = ߢKnELAHI=lߣ oFAn-IoKH?A >ooJ lo=@AH @AHELA@ BHom LEnKN =n@ oBJAn FHoLE@A@ ! =I JDA IJo?k >ooJ lo=@AH on non-2+ IOIJAmI. 6DAHA EI IEmEl=H ?o@A En JDA 8EHJAN FoHJI, >KJ EJߣI?KHHAnJlOJKHnA@oBB >A?=KIA HAIAJJEnCJDA 8EHJAN>o=H@IEIlAIIKIABKl. 2.4. ARM Kernel Initialisation 7->ooJ jKIJ l=OI JDA kAHnAlߣI Em=CA @oMn En mAmoHO, MEJDoKJ HAC=H@ BoH IACmAnJ >oKn@=HEAI, Io JDA )4M kAHnAlI HAlo?=JA JDAEH @=J= IACmAnJI Jo JDA ANFA?JA@ FDOIE?=l =@@HAIIAI=n@JDAnzAHoJDAEH*55IACmAnJI. 9A KIA 7->ooJ Jo lo=@ /cfg/pxe/$ether EnJo mAmoHO >ABoHA lo=@EnC JDA kAHnAl, MDE?DF=HIAIJDA En-mAmoHO?oFOJoIEmKl=JA MD=J 9load MoKl@D=LA @onA onJDA 2+. 7->ooJ ?onBECKHAI JDA FHo?AIIoH =n@ L=HEoKI 5o+ @ALE?AI >ABoHA lo=@EnC JDA kAHnAl, MDE?D EI = DAlF >A?=KIA JDAHA =HA m=nO, m=nO BECKH=JELA @E=lI =n@ kno>I JDoKI=n@I oB F=CAI MoHJD JD=J ?=n >A JMA=kA@ =n@ IomAJEmAI mKIJ >A jKIJ Jo CAJ >=IE? BKn?JEon=l EJO. OKH kAHnAlI m=kA =n ABBoHJ Jo ?onBECKHA JDA D=H@M=HA JD=J JDAO KIA, >KJ FHo>=>lO @onߣJ @o JDA BKll jo>. 6EmA EI BEnEJA >KJ D=H@M=HA ?onBECKH=JEon HACEIJAHI =n@ F=@ =n@ CFEo?onBECKH=JEonI=HA noJ oHIoEJ IAAmI. 2.5. Floating Point and Other Emulation 6DA :ElEnN 8EHJAN =n@ M=HLAll KEHkMoo@ >o=H@I D=LA no Blo=JEnC-FoEnJ KnEJI, Io JDA kAH nAl JH=FI =n@ AmKl=JAI Blo=JEnC-FoEnJ EnIJHK?JEonI. 6DEI EI nA?AII=HO >A?=KIA Blo=JEnC-FoEnJ EIKIA@En awk,BoHAN=mFlA. 6DA )4M FoHJIMEll =lIoAmKl=JA ldrex, strex =n@ lo?=llO-EnLAnJA@ cas EnIJHK?JEonI EB JDA FHo?AIIoHJH=FIJDAm=IEllAC=l EnIJHK?JEonI. 2.6. Math Debugging 9A KIA@ = FoHJ oB 9. M. K=D=nߣI paranoia Jo M=J?D BoH AHHoHI En Blo=JEnC-FoEnJ AmKl= JEon. ) nAM FHoCH=m Jo LAHEBO vlong =HEJDmAJE? BoKn@ = ?o@A-CAnAH=JEon >KC En qc MDE?DD=IIEn?A >AAnBENA@. 3. PowerPC Ports 6DAIA 2oMAH2+ FoHJI=HA =ll +27 IAHLAHkAHnAlI. 3.1. Blue Gene Ports 6DEI MoHk EI >AEnC BKn@A@ >O JDA 7.5. ,AFJ. oB -nAHCO ,o- Kn@AH JDA FHojA?J n=mA ߢ0)4-ߣ* =n@ JDA m=En F=HJE?EF=nJI =HA *All L=>I, 1*M 4AIA=H?D, 5=n@E= N=JEon=l L=>I =n@ 8EJ=nKoL=. 6DA EnJAnJ EI Jo FHoLE@A BKll oFAH=JEnC IOIJAm ?=F=>ElEJEAI LE= ?omF=H= JELAlO lECDJMAECDJ 2l=n ' H=JDAH JD=n DA=LOMAECDJ LEnKN oH ALAn moHA FHEmEJELA oFAH=J EnCIOIJAmIonLAHOl=HCA-I?=lA F=H=llAl m=?DEnAI.