1 #include<stdio.h> 2 #include<time.h> 3 #include<stdlib.h> 4 #include<unistd.h> 5 6 int stckf(unsigned long *addr) 7 { 8 int cc; 9 asm volatile ( ".insn s,0xb27c0000,%0\n" 10 "ipm %1\n" 11 "srl %1,28\n" 12 :"=Q" (*addr), "=d"(cc)::"memory", "cc"); 13 return cc; 14 } 15 16 unsigned long clockticks_in_msec(unsigned long b, unsigned long a) 17 { 18 return (b - a) / 4096000UL; 19 } 20 21 int main() 22 { 23 24 int cc; 25 unsigned long start, end, diff; 26 27 cc = stckf(&start); 28 if (cc) 29 printf("cc != 0!\n"); 30 sleep(1); 31 cc = stckf(&end); 32 if (cc) 33 printf("cc != 0!\n"); 34 35 diff = clockticks_in_msec(end, start); 36 if (diff >= 1000 && diff < 1500) 37 printf("OK.....Testcase passed\n"); 38 else 39 printf("FAILED.....Testcase failed\n"); 40 return 0; 41 42 } 43