summaryrefslogtreecommitdiffstats
path: root/efi_memtest/MemtestEfi.c
diff options
context:
space:
mode:
authorRegina König2020-07-22 00:37:04 +0200
committerRegina König2020-07-22 00:37:04 +0200
commit660e62b69df5de4dcf01d196ad24e199a845bc5b (patch)
tree8d8efed518cc76f6a681d723a96a60cfa17ea0e2 /efi_memtest/MemtestEfi.c
parentRemoved some files not needed in git repository (diff)
downloadmemtest86-660e62b69df5de4dcf01d196ad24e199a845bc5b.tar.gz
memtest86-660e62b69df5de4dcf01d196ad24e199a845bc5b.tar.xz
memtest86-660e62b69df5de4dcf01d196ad24e199a845bc5b.zip
Moved code to get protocols into own application
Diffstat (limited to 'efi_memtest/MemtestEfi.c')
-rw-r--r--efi_memtest/MemtestEfi.c174
1 files changed, 0 insertions, 174 deletions
diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c
index 24ea0b9..a671434 100644
--- a/efi_memtest/MemtestEfi.c
+++ b/efi_memtest/MemtestEfi.c
@@ -21,181 +21,7 @@ UefiMain (
print_usage();
test_start();*/
- EFI_STATUS efiStatus;
- EFI_BOOT_SERVICES* bs = SystemTable->BootServices;
- EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
- EFI_HANDLE* handleBuffer = NULL;
- UINTN handleCount = 0;
- UINTN HandleIndex;
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
- UINTN OpenInfoIndex;
- UINTN OpenInfoCount;
-
- efiStatus = bs->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- handleCount,
- &handleBuffer
- );
-
- Print(L"Number of handles found: %d\n", handleCount);
-
- if (!EFI_ERROR (efiStatus)) {
- for (HandleIndex = 0; HandleIndex < handleCount; HandleIndex++) {
- //
- // Retrieve the list of all the protocols on each handle
- //
- efiStatus = bs->ProtocolsPerHandle (
- handleBuffer[HandleIndex],
- &ProtocolGuidArray,
- &ArrayCount
- );
-
- Print(L"Number of Protocols per Handle: %d\n", ArrayCount);
-
- if (!EFI_ERROR (efiStatus)) {
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- //
- // Retrieve the protocol instance for each protocol
- //
-
- efiStatus = bs->OpenProtocol (
- handleBuffer[HandleIndex],
- ProtocolGuidArray[ProtocolIndex],
- NULL,
- ImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- //
- // Retrieve the list of agents that have opened each protocol
- //
- efiStatus = bs->OpenProtocolInformation (
- handleBuffer[HandleIndex],
- ProtocolGuidArray[ProtocolIndex],
- &OpenInfo,
- &OpenInfoCount
- );
- 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) {
- bs->FreePool(OpenInfo);
- }
- }
- }
- if (ProtocolGuidArray != NULL) {
- bs->FreePool(ProtocolGuidArray);
- }
- }
- if (handleBuffer != NULL) {
- bs->FreePool (handleBuffer);
- }
- }
- }
-
- /* efiStatus = bs->LocateHandleBuffer(ByProtocol,
- &sfspGuid,
- NULL,
- &handleCount,
- &handles);
-
- Print(L"Handle count: %d\n", handleCount);
-
- for (int index = 0; index < (int)handleCount; ++ index)
- {
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL;
-
- Print(L"sfspGuid: %d\n", sfspGuid);
-
- 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;
}