Google
 

Trailing-Edge - PDP-10 Archives - BB-P363B-SM_1985 - mcb/cex/cexbuf.lst
There are no other files named cexbuf.lst in the archive.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20
CEXBUF.M11    29-DEC-82 15:48		TABLE OF CONTENTS

  2647		DECLARATIONS
  2698		$BLKGT - Get Block of Core
  2750		$CCBCN - Cancel request for CCB
  2790		$CCBGT - Allocate a CCB from the free pool
  2838		$CCBRQ - Request the next freed CCB
  2878		$CCBRT - Return a CCB to the free pool
  2930		$CBBGT - Allocate CCB/COR from the free pool
  2998		$CBBRT - Return a CCB/buffer to the free pool
  3082		$CORGT - Allocate a COR buffer from the free pool
  3151		$CORRT - Return a COR block to the free pool
  3231		$DSRGT - Allocate Memory from the RSX DSR
  3287		$DSRRT - Return Memory to the RSX DSR
  3350		$RDBCN - Cancel request for RDB
  3390		$RDBGT - Allocate a RDB from the free pool
  3447		$RDBRQ - Request the next freed RDB
  3487		$RDBRT - Return a RDB to the free pool
  3554		CCBCN - Cancel request for a CCB/buffer
  3601		CCBGT - Get a CCB/buffer
  3669		CCBRQ - Request the next freed CCB/buffer
  3726		CCBRT - Return CCB/buffer to Pool or Needy Process
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 1
CEXBUF.M11    29-DEC-82 15:48

     1						.TITLE	CEXBUF - COMM/EXEC BUFFER MANAGEMENT
     2						.IDENT	/003180/
     3						.ENABL	LC
     4
     5					;
     6					;                    COPYRIGHT (c) 1980, 1981, 1982
     7					;                    DIGITAL EQUIPMENT CORPORATION
     8					;                        Maynard, Massachusetts
     9					;
    10					;     This software is furnished under a license and may  be  used
    11					;     and copied only in accordance with the terms of such license
    12					;     and with the inclusion of the above copyright notice.   This
    13					;     software  or any other copies thereof may not be provided or
    14					;     otherwise made available to any other person.  No  title  to
    15					;     and ownership of the software is hereby transferred.
    16					;
    17					;     The information  in  this  software  is  subject  to  change
    18					;     without  notice  and should not be construed as a commitment
    19					;     by DIGITAL EQUIPMENT CORPORATION.
    20					;
    21					;     DIGITAL assumes no responsibility for the use or reliability
    22					;     of  its  software  on  equipment  which  is  not supplied by
    23					;     DIGITAL.
    24					;
    25
    26					;++
    27					; FACILITY: MCB Communications Executive
    28					;
    29					; FUNCTIONAL ABSTRACT:
    30					;
    31					;	This module contains the routines which manage the MCB
    32					;	Comm/Exec buffer pools. These include CCBs, SDBs, LDBs,
    33					;	and RDBs.
    34					;
    35					; ENVIRONMENT: RSX kernel mode with EIS
    36					;
    37					; AUTHOR: Alan D. Peckham, CREATION DATE: 21-FEB-80
    38					;
    39					; MODIFIED BY:
    40					;
    41					;	Alan D. Peckham, 2-Jul-80: VERSION 3.0
    42					; 01	- Change CRSH$ references to CRSH$S.
    43					; 02	- Globalize references to I/O page.
    44					; 03	- Moved global data to seperate module.
    45					;	  Eliminated local data (module can now be made read-only).
    46					; 04	- Must map buffer in $SDBRT before clearing link word.
    47					; 05	- Add support for "CCB allocated" flag.
    48					;	- Support SDB header, owner checking, and "SDB allocated" flag.
    49					; 06	- Catch RDB being returned as CCB and vice-versa.
    50					;	  Update CRSH$S context.
    51					; 08	- Eliminate CE$CBL and CE$RBL checks.
    52					; 09	- Detect out-of-range CCB, RDB, and SDB addresses.
    53					;	Alan D. Peckham, 11-Dec-80: VERSION 3.1
    54					; 10	- Add $DSRGT and $DSRRT routines for DSR checking.
    55					; 11	- Add DSR checking crashes.
    56					; 12	- Add CCB recovery support.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 1-1
