summaryrefslogtreecommitdiffstats
path: root/memtestEDK
diff options
context:
space:
mode:
authorRegina König2020-08-04 03:27:23 +0200
committerRegina König2020-08-04 03:27:23 +0200
commit2773346899434e71575c73ff793600f9df7ddf94 (patch)
tree2bcd0f6d57f719ad98cdcf245057b60062ecea50 /memtestEDK
parentTest application which contains all Console-Output functions (diff)
downloadmemtest86-2773346899434e71575c73ff793600f9df7ddf94.tar.gz
memtest86-2773346899434e71575c73ff793600f9df7ddf94.tar.xz
memtest86-2773346899434e71575c73ff793600f9df7ddf94.zip
Trying to get access to file via file-protocol
Diffstat (limited to 'memtestEDK')
-rw-r--r--memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c173
-rwxr-xr-xmemtestEDK/Memtest/run.sh2
2 files changed, 92 insertions, 83 deletions
diff --git a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
index 4a953c3..59e424f 100644
--- a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
+++ b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c
@@ -3,6 +3,7 @@
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
+#include <Include/Guid/FileSystemInfo.h>
EFI_STATUS
@@ -101,6 +102,96 @@ UefiMain (
&OpenInfo,
&OpenInfoCount
);
+
+ Print(L"Number of agents which have opened the protocol: %d\n", OpenInfoCount);
+
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
+
+ efiStatus = bs->HandleProtocol( // TODO Should use OpenProtocol() in new implementations
+ handleBuffer[handleIndex],
+ &sfspGuid,
+ (void**)&fs
+ );
+
+ Print(L"Status after HandleProtocol: %r\n", efiStatus);
+ Print(L"fs pointer: %p\n", fs);
+
+
+ EFI_FILE_PROTOCOL* root = NULL;
+
+ efiStatus = fs->OpenVolume(fs, &root);
+ Print(L"Status after open volume: %r\n", efiStatus);
+
+ EFI_GUID fsiGuid = EFI_FILE_SYSTEM_INFO_ID;
+
+ UINTN bufSize = 0;
+
+ EFI_FILE_SYSTEM_INFO* fileSystemInfo = NULL;
+ efiStatus = root->GetInfo(
+ root,
+ &fsiGuid,
+ &bufSize,
+ &fileSystemInfo);
+
+ Print(L"Status: %r\n", efiStatus);
+ Print(L"Required buffer size: %d\n", bufSize );
+
+ efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (bufSize) , (void **)&fileSystemInfo);
+
+ efiStatus = root->GetInfo(
+ root,
+ &fsiGuid,
+ &bufSize,
+ fileSystemInfo);
+
+ Print(L"Status: %r\n", efiStatus);
+
+ 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);
+/*
+ efiStatus = bs->FreePool((void **)&buffer);
+ Print(L"efiStatus after FreePool: %r\n", efiStatus);*/
+
+
+ EFI_FILE_PROTOCOL* token = NULL;
+ efiStatus = root->Open(
+ root,
+ &token,
+ L"log",
+ EFI_FILE_MODE_READ,
+ EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
+
+ UINTN fileSize = 50;
+ CHAR16* fileBuffer = NULL;
+ efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (fileSize) , (void **)&fileBuffer);
+
+ efiStatus = token->Read(token, &fileSize, fileBuffer);
+ Print(L"Status after file read: %r\n", efiStatus);
+ Print(L"File Size: %d\n", fileSize);
+ Print(L"File Buffer Pointer: %p\n", fileBuffer);
+
+ Print(L"File Content: %a\n", fileBuffer);
+
+
+/*
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ EFI_FILE_GET_POSITION GetPosition;
+ EFI_FILE_SET_POSITION SetPosition;
+ EFI_FILE_GET_INFO GetInfo;
+ EFI_FILE_SET_INFO SetInfo;
+ EFI_FILE_FLUSH Flush;*/
}
}
}
@@ -140,88 +231,6 @@ UefiMain (
Print(L"Handle count: %d\n", handleCount2);
-
- for (int index = 0; index < (int)handleCount; ++ index)
- {
- //EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
-
- /*efiStatus = bs->HandleProtocol( // TODO Should use OpenProtocol() in new implementations
- handles[index],
- &sfspGuid,
- (void**)&fs
- );*/
- /*Print(L"Status after HandleProtocol: %r\n", efiStatus);
- Print(L"Volume %d found\n", index);
- Print(L"fs pointer: %p\n", fs);
- EFI_FILE_PROTOCOL* root = NULL;
- efiStatus = fs->OpenVolume(fs, &root);
- Print(L"Status after open volume: %r\n", efiStatus);
- EFI_GUID fsiGuid = EFI_FILE_SYSTEM_INFO_ID;
- UINTN bufSize = 0;
- VOID* buffer = NULL;*/
-
- /*efiStatus = root->GetInfo(
- root,
- &fsiGuid,
- &bufSize,
- &buffer);
-
- Print(L"Status: %r\n", efiStatus);
- Print(L"Required buffer size: %d\n", bufSize );
-
-
- efiStatus = bs->AllocatePool(EfiLoaderData, (UINTN) (bufSize) , (void **)&buffer);
-
-
- efiStatus = root->GetInfo(
- root,
- &fsiGuid,
- &bufSize,
- &buffer);*/
-/*
- Print(L"Status: %r\n", efiStatus);
-
- EFI_FILE_SYSTEM_INFO* fhgf = buffer;
-
- Print(L"buffer pointer %p\n", buffer);
- Print(L"fhgf pointer %p\n", fhgf);
-
- Print(L"VolumeLabel: %s\n", fhgf->VolumeLabel);
- Print(L"Size: %d\n", fhgf->Size);
- Print(L"ReadOnly: %d\n", fhgf->ReadOnly);
- Print(L"VolumeSize: %d\n", fhgf->VolumeSize);
- Print(L"FreeSpace: %d\n", fhgf->FreeSpace);
- Print(L"BlockSize: %d\n", fhgf->BlockSize);
- Print(L"Number of handle found %d\n", (index + 1));
-
- efiStatus = bs->FreePool((void **)&buffer);
- Print(L"efiStatus after FreePool: %r\n", efiStatus);*/
- }
-/*
-...
-
-
-
-
- EFI_FILE_PROTOCOL* token = NULL;
-efiStatus = root->Open(
- root,
- &token,
- L"myfolder\\token.bin",
- EFI_FILE_MODE_READ,
- EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);*/
-
-/*
- EFI_FILE_OPEN Open;
- EFI_FILE_CLOSE Close;
- EFI_FILE_DELETE Delete;
- EFI_FILE_READ Read;
- EFI_FILE_WRITE Write;
- EFI_FILE_GET_POSITION GetPosition;
- EFI_FILE_SET_POSITION SetPosition;
- EFI_FILE_GET_INFO GetInfo;
- EFI_FILE_SET_INFO SetInfo;
- EFI_FILE_FLUSH Flush;*/
return EFI_SUCCESS;
}
diff --git a/memtestEDK/Memtest/run.sh b/memtestEDK/Memtest/run.sh
index 82ecd19..6d98a65 100755
--- a/memtestEDK/Memtest/run.sh
+++ b/memtestEDK/Memtest/run.sh
@@ -3,7 +3,7 @@
(cd ..;. edksetup.sh BaseTools; build -a X64 -p MdeModulePkg/MdeModulePkg.dsc)
if [ $? -ne 0 ]; then exit 1; fi
-(cd ..; cp Build/MdeModule/DEBUG_GCC5/X64/TextOutput.efi ../../git/working_dir/memtest86/test_code/hda-contents/)
+(cd ..; cp Build/MdeModule/DEBUG_GCC5/X64/ProtocolInformation.efi ../../git/working_dir/memtest86/test_code/hda-contents/)
if [ $? -ne 0 ]; then exit 1; fi
(cd ../../../git/working_dir/memtest86/test_code; sudo ./run.sh )