Google
 

Trailing-Edge - PDP-10 Archives - TOPS-20_V6.1_DECnetSrc_7-23-85 - mcb/xpt/top.bli
There is 1 other file named top.bli in the archive. Click here to see a list.
module TOP	(
		IDENT = 'X01040'
		) =
begin

!
!                    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:	Application Services
!
! ABSTRACT:
!
!	Network Topology task - sends to anyone who connects to it a bit map
!	of the network topology.  The map, which is contained in a single
!	message, is of the following format:
!	
!		+----+----+----+----+       +-----+
!		| NN | n1 | n2 | n3 | * * * | nNN +   Field
!		+----+----+----+----+       +-----+
!		  2    .2   .2   .2           .2      Length (bytes.bits)
!	
!	where:
!	
!		NN	is the highest node number accessible from the local
!			node.
!		nX	is a two-bit field giving the topology status for node
!			X:
!	
!				00	Node not reachable
!				01	   (reserved)
!				10	Accessible Phase II node
!				11	Assessible Phase III node
!	
!	As is the customary DECnet convention, the bit fields are arranged from
!	low-order to high-order in each byte, four to a byte, and the bytes are
!	arranged from beginning to end of the message.  Thus bits 0-1 of byte 2
!	(zero-based) in the message are for node 1, bits 2-3 of the byte are
!	for node 2, bits 0-1 of byte 3 are for node 5, and so forth.
!	
!	The total length of the message is (NN+3)/4 + 2 bytes.
!
! ENVIRONMENT:	MCB
!
! AUTHOR: L. Webber , CREATION DATE: 27-Jan-81
!
! MODIFIED BY:
!
!	27-Jan-81 : VERSION 1.00
!
! 1.01	L. Webber, 3-Mar-81
!	Quit ACCEPT_COMPLETE after an abort.
!
! 1.02	A. Peckham, 8-May-82
!	Eliminate GETLDB$ and RETLDB$ references.
!
! 1.04	A. Peckham, 21-May-82
!	Use state machine.
!
!--
!
! INCLUDE FILES:
!

library 'MCB:MCBLIB';
library 'MCB:XPORTX';
library 'MCB:SCSYS';
require 'XPT:TOPMAC';

!
! TABLE OF CONTENTS
!

forward routine
	RCPDSP: MCB_DB_CCB_MOD novalue,
	XCPDSP: MCB_DB_CCB_MOD novalue,
	INIT_TOP: MCB_DB_MOD novalue,
	RCV_CONNECT: MCB_DB_CCB novalue,
        RCV_ABORT: MCB_DB_CCB novalue,
	ACCEPT_COMPLETE: MCB_DB_CCB novalue,
	SEND_COMPLETE: MCB_DB_CCB novalue,
	DISCONNECT_COMPLETE: MCB_DB_CCB novalue,
        ABORT: MCB_DB_CCB novalue,
        SEND_MESSAGE: MCB_DB_CCB novalue;

!
! MACROS:
!

macro RAD50(NAME) =
    %IF %bliss(BLISS36) %THEN
	%RAD50_10 %string(NAME)
    %ELSE
	%RAD50_11 %string(NAME)
    %FI %;

!
! EQUATED SYMBOLS:
!

!
! OWN STORAGE:
!

external routine $DSPCR: novalue;

bind $TOPLL = TABLE$ ($DSPCR, FC_CCP,	! Dispatch table:

	(FC_TIM,INIT_TOP),		!   Timer service
	(FC_XCP,XCPDSP),		!   Transmit complete
	(FC_RCP,RCPDSP));		!   Receive complete

$MCB_PROCESS(name=TOP,llc_dispatch=$TOPLL)

!
! EXTERNAL REFERENCES:
!

external
    MCB$GW_PROCESS_HANDLE;
routine RCPDSP (DB,CCB,MODD): MCB_DB_CCB_MOD novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Dispatches Receive Complete subfunctions.
!
! FORMAL PARAMETERS
!
!	DB	Process database
!	CCB	Function CCB
!	MODD	Modifier
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