CEXBUF.M11    29-DEC-82 15:48

    57					;	Alan D. Peckham, 30-Jan-80: VERSION 3.2
    58					; 13	- Support new C.SRC and C.DST in BUFDS.
    59					;	  Use .CRPDB where current process descriptor block is useful.
    60					;	  Alter process descriptor scan in BUFDS to use
    61					;	  process descriptor vector.
    62					; 14	- Combine CCB/RDB service routines
    63					; 15	- Correct flag handling bug in CCBRQ.
    64					; 16	- Correct crash stack context in $CBBRT, $CORRT, and $DSRRT.
    65					; 17	- Add $BLKGT which allocated 32 word blocks of mapped core.
    66					; 18	- Correct $CORRT to adjust R0 when D$$BUG is turned off.
    67					;	  Remove D$$BUG conditionals from CF.USE and CF.ACT maintenance.
    68					;--
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 2
CEXBUF.M11    29-DEC-82 15:48		DECLARATIONS

    70						.SBTTL	DECLARATIONS
    71
    72					;
    73					; INCLUDE FILES:
    74					;
    75
    76						.MCALL	CRSH$S
    77
    78					;
    79					; MACROS:
    80					;
    81
    82						.MACRO	CORCK$ adr,?l1
    83						.IF	NE,D$$BUG
    84						PUSH$S	adr		; Range check
    85						SUB	#140000,(SP)	; virtual address
    86						CMP	#20000,(SP)+
    87						BHI	l1
    88						CRSH$S	BFR		; Invalid address for buffer.
    89					l1:
    90						.ENDC
    91						.ENDM	CORCK$
    92
    93						.MACRO	DSRCK$ adr,?l1,?l2
    94						.IF	NE,D$$BUG
    95						CMP	#$POOL,adr
    96						BHI	l1
    97						CMP	$EXSIZ,adr
    98						BHI	l2
    99					l1:	CRSH$S	DSR		; DSR address invalid
   100					l2:
   101						.ENDC
   102						.ENDM	DSRCK$
   103
   104					;
   105					; EQUATED SYMBOLS:
   106					;
   107					;	None
   108					;
   109					; OWN STORAGE:
   110					;
   111
   112						.GLOBL	.CCBTB		; Address of CCB pool table
   113						.GLOBL	.RDBTB		; Address of RDB pool table
   114
   115						.GLOBL	.CORTA
   116						.GLOBL	.CORNM
   117					;
   118					; VALIDATION DECLARATIONS:
   119					;
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 3
CEXBUF.M11    29-DEC-82 15:48		$BLKGT - GET BLOCK OF CORE

   121						.SBTTL	$BLKGT - Get Block of Core
   122					;++
   123					; FUNCTIONAL DESCRIPTION:
   124					;
   125					;	Allocate a core block from the pool.
   126					;
   127					;	NOTE: At present, only one block is assumed to be in the pool.
   128					;
   129					; CALLING SEQUENCE:
   130					;
   131					;	CALL	$BLKGT
   132					;
   133					; INPUT PARAMETERS:
   134					;
   135					;	R1 = number of 32. word blocks to allocate.
   136					;
   137					; IMPLICIT INPUTS:
   138					;
   139					;	.BLKTB = Address of free core.
   140					;
   141					; OUTPUT PARAMETERS:
   142					;
   143					;	KISAR6 = mapped to allocated block.
   144					;
   145					; IMPLICIT OUTPUTS:
   146					;
   147					;	None
   148					;
   149					; COMPLETION CODES:
   150					;
   151					;	None
   152					;
   153					; SIDE EFFECTS:
   154					;
   155					;	None
   156					;--
   157
   158		000000'				.PSECT	$CODE$,I,RO
   159	000000'				$BLKGT::PLVL$			; Crash if not process level.
   160	000000'					MAP$	.BLKTB		; If there is a pool,
   161	000006'	001415				BEQ	80$		; then
   162	000010'	160137	140002			SUB	R1,@#140002	; allocate our block
   163	000014'	100410				BMI	70$		; if enough room.
   164	000016'	001404				BEQ	20$
   165	000020'	063737	140002	000000G		ADD	@#140002,@#KISAR6 ; Map to allocated block.
   166	000026'	000207				RETURN
   167	000030'	005067	000000G		20$:	CLR	.BLKTB		; Pool is exhausted.
   168	000034'	000207				RETURN
   169	000036'	060137	140002		70$:	ADD	R1,@#140002	; (not enough room)
   170	000042'	000261			80$:	SEC
   171	000044'	000207				RETURN
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 4
CEXBUF.M11    29-DEC-82 15:48		$CCBCN - CANCEL REQUEST FOR CCB

   173						.SBTTL	$CCBCN - Cancel request for CCB
   174					;++
   175					; FUNCTIONAL DESCRIPTION:
   176					;
   177					;	Disable the CCB request flag for the current data base.
   178					;
   179					; CALLING SEQUENCE:
   180					;
   181					;	CALL	$CCBCN
   182					;
   183					; INPUT PARAMETERS:
   184					;
   185					;	None
   186					;
   187					; IMPLICIT INPUTS:
   188					;
   189					;	.CCBTB = Address of CCB pool.
   190					;
   191					; OUTPUT PARAMETERS:
   192					;
   193					;	None
   194					;
   195					; IMPLICIT OUTPUTS:
   196					;
   197					;	None
   198					;
   199					; COMPLETION CODES:
   200					;
   201					;	None
   202					;
   203					; SIDE EFFECTS:
   204					;
   205					;	Routine CCBCN is called.
   206					;--
   207
   208		000046'				.PSECT	$CODE$,I,RO
   209	000046'				$CCBCN::PLVL$			; Crash if not process level.
   210	000046'	004267	000360			JSR	R2,CCBCN
   211	000052'	000000G				.CCBTB
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 5
CEXBUF.M11    29-DEC-82 15:48		$CCBGT - ALLOCATE A CCB FROM THE FREE POOL

   213						.SBTTL	$CCBGT - Allocate a CCB from the free pool
   214					;++
   215					; FUNCTIONAL DESCRIPTION:
   216					;
   217					;	Allocate a CCB for the current process.
   218					;
   219					; CALLING SEQUENCE:
   220					;
   221					;	CALL	$CCBGT
   222					;
   223					; INPUT PARAMETERS:
   224					;
   225					;	None
   226					;
   227					; IMPLICIT INPUTS:
   228					;
   229					;	.CCBTB = Address of CCB pool.
   230					;
   231					; OUTPUT PARAMETERS:
   232					;
   233					;	If success:
   234					;	    R4 = address of CCB containing:
   235					;		C.LNK	<zero>
   236					;		C.CHN	<zero>
   237					;		C.STK	<zero>
   238					;		C.OWN	<calling process' PIX>
   239					;	If failure:
   240					;	    R4 = undefined.
   241					;
   242					; IMPLICIT OUTPUTS:
   243					;
   244					;	None
   245					;
   246					; CONDITION CODES:
   247					;
   248					;	C-bit set = Allocation failed.
   249					;	C-bit clear = CCB allocated.
   250					;
   251					; SIDE EFFECTS:
   252					;
   253					;	Routine CCBGT is called.
   254					;--
   255
   256		000054'				.PSECT	$CODE$,I,RO
   257	000054'				$CCBGT::PLVL$			; Crash if not process level.
   258	000054'	004267	000412			JSR	R2,CCBGT	; Get a CCB
   259	000060'	000000G				.WORD	.CCBTB		; from the CCB pool.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 6
CEXBUF.M11    29-DEC-82 15:48		$CCBRQ - REQUEST THE NEXT FREED CCB

   261						.SBTTL	$CCBRQ - Request the next freed CCB
   262					;++
   263					; FUNCTIONAL DESCRIPTION:
   264					;
   265					;	Enable the CCB request flag for the current process.
   266					;
   267					; CALLING SEQUENCE:
   268					;
   269					;	CALL	$CCBRQ
   270					;
   271					; INPUT PARAMETERS:
   272					;
   273					;	None
   274					;
   275					; IMPLICIT INPUTS:
   276					;
   277					;	None
   278					;
   279					; OUTPUT PARAMETERS:
   280					;
   281					;	None
   282					;
   283					; IMPLICIT OUTPUTS:
   284					;
   285					;	None
   286					;
   287					; COMPLETION CODES:
   288					;
   289					;	None
   290					;
   291					; SIDE EFFECTS:
   292					;
   293					;	Routine CCBRQ is called.
   294					;--
   295
   296		000062'				.PSECT	$CODE$,I,RO
   297	000062'				$CCBRQ::PLVL$			; Crash if not process level.
   298	000062'	004267	000476			JSR	R2,CCBRQ
   299	000066'	000000G				.CCBTB
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 7
CEXBUF.M11    29-DEC-82 15:48		$CCBRT - RETURN A CCB TO THE FREE POOL

   301						.SBTTL	$CCBRT - Return a CCB to the free pool
   302					;++
   303					; FUNCTIONAL DESCRIPTION:
   304					;
   305					;	Return a CCB to the free CCB pool.
   306					;
   307					; CALLING SEQUENCE:
   308					;
   309					;	CALL	$CCBRT
   310					;
   311					; INPUT PARAMETERS:
   312					;
   313					;	R4 = CCB to return to pool.
   314					;
   315					; IMPLICIT INPUTS:
   316					;
   317					;	None
   318					;
   319					; OUTPUT PARAMETERS:
   320					;
   321					;	None
   322					;
   323					; IMPLICIT OUTPUTS:
   324					;
   325					;	.CCBTB = Address of CCB pool.
   326					;
   327					; CONDITION CODES:
   328					;
   329					;	None
   330					;
   331					; SIDE EFFECTS:
   332					;
   333					;	Routine CCBRT is called.
   334					;	Register R4 is not preserved.
   335					;--
   336
   337		000070'				.PSECT	$CODE$,I,RO
   338	000070'				$CCBRT::PLVL$			; Crash if not process level.
   339	000070'					CCBCK$			; Verify CCB address.
   340
   341		   001				.IF	NE,D$$BUG
   342						BIT	#CF.RDB,C.FLG(R4) ; If an RDB
   343						BNE	100$		; then don't allow this to happen.
   344						.IFTF
   345
   346	000070'	004267	000530			JSR	R2,CCBRT	; Return this
   347	000074'	000000G				.WORD	.CCBTB		; the CCB pool.
   348
   349						.IFT
   350					100$:	CRSH$S	CBB		; RDB being returned as CCB
   351		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 8
