Change primary postcode interface to byte array
At least one processor implementation currently uses 9 byte post codes,
which does not fit nicely into any standard types. The backends are
changing dbus interface to be two arrays rather than a {uint64, array},
which will allow arbitrary sized postcodes[1].
[1]: https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/74633
Tested:
- Test with 9 bytes postcode system
```
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries",
"@odata.type": "#LogEntryCollection.LogEntryCollection",
"Description": "Collection of POST Code Log Entries",
"Members": [
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1",
"@odata.type": "#LogEntry.v1_9_0.LogEntry",
"Created": "2024-10-08T16:37:51.180760+00:00",
"EntryType": "Event",
"Id": "B1-1",
"Message": "Boot Count: 1; Time Stamp Offset: 0.0000 seconds; POST Code: 0x01000000000001C000",
"MessageArgs": [
"1",
"0.0000",
"0x01000000000001C000"
],
"MessageId": "OpenBMC.0.2.BIOSPOSTCode",
"Name": "POST Code Log Entry",
"Severity": "OK"
},
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-2",
"@odata.type": "#LogEntry.v1_9_0.LogEntry",
"Created": "2024-10-08T16:37:51.282429+00:00",
"EntryType": "Event",
"Id": "B1-2",
"Message": "Boot Count: 1; Time Stamp Offset: 0.1017 seconds; POST Code: 0x01000000020001C100",
"MessageArgs": [
"1",
"0.1017",
"0x01000000020001C100"
],
"MessageId": "OpenBMC.0.2.BIOSPOSTCode",
"Name": "POST Code Log Entry",
"Severity": "OK"
},
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-3",
"@odata.type": "#LogEntry.v1_9_0.LogEntry",
"Created": "2024-10-08T16:37:51.654501+00:00",
"EntryType": "Event",
"Id": "B1-3",
"Message": "Boot Count: 1; Time Stamp Offset: 0.4737 seconds; POST Code: 0x01000000010001C000",
"MessageArgs": [
"1",
"0.4737",
"0x01000000010001C000"
],
"MessageId": "OpenBMC.0.2.BIOSPOSTCode",
"Name": "POST Code Log Entry",
"Severity": "OK"
},
......
}
```
- Test attachment (secondary postcode) with maunul feed postcode
- promary: 0x010203040506070809
- secondary: 0x090807060504030201
```
root@bmc:~# busctl set-property xyz.openbmc_project.State.Boot.Raw /xyz/openbmc_project/state/boot/raw0 xyz.openbmc_project.State.Boot.Raw Value '(ayay)' 9 1 2 3 4 5 6 7 8 9 9 9 8 7 6 5 4 3 2 1
root@bmc:~# curl -u root:0penBmc -k https://127.0.0.1/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1",
"@odata.type": "#LogEntry.v1_9_0.LogEntry",
"AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment",
"Created": "2024-10-15T00:52:38.408819+00:00",
"EntryType": "Event",
"Id": "B1-1",
"Message": "Boot Count: 1; Time Stamp Offset: 0.0000 seconds; POST Code: 0x010203040506070809",
"MessageArgs": [
"1",
"0.0000",
"0x010203040506070809"
],
"MessageId": "OpenBMC.0.2.BIOSPOSTCode",
"Name": "POST Code Log Entry",
"Severity": "OK"
}
root@bmc:~# curl -u root:0penBmc -k https://127.0.0.1/redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment
CQgHBgUEAwIB
```
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: Id5e8779b191e733e6be32294d21a0a1775c48db4
diff --git a/redfish-core/lib/systems_logservices_postcodes.hpp b/redfish-core/lib/systems_logservices_postcodes.hpp
index 90782bd..f7f84c7 100644
--- a/redfish-core/lib/systems_logservices_postcodes.hpp
+++ b/redfish-core/lib/systems_logservices_postcodes.hpp
@@ -154,7 +154,8 @@
static bool fillPostCodeEntry(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const boost::container::flat_map<
- uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>& postcode,
+ uint64_t, std::tuple<std::vector<uint8_t>, std::vector<uint8_t>>>&
+ postcode,
const uint16_t bootIndex, const uint64_t codeIndex = 0,
const uint64_t skip = 0, const uint64_t top = 0)
{
@@ -168,8 +169,9 @@
}
uint64_t currentCodeIndex = 0;
uint64_t firstCodeTimeUs = 0;
- for (const std::pair<uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>&
- code : postcode)
+ for (const std::pair<uint64_t, std::tuple<std::vector<uint8_t>,
+ std::vector<uint8_t>>>& code :
+ postcode)
{
currentCodeIndex++;
std::string postcodeEntryID =
@@ -214,9 +216,6 @@
entryTimeStr = redfish::time_utils::getDateTimeUintUs(usecSinceEpoch);
// assemble messageArgs: BootIndex, TimeOffset(100us), PostCode(hex)
- std::ostringstream hexCode;
- hexCode << "0x" << std::setfill('0') << std::setw(2) << std::hex
- << std::get<0>(code.second);
std::ostringstream timeOffsetStr;
// Set Fixed -Point Notation
timeOffsetStr << std::fixed;
@@ -227,7 +226,8 @@
std::string bootIndexStr = std::to_string(bootIndex);
std::string timeOffsetString = timeOffsetStr.str();
- std::string hexCodeStr = hexCode.str();
+ std::string hexCodeStr =
+ "0x" + bytesToHexString(std::get<0>(code.second));
std::array<std::string_view, 3> messageArgs = {
bootIndexStr, timeOffsetString, hexCodeStr};
@@ -261,7 +261,7 @@
bmcLogEntry["EntryType"] = "Event";
bmcLogEntry["Severity"] = std::move(severity);
bmcLogEntry["Created"] = entryTimeStr;
- if (!std::get<std::vector<uint8_t>>(code.second).empty())
+ if (!std::get<1>(code.second).empty())
{
bmcLogEntry["AdditionalDataURI"] =
std::format(
@@ -310,8 +310,8 @@
[asyncResp, entryId, bootIndex,
codeIndex](const boost::system::error_code& ec,
const boost::container::flat_map<
- uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>&
- postcode) {
+ uint64_t, std::tuple<std::vector<uint8_t>,
+ std::vector<uint8_t>>>& postcode) {
if (ec)
{
BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
@@ -346,8 +346,8 @@
[asyncResp, bootIndex, bootCount, entryCount, skip,
top](const boost::system::error_code& ec,
const boost::container::flat_map<
- uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>&
- postcode) {
+ uint64_t, std::tuple<std::vector<uint8_t>,
+ std::vector<uint8_t>>>& postcode) {
if (ec)
{
BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
@@ -503,8 +503,8 @@
crow::connections::systemBus->async_method_call(
[asyncResp, postCodeID, currentValue](
const boost::system::error_code& ec,
- const std::vector<std::tuple<uint64_t, std::vector<uint8_t>>>&
- postcodes) {
+ const std::vector<std::tuple<std::vector<uint8_t>,
+ std::vector<uint8_t>>>& postcodes) {
if (ec.value() == EBADR)
{
messages::resourceNotFound(asyncResp->res, "LogEntry",