From abd5686cbe9d0c87518a16f073d3d4a6153afef6 Mon Sep 17 00:00:00 2001 From: Regina König Date: Fri, 7 Aug 2020 14:30:29 +0200 Subject: added new application to test the first test --- memtestEDK/MdeModulePkg.dsc | 1 + memtestEDK/Memtest/Test1/doTest1.c | 20 +++++++++ memtestEDK/Memtest/Test1/doTest1.inf | 33 ++++++++++++++ memtestEDK/Memtest/Test1/test.c | 85 +++++++++++++++++++++++++++++++++++ memtestEDK/Memtest/Test1/test.h | 1 + memtestEDK/Memtest/Test2/Template.c | 18 ++++++++ memtestEDK/Memtest/Test2/Template.inf | 32 +++++++++++++ 7 files changed, 190 insertions(+) create mode 100644 memtestEDK/Memtest/Test1/doTest1.c create mode 100644 memtestEDK/Memtest/Test1/doTest1.inf create mode 100644 memtestEDK/Memtest/Test1/test.c create mode 100644 memtestEDK/Memtest/Test1/test.h create mode 100644 memtestEDK/Memtest/Test2/Template.c create mode 100644 memtestEDK/Memtest/Test2/Template.inf (limited to 'memtestEDK') diff --git a/memtestEDK/MdeModulePkg.dsc b/memtestEDK/MdeModulePkg.dsc index daa3e94..09bc5a1 100644 --- a/memtestEDK/MdeModulePkg.dsc +++ b/memtestEDK/MdeModulePkg.dsc @@ -209,6 +209,7 @@ Memtest/GetRootSystemDescriptionPointer/GetRootSystemDescriptionPointer.inf # Memtest/GraphicsOutput/GraphicsOutputProtocol.inf Memtest/GraphicsOutput/TextOutput.inf + Memtest/Test1/doTest1.inf # MdeModulePkg/Application/HelloWorld/HelloWorld.inf # MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf diff --git a/memtestEDK/Memtest/Test1/doTest1.c b/memtestEDK/Memtest/Test1/doTest1.c new file mode 100644 index 0000000..11babee --- /dev/null +++ b/memtestEDK/Memtest/Test1/doTest1.c @@ -0,0 +1,20 @@ +#include + +#include +#include +#include +#include + +#include "test.h" + +EFI_STATUS +EFIAPI +UefiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + return EFI_SUCCESS; + +} \ No newline at end of file diff --git a/memtestEDK/Memtest/Test1/doTest1.inf b/memtestEDK/Memtest/Test1/doTest1.inf new file mode 100644 index 0000000..5a15050 --- /dev/null +++ b/memtestEDK/Memtest/Test1/doTest1.inf @@ -0,0 +1,33 @@ +[Defines] + INF_VERSION = 1.25 + BASE_NAME = doTest1 + FILE_GUID = 6e6463a5-8e95-4959-97ea-7db3c845f8d5 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC Etc... +# + +[Sources] + doTest1.c + test.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + UefiLib + +[Guids] + +[Ppis] + +[Protocols] + +[FeaturePcd] + +[Pcd] diff --git a/memtestEDK/Memtest/Test1/test.c b/memtestEDK/Memtest/Test1/test.c new file mode 100644 index 0000000..818a193 --- /dev/null +++ b/memtestEDK/Memtest/Test1/test.c @@ -0,0 +1,85 @@ +typedef void(*segment_fn)(ulong* start, // start address + ulong len_dw, // length of segment in dwords + const void* ctx); // any context data needed + +static const void* const nullptr = 0x0; + int me = 0; // my_cpu_num in main.c + +/* + * Memory address test, walking ones + */ +void addr_tst1(int me) // TODO TEST STARTS HERE +{ + unsliced_foreach_segment(nullptr, me, addr_tst1_seg); +} + + +/* Calls segment_fn() for each segment in vv->map. + * + * Does not slice by CPU number, so it covers the entire memory. + * Contrast to sliced_foreach_segment(). + */ +STATIC void unsliced_foreach_segment +(const void* ctx, int me, segment_fn func) { + int j; + for (j=0; jmap[j].start, + vv->map[j].end, + me, ctx, func); + } +} + +/* Call segment_fn() for each up-to-SPINSZ segment between + * 'start' and 'end'. + */ +void foreach_segment +(ulong* start, ulong* end, + int me, const void* ctx, segment_fn func) { + + ASSERT(start < end); + + // Confirm 'start' points to an even dword, and 'end' + // should point to an odd dword + ASSERT(0 == (((ulong)start) & 0x7)); + ASSERT(0x4 == (((ulong)end) & 0x7)); + + // 'end' may be exactly 0xfffffffc, right at the 4GB boundary. + // + // To avoid overflow in our loop tests and length calculations, + // use dword indices (the '_dw' vars) to avoid overflows. + ulong start_dw = ((ulong)start) >> 2; + ulong end_dw = ((ulong) end) >> 2; + + // end is always xxxxxffc, but increment end_dw to an + // address beyond the segment for easier boundary calculations. + ++end_dw; + + ulong seg_dw = start_dw; + ulong seg_end_dw = start_dw; + + int done = 0; + do { + do_tick(me); + { BAILR } + + // ensure no overflow + ASSERT((seg_end_dw + SPINSZ_DWORDS) > seg_end_dw); + seg_end_dw += SPINSZ_DWORDS; + + if (seg_end_dw >= end_dw) { + seg_end_dw = end_dw; + done++; + } + if (seg_dw == seg_end_dw) { + break; + } + + ASSERT(((ulong)seg_end_dw) <= 0x40000000); + ASSERT(seg_end_dw > seg_dw); + ulong seg_len_dw = seg_end_dw - seg_dw; + + func((ulong*)(seg_dw << 2), seg_len_dw, ctx); + + seg_dw = seg_end_dw; + } while (!done); +} \ No newline at end of file diff --git a/memtestEDK/Memtest/Test1/test.h b/memtestEDK/Memtest/Test1/test.h new file mode 100644 index 0000000..d741056 --- /dev/null +++ b/memtestEDK/Memtest/Test1/test.h @@ -0,0 +1 @@ +void addr_tst1(int me); \ No newline at end of file diff --git a/memtestEDK/Memtest/Test2/Template.c b/memtestEDK/Memtest/Test2/Template.c new file mode 100644 index 0000000..723d7d9 --- /dev/null +++ b/memtestEDK/Memtest/Test2/Template.c @@ -0,0 +1,18 @@ +#include + +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +UefiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + return EFI_SUCCESS; + +} \ No newline at end of file diff --git a/memtestEDK/Memtest/Test2/Template.inf b/memtestEDK/Memtest/Test2/Template.inf new file mode 100644 index 0000000..0d31854 --- /dev/null +++ b/memtestEDK/Memtest/Test2/Template.inf @@ -0,0 +1,32 @@ +[Defines] + INF_VERSION = 1.25 + BASE_NAME = Template + FILE_GUID = https://www.guidgenerator.com/online-guid-generator.aspx + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC Etc... +# + +[Sources] + Template.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + UefiLib + +[Guids] + +[Ppis] + +[Protocols] + +[FeaturePcd] + +[Pcd] -- cgit v1.2.3-55-g7522