ShellPkg: Refine the code logic of 'command history'.
Add the PCD to PcdShellMaxHistoryCommandCount indicate the max count of history commands. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19520 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1288,13 +1288,40 @@ AddLineToCommandHistory(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
BUFFER_LIST *Node;
|
BUFFER_LIST *Node;
|
||||||
|
BUFFER_LIST *Walker;
|
||||||
|
UINT16 MaxHistoryCmdCount;
|
||||||
|
UINT16 Count;
|
||||||
|
|
||||||
|
Count = 0;
|
||||||
|
MaxHistoryCmdCount = PcdGet16(PcdShellMaxHistoryCommandCount);
|
||||||
|
|
||||||
|
if (MaxHistoryCmdCount == 0) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Node = AllocateZeroPool(sizeof(BUFFER_LIST));
|
Node = AllocateZeroPool(sizeof(BUFFER_LIST));
|
||||||
ASSERT(Node != NULL);
|
ASSERT(Node != NULL);
|
||||||
Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer);
|
Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer);
|
||||||
ASSERT(Node->Buffer != NULL);
|
ASSERT(Node->Buffer != NULL);
|
||||||
|
|
||||||
InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
|
for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)
|
||||||
|
; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
|
||||||
|
; Walker = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
|
||||||
|
){
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
if (Count < MaxHistoryCmdCount){
|
||||||
|
InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
|
||||||
|
} else {
|
||||||
|
Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link);
|
||||||
|
RemoveEntryList(&Walker->Link);
|
||||||
|
if (Walker->Buffer != NULL) {
|
||||||
|
FreePool(Walker->Buffer);
|
||||||
|
}
|
||||||
|
FreePool(Walker);
|
||||||
|
InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,18 +95,19 @@
|
|||||||
gEfiDevicePathProtocolGuid ## CONSUMES
|
gEfiDevicePathProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupportOldProtocols ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellSupportOldProtocols ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellRequireHiiPlatform ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellRequireHiiPlatform ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupportFrameworkHii ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellSupportFrameworkHii ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellPageBreakDefault ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellPageBreakDefault ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellInsertModeDefault ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellInsertModeDefault ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellScreenLogCount ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellScreenLogCount ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellForceConsole ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellForceConsole ## CONSUMES
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupplier ## CONSUMES
|
gEfiShellPkgTokenSpaceGuid.PcdShellSupplier ## CONSUMES
|
||||||
|
gEfiShellPkgTokenSpaceGuid.PcdShellMaxHistoryCommandCount ## CONSUMES
|
||||||
|
|
||||||
[BuildOptions.AARCH64]
|
[BuildOptions.AARCH64]
|
||||||
# The tiny code model used by AARCH64 only supports binaries of up to 1 MB in
|
# The tiny code model used by AARCH64 only supports binaries of up to 1 MB in
|
||||||
|
@ -101,6 +101,9 @@
|
|||||||
|
|
||||||
## This determines how many bytes are read out of files at a time for file operations (type, copy, etc...)
|
## This determines how many bytes are read out of files at a time for file operations (type, copy, etc...)
|
||||||
gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x1000|UINT32|0x0000000A
|
gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x1000|UINT32|0x0000000A
|
||||||
|
|
||||||
|
## This determines the max count of history commands
|
||||||
|
gEfiShellPkgTokenSpaceGuid.PcdShellMaxHistoryCommandCount|0x0020|UINT16|0x00000014
|
||||||
|
|
||||||
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
|
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
|
||||||
## This flag is used to control the protocols produced by the shell
|
## This flag is used to control the protocols produced by the shell
|
||||||
|
Reference in New Issue
Block a user