Porting NetBSD to JavaStation--NC

  • 格式:pdf
  • 大小:22.20 KB
  • 文档页数:4

PortingNetBSDtoJavaStation–NC

ValeriyE.Ushakov

Abstract

PortingNetBSDtoanewplatformthathasits

CPUalreadysupportedissimplifiedbycleanin-

terfacesoftheNetBSDkernelandawiderangeof

machine–independentdriversfordifferentbuses

anddevices.Thispapersummarizesexperiencein

portingNetBSDtotheJavaStation–NCandgives

anoverviewofmachine–dependentcodethatwas

necessary.

1.Introduction

TheJavaStation–NCisanetworkcomput-

erclassmachinebuiltonthemicroSPARC–IIep

processor.ThemicroSPARC–IIepisasun4m

withanintegratedPCIcontroller[3].Thismakes

ituniqueamongst32-bitsparcsystemsasother

sun4candsun4mmodelsareSBus-based.Itis

sufficientlysimilartosun4mtoreusemuchofthe

existingcodeandsufficientlydifferenttorequire

anon-trivialportingeffort.Genericandflexible

machine–independentinfrastructureanddrivers

providedbyNetBSDwerecrucialtocompleting

theportinshorttimedespitetheauthor’slackof

anypreviousexperiencewithNetBSDkernelin-

ternals.

Itishopedthatthisexperiencewillbein-

terestingtopeoplewhoneedamodernOSfor

thedevicetheydeveloportoenthusiastswho

wanttoportBSDtotheirfavoritegadget.Since

NetBSDalreadysupportsalmostallmodern(and

notsomodern)processors,chancesarethatmost

ofthehardwork,likeMMUandcachesupport,

isalreadydone.Mostlikelytherearealready

machine–independentdevicedriversforsomeof

thedevicesfoundinthetargetplatform,thusfur-

therreducingyourportingtimeandcosts.

PortingNetBSDtoacompletelynewplat-

formisdescribedin[2]thatalsooutlineskeyfea-

turesofNetBSDthatcontributetoitsgreatporta-

bility.

2.Thetargetmachine

Inlate1990sSunwasaggressivelypushing

theconceptof“NetworkComputer”.Itdeveloped

severalnetworkcomputerclassmachinesofwhich

onlytwoweremoreorlesswidelyavailableinthe

wild—JavaStation-1,codename“Mr.Coffee”,andJavaStation–NC,codename“Krups”1.All

JavaStationswereshippedwithJavaOS.

Mr.Coffeeisa“chimeric”machine.Itisa

straightsun4m,exceptequippedwithcommodity

PS/2keyboardandmouse.ItusestheSunTCX

framebuffer,butthevideoconnectorisstandard

15-pinVGAD-SUBsothatitcanbeusedwithany

PCmonitor.

ForKrups,SunusedthemicroSPARC–IIep

processor,where‘e’standsfor“embedded”

and‘p’standsfor“PCI”.Being“embedded”,

themicroSPARC–IIepisverylow–heat,so

Krupshasnofan,makingitadead-silentma-

chine.ItsintegratedPCIcontrollermakesthe

microSPARC–IIepuniqueamongstother32-bit

sparcmachines,butinallotherrespectsitisa

SPARCv8.KrupsusesaPCIOchipthatprovides

“HappyMeal”EthernetandEBus(8-bitperipheral

bus).ThelatterisusedtoconnectPS/2keyboard

andmouse,theserialport,andCS4231audio.

NetBSD/sparcalreadyhadcompletesup-

portforSPARCv8MMUandcaches,sowhenthe

Krupsportwasstarted,mostofthehardstuffwas

alreadythere.Asfarasperipheralsareconcerned,

KrupsissufficientlysimilartoPCI-basedSunUl-

tramachines,sotheplanwastoreuseasmuchde-

vicesupportcodefromNetBSD’ssparc64portas

possible.

3.Firmwareandbootloader

Thefirstthingthatwasneededwasaboot

loader.LikeUltramachinesKrupsusesOpen

Firmware(OFW).Fortunately,NetBSD/sparcport

alreadyborrowedOFWsupportfromthesparc64

port,thoughtherewerefewminorbugsandmiss-

ingbitshereandtherebecauseJavaStationsare

probablytheonly32-bitsparcswithOFWandso

theOFWsupporthadjustneverbeentestedinthe

32-bitsparcport(other32-bitsparcsuseOpen

BootPROM(OBP),apredecessorofOFW).

ThenastysurprisewasthatOFWinKrups

hasmanyquirks.Theworstonewasthat

OFW,inviolationofthestandard,waslocat-

edatf000.0000—theaddressatwhichthe

NetBSD/sparckernelexpectstobeloaded.Nor-

1ThispaperwillrefertoJavaStationsbytheircodenamesforbrevityandclarity.mally,OFWislocatedinhighvirtualaddresses,

sotheNetBSD/sparckernelhasafundamentalas-

sumptionthatithasthespacebetweenitsownend

andthebeginningofOFWatitsdisposal.Asa

workaroundthekernelwasrelocatedtoalowerad-

dressandmemorybootstrapcodewastweakedto

startitsheappastOFW.Thisisakludge,butitre-

quiredchangingonlyfewlinesinacoupleoffiles

andallwasreadytoproceedwithporting,leaving

thequestionofhowtoproperlydealwiththissitu-

ationtoabettertime.Thisworkwasactuallydone

onaMr.CoffeethatalsohadOFWwiththisprob-

lem,buthadthebenefitofhavingaminimalwork-

ingsupportalready,soitwaseasytotestthekernel

relocationonitwithotherwiseworkingkernel.

Therewerealsoafewotherproblems,mostly

relatedtodevicenodesandtheirproperties.To

avoidpollutingthekernelwithnumerousspecial

casesandworkaroundsforOFWquirks,theboot

loaderwasmodifiedto“patch”theOFWbefore

loadingthekernel.SinceOFWisafull-fledged

Forthenvironment,thiswaseasilyachievablewith

smallpiecesofforthcodethatbootloaderpasses

toOFWtoexecute.

Linuxtookadifferentpath.PeteZaitcevim-

plementedPROLL,asmallOBPsimulatorthat

providedtothekernelthedevicetreeandamin-

imalsubsetofOBPentrypointsthatLinuxsparc

kernelused.PROLLcompletelyreplacesma-

chine’sOFW.HoweverhavingOFWaroundis

quitehandytobeabletoinspecthardwarestatein-

teractively,sofortheNetBSDport,thecasewas

decidedinfavorofOFWdespitethenecessary