17 #define LEN (0x100000 - 0xc0000)
18 #define OFFSET (0xc0000)
21 #define __packed __attribute((packed))
26 static const int fid_to_mult[32] = {
27 110, 115, 120, 125, 50, 55, 60, 65,
28 70, 75, 80, 85, 90, 95, 100, 105,
29 30, 190, 40, 200, 130, 135, 140, 210,
30 150, 225, 160, 165, 170, 180, -1, -1,
33 static const int vid_to_voltage[32] = {
34 2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650,
35 1600, 1550, 1500, 1450, 1400, 1350, 1300, 0,
36 1275, 1250, 1225, 1200, 1175, 1150, 1125, 1100,
37 1075, 1050, 1024, 1000, 975, 950, 925, 0,
61 decode_pst(
char *
p,
int npstates)
66 for (i = 0; i < npstates; ++
i) {
69 freq = 100 * fid_to_mult[
fid] * fsb;
71 printf(
" %2d %8dkHz FID %02x (%2d.%01d) VID %02x (%4dmV)\n",
74 fid, fid_to_mult[fid]/10, fid_to_mult[fid]%10,
75 vid, vid_to_voltage[vid]);
82 void decode_psb(
char *
p,
int numpst)
93 printf(
"PSB version: %hhx flags: %hhx settling time %hhuus res1 %hhx num pst %hhu\n",
104 p = ((
char *) psb) +
sizeof(
struct psb_header);
109 printf(
"Overriding number of pst :%d\n", numpst);
111 for (i = 0; i <
numpst; i++) {
115 if (relevant!= pst->
cpuid)
119 printf(
" PST %d cpuid %.3x fsb %hhu mfid %hhx svid %hhx numberstates %hhu\n",
136 static struct option info_opts[] = {
137 {.name =
"numpst", .has_arg=no_argument, .flag=
NULL, .val=
'n'},
142 printf (
"Usage: dump_psb [options]\n");
144 printf (
" -n, --numpst Set number of PST tables to scan\n");
145 printf (
" -r, --relevant Only display PSTs relevant to cpuid N\n");
158 ret = getopt_long(argc, argv,
"hr:n:", info_opts,
NULL);
166 relevant = strtol(optarg,
NULL, 16);
169 numpst = strtol(optarg,
NULL, 10);
180 printf (
"Couldn't open /dev/mem. Are you root?\n");
187 for (p = mem; p - mem <
LEN; p+=16) {
188 if (
memcmp(p,
"AMDK7PNOW!", 10) == 0) {
189 decode_psb(p, numpst);