-- Auxiliary Hardware Functions
-- MESA Definitions Module
-- Anthony West, October 29, 1981 3:38 PM

-- This interface allows MESA programmers to access:
-- a) DES Cryptography hardware
-- b) Random Bit Generator hardware
-- c) Intel Multibus

DIRECTORY AltoDefs USING[BYTE];

AuxDefs: DEFINITIONS =
{
-- DES Cryptography

-- NB: Keys, initVectors and blocks are 64 bit entities.
-- To, From must point to segments containing an integral number of 64-bit blocks.
-- The segments must be totally disjoint or fully congruent!
-- For speed, try to align to and from segments on quadword boundaries.

-- a) Electronic Code Book.
-- No state kept between 64-bit blocks.

OPEN AltoDefs;

BLOCK: TYPE = PACKED ARRAY [0..7] OF BYTE;
DESKey: TYPE = LONG POINTER TO BLOCK;
DESVector: TYPE = LONG POINTER TO BLOCK;

ECBEncrypt: PROC [ key: DESKey,
nBlks: CARDINAL,
from, to: LONG POINTER ];

ECBDecrypt: PROC [ key: DESKey,
nBlks: CARDINAL,
from, to: LONG POINTER ];

-- a) Cipher Block Chaining.
-- 64-bits of state kept between blocks. This state is XOR’d
-- with the next incoming clear text block before encryption.
-- initVec is the 64-bit initial value of this state.

CBCEncrypt: PROC [ key: DESKey,
initVec: DESVector,
nBlks: CARDINAL,
from, to: LONG POINTER ];

CBCDecrypt: PROC [ key: DESKey,
initVec: DESVector,
nBlks: CARDINAL,
from, to: LONG POINTER ];

CBCChecksum: PROC [ key: DESKey,
initVec: DESVector,
nBlks: CARDINAL,
from: LONG POINTER ] RETURNS [ BLOCK ];

GetRandomDESKey: PROC RETURNS [ BLOCK ];

-- Random Numbers

BIT: TYPE = UNSPECIFIED[0..1];

GetBiassedBit: PROC RETURNS [ BIT ];
GetUnbiassedBit: PROC RETURNS [ BIT ];
GetRandom8: PROC RETURNS [ UNSPECIFIED ];
GetRandom16: PROC RETURNS [ UNSPECIFIED ];
GetRandom32: PROC RETURNS [ LONG UNSPECIFIED ];
GetRandom64: PROC RETURNS [ BLOCK ];

-- Intel Multibus Interface

-- Read the Multibus Status
MBStatus: PROC RETURNS [UNSPECIFIED];

-- Multibus Byte and Word Transfer operations
MBMemReadWord: PROC [MBAddr: CARDINAL] RETURNS [WORD];
MBIOReadWord: PROC [Address: CARDINAL] RETURNS [UNSPECIFIED];

MBMemReadByte: PROC [MBAddr: CARDINAL] RETURNS [BYTE];
MBIOReadByte: PROC [Address: CARDINAL] RETURNS [BYTE];

MBMemWriteWord: PROC [Address: CARDINAL, data: UNSPECIFIED];
MBIOWriteWord: PROC [Address: CARDINAL, data: UNSPECIFIED];

MBMemWriteByte: PROC [Address: CARDINAL, data: BYTE];
MBIOWriteByte: PROC [Address: CARDINAL, data: BYTE];

-- Multibus Block Transfer operations
MBMemReadWBLT: PROC [ MBusAddr: CARDINAL,
MesaAddr: LONG POINTER,
nWords: CARDINAL ];

MBIOReadWBLT: PROC [ MBusAddr: CARDINAL,
MesaAddr: LONG POINTER,
nWords: CARDINAL ];

MBMemWriteWBLT: PROC [ MesaAddr: LONG POINTER,
MBusAddr: CARDINAL,
nWords: CARDINAL ];

MBIOWriteWBLT: PROC [ MesaAddr: LONG POINTER,
MBusAddr: CARDINAL,
nWords: CARDINAL ];

-- Multibus interrupt levels are set by external jumpers
Level: TYPE = CARDINAL[0..7];

-- Allow/Prevent Multibus to interrupt Dorado
MBIntEnable: PROC;
MBIntDisable: PROC;

-- Generate interrupts on the Multibus
MBInterrupt:
PROC [ Level ];

-- Wait for Multibus to interrupt Dorado
MBWait: PROC [ Level ];

-- Simulate receiving an interrupt from the Multibus
MBPost: PROC [ Level ];
}.