DEFINITION MODULE extio;

FROM SYSTEM IMPORT ADDRESS;

FROM K32baseTypes IMPORT
	integer16, cardinal16, cardinal32;
FROM IOform IMPORT
	SLOTSPERBLOCK, SLOTCHKSUM, SLOTBLKFILLSZ,
	mBlockNumber;
FROM IOEform IMPORT
	extentItem;
FROM IOFform IMPORT
	slotNumber, treeNumber, mapNumber, fileCond,
	mountLocation,
	allocSlot, jNode, mountItem;
FROM bio IMPORT
	Btype;

EXPORT QUALIFIED
	extentDescriptor,
	openx, closex, flushx,
	findx, readx, writex,
	readj, writej,
	findb, readb, writeb,
	setmap, freeb, allocb;

TYPE

     	packedSlot =		ARRAY [1..102] OF CHAR;
			(* a packed on-disk slot structure *)
	jBlock = RECORD
		jbufs:		ARRAY [0..SLOTSPERBLOCK-1] OF packedSlot;
		filler:		ARRAY [0..SLOTBLKFILLSZ-1] OF CHAR;
	END;		(* This must be exactly BLOCKSIZE (512) bytes long *)

	extentDescriptor = cardinal16;




PROCEDURE findx(
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	upd:		Btype
):			ADDRESS;


PROCEDURE readx (
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	VAR buf:	(*UNIV*) jBlock
);



PROCEDURE writex(
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	buf:		(*UNIV*) jBlock
);


PROCEDURE findj(
	ex:		extentDescriptor;
	jn:		slotNumber;
	upd:		Btype
):			ADDRESS;


PROCEDURE readj(
	ex:		extentDescriptor;
	jn:		slotNumber;
	slotP:		ADDRESS
);


PROCEDURE writej(
	ex:		extentDescriptor;
	jn:		slotNumber;
	slotP:		ADDRESS
);


PROCEDURE setmap(
	ex:		extentDescriptor;
	mapn:		mapNumber
);


PROCEDURE openx (
	VAR ex:		extentDescriptor;
	devn:		ARRAY OF CHAR;
	extn:		(*UNIV*) cardinal16;
	mode:		(*integer16*) BITSET
):			BOOLEAN;


PROCEDURE closex(
	ex:		extentDescriptor
);



PROCEDURE flushx(
	ex:		extentDescriptor
);



PROCEDURE findb(
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	upd:		Btype
):			ADDRESS;



PROCEDURE readb (
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	VAR buf:	(*UNIV*) jBlock
);



PROCEDURE writeb(
	ex:		extentDescriptor;
	bno:		mBlockNumber;
	buf:		ADDRESS
);



PROCEDURE decomposeBlockNumber(
	n:		mBlockNumber;
	VAR aslot:	mapNumber;	(* which bit map *)
	VAR w:		cardinal16;	(* which word in bit map *)
	VAR b:		cardinal16	(* which bit in word *)
);


PROCEDURE freeb(
	ex:		extentDescriptor;
	block:		mBlockNumber
);



PROCEDURE allocb(
	ex:		extentDescriptor;
	VAR block:	mBlockNumber
);


END extio.
