master
c 101 lines 2.92 KB
Raw
1 /*
2 * Copyright(c) 2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdio.h>
19 #include <signal.h>
20 #include <time.h>
21
22 void sig_user(int sig, siginfo_t *info, void *puc)
23 {
24 asm("r7 = #0\n\t"
25 "p0 = r7\n\t"
26 "p1 = r7\n\t"
27 "p2 = r7\n\t"
28 "p3 = r7\n\t"
29 "r6 = #0x12345678\n\t"
30 "cs0 = r6\n\t"
31 "r6 = #0x87654321\n\t"
32 "cs1 = r6\n\t"
33 : : : "r6", "r7", "p0", "p1", "p2", "p3", "cs0", "cs1");
34 }
35
36 int main()
37 {
38 int err = 0;
39 unsigned int i = 100000;
40 struct sigaction act;
41 struct itimerspec it;
42 timer_t tid;
43 struct sigevent sev;
44
45 act.sa_sigaction = sig_user;
46 sigemptyset(&act.sa_mask);
47 act.sa_flags = SA_SIGINFO;
48 sigaction(SIGUSR1, &act, NULL);
49 sev.sigev_notify = SIGEV_SIGNAL;
50 sev.sigev_signo = SIGUSR1;
51 sev.sigev_value.sival_ptr = &tid;
52 timer_create(CLOCK_REALTIME, &sev, &tid);
53 it.it_interval.tv_sec = 0;
54 it.it_interval.tv_nsec = 100000;
55 it.it_value.tv_sec = 0;
56 it.it_value.tv_nsec = 100000;
57 timer_settime(tid, 0, &it, NULL);
58
59 asm("loop0(1f, %1)\n\t"
60 "1: r9 = #0xdeadbeef\n\t"
61 " cs0 = r9\n\t"
62 " r9 = #0xbadc0fee\n\t"
63 " cs1 = r9\n\t"
64 " r8 = #0xff\n\t"
65 " p0 = r8\n\t"
66 " p1 = r8\n\t"
67 " p2 = r8\n\t"
68 " p3 = r8\n\t"
69 " jump 3f\n\t"
70 "2: memb(%0) = #1\n\t"
71 " jump 4f\n\t"
72 "3:\n\t"
73 " r8 = p0\n\t"
74 " p0 = cmp.eq(r8, #0xff)\n\t"
75 " if (!p0) jump 2b\n\t"
76 " r8 = p1\n\t"
77 " p0 = cmp.eq(r8, #0xff)\n\t"
78 " if (!p0) jump 2b\n\t"
79 " r8 = p2\n\t"
80 " p0 = cmp.eq(r8, #0xff)\n\t"
81 " if (!p0) jump 2b\n\t"
82 " r8 = p3\n\t"
83 " p0 = cmp.eq(r8, #0xff)\n\t"
84 " if (!p0) jump 2b\n\t"
85 " r8 = cs0\n\t"
86 " r9 = #0xdeadbeef\n\t"
87 " p0 = cmp.eq(r8, r9)\n\t"
88 " if (!p0) jump 2b\n\t"
89 " r8 = cs1\n\t"
90 " r9 = #0xbadc0fee\n\t"
91 " p0 = cmp.eq(r8, r9)\n\t"
92 " if (!p0) jump 2b\n\t"
93 "4: {}: endloop0\n\t"
94 :
95 : "r"(&err), "r"(i)
96 : "memory", "r8", "r9", "p0", "p1", "p2", "p3", "cs0", "cs1", "lc0",
97 "sa0");
98
99 puts(err ? "FAIL" : "PASS");
100 return err;
101 }