blob: 9e4e263b88fd865faf4ce52ce8e3c6973abd4e2e [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{
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080031 uint8_t* dataIn = storage;
Cheng C Yangb4651b92019-12-19 00:59:01 +080032 dataIn = getSMBIOSTypePtr(dataIn, systemType);
33 if (dataIn != nullptr)
34 {
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080035 auto systemInfo = reinterpret_cast<struct SystemInfo*>(dataIn);
Cheng C Yangb4651b92019-12-19 00:59:01 +080036 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";
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080067 uint8_t* dataIn = storage;
Cheng C Yangb4651b92019-12-19 00:59:01 +080068 dataIn = getSMBIOSTypePtr(dataIn, biosType);
69 if (dataIn != nullptr)
70 {
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080071 auto biosInfo = reinterpret_cast<struct BIOSInfo*>(dataIn);
Cheng C Yangb4651b92019-12-19 00:59:01 +080072 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