Google
 

Trailing-Edge - PDP-10 Archives - BB-P363B-SM_1985 - t20/nmlt20/ncpctr.bli
There are 2 other files named ncpctr.bli in the archive. Click here to see a list.
! UPD ID= 23, SNARK:<6.1.NML>NCPCTR.BLI.2,  24-May-84 14:12:16 by GLINDELL
! DSKC:NCPCTR.BLI[10,5665,SOURCE,TOPS10] 20-Oct-83 22:58:00, Edit by GROSSMAN
!
! Move tables to the highseg.
! Edit=43
!
!<MCINTEE.WORK>NCPCTR.BLI.2, 27-Jul-83 15:16:17, Edit by MCINTEE
!
! Ident 05.
!   Subentity type now part of entity type.
!   Also rename tables to reflect possibility of more than one 
!   module subentity having counters
!
!PH4:<MCINTEE.WORK>NCPCTR.BLI.2 22-Jun-83 9:19:35, Edit by MCINTEE
!
! Ident 04.
!   Change ENTITY type constant names to new style.
!
!NET:<PECKHAM.DEVELOPMENT>NCPCTR.BLI.2 26-Feb-82 09:33:17, Edit by PECKHAM
!
! Ident 03.
! Move counter definitions to NMARCH.
!
!NET:<DECNET20-V3P1.BASELEVEL-2.SOURCES>NCPCTR.BLI.5  9-Oct-81 08:21:08, Edit by PECKHAM
!
! Ident 02.
! Correct typos in $NML$CIRCUIT_COUNTERS and $NML$LINE_COUNTERS.
!
module NCPCTR	(
		ident = 'X03.05'
		) =
begin

!
!			  COPYRIGHT (c) 1981 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!
! 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:	DECnet-10/20 V3.0 Network Control Program (NCP)
!
! ABSTRACT:
!
!	Provides lookup and translation of NM counter type numbers
!       to text strings.
!
! ENVIRONMENT:	TOPS-10/20 User mode under NML
!
! AUTHOR: Dale C. Gunn , CREATION DATE: 22-Jul-81
!
! MODIFIED BY:
!
! VERSION	Modifier, Date
!		Explanation
!
! 3.01		L. Webber, 30-Sep-81
!		Redo table gen macros, code routines to access them.
!
!--

!
! INCLUDE FILES:
!

library 'NCPLIB';                       ! All required definitions

!
! TABLE OF CONTENTS
!

forward routine
	NCP$COUNTER_TEXT,
	GET_CEB_ADDRESS,
	SEARCH_COUNTER_TABLE;
!
! MACROS:
!
! $NML$CV_LOOKUP (parameter-entry-list) - 
!
!	Macro to expand a list of counter definitions and issue
!       preset attribute parameters to initialize the counter
!       lookup block vector structure. This structure is used to
!       determine the validity and information about any of the
!       NML defined counters for each entity.
!       'parameter_entry_list' is a sequence of doublet entries, each
!       being enclosed in parenthesis, e.g.,
!
!       (counter_definition) , (bit_map_definition_list) , ...
!
!       where 'counter_definition' is
!             (counter_number , 'counter_text' , counter_length)
!
!       and 'bit_map_definition_list' is
!
!             ((bit_position , 'bit_map_text') , ...)
!
!       The 'bit_map_definition_list' may be null.
!       

macro
     $NML$CV_LOOKUP [ENTRY_LIST,ENTRY_BITS] =
         $$NML_LOOKUP_ENTRY (%count,%remove(ENTRY_LIST),ENTRY_BITS)
     % ;

macro
     $$NML_LOOKUP_ENTRY (CNT,CTR,STR,WID,BDF) =
         [CNT,CE_NUMBER] = CTR,
         [CNT,CE_ADDRESS] = uplit (CH$ASCIZ (%remove(STR)),
                                   %if not %null(WID) %then
                                       WID
                                   %else 0 %fi,
                                   %if not %null(BDF)
                                   %then
                                        MAX($$MAX_BIT(%remove(BDF))),
                                        plit ($$COUNTER_LIST(%remove(BDF)))
                                   %else
                                        -1,
                                        0
                                   %fi )
     % ;

