summaryrefslogtreecommitdiffstats
path: root/src/include/kernel/cpuid.H
blob: fa9b0649b7915ca73b92ec9d1cacf017e90f7f6e (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __KERNEL_CPUID_H
#define __KERNEL_CPUID_H

#include <arch/ppc.H>

/** @enum ProcessorCoreType
 *  @brief Enumeration of the different supported processor cores.
 */
enum ProcessorCoreType
{
        /** Base Power7 */
    POWER7,
        /** Power7+ */
    POWER7_PLUS,

        /** Power8 "Salerno" (low-end) core */
    POWER8_SALERNO,
        /** Power8 "Venice" (high-end) core */
    POWER8_VENICE,

    UNKNOWN,
};

/** @fn getCpuType()
 *  @brief Decode the processor type from the PVR register.
 *
 *  These values come from the pervasive spec for each processor.
 *
 *  @return ProcessorCoreType - Value from enumeration for this core.
 */
ALWAYS_INLINE
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.

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

        case 0x004A0000:
            return POWER7_PLUS;

        case 0x004B0000:
            return POWER8_VENICE;

        default:
            return UNKNOWN;
    }
}

/** @fn getCpuDD
 *  @brief Decode the processor DD level from the PVR register.
 *
 *  These offsets come from the pervasive spec for each processor.
 *
 *  @return 1 byte DD level as <major nibble, minor nibble>.
 */
ALWAYS_INLINE
uint8_t getCpuDD()
{
    uint64_t l_pvr = getPVR();
    return ((l_pvr & 0x0F00) >> 4) | (l_pvr & 0x000F);
}

#endif
OpenPOWER on IntegriCloud