mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2026-11-24 15:08:48 -06:00
* Initial commit for ARM64 (header.S & startup.S) * Add Aarch64 interrupt handler * Adapt lib/ to Aarch64 * Small ASM addition for AArch64 * Rewrite Aarch64 system/ - cpuid.c/cpuinfo.c for CPU detection (Qualcomm, Apple, Nvidia, etc) - Add ARM Power State Coordination Interface (PSCI) functions - vmem.c for Virtual Memory MAnagement on ARM64 - Various functions placeholders * Add pseudo-TSC correction for Aarch64 * Add pseudo-tsc measurement for Aarch64 * Add Aarch64 if/elif on basic IO/MMIO/MEM RW functions * Add support for Surface 13 / Snapdragon X KB USB Fix an issue with the XHCI.c drivers with packets > 8 bytes * Add MMIO Serial support for ARM64 * Add ARM64 ASM for block_move & mov_inv_fixed. Fix VM start pointer * Add ARM Serial MMIO configuration * Revert previous commit & reintroduce ARM64 cache functions * Add ACPI MCFG Table description & SMP parsing. This requires careful review/testing to avoid BC issues! * Revert previous commmit and reintroduce relocation and heap change for ARM64 * ARM64 does not support CPU PNS. Use DMI type4 parsing instead. Add SMBIOS v3 support (ARM64 does not support v2) * Fix typo in pci.h * Move Aarch64 load-limit computation from main.c to pmem.c * Add .arm64 to version string. Use PMU for clock computation display. Fix D5 Temp NULL not handled * Add Makefile and linker scripts for aarch64. Set cross-compiler from x86 by default * Attempt to add aarch64 to workflow * Remove a remaining internal debug flag * Correct typos * Fix ARM64 SMP freeze assign heap when RAM is one contiguous region, keep it below 3GB for DMA (RPi5), add DSB before SEV to avoid missed barrier wakeups Sync I-cache with D-cache after program relocation to prevent stale instruction fetch * Validate MADT entry lengths to avoid reading past the table (or looping forever) on malformed ACPI tables * aarch64: add NEON kernels for the vector PRSG tests Tests 3 (bus stress) and 5 (moving inversions, random) now dispatch to 128-bit NEON fill/scan instead of scalar. * Fix ARM64 data abort from the per-second DMI check & fix unbounded strstr() * Fix ARM64 data abort when saving results to USB after a relocation * Update README.md with AArch64 (ARM64) support * aarch64: shrink static string tables, harden MCFG/paging Replace pointer-based name tables with inline char arrays (saves ~1.5KB + relocs) alidate MCFG length/bus ranges, and bound pm_map/vm_map fills against overflows * Add NVIDIA & latest Apple ARM SoC to cpuid.c * Fix stale pointers read by the report writer after a program relocation cpu_model gets a static init (creates its reloc record)SPD type becomes an inline char array
136 lines
2.8 KiB
C
136 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2020 Martin Whitaker.
|
|
//
|
|
// Derived from an extract of memtest86+ lib.c:
|
|
//
|
|
// lib.c - MemTest-86 Version 3.4
|
|
//
|
|
// Released under version 2 of the Gnu Public License.
|
|
// By Chris Brady
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "string.h"
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Private Functions
|
|
//------------------------------------------------------------------------------
|
|
|
|
void reverse(char s[])
|
|
{
|
|
int i, j;
|
|
char c;
|
|
|
|
for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
|
|
c = s[i];
|
|
s[i] = s[j];
|
|
s[j] = c;
|
|
}
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
// Public Functions
|
|
//------------------------------------------------------------------------------
|
|
|
|
void *memmove(void *dest, const void *src, size_t n)
|
|
{
|
|
char *d = (char *)dest, *s = (char *)src;
|
|
|
|
if (n > 0) {
|
|
if (dest < src) {
|
|
for (size_t i = 0; i < n; i++) {
|
|
d[i] = s[i];
|
|
}
|
|
}
|
|
if (dest > src) {
|
|
size_t i = n;
|
|
do {
|
|
i--;
|
|
d[i] = s[i];
|
|
} while (i > 0);
|
|
}
|
|
}
|
|
return dest;
|
|
}
|
|
|
|
#if (defined(DEBUG_GDB) || defined(__loongarch_lp64) || defined(__aarch64__) || defined(__clang__))
|
|
|
|
void *memcpy (void *dest, const void *src, size_t len)
|
|
{
|
|
char *d = dest;
|
|
const char *s = src;
|
|
while (len--)
|
|
*d++ = *s++;
|
|
return dest;
|
|
}
|
|
|
|
void *memset (void *dest, int val, size_t len)
|
|
{
|
|
unsigned char *ptr = dest;
|
|
while (len-- > 0)
|
|
*ptr++ = val;
|
|
return dest;
|
|
}
|
|
|
|
#endif
|
|
|
|
char *strstr(const char *haystack, const char *needle)
|
|
{
|
|
size_t haystack_len = strlen(haystack);
|
|
size_t needle_len = strlen(needle);
|
|
|
|
if (needle_len > haystack_len) {
|
|
return NULL;
|
|
}
|
|
|
|
size_t max_idx = haystack_len - needle_len;
|
|
|
|
for (size_t idx = 0; idx <= max_idx; idx++) {
|
|
if (memcmp(haystack + idx, needle, needle_len) == 0) {
|
|
return (char *)haystack + idx;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
char *itoa(int num, char *str)
|
|
{
|
|
int i = 0;
|
|
|
|
/* Special case for 0 */
|
|
if (num == 0) {
|
|
str[i++] = '0';
|
|
str[i] = '\0';
|
|
return str;
|
|
}
|
|
|
|
// Parse digits
|
|
while (num != 0) {
|
|
int rem = num % 10;
|
|
str[i++] = (rem > 9) ? (rem-10) + 'a' : rem + '0';
|
|
num /= 10;
|
|
}
|
|
|
|
// Last is string terminator
|
|
str[i] = '\0';
|
|
|
|
reverse(str);
|
|
|
|
return str;
|
|
}
|
|
|
|
uint32_t hexstr2int(const char *hexstr) {
|
|
uint32_t ival = 0;
|
|
while (*hexstr) {
|
|
uint8_t b = *hexstr++;
|
|
|
|
if (b >= '0' && b <= '9') b = b - '0';
|
|
else if (b >= 'a' && b <='f') b = b - 'a' + 10;
|
|
else if (b >= 'A' && b <='F') b = b - 'A' + 10;
|
|
else return 0;
|
|
|
|
ival = (ival << 4) | (b & 0xF);
|
|
}
|
|
return ival;
|
|
}
|