summaryrefslogtreecommitdiff
path: root/include/cpu.hpp
blob: 953c54909e76e8602fbbab9b1bc8cb9f06b4cc8f (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
// Copyright (c) 2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

#pragma once
#include "smbios.hpp"


#include <xyz/openbmc_project/Association/Definitions/server.hpp>
#include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp>
#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
#include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
#include <xyz/openbmc_project/Inventory/Item/server.hpp>

namespace phosphor
{

namespace smbios
{

using rev = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision;
using asset = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset;
using location = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::LocationCode;
using connector = sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot;
using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
using Item = sdbusplus::xyz::openbmc_project::Inventory::server::Item;
using association = sdbusplus::xyz::openbmc_project::Association::server::Definitions;

// Definition follow smbios spec DSP0134 3.0.0
static const std::map<uint8_t, std::string> cpuTypeTable = {
    {0x1, "Other"},          {0x2, "Unknown"},       {0x3, "Central Processor"},
    {0x4, "Math Processor"}, {0x5, "DSP Processor"}, {0x6, "Vodeo Processor"},
};

// Definition follow smbios spec DSP0134 3.0.0
static const std::map<uint8_t, std::string> familyTable = {
    {0x1, "Other"},
    {0x2, "Unknown"},
    {0x10, "Pentium II Xeon processor"},
    {0xa1, "Quad-Core Intel Xeon processor 3200 Series"},
    {0xa2, "Dual-Core Intel Xeon processor 3000 Series"},
    {0xa3, "Quad-Core Intel Xeon processor 5300 Series"},
    {0xa4, "Dual-Core Intel Xeon processor 5100 Series"},
    {0xa5, "Dual-Core Intel Xeon processor 5000 Series"},
    {0xa6, "Dual-Core Intel Xeon processor LV"},
    {0xa7, "Dual-Core Intel Xeon processor ULV"},
    {0xa8, "Dual-Core Intel Xeon processor 7100 Series"},
    {0xa9, "Quad-Core Intel Xeon processor 5400 Series"},
    {0xaa, "Quad-Core Intel Xeon processor"},
    {0xab, "Dual-Core Intel Xeon processor 5200 Series"},
    {0xac, "Dual-Core Intel Xeon processor 7200 Series"},
    {0xad, "Quad-Core Intel Xeon processor 7300 Series"},
    {0xae, "Quad-Core Intel Xeon processor 7400 Series"},
    {0xaf, "Multi-Core Intel Xeon processor 7400 Series"},
    {0xb0, "Pentium III Xeon processor"},
    {0xb3, "Intel Xeon processor"},
    {0xb5, "Intel Xeon processor MP"},
    {0xd6, "Multi-Core Intel Xeon processor"},
    {0xd7, "Dual-Core Intel Xeon processor 3xxx Series"},
    {0xd8, "Quad-Core Intel Xeon processor 3xxx Series"},
    {0xd9, "VIA Nano Processor Family"},
    {0xda, "Dual-Core Intel Xeon processor 5xxx Series"},
    {0xdb, "Quad-Core Intel Xeon processor 5xxx Series"},
    {0xdd, "Dual-Core Intel Xeon processor 7xxx Series"},
    {0xde, "Quad-Core Intel Xeon processor 7xxx Series"},
    {0xdf, "Multi-Core Intel Xeon processor 7xxx Series"},
    {0xe0, "Multi-Core Intel Xeon processor 3400 Series"}

};

// Definition follow smbios spec DSP0134 3.0.0
static const std::array<std::optional<processor::Capability>, 16>
    characteristicsTable{std::nullopt,
                         std::nullopt,
                         processor::Capability::Capable64bit,
                         processor::Capability::MultiCore,
                         processor::Capability::HardwareThread,
                         processor::Capability::ExecuteProtection,
                         processor::Capability::EnhancedVirtualization,
                         processor::Capability::PowerPerformanceControl,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt,
                         std::nullopt};

class Cpu : sdbusplus::server::object_t<processor, asset, location, connector, rev,
                                Item, association>
{
  public:
    Cpu() = delete;
    Cpu(const Cpu &) = delete;
    Cpu &operator=(const Cpu &) = delete;
    Cpu(Cpu &&) = delete;
    Cpu &operator=(Cpu &&) = delete;
    ~Cpu() = default;

    Cpu(sdbusplus::bus::bus &bus, const std::string &objPath,
        const uint8_t &cpuId, struct ManagedDataRegion *region) :

        sdbusplus::server::object_t<processor, asset, location, connector, rev,
                                    Item, association>(bus, objPath.c_str()),
        cpuNum(cpuId), regionS(region)
    {
        processorInfoUpdate();
    }

    void processorInfoUpdate(void);

    std::string processorSocket(std::string value);
    std::string processorType(std::string value);
    std::string processorFamily(std::string value);
    std::string processorManufacturer(std::string value);
    uint32_t processorId(uint32_t value);
    std::string processorVersion(std::string value);
    uint16_t processorMaxSpeed(uint16_t value);
    std::string processorCharacteristics(std::string value) ;
    uint16_t processorCoreCount(uint16_t value);
    uint16_t processorThreadCount(uint16_t value);

  private:
    /** @brief Path of the group instance */
    uint8_t cpuNum;

    struct ManagedDataRegion *regionS;

    struct ProcessorInfo
    {
        uint8_t type;
        uint8_t length;
        uint16_t handle;
        uint8_t socketDesignation;
        uint8_t processorType;
        uint8_t family;
        uint8_t manufacturer;
        uint64_t id;
        uint8_t version;
        uint8_t voltage;
        uint16_t exClock;
        uint16_t maxSpeed;
        uint16_t currSpeed;
        uint8_t status;
        uint8_t upgrade;
        uint16_t l1Handle;
        uint16_t l2Handle;
        uint16_t l3Handle;
        uint8_t serialNum;
        uint8_t assetTag;
        uint8_t partNum;
        uint8_t coreCount;
        uint8_t coreEnable;
        uint8_t threadCount;
        uint16_t characteristics;
        uint16_t family2;
        uint16_t coreCount2;
        uint16_t coreEnable2;
        uint16_t threadCount2;
    } __attribute__((packed));

    void cpuSocket(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn);
    void cpuType(uint8_t value);
    void cpuFamily(uint8_t value);
    void cpuManufacturer(uint8_t positionNum, uint8_t structLen,
                         uint8_t *dataIn);
    void cpuVersion(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn);
    void cpuCharacteristics(uint16_t value);
};

} // namespace smbios

} // namespace phosphor