summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina König2020-08-20 23:33:23 +0200
committerRegina König2020-08-20 23:33:23 +0200
commit269966925ec62706a18444bc45d2b9590bc6f5ca (patch)
tree0c1b20b7e95faf4cbc57dd84e36293ff7ae6f531
parentrefactoring ProtocolInformation.c (diff)
downloadmemtest86-269966925ec62706a18444bc45d2b9590bc6f5ca.tar.gz
memtest86-269966925ec62706a18444bc45d2b9590bc6f5ca.tar.xz
memtest86-269966925ec62706a18444bc45d2b9590bc6f5ca.zip
corrected OpenProtocol function call
-rw-r--r--memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
index b32a97d..afd47ec 100644
--- a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
+++ b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
@@ -34,26 +34,26 @@ UINTN OpenInfoCount;
void printFileSystemInfo(EFI_FILE_SYSTEM_INFO* fileSystemInfo) {
- Print(L"fileSystemInfo pointer %p\n", fileSystemInfo);
+ Print(L"fileSystemInfo pointer %p\n", fileSystemInfo);
CHAR16* volumeLabel = fileSystemInfo->VolumeLabel;
- Print(L"VolumeLabel: %a\n", volumeLabel);
- Print(L"Size of volume Label: %d\n", sizeof(fileSystemInfo->VolumeLabel));
- Print(L"Size: %d\n", fileSystemInfo->Size);
- Print(L"ReadOnly: %d\n", fileSystemInfo->ReadOnly);
- Print(L"VolumeSize: %d\n", fileSystemInfo->VolumeSize);
- Print(L"FreeSpace: %d\n", fileSystemInfo->FreeSpace);
- Print(L"BlockSize: %d\n", fileSystemInfo->BlockSize);
+ Print(L"VolumeLabel: %a\n", volumeLabel);
+ Print(L"Size of volume Label: %d\n", sizeof(fileSystemInfo->VolumeLabel));
+ Print(L"Size: %d\n", fileSystemInfo->Size);
+ Print(L"ReadOnly: %d\n", fileSystemInfo->ReadOnly);
+ Print(L"VolumeSize: %d\n", fileSystemInfo->VolumeSize);
+ Print(L"FreeSpace: %d\n", fileSystemInfo->FreeSpace);
+ Print(L"BlockSize: %d\n", fileSystemInfo->BlockSize);
}
void printFileContent(UINTN fileSize, CHAR16* fileBuffer) {
- Print(L"File Size: %d\n", fileSize);
- Print(L"File Content: %a\n", fileBuffer);
+ Print(L"File Size: %d\n", fileSize);
+ Print(L"File Content: %a\n", fileBuffer);
}
-void checkStatus(EFI_STATUS es, CHAR16* msg) {
+void checkStatus(EFI_STATUS es, char *msg) {
if (es != EFI_SUCCESS) {
- Print(L"%a\n", msg);
+ Print(L"Point of failure: %a\n", msg);
Print(L"Exit with status: %r\n", es);
Exit(1);
}
@@ -95,8 +95,7 @@ UefiMain (
&handleCount,
&handleBuffer
);
-
- checkStatus(efiStatus, L"LocateHandleBuffer");
+ checkStatus(efiStatus, "LocateHandleBuffer");
for (handleIndex = 0; handleIndex < handleCount; handleIndex++) {
//
@@ -107,8 +106,7 @@ UefiMain (
&ProtocolGuidArray,
&ArrayCount
);
-
- checkStatus(efiStatus, L"ProtocolsPerHandle");
+ checkStatus(efiStatus, "ProtocolsPerHandle");
//
// Search for protocol with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
@@ -128,10 +126,9 @@ UefiMain (
NULL,
ImageHandle,
NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
-
- checkStatus(efiStatus, L"OpenProtocol");
+ checkStatus(efiStatus, "OpenProtocol");
//
// Retrieve the list of agents that have opened each protocol
@@ -142,8 +139,7 @@ UefiMain (
&OpenInfo,
&OpenInfoCount // Number of agents that have opened the protocol
);
-
- checkStatus(efiStatus, L"OpenProtocolInformation");
+ checkStatus(efiStatus, "OpenProtocolInformation");
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
@@ -152,12 +148,11 @@ UefiMain (
&sfspGuid,
(void**)&fs
);
-
- checkStatus(efiStatus, L"HandleProtocol");
+ checkStatus(efiStatus, "HandleProtocol");
EFI_FILE_PROTOCOL* root = NULL;
efiStatus = fs->OpenVolume(fs, &root);
- checkStatus(efiStatus, L"OpenVolume");
+ checkStatus(efiStatus, "OpenVolume");
EFI_GUID fsiGuid = EFI_FILE_SYSTEM_INFO_ID;
UINTN bufSize = 0;
@@ -170,40 +165,40 @@ UefiMain (
&fileSystemInfo);
efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (bufSize) , (void **)&fileSystemInfo);
- checkStatus(efiStatus, L"AllocatePool");
+ checkStatus(efiStatus, "AllocatePool");
efiStatus = root->GetInfo(
root,
&fsiGuid,
&bufSize,
fileSystemInfo);
- checkStatus(efiStatus, L"GetInfo");
- printFileSystemInfo(fileSystemInfo);
+ checkStatus(efiStatus, "GetInfo");
+ //printFileSystemInfo(fileSystemInfo);
// TODO first check if it is the right filesystem. If yes, leave the for loop
EFI_FILE_PROTOCOL* token = NULL;
- efiStatus = root->Open( // TODO do I need that to read?
+ efiStatus = root->Open(
root,
&token,
L"log",
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
0);
- checkStatus(efiStatus, L"Open");
+ checkStatus(efiStatus, "Open");
- UINTN fileSize = 50; // TODO get the actual size
+ UINTN fileSize = 100; // TODO get the actual size
CHAR16* fileBuffer = NULL;
efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (fileSize) , (void **)&fileBuffer);
- checkStatus(efiStatus, L"AllocatePool for file");
+ checkStatus(efiStatus, "AllocatePool for file");
efiStatus = token->Read(token, &fileSize, fileBuffer);
- checkStatus(efiStatus, L"Read");
+ checkStatus(efiStatus, "Read");
printFileContent(fileSize, fileBuffer);
UINT64 currPos;
efiStatus = token->GetPosition(token, &currPos);
- checkStatus(efiStatus, L"GetPosition");
+ checkStatus(efiStatus, "GetPosition");
Print(L"Current File Position: %d\n", currPos);
fileBuffer[0] = (CHAR16) 'C'; // TODO create new buffer. What's the best practice? Extra function
@@ -214,7 +209,7 @@ UefiMain (
token->SetPosition(token, fileSize - 1);
efiStatus = token->Write(token, &length, fileBuffer);
- checkStatus(efiStatus, L"Write");
+ checkStatus(efiStatus, "Write");
fileSize += length;