summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina König2021-07-01 11:41:25 +0200
committerRegina König2021-07-01 11:41:25 +0200
commit4bb2dad8414193b823685d3b474e7aa9e9ca9e92 (patch)
tree389b5218f9e1d673475bd6d3dc645b9cd8973a42
parentDelete all unnecessary files (diff)
downloadmemtest86-4bb2dad8414193b823685d3b474e7aa9e9ca9e92.tar.gz
memtest86-4bb2dad8414193b823685d3b474e7aa9e9ca9e92.tar.xz
memtest86-4bb2dad8414193b823685d3b474e7aa9e9ca9e92.zip
Add two new allocation methods: sequential and rising size
-rw-r--r--allocate_pages_test/Makefile2
-rw-r--r--allocate_pages_test/MemtestEfi.c13
-rw-r--r--allocate_pages_test/logger_config.h2
-rw-r--r--allocate_pages_test/memtest86+/efi/page_allocator.c75
-rw-r--r--allocate_pages_test/memtest86+/efi/page_allocator.h6
-rw-r--r--allocate_pages_test/memtest86+/main.c2
6 files changed, 88 insertions, 12 deletions
diff --git a/allocate_pages_test/Makefile b/allocate_pages_test/Makefile
index af4e9de..aa92ab7 100644
--- a/allocate_pages_test/Makefile
+++ b/allocate_pages_test/Makefile
@@ -82,7 +82,7 @@ $(MAIN_FILE).dll: $(MAIN_FILE).lib
-Wl,--defsym=PECOFF_HEADER_SIZE=0x228 \
-Wl,--script=memtest86+/efi/Include/GccBase.lds \
-z common-page-size=0x40 \
- -u _ModuleEntryPoint \
+ -u _ModuleEntryPoint
objcopy --strip-unneeded -R .eh_frame -v $(MAIN_FILE).dll $(MAIN_FILE).dll
strip -R .strtab MemtestEfi.dll
diff --git a/allocate_pages_test/MemtestEfi.c b/allocate_pages_test/MemtestEfi.c
index 5e5af30..190a9de 100644
--- a/allocate_pages_test/MemtestEfi.c
+++ b/allocate_pages_test/MemtestEfi.c
@@ -84,6 +84,19 @@ UefiMain (
mem_size();
+ for (int i = 0; i < 9; i++) {
+ allocate_pages_div_n_conq(mem_info.e820[i].size, (unsigned long *) mem_info.e820[i].addr);
+ }
+
+ for (int i = 0; i < 9; i++) {
+ allocate_pages_single_pages(mem_info.e820[i].size, (unsigned long *) mem_info.e820[i].addr);
+ }
+
+ for (int i = 0; i < 9; i++) {
+ allocate_pages_rising_size(mem_info.e820[i].size, (unsigned long *) mem_info.e820[i].addr);
+ }
+
+ mem_size();
if (logflag) {
char msg[] = "MemtestEfi finished!\n";
diff --git a/allocate_pages_test/logger_config.h b/allocate_pages_test/logger_config.h
index 70dbb26..47cbf93 100644
--- a/allocate_pages_test/logger_config.h
+++ b/allocate_pages_test/logger_config.h
@@ -22,4 +22,4 @@ short log_dmi = 0;
short log_tst2 = 1;
// PAGE ALLOCATION
-short log_page_alloc = 0; \ No newline at end of file
+short log_page_alloc = 1; \ No newline at end of file
diff --git a/allocate_pages_test/memtest86+/efi/page_allocator.c b/allocate_pages_test/memtest86+/efi/page_allocator.c
index 22230a4..361481e 100644
--- a/allocate_pages_test/memtest86+/efi/page_allocator.c
+++ b/allocate_pages_test/memtest86+/efi/page_allocator.c
@@ -69,12 +69,11 @@ void sequential_allocation(int page_no, unsigned long * p) {
EFI_PHYSICAL_ADDRESS * q = (EFI_PHYSICAL_ADDRESS *)(p + i*512);
- EFI_STATUS status = gST->BootServices->AllocatePages(AllocateAddress, EfiBootServicesData, 1, q);
+ EFI_STATUS status = gST->BootServices->AllocatePages(AllocateAddress, EfiLoaderData, 1, q);
if (status != EFI_SUCCESS) {
//print_log("no success", 10);
} else {
-
if (logflag) {
print_log("SUCCESS!!!!", 11);
char log[24] = "q = ";
@@ -111,20 +110,20 @@ void divide_n_conquer_allocation(int page_no, unsigned long *p) {
if (status != EFI_SUCCESS ) {
- if (logflag && log_page_alloc) {
+/* if (logflag && log_page_alloc) {
char log[19] = "STATUS = ";
int length = 9;
int_to_charr(status, log, &length);
print_log(log, length);
- }
+ }*/
- /*if (page_no >= 2) {
+ if (page_no >= 2) {
int first = page_no / 2;
int scnd = page_no - first;
divide_n_conquer_allocation(first, p);
divide_n_conquer_allocation(scnd, (p + first*512));
- }*/
+ }
} else {
@@ -146,7 +145,11 @@ void divide_n_conquer_allocation(int page_no, unsigned long *p) {
}
-void allocate_pages(int page_no, unsigned long * p) {
+void allocate_pages_div_n_conq(int page_no, unsigned long * p) {
+
+ if (logflag && log_page_alloc) {
+ print_log("Try divide and conquer...", 25);
+ }
if (logflag && log_page_alloc) {
char log[21] = "\npage_no = ";
@@ -164,13 +167,69 @@ void allocate_pages(int page_no, unsigned long * p) {
d_n_c_level = 0;
- // sequential_allocation(page_no, p);
divide_n_conquer_allocation(page_no, p);
print_alloc_map();
}
+void allocate_pages_single_pages(int page_no, unsigned long * p) {
+
+ if (logflag && log_page_alloc) {
+ print_log("Try sequential...", 18);
+ }
+
+ if (logflag && log_page_alloc) {
+ char log[21] = "\npage_no = ";
+ int length = 11;
+ int_to_charr(page_no, log, &length);
+ print_log(log, length);
+ }
+
+ if (logflag && log_page_alloc) {
+ char log[24] = "p = ";
+ int length = 4;
+ int_to_charr((unsigned long) p, log, &length);
+ print_log(log, length);
+ }
+
+ sequential_allocation(page_no, p);
+
+}
+
+void allocate_pages_rising_size(int page_no, unsigned long * p) {
+
+ if (logflag && log_page_alloc) {
+ print_log("Try rising size...", 18);
+ }
+
+ if (logflag && log_page_alloc) {
+ char log[21] = "\npage_no = ";
+ int length = 11;
+ int_to_charr(page_no, log, &length);
+ print_log(log, length);
+ }
+
+ if (logflag && log_page_alloc) {
+ char log[24] = "p = ";
+ int length = 4;
+ int_to_charr((unsigned long) p, log, &length);
+ print_log(log, length);
+ }
+
+ EFI_STATUS status;
+ int length = 1;
+
+ while (status != EFI_SUCCESS && length <= page_no) {
+ status = gST->BootServices->AllocatePages(AllocateAddress, EfiBootServicesData, length,(EFI_PHYSICAL_ADDRESS *) p);
+ length++;
+ }
+
+ if (status == EFI_SUCCESS) {
+ print_log("HURRAY!!", 8);
+ }
+}
+
void free_pages(unsigned long *p) {
}
diff --git a/allocate_pages_test/memtest86+/efi/page_allocator.h b/allocate_pages_test/memtest86+/efi/page_allocator.h
index 427ae05..9c5bd90 100644
--- a/allocate_pages_test/memtest86+/efi/page_allocator.h
+++ b/allocate_pages_test/memtest86+/efi/page_allocator.h
@@ -14,4 +14,8 @@ struct allocation_map {
struct allocation_map_entry entry[MAX_ALLOCATION_MAP_ENTRIES];
};
-void allocate_pages(int page_no, unsigned long * p);
+void allocate_pages_div_n_conq(int page_no, unsigned long * p);
+
+void allocate_pages_single_pages(int page_no, unsigned long * p);
+
+void allocate_pages_rising_size(int page_no, unsigned long * p);
diff --git a/allocate_pages_test/memtest86+/main.c b/allocate_pages_test/memtest86+/main.c
index ad050e9..dfb61a6 100644
--- a/allocate_pages_test/memtest86+/main.c
+++ b/allocate_pages_test/memtest86+/main.c
@@ -1106,7 +1106,7 @@ int do_test(int my_ord)
ulong * p = (ulong *) (vv->pmap[i].start * 4096);
ulong page_no = ((ulong) vv->pmap[i].end - (ulong) vv->pmap[i].start);
- allocate_pages(page_no, p); // TODO provide allocate-map structure
+ allocate_pages_div_n_conq(page_no, p); // TODO provide allocate-map structure
}
}