[IPMI]Set/Get global enables

Recv Message Queue and SEL are enabled by default.
Event Message buffer are disabled by default (not supported).
Any request that try to change the mask will be rejected.

Test:
test pass with ipmitool

Change-Id: Ia6bd4a6bf7b2b04dcfde6bfec910ca854a7aaeb8
Signed-off-by: Jia, Chunhui <chunhui.jia@linux.intel.com>
diff --git a/systemintfcmds.cpp b/systemintfcmds.cpp
index 4964800..00e6c51 100644
--- a/systemintfcmds.cpp
+++ b/systemintfcmds.cpp
@@ -18,6 +18,17 @@
 using cmdManagerPtr = std::unique_ptr<phosphor::host::command::Manager>;
 extern cmdManagerPtr& ipmid_get_host_cmd_manager();
 
+// global enables
+// bit0   - Message Receive Queue enable
+// bit1   - Enable Event Message Buffer Full Interrupt
+// bit2   - Enable Event Message Buffer
+// bit3   - Enable System Event Logging
+// bit4   - reserved
+// bit5-7 - OEM 0~2 enables
+static constexpr uint8_t selEnable = 0x08;
+static constexpr uint8_t recvMsgQueueEnable = 0x01;
+static constexpr uint8_t globalEnablesDefault = selEnable | recvMsgQueueEnable;
+
 //-------------------------------------------------------------------
 // Called by Host post response from Get_Message_Flags
 //-------------------------------------------------------------------
@@ -74,9 +85,9 @@
     // bit:[1] from LSB : 1b = Event Message Buffer Full.
     // Return as 0 if Event Message Buffer is not supported,
     // or when the Event Message buffer is disabled.
-    // TODO. For now. assume its not disabled and send "0x2" anyway:
+    // For now, it is not supported.
 
-    uint8_t set_event_msg_buffer_full = 0x2;
+    uint8_t set_event_msg_buffer_full = 0x0;
     *data_len = sizeof(set_event_msg_buffer_full);
 
     // Pack the actual response
@@ -85,6 +96,23 @@
     return rc;
 }
 
+ipmi_ret_t ipmi_app_get_bmc_global_enables(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)
+{
+    ipmi_ret_t rc = IPMI_CC_OK;
+    if (0 != *data_len)
+    {
+        *data_len = 0;
+        return IPMI_CC_REQ_DATA_LEN_INVALID;
+    }
+    *data_len = sizeof(globalEnablesDefault);
+    *reinterpret_cast<uint8_t*>(response) = globalEnablesDefault;
+    return rc;
+}
+
 ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
                                            ipmi_request_t request,
                                            ipmi_response_t response,
@@ -92,13 +120,22 @@
                                            ipmi_context_t context)
 {
     ipmi_ret_t rc = IPMI_CC_OK;
+
+    uint8_t reqMask = *reinterpret_cast<uint8_t*>(request);
+    if (sizeof(reqMask) != *data_len)
+    {
+        *data_len = 0;
+        return IPMI_CC_REQ_DATA_LEN_INVALID;
+    }
+
     *data_len = 0;
-
-    // Event and message logging enabled by default so return for now
-#ifdef __IPMI_DEBUG__
-    std::printf("IPMI APP SET BMC GLOBAL ENABLES Ignoring for now\n");
-#endif
-
+    // Recv Message Queue and SEL are enabled by default.
+    // Event Message buffer are disabled by default (not supported).
+    // Any request that try to change the mask will be rejected
+    if (reqMask != (selEnable | recvMsgQueueEnable))
+    {
+        return IPMI_CC_INVALID_FIELD_REQUEST;
+    }
     return rc;
 }
 
@@ -131,6 +168,10 @@
     ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_BMC_GLOBAL_ENABLES, NULL,
                            ipmi_app_set_bmc_global_enables, SYSTEM_INTERFACE);
 
+    // <Get BMC Global Enables>
+    ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_BMC_GLOBAL_ENABLES, NULL,
+                           ipmi_app_get_bmc_global_enables, SYSTEM_INTERFACE);
+
     // <Get Message Flags>
     ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS, NULL,
                            ipmi_app_get_msg_flags, SYSTEM_INTERFACE);