Google
 

Trailing-Edge - PDP-10 Archives - BB-P363B-SM_1985 - mcb/cex/cexsge.m11
There are no other files named cexsge.m11 in the archive.
	.TITLE	CEXSGE	- Bliss-16 Condition handling facility
	.IDENT	/003220/
	.ENABL	LC

;
;                    COPYRIGHT (c) 1980, 1981, 1982
;                    DIGITAL EQUIPMENT CORPORATION
;                        Maynard, Massachusetts
;
;     This software is furnished under a license and may  be  used
;     and copied only in accordance with the terms of such license
;     and with the inclusion of the above copyright notice.   This
;     software  or any other copies thereof may not be provided or
;     otherwise made available to any other person.  No  title  to
;     and ownership of the software is hereby transferred.
;
;     The information  in  this  software  is  subject  to  change
;     without  notice  and should not be construed as a commitment
;     by DIGITAL EQUIPMENT CORPORATION.
;
;     DIGITAL assumes no responsibility for the use or reliability
;     of  its  software  on  equipment  which  is  not supplied by
;     DIGITAL.
;

;++
; FACILITY:  
;	MCB Communications Executive
;
; ABSTRACT:
;	This module provides signal and enable support for
;	the Bliss-16 condition handling facility.
;	
; ENVIRONMENT:
;	 RSX kernel mode with EIS
;	
; AUTHOR: Bose S. Ghanta CREATION DATE:  26-Jan-78
;
; MODIFIED BY:
;
; 1.	14-Feb-80	DGF	Now conforms to software standards.
;
; 2.	 4-Apr-80	DL	SS$.UN is now a global literal, it may be
;				accessed from Bliss-16 programs using the
;				VMS standard name SS$_UNWIND.  The name is
;				truncated to 6 rad50 characters: SS$.UN
;				    EXTERNAL LITERAL SS$_UNWIND
;				Also, SS$UNWIND (RAD50-11 SS$UNW) is defined.
;
; 3.	8-Apr-80	DL	The value set in the MECH vector is now used.
;
;	Alan D. Peckham, 1-Jul-80: VERSION 3.0
; 01	- Set to operate within the MCB environment.
;	  Conditionalize the handler and unwind coding.
; 02	- Insert external global declarations to pull in BLISS library
;	  modules of universal utility...
; 03	- Moved global data to seperate module.
;	  Eliminated local data (module can now be made read-only).
; 04	- Put meaningful data in registers on IOT.
; 05	- Remove that meaningful data.
; 06	- Add Comm/Exec $CRSH entry point.
;	  Enable UNWIND coding.
; 07	- Rewritten to compact coding and eliminate stack handling bug.
; 08	- Add $INTR routine for CEXINT to do exception handling.
;	  Save PANIC context and call panic process if existant.
;	  Added call to debug process before exception handling.
; 09	- Correct exception handlers $INTR, $CRSH, $STOP to be able to
;	  continue after a call to the debug process.
; 10	- Bugs in previous fix.
; 11	- Allow the debug process to UNWIND into a panic dump.
;	  Do not attempt to save PC or PS in panic dump.
; 12	- Correct debug UNWIND coding.
; 13	- Re-organize resignalling strategy.
;	  Move panic dumper to CEX process.
; 14	- Remove unneeded definitions.
;	  Correct M.EXR address bug in SETSIG.
; 15	- Correct context restoration in RETSIG.
; 16	- $STOP should go to SIGNAL, not to $IGNAL.
; 17	- Add $DBGDL for BLISS call tracing (/DEBUG).
;	Alan D. Peckham, 12-Dec-80: VERSION 3.1
; 18	- Add support for enable vector address in exception vectors.
;	Alan D. Peckham, 30-Jan-80: VERSION 3.2
; 19	- Fix status code pickup bug in DBGCHK.
;	  Change excpetion data base in SIGNAL, $ETEXV.
;	  Remove HALT instruction from $STOP code.
;	  New method for translating PIX to process descriptor in $ETEXV.
;	  Add default process exception handler coding in SIGNAL.
;	  Move $INTR to CEXINT.
;	  Move $CRSH to CEXSCH.
; 20	- Remap to calling process after exception in SIGNAL.
; 21	- Conditionalize out UNWIND coding.
; 22	- More conditionalizing.
;	  Comment out process signal handling dispatch - nobody uses it!
;--
	.SBTTL	DECLARATIONS

;
; INCLUDE FILES:
;

	.MCALL	POP$S,PUSH$S,SAV5$S
	.GLOBL	KISAR5,KISAR6,PS,.CRPIX
