2 * dump_psb. (c) 2004, Dave Jones, Red Hat Inc.
3 * Licensed under the GPL v2.
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
)
85 struct psb_header
*psb
;
86 struct pst_header
*pst
;
88 psb
= (struct psb_header
*) p
;
90 if (psb
->version
!= 0x12)
93 printf("PSB version: %hhx flags: %hhx settling time %hhuus res1 %hhx num pst %hhu\n",
99 sgtc
= psb
->settlingtime
* 100;
104 p
= ((char *) psb
) + sizeof(struct psb_header
);
107 numpst
= psb
->numpst
;
109 printf("Overriding number of pst :%d\n", numpst
);
111 for (i
= 0; i
< numpst
; i
++) {
112 pst
= (struct pst_header
*) p
;
115 if (relevant
!= pst
->cpuid
)
119 printf(" PST %d cpuid %.3x fsb %hhu mfid %hhx svid %hhx numberstates %hhu\n",
128 decode_pst(p
+ sizeof(struct pst_header
), pst
->numpstates
);
131 p
+= sizeof(struct pst_header
) + 2*pst
->numpstates
;
136 static struct option info_opts
[] = {
137 {"numpst", no_argument
, NULL
, 'n'},
140 void print_help(void)
142 printf ("Usage: dump_psb [options]\n");
143 printf ("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");
149 main(int argc
, char *argv
[])
158 ret
= getopt_long(argc
, argv
, "hr:n:", info_opts
, NULL
);
166 relevant
= strtol(optarg
, NULL
, 16);
169 numpst
= strtol(optarg
, NULL
, 10);
178 fd
= open("/dev/mem", O_RDONLY
);
180 printf ("Couldn't open /dev/mem. Are you root?\n");
184 mem
= mmap(mem
, 0x100000 - 0xc0000, PROT_READ
, MAP_SHARED
, fd
, 0xc0000);
187 for (p
= mem
; p
- mem
< LEN
; p
+=16) {
188 if (memcmp(p
, "AMDK7PNOW!", 10) == 0) {
189 decode_psb(p
, numpst
);