DEFINITION MODULE KPRdcl;

FROM K32baseTypes IMPORT

	bits16, byte, cardinal16, cardinal32, integer16;

FROM K32conf IMPORT

	modProcsLimit, pcsLimit, procsLimit;

FROM K32types IMPORT

	ipcReturn, kernelNsp, msgStruct, processNsp, seid, tiiStruct;

FROM KERpcs IMPORT

	ipcBlock, pcs, pcsIpcLimit;

EXPORT QUALIFIED

	alarmFlag, alarmInterrupt, auditSeid, baseLev, contextSize,
	currIndex, currProc, delayFlag, eligibleResource, hardLev,
	iocProgMax, ioLev, ipcBlockLimit, ipcFlag, ipcLev, ipct,
	kernelExec, kernelSeid, Killegal, killFlag, KinitSeg,
	KprocDel, levelType, mappable, maxIocCount, maxIpcCount,
	messageCount, messageDescr, messageInfo, messageType, napFlag,
	noSeid, nucleusType, nullMes, nullProcPtr, nullUptEntry,
	numInt, pcsId, PCSrecSize, PCSsegSize, pcsSize, pcsSt, ppt,
	pptEntry, primitiveResource, procContext, procContextAdr,
	procInfo, procSwap, procTdi, psePending, resident,
	residentDescr, sanitaryIpc, sigLev, slotId, slots, stackLimit,
	swapContextSize, swapFlag, swapHelpFree, swapHelpNormal,
	swapHelpReleased, swapPcs, tempContext, tempSwap, timeLev,
	timerToggle, upt, uptEntry, userParOff, userPcsPdr,
	userResource;

(*
COPYRIGHT:  1979, by Ford Aerospace and Communications Corp.
ADDRESS:    Ford Aerospace and Communications Corp.
            Western Development Laboratories
            3939 Fabian Way
            Palo Alto, California 94303
            Attention: Software Technology Dept.
            Mail Stop: V02 

CPCI:   Kernel
CPC:    Kernel Process Management (KPR)

TAG:    KPR
MODULE NAME:  

	Kernel Process Management Declarations

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR:   L. C. Dion
  VERSION:  1.1 of 6/18/86
  MODULE TYPE: MODULA

PRIVILEGES:  None
SPECIAL NOTES:  None

*)


(*

CPCI:   Kernel
CPC:    Kernel Process Management (KPR)

TAG:    STR
MODULE NAME:  

	KPR STRuctures ... constant declarations - str_con

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR:   L. C. Dion
  VERSION:  1.1 of 6/18/86
  MODULE TYPE: MODULA

PRIVILEGES:  None
SPECIAL NOTES:  None

 *
 *      STR_CON:        KPR Constants
 *)

CONST   (* constants *)