;	.GLOBL	BL$ABS		; B16ABS
	.GLOBL	BL$CMP,BL$EQL,BL$GEQ,BL$GTR,BL$LEQ,BL$LSS,BL$NEQ ; B16CH1
	.GLOBL	BL$CPY		; B16CH2
	.GLOBL	BL$FCH,BL$FNC	; B16CH3
	.GLOBL	BL$FSB		; B16CH4
	.GLOBL	BL$FIL,BL$MOV	; B16CH5
;	.GLOBL	BL$TRN		; B16CH6
;	.GLOBL	BL$GT1		; B16PG1
;	.GLOBL	BL$GT2		; B16PG2
;	.GLOBL	BL$PU1		; B16PG3
;	.GLOBL	BL$PU2		; B16PG4
;	.GLOBL	BL$ROT		; B16ROT
	.GLOBL	$SAVE2,$SAVE3,$SAVE4,$SAVE5 ; B16SAV

;
; MACROS:
;
;	None
;
; EQUATED SYMBOLS:

;
C$$UNW	= 0			; No unwinding allowed

SS$.UN	== 7!<<7777>*10>	; UNWIND SIGNAL VALUE. A BLISS-16
				; program can reference this symbol
				; as EXTERNAL LITERAL SS$_UNWIND;
SS$UNW	== 7!<<7777>*10>	; ALSO, SS$UNWIND (10/20 standard)
;
; Mechanism vector
;
	.ASECT
.	= 0
	.BLKW	1		; Constant = 1
M.R0::	.BLKW	1		; Saved R0
M.AR5::	.BLKW	1		; Saved KISAR5
M.HSP::	.BLKW	1		; Copy of $HANSP at time of SIGNAL
M.FRM::	.BLKW	1		; Copy of $IGREG at time of SIGNAL
M.MCH::	.BLKW	1		; Address of next MeCHanism frame
M.SIG::	.BLKW	1		; Address of current SIGnal vector
M.EXR::	.BLKW	1		; Next exception processor.
M.LVL::	.BLKW	1		; Frame level:
 ML.LST	==	 -3		;  Last chance
 ML.PRI	==	 -2		;  Primary
 ML.SEC	==	 -1		;  Secondary

M.LNG::	.BLKW	0		; Length of mechanism frame
.	= 0
	.PSECT

;
; OWN STORAGE:
;

	.GLOBL	$IGREG		; Enable frame pointer
	.GLOBL	$HANSP		; Global used by ENABLE code
	.GLOBL	.DBGFP		; Debug frame pointer for call tracing.
	.GLOBL	.DBGST		; Non-zero for call tracing
	.GLOBL	.UNWLV		; Non-zero if UNWIND requested
	.GLOBL	.MCHVC		; Address of current MeCHanism vector
	.GLOBL	.MEXV1		; Primary MCB exception vector.
	.GLOBL	.MEXV2		; Secondary MCB exception vector.
	.GLOBL	.MEXVL		; Last chance MCB exception vector.
	.GLOBL	.MEXVD		; MCB dumper exception vector.

	.IF	NE,C$$UNW
	.PSECT	$PLIT$,D,RO
UNWSIG:	.WORD	1,SS$UNW	; UNWIND SIGNAL vector.
	.ENDC
	.IIF	NE,<E.LVL-0>,.ERROR E.LVL; must be first word in EXV
	.IIF	NE,<E.PDB-2-E.LVL>,.ERROR E.PDB; must follow level
	.IIF	NE,<E.DSP-2-E.PDB>,.ERROR E.DSP; must follow PDB
	.IIF	NE,<E.ENA-2-E.DSP>,.ERROR E.ENA; must follow dispatch
	.IIF	NE,<Z.DSP-0>,.ERROR Z.DSP; must be first word in PD
	.SBTTL	$DBGDL	- Singal Routine Entry/Exit
;++
; FUNCTIONAL DESCRIPTION:
;
;	None
;
; CALLING SEQUENCE:
;
;	CALL	$DBGDL
;	.
;	:
;	BR	.+22
;	.ASCII	/modulnam/
;	.ASCII	/routinam/
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
$DBGDL::PUSH$S	<@#KISAR5,.DBGFP> ; Link us
	MOV	SP,.DBGFP	; into frame list.
	CALL	DBGCHK		; If asked,
	CE$RCL			; indicate that the routine is being called.
	CALL	@2(SP)		; Invoke the routine.
	CALL	DBGCHK		; If asked,
	CE$RRT			; indicate that the routine is returning.
	POP$S	<.DBGFP,,>	; Remove from frame list
	RETURN			; and drop out of routine.
	.SBTTL	$ETUNW	- Initiate Unwind Processing
;++
; FUNCTIONAL DESCRIPTION:
;
;	Invoked by:
;	    SETUNWIND ();
;
; CALLING SEQUENCE:
;
;	$ETUNW ()
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
	.IF	NE,C$$UNW
$ETUNW::MOVB	#1,.UNWLV	; Set unwind level
	RETURN			; and return.
	.ENDC
	.SBTTL	$HANDL	- Call a User Condition Handling Routine
;++
; FUNCTIONAL DESCRIPTION:
;
;	None
;
; CALLING SEQUENCE:
;
;	$HANDL (arg1, arg2, ..., number_of_args, handler_routine)
;
; INPUT PARAMETERS:
;
;	
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
$HANDL::MOV	.MCHVC,R0	; Get mechanism vector
	PUSH$S	<M.SIG(R0),R0,#3.*2+4> ; and set up
	ADD	SP,(SP)		; condition handler arguments.
	.IF	NE,C$$UNW
	CLRB	.UNWLV		; Assume no UNWINDing and
	.ENDC
	CALL	@3.*2+2(SP)	; call the user handler routine.
HANDL:	POP$S	,2		; Remove enable and mechanism addresses
.PAGE
;
; There are now four options:
;
;  1)	An unwind is already in progress
;  2)	An unwind has been requested
;  3)	Resignalling is being requested
;  4)	The signalling routine is to be continued
;

	.IF	NE,C$$UNW
	CMP	#UNWSIG,(SP)+	; If UNWIND already in progress
	BEQ	UNWIN2		; then go see if finished.
	.IFTF

	MOV	.MCHVC,SP	; Recover SIGNAL stack pointer.
	.IFT
	TSTB	.UNWLV		; If user has requested UNWIND
	BNE	UNWIND		; then start processing.
	.ENDC

	ASR	R0		; If no resignalling requested
	BCS	RETSIG		; then complete the SIGNAL call
	JMP	SIGNAL		; otherwise go on to next frame.
.PAGE
;
; This handler has requested an unwind. Unwinding is done by
; scanning back through the stack and calling each handler
; until we match the handler that requested unwind. The $IGREG
; will point to next outer enable frame when we return.
; In this unwind process, the value returned by the handler
; is ignored.
;

	.IF	NE,C$$UNW
UNWIND:	MOV	M.FRM(SP),R0	; Get starting frame pointer,
	MOV	$IGREG,M.FRM(SP) ; Exchange with current one.
	MOV	R0,$IGREG
	MOV	#UNWSIG,M.SIG(SP) ; Set up the SS$UNW signal vector,
UNWIN1:	MOV	.MCHVC,SP	; recover signal stack
	JMP	SIGNAL		; and invoke the handler.

;
; An unwind is in progress.
;

UNWIN2:	MOV	.MCHVC,R0	; Get MeCHanism vector
	CMP	$IGREG,M.FRM(R0) ; and if we are backed to UNWIND requestor
	BNE	UNWIN1		; then

;
; Now, we return from the routine which established this handler.
;

	MOV	(SP),(R0)	; Get return address,
	ADD	$HANSP,SP	; adjust the stack
	MOV	(R0)+,(SP)	; and reset address.
	MOV	(R0),R0		; Get routine value from mechanism vector,
	RETURN			; and let him exit.
	.ENDC
	.SBTTL	$IGNAL	- Initiate Condition Handling
;++
; FUNCTIONAL DESCRIPTION:
;
;	Invoked by:
;	    SIGNAL (arg1, arg2, ...);
;
; CALLING SEQUENCE:
;
;	$IGNAL (arg1, arg2, ..., number_of_args)
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
$IGNAL::CALL	SETSIG		; Set up MeCHanism vector
	JMP	SIGNAL		; and start signalling.

;
; Set up MeCHanism vector for SIGnal
;

SETSIG:	PUSH$S	<#MEXV,#M.LNG+2,.MCHVC,$IGREG,$HANSP>
	PUSH$S	<@#KISAR5,R0,#1>
	ADD	SP,M.SIG(SP)
	MOV	SP,.MCHVC
	JMP	@M.LVL(SP)
;
; Return from the signal
;

