DEFINITION MODULE KERnad;

EXPORT QUALIFIED
     integer16, integer32,
     cardinal16, cardinal32, byte, bits16, bits32,
     tiiStruct, virtAddr, exceptionType, pBlock, seid;

(* ===========================================================================

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:  KSOS Kernel

NAME:

	     KERNEL GLOBAL DECLARATIONS -- NON-ALLOCATING
	
HISTORY:
  AUTHOR:   Richard Neely, Luke Dion
  VERSION:  10.32.1.1 of 11/21/80
  MODULE TYPE: 

=========================================================================== *)

CONST KERnadWhat = '@(#)KERnad.mod	10.32.1.1';

CONST
    maxVirtAddr   = 177777B;  (*2^16 - 1*)
    (*table sizes*)
	openFileLimit =     15 ;  (*olt open files per process*)
	openSegLimit  =     15 ;  (*olt segments per process*)
	topPageGroup  =      7 ;  (*olt page reg groups per proc-dom-space*)
	topGenReg     =      5 ;  (*olt no. of general registers*)
	topFloReg     =      5 ;  (*olt no. of floating registers*)
	mesLimit	=	11;	(* number of chars-1 in message *)
	userSemLimit  =       320;    (* number of user semaphores    *)

TYPE
	(* ============== Fundamental Types ================= *)

	cardinal8	= [0 .. 255];
	integer8	= [-128 .. 127];
	bits8		= SET OF [0 .. 7];
	byte		= cardinal8;

	cardinal16	= [0 .. 65535];
	integer16	= [-32768 .. 32767];
	bits16		= SET OF [0 .. 15];
     
        cardinal32	= CARDINAL;
	integer32	= INTEGER;
	bits32		= BITSET;

(*****
	bits32          = ARRAY [0..1] OF bits16;    (* 32-bit bits *)
	cardinal32      = ARRAY [0..1] OF CARDINAL; (* 32-bit unsigned *)
******)

	physAddr       = CARDINAL;

	exceptionType   = CARDINAL;	(* exceptions at kernel interface *)

	nspType        = byte;         (* name space partition *)

	(* ============== Miscellaneous ================ *)

	segIndex       = integer16;

	segDes         = integer16;

	openDescriptor  = integer16;

	selector        = bits16;


CONST
	    nullNsp    = 0C;      (* null *)
	    extentNsp  = 1C;      (* EXTENTS *)
	    terminalNsp= 2C;      (* TERMINALS *)
	    deviceNsp  = 3C;      (* DEVICES *)
	    processNsp = 4C;      (* PROCESSES *)
	    segmentNsp = 5C;      (* SEGMENTS *)
	    subtypeNsp = 6C;      (* SUBTYPES *)
	    kernelNsp  = 7C;      (* Kernel namespace *)
	    sameNsp    = 128(*C*);    (* 128 - used in UNIX directories only *)
	    lowFileNsp = 129(*C*);    (* 129 - first nsp for mounted file system*)
	    highFileNsp= 255(*C*);    (* 255 - last nsp for mounted file system *)

TYPE

	seid            = RECORD                (* secure entity identifier *)
			  nsp     : nspType;       (* name space *)
			  uniqId0: byte;           (* unique ID *)
			  uniqId1: CARDINAL;
			  END;

	privStruct     = bits32;               (* set of privileges *)

	privNames      = (                     (*names of privileges*)
			  privFileUpdateStatus,  privLink,
			  privLockSeg,           privModifyPriv,
			  privMount,             privSetLevel,
			  privStickySeg,         privSetPath,
			  privViolSimpSecurity,  privViolStarSecurity,
			  privViolSimpIntegrity, privViolStarIntegrity,
			  privViolDiscrAccess,   privRealizeExecPermission,
			  privSignal,            privWalkPTable,
			  privHalt,              privKernelCall,
			  privViolCompartments,  privSetComm,
			  privImmigrate,         privViolTranquility
			  );

	(* ============== TII Construction ================= *)

	discrAccess	= bits16;			(* discretionary access *)

	securityCatType       = byte;   (* security categories (half byte) *)

	integrityCatType      = byte;   (* integrity categories (half byte) *)

	compartSet     = bits32;        (* set of security compartments *)

	tiiStruct      = RECORD
			  securityCategory     : securityCatType;
			  integrityCategory    : integrityCatType;
			  securityCompart      : compartSet;
			  owner                 : CARDINAL;
			  group                 : CARDINAL;
			  da                    : discrAccess;
			  tiiPriv              : privStruct;
			  END;

	(* ============== Virtual Memory ================= *)

	domainType     = (nullDomain,kernelDomain,supervisorDomain,userDomain);


	memType        = (nullSpace,dSpace,iSpace);

	virtAddr       = CARDINAL;

	virtLoc        = RECORD               (* virtual location *)
			  domain        : domainType;
			  space         : memType;
			  address       : virtAddr;
			  END;

	pBlock         = RECORD
			  location      : virtLoc;
			  size          : CARDINAL;
			  END;


	(** IPC Kernel interface structure **)

	msgStruct = ARRAY [0..mesLimit] OF CHAR; (* IPC message data *)

	ipcReturn = RECORD
			sender  : seid;
			message : msgStruct;
		     END;

	ipcBlock = RECORD
			ipcPtr	: integer16;
			ipcMes	: ipcReturn;
		    END;

CONST
	(*
	 * Event type codes for pseudo interrupt IPC's
	 *	(To be placed in the first byte of the
	 *		message field.)
	 *)

	nullEvent		= 0C;
	memerrEvent		= 1C;
	bptEvent		= 2C;
	iotEvent		= 3C;
	cpuerrorEvent		= 4C;
	illinstEvent		= 5C;
	mmEvent		= 6C;
	fltpntEvent		= 7C;
	ttoggleEvent		= 10C;
	talarmEvent		= 11C;
	emulcallEvent		= 12C;
	iocompleteEvent	= 13C;


CONST
    (* bits for discretionary access in TII *)
	setuid		   = 10;
	setgid		   = 9;
	ownerRead          = 8;
	ownerWrite         = 7;
	ownerExecute       = 6;
	groupRead          = 5;
	groupWrite         = 4;
	groupExecute       = 3;
	allRead            = 2;
	allWrite           = 1;
	allExecute         = 0;
    (* bits for access mode in POST *)
	readAcc            = ownerRead;
	writeAcc           = ownerWrite;
	executeAcc         = ownerExecute;
    (* null objects *)
	nullBoolean       = FALSE;
	nullBits          = {};
	nullChar          = 0C;
	nullInteger       = 0;
	nullCardinal      = 0;

	nullByte          = 0C;
	nullSegDes       = -1;
	nullSegIndex     = -1;
	nullSecurityCat  = 0C;
	nullIntegrityCat = 0C;

	nullVirtLoc      = 0; (* virtLoc(nullDomain,nullSpace,0);TEMP*)

	noIndex           = -1;
	nullSeid          = 0; (*seid(nullNsp,0C,nullCardinal);TEMP*)
	nullBits32        = {}; (*bits32({},{});TEMP*)
(*	nullTiiStruct    = tiiStruct(0C,0C,bits32({},{}),
					0,0,{},bits32({},{}));TEMP *)
    (* other *)
	readOnly           = {readAcc};
	writeOnly	   = {writeAcc};


VAR typeCond: bits16;
CONST
    typeAll		= 0;
    typeParam		= 1;
    typeParamNw	= 2;
    typeKcall		= 3;
    typeKcallNw	= 4;
    typeGate		= 5;
    typeSwap		= 6;
    typeSch		= 7;
    typePse		= 8;

END KERnad.