CEXBUF.M11    29-DEC-82 15:48		$CBBGT - ALLOCATE CCB/COR FROM THE FREE POOL

   353						.SBTTL	$CBBGT - Allocate CCB/COR from the free pool
   354					;++
   355					; FUNCTIONAL DESCRIPTION:
   356					;
   357					;	Allocate a CCB and COR for the current process.
   358					;
   359					;	If a CCB can be allocated (by calling $CCBGT), then
   360					;	an attempt to obtain the required buffer is made (by calling
   361					;	$CORGT).  If a buffer is not available, then the CCB is
   362					;	returned,  otherwise the buffer bias/address is set in
   363					;	the buffer descriptor of the CCB.
   364					;
   365					; CALLING SEQUENCE:
   366					;
   367					;	CALL	$CBBGT
   368					;
   369					; INPUT PARAMETERS:
   370					;
   371					;	R1 = length of required buffer.
   372					;
   373					; IMPLICIT INPUTS:
   374					;
   375					;	None
   376					;
   377					; OUTPUT PARAMETERS:
   378					;
   379					;	If success:
   380					;	    R4 = address of CCB containing:
   381					;		C.LNK	<zero>
   382					;		C.CHN	<zero>
   383					;		C.STK	<zero>
   384					;		C.OWN	<calling process' PIX>
   385					;		C.BUF	<descriptor of allocated buffer>
   386					;	If failure:
   387					;	    R4 = undefined.
   388					;
   389					; IMPLICIT OUTPUTS:
   390					;
   391					;	If success:
   392					;	    KISAR6 = mapped to allocated buffer.
   393					;	If failure:
   394					;	    KISAR6 = undefined.
   395					;
   396					; CONDITION CODES:
   397					;
   398					;	C-bit set = Allocation of either CCB or buffer failed.
   399					;	C-bit clear = Allocation succeeded.
   400					;
   401					; SIDE EFFECTS:
   402					;
   403					;	Routines $CCBGT and $CORGT are called.
   404					;--
   405
   406		000076'				.PSECT	$CODE$,I,RO
   407	000076'				$CBBGT::PLVL$			; Crash if not process level.
   408	000076'	004767	177752			CALL	$CCBGT		; If we can get a CCB
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 8-1
CEXBUF.M11    29-DEC-82 15:48		$CBBGT - ALLOCATE CCB/COR FROM THE FREE POOL

   409	000102'	103416				BCS	80$		; then
   410	000104'					PUSH$S	R0		; save register used by $CORGT.
   411	000106'	004767	000056			CALL	$CORGT		; Try for a buffer
   412	000112'	103004				BCC	10$		; and if no-go
   413	000114'	004767	177750			CALL	$CCBRT		; then return the CCB
   414	000120'	000261				SEC			; and return
   415	000122'	000405				BR	20$		; in shame.
   416	000124'				10$:	SMAP$	C.BUF+0(R4)	; Set the buffer mapping bias
   417	000132'	010064	000020			MOV	R0,C.BUF+2(R4)	; and the virtual address.
   418	000136'				20$:	POP$S	R0		; Restore user registers
   419	000140'	000207			80$:	RETURN			; and return.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 9
CEXBUF.M11    29-DEC-82 15:48		$CBBRT - RETURN A CCB/BUFFER TO THE FREE POOL

   421						.SBTTL	$CBBRT - Return a CCB/buffer to the free pool
   422					;++
   423					; FUNCTIONAL DESCRIPTION:
   424					;
   425					;	Return a CCB and attached buffer to their related
   426					;	pools.
   427					;
   428					;	Simple!  Return the buffer (by calling $CORRT),  and
   429					;	return the CCB (by calling $CCBRT).
   430					;
   431					; CALLING SEQUENCE:
   432					;
   433					;	CALL	$CBBRT
   434					;
   435					; INPUT PARAMETERS:
   436					;
   437					;	R4 = Address of CCB containing:
   438					;	    C.BUF	<descriptor of buffer to return>
   439					;
   440					; IMPLICIT INPUTS:
   441					;
   442					;	None
   443					;
   444					; OUTPUT PARAMETERS:
   445					;
   446					;	None
   447					;
   448					; IMPLICIT OUTPUTS:
   449					;
   450					;	None
   451					;
   452					; COMPLETION CODES:
   453					;
   454					;	None
   455					;
   456					; SIDE EFFECTS:
   457					;
   458					;	Routines $CCBRT and $CORRT are called.
   459					;
   460					;	Registers R4 and KISAR6 are not preserved.
   461					;--
   462
   463		000142'				.PSECT	$CODE$,I,RO
   464	000142'				$CBBRT::PLVL$			; Crash if not process level.
   465	000142'					CCBCK$			; Verify CCB address.
   466	000142'					CORCK$	C.BUF+2(R4)
   467
   468		   001				.IF	NE,D$$BUG
   469						BIT	#CF.ACT,C.FLG(R4) ; If not allocated
   470						BEQ	92$		; then this is not his.
   471						BIT	#CF.RDB,C.FLG(R4) ; If an RDB
   472						BNE	93$		; then don't allow this to happen.
   473						CMPB	.CRPIX,C.OWN(R4) ; If returning process not owner
   474						BNE	90$		; then quit while we're ahead.
   475						.IFTF
   476
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 9-1
CEXBUF.M11    29-DEC-82 15:48		$CBBRT - RETURN A CCB/BUFFER TO THE FREE POOL

   477	000142'					PUSH$S	R0		; Save user's register so that we may
   478	000144'					MAP$	C.BUF+0(R4)	; get the buffer bias
   479	000152'	016400	000020			MOV	C.BUF+2(R4),R0	; and virtual address
   480
   481						.IFT
   482						CMP	.CRPDB,-(R0)	; If returning process not owner
   483						BNE	94$		; then quit while we're ahead.
   484						TST	-(R0)		; If not allocated
   485						BEQ	95$		; then this is not his.
   486						CMP	R1,(R0)		; If length incorrect
   487						BNE	91$		; then complain.
   488						CMP	(R0)+,(R0)+	; Reset CORe address.
   489						.IFTF
   490
   491	000156'	004767	000104			CALL	$CORRT		; to return it.
   492	000162'					POP$S	R0		; Restore user register
   493	000164'	000167	177700			JMP	$CCBRT		; and release the CCB.
   494
   495						.IFT
   496					93$:	CRSH$S	CBB		; RDB being returned as CCB
   497					95$:	POP$S	R0		; Restore user register
   498					92$:	CRSH$S	FRE		; Free buffer being returned
   499					91$:	POP$S	R0		; Restore user register
   500						CRSH$S	LEN		; Buffer length is invalid
   501					94$:	POP$S	R0		; Restore user register
   502					90$:	CRSH$S	OWN		; Buffer not being returned by owner
   503		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 10
