xref: /openbmc/smbios-mdr/include/system.hpp (revision 027277a4)
1 /*
2 // Copyright (c) 2018 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #pragma once
18 #include "smbios_mdrv2.hpp"
19 
20 #include <sdbusplus/asio/connection.hpp>
21 #include <xyz/openbmc_project/Common/UUID/server.hpp>
22 #include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
23 
24 namespace phosphor
25 {
26 
27 namespace smbios
28 {
29 
30 class System :
31     sdbusplus::server::object_t<
32         sdbusplus::server::xyz::openbmc_project::common::UUID>,
33     sdbusplus::server::object_t<
34         sdbusplus::server::xyz::openbmc_project::inventory::decorator::Revision>
35 {
36   public:
37     System() = delete;
38     ~System() = default;
39     System(const System&) = delete;
40     System& operator=(const System&) = delete;
41     System(System&&) = default;
42     System& operator=(System&&) = default;
43 
System(std::shared_ptr<sdbusplus::asio::connection> bus,std::string objPath,uint8_t * smbiosTableStorage,std::string filePath)44     System(std::shared_ptr<sdbusplus::asio::connection> bus,
45            std::string objPath, uint8_t* smbiosTableStorage,
46            std::string filePath) :
47         sdbusplus::server::object_t<
48             sdbusplus::server::xyz::openbmc_project::common::UUID>(
49             *bus, objPath.c_str()),
50         sdbusplus::server::object_t<sdbusplus::server::xyz::openbmc_project::
51                                         inventory::decorator::Revision>(
52             *bus, objPath.c_str()),
53         bus(std::move(bus)), path(std::move(objPath)),
54         storage(smbiosTableStorage), smbiosFilePath(std::move(filePath))
55     {
56         std::string input = "0";
57         uuid(input);
58         version("0.00");
59     }
60 
61     std::string uuid(std::string value) override;
62 
63     std::string version(std::string value) override;
64 
65     std::shared_ptr<sdbusplus::asio::connection> bus;
66 
67   private:
68     /** @brief Path of the group instance */
69     std::string path;
70 
71     uint8_t* storage;
72 
73     struct BIOSInfo
74     {
75         uint8_t type;
76         uint8_t length;
77         uint16_t handle;
78         uint8_t vendor;
79         uint8_t biosVersion;
80         uint16_t startAddrSegment;
81         uint8_t releaseData;
82         uint8_t romSize;
83         uint64_t characteristics;
84         uint16_t externCharacteristics;
85         uint8_t systemBIOSMajor;
86         uint8_t systemBIOSMinor;
87         uint8_t embeddedFirmwareMajor;
88         uint8_t embeddedFirmwareMinor;
89     } __attribute__((packed));
90 
91     struct UUID
92     {
93         uint32_t timeLow;
94         uint16_t timeMid;
95         uint16_t timeHiAndVer;
96         uint8_t clockSeqHi;
97         uint8_t clockSeqLow;
98         uint8_t node[6];
99     } __attribute__((packed));
100 
101     struct SystemInfo
102     {
103         uint8_t type;
104         uint8_t length;
105         uint16_t handle;
106         uint8_t manufacturer;
107         uint8_t productName;
108         uint8_t version;
109         uint8_t serialNum;
110         struct UUID uuid;
111         uint8_t wakeupType;
112         uint8_t skuNum;
113         uint8_t family;
114     } __attribute__((packed));
115 
116     std::string smbiosFilePath;
117 };
118 
119 } // namespace smbios
120 
121 } // namespace phosphor
122