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 : : : "r7", "p0", "p1", "p2", "p3"); 30 } 31 32 int main() 33 { 34 int err = 0; 35 unsigned int i = 100000; 36 struct sigaction act; 37 struct itimerspec it; 38 timer_t tid; 39 struct sigevent sev; 40 41 act.sa_sigaction = sig_user; 42 sigemptyset(&act.sa_mask); 43 act.sa_flags = SA_SIGINFO; 44 sigaction(SIGUSR1, &act, NULL); 45 sev.sigev_notify = SIGEV_SIGNAL; 46 sev.sigev_signo = SIGUSR1; 47 sev.sigev_value.sival_ptr = &tid; 48 timer_create(CLOCK_REALTIME, &sev, &tid); 49 it.it_interval.tv_sec = 0; 50 it.it_interval.tv_nsec = 100000; 51 it.it_value.tv_sec = 0; 52 it.it_value.tv_nsec = 100000; 53 timer_settime(tid, 0, &it, NULL); 54 55 asm("loop0(1f, %1)\n\t" 56 "1: r8 = #0xff\n\t" 57 " p0 = r8\n\t" 58 " p1 = r8\n\t" 59 " p2 = r8\n\t" 60 " p3 = r8\n\t" 61 " jump 3f\n\t" 62 "2: memb(%0) = #1\n\t" 63 " jump 4f\n\t" 64 "3:\n\t" 65 " r8 = p0\n\t" 66 " p0 = cmp.eq(r8, #0xff)\n\t" 67 " if (!p0) jump 2b\n\t" 68 " r8 = p1\n\t" 69 " p0 = cmp.eq(r8, #0xff)\n\t" 70 " if (!p0) jump 2b\n\t" 71 " r8 = p2\n\t" 72 " p0 = cmp.eq(r8, #0xff)\n\t" 73 " if (!p0) jump 2b\n\t" 74 " r8 = p3\n\t" 75 " p0 = cmp.eq(r8, #0xff)\n\t" 76 " if (!p0) jump 2b\n\t" 77 "4: {}: endloop0\n\t" 78 : 79 : "r"(&err), "r"(i) 80 : "memory", "r8", "p0", "p1", "p2", "p3"); 81 82 puts(err ? "FAIL" : "PASS"); 83 return err; 84 } 85