(*      STRconWhat = '@(#)str_con.mod	1.1{0}';  *)

	numInt                 = 5;    (* number of pseudo interrupts -1   *)
	baseLev		= 0;	(* base pseudo interrupt level *)
	ipcLev			= 1;	(* IPC pseudo interrupt level *)
	timeLev		= 2;	(* timer pseudo interrupt level *)
	sigLev			= 3;	(* K_signal pseudo interrupt level *)
	ioLev			= 4;	(* I/O comp pseudo interrupt level *)
	hardLev		= 5;	(* hardware pseudo interrupt level *)

	userResource           = 0;    (* sch_info - user resource request *)
	eligibleResource       = 1;    (* sch_info - elig resource request *)
	primitiveResource      = 2;    (* sch_info - prim resource request *)
	ipcFlag                = 3;    (* sch_info - ipc wait in progress  *)
	napFlag                = 4;    (* sch_info - nap wait in progress  *)
	swapFlag               = 5;    (* sch_info - being swapped         *)
	killFlag               = 6;    (* sch_info - process killed        *)
	timerToggle            = 7;    (* sch_info - timer toggle enabled  *)
	alarmInterrupt         = 8;    (* sch_info - alarm interrupt pend  *)
	delayFlag              = 9;    (* sch_info - Kcall delay in prog.  *)
	kernelExec             = 10;   (* sch_info - kernel execution      *)
	alarmFlag		= 11;	(* sch_info - alarm in progress	    *)

	(* only ipc_lev, time_lev, sig_lev and io_lev may be pending        *)

	psePending             = 11;   (* sch_info - array 1:num_int-1     *)

	iocProgMax              = 5;    (* max # of in progress ioc request *)

	maxIpcCount             = 30;   (* max # of queued ipc messages     *)
	maxIocCount             = 6;    (* max # of queued ioc messages     *)
		(* See comment in KERpcs.mod about relation of these constants
			to pcs_ipc_limit	tep 9/24/85	*)

	ipcBlockLimit         = (iocProgMax*(procsLimit+1))-1;
					(* number of IPC blocks in IPCT     *)


	mappable                = 6 - 1;    (* # of mappable nucleus procs  *)

	(* SWAP HELP STATUS *)

	swapHelpNormal	= 0;
	swapHelpReleased	= 1;
	swapHelpFree		= 2;

VAR
	(* sanitary IPC *)

	sanitaryIpc : ipcReturn;

	(* audit capture process seid *)

	auditSeid : seid;

	(* Kernel seid *)

	kernelSeid : seid;

CONST
	(* dummy Kernel call numbers *)

	KinitSeg      = 256;		(* SMCLinitialSegment call	*)
	KprocDel      = 257;		(* process delete support	*)
	Killegal       = 258;		(* Illegal Kernel call		*)


(*
COPYRIGHT:  1979, by Ford Aerospace and Communications Corp.
ADDRESS:    Ford Aerospace and Communications Corp.
            Western Development Laboratories
            3939 Fabian Way
            Palo Alto, California 94303
            Attention: Software Technology Dept.
            Mail Stop: V02 

CPCI:   Kernel
CPC:    Kernel Process Management (KPR)

TAG:    STR
MODULE NAME:  

	KPR STRuctures ... type declarations - str_type

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR:   L. C. Dion
  VERSION:  1.1 of 6/18/86
  MODULE TYPE: MODULA

PRIVILEGES:  None
SPECIAL NOTES:  None

 *
 *
 *      STR_TYPE: Kernel Process Management Types
 *
 *)

(*      CONST   StrTypeWhat = '@(#)str_type.mod	1.1{0}';         *)      (* WHAT string *)

TYPE    levelType = ( userLevel,              (* user process states *)
		       eligibleLevel,
		       primitiveLevel,
		       primWaitLevel,
		       primReadyLevel );

	nucleusType = ( nucleusWait,          (* nucleus process states *)
			 nucleusReady );

	procInfo = RECORD                      (* user process information *)
			deltaPrio      : cardinal16;
			dispatchCount  : byte;
			dispatchSched	: byte;
			uniqueId       : cardinal16;
		    END;

	procTdi = RECORD                       (* user process tdi *)
			parent          : seid;
			familyName     : cardinal16;
			priority        : cardinal16;
			timeOut        : integer16;
			realOwner      : cardinal16;
			realGroup      : cardinal16;
			pseIntLevel   : cardinal16;
		   END;

	messageType = (ipcMessage,iocMessage);

	resident = (inipct,inpcs);	(* IPC message residence *)

	residentDescr = ARRAY [inipct..inpcs] OF integer16;

	messageDescr = ARRAY [ipcMessage..iocMessage] OF residentDescr;

	messageCount = ARRAY [ipcMessage..iocMessage] OF integer16;

	messageInfo = RECORD
			messageHead    : messageDescr;
			messCount      : messageCount;
			iocInProgress   : integer16;
			messFreeCount   : integer16;
		       END;

	uptEntry = RECORD                      (* user process table entry *)
			procPtr        : integer16;
			schinfo         : bits16;
			minfo           : messageInfo;
			pinfo           : procInfo;
			tdinfo          : procTdi;
			tiinfo          : tiiStruct;
			userTiming     : cardinal16;
			supvTiming     : cardinal16;
			kernTiming     : cardinal16;
		    END;

	pptEntry = RECORD              (* prim process table entry *)
			sp              : cardinal16;
			stkPar         : cardinal16;
			stkPdr         : cardinal16;
			modulaPtr      : integer16;
			rank            : integer16;
			misc            : integer16;
		    END;

	slotId = RECORD                        (* PCS slot information *)
			proc    : integer16;
			sltPar : cardinal16;
			sltCnt : cardinal16;
			sltTim	: cardinal16;
		  END;

	pcsId = RECORD                         (* PCS slot process info *)
			sSeid  : seid;
			slot    : integer16;
		 END;

CONST

	pcsSize = 512 * 7;		(* size of pcs segment *)
	contextSize = 1308;		(* TSIZE( pcs ) *)
	stackLimit = ( ( ( pcsSize-1 ) - contextSize ) DIV 2 );

TYPE
	swapPcs = RECORD
		modStack       : ARRAY [0..stackLimit] OF cardinal16;
		context         : pcs;
		   END;

CONST
	swapContextSize = 3584;		(* TSIZE( swapPcs ) *)

	(*	I notice that (pcsSize = swapContextSize).  Is this
		a coincidence or is it worth asserting?
			:: Jeff Makey  4 November 1986 *)

	pageSize = 8192;
	(*
	 * user_pcs_pdr ... page descr. register for user process PCS.
	 *                      Reference the PDP11/70 manual for PDR
	 *                      definition ... paying special attention
	 *                      to downward growing segments.
	 *)
	userPcsPdr = 77416B - ((( swapContextSize DIV 64 ) -1) * 256);
	userParOff = ( pageSize - swapContextSize ) DIV 64;


(*
CPCI:   Kernel
CPC:    Kernel Process Management (KPR)

TAG:    STR
MODULE NAME:  

	KPR STRuctures ... variable declarations - str_var

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR:   L. C. Dion
  VERSION:  1.1 of 6/18/86
  MODULE TYPE: MODULA

PRIVILEGES:  None
SPECIAL NOTES:  None

 *
 *
 *	STR_VAR:	STR variable declarations
 *
 *)


(*      CONST   STRvarWhat = '@(#)str_var.mod	1.1{0}';          *)

VAR

	upt     : ARRAY [0..procsLimit] OF uptEntry;

	ppt     : ARRAY [0..modProcsLimit] OF pptEntry;

	ipct    : ARRAY [0..ipcBlockLimit] OF ipcBlock;

	pcsSt  : ARRAY [0..procsLimit] OF pcsId;

	slots   : ARRAY [0..pcsLimit] OF slotId;

	currIndex	: integer16;	(* current user process' UPT index *)
	currProc	: seid;		(* current user process' SEID *)

	(* PCS SUPPORT *)

	PCSsegSize	: cardinal16;
	PCSrecSize	: cardinal16;

	tempSwap[ 140000B - swapContextSize ]        : swapPcs;
	procSwap[ 160000B - swapContextSize ]        : swapPcs;

	tempContext[ 140000B - contextSize   ]        : pcs;

CONST	procContextAdr = 160000B - contextSize;
VAR	procContext[ procContextAdr   ]        : pcs;

	(*
	 *      PLEASE NOTE:
	 *
	 *              By the definitions above:
	 *
	 *              adr( temp_swap.context ) =
	 *                      adr( temp_context )
	 *
	 *              adr( proc_swap.context ) =
	 *                      adr( proc_context )
	 *
	 *)

(*	CONST	KPRdclWhat = '@(#)KPRdcl.mod	1.1{0}';  *)


VAR
	noSeid : seid;

CONST
	nullMes = -1;

	nullProcPtr = procsLimit + 1;

VAR
	nullUptEntry : uptEntry;

END KPRdcl.