CEXBUF.M11    29-DEC-82 15:48		$CORGT - ALLOCATE A COR BUFFER FROM THE FREE POOL

   505						.SBTTL	$CORGT - Allocate a COR buffer from the free pool
   506					;++
   507					; FUNCTIONAL DESCRIPTION:
   508					;
   509					;	Allocate a COR block from one of the pre-allocated pools.
   510					;
   511					; CALLING SEQUENCE:
   512					;
   513					;	CALL	$CORGT
   514					;
   515					; INPUT PARAMETERS:
   516					;
   517					;	R1 = length of block to allocate.
   518					;
   519					; IMPLICIT INPUTS:
   520					;
   521					;	None
   522					;
   523					; OUTPUT PARAMETERS:
   524					;
   525					;	If success:
   526					;	    R0 = virtual address of buffer.
   527					;	If failure:
   528					;	    R0 = undefined.
   529					;
   530					; IMPLICIT OUTPUTS:
   531					;
   532					;	If success:
   533					;	    KISAR6 = mapped to buffer.
   534					;	If failure:
   535					;	    KISAR6 = undefined.
   536					;
   537					; COMPLETION CODES:
   538					;
   539					;	C-bit set = Allocation failed.
   540					;	C-bit clear = Buffer allocated.
   541					;
   542					; SIDE EFFECTS:
   543					;
   544					;	None
   545					;--
   546
   547		000170'				.PSECT	$CODE$,I,RO
   548	000170'				$CORGT::PLVL$			; Crash if not process level.
   549	000170'					PUSH$S	R2
   550	000172'	016702	000000G			MOV	.CORTA,R2
   551	000176'	001003				BNE	20$
   552	000200'	000430				BR	60$
   553	000202'	062702	000022		10$:	ADD	#P.BLEN-2,R2
   554	000206'	022201			20$:	CMP	(R2)+,R1
   555	000210'	103774				BLO	10$
   556	000212'	005322				DEC	(R2)+
   557	000214'	100417				BMI	50$
   558	000216'					MAP$	(R2)+
   559	000222'	011200				MOV	(R2),R0
   560	000224'	012042				MOV	(R0)+,-(R2)
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 10-1
CEXBUF.M11    29-DEC-82 15:48		$CORGT - ALLOCATE A COR BUFFER FROM THE FREE POOL

   561	000226'	012062	000002			MOV	(R0)+,2(R2)
   562	000232'	001002				BNE	30$
   563	000234'	010262	000006			MOV	R2,6(R2)
   564	000240'	010120			30$:	MOV	R1,(R0)+
   565	000242'	016720	000000G			MOV	.CRPDB,(R0)+
   566	000246'	000241				CLC
   567	000250'				40$:	POP$S	R2
   568	000252'	000207				RETURN
   569	000254'	005242			50$:	INC	-(R2)
   570	000256'	005262	000012			INC	P.BALF-2(R2)
   571	000262'	000261			60$:	SEC
   572	000264'	000771				BR	40$
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 11
CEXBUF.M11    29-DEC-82 15:48		$CORRT - RETURN A COR BLOCK TO THE FREE POOL

   574						.SBTTL	$CORRT - Return a COR block to the free pool
   575					;++
   576					; FUNCTIONAL DESCRIPTION:
   577					;
   578					;	Return a COR block to the free pool.
   579					;
   580					; CALLING SEQUENCE:
   581					;
   582					;	CALL	$CORRT
   583					;
   584					; INPUT PARAMETERS:
   585					;
   586					;	R0 = buffer virtual address.
   587					;
   588					; IMPLICIT INPUTS:
   589					;
   590					;	KISAR6 = buffer bias.
   591					;
   592					; OUTPUT PARAMETERS:
   593					;
   594					;	None
   595					;
   596					; IMPLICIT OUTPUTS:
   597					;
   598					;	None
   599					;
   600					; COMPLETION CODES:
   601					;
   602					;	None
   603					;
   604					; SIDE EFFECTS:
   605					;
   606					;	Registers R2 and KISAR6 are not preserved.
   607					;--
   608
   609		000266'				.PSECT	$CODE$,I,RO
   610	000266'				$CORRT::PLVL$			; Crash if not process level.
   611	000266'					CORCK$	R0
   612
   613		   001				.IF	NE,D$$BUG
   614						CMP	.CRPDB,-(R0)	; If returning process not owner
   615						BNE	90$		; then quit while we're ahead.
   616						TST	-(R0)		; If not allocated
   617						BEQ	91$		; then this is not his.
   618						CMP	R1,(R0)		; If length incorrect
   619						BNE	93$		; then complain.
   620						CLR	(R0)		; 
   621						.IFF
   622	000266'	024040				CMP	-(R0),-(R0)
   623						.IFTF
   624
   625	000270'					PUSH$S	R2
   626	000272'	016702	000000G			MOV	.CORTA,R2
   627	000276'	000402				BR	20$
   628	000300'	062702	000022		10$:	ADD	#P.BLEN-2,R2
   629	000304'	022201			20$:	CMP	(R2)+,R1
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 11-1
CEXBUF.M11    29-DEC-82 15:48		$CORRT - RETURN A COR BLOCK TO THE FREE POOL

   630	000306'	103774				BLO	10$
   631	000310'	005222				INC	(R2)+
   632	000312'	005040				CLR	-(R0)
   633	000314'	005040				CLR	-(R0)
   634	000316'					PUSH$S	R0
   635	000320'					SMAP$S
   636	000324'					MAP$	4(R2)
   637	000332'	016200	000006			MOV	6(R2),R0
   638	000336'	011620				MOV	(SP),(R0)+
   639	000340'					POP$S	4(R2)
   640	000344'	011610				MOV	(SP),(R0)
   641	000346'					POP$S	6(R2)
   642	000352'					POP$S	R2
   643	000354'	000207				RETURN
   644
   645						.IFT
   646					90$:	TST	(R0)+		; Reset user register
   647						CRSH$S	OWN		; Buffer not being returned by owner.
   648					91$:	CMP	(R0)+,(R0)+	; Reset user register
   649						CRSH$S	FRE		; Free buffer being returned.
   650					93$:	CMP	(R0)+,(R0)+	; Reset user register
   651						CRSH$S	LEN		; Buffer length is invalid.
   652		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 12
