TTYHeadDLion.mesa
Copyright Ó 1980, 1982, 1987 by Xerox Corporation. All rights reserved.
Last edited: 26-Sep-84 0:17:24 By: DXG
This head supports only ONE LINE
Tim Diebert: March 31, 1987 7:39:37 am PST
DIRECTORY
DeviceCleanup USING [Await, Item, Reason],
DLionInputOutput USING [IOPage, ttyCommandOffset, ttyInCSBOffset, ttyOutCSBOffset],
Process USING[MsecToTicks, Pause],
TTYFace;
TTYHeadDLion: PROGRAM
IMPORTS DeviceCleanup, DLionInputOutput, Process
EXPORTS TTYFace =
BEGIN
TTYInCSB: LONG POINTER TO MACHINE DEPENDENT RECORD [
inControl(0): InCharStatus,
inData(1:0..7): CHARACTER,
dataTerminalReady(1:8..8): BOOLEAN,
unused1(1:9..12): [0..20B),
requestToSend(1:13..13): BOOLEAN,
rxRDY(1:14..14): BOOLEAN,
txRDY(1:15..15): BOOLEAN] = DLionInputOutput.IOPage + DLionInputOutput.ttyInCSBOffset;
TTYOutCSB: LONG POINTER TO MACHINE DEPENDENT RECORD [
parameter(0): ParameterRecord,
notifyMask(1): WORD] = DLionInputOutput.IOPage + DLionInputOutput.ttyOutCSBOffset;
TTYOutCommand: LONG POINTER TO MACHINE DEPENDENT RECORD [
command(0:0..7): {(0), putChar(200B), abortPut(205B)},
outData(0:8..15): CHAR] = DLionInputOutput.IOPage + DLionInputOutput.ttyCommandOffset;
TTYSetParameterCommand: LONG POINTER TO MACHINE DEPENDENT RECORD [
command: {(0), --setParameterCommand(100400B),
setDSR(100401B), setCTS(100402B),
setCharLength(100404B), setParity(100410B), setStopBits(100420B),
setBaudRate(100440B), setAllParameters(100477B), (177777B)}
] = DLionInputOutput.IOPage + DLionInputOutput.ttyCommandOffset;
TTYCommand: LONG POINTER TO MACHINE DEPENDENT RECORD [
command: {(0), getStatus(101000B), on(101400B), off(102000B), --abortPut(102400B),-- breakOn(103000B), breakOff(103400B)}] = DLionInputOutput.IOPage + DLionInputOutput.ttyCommandOffset;
ChipParity: TYPE = MACHINE DEPENDENT {none(0), odd(1), even(3)};
ConvertParity: ARRAY TTYFace.Parity OF ChipParity =
[none: none, odd: odd, even: even];
ParameterRecord: TYPE = MACHINE DEPENDENT RECORD [
onOff(0:0..3): MACHINE DEPENDENT {on(0), off(1), (17B)}, -- (Head flag)
baudRate(0:4..7): TTYFace.LineSpeed ← bps1200,
stopBits(0:8..9): TTYFace.StopBits ← two,
parity(0:10..11): ChipParity ← none,
charLength(0:12..13): TTYFace.CharacterLength ← lengthIs8bits,
clearToSend(0:14..14): BOOLEANFALSE,
dataSetReady(0:15..15): BOOLEANFALSE];
InCharStatus: TYPE = MACHINE DEPENDENT RECORD [
state(0:0..0): MACHINE DEPENDENT{empty(0), charPresent(1)},
unused(0:1..7): [0..200B),
success(0:8..8): BOOLEAN,
breakDetected(0:9..9): BOOLEAN,
framingError(0:10..10): BOOLEAN,
dataLost(0:11..11): BOOLEAN,
parityError(0:12..12): BOOLEAN,
unused1(0:13..14): [0..4),
notReady(0:15..15): BOOLEAN];
state: ParameterRecord ← [onOff: off];
GetCommand: PUBLIC PROC [CARDINAL]
RETURNS
[data: CHARACTER, stat: TTYFace.TransferStatus] = BEGIN
ttyInStatus: InCharStatus = TTYInCSB.inControl;
IF ttyInStatus.state = empty THEN RETURN[NULL, notReady];
data ← TTYInCSB.inData; TTYInCSB.inControl.state ← empty;
stat ← SELECT TRUE FROM
ttyInStatus.success => success,
ttyInStatus.breakDetected => breakDetected,
ttyInStatus.framingError => asynchFramingError,
ttyInStatus.dataLost => dataLost,
ttyInStatus.parityError => parityError,
ttyInStatus.notReady => notReady,
ENDCASE => success;
END;
GetLineCount: PUBLIC PROC RETURNS [CARDINAL] = {RETURN[1]};
GetStatus: PUBLIC PROC [CARDINAL] RETURNS [TTYFace.DeviceStatus] = BEGIN
RETURN[[
readyToPut: TTYOutCommand.command < putChar,
readyToGet: TTYInCSB.inControl.state = charPresent,
dataTerminalReady: TTYInCSB.dataTerminalReady,
requestToSend: TTYInCSB.requestToSend]];
END;
PutCommand: PUBLIC PROC [lineNumber: CARDINAL, data: CHARACTER]
RETURNS
[TTYFace.TransferStatus] = BEGIN
IF TTYOutCommand.command >= putChar THEN RETURN[notReady];
TTYOutCommand.outData ← data; TTYOutCommand.command ← putChar;
RETURN[success];
END;
SendBreak: PUBLIC PROC [lineNumber: CARDINAL] = BEGIN
WHILE TTYOutCommand.command >= putChar DO ENDLOOP; --Wait for IOP to finish current command
TTYCommand.command ← breakOn;
Process.Pause[Process.MsecToTicks[190]];
TTYCommand.command ← breakOff;
END;
SetParameter: PUBLIC PROC [lineNumber: CARDINAL, parameter: TTYFace.Parameter] = BEGIN
WHILE TTYOutCommand.command >= putChar DO ENDLOOP; --Wait for IOP to finish current command
WITH parameter SELECT FROM
characterLength => {TTYOutCSB.parameter.charLength ← characterLength; TTYSetParameterCommand.command ← setCharLength};
clearToSend => {TTYOutCSB.parameter.clearToSend ← clearToSend; TTYSetParameterCommand.command ← setCTS};
dataSetReady => {TTYOutCSB.parameter.dataSetReady ← dataSetReady; TTYSetParameterCommand.command ← setDSR};
lineSpeed => {TTYOutCSB.parameter.baudRate ← lineSpeed;  TTYSetParameterCommand.command ← setBaudRate};
stopBits => {TTYOutCSB.parameter.stopBits ← stopBits;  TTYSetParameterCommand.command ← setStopBits; };
parity => {TTYOutCSB.parameter.parity ← ConvertParity[parity]; TTYSetParameterCommand.command ← setParity};
ENDCASE => RETURN;
state ← TTYOutCSB.parameter; -- save state for inload
END;
should check to see if the out is busy???
On: PUBLIC PROC [lineNumber: CARDINAL, mask: UNSPECIFIED] = BEGIN
state ← [onOff: on];
TTYOutCSB.notifyMask ← mask; TTYInCSB.inControl.state ← empty;
TTYInCSB.dataTerminalReady ← FALSE;
TTYInCSB.requestToSend ← FALSE;
TTYCommand.command ← on;
set the defaults independent of what the IOP may think
WHILE TTYOutCommand.command >= putChar DO ENDLOOP; -- Wait for IOP to process command
TTYOutCSB.parameter ← state; TTYSetParameterCommand.command ← setAllParameters
END;
Off: PUBLIC PROC [CARDINAL] = BEGIN
WHILE TTYOutCommand.command >= putChar DO ENDLOOP;
TTYOutCSB.notifyMask ← 0;
TTYCommand.command ← off;
state ← [onOff: off];
END;
InitializeCleanup: PROC = BEGIN
item: DeviceCleanup.Item;
mask: WORD;
DO
reason: DeviceCleanup.Reason = DeviceCleanup.Await[@item];
IF state.onOff=on THEN SELECT reason FROM
turnOff, kill =>
BEGIN
THROUGH [0..LAST[CARDINAL]] WHILE TTYOutCommand.command >= putChar DO ENDLOOP;
IF TTYOutCommand.command >= putChar THEN {
TTYOutCommand.command ← abortPut; -- the printer is stuck
WHILE TTYOutCommand.command >= putChar DO ENDLOOP;
};
mask ← TTYOutCSB.notifyMask; TTYOutCSB.notifyMask ← 0; TTYCommand.command ← off;
WHILE TTYOutCommand.command >= putChar DO ENDLOOP;
END;
turnOn =>
BEGIN
TTYOutCSB.notifyMask ← mask; TTYCommand.command ← on;
WHILE TTYOutCommand.command >= putChar DO ENDLOOP;
TTYOutCSB.parameter ← state; TTYSetParameterCommand.command ← setAllParameters;
END;
disconnect => NULL; -- turnOff was already called
ENDCASE;
ENDLOOP;
END;
Mainline code
InitializeCleanup[];
END....
LOG
Time: September 9, 1980 2:19 PM By: Ken Yamanaka Action: Created file
Time: September 11, 1980 10:30 PM By: Ken Yamanaka Action: Many Changes
Time: September 25, 1980 11:27 PM By: FXH Action: maul Over
Time: October 16, 1980 11:42 AM By: FXH Action: Add device cleanup (sigh)
Time: October 20, 1980 5:24 PM By: FXH Action: redo setParameter and device cleanup
Time: 23-Jul-82 15:30:38 By: Jim JXF Action: New IOPage format
Time: 18-Aug-82 13:52:27 By: Jim JXF Action: Added SendBreak
Time: 16-Sep-82 10:11:34 By: Jim JXF Action: Save parameters for inload.
Time: 6-Oct-82 15:04:22 By: Jim JXF Action: Leave Break on for 190 msec. Initialize TTYInCSB in On command.
Time: 26-Sep-84 0:17:21 By: DXGAction: Added copyright notice and rebuild for 11.1 release.