blob: efa14f0d0389b573c5ca7df7fd78360bb6d2acd3 [file] [log] [blame]
Prithvi Pai5af42bb2025-02-11 17:59:07 +05301#pragma once
2#include "smbios_mdrv2.hpp"
3
4#include <sdbusplus/asio/connection.hpp>
5#include <xyz/openbmc_project/Association/Definitions/server.hpp>
6#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
7#include <xyz/openbmc_project/Inventory/Item/Tpm/server.hpp>
8#include <xyz/openbmc_project/Inventory/Item/server.hpp>
9#include <xyz/openbmc_project/Software/Version/server.hpp>
10
11namespace phosphor
12{
13
14namespace smbios
15{
16
17using tpm = sdbusplus::server::xyz::openbmc_project::inventory::item::Tpm;
18using asset =
19 sdbusplus::server::xyz::openbmc_project::inventory::decorator::Asset;
20using Item = sdbusplus::server::xyz::openbmc_project::inventory::Item;
21using softwareversion =
22 sdbusplus::server::xyz::openbmc_project::software::Version;
23using association =
24 sdbusplus::server::xyz::openbmc_project::association::Definitions;
25
26constexpr uint8_t tpmMajorVerion1 = 0x01;
27constexpr uint8_t tpmMajorVerion2 = 0x02;
28
29class Tpm :
30 sdbusplus::server::object_t<tpm, asset, Item, association, softwareversion>
31{
32 public:
33 Tpm() = delete;
34 ~Tpm() = default;
35 Tpm(const Tpm&) = delete;
36 Tpm& operator=(const Tpm&) = delete;
37 Tpm(Tpm&&) = default;
38 Tpm& operator=(Tpm&&) = default;
39
40 Tpm(sdbusplus::bus_t& bus, const std::string& objPath, const uint8_t tpmID,
41 uint8_t* smbiosTableStorage, const std::string& motherboard) :
42 sdbusplus::server::object_t<tpm, asset, Item, association,
43 softwareversion>(bus, objPath.c_str()),
44 tpmId(tpmID), storage(smbiosTableStorage), motherboardPath(motherboard)
45 {
46 tpmInfoUpdate(smbiosTableStorage, motherboard);
47 }
48
49 void tpmInfoUpdate(uint8_t* smbiosTableStorage,
50 const std::string& motherboard);
51
52 private:
53 uint8_t tpmId;
54
55 uint8_t* storage;
56
57 std::string motherboardPath;
58 struct TPMInfo
59 {
60 uint8_t type;
61 uint8_t length;
62 uint16_t handle;
63 char vendor[4];
64 uint8_t specMajor;
65 uint8_t specMinor;
66 uint32_t firmwareVersion1;
67 uint32_t firmwareVersion2;
68 uint8_t description;
69 uint64_t characteristics;
70 uint32_t oem;
71 } __attribute__((packed));
72
73 struct TPMVersionSpec1
74 {
75 uint8_t specMajor;
76 uint8_t specMinor;
77 uint8_t revMajor;
78 uint8_t revMinor;
79 } __attribute__((packed));
80
81 struct TPMVersionSpec2
82 {
83 uint16_t revMinor;
84 uint16_t revMajor;
85 } __attribute__((packed));
86
87 void tpmVendor(const struct TPMInfo* tpmInfo);
88 void tpmFirmwareVersion(const struct TPMInfo* tpmInfo);
89 void tpmDescription(const uint8_t positionNum, const uint8_t structLen,
90 uint8_t* dataIn);
91};
92
93} // namespace smbios
94
95} // namespace phosphor