-- Copyright (C) 1983  by Xerox Corporation. All rights reserved. 
-- SimplePUPIO.mesa, HGM, 12-Dec-83  0:52:24
-- SimplePUPIO.mesa      25-May-83 10:40:48 by DKnutsen

-- This interface provides simple facilities for communication over the PUP network.

DIRECTORY
  BootChannel USING [Result],
  Device USING [Type],
  PilotMP USING [cGermDriver, cGermTimeout, Code],
  System USING [Microseconds],
  
  PupTypes USING [PupAddress, PupSocketID, PupType, Pair];

SimplePUPIO: DEFINITIONS =
  BEGIN

  ByteCount: TYPE = CARDINAL;

  GetRawBufferSize: PROCEDURE RETURNS [rawBufferSize: CARDINAL];

  Initialize: PROCEDURE [
    deviceType: Device.Type, deviceOrdinal: CARDINAL,
    rawBuffer: LONG POINTER, cleanups: Cleanups ← avoidCleanup]
    RETURNS [result: BootChannel.Result];
  << Prepares for transfers on on given device.
  rawBuffer↑ is resident storage, of the size given by GetRawBufferSize.
  It becomes the property of SimpleNSIO until Finalize or error.
  Clients running in germ-land should use cleanups = avoidCleanup.
  If requested device is not available, returns result = cantHandleDevice,
  either because the device does not exist or because the
  implementation does not know how to talk to it. >>
  
  Cleanups: TYPE = {avoidCleanup, doCleanup};
  cantHandleDeviceCode: PilotMP.Code = PilotMP.cGermDriver;
  cantHandleDevice: BootChannel.Result = [error[cantHandleDeviceCode]];

  Finalize: PROCEDURE [cleanups: Cleanups ← avoidCleanup];

  GetEthernetHostNumber: PROCEDURE RETURNS [CARDINAL];
  
  GetEthernetNetNumber: PROCEDURE RETURNS [CARDINAL];  -- 0 if unknown

  -- returns -1 if timeout
  ReceivePacket: PROCEDURE [
    source: LONG POINTER TO PupTypes.PupAddress, me: PupTypes.PupSocketID,
    data: LONG POINTER, maxWords: CARDINAL, timeout: System.Microseconds]
    RETURNS [result: BootChannel.Result, bytes: CARDINAL, id: PupTypes.Pair, type: PupTypes.PupType];
  -- data is a pointer to a buffer to receive a client level two packet
  -- of not more than given WORD length.
  -- If timed out, returns result = timeOut and bytes = timeOutBytes.
    
  timedOutCode: PilotMP.Code = PilotMP.cGermTimeout;
  timedOutResult: BootChannel.Result =  --
    [error[timedOutCode]];  -- Note: Mesa won't compare this to an unbound Result.
  timedOutBytes: ByteCount = ByteCount.LAST;

  ReturnPacket: PROCEDURE [
    type: PupTypes.PupType, data: LONG POINTER, bytes: ByteCount]
    RETURNS [result: BootChannel.Result];
  -- Sends Level two packet [data, bytes] back to where
  --   last packet came from.

  SendPacket: PROCEDURE [
    dest: PupTypes.PupAddress, me: PupTypes.PupSocketID, type: PupTypes.PupType,
    id: PupTypes.Pair, data: LONG POINTER, bytes: ByteCount]
    RETURNS [result: BootChannel.Result];
  -- Transmits level two packet [data, count].

  END.


LOG

2-Nov-81 18:04:03   Knutsen   Deleted iocb param to ActivateDriver.
25-May-83 10:40:44   DKnutsen
   Renamed MiniEthernetDefs.mesa  =>  SimplePUPIO. Change names to track SimpleNSIO. Initialize returns Result.