Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <math.h>
0003 #include <unistd.h>
0004 #include <stdio.h>
0005 #include <stdlib.h>
0006 #include <sys/types.h>
0007 #include <sys/stat.h>
0008 #include <fcntl.h>
0009 #include <sys/timeb.h>
0010 #include <sched.h>
0011 #include <errno.h>
0012 
0013 
0014 int main(int argc, char **argv) {
0015     int cpu, fd;
0016     long long msr;
0017     char msr_file_name[64];
0018 
0019     if (argc != 2)
0020         return 1;
0021 
0022     errno = 0;
0023     cpu = strtol(argv[1], (char **) NULL, 10);
0024 
0025     if (errno)
0026         return 1;
0027 
0028     sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
0029     fd = open(msr_file_name, O_RDONLY);
0030 
0031     if (fd == -1) {
0032         perror("Failed to open");
0033         return 1;
0034     }
0035 
0036     pread(fd, &msr,  sizeof(msr), 0x199);
0037 
0038     printf("msr 0x199: 0x%llx\n", msr);
0039     return 0;
0040 }