-- Copyright (C) 1984  by Xerox Corporation. All rights reserved. 
-- DicentraInputOutput.mesa, HGM, 18-Feb-84 21:12:03

DIRECTORY
  Environment USING [PageCount],
  ESCAlpha USING [aINPUT, aLOADRAMJ, aOUTPUT],
  Mopcodes USING [zESC];

DicentraInputOutput: DEFINITIONS =
  BEGIN
  
  IOAddress: TYPE = LONG POINTER;
  
  -- Read/Write one WORD from specified IO Address (ADR0 = 0)
  Input: PROCEDURE [IOAddress] RETURNS [UNSPECIFIED] = MACHINE CODE
    BEGIN Mopcodes.zESC, ESCAlpha.aINPUT END;
  Output: PROCEDURE [datum: UNSPECIFIED, address: IOAddress] = MACHINE CODE
    BEGIN Mopcodes.zESC, ESCAlpha.aOUTPUT END;
  
  -- Read/Write one BYTE from specified IO Address (ADR0 = 0)
  InputByteEven: PROCEDURE [IOAddress] RETURNS [UNSPECIFIED] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08CH END;
  OutputByteEven: PROCEDURE [datum: UNSPECIFIED, address: IOAddress] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08DH END;
  -- Read/Write one BYTE from specified IO Address (ADR0 = 1)
  InputByteOdd: PROCEDURE [IOAddress] RETURNS [UNSPECIFIED] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08EH END;
  OutputByteOdd: PROCEDURE [datum: UNSPECIFIED, address: IOAddress] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08FH END;
  

  -- Block transfer operations to IO Address space

  -- Read "Reads" from the IO device.
  -- "Hole" uses the same IO Address for each word.
  
  ReadHole: PROCEDURE [to: LONG POINTER, from: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 090H END;
  
  ReadBlock: PROCEDURE [to: LONG POINTER, from: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 091H END;
  
  ReadHyper: PROCEDURE [to: LONG POINTER, from: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 092H END;
  
  WriteHole: PROCEDURE [from: LONG POINTER, to: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 093H END;
    
  WriteBlock: PROCEDURE [from: LONG POINTER, to: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 094H END;
  
  WriteHyper: PROCEDURE [from: LONG POINTER, to: IOAddress, words: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, 095H END;
 
  
  -- Read/Write one word from specified real memory
  -- This allows access to memory beyond the addressing limits of the Map
  RawRead: PROCEDURE [IOAddress] RETURNS [UNSPECIFIED] = MACHINE CODE
    BEGIN Mopcodes.zESC, 084H END;
  RawWrite: PROCEDURE [datum: UNSPECIFIED, address: IOAddress] = MACHINE CODE
    BEGIN Mopcodes.zESC, 085H END;
  
    
  ExternalStatus: TYPE = RECORD [
    ints: PACKED ARRAY InterruptLevel OF BOOLEAN,
    trash: PACKED ARRAY [0..4) OF BOOLEAN,
    altBoot, masterBar, debAFull, debBFull: BOOLEAN ];
    
  GetExternalStatus: PROCEDURE RETURNS [ExternalStatus] = MACHINE CODE
    BEGIN Mopcodes.zESC, 086H END;

  SetExtCtrl: PROCEDURE [WORD] = MACHINE CODE
    BEGIN Mopcodes.zESC, 087H END;


  InterruptLevel: TYPE = MACHINE DEPENDENT {
    processTimeouts(0),
    slowThings(1),  -- Not used yet
    ethernet(2),
    ethernetOne(3),
    phoneLine(4),
    disk(5),  -- Not used yet
    display(6),  -- Not used yet
    fastThings(7)};  -- Not used yet

  SetWakeupMask: PROCEDURE [bits: WORD, intLevel: InterruptLevel] = MACHINE CODE
    BEGIN Mopcodes.zESC, 088H END;

  SetNxmExpected: PROCEDURE [BOOLEAN] = MACHINE CODE
    BEGIN Mopcodes.zESC, 089H END;

  SetWakeupBits: PROCEDURE [bits: WORD] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08AH END;

  SetPhonelineCSB: PROCEDURE [LONG POINTER] = MACHINE CODE
    BEGIN Mopcodes.zESC, 08BH END;
  
  JumpBank: PROCEDURE [newBank: CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zESC, ESCAlpha.aLOADRAMJ END;



  -- number of virtual pages in a standard product dandelion  (16K map)
  numberVirtualPages: Environment.PageCount = 40000B; -- = 16384D = 4000x
  
  END..