mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2024-11-27 01:50:20 -06:00
Add the 64-bit and 32-bit CC flag
Added a new CC flag into build32 and build64 Makefiles to distinguish whether compiling to 32-bit or 64-bit code. [Lionel Debroux: rebased on the memrw functions refactor.] Signed-off-by: Chao Li <lichao@loongson.cn>
This commit is contained in:
parent
8d966d98f4
commit
e99ce97648
@ -52,7 +52,7 @@ extern barrier_t *run_barrier;
|
|||||||
*/
|
*/
|
||||||
extern spinlock_t *error_mutex;
|
extern spinlock_t *error_mutex;
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
/**
|
/**
|
||||||
* The word width (in bits) used for memory testing.
|
* The word width (in bits) used for memory testing.
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
#define NATIVE_MSB UINT64_C(0x8000000000000000)
|
#define NATIVE_MSB UINT64_C(0x8000000000000000)
|
||||||
#else
|
#else
|
||||||
#define NATIVE_MSB 0x80000000
|
#define NATIVE_MSB 0x80000000
|
||||||
@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
#define efiapi __attribute__((ms_abi))
|
#define efiapi __attribute__((ms_abi))
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
typedef uint64_t uintn_t;
|
typedef uint64_t uintn_t;
|
||||||
#else
|
#else
|
||||||
typedef uint32_t uintn_t;
|
typedef uint32_t uintn_t;
|
||||||
|
@ -146,7 +146,7 @@ static void test_frame_buffer(screen_info_t *si)
|
|||||||
pixel_value.word = (r_value << si->red_pos) | (g_value << si->green_pos) | (b_value << si->blue_pos);
|
pixel_value.word = (r_value << si->red_pos) | (g_value << si->green_pos) | (b_value << si->blue_pos);
|
||||||
|
|
||||||
uintptr_t lfb_base = si->lfb_base;
|
uintptr_t lfb_base = si->lfb_base;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (LFB_CAPABILITY_64BIT_BASE & si->capabilities) {
|
if (LFB_CAPABILITY_64BIT_BASE & si->capabilities) {
|
||||||
lfb_base |= (uintptr_t)si->ext_lfb_base << 32;
|
lfb_base |= (uintptr_t)si->ext_lfb_base << 32;
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ static efi_status_t set_screen_info_from_gop(screen_info_t *si, efi_handle_t *ha
|
|||||||
si->lfb_width = best_info.h_resolution;
|
si->lfb_width = best_info.h_resolution;
|
||||||
si->lfb_height = best_info.v_resolution;
|
si->lfb_height = best_info.v_resolution;
|
||||||
si->lfb_base = lfb_base;
|
si->lfb_base = lfb_base;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (lfb_base >> 32) {
|
if (lfb_base >> 32) {
|
||||||
si->capabilities |= LFB_CAPABILITY_64BIT_BASE;
|
si->capabilities |= LFB_CAPABILITY_64BIT_BASE;
|
||||||
si->ext_lfb_base = lfb_base >> 32;
|
si->ext_lfb_base = lfb_base >> 32;
|
||||||
@ -669,7 +669,7 @@ static efi_status_t set_efi_info_and_exit_boot_services(efi_handle_t handle, boo
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64
|
#if (ARCH_BITS == 64)
|
||||||
boot_params->efi_info.loader_signature = EFI64_LOADER_SIGNATURE;
|
boot_params->efi_info.loader_signature = EFI64_LOADER_SIGNATURE;
|
||||||
#else
|
#else
|
||||||
boot_params->efi_info.loader_signature = EFI32_LOADER_SIGNATURE;
|
boot_params->efi_info.loader_signature = EFI32_LOADER_SIGNATURE;
|
||||||
@ -679,7 +679,7 @@ static efi_status_t set_efi_info_and_exit_boot_services(efi_handle_t handle, boo
|
|||||||
boot_params->efi_info.mem_desc_version = mem_desc_version;
|
boot_params->efi_info.mem_desc_version = mem_desc_version;
|
||||||
boot_params->efi_info.mem_map = (uintptr_t)mem_map;
|
boot_params->efi_info.mem_map = (uintptr_t)mem_map;
|
||||||
boot_params->efi_info.mem_map_size = mem_map_size;
|
boot_params->efi_info.mem_map_size = mem_map_size;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
boot_params->efi_info.sys_tab_hi = (uintptr_t)sys_table >> 32;
|
boot_params->efi_info.sys_tab_hi = (uintptr_t)sys_table >> 32;
|
||||||
boot_params->efi_info.mem_map_hi = (uintptr_t)mem_map >> 32;
|
boot_params->efi_info.mem_map_hi = (uintptr_t)mem_map >> 32;
|
||||||
#endif
|
#endif
|
||||||
@ -691,7 +691,7 @@ fail:
|
|||||||
static void set_e820_map(boot_params_t *params)
|
static void set_e820_map(boot_params_t *params)
|
||||||
{
|
{
|
||||||
uintptr_t mem_map_addr = params->efi_info.mem_map;
|
uintptr_t mem_map_addr = params->efi_info.mem_map;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
mem_map_addr |= (uintptr_t)params->efi_info.mem_map_hi << 32;
|
mem_map_addr |= (uintptr_t)params->efi_info.mem_map_hi << 32;
|
||||||
#endif
|
#endif
|
||||||
size_t mem_map_size = params->efi_info.mem_map_size;
|
size_t mem_map_size = params->efi_info.mem_map_size;
|
||||||
|
@ -11,7 +11,7 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS = -std=gnu11 -Wall -Wextra -Wshadow -m32 -march=i586 -fpic -fno-builtin \
|
CFLAGS = -std=gnu11 -Wall -Wextra -Wshadow -m32 -march=i586 -fpic -fno-builtin \
|
||||||
-ffreestanding -fomit-frame-pointer -fno-stack-protector
|
-ffreestanding -fomit-frame-pointer -fno-stack-protector -DARCH_BITS=32
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS+=-ggdb3 -DDEBUG_GDB
|
CFLAGS+=-ggdb3 -DDEBUG_GDB
|
||||||
|
@ -11,7 +11,8 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS = -std=gnu11 -Wall -Wextra -Wshadow -m64 -march=x86-64 -mno-mmx -mno-sse -mno-sse2 \
|
CFLAGS = -std=gnu11 -Wall -Wextra -Wshadow -m64 -march=x86-64 -mno-mmx -mno-sse -mno-sse2 \
|
||||||
-fpic -fno-builtin -ffreestanding -fomit-frame-pointer -fno-stack-protector
|
-fpic -fno-builtin -ffreestanding -fomit-frame-pointer -fno-stack-protector \
|
||||||
|
-DARCH_BITS=64
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS+=-ggdb3 -DDEBUG_GDB
|
CFLAGS+=-ggdb3 -DDEBUG_GDB
|
||||||
|
@ -100,7 +100,7 @@ static rsdp_t *scan_for_rsdp(uintptr_t addr, int length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
static rsdp_t *find_rsdp_in_efi64_system_table(efi64_system_table_t *system_table)
|
static rsdp_t *find_rsdp_in_efi64_system_table(efi64_system_table_t *system_table)
|
||||||
{
|
{
|
||||||
efi64_config_table_t *config_tables = (efi64_config_table_t *)map_region(system_table->config_tables,
|
efi64_config_table_t *config_tables = (efi64_config_table_t *)map_region(system_table->config_tables,
|
||||||
@ -150,7 +150,7 @@ static uintptr_t find_rsdp(void)
|
|||||||
|
|
||||||
// Search for the RSDP
|
// Search for the RSDP
|
||||||
rsdp_t *rp = NULL;
|
rsdp_t *rp = NULL;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (efi_info->loader_signature == EFI64_LOADER_SIGNATURE) {
|
if (efi_info->loader_signature == EFI64_LOADER_SIGNATURE) {
|
||||||
uintptr_t system_table_addr = (uintptr_t)efi_info->sys_tab_hi << 32 | (uintptr_t)efi_info->sys_tab;
|
uintptr_t system_table_addr = (uintptr_t)efi_info->sys_tab_hi << 32 | (uintptr_t)efi_info->sys_tab;
|
||||||
system_table_addr = map_region(system_table_addr, sizeof(efi64_system_table_t), true);
|
system_table_addr = map_region(system_table_addr, sizeof(efi64_system_table_t), true);
|
||||||
@ -279,7 +279,7 @@ static bool parse_fadt(uintptr_t fadt_addr)
|
|||||||
acpi_config.pm_addr = *(uint32_t *)(fadt_addr+FADT_PM_TMR_BLK_OFFSET);
|
acpi_config.pm_addr = *(uint32_t *)(fadt_addr+FADT_PM_TMR_BLK_OFFSET);
|
||||||
acpi_config.pm_is_io = true;
|
acpi_config.pm_is_io = true;
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
acpi_gen_addr_struct *rt;
|
acpi_gen_addr_struct *rt;
|
||||||
|
|
||||||
// Get APIC Timer Address
|
// Get APIC Timer Address
|
||||||
|
@ -33,7 +33,7 @@ static efi_runtime_services_t *efi_rs_table = NULL;
|
|||||||
void hwctrl_init(void)
|
void hwctrl_init(void)
|
||||||
{
|
{
|
||||||
boot_params_t *boot_params = (boot_params_t *)boot_params_addr;
|
boot_params_t *boot_params = (boot_params_t *)boot_params_addr;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (boot_params->efi_info.loader_signature == EFI64_LOADER_SIGNATURE) {
|
if (boot_params->efi_info.loader_signature == EFI64_LOADER_SIGNATURE) {
|
||||||
uintptr_t system_table_addr = (uintptr_t)boot_params->efi_info.sys_tab_hi << 32 | boot_params->efi_info.sys_tab;
|
uintptr_t system_table_addr = (uintptr_t)boot_params->efi_info.sys_tab_hi << 32 | boot_params->efi_info.sys_tab;
|
||||||
if (system_table_addr != 0) {
|
if (system_table_addr != 0) {
|
||||||
|
@ -306,7 +306,7 @@ void screen_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lfb_base = screen_info->lfb_base;
|
lfb_base = screen_info->lfb_base;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (LFB_CAPABILITY_64BIT_BASE & screen_info->capabilities) {
|
if (LFB_CAPABILITY_64BIT_BASE & screen_info->capabilities) {
|
||||||
lfb_base |= (uintptr_t)screen_info->ext_lfb_base << 32;
|
lfb_base |= (uintptr_t)screen_info->ext_lfb_base << 32;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ static char *get_tstruct_string(struct tstruct_header *header, uint16_t maxlen,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
static smbiosv2_t *find_smbiosv2_in_efi64_system_table(efi64_system_table_t *system_table)
|
static smbiosv2_t *find_smbiosv2_in_efi64_system_table(efi64_system_table_t *system_table)
|
||||||
{
|
{
|
||||||
efi64_config_table_t *config_tables = (efi64_config_table_t *) map_region(system_table->config_tables, system_table->num_config_tables * sizeof(efi64_config_table_t), true);
|
efi64_config_table_t *config_tables = (efi64_config_table_t *) map_region(system_table->config_tables, system_table->num_config_tables * sizeof(efi64_config_table_t), true);
|
||||||
@ -90,7 +90,7 @@ static uintptr_t find_smbiosv2_adr(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (rp == NULL && efi_info -> loader_signature == EFI64_LOADER_SIGNATURE) {
|
if (rp == NULL && efi_info -> loader_signature == EFI64_LOADER_SIGNATURE) {
|
||||||
// EFI64
|
// EFI64
|
||||||
if (rp == NULL && efi_info->loader_signature == EFI64_LOADER_SIGNATURE) {
|
if (rp == NULL && efi_info->loader_signature == EFI64_LOADER_SIGNATURE) {
|
||||||
|
@ -424,7 +424,7 @@ static void reset_usb_controller(hci_info_t *hci)
|
|||||||
uintptr_t mmio_size = pci_config_read32(bus, dev, func, bar);
|
uintptr_t mmio_size = pci_config_read32(bus, dev, func, bar);
|
||||||
pci_config_write32(bus, dev, func, bar, base_addr);
|
pci_config_write32(bus, dev, func, bar, base_addr);
|
||||||
bool in_io_space = base_addr & 0x1;
|
bool in_io_space = base_addr & 0x1;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
if (!in_io_space && (base_addr & 0x4)) {
|
if (!in_io_space && (base_addr & 0x4)) {
|
||||||
base_addr += (uintptr_t)pci_config_read32(bus, dev, func, bar + 4) << 32;
|
base_addr += (uintptr_t)pci_config_read32(bus, dev, func, bar + 4) << 32;
|
||||||
pci_config_write32(bus, dev, func, bar + 4, 0xffffffff);
|
pci_config_write32(bus, dev, func, bar + 4, 0xffffffff);
|
||||||
|
@ -135,7 +135,7 @@ int test_own_addr2(int my_cpu, int stage)
|
|||||||
// Calculate the offset (in pages) between the virtual address and the physical address.
|
// Calculate the offset (in pages) between the virtual address and the physical address.
|
||||||
offset = (vm_map[0].pm_base_addr / VM_WINDOW_SIZE) * VM_WINDOW_SIZE;
|
offset = (vm_map[0].pm_base_addr / VM_WINDOW_SIZE) * VM_WINDOW_SIZE;
|
||||||
offset = (offset >= VM_PINNED_SIZE) ? offset - VM_PINNED_SIZE : 0;
|
offset = (offset >= VM_PINNED_SIZE) ? offset - VM_PINNED_SIZE : 0;
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
// Convert to a byte address offset. This will translate the virtual address into a physical address.
|
// Convert to a byte address offset. This will translate the virtual address into a physical address.
|
||||||
offset *= PAGE_SIZE;
|
offset *= PAGE_SIZE;
|
||||||
#else
|
#else
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* Test word atomic read and write functions.
|
* Test word atomic read and write functions.
|
||||||
*/
|
*/
|
||||||
#include "memrw.h"
|
#include "memrw.h"
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
#define read_word read64
|
#define read_word read64
|
||||||
#define write_word write64
|
#define write_word write64
|
||||||
#else
|
#else
|
||||||
@ -73,7 +73,7 @@ static inline uintptr_t round_up(uintptr_t value, size_t align_size)
|
|||||||
static inline testword_t prsg(testword_t state)
|
static inline testword_t prsg(testword_t state)
|
||||||
{
|
{
|
||||||
// This uses the algorithms described at https://en.wikipedia.org/wiki/Xorshift
|
// This uses the algorithms described at https://en.wikipedia.org/wiki/Xorshift
|
||||||
#ifdef __x86_64__
|
#if (ARCH_BITS == 64)
|
||||||
state ^= state << 13;
|
state ^= state << 13;
|
||||||
state ^= state >> 7;
|
state ^= state >> 7;
|
||||||
state ^= state << 17;
|
state ^= state << 17;
|
||||||
|
Loading…
Reference in New Issue
Block a user