****************************************************************************** * * * File G_TL_Ini.A40 Rev. 20-DEC-1995 * * * * "Meaningful" Register Usage * * --------------------------- * * * * "Destroyable" Register Usage * * ---------------------------- * * R8, R9*, R10*, R11*, AR7, AR6, IR1 * * * * * Note that R9, R10, and R11 are used for communication with the * * Parameter Checking module * * * * Description of Module * * ===================== * * * * This is the module that Initializes the Global Tool Code. Note that * * there must be one of these modules for each Global Tool. In this first * * version of the code there is only one Global Tool and hence only one * * Global Tool Initialization module. * * * * Note that this Tool is designed to evaluate 4 Terms, with 4 separate * * sets of Global Parameters. These must be Terms #0, #1, #2, and #3. * * This Tool Initialization module knows where to look in the Data Block * * to find the Global Parameters for each of these 4 Terms. * * * * This module is called only when new Parameters are loaded (i.e. * * in response to a START message from COOR). * * * * It performs the following functions: * * * * * * (0) Check the Tool Number found in the Parameter Block * * (only for Term #0) * * (1) Receive, check, and store the Global Tool Parameters * * Note that this version of the code receives, checks, and * * stores 4 copies of the Global Tool Parameters, one for each * * of the 4 Terms that this Tool evaluates. * * (3) Return a status code to the Parameter Checking module * * (4) Return to the calling module * * * ****************************************************************************** ****************************************************************************** * Include the DSP Program-Specific Constant Definitions * ****************************************************************************** .include "constant.inc" ****************************************************************************** * Define a module-specific macro * ****************************************************************************** ****************************************************************************** * * * Macro: GET_GLOBAL_PARAMS * * * * Arguments: Term integer in the range [0..3] defining * * the Term Number we are getting Global * * Parameters for * * * * Purpose of macro * * ---------------- * * This macro receives the Global Parameters for a Term. It first checks * * the number of Global Parameters against the expected number of Global * * Parameters, and branches to a failure routine if there is an error. * * * * It then receives and range-checks the 1 Global parameter for the * * Term, and branches to a failure routine if there is an error * ****************************************************************************** GET_GLOBAL_PARAMS .macro Term LDI *+AR7(1), R11 ; Get the number ; of Parameters ; for this Tool ; from the Dual Port ; Memory CMPI Number_of_Parameters_Expected,R11 ; Compare the number ; of Parameters for ; this Tool to the ; number of Parameters ; required. Bne Number_of_Parameters_Failure ; If the wrong number ; of Parameters are ; specified then ; branch to a failure ; exit point ADDI 1,R8 ; Increment the ; "Current Parameter ; Number" counter Get_First_Param_? LDI *+AR7(2), R11 ; Get this Tool's ; First Tool-Dependent ; Parameter (Count ; Threshold, it is ; an INTEGER with units ; of Objects) from ; Dual Port Memory. CMPI 0, R11 ; Check the Count ; Threshold against ; the LOWER limit Blt Parameter_Range_Failure ; Branch to the Param. ; Range Failure routine ; if the Count ; Threshold ; is BELOW the LOWER ; limit. CMPI 8, R11 ; Check the Count ; Threshold against ; the UPPER limit Bgt Parameter_Range_Failure ; Branch to the Param. ; Range Failure routine ; if the Et Threshold ; is ABOVE the UPPER ; limit STI R11, @Count_Threshold_Term_:Term:_Loc ; Store the Count ; Threshold. ADDI 1,R8 ; Increment the ; "Current Parameter ; Number" counter Get_Second_Param_? LDI *+AR7(3), R11 ; Get this Tool's ; 2nd Tool-Dependent ; Parameter (Term ; Type, it is an ; an INTEGER) from ; Dual Port Memory. STI R11, @Term_Type_:Term:_Loc ; Store the Term ; Type. ADDI 1,R8 ; Increment the ; "Current Parameter ; Number" counter Get_Third_Param_? LDI *+AR7(4), R11 ; Get this Tool's ; Third Tool-Dependent ; Parameter (Phi ; Search Word, it ; is an INTEGER) CMPI 1, R11 ; if param < 1 or ; param > 16 then Blt Parameter_Range_Failure ; give up and go ; to the Range CMPI 16, R11 ; Failure Exit ; Point Bgt Parameter_Range_Failure LDI R11, IR0 ; Look up the ; Phi Search LDA @Phi_Search_Word_Table_Handle, AR6 ; Word. LDI *+AR6(IR0), R11 STI R11, @Phi_Search_Word_:Term:_Loc ; Store the Phi ; Search Word ADDI 1,R8 ; Increment the ; "Current Parameter ; Number" counter .endm ****************************************************************************** * End of macro: GET_GLOBAL_PARAMS * ****************************************************************************** ****************************************************************************** * Load Code into the .text Section * ****************************************************************************** .text Initialize_Tool: ****************************************************************************** * Check Tool Number of the Parameter Block passed to this Tool * * * * The calling module passes a pointer to the Global Tool Parameter Block * * for this Tool. Here we check the Tool Number of that Parameter Block. * * * ****************************************************************************** Check_Tool_Number: LDI @Global_Tool_Parameter_Handle,AR7 ; Load the pointer ; to this Tool's ; Global Parameters ; into AR7 LDI @Zero_Loc,R8 ; Zero the "Current ; Parameter Number" ; (which is stored ; in R8) LDI *AR7, R11 ; Get the Tool Number ; of the Parameter ; Block passed to ; this Tool CMPI @Tool_Number_Loc,R11 ; Compare the Tool ; Number found to ; this Tool's Tool ; Number Bne Parameter_Range_Failure ; If the Tool ID of ; the Parameter Block ; does not match the ; Tool ID of this Tool ; then branch to a ; failure routine ****************************************************************************** * Extract, Check, and Store Tool Parameters * * for each of the 4 Terms * * * * This section of the code extracts and checks the Tool Parameters from * * the Dual Port Memory. * * * * It extracts and checks the Tool Parameters for Terms #0, #1, #2, and #3 * * * * The calling module passes a pointer to the Global Tool Parameters for * * this Tool in a memory location. The Tool must read that memory location * * to discover where its Global Parameters are in Dual Port Memory. * * * * It checks the Tool Parameters for the following things: * * * * - This Term Entry in the parameter block belongs to this Tool Number, * * - that the proper number of parameters appear in the term entry * * - and that all data contained in this entry is within range and * * consistency checks that are built into this part of the Tool code. * * * * As it checks the Tool Parameters it stores them in known locations in * * the Global SRAM (i.e. the region of memory starting at $C000 0000) * * * * It generates a return code for the Parameter Checker also. * * * ****************************************************************************** Get_Parameters_for_Term_0: GET_GLOBAL_PARAMS 0 ; Get the Global Parameters ; for Term #0 Get_Parameters_for_Term_1: ADDI One_Term_Global_Param_Block_Size, AR7 ; Point AR7 to the ; Global Parameters ; for Term #1 LDI @Zero_Loc, R8 ; Zero the ; "Current Parameter ; Number" counter LDI Term_Number_1, R11 ; Use R11 to set ; the Current Term STI R11, @Term_Number_Expected_Loc ; Number Expected ; to Term #1 GET_GLOBAL_PARAMS 1 Get_Parameters_for_Term_2: ADDI One_Term_Global_Param_Block_Size, AR7 ; Point AR7 to the ; Global Parameters ; for Term #2 LDI @Zero_Loc, R8 ; Zero the ; "Current Parameter ; Number" counter LDI Term_Number_2, R11 ; Use R11 to set ; the Current Term STI R11, @Term_Number_Expected_Loc ; Number Expected ; to Term #1 GET_GLOBAL_PARAMS 2 Get_Parameters_for_Term_3: ADDI One_Term_Global_Param_Block_Size, AR7 ; Point AR7 to the ; Global Parameters ; for Term #3 LDI @Zero_Loc, R8 ; Zero the ; "Current Parameter ; Number" counter LDI Term_Number_3, R11 ; Use R11 to set ; the Current Term STI R11, @Term_Number_Expected_Loc ; Number Expected ; to Term #1 GET_GLOBAL_PARAMS 3 ; if we get to ; this point then ; all Parameters were ; OK ; We can return to ; the calling module ****************************************************************************** * Success Exit Point * * * * Now return to the calling module * ****************************************************************************** Tool_Initialize_Success: LDI Status_OK,R11 ; Store the Status OK ; message in R11 for returning ; to the calling module LDI @Zero_Loc,R10 ; Clear R10 RETS ; Return to the calling module ****************************************************************************** * Failure Processing * * * * We have found an error with one of the Parameters or the Reference * * Set Type. We need to set a return code to the calling module (the * * Parameter Checking module) and then return to the calling module. * * * ****************************************************************************** ****************************************************************************** * Global Tool-Dependent Term Parameter Failure Processing * * * * This is the processing corresponding to failures in Frame Parameter * * extraction and checking. The possible Global Parameter Failures are: * * * * Failure Description Error Code * * ------------------- ---------- * * Incorrect Global Tool Number (Tool ID) 101 * * Incorrect Number of Global Tool Parameters 102 * * Global Tool Parameter out of Range 103 * * (note: Tool Number = Parameter Number 0) * * Parameter Block Type Flag Mismatch in Header 104 * * Term Number Mismatch in Header 105 * * The Status response to the TCC is composed of 3 longwords: * * * * The first longword looks like: * * * * Bits Description * * ----- ----------- * * 7:0 Error Code (in the range 101-120, as described above) * * 15:8 Reserved * * 23:16 Term Number (expected) * * 31:24 Number of Parameters expected (if error code = 102) * * Which Parameter is bad (if error code = 103) * * Parameter Type Flag expected (if error code = 104) * * * * The second longword looks like: * * * * Bits Description * * ----- ----------- * * 31:0 Tool Number found (if error code = 101) * * Number of Parameters found (if error code = 102) * * Value of bad Parameter (if error code = 103) * * Parameter Type Flag found (if error code = 104) * * Term Number found (if error code = 105) * * * * The third longword looks like: * * * * Bits Description * * ----- ----------- * * 31:0 Tool Number of Tool mapped to this Term * * * ****************************************************************************** Number_of_Parameters_Failure: ; The Number of Parameters specified in ; the Global Parameter Block Header does not ; match the number of Parameters expected ; by this Tool ; R11 contains the number of Parameters ; specified in the header LDI Number_of_Global_Params_Error,R10 ; Load the error code ; for incorrect Number ; of Global Parameters ; into R10 LDI Number_of_Parameters_Expected,R9 ; Load the number of ; Parameters expected ; into R9 RETS ; Return to the ; calling module Parameter_Range_Failure: ; One of the Parameters specified in the ; Global Parameter Block is out of range. ; R11 contains the value of the bad Parameter, ; and R8 contains the Parameter Number ; of the bad Parameter. LDI Global_Param_Range_Error,R10 ; Load the error code ; for Global Parameter ; Range Checking error ; into R10 LDI R8,R9 ; Load the Parameter ; Number of the Bad ; Parameter into R9 RETS ; Return to the calling ; module ****************************************************************************** * This is the Bulkhead. This code should never be executed * ****************************************************************************** End_Of_L_Tl_Ini: ; These instructions should never be ; executed in the "normal" operation BR End_Of_L_Tl_Ini ; of the program. If the program ; counter becomes corrupted or BR End_Of_L_Tl_Ini ; if we have a bug in the program ; we MAY try to execute these BR End_Of_L_Tl_Ini ; instructions. If we get to these ; instructions the program will appear BR End_Of_L_Tl_Ini ; to halt. We could also use a ; TRAP instruction here, and jump to ; a service routine. ****************************************************************************** * Constants defined using assembler .set directives * ****************************************************************************** Number_of_Parameters_Expected .set 3 ; Specifies that this ; Tool Code requires ; 3 ; Global Parameters ****************************************************************************** * Define constants and working variables in the Data Section * ****************************************************************************** .data Tool_Number_Loc: .word eWjj_Tool ; Memory location to ; store the Tool Number ; of this Local Tool Count_Threshold_Term_0_Loc: .word 1 ; Memory location to ; store the Count ; Threshold for ; Term #0. The ; value stored here is a ; dummy value, the actual ; value is loaded from ; the Parameter Block. Count_Threshold_Term_1_Loc: .word 1 ; Memory location to ; store the Count ; Threshold for ; Term #1. The ; value stored here is a ; dummy value, the actual ; value is loaded from ; the Parameter Block. Count_Threshold_Term_2_Loc: .word 1 ; Memory location to ; store the Count ; Threshold for ; Term #2. The ; value stored here is a ; dummy value, the actual ; value is loaded from ; the Parameter Block. Count_Threshold_Term_3_Loc: .word 1 ; Memory location to ; store the Count ; Threshold for ; Term #3. The ; value stored here is a ; dummy value, the actual ; value is loaded from ; the Parameter Block. **** Memory locations added for eWjj_Tool Term_Type_0_Loc: .word 1 ; New (eWjj) Params for ; Term #0 Phi_Search_Word_0_Loc: .word 0 Term_Type_1_Loc: .word 1 ; New (eWjj) Params for ; Term #1 Phi_Search_Word_1_Loc: .word 0 Term_Type_2_Loc: .word 1 ; New (eWjj) Params for ; Term #2 Phi_Search_Word_2_Loc: .word 0 Term_Type_3_Loc: .word 1 ; New (eWjj) Params for ; Term #3 Phi_Search_Word_3_Loc: .word 0 **** End of new eWjj_Tool memory locations **** Phi Distance -> Phi Search Word Lookup Table Phi_Search_Word_Table_Handle: .word Phi_Search_Word_Table_Loc Phi_Search_Word_Table_Loc: .word 80000000h ; Distance = 0 (not used) .word 0ffffffffh ; Distance = 1 .word 0bffffffeh ; 2 .word 9ffffffch ; 3 .word 8ffffff8h ; 4 .word 87fffff0h ; 5 .word 83ffffe0h ; 6 .word 81ffffc0h ; 7 .word 80ffff80h ; 8 .word 807fff00h ; 9 .word 803ffe00h ; 10 .word 801ffc00h ; 11 .word 800ff800h ; 12 .word 8007f000h ; 13 .word 8003e000h ; 14 .word 8001c000h ; 15 .word 80008000h ; 16 **** End of Phi Distance -> Phi Search Word Lookup Table ****************************************************************************** * Cross-References * ****************************************************************************** .def Initialize_Tool ; Symbols defined in this .def Count_Threshold_Term_0_Loc ; module for use in other .def Count_Threshold_Term_1_Loc ; modules .def Count_Threshold_Term_2_Loc .def Count_Threshold_Term_3_Loc .def Term_Type_0_Loc ; new (eWjj) def's .def Phi_Search_Word_0_Loc .def Term_Type_1_Loc .def Phi_Search_Word_1_Loc .def Term_Type_2_Loc .def Phi_Search_Word_2_Loc .def Term_Type_3_Loc .def Phi_Search_Word_3_Loc .ref Global_Tool_Parameter_Handle ; Symbols referenced in .ref Zero_Loc ; this module but .ref Term_Number_Expected_Loc ; defined in other modules .end