Hi Everyone.
I'm doing some tests related to the GOP and graphical applications.
What I've seeing is that after calling the GOP->BLT several times the
available memory from the system decrease.
For example. When the system just boot I have the following at the uefi
shell memmap command:
reserved : 124 Pages (507,904)
LoaderCode: 186 Pages (761,856)
LoaderData: 24 Pages (98,304)
BS_code : 1,719 Pages (7,041,024)
BS_data : 10,774 Pages (44,130,304)
RT_code : 256 Pages (1,048,576)
RT_data : 660 Pages (2,703,360)
*available : 407,184 Pages (1,667,825,664)*
ACPI_recl : 96 Pages (393,216)
ACPI_NVS : 129 Pages (528,384)
MemMapIO : 1 Pages (4,096)
Total Memory: 1,644 MB (1,724,530,688) Bytes
After executing a sample application that just draw a white box 10 times, I
have the following:
reserved : 124 Pages (507,904)
LoaderCode: 186 Pages (761,856)
LoaderData: 24 Pages (98,304)
BS_code : 1,719 Pages (7,041,024)
BS_data : 10,776 Pages (44,138,496)
RT_code : 256 Pages (1,048,576)
RT_data : 660 Pages (2,703,360)
* available : 407,182 Pages (1,667,817,472)*
ACPI_recl : 96 Pages (393,216)
ACPI_NVS : 129 Pages (528,384)
MemMapIO : 1 Pages (4,096)
Total Memory: 1,644 MB (1,724,530,688) Bytes
So the situation is that on a Graphical UEFI application, there is a
possibility of getting too much memory.
As much as I execute the application the available memory keeps decreasing.
Could someone please help me to find some problem on the sample application
code ?
"
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
#include <Library/PrintLib.h>
#include <Library/DebugLib.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/EdidActive.h>
#define BoxWidth 100
#define BoxHeight 100
EFI_STATUS PrintImage(EFI_HANDLE ImageHandle, UINTN ImagePositionX, UINTN
ImagePositionY){
UINTN Size;
EFI_STATUS Status;
UINTN HandleIndex = 0;
EFI_HANDLE *HandleArray = NULL;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicProtocol = NULL;
EFI_GUID gGraphicalProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GUID gEdidActivated = EFI_EDID_ACTIVE_PROTOCOL_GUID;
EFI_EDID_ACTIVE_PROTOCOL *EdidActivated = NULL;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* inMemoryImage = NULL;
Status = gBS->LocateHandleBuffer(ByProtocol,
&gEfiGraphicsOutputProtocolGuid,
NULL,
&Size,
&HandleArray);
if(!EFI_ERROR(Status))
{
for(HandleIndex=0; HandleIndex<Size; HandleIndex++)
{
Status = gBS->OpenProtocol(HandleArray[HandleIndex],
&gGraphicalProtocol,
(VOID**) &GraphicProtocol,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
if(EFI_ERROR(Status)){
gBS->CloseProtocol(HandleArray[HandleIndex],
&gGraphicalProtocol,
ImageHandle,
NULL);
GraphicProtocol = NULL;
continue;
} else {
// Verifies if current handle corresponds to current video
Status = gBS->OpenProtocol(HandleArray[HandleIndex],
&gEdidActivated,
(VOID**) &EdidActivated,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
if(EFI_ERROR(Status)){
gBS->CloseProtocol(HandleArray[HandleIndex],
&gGraphicalProtocol,
ImageHandle,
NULL);
GraphicProtocol = NULL;
gBS->CloseProtocol(HandleArray[HandleIndex],
&gEdidActivated,
ImageHandle,
NULL);
EdidActivated = NULL;
continue;
} else {
break;
}
}
}
if(!EFI_ERROR(Status))
{
Status = gBS->AllocatePool(EfiBootServicesData,
sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
BoxWidth * BoxHeight,
&inMemoryImage);
if(!EFI_ERROR(Status))
{
gBS->SetMem(inMemoryImage,
sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
BoxWidth * BoxHeight,
0xFF);
Status = GraphicProtocol->Blt(GraphicProtocol,
inMemoryImage,
EfiBltBufferToVideo,
0,
0,
ImagePositionX,
ImagePositionY,
BoxWidth,
BoxHeight,
0);
if(EFI_ERROR(Status)){
Print(L"Fail to print Image");
goto CLEAR;
}
} else {
Print(L"Fail to allocate buffer");
goto CLEAR;
}
}else{
Print(L"Fail to locate GraphicIoProtocol devices");
goto CLEAR;
}
}
CLEAR:
if(inMemoryImage != NULL) {
FreePool(inMemoryImage);
inMemoryImage = NULL;
}
if(GraphicProtocol != NULL) {
Status = gBS->CloseProtocol(HandleArray[HandleIndex],
&gGraphicalProtocol,
ImageHandle,
NULL);
GraphicProtocol = NULL;
}
if(EdidActivated != NULL) {
Status = gBS->CloseProtocol(HandleArray[HandleIndex],
&gEdidActivated,
ImageHandle,
NULL);
EdidActivated = NULL;
}
if(HandleArray != NULL) {
FreePool(HandleArray);
HandleArray = NULL;
}
return Status;
}
EFI_STATUS testMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
return PrintImage(ImageHandle, 50, 50);
}
"
Any help will be really useful.
Thanks and Regards
Rafael R. Machado
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel