-- Copyright (C) 1984, 1985 by Xerox Corporation. All rights reserved. -- GateParameterTajo.mesa, HGM, 6-Jan-85 5:40:18 DIRECTORY CmFile USING [Handle, TableError], Format USING [NetworkNumber], HeraldWindow USING [window], HostNumbers USING [HostNumber], Process USING [Priority, priorityForeground], Put USING [NetworkNumber, Octal, Text], Runtime USING [GetBuildTime], SpecialSystem USING [GetProcessorID], String USING [AppendChar, AppendDecimal, AppendNumber, AppendOctal, AppendString], StringLookUp USING [noMatch, TableDesc], System USING [AdjustGreenwichMeanTime, GreenwichMeanTime, NetworkNumber, nullNetworkNumber], Time USING [Append, Packed, Unpack, Unpacked], Token USING [Boolean, Decimal, NetworkNumber, Octal], ToolWindow USING [Deactivate], BufferOps USING [Defaults, GetDefaults, SetDefaults], DriverTypes USING [DeviceType], Driver USING [GetDeviceChain, GetNSRouter, GetPupRouter, Network], PupDefs USING [SmashMyHostNumber], Router USING [SetNetworkID], RS232C USING [ChannelHandle, CommParamObject, Create], RS232CEnvironment USING [], GateDefs USING [typescript], Indirect USING [Close, NextValue, OpenSection], MicrocodeVersion USING [VERSION, VersionResult], PhoneCreate USING [CreateSla, CreateSimplePhoneNet], RoutingFudges USING [SetNSFudge, SetPupFudge], Trouble USING [Bug, WrapTypescriptFile]; GateParameterTajo: PROGRAM IMPORTS CmFile, Format, HeraldWindow, Put, Process, Runtime, SpecialSystem, String, System, Time, Token, ToolWindow, BufferOps, Driver, GateDefs, Indirect, PupDefs, Router, RS232C, MicrocodeVersion, PhoneCreate, RoutingFudges, Trouble EXPORTS GateDefs = BEGIN PrintHost: PROCEDURE [ name: LONG STRING, board, pupNet: CARDINAL, nsNet: System.NetworkNumber] = BEGIN Put.Text[NIL, name]; IF board # LAST[CARDINAL] THEN BEGIN Put.Text[NIL, " number "L]; Put.Octal[NIL, board]; END; Put.Text[NIL, " is Pup network "L]; Put.Octal[NIL, pupNet]; Put.Text[NIL, " and NS network "L]; Put.NetworkNumber[NIL, nsNet, octal]; Put.Text[NIL, " ("L]; Put.NetworkNumber[NIL, nsNet, productSoftware]; Put.Text[NIL, ").\n"L]; END; ScanParameterFile: PUBLIC PROCEDURE RETURNS [ priority: Process.Priority ← Process.priorityForeground, disableNSRouting: BOOLEAN ← FALSE] = BEGIN cmFile: CmFile.Handle; Option: TYPE = MACHINE DEPENDENT{ ethernetOne(0), ethernet, leasedLine, altoPhoneLine, pupHostNumber, buffers, priority, typescript, deactivateHerald, disableNSRouting, extraHops, noMatch(StringLookUp.noMatch)}; DefinedOption: TYPE = Option [ethernetOne..extraHops]; CheckType: PROCEDURE [h: CmFile.Handle, table: StringLookUp.TableDesc] RETURNS [index: CARDINAL] = Indirect.NextValue; MyNextValue: PROCEDURE [ h: CmFile.Handle, table: LONG DESCRIPTOR FOR ARRAY DefinedOption OF LONG STRING] RETURNS [index: Option] = LOOPHOLE[CheckType]; optionTable: ARRAY DefinedOption OF LONG STRING ← [ ethernetOne: "EthernetOne"L, ethernet: "Ethernet"L, leasedLine: "Leased Line"L, altoPhoneLine: "Alto Phone Line", pupHostNumber: "Pup Host Number"L, buffers: "Buffers"L, priority: "Priority"L, typescript: "Typescript"L, deactivateHerald: "Deactivate Herald Window"L, disableNSRouting: "Disable NS Routing"L, extraHops: "Extra Hops"L]; leasedLines: CARDINAL ← 0; cmFile ← Indirect.OpenSection["Gateway"L]; IF cmFile = NIL THEN BEGIN Message["Can't find [Gateway] section in Parameter file"L]; RETURN; END; DO option: Option; option ← MyNextValue[cmFile, DESCRIPTOR[optionTable] ! CmFile.TableError => BEGIN IF name[0] # '; THEN Message["Unrecognized parameter: ", name]; RETRY; END]; SELECT option FROM noMatch => EXIT; ethernetOne => -- <board> <Pup Net> <NS net> (octal) BEGIN board: CARDINAL ← Token.Decimal[cmFile]; pupNet: CARDINAL ← Token.Octal[cmFile]; nsNet: System.NetworkNumber ← Token.NetworkNumber[cmFile, octal]; SetPupNetworkID[board, ethernetOne, pupNet]; IF nsNet # System.nullNetworkNumber THEN BEGIN CheckNSNetworkID[board, ethernetOne, nsNet]; [] ← Router.SetNetworkID[board, ethernetOne, nsNet]; END; PrintHost["EthernetOne"L, board, pupNet, nsNet]; END; ethernet => -- <board> <Pup Net> <NS net> (octal) BEGIN board: CARDINAL ← Token.Decimal[cmFile]; pupNet: CARDINAL ← Token.Octal[cmFile]; nsNet: System.NetworkNumber ← Token.NetworkNumber[cmFile, octal]; SetPupNetworkID[board, ethernet, pupNet]; IF nsNet # System.nullNetworkNumber THEN BEGIN CheckNSNetworkID[board, ethernet, nsNet]; [] ← Router.SetNetworkID[board, ethernet, nsNet]; END; PrintHost["Ethernet"L, board, pupNet, nsNet]; END; altoPhoneLine => -- <host> <Pup Net> <NS net> (octal) BEGIN host: CARDINAL ← Token.Octal[cmFile]; pupNet: CARDINAL ← Token.Octal[cmFile]; nsNet: System.NetworkNumber ← Token.NetworkNumber[cmFile, octal]; me: HostNumbers.HostNumber = SpecialSystem.GetProcessorID[]; PhoneCreate.CreateSla[host, pupNet]; IF nsNet # System.nullNetworkNumber THEN BEGIN CheckNSNetworkID[1, sla, nsNet]; SetNSNetworkID[1, sla, nsNet]; END; PrintHost["The Phone Line (Alto Mode)"L, LAST[CARDINAL], pupNet, nsNet]; IF me.a # 0 OR me.b # 0 OR me.c # 252B OR me.d # 026B OR me.e # pupNet OR me.f # host THEN Put.Text[ NIL, "Warning: This connection won't forward NS packets. *******\n"L]; END; leasedLine => -- <line number> <Pup Net> <NS net> (octal) BEGIN line: WORD ← Token.Octal[cmFile]; pupNet: CARDINAL ← Token.Octal[cmFile]; nsNet: System.NetworkNumber ← Token.NetworkNumber[cmFile, octal]; chan: RS232C.ChannelHandle; parms: RS232C.CommParamObject ← [full, bitSynchronous, bps9600, directConn[]]; leasedLines ← leasedLines + 1; chan ← RS232C.Create[line, @parms, preemptAlways, preemptNever]; PhoneCreate.CreateSimplePhoneNet[line, chan, parms]; SetPupNetworkID[leasedLines, phonenet, pupNet]; IF nsNet # System.nullNetworkNumber THEN BEGIN CheckNSNetworkID[leasedLines, phonenet, nsNet]; [] ← Router.SetNetworkID[leasedLines, phonenet, nsNet]; END; PrintHost["The Phone Line (NS Mode)"L, leasedLines, pupNet, nsNet]; END; pupHostNumber => BEGIN me: CARDINAL ← Token.Octal[cmFile]; PupDefs.SmashMyHostNumber[me]; MessageOctal["Set my Pup Host Number to "L, me]; END; buffers => -- <number> (decimal) BEGIN defaults: ARRAY BufferOps.Defaults OF CARDINAL ← BufferOps.GetDefaults[]; buffers: CARDINAL ← Token.Decimal[cmFile]; defaults[bias] ← defaults[bias] + buffers; BufferOps.SetDefaults[defaults]; MessageDecimal["Set number of buffers to "L, buffers]; END; priority => -- <priority> (decimal) BEGIN priority ← Token.Decimal[cmFile]; MessageDecimal["Priority will be "L, priority]; END; typescript => -- <pages> BEGIN pages: CARDINAL ← Token.Decimal[cmFile]; Trouble.WrapTypescriptFile[GateDefs.typescript, pages]; MessageDecimal[ "Typescript file will be trimmed at "L, pages, " pages"L]; END; deactivateHerald => -- <boolean> BEGIN IF Token.Boolean[cmFile] THEN BEGIN Message["Deactivating Herald Window"L]; [] ← ToolWindow.Deactivate[HeraldWindow.window]; END ELSE Message["Didn't deactivate Herald Window"L]; END; disableNSRouting => -- <boolean> BEGIN IF Token.Boolean[cmFile] THEN BEGIN Message["Deactivating NS Router"L]; disableNSRouting ← TRUE; END ELSE Message["Didn't deactivate NS Router"L]; END; extraHops => -- <boolean> BEGIN IF Token.Boolean[cmFile] THEN BEGIN Message["Adding Extra Hops"L]; RoutingFudges.SetPupFudge[1]; RoutingFudges.SetNSFudge[1]; END ELSE Message["Didn't add any Extra Hops"L]; END; ENDCASE => ERROR; ENDLOOP; Indirect.Close[cmFile]; END; MessageDecimal: PROCEDURE [ one: LONG STRING, num: CARDINAL, two, three: LONG STRING ← NIL] = BEGIN text: STRING = [100]; String.AppendString[text, one]; String.AppendDecimal[text, num]; IF two # NIL THEN String.AppendString[text, two]; IF three # NIL THEN String.AppendString[text, three]; String.AppendChar[text, '.]; String.AppendChar[text, '\n]; LogString[text]; END; MessageOctal: PROCEDURE [ one: LONG STRING, num: CARDINAL, two, three: LONG STRING ← NIL] = BEGIN text: STRING = [100]; String.AppendString[text, one]; String.AppendOctal[text, num]; IF two # NIL THEN String.AppendString[text, two]; IF three # NIL THEN String.AppendString[text, three]; String.AppendChar[text, '.]; String.AppendChar[text, '\n]; LogString[text]; END; Message: PROCEDURE [one, two, three: LONG STRING ← NIL] = BEGIN text: STRING = [100]; String.AppendString[text, one]; IF two # NIL THEN String.AppendString[text, two]; IF three # NIL THEN String.AppendString[text, three]; String.AppendChar[text, '.]; String.AppendChar[text, '\n]; LogString[text]; END; LogString: PROCEDURE [text: LONG STRING] = BEGIN Put.Text[NIL, text]; END; PrintTajoVersion: PROCEDURE = BEGIN temp: STRING = [100]; packed: Time.Packed; unpacked: Time.Unpacked; String.AppendString[temp, "Running on Tajo of "L]; Time.Append[temp, Time.Unpack[Runtime.GetBuildTime[]], TRUE]; String.AppendString[temp, " = "L]; packed ← Runtime.GetBuildTime[]; unpacked ← Time.Unpack[packed, [useThese[[west, 0, 0, 366, 366]]]]; Time.Append[temp, unpacked, TRUE]; String.AppendString[temp, ".\n"L]; LogString[temp]; END; PrintMicrocodeInfo: PROCEDURE = BEGIN CatchKrock: PROCEDURE RETURNS [MicrocodeVersion.VersionResult] = BEGIN RETURN[MicrocodeVersion.VERSION[]]; END; temp: STRING = [200]; version: MicrocodeVersion.VersionResult ← CatchKrock[ ! ANY => GOTO NoVersion]; when: System.GreenwichMeanTime ← -- 0 => Jan 1, 1901 System.AdjustGreenwichMeanTime[[0], version.releaseDate*86400]; unpacked: Time.Unpacked; String.AppendString[temp, "This microcode was built on "L]; unpacked ← Time.Unpack[when, [useThese[[west, 0, 0, 366, 366]]]]; Time.Append[temp, unpacked, FALSE]; temp.length ← temp.length - 9; -- Discard time = " xx:xx:xx" String.AppendString[temp, ".\n"L]; String.AppendString[temp, "This machine is a "L]; String.AppendString[temp, SELECT version.machineType FROM dolphin => "Dolphin"L, dorado => "Dorado"L, dandelion => "Dandelion"L, dicentra => "Dicentra"L, ENDCASE => "??"L]; String.AppendString[temp, ". FloatintPoint = "L]; String.AppendString[temp, IF version.floatingPoint THEN "TRUE"L ELSE "FALSE"L]; String.AppendString[temp, ", Cedar = "L]; String.AppendString[temp, IF version.cedar THEN "TRUE"L ELSE "FALSE"L]; String.AppendString[temp, ".\n"L]; LogString[temp]; EXITS NoVersion => LogString["This microcode won't tell me when it was built.\n"]; END; SetPupNetworkID: PROCEDURE [ physicalOrder: CARDINAL, medium: DriverTypes.DeviceType, newNetID: CARDINAL] = BEGIN ENABLE UNWIND => NULL; network: Driver.Network ← GetNthDevice[physicalOrder, medium]; IF network.pupNetNumber # 0 AND network.pupNetNumber # newNetID THEN BEGIN text: STRING = [200]; String.AppendString[text, "Wrong Pup network number. Expected: "L]; String.AppendNumber[text, newNetID, 8]; String.AppendString[text, ", Found: "L]; String.AppendNumber[text, network.pupNetNumber, 8]; Trouble.Bug[text]; END; network.pupNetNumber ← newNetID; -- This used to be stateChanged, but that screws up (net 0) in the no-LF case. Driver.GetPupRouter[].addNetwork[network]; END; SetNSNetworkID: PROCEDURE [ physicalOrder: CARDINAL, medium: DriverTypes.DeviceType, newNetID: System.NetworkNumber] = BEGIN ENABLE UNWIND => NULL; network: Driver.Network ← GetNthDevice[physicalOrder, medium]; IF network.netNumber # System.nullNetworkNumber AND network.netNumber # newNetID THEN BEGIN text: STRING = [200]; String.AppendString[text, "Wrong NS network number. Expected: "L]; AppendNetNumbers[text, newNetID]; String.AppendString[text, ", Found: "L]; AppendNetNumbers[text, network.netNumber]; Trouble.Bug[text]; END; network.netNumber ← newNetID; Driver.GetNSRouter[].stateChanged[network]; END; CheckNSNetworkID: PROCEDURE [ physicalOrder: CARDINAL, medium: DriverTypes.DeviceType, newNetID: System.NetworkNumber] = BEGIN ENABLE UNWIND => NULL; network: Driver.Network ← GetNthDevice[physicalOrder, medium]; IF network.netNumber # System.nullNetworkNumber AND network.netNumber # newNetID THEN BEGIN text: STRING = [200]; String.AppendString[text, "Wrong NS network number. Expected: "L]; AppendNetNumbers[text, newNetID]; String.AppendString[text, ", Found: "L]; AppendNetNumbers[text, network.netNumber]; Trouble.Bug[text]; END; network ← NIL; -- Compiler and Debugger don't cooperate END; AppendNetNumbers: PROCEDURE [string: LONG STRING, net: System.NetworkNumber] = BEGIN words: RECORD [a, b: WORD] = LOOPHOLE[net]; AppendNetNumber[string, net]; IF words.b < 256 THEN BEGIN String.AppendString[string, " ("L]; AppendNetNumberOctal[string, net]; String.AppendString[string, ")"L]; END; END; AppendNetNumber: PROCEDURE [string: LONG STRING, net: System.NetworkNumber] = BEGIN Append: PROCEDURE [s: LONG STRING, clientData: LONG POINTER] = BEGIN String.AppendString[string, s]; END; Format.NetworkNumber[Append, net, productSoftware]; END; AppendNetNumberOctal: PROCEDURE [string: LONG STRING, net: System.NetworkNumber] = BEGIN Append: PROCEDURE [s: LONG STRING, clientData: LONG POINTER] = BEGIN String.AppendString[string, s]; END; Format.NetworkNumber[Append, net, octal]; END; GetNthDevice: PROCEDURE [ physicalOrder: CARDINAL, medium: DriverTypes.DeviceType] RETURNS [network: Driver.Network] = BEGIN i: CARDINAL ← 0; FOR network ← Driver.GetDeviceChain[], network.next UNTIL network = NIL DO IF network.device = medium THEN IF (i ← i + 1) = physicalOrder THEN RETURN; ENDLOOP; Trouble.Bug["Driver doesn't exist"L]; network ← NIL; -- Compiler and Debugger don't cooperate END; -- initialization PrintTajoVersion[]; PrintMicrocodeInfo[]; END.