diff options
author | Regina König | 2020-07-22 17:02:47 +0200 |
---|---|---|
committer | Regina König | 2020-07-22 17:02:47 +0200 |
commit | 736abeb2b9b3d2b9e4bb9affa2e36d2c0f1f4bec (patch) | |
tree | 1357203bdf2c72a311395637db6e22f70c678698 | |
parent | Added some information about at&t assembler (diff) | |
download | memtest86-736abeb2b9b3d2b9e4bb9affa2e36d2c0f1f4bec.tar.gz memtest86-736abeb2b9b3d2b9e4bb9affa2e36d2c0f1f4bec.tar.xz memtest86-736abeb2b9b3d2b9e4bb9affa2e36d2c0f1f4bec.zip |
Test application for smp.c
8 files changed, 49 insertions, 22 deletions
diff --git a/documentation/memtest86+ code/smp_c_h b/documentation/memtest86+ code/smp_c_h index 2a30d21..8ff5ce6 100644 --- a/documentation/memtest86+ code/smp_c_h +++ b/documentation/memtest86+ code/smp_c_h @@ -1,7 +1,6 @@ smp.h ==================================== - - +What is the barrier structure? diff --git a/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.c b/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.c new file mode 100644 index 0000000..61c05c8 --- /dev/null +++ b/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.c @@ -0,0 +1,13 @@ + +#include <Library/UefiLib.h> + + +#include "cpuid.h" +#include "smp.h" +#include "environment.h" +#include "get_cpuid_test.h" + + +void get_cpuid_test() { + Print(L"Calling test\n"); +}
\ No newline at end of file diff --git a/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.h b/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.h new file mode 100644 index 0000000..a7eaa65 --- /dev/null +++ b/memtest_for_edk2/Memtest/SingleComponents/SmpTestFunctions/get_cpuid_test.h @@ -0,0 +1,2 @@ + +void get_cpuid_test();
\ No newline at end of file diff --git a/memtest_for_edk2/Memtest/SingleComponents/TestSmp.c b/memtest_for_edk2/Memtest/SingleComponents/TestSmp.c index 5076981..869d48d 100644 --- a/memtest_for_edk2/Memtest/SingleComponents/TestSmp.c +++ b/memtest_for_edk2/Memtest/SingleComponents/TestSmp.c @@ -1,9 +1,12 @@ +#define UEFI + + #include <Uefi.h> #include <Library/UefiLib.h> #include <Library/UefiApplicationEntryPoint.h> -#include "smp.h" +#include "SmpTestFunctions/get_cpuid_test.h" EFI_STATUS EFIAPI @@ -12,10 +15,12 @@ UefiMain ( IN EFI_SYSTEM_TABLE *SystemTable ) { - Print(L"Test for smp\n\n"); + Print(L"Test of smp.h\n\n"); + get_cpuid_test(); + Print(L"Test of smp.c\n\n"); Print(L"Test finished.\n"); return EFI_SUCCESS; -}
\ No newline at end of file +} diff --git a/memtest_for_edk2/Memtest/SingleComponents/TestSmp.inf b/memtest_for_edk2/Memtest/SingleComponents/TestSmp.inf index 11d68c1..bd2908c 100644 --- a/memtest_for_edk2/Memtest/SingleComponents/TestSmp.inf +++ b/memtest_for_edk2/Memtest/SingleComponents/TestSmp.inf @@ -16,6 +16,8 @@ [Sources] TestSmp.c smp.c + cpuid.c + SmpTestFunctions/get_cpuid_test.c [Packages] MdePkg/MdePkg.dec diff --git a/memtest_for_edk2/Memtest/SingleComponents/environment.h b/memtest_for_edk2/Memtest/SingleComponents/environment.h index 26406dd..8546099 100644 --- a/memtest_for_edk2/Memtest/SingleComponents/environment.h +++ b/memtest_for_edk2/Memtest/SingleComponents/environment.h @@ -1,6 +1,7 @@ #include "stdin.h" + #if __linux__ // or #if __GNUC__ #if __x86_64__ || __ppc64__ #define ENVIRONMENT64 diff --git a/memtest_for_edk2/Memtest/SingleComponents/smp.c b/memtest_for_edk2/Memtest/SingleComponents/smp.c index c101c36..3e10332 100644 --- a/memtest_for_edk2/Memtest/SingleComponents/smp.c +++ b/memtest_for_edk2/Memtest/SingleComponents/smp.c @@ -14,6 +14,7 @@ #include "cpuid.h" #include "smp.h" #include "test.h" +#include "environment.h" #define DELAY_FACTOR 1 unsigned num_cpus = 1; // There is at least one cpu, the BSP @@ -111,12 +112,12 @@ volatile ap_info_t AP[MAX_CPUS]; void PUT_MEM16(uintptr_t addr, uint16_t val) { - *((volatile uint16_t *)addr) = val; + *((volatile uint16_t *)(MAX_BLOCK_SIZE)addr) = val; } void PUT_MEM32(uintptr_t addr, uint32_t val) { - *((volatile uint32_t *)addr) = val; + *((volatile uint32_t *)(MAX_BLOCK_SIZE)addr) = val; } static void inline @@ -233,7 +234,7 @@ void kick_cpu(unsigned cpu_num) APIC_WRITE(APICR_ESR, 0); - SEND_IPI(apic_id, 0, 0, APIC_DELMODE_STARTUP, (unsigned)startup_32 >> 12); + SEND_IPI(apic_id, 0, 0, APIC_DELMODE_STARTUP, (unsigned)(MAX_BLOCK_SIZE)startup_32 >> 12); timeout = 0; do { @@ -340,7 +341,7 @@ static int checksum(unsigned char *mp, int len) /* Parse an MP config table for CPU information */ bool read_mp_config_table(uintptr_t addr) { - mp_config_table_header_t *mpc = (mp_config_table_header_t*)addr; + mp_config_table_header_t *mpc = (mp_config_table_header_t*)(MAX_BLOCK_SIZE)addr; uint8_t *tab_entry_ptr; uint8_t *mpc_table_end; @@ -355,7 +356,7 @@ bool read_mp_config_table(uintptr_t addr) * AMD64, but it ignores the real problem, which is that lapic_addr * is only 32 bits. Maybe that's OK, but it should be investigated. */ - APIC = (volatile apic_register_t*)(uintptr_t)mpc->lapic_addr; + APIC = (volatile apic_register_t*)(MAX_BLOCK_SIZE)(uintptr_t)mpc->lapic_addr; tab_entry_ptr = ((uint8_t*)mpc) + sizeof(mp_config_table_header_t); mpc_table_end = ((uint8_t*)mpc) + mpc->length; @@ -412,8 +413,10 @@ scan_for_floating_ptr_struct(uintptr_t addr, uint32_t length) while ((uintptr_t)addr < end) { - fp = (floating_pointer_struct_t*)addr; - if (*(unsigned int *)addr == FPSignature && fp->length == 1 && checksum((unsigned char*)addr, 16) == 0 && ((fp->spec_rev == 1) || (fp->spec_rev == 4))) { + fp = (floating_pointer_struct_t*)(MAX_BLOCK_SIZE)addr; + if (*(unsigned int *)(MAX_BLOCK_SIZE)addr == FPSignature && fp->length == 1 + && checksum((unsigned char*)(MAX_BLOCK_SIZE)addr, 16) == 0 + && ((fp->spec_rev == 1) || (fp->spec_rev == 4))) { return fp; } addr += 4; @@ -429,9 +432,9 @@ rsdp_t *scan_for_rsdp(uintptr_t addr, uint32_t length) while ((uintptr_t)addr < end) { - rp = (rsdp_t*)addr; - if (*(unsigned int *)addr == RSDPSignature && - checksum((unsigned char*)addr, rp->length) == 0) { + rp = (rsdp_t*)(MAX_BLOCK_SIZE)addr; + if (*(unsigned int *)(MAX_BLOCK_SIZE)addr == RSDPSignature && + checksum((unsigned char*)(MAX_BLOCK_SIZE)addr, rp->length) == 0) { return rp; } addr += 4; @@ -442,7 +445,7 @@ rsdp_t *scan_for_rsdp(uintptr_t addr, uint32_t length) /* Parse a MADT table for processor entries */ int parse_madt(uintptr_t addr) { - mp_config_table_header_t *mpc = (mp_config_table_header_t*)addr; + mp_config_table_header_t *mpc = (mp_config_table_header_t*)(MAX_BLOCK_SIZE)addr; uint8_t *tab_entry_ptr; uint8_t *mpc_table_end; @@ -450,7 +453,7 @@ int parse_madt(uintptr_t addr) { return FALSE; } - APIC = (volatile apic_register_t*)(uintptr_t)mpc->lapic_addr; + APIC = (volatile apic_register_t*)(MAX_BLOCK_SIZE)(uintptr_t)mpc->lapic_addr; tab_entry_ptr = ((uint8_t*)mpc) + sizeof(mp_config_table_header_t); mpc_table_end = ((uint8_t*)mpc) + mpc->length; @@ -577,7 +580,7 @@ void smp_find_cpus() /* Found the RSDP, now get either the RSDT or XSDT */ if (rp->revision >= 2) { - rt = (rsdt_t *)rp->xrsdt[0]; + rt = (rsdt_t *)(MAX_BLOCK_SIZE)rp->xrsdt[0]; if (rt == 0) { return; @@ -591,7 +594,7 @@ void smp_find_cpus() } } else { - rt = (rsdt_t *)rp->rsdt; + rt = (rsdt_t *)(MAX_BLOCK_SIZE)rp->rsdt; if (rt == 0) { return; } @@ -611,12 +614,12 @@ void smp_find_cpus() while (tab_ptr < tab_end) { uiptr = *((unsigned int *)tab_ptr); - ptr = (unsigned int *)uiptr; + ptr = (unsigned int *)(MAX_BLOCK_SIZE)uiptr; /* Check for the MADT signature */ if (ptr && *ptr == MADTSignature) { /* Found it, now parse it */ - if (parse_madt((uintptr_t)ptr)) { + if (parse_madt((uintptr_t)(MAX_BLOCK_SIZE)ptr)) { return; } } diff --git a/memtest_for_edk2/Memtest/SingleComponents/stddef.h b/memtest_for_edk2/Memtest/SingleComponents/stddef.h index 213c89b..e835dc8 100644 --- a/memtest_for_edk2/Memtest/SingleComponents/stddef.h +++ b/memtest_for_edk2/Memtest/SingleComponents/stddef.h @@ -1,7 +1,9 @@ #ifndef I386_STDDEF_H #define I386_STDDEF_H - +/* +#ifndef UEFI #define NULL ((void *)0) +#endif*/ typedef unsigned long size_t; |