macro
     $$COUNTER_LIST [ENTRY_LIST] =
         $$BIT_TEXT (%remove(ENTRY_LIST)) %;

macro
     $$BIT_TEXT (BIT_POSITION,TEXT) =
	BIT_POSITION, ch$asciz(text) %;

macro
    $$MAX_BIT [entry] =
	$$MAX_BITX(%remove(entry)) %;

macro
    $$MAX_BITX (position,text) =
	position %;

macro
     $NML$CV_LOOKUP_COUNT (ENTRY_LIST) =
         %length % ;

macro                                   ! Not referenced...
     $NML$CVL_DATA_BLOCK =
         block [CVL_DATA_BLOCK_SIZE]
         field (CVL_DATA_BLOCK)
     % ;

macro
     $NML$CVB_ENTRY_VECTOR (N) =
         blockvector [N,CVB_ENTRY_SIZE]
         field (CVB_ENTRY) % ;

macro
     $NML$CVB_ENTRY_BLOCK =
         block [CVB_ENTRY_SIZE]
         field (CVB_ENTRY) % ;
!
! EQUATED SYMBOLS:
!

$field CVL_DATA_BLOCK =
    set
%if not $MCB                            ! No NCP on MCB, eliminate string text
%then
    CDB_NAME = [$pointer],              ! Pointer to counter name text
%fi
    CDB_WIDTH = [$tiny_integer]

    tes;

literal
       CVL_DATA_BLOCK_SIZE = $field_set_size ;

!
! Structure definition for an entry in the vector block for
! the counter lookup table (CVB).
!

$field CVB_ENTRY =
    set
    CE_NUMBER = [$integer],             ! Counter number
    CE_ADDRESS = [$address]             ! Address of data for this counter
    tes;

literal
       CVB_ENTRY_SIZE = $field_set_size;

!
! Structure definition for an entry in the counter lookup table (CEB)
!

$field CEB_ENTRY =
    set
    CB_TEXT =	[$pointer],		! Pointer to counter text
    CB_WIDTH =	[$integer],		! Bit width of counter
    CB_HIBIT =	[$integer],		! Bit number of most significant bit
					!   with text, or -1 if none (lowest-
					!   order bit is bit 0)
    CB_BEB =	[$address]		! Address of BEB entry for bit map,
    tes;				!   or 0 if none

literal
	CEB_ENTRY_SIZE = $field_set_size;

!
! Structure definition for an entry in the bit map lookup table (BEB)
!

$field BEB_ENTRY =
    set
    BB_BIT =	[$integer],		! Bit position
    BB_TEXT =	[$pointer]		! Pointer to text for bit
    tes;

literal
	BEB_ENTRY_SIZE = $field_set_size;

!
! OWN STORAGE:
!

literal NODE_COUNTER_LENGTH = $NML$CV_LOOKUP_COUNT($NML$NODE_COUNTERS);
own
   NODE_COUNTER_TABLE:
       $NML$CVB_ENTRY_VECTOR (NODE_COUNTER_LENGTH)
       preset ($NML$CV_LOOKUP($NML$NODE_COUNTERS))
       psect ($high$);


literal LINE_COUNTER_LENGTH = $NML$CV_LOOKUP_COUNT($NML$LINE_COUNTERS);
own
   LINE_COUNTER_TABLE:
       $NML$CVB_ENTRY_VECTOR (LINE_COUNTER_LENGTH)
       preset ($NML$CV_LOOKUP($NML$LINE_COUNTERS))
       psect ($high$);

literal CIRCUIT_COUNTER_LENGTH = $NML$CV_LOOKUP_COUNT($NML$CIRCUIT_COUNTERS);
own
   CIRCUIT_COUNTER_TABLE:
       $NML$CVB_ENTRY_VECTOR (CIRCUIT_COUNTER_LENGTH)
       preset ($NML$CV_LOOKUP($NML$CIRCUIT_COUNTERS))
       psect ($high$);

literal X25_SERVER_COUNTER_LENGTH = $NML$CV_LOOKUP_COUNT($NML$X25_SERVER_COUNTERS);
own
   X25_SERVER_COUNTER_TABLE:
       $NML$CVB_ENTRY_VECTOR (X25_SERVER_COUNTER_LENGTH)
       preset ($NML$CV_LOOKUP($NML$X25_SERVER_COUNTERS))
       psect ($high$);

literal X25_PROTOCOL_COUNTER_LENGTH = $NML$CV_LOOKUP_COUNT($NML$X25_PROTOCOL_COUNTERS);
own
   X25_PROTOCOL_COUNTER_TABLE:
       $NML$CVB_ENTRY_VECTOR (X25_PROTOCOL_COUNTER_LENGTH)
       preset ($NML$CV_LOOKUP($NML$X25_PROTOCOL_COUNTERS))
       psect ($high$);
!
! EQUATED SYMBOLS:
!

%module_name ('NCPCTR');

!
! OWN STORAGE:
!

!
! EXTERNAL REFERENCES:
!

external
        %debug_data_base;
%global_routine ('NCP$COUNTER_TEXT', ENTITY_TYPE, COUNTER_NO)  =

!++
! FUNCTIONAL DESCRIPTION:
!
! Called to get the text describing a counter.
!
! FORMAL PARAMETERS
!
!	ENTITY_TYPE	One of the following entity codes:
!
!			    ENTITY_NODE  	NODE
!			    ENTITY_LINE 	LINE
!			    ENTITY_LOGGING 	LOGGING (no counters)
!			    ENTITY_CIRCUIT 	CIRCUIT
!			    ENTITY_MODULE 	MODULE
!			    ENTITY_AREA		AREA (no counters)
!
!	COUNTER_NO	Number of counter to get the text for
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
!
!	Pointer to an ASCIZ text string, or 0 if no text.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

local CEB: ref block field(CEB_ENTRY);

if (CEB=GET_CEB_ADDRESS(.ENTITY_TYPE,.COUNTER_NO)) eql 0 then 0

else .CEB[CB_TEXT]

end;				!End of NCP$COUNTER_TEXT
%global_routine ('NCP$BIT_TEXT', ENTITY_TYPE, COUNTER_NO, BIT_NO)  =

!++
! FUNCTIONAL DESCRIPTION:
!
! Called to get the text describing a bit in a counter's bit map.
!
! FORMAL PARAMETERS
!
!	ENTITY_TYPE	One of the following entity codes:
!				               
!			    ENTITY_NODE           NODE
!			    ENTITY_LINE 	  LINE
!			    ENTITY_LOGGING 	  LOGGING (no counters)
!			    ENTITY_CIRCUIT 	  CIRCUIT
!			    ENTITY_MODULE 	  MODULE
!			    ENTITY_AREA		  AREA (no counters)
!
!	COUNTER_NO	Number of counter to get the text for.
!
!	BIT_NO		Bit number (low-order = 0) of bit to get the text for.
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
!
!	Pointer to an ASCIZ text string, or 0 if no text.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

local CEB: ref block field(CEB_ENTRY);
local BEB: ref blockvector [1,BEB_ENTRY_SIZE] field(BEB_ENTRY);
local MAX_BIT,MAX_ENTRY;

if (CEB=GET_CEB_ADDRESS(.ENTITY_TYPE,.COUNTER_NO)) eql 0 then 0
else begin
    BEB = .CEB[CB_BEB];			! Address bit map table
    MAX_BIT = .CEB[CB_HIBIT];		!   and high bit number
    if .BIT_NO gtru .MAX_BIT then 0	! Bit out of range - retn null pointer
    else begin
	local RET;
	MAX_ENTRY =				! Pick up PLIT
	    (.vector[.BEB,-1])/BEB_ENTRY_SIZE;	!   count field
	RET =				
	(incr I from 0 to .MAX_ENTRY-1 do	! Scan through the
	    (if .BEB[.I,BB_BIT] eql .BIT_NO	!   BEB table for
	    then  exitloop(.BEB[.I,BB_TEXT])));	!  a matching bit number
	if .RET eql -1 then 0
	else .RET
	end
    end

end;				!End of NCP$COUNTER_TEXT
%routine ('GET_CEB_ADDRESS', ENTITY_TYPE, COUNTER_NO) =

