Path: blob/master/tools/testing/selftests/intel_pstate/msr.c
26285 views
// SPDX-License-Identifier: GPL-2.01#include <math.h>2#include <unistd.h>3#include <stdio.h>4#include <stdlib.h>5#include <sys/types.h>6#include <sys/stat.h>7#include <fcntl.h>8#include <sys/timeb.h>9#include <sched.h>10#include <errno.h>111213int main(int argc, char **argv) {14int cpu, fd;15long long msr;16char msr_file_name[64];1718if (argc != 2)19return 1;2021errno = 0;22cpu = strtol(argv[1], (char **) NULL, 10);2324if (errno)25return 1;2627sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);28fd = open(msr_file_name, O_RDONLY);2930if (fd == -1) {31perror("Failed to open");32return 1;33}3435pread(fd, &msr, sizeof(msr), 0x199);3637printf("msr 0x199: 0x%llx\n", msr);38return 0;39}404142