summaryrefslogtreecommitdiffstats
path: root/memtestEDK
diff options
context:
space:
mode:
Diffstat (limited to 'memtestEDK')
-rw-r--r--memtestEDK/Memtest/GetMemoryMap/GetMemoryMap.c97
-rw-r--r--memtestEDK/Memtest/GetMemoryMap/TODO0
-rw-r--r--memtestEDK/Memtest/ProtocolInformation/TODO0
-rwxr-xr-xmemtestEDK/Memtest/run.sh2
4 files changed, 13 insertions, 86 deletions
diff --git a/memtestEDK/Memtest/GetMemoryMap/GetMemoryMap.c b/memtestEDK/Memtest/GetMemoryMap/GetMemoryMap.c
index 926849c..3300552 100644
--- a/memtestEDK/Memtest/GetMemoryMap/GetMemoryMap.c
+++ b/memtestEDK/Memtest/GetMemoryMap/GetMemoryMap.c
@@ -1,7 +1,3 @@
-#include <stdio.h>
-//#include <stdlib.h>
-
-
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
@@ -33,41 +29,6 @@ const CHAR16 *memory_types[] =
L"EfiPalCode",
};
-void printToFile() {
- /* Variable to store user content */
- char data[DATA_SIZE];
-
- /* File pointer to hold reference to our file */
- FILE * fPtr;
-
-
- /*
- * Open file in w (write) mode.
- * "data/file1.txt" is complete path to create file
- */
- fPtr = fopen("data/file1.txt", "w");
-
-
- /* fopen() return NULL if last operation was unsuccessful */
- if(fPtr == NULL)
- {
- /* File not created hence exit */
- printf("Unable to create file.\n");
- }
-
-
- /* Write data to file */
- fputs(data, fPtr);
-
-
- /* Close file to save file data */
- fclose(fPtr);
-
-
- /* Success message */
- printf("File created and saved successfully. :) \n");
-}
-
EFI_STATUS
EFIAPI
UefiMain (
@@ -75,7 +36,8 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- Print(L"Application to get Memory Map\n");
+
+ Print(L"Application to get Memory Map\n\n");
UINTN MemoryMapSize = 0;
EFI_MEMORY_DESCRIPTOR *memoryMap = NULL;
@@ -86,65 +48,30 @@ UefiMain (
EFI_BOOT_SERVICES *bs = SystemTable->BootServices;
+ /* Allocate the buffer for the MemoryMap. As the memory map changes every time we query it, the
+ size also may change. So we allocate a new buffer until it has sufficient space for the MemoryMap.
+ */
Status = bs->GetMemoryMap(&MemoryMapSize, memoryMap, &LocalMapKey, &DescriptorSize, &DescriptorVersion);
-/* Print(L"MemoryMapSize: %d\n", MemoryMapSize); // size needed if the buffer was to small
- Print(L"memoryMap pointer: %p\n", memoryMap);
- Print(L"This time through the memory map loop, status = %r\n",Status);*/
do {
-/* Print(L"Buffer was too small!\n");
- Print(L"Trying with size %d\n", (UINTN) (MemoryMapSize + 1) );
- Print(L"MemoryMapSize: %d\n", MemoryMapSize); // size needed if the buffer was to small
- Print(L"MemoryMap pointer: %p\n", memoryMap);*/
-
Status = bs->AllocatePool(EfiLoaderData, (UINTN) (MemoryMapSize + 1) , (void **)&memoryMap);
-/*
- Print(L"Status = %r\n", Status);
- Print(L"MemoryMap pointer: %p\n", memoryMap);
-*/
Status = bs->GetMemoryMap(&MemoryMapSize, memoryMap, &LocalMapKey, &DescriptorSize, &DescriptorVersion);
-/* Print(L"Status = %r\n", Status);
- Print(L"After GetMemoryMap\n");
- Print(L"MemoryMapSize: %d\n", MemoryMapSize); // size needed if the buffer was to small
- Print(L"memoryMap pointer: %p\n", memoryMap);
- Print(L"This time through the memory map loop, status = %r\n",Status);*/
} while (Status == EFI_BUFFER_TOO_SMALL);
if (Status != EFI_SUCCESS) {
Print(L"Status = %r\n", Status);
+ return Status;
}
-
- Print(L"After GetMemoryMap\n");
- Print(L"MemoryMapSize: %d\n", MemoryMapSize); // size needed if the buffer was to small
- Print(L"MemoryMap pointer: %p\n", memoryMap);
-
- EFI_MEMORY_DESCRIPTOR firstElement = *memoryMap;
Print(L"memoryMap location: %p\n", memoryMap);
- Print(L"Size of first element: %d\n", sizeof(firstElement));
- Print(L"Type: %d\n", firstElement.Type);
- Print(L"PhysicalStart: %p\n", firstElement.PhysicalStart);
- Print(L"VirtualStart: %p\n", firstElement.VirtualStart);
- Print(L"NumberOfPages: %d\n", firstElement.NumberOfPages);
- Print(L"Attribute: %d\n", firstElement.Attribute);
-
-
- EFI_MEMORY_DESCRIPTOR secondElement = *(memoryMap + 40);
- Print(L"memoryMap location: %p\n", memoryMap);
- Print(L"Size of first element: %d\n", sizeof(secondElement));
- Print(L"Type: %d\n", secondElement.Type);
- Print(L"PhysicalStart: %p\n", secondElement.PhysicalStart);
- Print(L"VirtualStart: %p\n", secondElement.VirtualStart);
- Print(L"NumberOfPages: %d\n", secondElement.NumberOfPages);
- Print(L"Attribute: %d\n", secondElement.Attribute);
+ //Print(L"Size of first element (and all other elements): %d\n", sizeof(secondElement));
+ Print(L"DescriptorSize: %d\n", DescriptorSize);
+ Print(L"DescriptorVersion: %d\n\n\n", DescriptorVersion);
uint8_t *startOfMemoryMap = (uint8_t *)memoryMap;
uint8_t *endOfMemoryMap = startOfMemoryMap + MemoryMapSize;
-
uint8_t *offset = startOfMemoryMap;
-
uint32_t counter = 0;
uint64_t totalPages = 0;
-
EFI_MEMORY_DESCRIPTOR *desc = NULL;
while(offset < endOfMemoryMap) {
@@ -161,11 +88,11 @@ UefiMain (
offset += DescriptorSize;
counter++;
-
- uint64_t MemoryMapSize = totalPages * 4096;
- Print(L"Memory detected: %d MB\n", MemoryMapSize / 1024 / 1024);
}
+
+ uint64_t MemoryMapSize = totalPages * 4096;
+ Print(L"Memory detected: %d MB\n\n", MemoryMapSize / 1024 / 1024);
return EFI_SUCCESS;
}
diff --git a/memtestEDK/Memtest/GetMemoryMap/TODO b/memtestEDK/Memtest/GetMemoryMap/TODO
deleted file mode 100644
index e69de29..0000000
--- a/memtestEDK/Memtest/GetMemoryMap/TODO
+++ /dev/null
diff --git a/memtestEDK/Memtest/ProtocolInformation/TODO b/memtestEDK/Memtest/ProtocolInformation/TODO
deleted file mode 100644
index e69de29..0000000
--- a/memtestEDK/Memtest/ProtocolInformation/TODO
+++ /dev/null
diff --git a/memtestEDK/Memtest/run.sh b/memtestEDK/Memtest/run.sh
index 6d98a65..742efca 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/ProtocolInformation.efi ../../git/working_dir/memtest86/test_code/hda-contents/)
+(cd ..; cp Build/MdeModule/DEBUG_GCC5/X64/ConfigurationTable.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 )