os/kernelhwsrv/kerneltest/e32test/rm_debug/d_rmdebug_step_test.s
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 ; Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 ; All rights reserved.
     3 ; This component and the accompanying materials are made available
     4 ; under the terms of the License "Eclipse Public License v1.0"
     5 ; which accompanies this distribution, and is available
     6 ; at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 ;
     8 ; Initial Contributors:
     9 ; Nokia Corporation - initial contribution.
    10 ;
    11 ; Contributors:
    12 ;
    13 ; Description:
    14 ;
    15 
    16         AREA |d-rmdebug-bkpt$$Code|, CODE, READONLY, ALIGN=6
    17 
    18 	CODE32
    19 
    20 	; ARM tests
    21 	
    22 ; 
    23 ; Non-PC modifying
    24 ;
    25 	EXPORT RMDebug_StepTest_Non_PC_Modifying
    26 	EXPORT RMDebug_StepTest_Non_PC_Modifying_OK
    27  
    28 RMDebug_StepTest_Non_PC_Modifying
    29 	mov		r0,r0		; nop
    30 RMDebug_StepTest_Non_PC_Modifying_OK
    31 	bx		lr			; should return to normal execution of the test thread
    32 
    33 ;
    34 ; Branch
    35 ;
    36 	EXPORT RMDebug_StepTest_Branch
    37 	EXPORT RMDebug_StepTest_Branch_1
    38 
    39 RMDebug_StepTest_Branch
    40 	b		RMDebug_StepTest_Branch_1		
    41 	mov		r0, #2		; if the pc ends up here, we know its gone wrong
    42 RMDebug_StepTest_Branch_1
    43 	bx		lr			; return
    44 
    45 ;
    46 ; Branch and Link
    47 ;
    48 	EXPORT RMDebug_StepTest_Branch_And_Link
    49 	EXPORT RMDebug_StepTest_Branch_And_Link_1
    50 	EXPORT RMDebug_StepTest_Branch_And_Link_2
    51 
    52 RMDebug_StepTest_Branch_And_Link		
    53 	mov		r0, lr		; preserve lr for the moment
    54 RMDebug_StepTest_Branch_And_Link_1
    55 	bl		RMDebug_StepTest_Branch_And_Link_2
    56 	mov		r1, #1		; insert a gap in the instruction stream so we know we branched.
    57 RMDebug_StepTest_Branch_And_Link_2
    58 	mov		lr, r0		; restore lr			
    59 	bx		lr			; should return to normal execution of the test thread
    60 
    61 ;
    62 ; MOV PC
    63 ;
    64 	EXPORT RMDebug_StepTest_MOV_PC
    65 	EXPORT RMDebug_StepTest_MOV_PC_1
    66 	EXPORT RMDebug_StepTest_MOV_PC_2
    67 
    68 RMDebug_StepTest_MOV_PC
    69 	mov		r0, #4
    70 RMDebug_StepTest_MOV_PC_1
    71 	add		pc, pc, r0	; should be a jump (bear in mind reading pc = current inst + 8bytes for arm)
    72 	mov		r0, #1		; Simple instructions which allow us to test where the PC really is
    73 	mov		r0, #2		; just by reading r0.
    74 RMDebug_StepTest_MOV_PC_2
    75 	mov		r0, #3		; 
    76 	mov		r0, #4		; 
    77 	bx		lr			; should return to normal execution of the test thread
    78 
    79 ; 
    80 ; LDR PC
    81 ;
    82 	EXPORT RMDebug_StepTest_LDR_PC
    83 	EXPORT RMDebug_StepTest_LDR_PC_1
    84 
    85 RMDebug_StepTest_LDR_PC
    86 	ldr		pc, =RMDebug_StepTest_LDR_PC_1
    87 	mov		r0, #1		;  separate the branch target so we can prove it works
    88 RMDebug_StepTest_LDR_PC_1
    89 	bx		lr			; should return to normal execution of the test thread
    90 	
    91 ;
    92 ; ARM -> Thumb -> ARM interworking test
    93 ;
    94 ; Note: We always start and finish this test
    95 ; in ARM mode.
    96 	EXPORT RMDebug_StepTest_Interwork
    97 	EXPORT RMDebug_StepTest_Interwork_1
    98 	EXPORT RMDebug_StepTest_Interwork_2
    99 	EXPORT RMDebug_StepTest_Interwork_3	
   100 RMDebug_StepTest_Interwork
   101 	mov		r0, lr	; preserve lr
   102 RMDebug_StepTest_Interwork_1
   103 	blx		RMDebug_StepTest_Interwork_2
   104 
   105 	CODE16
   106 RMDebug_StepTest_Interwork_2
   107 	blx		RMDebug_StepTest_Interwork_3
   108 
   109 	CODE32
   110 
   111 RMDebug_StepTest_Interwork_3
   112 	bx		r0
   113 
   114 ;
   115 ; Stepping performance tests
   116 ;
   117 ; This counts down from 100000 to 0
   118 ; This means that for all practical purposes
   119 ; we can single-step as much as we like
   120 ; in less than one second and have some likelyhood
   121 ; that we will not step too far from our loop
   122 
   123 	EXPORT RMDebug_StepTest_Count
   124 	EXPORT RMDebug_StepTest_Count_1
   125 	EXPORT RMDebug_StepTest_Count_2
   126 
   127 RMDebug_StepTest_Count
   128 	ldr		r2, =100000
   129 RMDebug_StepTest_Count_1
   130 	subs	r2, r2, #1
   131 RMDebug_StepTest_Count_2
   132 	bne		RMDebug_StepTest_Count_1
   133 	bx		lr
   134 
   135 ; Thumb tests
   136 
   137 ; Thumb non-pc modifying
   138 ;
   139 ;
   140 RMDebug_StepTest_Thumb_Non_PC_Modifying
   141 	mov		r0, lr	; preserve lr
   142 	blx		RMDebug_StepTest_Thumb_Non_PC_Modifying_1
   143 	bx		r0
   144 
   145 ;
   146 ; Thumb Branch
   147 ;
   148 RMDebug_StepTest_Thumb_Branch
   149 	mov		r0, lr	; preserve lr
   150 	blx		RMDebug_StepTest_Thumb_Branch_1
   151 	bx		r0		
   152 
   153 ;
   154 ; Thumb Branch and link
   155 ;
   156 RMDebug_StepTest_Thumb_Branch_And_Link
   157 	mov		r0, lr	; preserve lr
   158 	blx		RMDebug_StepTest_Thumb_Branch_And_Link_1
   159 	bx		r0 
   160 
   161 ;
   162 ; Thumb Back Branch and link
   163 ;
   164 RMDebug_StepTest_Thumb_Back_Branch_And_Link
   165 	mov		r0, lr	; preserve lr
   166 	blx		RMDebug_StepTest_Thumb_Back_Branch_And_Link_1
   167 	bx		r0 
   168 
   169 ;
   170 ; Thumb ADD PC,PC, #0
   171 ;
   172 RMDebug_StepTest_Thumb_AddPC
   173 	mov		r0, lr	; preserve lr
   174 	blx		RMDebug_StepTest_Thumb_AddPC_1
   175 	bx		r0 
   176 
   177 	CODE16
   178 
   179 	; Thumb tests
   180 	EXPORT RMDebug_StepTest_Thumb_Non_PC_Modifying
   181 	EXPORT RMDebug_StepTest_Thumb_Non_PC_Modifying_1
   182 	EXPORT RMDebug_StepTest_Thumb_Non_PC_Modifying_2
   183 
   184 	EXPORT RMDebug_StepTest_Thumb_Branch
   185 	EXPORT RMDebug_StepTest_Thumb_Branch_1
   186 	EXPORT RMDebug_StepTest_Thumb_Branch_2
   187 
   188 	EXPORT RMDebug_StepTest_Thumb_Branch_And_Link
   189 	EXPORT RMDebug_StepTest_Thumb_Branch_And_Link_1
   190 	EXPORT RMDebug_StepTest_Thumb_Branch_And_Link_2
   191 	EXPORT RMDebug_StepTest_Thumb_Branch_And_Link_3
   192 
   193 	EXPORT RMDebug_StepTest_Thumb_Back_Branch_And_Link
   194 	EXPORT RMDebug_StepTest_Thumb_Back_Branch_And_Link_1
   195 	EXPORT RMDebug_StepTest_Thumb_Back_Branch_And_Link_2
   196 	EXPORT RMDebug_StepTest_Thumb_Back_Branch_And_Link_3
   197 
   198 RMDebug_StepTest_Thumb_Non_PC_Modifying_1
   199 	mov		r0, r0	; nop
   200 RMDebug_StepTest_Thumb_Non_PC_Modifying_2
   201 	bx		lr	
   202 
   203 RMDebug_StepTest_Thumb_Branch_1
   204 	b		RMDebug_StepTest_Thumb_Branch_2
   205 	mov		r0, r0
   206 RMDebug_StepTest_Thumb_Branch_2
   207 	bx		lr
   208 
   209 RMDebug_StepTest_Thumb_Branch_And_Link_1
   210 	mov		r1, lr
   211 RMDebug_StepTest_Thumb_Branch_And_Link_2
   212 	bl		RMDebug_StepTest_Thumb_Branch_And_Link_3
   213 	mov		r0, r0
   214 RMDebug_StepTest_Thumb_Branch_And_Link_3
   215 	bx		r1
   216 
   217 RMDebug_StepTest_Thumb_Back_Branch_And_Link_3
   218 	bx		r1
   219 
   220 RMDebug_StepTest_Thumb_Back_Branch_And_Link_1
   221 	mov		r1, lr
   222 RMDebug_StepTest_Thumb_Back_Branch_And_Link_2
   223 	bl		RMDebug_StepTest_Thumb_Back_Branch_And_Link_3
   224 	bx		r1
   225 
   226 ;
   227 ; ADD PC
   228 ;
   229 	EXPORT RMDebug_StepTest_Thumb_AddPC
   230 	EXPORT RMDebug_StepTest_Thumb_AddPC_1
   231 	EXPORT RMDebug_StepTest_Thumb_AddPC_2
   232 	EXPORT RMDebug_StepTest_Thumb_AddPC_3
   233 
   234 RMDebug_StepTest_Thumb_AddPC_1
   235 	mov		r1, lr
   236 	mov		r2, #4
   237 RMDebug_StepTest_Thumb_AddPC_2
   238 	add		pc, pc, r2	; should arrive at RMDebug_StepTest_Thumb_AddPC_3
   239 	mov		r0, r0
   240 	mov		r0, r0
   241 	mov		r0, r0
   242 RMDebug_StepTest_Thumb_AddPC_3
   243 	bx		r1
   244 
   245 	ALIGN 4
   246 
   247 	CODE32
   248 
   249 ;
   250 ; ARM multiple-step ( 5 steps )
   251 ;
   252 	EXPORT RMDebug_StepTest_ARM_Step_Multiple
   253 	EXPORT RMDebug_StepTest_ARM_Step_Multiple_1
   254 
   255 RMDebug_StepTest_ARM_Step_Multiple
   256 	mov		r0,r0		; nop
   257 	mov		r0,r0		; nop
   258 	mov		r0,r0		; nop
   259 	mov		r0,r0		; nop
   260 	mov		r0,r0		; nop
   261 RMDebug_StepTest_ARM_Step_Multiple_1
   262 	bx		lr
   263 
   264 	END
   265 
   266 ; End of file - d_rmdebug_bkpt.s