8 /* Register contents after executing an TRE insn */
19 tre_regs
tre(uint8_t *codepage
, uint8_t *addr
, uint64_t len
, uint8_t test_byte
)
24 register uint64_t param
asm("0") = test_byte
;
25 register uint64_t a2
asm ("4") = (uint64_t)codepage
;
26 register uint64_t a1
asm ("2") = (uint64_t)addr
;
27 register uint64_t l1
asm ("3") = len
;
33 : "=d"(cc
), "+a"(a1
), "+a"(a2
), "+a"(l1
), "+d"(param
)
39 regs
.testbyte
= param
;
45 void run_test(void *tran_table
, void *srcaddr
, uint64_t len
, uint8_t test
)
50 regs
= tre(tran_table
, srcaddr
, len
, test
);
52 if ((uint64_t)tran_table
!= regs
.tabaddr
)
53 printf("translation table address changed\n");
54 if (test
!= regs
.testbyte
)
55 printf("test byte changed\n");
56 if ((uint64_t)srcaddr
+ (len
- regs
.len
) != regs
.addr
)
57 printf("source address/length not updated properly\n");
59 printf("Resulting cc is %"PRIu64
" and the string is ", regs
.cc
);
60 for ( i
= 0; i
< len
; i
++) {
61 printf("%c", buff
[i
]);
70 /* Test 1: length = 0 */
71 run_test(NULL
, NULL
, 0, 0x0);
72 run_test((char *)&touppercase
, &buff
, 0, 0x0);
73 run_test((char *)&touppercase
, &buff
, 0, 'b');
75 /* Test 2 : length > 0 */
77 run_test((char *)&touppercase
, &buff
, 1, 'a'); //cc = 1
78 run_test((char *)&touppercase
, &buff
, 1, 'b');
80 memcpy(buff
, "abcdefgh", 8);
81 run_test((char *)&touppercase
, &buff
, 3, 'a'); //cc = 1
82 run_test((char *)&touppercase
, &buff
, 3, 'f'); //cc = 0
83 run_test((char *)&touppercase
, &buff
, 8, 'l'); //cc = 0
85 memcpy(buff
, "ABCDEFGH", 8);
86 run_test((char *)&tolowercase
, &buff
, 3, 'A'); // cc = 1
87 run_test((char *)&tolowercase
, &buff
, 3, 'C'); // cc = 0
88 run_test((char *)&tolowercase
, &buff
, 8, 0x0); // cc = 0
90 memcpy(buff
, "01234567", 8);
91 run_test((char *)&touppercase
, &buff
, 8, 'A');
92 run_test((char *)&tolowercase
, &buff
, 8, 'A');