[edk2-devel] [PATCH edk2-platforms 3/3] IpmiFeaturePkg: refine GetSelfTest function

Mike Maslenkin posted 3 patches 2 years, 11 months ago
There is a newer version of this series
[edk2-devel] [PATCH edk2-platforms 3/3] IpmiFeaturePkg: refine GetSelfTest function
Posted by Mike Maslenkin 2 years, 11 months ago
Use predefined type while accessing IPMI command returned data
instead of raw byte array.

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c     | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
index 8a0c596a6434..1db47e28c54e 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
@@ -86,6 +86,8 @@ Returns:
   BOOLEAN     bResultFlag = FALSE;
   UINT8       TempData[MAX_TEMP_DATA];
 
+  IPMI_SELF_TEST_RESULT_RESPONSE *pSelfTestResult;
+
   //
   // Get the SELF TEST Results.
   //
@@ -100,7 +102,8 @@ Returns:
 
   DataSize = sizeof (TempData);
 
-  TempData[1] = 0;
+  pSelfTestResult = (IPMI_SELF_TEST_RESULT_RESPONSE*)&TempData[0];
+  pSelfTestResult->CompletionCode = 0;
 
   do {
     Status = IpmiSendCommand (
@@ -114,7 +117,7 @@ Returns:
                &DataSize
                );
     if (Status == EFI_SUCCESS) {
-      switch (TempData[1]) {
+      switch (pSelfTestResult->Result) {
         case IPMI_APP_SELFTEST_NO_ERROR:
         case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:
         case IPMI_APP_SELFTEST_ERROR:
@@ -147,7 +150,7 @@ Returns:
     IpmiInstance->BmcStatus = BMC_HARDFAIL;
     return Status;
   } else {
-    DEBUG ((DEBUG_INFO, "[IPMI] BMC self-test result: %02X-%02X\n", TempData[1], TempData[2]));
+    DEBUG ((DEBUG_INFO, "[IPMI] BMC self-test result: %02X-%02X\n", pSelfTestResult->Result, pSelfTestResult->Param));
     //
     // Copy the Self test results to Error Status.  Data will be copied as long as it
     // does not exceed the size of the ErrorStatus variable.
@@ -162,7 +165,7 @@ Returns:
     // Check the IPMI defined self test results.
     // Additional Cases are device specific test results.
     //
-    switch (TempData[1]) {
+    switch (pSelfTestResult->Result) {
       case IPMI_APP_SELFTEST_NO_ERROR:
       case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:
         IpmiInstance->BmcStatus = BMC_OK;
@@ -174,7 +177,7 @@ Returns:
         // BootBlock Firmware corruption, and Operational Firmware Corruption.  All
         // other errors are BMC soft failures.
         //
-        if ((TempData[2] & (IPMI_APP_SELFTEST_FRU_CORRUPT | IPMI_APP_SELFTEST_FW_BOOTBLOCK_CORRUPT | IPMI_APP_SELFTEST_FW_CORRUPT)) != 0) {
+        if ((pSelfTestResult->Param & (IPMI_APP_SELFTEST_FRU_CORRUPT | IPMI_APP_SELFTEST_FW_BOOTBLOCK_CORRUPT | IPMI_APP_SELFTEST_FW_CORRUPT)) != 0) {
           IpmiInstance->BmcStatus = BMC_HARDFAIL;
         } else {
           IpmiInstance->BmcStatus = BMC_SOFTFAIL;
@@ -182,7 +185,7 @@ Returns:
         //
         // Check if SDR repository is empty and report it if it is.
         //
-        if ((TempData[2] & IPMI_APP_SELFTEST_SDR_REPOSITORY_EMPTY) != 0) {
+        if ((pSelfTestResult->Param & IPMI_APP_SELFTEST_SDR_REPOSITORY_EMPTY) != 0) {
           if (*ErrorCount < MAX_SOFT_COUNT) {
             StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | CU_FP_EC_SDR_EMPTY;
             (*ErrorCount)++;
-- 
2.35.3



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#100527): https://edk2.groups.io/g/devel/message/100527
Mute This Topic: https://groups.io/mt/97279450/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH edk2-platforms 3/3] IpmiFeaturePkg: refine GetSelfTest function
Posted by Isaac Oram 2 years, 11 months ago
Coding convention does not allow Hungarian notation, https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/v/release-2.20/4_naming_conventions/43_identifiers#4.3.3-hungarian-prefixes
Please change pSelfTestResult to SelfTestResult.

Thanks,
Isaac

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Mike Maslenkin
Sent: Monday, February 27, 2023 3:28 PM
To: devel@edk2.groups.io
Cc: Mike Maslenkin <mike.maslenkin@gmail.com>; Oram, Isaac W <isaac.w.oram@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [PATCH edk2-platforms 3/3] IpmiFeaturePkg: refine GetSelfTest function

Use predefined type while accessing IPMI command returned data instead of raw byte array.

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
---
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c     | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
index 8a0c596a6434..1db47e28c54e 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/
+++ IpmiInit.c
@@ -86,6 +86,8 @@ Returns:
   BOOLEAN     bResultFlag = FALSE;   UINT8       TempData[MAX_TEMP_DATA]; +  IPMI_SELF_TEST_RESULT_RESPONSE *pSelfTestResult;+   //   // Get the SELF TEST Results.   //@@ -100,7 +102,8 @@ Returns:
    DataSize = sizeof (TempData); -  TempData[1] = 0;+  pSelfTestResult = (IPMI_SELF_TEST_RESULT_RESPONSE*)&TempData[0];+  pSelfTestResult->CompletionCode = 0;    do {     Status = IpmiSendCommand (@@ -114,7 +117,7 @@ Returns:
                &DataSize                );     if (Status == EFI_SUCCESS) {-      switch (TempData[1]) {+      switch (pSelfTestResult->Result) {         case IPMI_APP_SELFTEST_NO_ERROR:         case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:         case IPMI_APP_SELFTEST_ERROR:@@ -147,7 +150,7 @@ Returns:
     IpmiInstance->BmcStatus = BMC_HARDFAIL;     return Status;   } else {-    DEBUG ((DEBUG_INFO, "[IPMI] BMC self-test result: %02X-%02X\n", TempData[1], TempData[2]));+    DEBUG ((DEBUG_INFO, "[IPMI] BMC self-test result: %02X-%02X\n", pSelfTestResult->Result, pSelfTestResult->Param));     //     // Copy the Self test results to Error Status.  Data will be copied as long as it     // does not exceed the size of the ErrorStatus variable.@@ -162,7 +165,7 @@ Returns:
     // Check the IPMI defined self test results.     // Additional Cases are device specific test results.     //-    switch (TempData[1]) {+    switch (pSelfTestResult->Result) {       case IPMI_APP_SELFTEST_NO_ERROR:       case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:         IpmiInstance->BmcStatus = BMC_OK;@@ -174,7 +177,7 @@ Returns:
         // BootBlock Firmware corruption, and Operational Firmware Corruption.  All         // other errors are BMC soft failures.         //-        if ((TempData[2] & (IPMI_APP_SELFTEST_FRU_CORRUPT | IPMI_APP_SELFTEST_FW_BOOTBLOCK_CORRUPT | IPMI_APP_SELFTEST_FW_CORRUPT)) != 0) {+        if ((pSelfTestResult->Param & (IPMI_APP_SELFTEST_FRU_CORRUPT | IPMI_APP_SELFTEST_FW_BOOTBLOCK_CORRUPT | IPMI_APP_SELFTEST_FW_CORRUPT)) != 0) {           IpmiInstance->BmcStatus = BMC_HARDFAIL;         } else {           IpmiInstance->BmcStatus = BMC_SOFTFAIL;@@ -182,7 +185,7 @@ Returns:
         //         // Check if SDR repository is empty and report it if it is.         //-        if ((TempData[2] & IPMI_APP_SELFTEST_SDR_REPOSITORY_EMPTY) != 0) {+        if ((pSelfTestResult->Param & IPMI_APP_SELFTEST_SDR_REPOSITORY_EMPTY) != 0) {           if (*ErrorCount < MAX_SOFT_COUNT) {             StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | CU_FP_EC_SDR_EMPTY;             (*ErrorCount)++;-- 
2.35.3



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#100527): https://edk2.groups.io/g/devel/message/100527
Mute This Topic: https://groups.io/mt/97279450/1492418
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [isaac.w.oram@intel.com] -=-=-=-=-=-=




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#100817): https://edk2.groups.io/g/devel/message/100817
Mute This Topic: https://groups.io/mt/97279450/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-