xref: /openbmc/qemu/tests/tcg/s390x/exrl-trt.c (revision f0984d40)
1 #include <stdint.h>
2 #include <unistd.h>
3 
4 int main(void)
5 {
6     char op1[] = "hello";
7     char op2[256];
8     register uint64_t r1 asm("r1") = 0xffffffffffffffffull;
9     register uint64_t r2 asm("r2") = 0xffffffffffffffffull;
10     uint64_t cc;
11     int i;
12 
13     for (i = 0; i < 256; i++) {
14         if (i == 0) {
15             op2[i] = 0xaa;
16         } else {
17             op2[i] = 0;
18         }
19     }
20     asm volatile(
21         "    j 2f\n"
22         "1:  trt 0(1,%[op1]),%[op2]\n"
23         "2:  exrl %[op1_len],1b\n"
24         "    ipm %[cc]\n"
25         : [r1] "+r" (r1),
26           [r2] "+r" (r2),
27           [cc] "=r" (cc)
28         : [op1] "a" (&op1),
29           [op1_len] "a" (5),
30           [op2] "Q" (op2)
31         : "cc");
32     cc = (cc >> 28) & 3;
33     if (cc != 2) {
34         write(1, "bad cc\n", 7);
35         return 1;
36     }
37     if ((char *)r1 != &op1[5]) {
38         write(1, "bad r1\n", 7);
39         return 1;
40     }
41     if (r2 != 0xffffffffffffffaaull) {
42         write(1, "bad r2\n", 7);
43         return 1;
44     }
45     return 0;
46 }
47