storagecommands:move get FRUInvAreaInfo to new API

Rewrite "get fru inv area info" cmd to new IPMI provider API.

Tested:
verified using ipmitool storage commands.
get fru inventory area info before and after the changes.

ipmitool raw 0x0a 0x10 0x0
 00 02 00

ipmitool raw 0x0a 0x10 0xff
Unable to send RAW command (channel=0x0 netfn=0xa lun=0x0 cmd=0x10
rsp=0xcc): Invalid data field in request

ipmitool raw 0x0a 0x10 0x02
Unable to send RAW command (channel=0x0 netfn=0xa lun=0x0 cmd=0x10
rsp=0xcb): Requested sensor, data, or record not found

Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I430ab2e4495b8ccf84ce811d4863b918de77995c
diff --git a/include/storagecommands.hpp b/include/storagecommands.hpp
index 48cfeef..5252576 100644
--- a/include/storagecommands.hpp
+++ b/include/storagecommands.hpp
@@ -88,13 +88,6 @@
     uint8_t countToRead;
 };
 
-struct GetFRUAreaResp
-{
-    uint8_t inventorySizeLSB;
-    uint8_t inventorySizeMSB;
-    uint8_t accessType;
-};
-
 struct WriteFRUDataReq
 {
     uint8_t fruDeviceID;
@@ -121,7 +114,6 @@
 
 enum class IPMINetfnStorageCmds : ipmi_cmd_t
 {
-    ipmiCmdGetFRUInvAreaInfo = 0x10,
     ipmiCmdReadFRUData = 0x11,
     ipmiCmdWriteFRUData = 0x12,
     ipmiCmdGetRepositoryInfo = 0x20,
diff --git a/src/storagecommands.cpp b/src/storagecommands.cpp
index 19d8dc5..39405c5 100644
--- a/src/storagecommands.cpp
+++ b/src/storagecommands.cpp
@@ -400,38 +400,33 @@
     return IPMI_CC_OK;
 }
 
-ipmi_ret_t ipmiStorageGetFRUInvAreaInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
-                                        ipmi_request_t request,
-                                        ipmi_response_t response,
-                                        ipmi_data_len_t dataLen,
-                                        ipmi_context_t context)
+/** @brief implements the get FRU inventory area info command
+ *  @param fruDeviceId  - FRU Device ID
+ *
+ *  @returns IPMI completion code plus response data
+ *   - inventorySize - Number of possible allocation units
+ *   - accessType    - Allocation unit size in bytes.
+ */
+ipmi::RspType<uint16_t, // inventorySize
+              uint8_t>  // accessType
+    ipmiStorageGetFruInvAreaInfo(uint8_t fruDeviceId)
 {
-    if (*dataLen != 1)
+    if (fruDeviceId == 0xFF)
     {
-        *dataLen = 0;
-        return IPMI_CC_REQ_DATA_LEN_INVALID;
+        return ipmi::responseInvalidFieldRequest();
     }
-    *dataLen = 0; // default to 0 in case of an error
 
-    uint8_t reqDev = *(static_cast<uint8_t*>(request));
-    if (reqDev == 0xFF)
-    {
-        return IPMI_CC_INVALID_FIELD_REQUEST;
-    }
-    ipmi_ret_t status = replaceCacheFru(reqDev);
+    ipmi::Cc status = replaceCacheFru(fruDeviceId);
 
     if (status != IPMI_CC_OK)
     {
-        return status;
+        return ipmi::response(status);
     }
 
-    GetFRUAreaResp* respPtr = static_cast<GetFRUAreaResp*>(response);
-    respPtr->inventorySizeLSB = fruCache.size() & 0xFF;
-    respPtr->inventorySizeMSB = fruCache.size() >> 8;
-    respPtr->accessType = static_cast<uint8_t>(GetFRUAreaAccessType::byte);
+    constexpr uint8_t accessType =
+        static_cast<uint8_t>(GetFRUAreaAccessType::byte);
 
-    *dataLen = sizeof(GetFRUAreaResp);
-    return IPMI_CC_OK;
+    return ipmi::responseSuccess(fruCache.size(), accessType);
 }
 
 ipmi_ret_t getFruSdrCount(size_t& count)
@@ -1030,11 +1025,9 @@
 void registerStorageFunctions()
 {
     // <Get FRU Inventory Area Info>
-    ipmiPrintAndRegister(
-        NETFUN_STORAGE,
-        static_cast<ipmi_cmd_t>(IPMINetfnStorageCmds::ipmiCmdGetFRUInvAreaInfo),
-        NULL, ipmiStorageGetFRUInvAreaInfo, PRIVILEGE_USER);
-
+    ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage,
+                          ipmi::storage::cmdGetFruInventoryAreaInfo,
+                          ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo);
     // <READ FRU Data>
     ipmiPrintAndRegister(
         NETFUN_STORAGE,