-- File: CommUtilDefs.Mesa,  Last Edit: HGM  January 7, 1981  12:57 AM

DIRECTORY
  ControlDefs USING [FrameHandle, returnOffset],
  Mopcodes USING [zLLB, zPOP],
  ProcessDefs USING [InterruptLevel];

CommUtilDefs: DEFINITIONS =
  BEGIN

  thisIsAnAlto: BOOLEAN = TRUE;

  -- Buffer/IOCB Allocation
  AllocateBuffers: PROCEDURE [nwords: CARDINAL] RETURNS [base: LONG POINTER];
  FreeBuffers: PROCEDURE [base: LONG POINTER];
  LockBuffers: PROCEDURE [LONG POINTER] = INLINE BEGIN END;

  UnlockBuffers: PROCEDURE [LONG POINTER] = INLINE BEGIN END;

  AllocateIocbs: PROCEDURE [CARDINAL] RETURNS [LONG POINTER];
  FreeIocbs: PROCEDURE [LONG POINTER];

  -- Lock Interrupt routines
  LockCode: PROCEDURE [UNSPECIFIED];
  UnlockCode: PROCEDURE [UNSPECIFIED];


  -- This is needed because of Process/ProcessDefs LONG/Short complications
  MaybeShorten: PROCEDURE [LONG POINTER] RETURNS [POINTER] = MACHINE CODE
    BEGIN Mopcodes.zPOP; END;

  GetEthernetHostNumber: PROCEDURE RETURNS [CARDINAL];

  -- Process/ProcessDefs stuff for Device Drivers
  AddInterruptHandler: PROCEDURE [InterruptLevel, POINTER TO CONDITION, WORD];
  RemoveInterruptHandler: PROCEDURE [InterruptLevel];
  InterruptLevel: TYPE = ProcessDefs.InterruptLevel;
  -- Parity Process runs at Pritority 7, and uses InterruptLevel 0
  -- Swat watcher and TOD clock uses InterruptLevel 3
  -- Timeout process uses InterruptLevel 4
  -- Keyboard Process run at Pritority 6, and uses InterruptLevel 7
  -- AltoEthernet drivers run at Pritority 5, and use InterruptLevels 5, 6, and 8
  -- PacketRadio driver runs at Priority 4 and uses InterruptLevels 9 and 10
  -- ASD/Sweeden is using Pritority 3 and InterruptLevels 9 and 10 for other lines
  -- D0Ethernet drivers run at Priority 5 and use InterruptLevels 5+6 and 9+10
  -- AltoSLA driver runs at Pritority 3, and uses InterruptLevel 12
  -- ReadDisk runs at normal Pritority, and uses InterruptLevel 13
  -- Gateway Dispatcher runs at Pritority 2

  -- Debugging things
  FrameHandle: TYPE = ControlDefs.FrameHandle;
  GetReturnFrame: PROCEDURE RETURNS [FrameHandle] = MACHINE CODE
    BEGIN Mopcodes.zLLB, ControlDefs.returnOffset; END;

  -- Other goodies

  EnableAborts: PROCEDURE [LONG POINTER TO CONDITION] = INLINE {};

  CopyLong, FriendOfCopyLong: PROCEDURE [
    from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER];

  -- This is a hack for debugging
  SetDebuggingPointer: PROCEDURE [LONG POINTER];
  magicMemoryLocation: --SHORT--POINTER = LOOPHOLE[612B];

  END.