blob: 8cdcbe326681ce969b77bbe15a29d2fab6798264 [file] [log] [blame]
Cheng C Yangb4651b92019-12-19 00:59:01 +08001/*
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#include "system.hpp"
18
19#include "mdrv2.hpp"
20
21#include <iomanip>
22#include <iostream>
23#include <sstream>
24namespace phosphor
25{
26namespace smbios
27{
28
29std::string System::uUID(std::string value)
30{
31 uint8_t *dataIn = storage;
32 dataIn = getSMBIOSTypePtr(dataIn, systemType);
33 if (dataIn != nullptr)
34 {
35 auto systemInfo = reinterpret_cast<struct SystemInfo *>(dataIn);
36 std::stringstream stream;
37 stream << std::setfill('0') << std::hex;
38 stream << std::setw(8) << systemInfo->uUID.timeLow;
39 stream << "-";
40 stream << std::setw(4) << systemInfo->uUID.timeMid;
41 stream << "-";
42 stream << std::setw(4) << systemInfo->uUID.timeHiAndVer;
43 stream << "-";
44 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.clockSeqHi);
45 stream << std::setw(2)
46 << static_cast<int>(systemInfo->uUID.clockSeqLow);
47 stream << "-";
48 static_assert(sizeof(systemInfo->uUID.node) == 6);
49 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[0]);
50 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[1]);
51 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[2]);
52 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[3]);
53 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[4]);
54 stream << std::setw(2) << static_cast<int>(systemInfo->uUID.node[5]);
55
56 return sdbusplus::xyz::openbmc_project::Common::server::UUID::uUID(
57 stream.str());
58 }
59
60 return sdbusplus::xyz::openbmc_project::Common::server::UUID::uUID(
61 "00000000-0000-0000-0000-000000000000");
62}
63
64std::string System::version(std::string value)
65{
66 std::string result = "No BIOS Version";
67 uint8_t *dataIn = storage;
68 dataIn = getSMBIOSTypePtr(dataIn, biosType);
69 if (dataIn != nullptr)
70 {
71 auto biosInfo = reinterpret_cast<struct BIOSInfo *>(dataIn);
72 uint8_t biosVerByte = biosInfo->biosVersion;
73 std::string tempS =
74 positionToString(biosInfo->biosVersion, biosInfo->length, dataIn);
75 result = tempS;
76 }
77
78 return sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::
79 Revision::version(result);
80}
81
82} // namespace smbios
83} // namespace phosphor