CEXBUF.M11    29-DEC-82 15:48		$DSRGT - ALLOCATE MEMORY FROM THE RSX DSR

   654						.SBTTL	$DSRGT - Allocate Memory from the RSX DSR
   655					;++
   656					; FUNCTIONAL DESCRIPTION:
   657					;
   658					;	Get DSR memory for requesting process.
   659					;
   660					; CALLING SEQUENCE:
   661					;
   662					;	CALL	$DSRGT
   663					;
   664					; INPUT PARAMETERS:
   665					;
   666					;	R1 = Size of memory to get in bytes.
   667					;
   668					; IMPLICIT INPUTS:
   669					;
   670					;	None
   671					;
   672					; OUTPUT PARAMETERS:
   673					;
   674					;	If success:
   675					;	    R0 = address of allocated memory.
   676					;	If failure:
   677					;	    R0 is undefined.
   678					;
   679					; IMPLICIT OUTPUTS:
   680					;
   681					;	None
   682					;
   683					; COMPLETION CODES:
   684					;
   685					;	C-bit set = Allocation failed.
   686					;	C-bit clear = DSR allocated.
   687					;
   688					; SIDE EFFECTS:
   689					;
   690					;	Routine $ALOCB is called.
   691					;--
   692
   693		000356'				.PSECT	$CODE$,I,RO
   694	000356'				$DSRGT::SAV2$S
   695
   696		   001				.IF	NE,D$$BUG
   697						PUSH$S	R1
   698						ADD	#4,R1
   699						.IFTF
   700
   701	000362'	004767	000000G			CALL	$ALOCB		; Just go to it for now.
   702
   703						.IFT
   704						POP$S	(R0)+
   705						MOV	.CRPDB,(R0)+
   706		   000				.ENDC
   707
   708	000366'	000207				RETURN
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 13
CEXBUF.M11    29-DEC-82 15:48		$DSRRT - RETURN MEMORY TO THE RSX DSR

   710						.SBTTL	$DSRRT - Return Memory to the RSX DSR
   711					;++
   712					; FUNCTIONAL DESCRIPTION:
   713					;
   714					;	Return DSR memory from process.
   715					;
   716					; CALLING SEQUENCE:
   717					;
   718					;	CALL	$DSRRT
   719					;
   720					; INPUT PARAMETERS:
   721					;
   722					;	R0 = address of memory to be returned.
   723					;	R1 = Size of memory to return in bytes.
   724					;
   725					; IMPLICIT INPUTS:
   726					;
   727					;	None
   728					;
   729					; OUTPUT PARAMETERS:
   730					;
   731					;	None
   732					;
   733					; IMPLICIT OUTPUTS:
   734					;
   735					;	None
   736					;
   737					; COMPLETION CODES:
   738					;
   739					;	None
   740					;
   741					; SIDE EFFECTS:
   742					;
   743					;	Routine $DEACB is called.
   744					;--
   745
   746		000370'				.PSECT	$CODE$,I,RO
   747	000370'				$DSRRT::DSRCK$	R0
   748
   749		   001				.IF	NE,D$$BUG
   750						CMP	.CRPDB,-(R0)
   751						BNE	101$
   752						CMP	R1,-(R0)
   753						BNE	100$
   754						CLR	(R0)
   755						.IFTF
   756
   757	000370'					SAV3$S
   758
   759						.IFT
   760						ADD	#4,R1
   761						.IFTF
   762
   763	000374'	004767	000000G			CALL	$DEACB		; Just go to it for now.
   764	000400'	000207				RETURN
   765
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 13-1
CEXBUF.M11    29-DEC-82 15:48		$DSRRT - RETURN MEMORY TO THE RSX DSR

   766						.IFT
   767					100$:	CMP	(R0)+,(R0)+
   768						CRSH$S	LEN		; DSR length incorrect.
   769					101$:	TST	(R0)+
   770						CRSH$S	OWN		; DSR being returned by foreigner
   771		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 14
CEXBUF.M11    29-DEC-82 15:48		$RDBCN - CANCEL REQUEST FOR RDB

   773						.SBTTL	$RDBCN - Cancel request for RDB
   774					;++
   775					; FUNCTIONAL DESCRIPTION:
   776					;
   777					;	Disable the RDB request flag for the current data base.
   778					;
   779					; CALLING SEQUENCE:
   780					;
   781					;	CALL	$RDBCN
   782					;
   783					; INPUT PARAMETERS:
   784					;
   785					;	None
   786					;
   787					; IMPLICIT INPUTS:
   788					;
   789					;	.CRPIX = data base index.
   790					;
   791					; OUTPUT PARAMETERS:
   792					;
   793					;	None
   794					;
   795					; IMPLICIT OUTPUTS:
   796					;
   797					;	None
   798					;
   799					; COMPLETION CODES:
   800					;
   801					;	None
   802					;
   803					; SIDE EFFECTS:
   804					;
   805					;	None
   806					;--
   807
   808		000402'				.PSECT	$CODE$,I,RO
   809	000402'				$RDBCN::PLVL$			; Crash if not process level.
   810	000402'	004267	000024			JSR	R2,CCBCN
   811	000406'	000000G				.RDBTB
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 15
CEXBUF.M11    29-DEC-82 15:48		$RDBGT - ALLOCATE A RDB FROM THE FREE POOL

   813						.SBTTL	$RDBGT - Allocate a RDB from the free pool
   814					;++
   815					; FUNCTIONAL DESCRIPTION:
   816					;
   817					;	Allocate a RDB for the current process.
   818					;
   819					;	If a RDB is available,  it  is  allocated,  and  the
   820					;	count of RDBs in the pool is decremented.  Otherwise
   821					;	the RDB allocation failure count is incremented.
   822					;
   823					; CALLING SEQUENCE:
   824					;
   825					;	CALL	$RDBGT
   826					;
   827					; INPUT PARAMETERS:
   828					;
   829					;	None
   830					;
   831					; IMPLICIT INPUTS:
   832					;
   833					;	.RDB*H = Free RDB list header.
   834					;	.CRPIX = process index of the current process.
   835					;
   836					; OUTPUT PARAMETERS:
   837					;
   838					;	If success:
   839					;	    R4 = address of CCB containing:
   840					;		C.LNK	<zero>
   841					;		C.CHN	<zero>
   842					;		C.STK	<zero>
   843					;		C.OWN	<calling process' PIX>
   844					;		C.BUF	<descriptor of RDB>
   845					;	If failure:
   846					;	    R4 = undefined.
   847					;
   848					; IMPLICIT OUTPUTS:
   849					;
   850					;	If success:
   851					;	    .RDBCT = count of RDBs in pool.
   852					;	If failure:
   853					;	    .RDBAF = number of RDB allocation failures.
   854					;
   855					; COMPLETION CODES:
   856					;
   857					;	C-bit set = Allocation failed.
   858					;	C-bit clear = RDB allocated.
   859					;
   860					; SIDE EFFECTS:
   861					;
   862					;	None
   863					;--
   864
   865		000410'				.PSECT	$CODE$,I,RO
   866	000410'				$RDBGT::PLVL$			; Crash if not process level.
   867	000410'	004267	000056			JSR	R2,CCBGT	; Get a RDB
   868	000414'	000000G				.WORD	.RDBTB		; from the RDB pool.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 16
