* [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9
@ 2020-06-09 13:41 Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 1/2] Silicon/Hisilicon/Smbios: correct coding style issue in " Ming Huang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ming Huang @ 2020-06-09 13:41 UTC (permalink / raw)
To: devel, leif, ard.biesheuvel
Cc: lidongzhan, huangming23, songdongkuang, wanghuiqiang, qiuliangen,
shenlimei, xiewenyi2
Main change since v1:
1 Add some commit messages.
Ming Huang (2):
Silicon/Hisilicon/Smbios: correct coding style issue in type 9
Silicon/Hisilicon/Smbios: Optimize type 9
Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c | 325 +++++++++++---------
1 file changed, 174 insertions(+), 151 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH edk2-platforms v2 1/2] Silicon/Hisilicon/Smbios: correct coding style issue in type 9
2020-06-09 13:41 [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9 Ming Huang
@ 2020-06-09 13:41 ` Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 2/2] Silicon/Hisilicon/Smbios: Optimize " Ming Huang
2020-06-16 14:32 ` [edk2-devel] [PATCH edk2-platforms v2 0/2] Optimize Smbios " Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Ming Huang @ 2020-06-09 13:41 UTC (permalink / raw)
To: devel, leif, ard.biesheuvel
Cc: lidongzhan, huangming23, songdongkuang, wanghuiqiang, qiuliangen,
shenlimei, xiewenyi2
The main changes are whitespace/indentation fixing and wrapping
of long lines and changing some macros from EFI_D_ERROR to DEBUG_ERROR.
This patch is prepare for optimizing Smbios type 9.
Signed-off-by: Ming Huang <huangming23@huawei.com>
---
Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c | 286 ++++++++++----------
1 file changed, 146 insertions(+), 140 deletions(-)
diff --git a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
index 87a06a2..2398c6b 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
+++ b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+* Copyright (c) 2015 - 2020, Hisilicon Limited. All rights reserved.
* Copyright (c) 2015, Linaro Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -14,178 +14,184 @@ extern UINT8 OemGetPcieSlotNumber ();
VOID
EFIAPI
-UpdateSmbiosType9Info(
+UpdateSmbiosType9Info (
IN OUT SMBIOS_TABLE_TYPE9 *Type9Record
)
{
- EFI_STATUS Status;
- UINTN HandleIndex;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN SegmentNumber;
- UINTN BusNumber;
- UINTN DeviceNumber;
- UINTN FunctionNumber;
- UINTN Index;
- REPORT_PCIEDIDVID2BMC ReportPcieDidVid[PCIEDEVICE_REPORT_MAX];
-
- GetPciDidVid ((VOID *) ReportPcieDidVid);
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if(EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, " Locate gEfiPciIoProtocol Failed.\n"));
- gBS->FreePool ((VOID *)HandleBuffer);
- return;
+ EFI_STATUS Status;
+ UINTN HandleIndex;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINTN SegmentNumber;
+ UINTN BusNumber;
+ UINTN DeviceNumber;
+ UINTN FunctionNumber;
+ UINTN Index;
+ REPORT_PCIEDIDVID2BMC ReportPcieDidVid[PCIEDEVICE_REPORT_MAX];
+
+ GetPciDidVid ((VOID *)ReportPcieDidVid);
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, " Locate gEfiPciIoProtocol Failed.\n"));
+ gBS->FreePool ((VOID *)HandleBuffer);
+ return;
+ }
+
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[HandleIndex],
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciIo
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Status : %r\n", __FUNCTION__, __LINE__, Status));
+ continue;
}
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- Status = gBS->HandleProtocol (
- HandleBuffer[HandleIndex],
- &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo
- );
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] Status : %r\n", __FUNCTION__, __LINE__, Status));
- continue;
- }
- (VOID)PciIo->GetLocation(PciIo, &SegmentNumber, &BusNumber, &DeviceNumber, &FunctionNumber);
- for(Index = 0; Index < sizeof(ReportPcieDidVid) / sizeof(REPORT_PCIEDIDVID2BMC); Index++){
- if (Type9Record->SlotID == ReportPcieDidVid[Index].Slot + 1) {
- if((BusNumber == ReportPcieDidVid[Index].Bus) && (DeviceNumber == ReportPcieDidVid[Index].Device)) {
- DEBUG((EFI_D_ERROR,"PCIe device plot in slot Seg %d bdf %d %d %d\r\n",SegmentNumber,BusNumber,DeviceNumber,FunctionNumber));
- Type9Record->SegmentGroupNum = SegmentNumber;
- Type9Record->BusNum = BusNumber;
- Type9Record->DevFuncNum = (DeviceNumber << 3) | FunctionNumber;
- Type9Record->CurrentUsage = SlotUsageInUse;
- break;
- }
- }
+ (VOID)PciIo->GetLocation (PciIo, &SegmentNumber, &BusNumber, &DeviceNumber, &FunctionNumber);
+ for (Index = 0; Index < sizeof(ReportPcieDidVid) / sizeof(REPORT_PCIEDIDVID2BMC); Index++) {
+ if (Type9Record->SlotID == ReportPcieDidVid[Index].Slot + 1) {
+ if ((BusNumber == ReportPcieDidVid[Index].Bus) && (DeviceNumber == ReportPcieDidVid[Index].Device)) {
+ DEBUG ((DEBUG_ERROR, "PCIe device plot in slot Seg %d bdf %d %d %d\r\n",
+ SegmentNumber, BusNumber, DeviceNumber, FunctionNumber));
+ Type9Record->SegmentGroupNum = SegmentNumber;
+ Type9Record->BusNum = BusNumber;
+ Type9Record->DevFuncNum = (DeviceNumber << 3) | FunctionNumber;
+ Type9Record->CurrentUsage = SlotUsageInUse;
+ break;
}
+ }
}
- gBS->FreePool ((VOID *)HandleBuffer);
- return;
+ }
+
+ gBS->FreePool ((VOID *)HandleBuffer);
+ return;
}
+
EFI_STATUS
EFIAPI
AddSmbiosType9Entry (
IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- EFI_SMBIOS_TYPE SmbiosType;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_PROTOCOL *Smbios;
- EFI_SMBIOS_TABLE_HEADER *Record;
- SMBIOS_TABLE_TYPE9 *Type9Record;
- SMBIOS_TABLE_TYPE9 *SmbiosRecord = NULL;
- CHAR8 *OptionalStrStart;
-
- UINT8 SmbiosAddType9Number;
- UINT8 Index;
-
- CHAR16 *SlotDesignation = NULL;
- UINTN SlotDesignationStrLen;
-
- Status = gBS->LocateProtocol (
+ EFI_STATUS Status;
+ EFI_SMBIOS_TYPE SmbiosType;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ SMBIOS_TABLE_TYPE9 *Type9Record;
+ SMBIOS_TABLE_TYPE9 *SmbiosRecord = NULL;
+ CHAR8 *OptionalStrStart;
+
+ UINT8 SmbiosAddType9Number;
+ UINT8 Index;
+
+ CHAR16 *SlotDesignation = NULL;
+ UINTN SlotDesignationStrLen;
+
+ Status = gBS->LocateProtocol (
&gEfiSmbiosProtocolGuid,
NULL,
(VOID **) &Smbios
);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] LocateProtocol Failed. Status : %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] LocateProtocol Failed. Status : %r\n",
+ __FUNCTION__, __LINE__, Status));
+ return Status;
+ }
+
+ do {
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ SmbiosType = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;
+ Status = Smbios->GetNext (Smbios, &SmbiosHandle, &SmbiosType, &Record, NULL);
+ if (!EFI_ERROR (Status)) {
+ Status = Smbios->Remove (Smbios, SmbiosHandle);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Remove System Slot Failed. Status : %r\n",
+ __FUNCTION__, __LINE__, Status));
+ break;
+ }
}
+ } while (SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED);
- do {
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- SmbiosType = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;
- Status = Smbios->GetNext (Smbios, &SmbiosHandle, &SmbiosType, &Record, NULL);
- if (!EFI_ERROR(Status)) {
- Status = Smbios->Remove (Smbios, SmbiosHandle);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] Remove System Slot Failed. Status : %r\n", __FUNCTION__, __LINE__, Status));
- break;
- }
- }
- } while (SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED);
-
- SmbiosAddType9Number = OemGetPcieSlotNumber();
+ SmbiosAddType9Number = OemGetPcieSlotNumber ();
- for (Index = 0; Index < SmbiosAddType9Number; Index++)
- {
- if (gPcieSlotInfo[Index].Hdr.Type != EFI_SMBIOS_TYPE_SYSTEM_SLOTS)
- {
- continue;
- }
-
- Type9Record = &gPcieSlotInfo[Index];
-
- UpdateSmbiosType9Info (Type9Record);
- SlotDesignation = AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH);
- if (NULL == SlotDesignation)
- {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n", __FUNCTION__, __LINE__, Status));
-
- goto Exit;
- }
+ for (Index = 0; Index < SmbiosAddType9Number; Index++) {
+ if (gPcieSlotInfo[Index].Hdr.Type != EFI_SMBIOS_TYPE_SYSTEM_SLOTS) {
+ continue;
+ }
- SlotDesignationStrLen = UnicodeSPrint (SlotDesignation, SMBIOS_STRING_MAX_LENGTH - 1, L"PCIE Slot%d", Type9Record->SlotID);
+ Type9Record = &gPcieSlotInfo[Index];
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);
- if(NULL == SmbiosRecord)
- {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n", __FUNCTION__, __LINE__, Status));
+ UpdateSmbiosType9Info (Type9Record);
+ SlotDesignation = AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH);
+ if (SlotDesignation == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n",
+ __FUNCTION__, __LINE__, Status));
- goto Exit;
- }
+ goto Exit;
+ }
- (VOID)CopyMem(SmbiosRecord, Type9Record, sizeof (SMBIOS_TABLE_TYPE9));
+ SlotDesignationStrLen = UnicodeSPrint (
+ SlotDesignation,
+ SMBIOS_STRING_MAX_LENGTH - 1,
+ L"PCIE Slot%d",
+ Type9Record->SlotID);
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);
+ if (SmbiosRecord == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n",
+ __FUNCTION__, __LINE__, Status));
+
+ goto Exit;
+ }
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
+ (VOID)CopyMem (SmbiosRecord, Type9Record, sizeof (SMBIOS_TABLE_TYPE9));
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
- UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord);
- if(EFI_ERROR(Status))
- {
- DEBUG((EFI_D_ERROR, "[%a]:[%dL] Smbios Type09 Table Log Failed! %r \n", __FUNCTION__, __LINE__, Status));
- goto Exit;
- }
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+ UnicodeStrToAsciiStr (SlotDesignation, OptionalStrStart);
- FreePool(SmbiosRecord);
- FreePool(SlotDesignation);
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type09 Table Log Failed! %r \n",
+ __FUNCTION__, __LINE__, Status));
+ goto Exit;
}
- return EFI_SUCCESS;
+ FreePool (SmbiosRecord);
+ FreePool (SlotDesignation);
+ }
+
+ return EFI_SUCCESS;
Exit:
- if(SmbiosRecord != NULL)
- {
- FreePool(SmbiosRecord);
- }
+ if(SmbiosRecord != NULL) {
+ FreePool (SmbiosRecord);
+ }
- if(SlotDesignation != NULL)
- {
- FreePool(SlotDesignation);
- }
+ if(SlotDesignation != NULL) {
+ FreePool (SlotDesignation);
+ }
- return Status;
+ return Status;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH edk2-platforms v2 2/2] Silicon/Hisilicon/Smbios: Optimize type 9
2020-06-09 13:41 [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9 Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 1/2] Silicon/Hisilicon/Smbios: correct coding style issue in " Ming Huang
@ 2020-06-09 13:41 ` Ming Huang
2020-06-16 14:32 ` [edk2-devel] [PATCH edk2-platforms v2 0/2] Optimize Smbios " Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Ming Huang @ 2020-06-09 13:41 UTC (permalink / raw)
To: devel, leif, ard.biesheuvel
Cc: lidongzhan, huangming23, songdongkuang, wanghuiqiang, qiuliangen,
shenlimei, xiewenyi2
Break down AddSmbiosType9Entry to three funtions for optimizing
Smbios type 9.
Signed-off-by: Ming Huang <huangming23@huawei.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
---
Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c | 173 +++++++++++---------
1 file changed, 95 insertions(+), 78 deletions(-)
diff --git a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
index 2398c6b..57e049a 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
+++ b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c
@@ -75,38 +75,16 @@ UpdateSmbiosType9Info (
return;
}
-EFI_STATUS
-EFIAPI
-AddSmbiosType9Entry (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+STATIC
+VOID
+EmptySmbiosType9 (
+ EFI_SMBIOS_PROTOCOL *Smbios
)
{
EFI_STATUS Status;
EFI_SMBIOS_TYPE SmbiosType;
EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_PROTOCOL *Smbios;
EFI_SMBIOS_TABLE_HEADER *Record;
- SMBIOS_TABLE_TYPE9 *Type9Record;
- SMBIOS_TABLE_TYPE9 *SmbiosRecord = NULL;
- CHAR8 *OptionalStrStart;
-
- UINT8 SmbiosAddType9Number;
- UINT8 Index;
-
- CHAR16 *SlotDesignation = NULL;
- UINTN SlotDesignationStrLen;
-
- Status = gBS->LocateProtocol (
- &gEfiSmbiosProtocolGuid,
- NULL,
- (VOID **) &Smbios
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "[%a]:[%dL] LocateProtocol Failed. Status : %r\n",
- __FUNCTION__, __LINE__, Status));
- return Status;
- }
do {
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
@@ -122,76 +100,115 @@ AddSmbiosType9Entry (
}
} while (SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED);
- SmbiosAddType9Number = OemGetPcieSlotNumber ();
+ return;
+}
- for (Index = 0; Index < SmbiosAddType9Number; Index++) {
- if (gPcieSlotInfo[Index].Hdr.Type != EFI_SMBIOS_TYPE_SYSTEM_SLOTS) {
- continue;
- }
+STATIC
+EFI_STATUS
+AddSmbiosType9Record (
+ EFI_SMBIOS_PROTOCOL *Smbios,
+ SMBIOS_TABLE_TYPE9 *Type9Record
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_TABLE_TYPE9 *SmbiosRecord;
+ CHAR8 *OptionalStrStart;
+ CHAR16 SlotDesignation[SMBIOS_STRING_MAX_LENGTH];
+ UINTN SlotStrLen;
+
+ SlotStrLen = UnicodeSPrint (
+ SlotDesignation,
+ SMBIOS_STRING_MAX_LENGTH * 2,
+ L"PCIE Slot%d",
+ Type9Record->SlotID);
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE9) + SlotStrLen + 1 + 1);
+ if (SmbiosRecord == NULL) {
+ DEBUG ((DEBUG_ERROR, "AllocateZeroPool Failed for SmbiosRecord.\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
- Type9Record = &gPcieSlotInfo[Index];
+ (VOID)CopyMem (SmbiosRecord, Type9Record, sizeof (SMBIOS_TABLE_TYPE9));
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+ (VOID)UnicodeStrToAsciiStr (SlotDesignation, OptionalStrStart);
- UpdateSmbiosType9Info (Type9Record);
- SlotDesignation = AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH);
- if (SlotDesignation == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((DEBUG_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n",
- __FUNCTION__, __LINE__, Status));
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Add Smbios Type09 Failed! %r\n", Status));
+ }
- goto Exit;
- }
+ FreePool (SmbiosRecord);
+ return Status;
+}
- SlotDesignationStrLen = UnicodeSPrint (
- SlotDesignation,
- SMBIOS_STRING_MAX_LENGTH - 1,
- L"PCIE Slot%d",
- Type9Record->SlotID);
-
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);
- if (SmbiosRecord == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- DEBUG ((DEBUG_ERROR, "[%a]:[%dL] AllocateZeroPool Failed. Status : %r\n",
- __FUNCTION__, __LINE__, Status));
+STATIC
+VOID
+HandleSmbiosType9 (
+ EFI_SMBIOS_PROTOCOL *Smbios
+ )
+{
+ EFI_STATUS Status;
+ SMBIOS_TABLE_TYPE9 *Type9Record;
+ UINT8 RecordCount;
+ UINT8 Index;
- goto Exit;
- }
+ RecordCount = OemGetPcieSlotNumber ();
+ if (RecordCount == 0) {
+ return;
+ }
- (VOID)CopyMem (SmbiosRecord, Type9Record, sizeof (SMBIOS_TABLE_TYPE9));
+ EmptySmbiosType9 (Smbios);
+ Status = EFI_SUCCESS;
+ for (Index = 0; Index < RecordCount; Index++) {
+ if (gPcieSlotInfo[Index].Hdr.Type != EFI_SMBIOS_TYPE_SYSTEM_SLOTS) {
+ continue;
+ }
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
+ Type9Record = &gPcieSlotInfo[Index];
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
- UnicodeStrToAsciiStr (SlotDesignation, OptionalStrStart);
+ UpdateSmbiosType9Info (Type9Record);
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord);
+ Status = AddSmbiosType9Record (Smbios, Type9Record);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type09 Table Log Failed! %r \n",
- __FUNCTION__, __LINE__, Status));
- goto Exit;
+ break;
}
-
- FreePool (SmbiosRecord);
- FreePool (SlotDesignation);
}
- return EFI_SUCCESS;
+ return;
+}
-Exit:
- if(SmbiosRecord != NULL) {
- FreePool (SmbiosRecord);
- }
+EFI_STATUS
+EFIAPI
+AddSmbiosType9Entry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_PROTOCOL *Smbios;
- if(SlotDesignation != NULL) {
- FreePool (SlotDesignation);
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID **) &Smbios
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[%a]:[%dL] LocateProtocol Failed. Status : %r\n",
+ __FUNCTION__, __LINE__, Status));
+ return Status;
}
+ HandleSmbiosType9 (Smbios);
+
return Status;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9
2020-06-09 13:41 [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9 Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 1/2] Silicon/Hisilicon/Smbios: correct coding style issue in " Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 2/2] Silicon/Hisilicon/Smbios: Optimize " Ming Huang
@ 2020-06-16 14:32 ` Leif Lindholm
2 siblings, 0 replies; 4+ messages in thread
From: Leif Lindholm @ 2020-06-16 14:32 UTC (permalink / raw)
To: devel, huangming23
Cc: ard.biesheuvel, lidongzhan, songdongkuang, wanghuiqiang,
qiuliangen, shenlimei, xiewenyi2
On Tue, Jun 09, 2020 at 21:41:06 +0800, Ming Huang wrote:
> Main change since v1:
> 1 Add some commit messages.
For the series:
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Pushed as c764551258ee..1c1506e2b28a
> Ming Huang (2):
> Silicon/Hisilicon/Smbios: correct coding style issue in type 9
> Silicon/Hisilicon/Smbios: Optimize type 9
>
> Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.c | 325 +++++++++++---------
> 1 file changed, 174 insertions(+), 151 deletions(-)
>
> --
> 2.8.1
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-16 14:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-09 13:41 [PATCH edk2-platforms v2 0/2] Optimize Smbios type 9 Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 1/2] Silicon/Hisilicon/Smbios: correct coding style issue in " Ming Huang
2020-06-09 13:41 ` [PATCH edk2-platforms v2 2/2] Silicon/Hisilicon/Smbios: Optimize " Ming Huang
2020-06-16 14:32 ` [edk2-devel] [PATCH edk2-platforms v2 0/2] Optimize Smbios " Leif Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox