📄 debug-macros.h.s
字号:
CTR1 SETA 1 ; - default
GBLA CTR2 ; General ctr for e.g. WHILE assembly
CTR2 SETA 1 ; - default
GBLA WATCH0ADDR
GBLA WATCH1ADDR
GBLS SC_Embedded_ICE
GBLS SC_Data_Plus_BREAKPT
GBLS SC_ARM740TD_Cache_Address_Tags
GBLS SC_ARM940TD_ICache
SC_ARM940TD_ICache SETS "4"
GBLA PCIncrement ; 2 bytes in THUMB, 4 bytes in ARM
SC_Embedded_ICE SETS "2"
SC_Data_Plus_BREAKPT SETS "1"
SC_ARM740TD_Cache_Address_Tags SETS "6"
PCIncrement SETA 4 ; Default is ARM value
; [ PCincrement = 2
; is used as a test for THUMB mode
; in e.g. Bst_NOP
]
MEND
; -------------------------------------
; Code must supply Handler_Flag
MACRO
$L Set_Handler_Flag $reg0,$reg1, $val; Set flag to show passed thru handler
; -----------------------------------------------
; 07/07/97 P Pearse - Use LOCAL
; -----------------------------------------------
LOCAL
B %F1
tmpreg0$l DCD 0
tmpreg1$l DCD 0
1
STR $reg0, tmpreg0$l
STR $reg1, tmpreg1$l
MOV r0, #$val
LDR r1, =Handler_Flag
LDR r0, [r1]
LDR $reg0, tmpreg0$l
LDR $reg1, tmpreg1$l
LOCAL_END
MEND
; -------------------------------------
; Code must supply Handler_Flag,
MACRO
$L Check_Handler_Flag $reg0, $reg1, $dest ; Check abort handler was called
; -------------------------------------
; 07/07/97 P Pearse - Use LOCAL
; -----------------------------------------------
LOCAL
STR $reg0, tmpreg0$l
STR $reg1, tmpreg1$l
LDR $reg1, =Handler_Flag
LDR $reg0, [$reg1]
CMP $reg0, #0
LDR $reg0, tmpreg0$l
LDR $reg1, tmpreg1$l
BNE $dest
B %F1
tmpreg0$l DCD 0
tmpreg1$l DCD 0
LTORG
1
LOCAL_END
MEND
; -----------------------------
; -----------------------------
; Mode values
; - USR last since it has limitations esp. mode switching
; -----------------------------
MACRO
Define_Applicable_Modes ; According to 26/32 bit and Arch 3/4
[ :LNOT::DEF: Applicable_Modes
GBLS Applicable_Modes
[ {CONFIG} = 32
Applicable_Modes SETS "Mode_FIQ_32,Mode_IRQ_32,Mode_SVC_32"
Applicable_Modes SETS "$Applicable_Modes,Mode_ABT_32,Mode_UND_32"
[ ARM_ARCH >= 4
Applicable_Modes SETS "$Applicable_Modes,Mode_SYS_32"
]
Applicable_Modes SETS "$Applicable_Modes,Mode_USR_32"
|
Applicable_Modes SETS "Mode_FIQ_26,Mode_IRQ_26,Mode_SVC_26,Mode_USR_26"
]
]
MEND
; -----------------------------
MACRO
CheckMode $MODE ; Check MODE is allowed by current address & Architectur
; -----------------------------
GBLS Addr
[ {CONFIG} = 26
Addr SETS "26"
[ "$MODE" /= "USR" :LAND: "$MODE" /= "FIQ" :LAND: "$MODE" /= "IRQ" :LAND: \
"$MODE" /= "SVC"
! 0 , "Illegal mode for 26 bit addressing"
MEXIT
]
|
Addr SETS "32"
[ ARM_ARCH < 4
[ "$MODE" = "SYS"
! 0, "Illegal mode for architecture < 4"
MEXIT
]
]
[ "$MODE" /= "USR" :LAND: "$MODE" /= "FIQ" :LAND: "$MODE" /= "IRQ" :LAND: \
"$MODE" /= "SVC" :LAND: "$MODE" /= "ABT" :LAND: "$MODE" /= "UND" :LAND: \
"$MODE" /= "SYS"
! 0 , "Illegal mode for 32 bit addressing"
MEXIT
]
]
MEND
; -----------------------------
MACRO
Define_Register_Lists ; Lists of register tags (decimal 0 - 14)
; -----------------------------
GBLS All_Registers
All_Registers SETS "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14"
GBLS Banked_Registers
Banked_Registers SETS "8,9,10,11,12,13,14"
MEND
; -----------------------------
; Called as e.g
; OperateOnParameterList "1,2,3,4,5,6"," B $ps"
; OperationLine is the complete line to allow e.g.
; GBLA ctr
; ctr SETA 0
; OperateOnParameterList "1,2,3,4,5,6", ctr SETA ctr + 1
; Reminder - Assembler replaces missing parameters with ""
; - OperationLines must use "" if need spaces on left
; In list:
; - spaces discarded
; - seperator is the , character
; - ALL other characters acceptable
;
; EXAMPLE: (and see MACRO:GetIndexedStringFromList)
;
; GBLA ctr
; ctr SETA 0
;
;A OperateOnParameterList "1 ,2 , 3 ", "ctr SETA ctr +1"
;
; [ ctr = 3
; ! 0, "Correct"
; |
; ! 0, "Wrong"
; ]
;
;
MACRO
$L OperateOnParameterList $ParameterList,$OperationLine1,$OperationLine2,$OperationLine3,$OperationLine4 \
, $OperationLine5, $OperationLine6 , $OperationLine7, $OperationLine8, $OperationLine9, $OperationLine10
; ----------------------------
LCLS ps ; Individual parameter extracted
LCLS paramList ; Remaining characters of list
LCLS leftChar ; Next character from left of list
ps SETS ""
paramList SETS "$ParameterList"
$L
WHILE paramList /= ""
; ----------------------------
; Still characters to process
; - get left-most
; ----------------------------
leftChar SETS paramList:LEFT:1
; ----------------------------
; If last character in list or seperator
; then use parameter
; else add to parameter
; ----------------------------
[ (leftChar = ",") :LOR: (:LEN:paramList=1)
[ :LEN:paramList=1
; ----------------------------
; If last character NOT space, add to parameter
; ----------------------------
[ "$leftChar" /= " "
ps SETS ps:CC:leftChar
]
]
; ----------------------------
; Use the parameter & clear for next
; ----------------------------
[ "$ps" = ""
! 0, "OperateOnParameterList: Consecutive commas"
]
$OperationLine1
$OperationLine2
$OperationLine3
$OperationLine4
$OperationLine5
$OperationLine6
$OperationLine7
$OperationLine8
$OperationLine9
$OperationLine10
ps SETS ""
|
; ----------------------------
; If next charcter NOT space, then add to parameter
; ----------------------------
[ "$leftChar" /= " "
ps SETS ps:CC:leftChar
]
]
; ----------------------------
; Discard left-most character
; ----------------------------
paramList SETS paramList:RIGHT:(:LEN:paramList - 1)
WEND
MEND
; -----------------------------
; Fill SDestination with AIndexth entry in comma seperated list SList
; - AIndex runs from 0
; - SDestination left empty "" if AIndex invalid
; - SList may have spaces
;
; EXAMPLE
;
; GBLS dest
;
;A GetIndexedStringFromList dest, 3, "a,b,c,d"
;
; [ "$dest" = "d"
; ! 0, "Indexing Correct"
; |
; ! 0, "Indexing Wrong"
; ]
;
MACRO
$L GetIndexedStringFromList $SDestination, $AIndex, $SList
; -----------------------------
$SDestination SETS ""
GBLA ctra ; Global so referred in lower macro
ctra SETA 0
LCLS ctraStr
ctraStr SETS "ctra"
OperateOnParameterList "$SList","ctra SETA ctra + 1"," [ $ctraStr = &$AIndex + 1", $SDestination SETS ps, " ]"
MEND
; -----------------------------
; - distinct values for different modes
; *** CAUTION these values may address the model correctly but fail on the PID card
; e.g. if registers loaded with these defaults
; STR r0, [r7]
; LDR r0, [r7]
; retrieves the stored value in the model but indeterminate value on the card
; - ensure addresses are set to known values in the tests
; rather than use the default register contents
MACRO
Define_Values_Reg_Test ; Values stored in registers to test for corruption
; -----------------------------
; User mode:
; -----------------------------
VU0 * 0x00000011
VU1 * 0x00002300
VU2 * 0x00470000
VU3 * 0x8F000000
VU4 * 0x0000001F
VU5 * 0x00003E00
VU6 * 0x007C0000
VU7 * 0xF8000000
VU8 * 0x00000000
VU9 * 0xFFFFFFFF
VU10 * 0xAA000000
VU11 * 0x55000000
VU12 * 0xA5000000
VU13 * 0x5A000000
VU14 * 0x99000000
; -----------------------------
; Irq mode:
; -----------------------------
VI13 * 0x00000055 ; Irq r13
VI14 * 0x00000077 ; Irq r14
; -----------------------------
; Undefined mode:
; -----------------------------
VN13 * 0x00001600 ; Undefined r13
VN14 * 0x00002800 ; Undefined r14
; -----------------------------
; Abort mode:
; -----------------------------
VA13 * 0x00150000 ; Abort r13
VA14 * 0x00560000 ; Abort r14
; -----------------------------
; Supervisor mode:
; -----------------------------
VS13 * 0x25000000 ; Supervisor r13
VS14 * 0x38000000 ; Supervisor r14
; -----------------------------
; Fiq mode:
; -----------------------------
VF8 * 0x000000A8 ; Fiq r8
VF9 * 0x000000A9 ; Fiq r9
VF10 * 0x000000AA ; Fiq r10
VF11 * 0x000000AB ; Fiq r11
VF12 * 0x000000AC ; Fiq r12
VF13 * 0x000000AD ; Fiq r13
VF14 * 0x000000AE ; Fiq r14
MEND
; -----------------------------
; Reduce clutter
; ALL defines required by the debug code
MACRO
Debug_Defines ; ALL defines required by the debug code
Define_Applicable_Modes
Define_Register_Lists
Define_Constants
Define_Globals
Define_Values_Reg_Test
GBLA varsubA ; vars to handle double pass substitutions
GBLS varsubS
MEND
; -----------------------------
MACRO
$L Cmp_CPSYS_Control_Reg $val ; Compare system co-processor control reg against val
; -----------------------------
; 15/05/97 P Pearse - Added
; 25/06/97 P Pearse - Added 720T
; 07/07/97 P Pearse - Use LOCAL
; 16/02/98 P Pearse - Do NOT reload the registers if comparison fails
; -----------------------------
LOCAL
B %F1
tmpr0$l DCD 0
tmpr1$l DCD 0
1
;~
STR r0, tmpr0$l
STR r1, tmpr1$l
MRC p15, 0, r0, c1, c0, 0
MOV r1, #0x000000FF
ADD r1,r1,#0x00000300
AND r0,r0,r1 ; Mask out dont care bits
; -------------------------------------------------
; Check hard-coded data value matches run-time values
; -------------------------------------------------
MOV r1, #$val
[ "$PROC" = "ARM710T" :LOR: "$PROC" = "ARM720T"
; Insert PDL bits - read as 1
ORR r1,r1,#P_bit
ORR r1,r1,#D_bit
ORR r1,r1,#L_bit
]
CMP r0, r1
BNE NO_Reload$l
LDR r0, tmpr0$l
LDR r1, tmpr1$l
NO_Reload$l
LOCAL_END
MEND
;--------------------------------------------------------------------------------
; -----------------------------
; Indicator for start of Boundary Scan Toolbox instructions
; bin2bst program searches for this value so beware changing it.
; -----------------------------
MACRO
BST_BEGIN
; label to skip BST code
B %F1234
; place any outstanding literals
LTORG
; define BSI starting delimeter (must be word aligned)
DCD 0xE600B510
MEND
MACRO
BST_END
; define BSI ending delimeter (must be word aligned)
DCD 0xE610B510
; label branched to by BST_BEGIN
1234
MEND
MACRO
BST_START
BST_BEGIN
[ SUPPORTS_NON_STOP_DEBUG :LAND: VARIANT = "ARM9"
; Clear the non-stop enable bit coming out of reset.
BST "PROC $VARIANT"
BST "SCAN_N 2"
BST "INTEST"
BST "ICEBINST WRITE DBG_CTL 0"
]
MEND
; --------------------------------------------------
; Terminating BST instructions just in case they are
; ever executed
; --------------------------------------------------
MACRO
TOBST
DCD 0xE600B510
[ SUPPORTS_NON_STOP_DEBUG :LAND: VARIANT = "ARM9"
; Clear the non-stop enable bit coming out of reset.
BST "PROC $VARIANT"
BST "SCAN_N 2"
BST "INTEST"
BST "ICEBINST WRITE DBG_CTL 0"
]
MEND
MACRO
Bst_End
BST "PRINTF Unexpected DBGRQ, exiting."
BST "HALT"
MEND
;--------------------------------------------------------------------------------
; Macro: [label] BST
;
; Function: Output a line to the BST file
;
;
MACRO
$label BST $txt
$label DCB "$txt\n"
MEND
;--------------------------------------------------------------------------------
; Macro: [label] Bst_MESSAGE <string> [,<verbosity>]
;
; Function: Prints message using BST if vebosity satisfies
;--------------------------------------------------------------------------------
MACRO
$label Bst_MESSAGE $string, $verbosity
$label
[ "$string" = ""
! 1, "\n\tSyntax: [label] Bst_MESSAGE <string> [,<verbosity>]"
MEXIT
]
LCLA limit
[ "$verbosity" = ""
limit SETA VERBOSE_DEFAULT
|
limit SETA $verbosity
]
[ VERBOSITY >= limit
DCB "PRINTF $string\n"
]
MEND
;--------------------------------------------------------------------------------
; Simple macro to aid debugging of debug tests
MACRO
Bst_Debug $brk, $ret
LCLA PC_Addr
LCLA Bk_Addr
[ "$brk" = ""
Bk_Addr SETA PCBRK0
|
Bk_Addr SETA $brk
]
PC_Addr SETA Bk_Addr + RETVAL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -