-- System.mesa (last edited by: Levin on: August 24, 1982 4:56 pm)

DIRECTORY
  MiscAlpha USING [aRCLK],
  Mopcodes USING [zMISC];

System: DEFINITIONS =

BEGIN


-- Universal identifiers

UniversalID: TYPE [5];

nullIDRep: RECORD [a, b, c, d, e: WORD] = [0, 0, 0, 0, 0]; -- never returned by GetUniversalID

nullID: UniversalID = LOOPHOLE[nullIDRep];

GetUniversalID: PROCEDURE RETURNS [uid: UniversalID];

FileID: TYPE = RECORD [UniversalID]; -- a useful special case of UniversalID
VolumeID: TYPE = RECORD [UniversalID]; -- another useful special case of UniversalID
PhysicalVolumeID: TYPE = RECORD [UniversalID]; -- yet another useful special case of UniversalID


-- Network addresses

NetworkAddress: TYPE [6];

nullNetworkAddress: READONLY NetworkAddress;


-- Time of day

GreenwichMeanTime: TYPE = RECORD [LONG CARDINAL];
-- A Greenwich mean time t represents the time which is t-gmtEpoch seconds after midnight, 1 January 1968, the time chosen as the epoch or beginning of the Pilot time standard.  Within the range in which they overlap, the Alto and Pilot time standards assign identical bit patterns, but the Pilot standard runs an additional 67 years before overflowing.

-- Greenwich mean times should be compared directly only for equality; to find which of two gmt's comes first, apply SecondsSinceEpoch to each and compare the result.  If t2 is a gmt known to occur after t1, then t2-t1 is the seconds between t1 and t2.  If t is a gmt, then System.GreenwichMeanTime[t+60] is the gmt one minute after t.

gmtEpoch: GreenwichMeanTime = [2114294400]; -- = (67 years * 365 days + 16 leap days) * 24 hours * 60 minutes * 60 seconds

GetGreenwichMeanTime: SAFE PROC RETURNS [gmt: GreenwichMeanTime];

SecondsSinceEpoch: SAFE PROC [gmt: GreenwichMeanTime] RETURNS [LONG CARDINAL] =
  TRUSTED INLINE {RETURN[gmt-gmtEpoch]};

AdjustGreenwichMeanTime: SAFE PROC [gmt: GreenwichMeanTime, delta: LONG INTEGER]
  RETURNS [GreenwichMeanTime] = TRUSTED INLINE {RETURN[[gmt+delta]]};

LocalTimeParameters: TYPE = MACHINE DEPENDENT RECORD [
  direction(0:0..0): WestEast, -- e.g. Pacific is west
  zone(0:1..4): [0..12], -- e.g. Pacific is 8
  zoneMinutes(1:0..6): [0..59],
  beginDST(0:5..15): [0..366], -- e.g. April 30 is 121
  endDST(1:7..15): [0..366]]; -- e.g. October 31 is 305

WestEast: TYPE = MACHINE DEPENDENT {west(0), east(1)};

GetLocalTimeParameters: SAFE PROC [pvID: PhysicalVolumeID ← [nullID]]
  RETURNS [params: LocalTimeParameters];
  -- The parameter pvID should normally be defaulted.

LocalTimeParametersUnknown: ERROR;

SetLocalTimeParameters: PROC [
  params: LocalTimeParameters, pvID: PhysicalVolumeID ← [nullID]];
  -- The parameter pvID should normally be defaulted.


-- Interval timing

Microseconds: TYPE = LONG CARDINAL;

Pulses: TYPE = RECORD [LONG CARDINAL];

GetClockPulses: SAFE PROC RETURNS [p: Pulses] = TRUSTED MACHINE CODE
  {Mopcodes.zMISC, MiscAlpha.aRCLK};

PulsesToMicroseconds: SAFE PROC [p: Pulses] RETURNS [m: Microseconds];

MicrosecondsToPulses: SAFE PROC [m: Microseconds] RETURNS [p: Pulses];


-- Old interval timer mechanism (clients should convert GetClockPulses)

TimerHandle: TYPE = RECORD [Pulses];

CreateIntervalTimer: SAFE PROC RETURNS [t: TimerHandle] = LOOPHOLE[GetClockPulses];

GetIntervalTime: SAFE PROC [t: TimerHandle] RETURNS [m: Microseconds];


-- System power control

PowerOff: PROC;

SetAutomaticPowerOn: SAFE PROC [time: GreenwichMeanTime, externalEvent: BOOLEAN];

ResetAutomaticPowerOn: SAFE PROC;

END.

LOG

Time: April 12, 1978  11:56 AM	By: Lauer	Action: Created file
Time: May 4, 1978  3:19 PM	By: Lauer	Action: Fixed for Mesa 4.0; added NetworkAddress
Time: May 5, 1978  11:12 AM	By: Lauer	Action: Added nullID
Time: June 21, 1978  11:23 AM	By: Lauer	Action: Deleted AllocateSpecificSocket
Time: July 29, 1978  1:07 PM	By: Horsley	Action: Deleted DeleteIntervalTimer and InvalidTimerHandle
Time: August 11, 1978  10:22 AM	By: Lauer	Action: Moved TimerHandle from SystemInternal
Time: August 29, 1978  11:26 AM	By: Lauer	Action: Changed representation of UniversalID to be four words of UNSPECIFIED
Time: March 9, 1979  4:37 PM	By: McJones	Action: Moved body of NetworkAddress from SystemInternal; changed representation of GreenwichMeanTime and Microseconds to be LONG CARDINALs
Time: May 2, 1979  2:26 PM	By: McJones	Action: Added new interval timing (Pulses)
Time: May 22, 1979  3:30 PM	By: Lauer	Action: Replaced NetworkAddress with a record containing only two LONG UNSPECIFIED's
Time: January 25, 1980  4:15 PM	By: McJones	Action: Redefined old interval timers in terms of Pulses
Time: February 9, 1980  12:41 PM	By: McJones	Action: Converted to new GreenwichMeanTime representation
Time: May 9, 1980  11:07 AM	By: McJones	Action: Added PhysicalVolumeID
Time: June 10, 1980  5:52 PM	By: McJones	Action: Added two more words to NetworkAddress and one more word to UniversalID; converted them both to exported types
Time: August 13, 1980  4:20 PM	By: McJones	Action: Added AdjustGreenwichMeanTime; converted to MiscAlpha
Time: January 21, 1981  1:36 PM	By: McJones	Action: Added local time parameters
Time: August 24, 1982 4:56 pm	By: Levin	Action: Make things SAFE.