mirror of https://github.com/acidanthera/audk.git
MdeModulePkg VariableInfo: Use fixed buffer for smm comm buffer
Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
fd3fac0fb2
commit
faf3de9bd0
|
@ -3,7 +3,7 @@
|
||||||
this utility will print out the statistics information. You can use console
|
this utility will print out the statistics information. You can use console
|
||||||
redirection to capture the data.
|
redirection to capture the data.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include <Guid/VariableFormat.h>
|
#include <Guid/VariableFormat.h>
|
||||||
#include <Guid/SmmVariableCommon.h>
|
#include <Guid/SmmVariableCommon.h>
|
||||||
|
#include <Guid/PiSmmCommunicationRegionTable.h>
|
||||||
#include <Protocol/SmmCommunication.h>
|
#include <Protocol/SmmCommunication.h>
|
||||||
#include <Protocol/SmmVariable.h>
|
#include <Protocol/SmmVariable.h>
|
||||||
|
|
||||||
|
@ -86,6 +87,11 @@ PrintInfoFromSmm (
|
||||||
UINTN CommSize;
|
UINTN CommSize;
|
||||||
SMM_VARIABLE_COMMUNICATE_HEADER *FunctionHeader;
|
SMM_VARIABLE_COMMUNICATE_HEADER *FunctionHeader;
|
||||||
EFI_SMM_VARIABLE_PROTOCOL *Smmvariable;
|
EFI_SMM_VARIABLE_PROTOCOL *Smmvariable;
|
||||||
|
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
|
||||||
|
UINT32 Index;
|
||||||
|
EFI_MEMORY_DESCRIPTOR *Entry;
|
||||||
|
UINTN Size;
|
||||||
|
UINTN MaxSize;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **) &Smmvariable);
|
Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **) &Smmvariable);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
@ -97,30 +103,47 @@ PrintInfoFromSmm (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
|
CommBuffer = NULL;
|
||||||
RealCommSize = CommSize;
|
Status = EfiGetSystemConfigurationTable (
|
||||||
CommBuffer = AllocateZeroPool (CommSize);
|
&gEdkiiPiSmmCommunicationRegionTableGuid,
|
||||||
|
(VOID **) &PiSmmCommunicationRegionTable
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||||
|
Entry = (EFI_MEMORY_DESCRIPTOR *) (PiSmmCommunicationRegionTable + 1);
|
||||||
|
Size = 0;
|
||||||
|
MaxSize = 0;
|
||||||
|
for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
|
||||||
|
if (Entry->Type == EfiConventionalMemory) {
|
||||||
|
Size = EFI_PAGES_TO_SIZE ((UINTN) Entry->NumberOfPages);
|
||||||
|
if (Size > (SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (VARIABLE_INFO_ENTRY))) {
|
||||||
|
if (Size > MaxSize) {
|
||||||
|
MaxSize = Size;
|
||||||
|
RealCommSize = MaxSize;
|
||||||
|
CommBuffer = (EFI_SMM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Entry = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||||
|
}
|
||||||
ASSERT (CommBuffer != NULL);
|
ASSERT (CommBuffer != NULL);
|
||||||
|
ZeroMem (CommBuffer, RealCommSize);
|
||||||
|
|
||||||
Print (L"Non-Volatile SMM Variables:\n");
|
Print (L"Non-Volatile SMM Variables:\n");
|
||||||
do {
|
do {
|
||||||
|
CommSize = RealCommSize;
|
||||||
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
FreePool (CommBuffer);
|
Print (L"The generic SMM communication buffer provided by SmmCommunicationRegionTable is too small\n");
|
||||||
CommBuffer = AllocateZeroPool (CommSize);
|
return Status;
|
||||||
ASSERT (CommBuffer != NULL);
|
|
||||||
RealCommSize = CommSize;
|
|
||||||
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status) || (CommSize <= SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE)) {
|
if (EFI_ERROR (Status) || (CommSize <= SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommSize < RealCommSize) {
|
|
||||||
CommSize = RealCommSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
||||||
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
||||||
|
|
||||||
|
@ -138,25 +161,19 @@ PrintInfoFromSmm (
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
|
|
||||||
Print (L"Volatile SMM Variables:\n");
|
Print (L"Volatile SMM Variables:\n");
|
||||||
ZeroMem (CommBuffer, CommSize);
|
ZeroMem (CommBuffer, RealCommSize);
|
||||||
do {
|
do {
|
||||||
|
CommSize = RealCommSize;
|
||||||
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
FreePool (CommBuffer);
|
Print (L"The generic SMM communication buffer provided by SmmCommunicationRegionTable is too small\n");
|
||||||
CommBuffer = AllocateZeroPool (CommSize);
|
return Status;
|
||||||
ASSERT (CommBuffer != NULL);
|
|
||||||
RealCommSize = CommSize;
|
|
||||||
Status = GetVariableStatisticsData (CommBuffer, &CommSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status) || (CommSize <= SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE)) {
|
if (EFI_ERROR (Status) || (CommSize <= SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommSize < RealCommSize) {
|
|
||||||
CommSize = RealCommSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
||||||
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
||||||
|
|
||||||
|
@ -173,7 +190,6 @@ PrintInfoFromSmm (
|
||||||
}
|
}
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
|
|
||||||
FreePool (CommBuffer);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,10 +265,10 @@ UefiMain (
|
||||||
} while (VariableInfo != NULL);
|
} while (VariableInfo != NULL);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Print (L"Warning: Variable Dxe driver doesn't enable the feature of statistical information!\n");
|
Print (L"Warning: Variable Dxe/Smm driver doesn't enable the feature of statistical information!\n");
|
||||||
Print (L"If you want to see this info, please:\n");
|
Print (L"If you want to see this info, please:\n");
|
||||||
Print (L" 1. Set PcdVariableCollectStatistics as TRUE\n");
|
Print (L" 1. Set PcdVariableCollectStatistics as TRUE\n");
|
||||||
Print (L" 2. Rebuild Variable Dxe driver\n");
|
Print (L" 2. Rebuild Variable Dxe/Smm driver\n");
|
||||||
Print (L" 3. Run \"VariableInfo\" cmd again\n");
|
Print (L" 3. Run \"VariableInfo\" cmd again\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
#
|
#
|
||||||
# This application can display statistical information about variable usage for SMM variable
|
# This application can display statistical information about variable usage for SMM variable
|
||||||
# driver and non-SMM variable driver.
|
# driver and non-SMM variable driver.
|
||||||
# Note that if Variable Dxe driver doesn't enable the feature by setting PcdVariableCollectStatistics
|
# Note that if Variable Dxe/Smm driver doesn't enable the feature by setting PcdVariableCollectStatistics
|
||||||
# as TRUE, the application will not display variable statistical information.
|
# as TRUE, the application will not display variable statistical information.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
# which accompanies this distribution. The full text of the license may be found at
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -53,8 +53,9 @@
|
||||||
gEfiSmmVariableProtocolGuid
|
gEfiSmmVariableProtocolGuid
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiAuthenticatedVariableGuid ## SOMETIMES_CONSUMES ## SystemTable
|
gEfiAuthenticatedVariableGuid ## SOMETIMES_CONSUMES ## SystemTable
|
||||||
gEfiVariableGuid ## CONSUMES ## SystemTable
|
gEfiVariableGuid ## SOMETIMES_CONSUMES ## SystemTable
|
||||||
|
gEdkiiPiSmmCommunicationRegionTableGuid ## SOMETIMES_CONSUMES ## SystemTable
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
[UserExtensions.TianoCore."ExtraFiles"]
|
||||||
VariableInfoExtra.uni
|
VariableInfoExtra.uni
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
//
|
//
|
||||||
// This application can display statistical information about variable usage for SMM variable
|
// This application can display statistical information about variable usage for SMM variable
|
||||||
// driver and non-SMM variable driver.
|
// driver and non-SMM variable driver.
|
||||||
// Note that if Variable Dxe driver doesn't enable the feature by setting PcdVariableCollectStatistics
|
// Note that if Variable Dxe/Smm driver doesn't enable the feature by setting PcdVariableCollectStatistics
|
||||||
// as TRUE, the application will not display variable statistical information.
|
// as TRUE, the application will not display variable statistical information.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
// Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
//
|
//
|
||||||
// This program and the accompanying materials
|
// This program and the accompanying materials
|
||||||
// are licensed and made available under the terms and conditions of the BSD License
|
// are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -20,5 +20,5 @@
|
||||||
|
|
||||||
#string STR_MODULE_ABSTRACT #language en-US "A shell application that displays statistical information about variable usage"
|
#string STR_MODULE_ABSTRACT #language en-US "A shell application that displays statistical information about variable usage"
|
||||||
|
|
||||||
#string STR_MODULE_DESCRIPTION #language en-US "This application can display statistical information about variable usage for SMM variable driver and non-SMM variable driver. Note that if Variable DXE driver doesn't enable the feature by setting PcdVariableCollectStatistics as TRUE, the application will not display variable statistical information."
|
#string STR_MODULE_DESCRIPTION #language en-US "This application can display statistical information about variable usage for SMM variable driver and non-SMM variable driver. Note that if Variable DXE/SMM driver doesn't enable the feature by setting PcdVariableCollectStatistics as TRUE, the application will not display variable statistical information."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue