DIRECTORY
Basics USING [bitsPerWord, DoubleShiftRight, LongMult],
CountedVM USING [Handle, SimpleAllocate],
FontTune USING [CreateFontTuner],
Imager USING [Context, metersPerInch, RotateT, ScaleT, TranslateT],
ImagerBitmapContext USING [Create],
ImagerDevice USING [FontTuner],
ImagerSample USING [Clear, GetSize, MapFromVM, RasterSampleMap],
Loader USING [MakeProcedureResident, MakeGlobalFrameResident],
LSEPFace,
Process USING [Pause, MsecToTicks],
PrincOps USING [wordsPerPage, BBTableSpace, BBptr, PageCount],
PrincOpsUtils USING [AllocateNakedCondition, AlignedBBTable],
RavenCodes,
RavenDriver,
Rope USING [ROPE],
VM USING [Allocate, Interval, PageCount, PagesForWords, Pin ];
~
BEGIN
OPEN RavenDriver;
myPixelMap: ImagerSample.RasterSampleMap ← NIL;
secondPixelMap: ImagerSample.RasterSampleMap ← NIL;
GetPrinterPixelMap: PUBLIC PROC RETURNS [pixelMap: ImagerSample.RasterSampleMap] = {RETURN[myPixelMap]};
MakePrinterPixelMap:
PROC RETURNS [pixelMap: ImagerSample.RasterSampleMap] =
BEGIN
numBands: NAT = ((8*300+300/2)+15)/16;
numLines: CARDINAL = numBands * sizeEachBand;
wordsPerLine: NAT ~ activeLength;
words: LONG CARDINAL ~ Basics.LongMult[wordsPerLine, numLines];
pages: CARDINAL = VM.PagesForWords[words];
vm: CountedVM.Handle ← CountedVM.SimpleAllocate[words];
interval: VM.Interval ~ vm.interval;
pixelMap ← ImagerSample.MapFromVM[
vm: vm,
box: [min: [0, 0], max: [(8*300+300/2), (11*300)]],
bitsPerSample: 1, bitsPerLine: 11*300];
FOR i:
INT ← 0, i+400
UNTIL i >= interval.count
DO
-- only pin about 100K each time
VM.Pin[[page: interval.page+i, count: MIN[interval.count-i, 400]]];
Process.Pause[Process.MsecToTicks[500]]; -- wait a half second for Laundry process
ENDLOOP;
ImagerSample.Clear[pixelMap];
END;
ContextFromPixelMap:
PUBLIC
PROC [pixelMap: ImagerSample.RasterSampleMap,
fontTunerParms: Rope.
ROPE ←
NIL]
RETURNS [context: Imager.Context] =
BEGIN
fontTuner: ImagerDevice.FontTuner ← NIL;
IF fontTunerParms # NIL THEN fontTuner ← FontTune.CreateFontTuner[fontTunerParms];
context ← ImagerBitmapContext.Create[deviceSpaceSize: ImagerSample.GetSize[pixelMap], scanMode: [slow: left, fast: up], surfaceUnitsPerInch: [300, 300], pixelUnits: FALSE, fontCacheName: $Bitmap, fontTuner: NIL];
Imager.RotateT[context, -90.0];
Imager.TranslateT[context, [-(8*300+300/2), 0]];
Imager.ScaleT[context, RavenCodes.resolution[fast]/Imager.metersPerInch];
END;
lastPaperFeed: RavenCodes.PrinterCommand ← feed;
SetRegistration:
PUBLIC
PROCEDURE [registration: RavenRegistration] =
TRUSTED
BEGIN
DivideUp: PROCEDURE [divident, divisor: CARDINAL] RETURNS [quotient: CARDINAL] = TRUSTED INLINE BEGIN RETURN[quotient: (divident + divisor - 1) / divisor]; END;
sets up arguments for call which will set page offsets
LSEPFace.SetPageOffsets[
wordsFast: DivideUp[divident: registration.long * registrationTabSize,
divisor: PrincOps.bitsPerWord],
linesSlow: registration.short * registrationTabSize];
END; -- SetRegistration
bandBufferSize: PrincOps.PageCount = 16; -- From BandBLT
ScanLine: TYPE = [0..bandBufferSize); -- scan line index into a band
bbTableSpace: PrincOps.BBTableSpace;
bb: PrincOps.BBptr ~ PrincOpsUtils.AlignedBBTable[@bbTableSpace];
dstBpl: INTEGER ~ PrincOps.wordsPerPage*Basics.bitsPerWord;
dataOnPulses: ARRAY [0 .. 256) OF CARD ← ALL[0];
PrintFromSampleMap:
PUBLIC
PROC [sampleMap: ImagerSample.RasterSampleMap,
copies:
CARDINAL ← 1, paperFeed: RavenDriver.PaperFeed ← alternating]
RETURNS [endingStatus: PrinterStatus, type: StatusType] =
BEGIN
RETURN [ropeStatus[noStatus], normal];
END;
currStatus: RavenCodes.PrinterStatus ← noStatus;
mySP: REF StatusProc ← NIL;
printing: BOOL ← FALSE;
SetScanLineLength:
PUBLIC
SAFE
PROCEDURE [scanLineLength: (0..PrincOps.wordsPerPage]] =
TRUSTED
BEGIN
END;
MonitorRavenStatus:
PROC [] =
BEGIN
END;
Message: TYPE = {traysUnlatched, preRegistrationFault, postRegistrationJam, preExitJam, postExitJam, doorOpen, outputTrayFull, tonerLow, aboutToDozeOff, fuserUnderTemperature, imageFault, commandStatusFault, offLine, ok};
RegisterStatusProc: PUBLIC ENTRY PROC [sp: StatusProc] = {mySP ← NEW[StatusProc ← sp]};
UnRegisterStatusProc: PUBLIC ENTRY PROC [sp: StatusProc] = {mySP ← NIL};
WakeUp:
PUBLIC
PROCEDURE[] =
BEGIN
LSEPFace.PutCommand[LOOPHOLE[RavenCodes.PrinterCommand[solicitStatus]]]; -- Jump start the Raven
END;
bandBufferCount: LSEPFace.BandBufferCount ← 3;
wordsPerBand: CARDINAL = sizeEachBand * PrincOps.wordsPerPage;
sizeEachBand: CARDINAL = 16;
pagesNeedForBands: VM.PageCount = LSEPFace.MaxBands * sizeEachBand + 20;
vm: VM.Interval;
activeLength: (0..PrincOps.wordsPerPage] ← ((11*300)+15)/16;
statusCondition: LONG POINTER TO CONDITION ← NIL; statusMask: WORD ← 0;
dataCondition: LONG POINTER TO CONDITION ← NIL; dataMask: WORD ← 0;
Init:
PROC [] =
BEGIN
vm ← VM.Allocate[pagesNeedForBands];
VMSideDoor.AssignSpecialRealMemory[vm]; -- Move to low core and Pin
LSEPFace.AllocateBands[vm.page, bandBufferCount, sizeEachBand, 1];
SetScanLineLength[activeLength];
myPixelMap ← MakePrinterPixelMap[];
secondPixelMap ← MakePrinterPixelMap[];
Loader.MakeProcedureResident[PrintFromSampleMap];
Loader.MakeGlobalFrameResident[PrintFromSampleMap];
[statusCondition, statusMask] ← PrincOpsUtils.AllocateNakedCondition[];
[dataCondition, dataMask] ← PrincOpsUtils.AllocateNakedCondition[];
Process.SetTimeout[dataCondition, Process.SecondsToTicks[20]];
LSEPFace.SetInterruptMasks[0, statusMask, dataMask];
LSEPFace.PutCommand[LOOPHOLE[RavenCodes.PrinterCommand[solicitStatus]]]; -- Jump start the Raven
Process.Detach[FORK MonitorRavenStatus[]]; -- Up to realTime
END;
ropeStatus: ARRAY RavenCodes.PrinterStatus OF PrinterStatus ← ALL[NIL];
ropeStatus[noStatus] ← "No status";
ropeStatus[key0] ← "key0";
ropeStatus[key1] ← "key1";
ropeStatus[key2] ← "key2";
ropeStatus[key3] ← "key3";
ropeStatus[key4] ← "key4";
ropeStatus[key5] ← "key5";
ropeStatus[key6] ← "key6";
ropeStatus[key7] ← "key7";
ropeStatus[key8] ← "key8";
ropeStatus[key9] ← "key9";
ropeStatus[keyClear] ← "keyClear";
ropeStatus[keyTest] ← "keyTest";
ropeStatus[keyOnLine] ← "keyOnLine";
ropeStatus[keyOffLine] ← "keyOffLine";
ropeStatus[warming] ← "Warming";
ropeStatus[standBy] ← "Ready";
ropeStatus[feederFault] ← "Feeder Fault";
ropeStatus[registrationJam] ← "Registration Jam";
ropeStatus[fuserJam] ← "Fuser Jam";
ropeStatus[noExit] ← "No Exit";
ropeStatus[interlockOpen] ← "Interlock Open";
ropeStatus[fuserCold] ← "Fuser Cold";
ropeStatus[feeding] ← "Feeding";
ropeStatus[readyToFeed] ← "Ready To Feed";
ropeStatus[displayAcknowledge] ← "displayAcknowledge";
ropeStatus[parityError] ← "parityError";
ropeStatus[unrecognizedCommand] ← "illegalCharacter";
ropeStatus[illegalSequence] ← "illegalSequence";
ropeStatus[feedTraysNotEngaged] ← "Paper Tray Open or Out of Paper";
ropeStatus[pageSync] ← "pageSync";
ropeStatus[pageAtOutputTray] ← "pageAtOutputTray";
ropeStatus[tonerLow] ← "Toner Low";
ropeStatus[goingOffLine] ← "goingOffLine";
ropeStatus[offLine] ← "offLine";
ropeStatus[outputTrayFull] ← "outputTrayFull";
ropeStatus[aboutToDozeOff] ← "Low Power Mode";
ropeStatus[statusError] ← "statusError";
ropeStatus[statusOverRun] ← "statusOverRun";
Init[];