CEXBUF.M11    29-DEC-82 15:48		$RDBRQ - REQUEST THE NEXT FREED RDB

   870						.SBTTL	$RDBRQ - Request the next freed RDB
   871					;++
   872					; FUNCTIONAL DESCRIPTION:
   873					;
   874					;	Enable the RDB request flag for the current data base.
   875					;
   876					; CALLING SEQUENCE:
   877					;
   878					;	CALL	$RDBRQ
   879					;
   880					; INPUT PARAMETERS:
   881					;
   882					;	None
   883					;
   884					; IMPLICIT INPUTS:
   885					;
   886					;	.CRPIX = data base index.
   887					;
   888					; OUTPUT PARAMETERS:
   889					;
   890					;	None
   891					;
   892					; IMPLICIT OUTPUTS:
   893					;
   894					;	None
   895					;
   896					; COMPLETION CODES:
   897					;
   898					;	None
   899					;
   900					; SIDE EFFECTS:
   901					;
   902					;	None
   903					;--
   904
   905		000416'				.PSECT	$CODE$,I,RO
   906	000416'				$RDBRQ::PLVL$			; Crash if not process level.
   907	000416'	004267	000142			JSR	R2,CCBRQ
   908	000422'	000000G				.RDBTB
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 17
CEXBUF.M11    29-DEC-82 15:48		$RDBRT - RETURN A RDB TO THE FREE POOL

   910						.SBTTL	$RDBRT - Return a RDB to the free pool
   911					;++
   912					; FUNCTIONAL DESCRIPTION:
   913					;
   914					;	The RDB is returned to the free pool.
   915					;
   916					;	If the returner of the RDB is not the owner,  a  RBO
   917					;	crash is generated.  If there is more than  one  RDB
   918					;	linked together, a RBL crash is generated. Otherwise
   919					;	count of RDBs in the pool is incremented and the RDB
   920					;	is linked into the pool.
   921					;
   922					; CALLING SEQUENCE:
   923					;
   924					;	CALL	$RDBRT
   925					;
   926					; INPUT PARAMETERS:
   927					;
   928					;	R4 = RDB to return to the pool.
   929					;
   930					; IMPLICIT INPUTS:
   931					;
   932					;	.CRPIX = process index of the current process.
   933					;
   934					; OUTPUT PARAMETERS:
   935					;
   936					;	None
   937					;
   938					; IMPLICIT OUTPUTS:
   939					;
   940					;	.RDB*H = Free RDB list header.
   941					;	.RDBCT = count of RDBs in pool.
   942					;
   943					; COMPLETION CODES:
   944					;
   945					;	None
   946					;
   947					; SIDE EFFECTS:
   948					;
   949					;	None
   950					;--
   951
   952		000424'				.PSECT	$CODE$,I,RO
   953	000424'				$RDBRT::PLVL$			; Crash if not process level.
   954	000424'					CCBCK$			; Verify CCB address.
   955
   956		   001				.IF	NE,D$$BUG
   957						PUSH$S	C.BUF+2(R4)	; Range check
   958						SUB	#140000,(SP)	; virtual address
   959						CMP	#20000,(SP)+
   960						BLOS	101$
   961						BIT	#CF.RDB,C.FLG(R4) ; If an CCB
   962						BEQ	100$		; then don't allow this to happen.
   963						PUSH$S	C.BUF+0(R4)	; and bias.
   964						SUB	.RDBCM+0,(SP)
   965						CMP	.RDBCM+2,(SP)+
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 17-1
CEXBUF.M11    29-DEC-82 15:48		$RDBRT - RETURN A RDB TO THE FREE POOL

   966						BLOS	101$
   967						.IFTF
   968
   969	000424'	004267	000174			JSR	R2,CCBRT	; Return this
   970	000430'	000000G				.WORD	.RDBTB		; the RDB pool.
   971
   972						.IFT
   973					100$:	CRSH$S	RBB		; CCB being returned as RDB
   974					101$:	CRSH$S	RBR		; Invalid bias/address for RDB
   975		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 18
CEXBUF.M11    29-DEC-82 15:48		CCBCN - CANCEL REQUEST FOR A CCB/BUFFER

   977						.SBTTL	CCBCN - Cancel request for a CCB/buffer
   978					;++
   979					; FUNCTIONAL DESCRIPTION:
   980					;
   981					;	This is a common routine to cancel a request for a CCB, RDB or SDB.
   982					;
   983					; CALLING SEQUENCE:
   984					;
   985					;	JSR	R2,CCBCN
   986					;	.WORD	address_of_ccb_pool_block
   987					;
   988					; INPUT PARAMETERS:
   989					;
   990					;	(SP) = return address.
   991					;
   992					; IMPLICIT INPUTS:
   993					;
   994					;	.CRPDB = current process descriptor block.
   995					;
   996					; OUTPUT PARAMETERS:
   997					;
   998					;	None
   999					;
  1000					; IMPLICIT OUTPUTS:
  1001					;
  1002					;	None
  1003					;
  1004					; COMPLETION CODES:
  1005					;
  1006					;	None
  1007					;
  1008					; SIDE EFFECTS:
  1009					;
  1010					;	None
  1011					;--
  1012
  1013		000432'				.PSECT	$CODE$,I,RO
  1014	000432'	011202			CCBCN:	MOV	(R2),R2		; Get CCB pool block
  1015	000434'					PUSH$S	R1
  1016	000436'	016701	000000G			MOV	.CRPDB,R1	; and current process descriptor.
  1017	000442'	036261	000020	000010		BIT	P.CFLG(R2),Z.FLG(R1) ; If flag is up
  1018	000450'	001405				BEQ	80$		; then
  1019	000452'	046261	000020	000010		BIC	P.CFLG(R2),Z.FLG(R1) ; clear the buffer request flag,
  1020	000460'	005362	000014			DEC	P.CREQ(R2)	; another request cancelled,
  1021	000464'				80$:	POP$S	<R1,R2>		; and restore the registers.
  1022	000470'	000207				RETURN
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 19
CEXBUF.M11    29-DEC-82 15:48		CCBGT - GET A CCB/BUFFER

  1024						.SBTTL	CCBGT - Get a CCB/buffer
  1025					;++
  1026					; FUNCTIONAL DESCRIPTION:
  1027					;
  1028					;	This is a common routine to dispatch a CCB to the next needy process.
  1029					;
  1030					; CALLING SEQUENCE:
  1031					;
  1032					;	JSR	R2,CCBGT
  1033					;	.WORD	address_of_ccb_pool_block
  1034					;
  1035					; INPUT PARAMETERS:
  1036					;
  1037					;	(SP) = return address.
  1038					;
  1039					; IMPLICIT INPUTS:
  1040					;
  1041					;	None
  1042					;
  1043					; OUTPUT PARAMETERS:
  1044					;
  1045					;	None
  1046					;
  1047					; IMPLICIT OUTPUTS:
  1048					;
  1049					;	None
  1050					;
  1051					; COMPLETION CODES:
  1052					;
  1053					;	None
  1054					;
  1055					; SIDE EFFECTS:
  1056					;
  1057					;	None
  1058					;--
  1059
  1060		000472'				.PSECT	$CODE$,I,RO
  1061	000472'	011202			CCBGT:	MOV	(R2),R2
  1062	000474'	062702	000006			ADD	#P.CQUE,R2
  1063
  1064		   001				.IF	NE,C$$QUE
  1065	000500'	011204				MOV	(R2),R4		; If there is a CCB available
  1066	000502'	001423				BEQ	80$		; then
  1067	000504'	011412				MOV	(R4),(R2)	; un-link it from the list
  1068	000506'	001002				BNE	10$		; and if now empty
  1069	000510'	010262	000002			MOV	R2,2(R2)	; then reset queue header.
  1070	000514'	005362	000004		10$:	DEC	4(R2)		; This CCB is no longer free.
  1071						.IFF
  1072						MOV	(R2),R4		; If there is a CCB available
  1073						BEQ	80$		; then
  1074						MOV	(R4),(R2)	; un-link it from the stack.
  1075						DEC	(R2)		; This CCB is no longer free.
  1076		   000				.ENDC
  1077
  1078	000520'	052764	003000	000006		BIS	#CF.ACT!CF.USE,C.FLG(R4) ; Indicate allocated.
  1079	000526'	116764	000000G	000006		MOVB	.CRPIX,C.OWN(R4) ; Set owner.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 19-1
