1# Blackfin testcase for hardware single stepping
2# mach: bfin
3# sim: --environment operating
4
5#include "test.h"
6	.include "testutils.inc"
7
8	start
9
10	# Set up exception handler
11	imm32 P4, EVT3;
12	loadsym R1, _evx;
13	[P4] = R1;
14
15	# Enable single stepping
16	R0 = 1;
17	SYSCFG = R0;
18
19	# Lower to the code we want to single step through
20	R1 = 1;
21	imm32 R5, 0xffff
22	R6 = 0;
23	R7 = 0;
24	loadsym R1, _usr;
25	RETI = R1;
26	RTI;
27
28_usr:
29	# Single step and set a new bit every time
30	BITSET (R7, 0);
31	BITSET (R7, 1);
32	BITSET (R7, 2);
33	BITSET (R7, 3);
34	BITSET (R7, 4);
35	BITSET (R7, 5);
36	BITSET (R7, 6);
37	BITSET (R7, 7);
38	BITSET (R7, 8);
39	BITSET (R7, 9);
40	BITSET (R7, 10);
41	BITSET (R7, 11);
42	BITSET (R7, 12);
43	BITSET (R7, 13);
44	BITSET (R7, 14);
45	BITSET (R7, 15);
46	JUMP fail_lvl;
47
48_evx:
49	# Make sure exception reason is single step
50	R3 = SEQSTAT;
51	R4 = 0x3f;
52	R3 = R3 & R4;
53	R4 = 0x10;
54	CC = R3 == R4;
55	IF !CC JUMP fail_lvl;
56
57	# Set a new bit in R6 every single step to match R7
58	CC = R1;
59	R6 = ROT R6 BY 1;
60	CC = R6 == R7;
61	IF !CC JUMP fail_lvl;
62
63	# Do it through each bit
64	CC = R5 == R6;
65	IF CC JUMP pass_lvl;
66
67	RTX;
68
69pass_lvl:
70	dbg_pass;
71fail_lvl:
72	dbg_fail;
73