!++
! FUNCTIONAL DESCRIPTION:
!
! Given an entity type and a counter number, returns the address of
! the CEB (counter table entry) for the counter.
!
! FORMAL PARAMETERS
!
!	ENTITY_TYPE	One of the entity types given in NCP$COUNTER_TEXT.
!
!	COUNTER_NO	Counter number
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
!
!	Address of the CEB entry for the counter, or 0 if the counter
!	was not found.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

local CVB: ref $NML$CVB_ENTRY_VECTOR (1000);
local CVB_LEN;

selectone .ENTITY_TYPE of
set

[ENTITY_NODE]:		begin
		CVB = NODE_COUNTER_TABLE;
		CVB_LEN = NODE_COUNTER_LENGTH
			end;

[ENTITY_LINE]:		begin
		CVB = LINE_COUNTER_TABLE;
		CVB_LEN = LINE_COUNTER_LENGTH
			end;

[ENTITY_CIRCUIT]:		begin
		CVB = CIRCUIT_COUNTER_TABLE;
		CVB_LEN = CIRCUIT_COUNTER_LENGTH
			end;

[ENTITY_MODULE_X25_PROTOCOL]:	begin
		CVB = X25_PROTOCOL_COUNTER_TABLE;
		CVB_LEN = X25_PROTOCOL_COUNTER_LENGTH
			end;

[ENTITY_MODULE_X25_SERVER]:	begin
		CVB = X25_SERVER_COUNTER_TABLE;
		CVB_LEN = X25_SERVER_COUNTER_LENGTH
			end;

[otherwise]:	CVB = 0;

tes;

if .CVB eql 0 then 0

else SEARCH_COUNTER_TABLE(.COUNTER_NO,.CVB,.CVB_LEN)

end;				!End of GET_CEB_ADDRESS
%routine ('SEARCH_COUNTER_TABLE', COUNTER_NO, TABLE_ADDRESS, N) =

!++
! FUNCTIONAL DESCRIPTION:
!
! Performs a binary search on a counter table.
!
! FORMAL PARAMETERS
!
!	COUNTER_NO	The counter number to be searched for.
!
!	TABLE_ADDRESS	The address of the CVB to be searched.
!
!	N		The number of entries in the table.
!
! IMPLICIT INPUTS
!
!	NONE.
!
! ROUTINE VALUE:
!
!	The CEB address for the specified counter, or 0 if the counter is
!	not found.
!
! SIDE EFFECTS:
!
!	NONE.
!
!--

begin

map                                 ! Map parameter vector as one element
       TABLE_ADDRESS: ref $NML$CVB_ENTRY_VECTOR (1);

local
         L,                             ! Left boundary
         R,                             ! Right boundary
         J,                             ! Index for search
         RTN_COD,                       ! Return code
         TEMP;

RTN_COD = 0;                       ! Set up for failure

L = 0;                             ! Initialize left (lower) bound
R = .N + 1;                        ! Initialize right (upper) bound

while (J = (.L + .R)/2; .J neq .L) ! Set center of bounds and test failure
do begin
    local
	INDEX;                     ! Index for parameter table

    INDEX = .J - 1;                ! Adjust table index for zero base

    if .COUNTER_NO eql .TABLE_ADDRESS[.INDEX,CE_NUMBER]
    then begin                     ! Entry found
	RTN_COD = .TABLE_ADDRESS[.INDEX,CE_ADDRESS];
	exitloop;
	end
    else if .COUNTER_NO lss .TABLE_ADDRESS[.INDEX,CE_NUMBER]
    then begin		           ! Entry is in lower bound
	R = .J;
	end
    else if .COUNTER_NO gtr .TABLE_ADDRESS[.INDEX,CE_NUMBER]
    then begin           	   ! Entry is in upper bound
	L = .J;
	end
    else return 0;
    end;

.RTN_COD

end;				!End of SEARCH_COUNTER_TABLE
end				!End of Module NCPCTR
eludom
! Local Modes:
! Mode:Fundamental
! Auto Save Mode:2
! Comment Column:40
! Comment Rounding:+1
! End: