// RaidProcs.bcpl. Supplementary procedures for RAID // Flushed TeleRaid July 20, 1983 2:49 PM by Bill van Melle // Last modified March 30, 1983 11:31 AM by Bill van Melle // Last modified December 16, 1982 10:15 PM by Bill van Melle // Last modified July 21, 1982 9:32 PM by Bill van Melle // Last modified September 19, 1981 2:01 PM by Bill van Melle // Last modified August 4, 1981 12:47 PM by Beau Sheil get "AltoDefs.d" get "Raid.decl" get "Stats.decl" get "Vmem.decl" get "Streams.d" external [ // procedures defined here ReadNum; ReadAtom; AtomNum; ShowRealCore DisplayVMinBitMap; DisplayVMbit; DoYankDef // statics VMDisplay ] external [ // procedures used CRLF; Ws; Wo; Wc; Bytes2 StealFromBcplDisplay; AddToBcplDisplay; DumpBlockToStats RaidReset; RAIDCode; ReadStrng; PrintAddrs; Confirm @BGetBase; @BGetBasePtr; @XPutBase; @BGetBase32; @BPutBase32 @XSetReadBR; @RRead; @RWrite BP; ReadFlags; VirtualPage; EmAddr; MkSmallPos; IGetBase InitStats; CloseStats; IndexedPageIO; LookupPage; EqNIL // OS procs used Zero; ShowDisplayStream; CreateDiskStream // statics used EmulatorSpace; LastRealPageNo; @lvVPtr dsp; @DisplayAddrHi statsFP; statsFile; LispFmap ] static [ VMDisplay = 0 ] manifest [ LastSegment = 63 // 22-bit address space IMSize = #20000; DummyHeight = 32 VMbitMapOffset = 2+2*lDCB // bitmap within VMDisplay VMDisplayWidth = 16; VMDisplayHeight = LastSegment+1 VMDisplayScanLines = DummyHeight + VMDisplayHeight VMDisplaySize = VMbitMapOffset + VMDisplayWidth*VMDisplayHeight ] structure String: [ length byte; char^1,255 byte ] let AtomNum(S) = valof // Finds atom number for BCPL string. pn char format is that of bcpl strings [ let LEN = S>>String.length let NW = LEN rshift 1 // Compute the hash code for the name. Mimic the behavior of LISP let SS = 0 for i = 1 to LEN do [ let h1 = ((SS & #7777) lshift 2) + SS SS = (h1 lshift 8) + h1 + S>>String.char^i ] [ let H = ((SS𒿑) rem (AHTSIZE lshift 8)) + AHTbase // H is the virtual address in the AtomHashTable let P = BGetBase(AHTspace, H) // P is address of hash table entry if P eq 0 then RaidReset("No such atom") // since P was non zero, it is the virtual address of an atom+1 P = P-1 // fetch atom and check its pname. Check its characters (word-by-word) // with those in pname. Count is first byte, and pad byte (if any) is 0. XSetReadBR(BGetBasePtr(PNPspace, PNPbase+(P lshift 1))) for i = 0 to NW do if RRead(i) ne S!i goto reprobe resultis P // pnames are the same; return virtual address reprobe: SS = SS+HashInc ] repeat // comparison failed so reprobe ] and ReadAtom() = valof // obtains atom number from typein [ let s = vec 50 unless ReadStrng(s) do RaidReset(" XXX") let num=0 for i=1 to s>>String.length do [ let c = (s>>String.char^i)-$0 test (c ge 0) & (c le 7) ifso num=num*8+c ifnot resultis AtomNum(s) ] resultis num ] and ReadNum(radix) = valof // read number in given radix [ let s = vec 50 unless ReadStrng(s) do RaidReset(" XXX") let num=0 for i=1 to s>>String.length do [ let c = (s>>String.char^i)-$0 test (c ge 0) & (c ls radix) ifso num=num*radix+c ifnot RaidReset(" XXX") ] resultis num ] and ShowRealCore() be // Displays a segment page usage map [ CRLF() Ws (" State of virtual memory file: ") Ws (IGetBase(IFPKey) eq IFPValidKey? "C", "Inc") Ws ("onsistent") CRLF(); CRLF() let base = vec LastSegment+2; Zero(base, LastSegment+3) let ndirty, nlocked = 0, 0 let bp = BP(0) for i = 2 to BptSize do [ bp = bp+3 // next one. Skips the dummy header if bp>>BPT.LOCK then nlocked = nlocked+1 let vp = bp>>BPT.VP let bucket = vp<>DS.fdcb = VMDisplayDCB VMDisplayDCB>>DCB.next = VMDisplayDCB + lDCB VMDisplayDCB>>DCB.width = 0 VMDisplayDCB>>DCB.bitmap = 0 VMDisplayDCB>>DCB.height = DummyHeight/2 VMDisplayDCB = VMDisplayDCB + lDCB VMDisplay>>DS.ldcb = VMDisplayDCB VMDisplayDCB>>DCB.next = 0 VMDisplayDCB>>DCB.height = VMDisplayHeight/2 VMDisplayDCB>>DCB.indentation = 1 VMDisplayDCB>>DCB.width = VMDisplayWidth VMDisplayDCB>>DCB.bitmap = VMDisplay + VMbitMapOffset // Turn on bits for pages already in core. Emulator done specially. for i=0 to PagesPerSegment-1 do DisplayVMbit(Bytes2(EmulatorSpace,i), true) for i=0 to LastRealPageNo-1-PagesPerSegment do [ let vp = VirtualPage(i) unless vp<