Home | History | Annotate | Download | only in s390x
      1 #include <stdio.h>
      2 #include<stdlib.h>
      3 #include<unistd.h>
      4 
      5 union stcke {
      6 	unsigned long buffer[2];
      7 	struct reader {
      8 		char pad;
      9 		unsigned long long time;
     10 		int time2;
     11 		short program;
     12 	} __attribute__ ((packed)) reader;
     13 };
     14 
     15 int stcke(unsigned long *addr)
     16 {
     17 
     18 	int cc;
     19 	asm volatile (	"stcke %0\n"
     20 			"ipm %1\n"
     21 			"srl %1, 28\n"
     22 		      :"+Q" (*addr), "=d"(cc)::"cc");
     23 
     24 	return cc;
     25 }
     26 
     27 unsigned long clockticks_in_msec(unsigned long b, unsigned long a)
     28 {
     29 	return (b -a ) / 4096000UL;
     30 }
     31 
     32 int main()
     33 {
     34 	union stcke start, end;
     35 	int cc;
     36 
     37 	cc = stcke(start.buffer);
     38 	if (cc)
     39 		printf("cc != 0!\n");
     40 
     41 	sleep(1);
     42 	cc = stcke(end.buffer);
     43 	if (cc)
     44 		printf("cc != 0!\n");
     45 
     46 	unsigned long c = clockticks_in_msec(end.reader.time,
     47 					     start.reader.time);
     48 
     49 	if (c >= 1000 && c < 1500)
     50 		printf("OK.....Testcase passed\n");
     51 	else
     52 		printf("FAILED.....Testcase failed\n");
     53 
     54 	return 0;
     55 
     56 }
     57