-- XMesaDefs.Mesa  Edited by Levin on October 16, 1978  3:10 PM

DIRECTORY
  AltoDefs: FROM "altodefs" USING [PageNumber, PageCount],
  BitBltDefs: FROM "BitBltDefs" USING [BBptr],
  SegmentDefs: FROM "segmentdefs" USING [SegmentHandle, FileSegmentHandle, DataSegmentHandle],
  Mopcodes: FROM "mopcodes" USING [zEXCH, zKFCB, zPOP];

XMesaDefs: DEFINITIONS =
  BEGIN

  -- XM Memory Management

  XVMtoSegment: PROCEDURE [a: LONG POINTER] RETURNS [SegmentDefs.SegmentHandle]; 
  XSegmentAddress: PROCEDURE [seg: SegmentDefs.SegmentHandle] RETURNS [LONG POINTER]; 

  XVMtoDataSegment: PROCEDURE [a: LONG POINTER] RETURNS [SegmentDefs.DataSegmentHandle]; 
  XDataSegmentAddress: PROCEDURE [seg: SegmentDefs.DataSegmentHandle] RETURNS [LONG POINTER]; 

  XVMtoFileSegment: PROCEDURE [a: LONG POINTER] RETURNS [SegmentDefs.FileSegmentHandle];
  XFileSegmentAddress: PROCEDURE [seg: SegmentDefs.FileSegmentHandle] RETURNS [LONG POINTER];

  ImmovableSegmentInHighBank: SIGNAL [SegmentDefs.FileSegmentHandle];

  -- Additional Options for Memory Allocation

  BankIndex: TYPE = [0..3];
  PagesPerBank: AltoDefs.PageCount = LAST[AltoDefs.PageCount];
  MaxXPage: AltoDefs.PageNumber = 1777B;
  DefaultBase0: AltoDefs.PageNumber = MaxXPage+1;
  DefaultBase1: AltoDefs.PageNumber = DefaultBase0+1;
  DefaultBase2: AltoDefs.PageNumber = DefaultBase1+1;
  DefaultBase3: AltoDefs.PageNumber = DefaultBase2+1;
  DefaultXMBase: AltoDefs.PageNumber = DefaultBase3+1;

  -- LONG POINTER support

  sXCOPY: CARDINAL = 17B;

  XCOPY: PROCEDURE[from, to: LONG POINTER,nwords: CARDINAL] =
    MACHINE CODE BEGIN  Mopcodes.zKFCB, sXCOPY END;

  InvalidXCOPY: ERROR;

  HighHalfPtr: PROCEDURE [LONG POINTER] RETURNS [CARDINAL] =
    MACHINE CODE BEGIN Mopcodes.zEXCH; Mopcodes.zPOP END;

  LowHalfPtr: PROCEDURE [LONG POINTER] RETURNS [POINTER] =
    MACHINE CODE BEGIN Mopcodes.zPOP END;

  LongAddressFromPage: PROCEDURE[page: AltoDefs.PageNumber] RETURNS[lp: LONG POINTER];
  PageFromLongAddress: PROCEDURE[lp: LONG POINTER] RETURNS[page: AltoDefs.PageNumber];

  InvalidLongPointer: ERROR [lp: LONG POINTER];
  InvalidXMPage: ERROR [page: AltoDefs.PageNumber];

  -- Configuration Information

  MachineType: TYPE = {unknown, AltoI, AltoII, AltoIIXM, D0, Dorado};

  MemoryConfig: TYPE = MACHINE DEPENDENT RECORD[
	reserved: [0..37B],
	AltoType: MachineType,
	useXM: BOOLEAN,
	unused: [0..3],
	secondROM: BOOLEAN,
	banks: [0..17B],
	mesaMicrocodeVersion: [0..377B],
	XMMicrocodeVersion: [0..377B]];

  GetMemoryConfig: PROCEDURE RETURNS [MemoryConfig];

  XMNotAvailable: ERROR;

  -- Miscellaneous

  XBitBlt: PROCEDURE[bbt:BitBltDefs.BBptr, bank:BankIndex];

  END.