meta-yosemitev2: add system get/set guid support

Added get/set system GUID command for multi host YosemiteV2,
it reads/writes guid to the corresponding hosts Bridge IC(BIC).

Tested:

Verified this with host reboot(BIOS automatically
sends get GUID command to BMC).

Verified this ipmitool.
 Get System GUID:
 ipmitool raw 60x37

 Set System GUID:
 ipmitool raw 0x30 0xEF 0 252 109 1 0 135 236 73 26
 54 249 84 1 1 80 7 8

Signed-off-by: Manikandan Elumalai <manikandan.hcl.ers.epl@gmail.com>
Change-Id: I4d24a2fb4bf98f38afd7c0d07df0005c22535d48
diff --git a/src/appcommands.cpp b/src/appcommands.cpp
index 52eceb3..e8571ce 100644
--- a/src/appcommands.cpp
+++ b/src/appcommands.cpp
@@ -25,6 +25,8 @@
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
+#include <ipmid/api.hpp>
+#include <ipmid/api-types.hpp>
 
 #include <fstream>
 #include <iomanip>
@@ -46,6 +48,9 @@
 static SysInfoParam sysInfoParams;
 nlohmann::json appData __attribute__((init_priority(101)));
 
+int sendBicCmd(uint8_t, uint8_t, uint8_t, std::vector<uint8_t>&,
+               std::vector<uint8_t>&);
+
 void printGUID(uint8_t* guid, off_t offset)
 {
     std::cout << "Read GUID from offset : " << offset << " :\n";
@@ -200,6 +205,22 @@
 //----------------------------------------------------------------------
 // Get System GUID (CMD_APP_GET_SYS_GUID)
 //----------------------------------------------------------------------
+#if BIC_ENABLED
+ipmi::RspType<std::vector<uint8_t>>
+    ipmiAppGetSysGUID(ipmi::Context::ptr ctx, std::vector<uint8_t> reqData)
+
+{
+    std::vector<uint8_t> respData;
+
+    uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2;
+
+    if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, reqData, respData))
+        return ipmi::responseUnspecifiedError();
+
+    return ipmi::responseSuccess(respData);
+}
+
+#else
 ipmi_ret_t ipmiAppGetSysGUID(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
                              ipmi_request_t request, ipmi_response_t response,
                              ipmi_data_len_t data_len, ipmi_context_t context)
@@ -213,6 +234,8 @@
     return IPMI_CC_OK;
 }
 
+#endif
+
 //----------------------------------------------------------------------
 // Platform specific functions for storing app data
 //----------------------------------------------------------------------
@@ -442,9 +465,15 @@
     ipmiPrintAndRegister(NETFUN_APP, CMD_APP_CLEAR_MESSAGE_FLAGS, NULL,
                          ipmiAppClearMsgFlags,
                          PRIVILEGE_USER); // Clear Message flags
+#if BIC_ENABLED
+    ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnApp,
+                          ipmi::app::cmdGetSystemGuid, ipmi::Privilege::User,
+                          ipmiAppGetSysGUID);
+#else
     ipmiPrintAndRegister(NETFUN_APP, CMD_APP_GET_SYS_GUID, NULL,
                          ipmiAppGetSysGUID,
                          PRIVILEGE_USER); // Get System GUID
+#endif
     ipmiPrintAndRegister(NETFUN_APP, CMD_APP_SET_SYS_INFO_PARAMS, NULL,
                          ipmiAppSetSysInfoParams,
                          PRIVILEGE_USER); // Set Sys Info Params