summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina König2020-08-21 11:34:02 +0200
committerRegina König2020-08-21 11:34:02 +0200
commit10316ef5771c3de1efbe13d2fd8f8fb62faa8a51 (patch)
tree687bf10c5762ae9ac8ccb3ef4481720c3c13b3c1
parentAm able to add a new line to file (diff)
downloadmemtest86-10316ef5771c3de1efbe13d2fd8f8fb62faa8a51.tar.gz
memtest86-10316ef5771c3de1efbe13d2fd8f8fb62faa8a51.tar.xz
memtest86-10316ef5771c3de1efbe13d2fd8f8fb62faa8a51.zip
modified ProtocolInformation.c
-rw-r--r--memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c57
1 files changed, 20 insertions, 37 deletions
diff --git a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
index 235d0b0..8f448c5 100644
--- a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
+++ b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
@@ -165,7 +165,7 @@ UefiMain (
&fileSystemInfo);
efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (bufSize) , (void **)&fileSystemInfo);
- checkStatus(efiStatus, "AllocatePool");
+ checkStatus(efiStatus, "AllocatePool"); // TODO Free pool
efiStatus = root->GetInfo(
root,
@@ -181,11 +181,16 @@ UefiMain (
efiStatus = root->Open(
root,
&token,
- L"log",
+ L"memtest_log",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
0);
checkStatus(efiStatus, "Open");
+ UINT64 currPos;
+ efiStatus = token->GetPosition(token, &currPos);
+ checkStatus(efiStatus, "GetPosition");
+ Print(L"Current File Position: %d\n", currPos);
+
UINTN fileSize = 500; // TODO get the actual size
CHAR16* fileBuffer = NULL;
efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (fileSize) , (void **)&fileBuffer);
@@ -195,8 +200,6 @@ UefiMain (
checkStatus(efiStatus, "Read");
printFileContent(fileSize, fileBuffer);
-
- UINT64 currPos;
efiStatus = token->GetPosition(token, &currPos);
checkStatus(efiStatus, "GetPosition");
Print(L"Current File Position: %d\n", currPos);
@@ -205,7 +208,9 @@ UefiMain (
UINTN length = 19;
Print(L"Lengh: %d\n", length);
- token->SetPosition(token, fileSize - 1);
+ if (fileSize >=1) {
+ token->SetPosition(token, fileSize - 1);
+ }
efiStatus = token->Write(token, &length, message);
checkStatus(efiStatus, "Write");
@@ -217,48 +222,26 @@ UefiMain (
efiStatus = token->Read(token, &fileSize, fileBuffer);
printFileContent(fileSize, fileBuffer);
+ if (fileBuffer != NULL) {
+ bs->FreePool(fileBuffer);
+ }
+
+ if (fileSystemInfo != NULL) {
+ bs->FreePool(fileSystemInfo);
+ }
+
} // end if (compareGuids(&sfspGuid, guid))
} // end for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++)
+ } // end "for (handleIndex = 0; handleIndex < handleCount; handleIndex++)"
-/*
- efiStatus = bs->FreePool((void **)&buffer);
- Print(L"efiStatus after FreePool: %r\n", efiStatus);*/
-
- if (!EFI_ERROR (efiStatus)) {
- for (OpenInfoIndex=0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- //
- // HandleBuffer[handleIndex] is the handle
- // ProtocolGuidArray[ProtocolIndex] is the protocol GUID
- // Instance is the protocol instance for the protocol
- // OpenInfo[OpenInfoIndex] is an agent that has opened a protocol
- //
- }
- /*if (OpenInfo != NULL) { // TODO Why is it crashing when using FreePool?
- bs->FreePool(OpenInfo);
- Print(L"EFI_STATUS after FreePool(OpenInfo): %r\n", efiStatus);
- }*/
- }
-
- /*if (ProtocolGuidArray != NULL) {
- bs->FreePool(ProtocolGuidArray);
- Print(L"EFI_STATUS after FreePool(ProtocolGuidArray): %r\n", efiStatus);
- }*/
-
- } // end "for (handleIndex = 0; handleIndex < handleCount; handleIndex++)"
-
- /*if (handleBuffer != NULL) {
- efiStatus = bs->FreePool(handleBuffer);
- Print(L"EFI_STATUS after FreePool(handleBuffer): %r\n", efiStatus);
- }*/
-
efiStatus = bs->LocateHandleBuffer(ByProtocol,
&sfspGuid,
NULL,
&handleCount2,
&handleBuffer2);
- Print(L"Handle count: %d\n", handleCount2);
+ Print(L"Handle count2: %d\n", handleCount2);
return EFI_SUCCESS;