DISPATCH$(.MODD,
          TABLE$ ($DSPCR, 0,		! Sub-dispatch table
                  (S$CNR,RCV_CONNECT),  !   Connect Received
                  (S$DSR,RCV_ABORT)),   !   Abort Received
          (.DB,.CCB),
          MCB_DB_CCB);

end;				!End of RCPDSP
routine TIMDSP (DB,CCB,MODD): MCB_DB_CCB_MOD novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Dispatches Time subfunctions.
!
! FORMAL PARAMETERS
!
!	DB	Process database
!	CCB	Function CCB
!	MODD	Modifier
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

DISPATCH$(.MODD,
          TABLE$ ($DSPCR, 0,		! Sub-dispatch table
                  (FM_PIN,INIT_TOP),    !  Initialize
                  (FM_CCB,SEND_MESSAGE)),! Use CCB
          (.DB,.CCB),
          MCB_DB_CCB);

end;				!End of TIMDSP
routine XCPDSP (DB,CCB,MODD): MCB_DB_CCB_MOD novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Dispatches Transmit Complete subfunctions.
!
! FORMAL PARAMETERS
!
!	DB	Process database
!	CCB	Function CCB
!	MODD	Modifier
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

DISPATCH$(.MODD,
          TABLE$ ($DSPCR, 0,                    ! Sub-dispatch table
                  (S$ACC,ACCEPT_COMPLETE),	!   Accept complete
                  (S$SND,SEND_COMPLETE),        !   Message sent
                  (S$DIS,DISCONNECT_COMPLETE),	!   Disconnection completed
                  (S$ABO,DISCONNECT_COMPLETE)),	!   Abort completed
          (.DB,.CCB),
          MCB_DB_CCB);

end;				!End of XCPDSP
routine INIT_TOP (DB,MODD): MCB_DB_MOD novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Performs process initialization for TOP:
!
!	1.  Acquires the Transport data base address from XPT.
!	2.  Gets a work CCB, to cut down the risk of resource
!	    failure.
!	3.  Calculates Session Control's PIX and stores it in
!	    the TOP data base.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	MODD	Function modifier: must be FM_PIN
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	All subsequent processing for TOP assumes that the Session
!	Control PIX and the Transport data base address already exist
!	in the TOP data base.
!
!--

begin

map DB: ref block field(D_FIELDS);

!
!  Get the PIX for Transport (temporarily)
!

if not PDVID$(rad50(XPT),D_XPTPIX)
then SIGNAL_STOP($TOP$_CFG);

end;				!End of INIT_TOP
routine RCV_CONNECT (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Processes an incoming connect.  Only one link at a time is allowed.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);
map CCB: ref block field(C_FIELDS);

if .D_STATE neq DS_IDLE                 ! Link already in use -
then begin                              !   reject this one
     $SC_CONNECT_RECEIVED(.CCB,0,S_EOTB);
     return;
     end;

D_STATE = DS_DO_ACCEPT;
D_LLA = .CCB[C_LIX];                    ! Save the LLA
D_SCPIX = .CCB[C_PIX];                  !  and SC PIX.
$SC_CONNECT_RECEIVED(.CCB,              ! Acknowledge the connection
    .C_ULA,S_SSUC);

SEND_MESSAGE(D_BASE,0)
end;				!End of RCV_CONNECT
routine RCV_ABORT (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Processes the completion of a disconnect or abort.  Since the
! disconnect cannot complete until the previous transmit has completed,
! and any abort will occur without any transmits outstanding, very little
! needs to be done in this routine.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);
map CCB: ref block field (C_fields);

$SC_DISCONNECTED(.CCB);

case .D_STATE from DS_LO to DS_HI of
    set
    [DS_DO_ACCEPT,DS_DO_DISCONNECT, DS_DO_ABORT]:
        D_STATE = DS_DO_ABORT;
    [inrange]:
        begin
        ABORT(D_BASE,0);
        end;
    tes;

end;				!End of RCV_ABORT
routine ACCEPT_COMPLETE (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! This routine is invoked after the connect accept has completed.
! If the link hasn't aborted in the meanwhile, the routine gets
! an buffer large enough to contain the topology message, constructs
! the message, sends it out, and sticks a synchronous disconnect
! behind it.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	None
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

map DB: ref block field(D_FIELDS);
map CCB: ref block field(C_FIELDS);

selectone .D_STATE of
    set
    [DS_ACCEPTING]:
        ;
    [DS_DO_ABORT, DS_ABORTING]:
        return $MCB_RETURN_CCB(.CCB);
    [otherwise]:
        return ABORT(D_BASE,.CCB);
    tes;

!
!  Error conditions:
!
!	1.  Link aborted.
!	2.  Unable to get a buffer to construct the message.
!

if (.CCB[C_STS] neq S_SSUC)
then return ABORT(D_BASE,.CCB);

if not $MCB_GET_BUFFER(.D_ALLOCATION,CCB[C_ADDR])
then return ABORT(D_BASE,.CCB);

SMAP$(CCB[C_BIAS]);
CCB[C_PRM5] = .D_ALLOCATION;

!
!  Construct the message
!

CALL$P(GETTOP, .D_XPTPIX, .CCB);

$SC_DATA_SEGMENT_TRANSMIT(.CCB,		! Send out
    .D_SCPIX,.D_LLA,.C_ULA,S$PEOM);     !   the message

D_STATE = DS_DO_DISCONNECT;
SEND_MESSAGE(D_BASE,0);
end;				!End of ACCEPT_COMPLETE
routine SEND_COMPLETE (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Processes the completion of the message transmission.  Because
! a disconnect was sent after it, all that has to be done is to
! release the message buffer.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);
map CCB: ref block field (C_fields);

$MCB_RETURN_CCB_AND_BUFFER(.D_ALLOCATION,.CCB);
end;				!End of SEND_COMPLETE
routine DISCONNECT_COMPLETE (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Processes the completion of a disconnect or abort.  Since the
! disconnect cannot complete until the previous transmit has completed,
! and any abort will occur without any transmits outstanding, very little
! needs to be done in this routine.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);

$MCB_RETURN_CCB(.CCB);
D_STATE = DS_IDLE;
end;				!End of DISCONNECT_COMPLETE
routine ABORT (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Abort the link.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);
map CCB: ref block field(C_FIELDS);

D_STATE = DS_DO_ABORT;
SEND_MESSAGE(D_BASE, .CCB);
end;				!End of ABORT
routine SEND_MESSAGE (DB,CCB): MCB_DB_CCB novalue =

!++
! FUNCTIONAL DESCRIPTION:
!
! Send a SC message appropriate to the state with the given CCB.
!
! FORMAL PARAMETERS
!
!	DB	TOP data base address
!	CCB	Function CCB
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
! COMPLETION CODES:
!
!	NONE.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin
map DB: ref block field(D_FIELDS);
map CCB: ref block field(C_FIELDS);

if .CCB eqla 0
then if not $MCB_GET_CCB(CCB)
     then return $MCB_REQUEST_CCB();

case .D_STATE from DS_LO to DS_HI of
    set
    [DS_DO_ACCEPT]:
        begin
        D_STATE = DS_ACCEPTING;
        $SC_ACCEPT(.CCB,.D_SCPIX,       ! Accept the connection
                   .D_LLA,.C_ULA,S$PSEG,(,,0));
        end;
    [DS_DO_DISCONNECT]:
        begin
        D_STATE = DS_DISCONNECTING;
        $SC_DISCONNECT(.CCB,.D_SCPIX,.D_LLA,.C_ULA,(,,0));
        end;
    [DS_DO_ABORT]:
        begin
        D_STATE = DS_ABORTING;
        $SC_ABORT(.CCB,.D_SCPIX,.C_ULA,(,,0));
        end;
    [inrange]:
        $MCB_RETURN_CCB(.CCB);
    tes;

end;				!End of SEND_MESSAGE

end				!End of Module TOP
eludom