summaryrefslogtreecommitdiffstats
path: root/memtestEDK
diff options
context:
space:
mode:
authorRegina König2020-08-24 01:13:10 +0200
committerRegina König2020-08-24 01:13:10 +0200
commit3d3f047338074c8d6198d35d3227d0b737370bd7 (patch)
tree4c6840845f66b6ed08008740d2402e1e800cd43f /memtestEDK
parentscreenshot with error message (diff)
downloadmemtest86-3d3f047338074c8d6198d35d3227d0b737370bd7.tar.gz
memtest86-3d3f047338074c8d6198d35d3227d0b737370bd7.tar.xz
memtest86-3d3f047338074c8d6198d35d3227d0b737370bd7.zip
final version of standalone-logger
Diffstat (limited to 'memtestEDK')
-rw-r--r--memtestEDK/Memtest/ProtocolInformation/Logger.c83
1 files changed, 47 insertions, 36 deletions
diff --git a/memtestEDK/Memtest/ProtocolInformation/Logger.c b/memtestEDK/Memtest/ProtocolInformation/Logger.c
index d41f7e5..739af65 100644
--- a/memtestEDK/Memtest/ProtocolInformation/Logger.c
+++ b/memtestEDK/Memtest/ProtocolInformation/Logger.c
@@ -19,9 +19,7 @@ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console;
EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
EFI_HANDLE* handleBuffer = NULL;
-EFI_HANDLE* handleBuffer2 = NULL; // TODO remove
UINTN handleCount = 0;
-UINTN handleCount2 = 0;
UINTN handleIndex;
EFI_GUID **ProtocolGuidArray;
@@ -35,6 +33,8 @@ UINTN OpenInfoCount;
EFI_FILE_PROTOCOL* root = NULL;
EFI_FILE_SYSTEM_INFO* fileSystemInfo = NULL;
+UINT64 currPos;
+
void printFileSystemInfo(EFI_FILE_SYSTEM_INFO* fileSystemInfo) {
Print(L"fileSystemInfo pointer %p\n", fileSystemInfo);
@@ -78,8 +78,19 @@ BOOLEAN compareGuids(EFI_GUID* sfspGuid, EFI_GUID* guid) {
return FALSE;
}
-EFI_STATUS writeToFile() {
-
+EFI_STATUS writeToFile(char* m, int l) {
+
+ Print(L"\n\nStart writeToFile to file\n");
+
+ // Append a newline symbol to the beginning
+ UINTN length = (UINTN) (l + 1);
+ char message[length];
+ message[0] = '\n';
+ for (int i = 0; i < l; i++) {
+ message[i+1] = m[i];
+ }
+
+ // Open the file
EFI_FILE_PROTOCOL* token = NULL;
efiStatus = root->Open(
root,
@@ -89,47 +100,38 @@ EFI_STATUS writeToFile() {
0);
checkStatus(efiStatus, "Open");
- UINT64 currPos;
- efiStatus = token->GetPosition(token, &currPos);
- checkStatus(efiStatus, "GetPosition");
- Print(L"Current File Position: %d\n", currPos);
-
- UINTN fileSize; // TODO get the actual size
+ /*UINTN fileSize = 80;
CHAR16* fileBuffer = NULL;
-
- efiStatus = token->Read(token, &fileSize, fileBuffer);
- checkStatus(efiStatus, "Read");
-
- Print(L"FILE SIZE: %d\n", fileSize);
-
- fileSize += 80;
efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (fileSize) , (void **)&fileBuffer);
checkStatus(efiStatus, "AllocatePool for file");
-
- Print(L"FILE SIZE2: %d\n", fileSize);
-
+ Print(L"FILE SIZE: %d\n", fileSize);
efiStatus = token->Read(token, &fileSize, fileBuffer);
checkStatus(efiStatus, "Read");
- printFileContent(fileSize, fileBuffer);
+
+ if (fileSize != 0) {
+ printFileContent(fileSize, fileBuffer);
+ }
efiStatus = token->GetPosition(token, &currPos);
checkStatus(efiStatus, "GetPosition");
Print(L"Current File Position: %d\n", currPos);
+*/
+ /*
+ if (fileSize >=1) {
+ token->SetPosition(token, fileSize-1);
+ }*/
- char message[] = "\nAdding a new line";
- UINTN length = 19;
- UINTN sizeBytes = sizeof(message);
- Print(L"size in bytes: %d\n", sizeBytes);
- Print(L"Lengh: %d\n", length);
+ Print(L"Write function starts\n");
- if (fileSize >=1) {
- token->SetPosition(token, fileSize);
- }
+ token->SetPosition(token, currPos);
efiStatus = token->Write(token, &length, message);
checkStatus(efiStatus, "Write");
- fileSize += length;
+ currPos += length;
+
+
+ /*fileSize += length;
token->SetPosition(token, 0);
@@ -138,15 +140,13 @@ EFI_STATUS writeToFile() {
if (fileBuffer != NULL) {
bs->FreePool(fileBuffer);
- }
-
- if (fileSystemInfo != NULL) {
- bs->FreePool(fileSystemInfo);
- }
+ }*/
efiStatus = token->Close(token);
checkStatus(efiStatus, "Close");
+ Print(L"End WriteToFile\n\n");
+
return efiStatus;
}
@@ -172,7 +172,9 @@ UefiMain (
);
checkStatus(efiStatus, "LocateHandleBuffer");
+ int filesystem_found = 0;
for (handleIndex = 0; handleIndex < handleCount; handleIndex++) {
+ if (filesystem_found) break;
//
// Retrieve the list of all the protocols on each handle
//
@@ -249,13 +251,22 @@ UefiMain (
//printFileSystemInfo(fileSystemInfo);
// TODO first check if it is the right filesystem. If yes, leave the for loop
+ filesystem_found = 1;
break;
} // end if (compareGuids(&sfspGuid, guid))
} // end for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++)
} // end "for (handleIndex = 0; handleIndex < handleCount; handleIndex++)"
- efiStatus = writeToFile();
+ char msg[] = "This is the first line";
+ efiStatus = writeToFile(msg, sizeof(msg));
+
+ char msg2[] = "This is the second line";
+ efiStatus = writeToFile(msg2, sizeof(msg2));
+
+ if (fileSystemInfo != NULL) {
+ bs->FreePool(fileSystemInfo);
+ }
return EFI_SUCCESS;
}