summaryrefslogtreecommitdiffstats
path: root/src/kernel/cpuid.C
blob: bbbe71190dc8c0311fc8ee370b3808c98666026e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/** @file cpuid.C
 *  Implementation of the cpuid functions.
 */

#include <kernel/cpuid.H>

namespace CpuID
{
    ProcessorCoreType getCpuType()
    {
        uint64_t l_pvr = getPVR();

        // Layout of the PVR is (32-bit):
        //     2 nibbles reserved.
        //     2 nibbles chip type.
        //     1 nibble technology.
        //     1 nibble major DD.
        //     1 nibble reserved.
        //     1 nibble minor DD.

        // TODO: Salerno PVR support.

        switch(l_pvr & 0xFFFF0000)
        {
            case 0x003F0000:
                return CORE_POWER7;

            case 0x004A0000:
                return CORE_POWER7_PLUS;

            case 0x004B0000:
                return CORE_POWER8_VENICE;

            default:
                return CORE_UNKNOWN;
        }
    }

    uint8_t getCpuDD()
    {
        uint64_t l_pvr = getPVR();
        return ((l_pvr & 0x0F00) >> 4) | (l_pvr & 0x000F);
    }
};


OpenPOWER on IntegriCloud