CEXBUF.M11    29-DEC-82 15:48		CCBGT - GET A CCB/BUFFER

  1080	000534'	005064	000004			CLR	C.STK(R4)	; Clear stack pointer
  1081	000540'	005064	000002			CLR	C.CHN(R4)	; buffer chain pointer
  1082	000544'	005014				CLR	(R4)		; and link word (C-bit clear).
  1083	000546'				90$:	POP$S	R2
  1084	000550'	000207				RETURN
  1085
  1086	000552'	005242			80$:	INC	-(R2)		; Account for failure
  1087	000554'	001001				BNE	82$		; and if overflow
  1088	000556'	005312				DEC	(R2)		; then back it up.
  1089	000560'	000261			82$:	SEC			; Indicate error.
  1090	000562'	000771				BR	90$
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 20
CEXBUF.M11    29-DEC-82 15:48		CCBRQ - REQUEST THE NEXT FREED CCB/BUFFER

  1092						.SBTTL	CCBRQ - Request the next freed CCB/buffer
  1093					;++
  1094					; FUNCTIONAL DESCRIPTION:
  1095					;
  1096					;	This is a common routine to enable a request for a CCB, RDB or SDB.
  1097					;
  1098					; CALLING SEQUENCE:
  1099					;
  1100					;	JSR	R2,CCBRQ
  1101					;	.WORD	address_of_ccb_pool_block
  1102					;
  1103					; INPUT PARAMETERS:
  1104					;
  1105					;	(SP) = return address.
  1106					;
  1107					; IMPLICIT INPUTS:
  1108					;
  1109					;	.CRPDB = current process descriptor block.
  1110					;
  1111					; OUTPUT PARAMETERS:
  1112					;
  1113					;	None
  1114					;
  1115					; IMPLICIT OUTPUTS:
  1116					;
  1117					;	None
  1118					;
  1119					; COMPLETION CODES:
  1120					;
  1121					;	None
  1122					;
  1123					; SIDE EFFECTS:
  1124					;
  1125					;	None
  1126					;--
  1127
  1128		000564'				.PSECT	$CODE$,I,RO
  1129	000564'	011202			CCBRQ:	MOV	(R2),R2		; Get CCB pool block
  1130
  1131		   001				.IF	NE,D$$BUG
  1132						TST	P.CCNT(R2)	; and if there is a buffer available
  1133						BNE	100$		; then he is mistaken.
  1134						.IFTF
  1135
  1136	000566'					PUSH$S	R1
  1137	000570'	016701	000000G			MOV	.CRPDB,R1	; Get current process descriptor
  1138	000574'	036261	000020	000010		BIT	P.CFLG(R2),Z.FLG(R1) ; and if flag not already up
  1139	000602'	001005				BNE	80$		; then
  1140	000604'	056261	000020	000010		BIS	P.CFLG(R2),Z.FLG(R1) ; set the buffer request flag,
  1141	000612'	005262	000014			INC	P.CREQ(R2)	; count another request,
  1142	000616'				80$:	POP$S	<R1,R2>		; and restore the registers.
  1143	000622'	000207				RETURN
  1144
  1145						.IFT
  1146					100$:	CRSH$S	IBR		; CCB request with pool non-empty
  1147		   000				.ENDC
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 21
CEXBUF.M11    29-DEC-82 15:48		CCBRT - RETURN CCB/BUFFER TO POOL OR NEEDY PROCESS

  1149						.SBTTL	CCBRT - Return CCB/buffer to Pool or Needy Process
  1150					;++
  1151					; FUNCTIONAL DESCRIPTION:
  1152					;
  1153					;	This is a common routine to dispatch a CCB to the next needy process.
  1154					;
  1155					; CALLING SEQUENCE:
  1156					;
  1157					;	JSR	R2,CCBRT
  1158					;	.WORD	address_of_ccb_pool_block
  1159					;
  1160					; INPUT PARAMETERS:
  1161					;
  1162					;	(SP) = return address.
  1163					;
  1164					; IMPLICIT INPUTS:
  1165					;
  1166					;	None
  1167					;
  1168					; OUTPUT PARAMETERS:
  1169					;
  1170					;	None
  1171					;
  1172					; IMPLICIT OUTPUTS:
  1173					;
  1174					;	None
  1175					;
  1176					; COMPLETION CODES:
  1177					;
  1178					;	None
  1179					;
  1180					; SIDE EFFECTS:
  1181					;
  1182					;	None
  1183					;--
  1184
  1185		000624'				.PSECT	$CODE$,I,RO
  1186	000624'	011202			CCBRT:	MOV	(R2),R2
  1187	000626'	062702	000014			ADD	#P.CREQ,R2
  1188
  1189		   001				.IF	NE,D$$BUG
  1190						BIT	#CF.ACT,C.FLG(R4) ; If not allocated
  1191						BEQ	100$		; then this is not his.
  1192						CMPB	.CRPIX,C.OWN(R4) ; If returning process not owner
  1193						BNE	101$		; then quit while we're ahead.
  1194						.IFTF
  1195
  1196	000632'	005712				TST	(R2)		; If CCB requested
  1197	000634'	001011				BNE	20$		; then dispatch to hungry process.
  1198	000636'	042764	001000	000006		BIC	#CF.ACT,C.FLG(R4) ; This is now ours.
  1199	000644'	005242				INC	-(R2)		; This CCB now free.
  1200
  1201		   002				.IF	NE,C$$QUE
  1202	000646'	005014				CLR	(R4)		; Clear the link,
  1203	000650'	010452				MOV	R4,@-(R2)	; set this CCB to last in queue
  1204	000652'	010412				MOV	R4,(R2)		; and new end of queue.
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 21-1
CEXBUF.M11    29-DEC-82 15:48		CCBRT - RETURN CCB/BUFFER TO POOL OR NEEDY PROCESS

  1205						.IFF
  1206						MOV	-(R2),(R4)	; Link top of stack to this CCB
  1207						MOV	R4,(R2)		; and set new top of stack.
  1208		   001				.ENDC
  1209
  1210	000654'					POP$S	R2
  1211	000656'	000207				RETURN
  1212	000660'				20$:	PUSH$S	<R1,R0>		; Get room for
  1213	000664'	005322				DEC	(R2)+
  1214	000666'	012200				MOV	(R2)+,R0	; process descriptor vector pointer.
  1215	000670'	026700	000000G		22$:	CMP	.PDBVE,R0	; If last process descriptor
  1216	000674'	101002				BHI	24$		; then
  1217	000676'	012700	000000G			MOV	#.PDBVB,R0	; reset to start of vector.
  1218	000702'	012001			24$:	MOV	(R0)+,R1	; Go on to next
  1219	000704'	001771				BEQ	22$		; (if there is one)
  1220	000706'	031261	000010			BIT	(R2),Z.FLG(R1)	; and if request flag is up
  1221	000712'	001766				BEQ	22$		; then
  1222	000714'	010062	177776			MOV	R0,-2(R2)	; service this data base.
  1223	000720'	042261	000010			BIC	(R2)+,Z.FLG(R1) ; Request is satisfied.
  1224	000724'	005014				CLR	(R4)		; Clear link word,
  1225	000726'	005064	000004			CLR	C.STK(R4)	; stack pointer,
  1226	000732'	005064	000002			CLR	C.CHN(R4)	; and buffer chain pointer.
  1227	000736'	116164	000010	000006		MOVB	Z.PIX(R1),C.OWN(R4) ; Destination is owner.
  1228	000744'	112264	000012			MOVB	(R2)+,C.FNC(R4) ; Set up dispatch codes.
  1229	000750'	112264	000013			MOVB	(R2)+,C.MOD(R4)
  1230	000754'	005064	000040			CLR	C.SRC(R4)	; We are source,
  1231	000760'	010164	000036			MOV	R1,C.DST(R4)	; destination is this process.
  1232	000764'					POP$S	<R0,R1,R2>
  1233	000772'	000167	000000G			JMP	$CCBQL		; Queue to lower process.
  1234
  1235						.IFT
  1236					100$:	POP$S	R2
  1237						CRSH$S	FRE		; Free CCB being returned
  1238					101$:	POP$S	R2
  1239						CRSH$S	OWN		; CCB not being returned by owner
  1240		   000				.ENDC
  1241
  1242		000001				.END
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 22
CEXBUF.M11    29-DEC-82 15:48		CROSS REFERENCE TABLE -- USER SYMBOLS