RETSIG:	POP$S	<,R0,@#KISAR5>
	POP$S	<$HANSP,$IGREG,.MCHVC>
	POP$S	,3
	RETURN
	.SBTTL	$STOP	- Initiate Condition Handling
;++
; FUNCTIONAL DESCRIPTION:
;
;	Invoked by:
;	    SIGNAL_STOP (arg1, arg2, ...);
;
; CALLING SEQUENCE:
;
;	$STOP (arg1, arg2, ..., number_of_args)
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
$STOP::	CALL	20$		; Spring the signal
10$:	PUSH$S	<#SS$STP,#1>	; and if he continues
	CALL	$IGNAL		; admonish him
	BR	10$		; again and again.

20$:	CALL	SETSIG		; Set the signal context,
	ADD	#2,M.SIG(SP)	; adjust the signal vector address
	JMP	SIGNAL		; and spring the SIGNAL.
	.SBTTL	DBGCHK	- Signal Routine Entry/Exit If Asked
;++
; FUNCTIONAL DESCRIPTION:
;
;	None
;
; CALLING SEQUENCE:
;
;	JMP	DBGCHK
;	.WORD	status_code
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
DBGCHK:	TSTB	.DBGST		; If no call tracing
	BNE	70$		; then
	ADD	#2,(SP)		; bypass the status code.
	RETURN
70$:	PUSH$S	@(SP)		; Otherwise set status code
	ADD	(PC),2(SP)	; and return addresses,
	JMP	$CRSH		; and do the signal.
	.SBTTL	SIGNAL	- Signal to the Next Exception Handler
;++
; FUNCTIONAL DESCRIPTION:
;
;	None
;
; CALLING SEQUENCE:
;
;	JMP	SIGNAL
;
; INPUT PARAMETERS:
;
;	None
;
; IMPLICIT INPUTS:
;
;	None
;
; OUTPUT PARAMETERS:
;
;	None
;
; IMPLICIT OUTPUTS:
;
;	None
;
; CONDITION CODES:
;
;	None
;
; SIDE EFFECTS:
;
;	None
;--

	.PSECT	$CODE$,I,RO
SIGNAL:	JMP	@M.EXR(SP)	; Go to next processor.

MEXV:	MOV	#.MEXV1,R0	; Primary exception.
	CALL	60$

	MOV	#.MEXV2,R0	; Secondary exception.
	CALL	60$

20$:	INC	M.LVL(SP)	; Bump exception depth
	BMI	20$		; and make sure it starts at zero.
	MOV	$IGREG,R0	; Get next handler frame
	BEQ	22$		; (if there is one)
	MOV	(R0)+,$IGREG	; and pop to next.
	MOV	(R0)+,$HANSP	; Put SP for the ENABLE body in a global place
	SUB	SP,$HANSP	; to get offset for locals on enable stack
	JMP	@(R0)+		; and go to ENABLE code (ie) $HANDL.

22$:;	CALL	50$							;UNUSED

30$:	MOV	#.MEXVL,R0	; Last chance exception.
	CALL	60$

	MOV	#.MEXVD,R0	; MCB dumper exception.
	BR	62$

50$:;	POP$S	M.EXR(SP)	; Set next exception processor.		;UNUSED
;	MOV	@.CRPDB,@#KISAR5 ; Set process mapping			;UNUSED
;	MOV	#PHDSIG,R0	; get signal address			;UNUSED
;	TST	(R0)+		; and check address			;UNUSED
;	BEQ	SIGNAL		; if it is there.			;UNUSED
;	CLR	$HANSP		; No stack offset			;UNUSED
;	PUSH$S	<M.SIG(SP),.MCHVC,#0>					;UNUSED
;				; Set exception handler parameters	;UNUSED
;	BR	68$		; and do the signal.			;UNUSED

60$:	POP$S	M.EXR(SP)	; Set next exception processor.
62$:	MOV	(R0)+,M.LVL(SP)	; Exception level
	MOV	@(R0)+,@#KISAR5	; process mapping
	TST	(R0)+		; and check address
	BEQ	SIGNAL		; if it is there.
	CLR	$HANSP		; No stack offset
	PUSH$S	<M.SIG(SP),.MCHVC,(R0)>
				; Set exception handler parameters
68$:
	.IF	NE,C$$UNW
	CLRB	.UNWLV		; assume no UNWINDing and
	.ENDC
	CALL	@-(R0)		; call the user handler routine.
	MOV	6+M.AR5(SP),@#KISAR5 ; Remap to original process
	JMP	HANDL		; and see how called handler did.

	.END