Imported Upstream version 1.30
[platform/upstream/x86info.git] / Intel / eblcr.c
1 /*
2  *  (C) 2001 Dave Jones.
3  *
4  *  Licensed under the terms of the GNU GPL License version 2.
5  *
6  *  Bus speed parsing.
7  */
8
9 #include <stdio.h>
10 #include "../x86info.h"
11
12 void interpret_eblcr(u32 lo)
13 {
14         const unsigned int buscode[2][4] = {
15                 { 6667, 13333, 10000, 0 },
16                 { 10000, 13333, 10000, 0 }
17         };
18
19         const unsigned int mult[32] = {
20                 10, 6, 8, 0, 11, 7, 9, 0,
21                 10, 14, 16, 12, 0, 15, 0, 13,
22                 0, 0, 0, 0, 0, 0, 17, 0,
23                 0, 0, 0, 0, 0, 0, 0, 0
24         };
25
26         int bus = (lo >> 18) & 3;
27         int mul = (lo >> 22) & 15;
28         int busclock, cpuclk;
29
30         return; /* too many bugs right now.. fix for a future release */
31
32         if (!user_is_root || !show_eblcr)
33                 return;
34
35         /*
36          * FIXME:
37          * 766MHz Celeron. 66MHz x 11.5 Being picked up as 133x5.0
38          * bus:1 mul:0
39          */
40
41 /*      printf("bus:%x mul:%x\n", bus, mul);*/
42
43         /* The mobile pIII added bit 27.
44          * This is zero on other intel and on the cyrix III */
45
46         if (lo & (1 >> 27))
47                 mul += 16;
48
49         busclock = buscode[1][bus]/100;
50
51         if (busclock == 0 || mult[mul] == 0)
52                 printf("Unknown CPU/BUS multiplier (%d X %dMHz, %x).\n", mul, bus, lo);
53
54         cpuclk = (buscode[1][bus] * mult[mul])/200;
55         printf("Bus Speed (%dMHz) x Multiplier (%.1fx) = CPU speed %dMhz\n",
56                 busclock,
57                 (float) cpuclk/busclock,
58                 cpuclk);
59 }