CCBCN   000432R    002	  210	  810	 1014#
CCBGT   000472R    002	  258	  867	 1061#
CCBRQ   000564R    002	  298	  907	 1129#
CCBRT   000624R    002	  346	  969	 1186#
CF.ACT= 001000        	 1078	 1198
CF.USE= 002000        	 1078
C$$QUE= 000001        	 1064	 1201
C.BUF   000016        	  416*	  417*	  478	  479
C.CHN   000002        	 1081*	 1226*
C.DST   000036        	 1231*
C.FLG   000006        	 1078*	 1198*
C.FNC   000012        	 1228*
C.MOD   000013        	 1229*
C.OWN   000006        	 1079*	 1227*
C.SRC   000040        	 1230*
C.STK   000004        	 1080*	 1225*
D$$BUG= 000000        	  159	  209	  257	  297	  338	  339	  341	  407	  464	  465	  466	  468	  548
			  610	  611	  613	  696	  747	  749	  809	  866	  906	  953	  954	  956	 1131
			 1189
KISAR6= ****** G      	  160#*	  165*	  416#	  478#*	  558#*	  635#	  636#*
P.BALF  000014        	  570*
P.BLEN  000024        	  553	  628
P.CFLG  000020        	 1017	 1019	 1138	 1140
P.CQUE  000006        	 1062
P.CREQ  000014        	 1020*	 1141*	 1187
S.PARM= 000012        	  694#	  757#
Z.FLG   000010        	 1017	 1019*	 1138	 1140*	 1220	 1223*
Z.PIX   000010        	 1227
$ALOCB= ****** GX     	  701*
$BLKGT  000000RG   002	  159#
$CBBGT  000076RG   002	  407#
$CBBRT  000142RG   002	  464#
$CCBCN  000046RG   002	  209#
$CCBGT  000054RG   002	  257#	  408*
$CCBQL= ****** GX     	 1233
$CCBRQ  000062RG   002	  297#
$CCBRT  000070RG   002	  338#	  413*	  493
$CORGT  000170RG   002	  411*	  548#
$CORRT  000266RG   002	  491*	  610#
$DEACB= ****** GX     	  763*
$DSRGT  000356RG   002	  694#
$DSRRT  000370RG   002	  747#
$RDBCN  000402RG   002	  809#
$RDBGT  000410RG   002	  866#
$RDBRQ  000416RG   002	  906#
$RDBRT  000424RG   002	  953#
$SAVE2= ****** G      	  694#
$SAVE3= ****** G      	  757#
.BLKTB= ****** GX     	  160	  167*
.CCBTB= ****** G      	  112#	  211	  259	  299	  347
.CORNM= ****** G      	  116#
.CORTA= ****** G      	  115#	  550	  626
.CRPDB= ****** GX     	  565	 1016	 1137
.CRPIX= ****** GX     	 1079
.PDBVB= ****** GX     	 1217
.PDBVE= ****** GX     	 1215
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 22-1
CEXBUF.M11    29-DEC-82 15:48		CROSS REFERENCE TABLE -- USER SYMBOLS

.RDBTB= ****** G      	  113#	  811	  868	  908	  970
CEXBUF - COMM/EXEC BUFFER MANAGEMENT	DNMAC X24.07-563  28-MAY-85  14:20  PAGE 23
CEXBUF.M11    29-DEC-82 15:48		CROSS REFERENCE TABLE -- MACRO NAMES

CCBCK$	  339	  465	  954
CORCK$	   82#	  466	  611
CRSH$S	   76#
DSRCK$	   93#	  747
MAP$	  160	  478	  558	  636
PLVL$	  159	  209	  257	  297	  338	  407	  464	  548	  610	  809	  866	  906	  953
POP$S	  418	  492	  567	  639	  641	  642	 1021	 1083	 1142	 1210	 1232
PUSH$S	  410	  477	  549	  625	  634	 1015	 1136	 1212
SAV2$S	  694
SAV3$S	  757
SMAP$	  416
SMAP$S	  635


. ABS.  000000     000	   CON   RW    ABS   LCL   I  
        000000     001	   CON   RW    REL   LCL   I  
$CODE$  000776     002	   CON   RO    REL   LCL   I  


 ERRORS DETECTED:  0
 DEFAULT GLOBALS GENERATED:  8

 CEXBUF,CEXBUF/CR=MCB:RSXLIB/PA:1,MCBLIB/PA:1,CEX:CEXLIB/PA:1,CEXBUF
 RUN-TIME: 4 2 .2 SECONDS
 RUN-TIME RATIO: 21/7=2.7
 CORE USED:  15K  (29 PAGES)