mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:57:45 +00:00
AK+Userland: Stub out code that isn't currently implemented on AARCH64
Even though this almost certainly wouldn't run properly even if we had a working kernel for AARCH64 this at least lets us build all the userland binaries.
This commit is contained in:
parent
c18c84dbfd
commit
31bd5b1a02
17 changed files with 206 additions and 6 deletions
|
@ -10,6 +10,7 @@
|
|||
// This is the size of the floating point environment image in protected mode
|
||||
static_assert(sizeof(__x87_floating_point_environment) == 28);
|
||||
|
||||
#ifndef AK_ARCH_AARCH64
|
||||
static u16 read_status_register()
|
||||
{
|
||||
u16 status_register;
|
||||
|
@ -45,6 +46,7 @@ static void set_mxcsr(u32 new_mxcsr)
|
|||
}
|
||||
|
||||
static constexpr u32 default_mxcsr_value = 0x1f80;
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -53,10 +55,14 @@ int fegetenv(fenv_t* env)
|
|||
if (!env)
|
||||
return 1;
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
asm volatile("fnstenv %0"
|
||||
: "=m"(env->__x87_fpu_env)::"memory");
|
||||
|
||||
env->__mxcsr = read_mxcsr();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -66,6 +72,9 @@ int fesetenv(fenv_t const* env)
|
|||
if (!env)
|
||||
return 1;
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
if (env == FE_DFL_ENV) {
|
||||
asm volatile("finit");
|
||||
set_mxcsr(default_mxcsr_value);
|
||||
|
@ -76,6 +85,7 @@ int fesetenv(fenv_t const* env)
|
|||
: "memory");
|
||||
|
||||
set_mxcsr(env->__mxcsr);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -87,9 +97,13 @@ int feholdexcept(fenv_t* env)
|
|||
fenv_t current_env;
|
||||
fegetenv(¤t_env);
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
current_env.__x87_fpu_env.__status_word &= ~FE_ALL_EXCEPT;
|
||||
current_env.__x87_fpu_env.__status_word &= ~(1 << 7); // Clear the "Exception Status Summary" bit
|
||||
current_env.__x87_fpu_env.__control_word &= FE_ALL_EXCEPT; // Masking these bits stops the corresponding exceptions from being generated according to the Intel Programmer's Manual
|
||||
#endif
|
||||
|
||||
fesetenv(¤t_env);
|
||||
|
||||
|
@ -122,8 +136,12 @@ int fesetexceptflag(fexcept_t const* except, int exceptions)
|
|||
fegetenv(¤t_env);
|
||||
|
||||
exceptions &= FE_ALL_EXCEPT;
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
current_env.__x87_fpu_env.__status_word &= exceptions;
|
||||
current_env.__x87_fpu_env.__status_word &= ~(1 << 7); // Make sure exceptions don't get raised
|
||||
#endif
|
||||
|
||||
fesetenv(¤t_env);
|
||||
return 0;
|
||||
|
@ -131,8 +149,12 @@ int fesetexceptflag(fexcept_t const* except, int exceptions)
|
|||
|
||||
int fegetround()
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
// There's no way to signal whether the SSE rounding mode and x87 ones are different, so we assume they're the same
|
||||
return (read_status_register() >> 10) & 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
int fesetround(int rounding_mode)
|
||||
|
@ -140,6 +162,9 @@ int fesetround(int rounding_mode)
|
|||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOWARDZERO)
|
||||
return 1;
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
auto control_word = read_control_word();
|
||||
|
||||
control_word &= ~(3 << 10);
|
||||
|
@ -154,6 +179,8 @@ int fesetround(int rounding_mode)
|
|||
|
||||
set_mxcsr(mxcsr);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -164,8 +191,12 @@ int feclearexcept(int exceptions)
|
|||
fenv_t current_env;
|
||||
fegetenv(¤t_env);
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
current_env.__x87_fpu_env.__status_word &= ~exceptions;
|
||||
current_env.__x87_fpu_env.__status_word &= ~(1 << 7); // Clear the "Exception Status Summary" bit
|
||||
#endif
|
||||
|
||||
fesetenv(¤t_env);
|
||||
return 0;
|
||||
|
@ -173,10 +204,15 @@ int feclearexcept(int exceptions)
|
|||
|
||||
int fetestexcept(int exceptions)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)exceptions;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
u16 status_register = read_status_register() & FE_ALL_EXCEPT;
|
||||
exceptions &= FE_ALL_EXCEPT;
|
||||
|
||||
return status_register & exceptions;
|
||||
#endif
|
||||
}
|
||||
|
||||
int feraiseexcept(int exceptions)
|
||||
|
@ -186,6 +222,9 @@ int feraiseexcept(int exceptions)
|
|||
|
||||
exceptions &= FE_ALL_EXCEPT;
|
||||
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
// While the order in which the exceptions is raised is unspecified, FE_OVERFLOW and FE_UNDERFLOW must be raised before FE_INEXACT, so handle that case in this branch
|
||||
if (exceptions & FE_INEXACT) {
|
||||
env.__x87_fpu_env.__status_word &= ((u16)exceptions & ~FE_INEXACT);
|
||||
|
@ -203,6 +242,7 @@ int feraiseexcept(int exceptions)
|
|||
env.__x87_fpu_env.__status_word &= exceptions;
|
||||
fesetenv(&env);
|
||||
asm volatile("fwait");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/ExtraMathConstants.h>
|
||||
#include <AK/FPControl.h>
|
||||
#ifndef AK_ARCH_AARCH64
|
||||
# include <AK/FPControl.h>
|
||||
#endif
|
||||
#include <AK/Math.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
@ -62,7 +64,7 @@ enum class RoundingMode {
|
|||
template<typename T>
|
||||
union FloatExtractor;
|
||||
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
#if ARCH(I386) || ARCH(X86_64) || ARCH(AARCH64)
|
||||
// This assumes long double is 80 bits, which is true with GCC on Intel platforms
|
||||
template<>
|
||||
union FloatExtractor<long double> {
|
||||
|
@ -413,6 +415,7 @@ MAKE_AK_BACKED2(remainder);
|
|||
|
||||
long double truncl(long double x) NOEXCEPT
|
||||
{
|
||||
#ifndef AK_ARCH_AARCH64
|
||||
if (fabsl(x) < LONG_LONG_MAX) {
|
||||
// This is 1.6 times faster than the implementation using the "internal_to_integer"
|
||||
// helper (on x86_64)
|
||||
|
@ -425,12 +428,14 @@ long double truncl(long double x) NOEXCEPT
|
|||
: [temp] "m"(temp));
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
return internal_to_integer(x, RoundingMode::ToZero);
|
||||
}
|
||||
|
||||
double trunc(double x) NOEXCEPT
|
||||
{
|
||||
#ifndef AK_ARCH_AARCH64
|
||||
if (fabs(x) < LONG_LONG_MAX) {
|
||||
u64 temp;
|
||||
asm(
|
||||
|
@ -440,12 +445,14 @@ double trunc(double x) NOEXCEPT
|
|||
: [temp] "m"(temp));
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
return internal_to_integer(x, RoundingMode::ToZero);
|
||||
}
|
||||
|
||||
float truncf(float x) NOEXCEPT
|
||||
{
|
||||
#ifndef AK_ARCH_AARCH64
|
||||
if (fabsf(x) < LONG_LONG_MAX) {
|
||||
u64 temp;
|
||||
asm(
|
||||
|
@ -455,40 +462,60 @@ float truncf(float x) NOEXCEPT
|
|||
: [temp] "m"(temp));
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
return internal_to_integer(x, RoundingMode::ToZero);
|
||||
}
|
||||
|
||||
long double rintl(long double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long double res;
|
||||
asm(
|
||||
"frndint\n"
|
||||
: "=t"(res)
|
||||
: "0"(value));
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
double rint(double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
double res;
|
||||
asm(
|
||||
"frndint\n"
|
||||
: "=t"(res)
|
||||
: "0"(value));
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
float rintf(float value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
float res;
|
||||
asm(
|
||||
"frndint\n"
|
||||
: "=t"(res)
|
||||
: "0"(value));
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
long lrintl(long double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long res;
|
||||
asm(
|
||||
"fistpl %0\n"
|
||||
|
@ -496,9 +523,14 @@ long lrintl(long double value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
long lrint(double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long res;
|
||||
asm(
|
||||
"fistpl %0\n"
|
||||
|
@ -506,9 +538,14 @@ long lrint(double value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
long lrintf(float value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long res;
|
||||
asm(
|
||||
"fistpl %0\n"
|
||||
|
@ -516,10 +553,15 @@ long lrintf(float value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
long long llrintl(long double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long long res;
|
||||
asm(
|
||||
"fistpq %0\n"
|
||||
|
@ -527,9 +569,14 @@ long long llrintl(long double value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
long long llrint(double value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long long res;
|
||||
asm(
|
||||
"fistpq %0\n"
|
||||
|
@ -537,9 +584,14 @@ long long llrint(double value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
long long llrintf(float value)
|
||||
{
|
||||
#ifdef AK_ARCH_AARCH64
|
||||
(void)value;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
long long res;
|
||||
asm(
|
||||
"fistpq %0\n"
|
||||
|
@ -547,6 +599,7 @@ long long llrintf(float value)
|
|||
: "t"(value)
|
||||
: "st");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
// On systems where FLT_RADIX == 2, ldexp is equivalent to scalbn
|
||||
|
|
|
@ -102,6 +102,10 @@ static int create_thread(pthread_t* thread, void* (*entry)(void*), void* argumen
|
|||
thread_params->rsi = (FlatPtr)argument;
|
||||
thread_params->rdx = (FlatPtr)thread_params->stack_location;
|
||||
thread_params->rcx = thread_params->stack_size;
|
||||
#elif ARCH(AARCH64)
|
||||
(void)entry;
|
||||
(void)argument;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
# error Unknown architecture
|
||||
#endif
|
||||
|
|
|
@ -136,6 +136,11 @@ void* memcpy(void* dest_ptr, void const* src_ptr, size_t n)
|
|||
"rep movsb"
|
||||
: "+D"(dest_ptr), "+S"(src_ptr), "+c"(n)::"memory");
|
||||
return original_dest;
|
||||
#elif ARCH(AARCH64)
|
||||
(void)dest_ptr;
|
||||
(void)src_ptr;
|
||||
(void)n;
|
||||
TODO_AARCH64();
|
||||
#else
|
||||
# error Unknown architecture
|
||||
#endif
|
||||
|
@ -168,6 +173,14 @@ void* memset(void* dest_ptr, int c, size_t n)
|
|||
}
|
||||
#elif ARCH(X86_64)
|
||||
// For x86-64, an optimized ASM implementation is found in ./arch/x86_64/memset.S
|
||||
#elif ARCH(AARCH64)
|
||||
void* memset(void* dest_ptr, int c, size_t n)
|
||||
{
|
||||
(void)dest_ptr;
|
||||
(void)c;
|
||||
(void)n;
|
||||
TODO_AARCH64();
|
||||
}
|
||||
#else
|
||||
# error Unknown architecture
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,10 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
|
|||
{
|
||||
# if ARCH(I386)
|
||||
return eip;
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
return rip;
|
||||
# else
|
||||
TODO_AARCH64();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -32,8 +34,11 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
|
|||
{
|
||||
# if ARCH(I386)
|
||||
eip = ip;
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
rip = ip;
|
||||
# else
|
||||
(void)ip;
|
||||
TODO_AARCH64();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -41,8 +46,10 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
|
|||
{
|
||||
# if ARCH(I386)
|
||||
return ebp;
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
return rbp;
|
||||
# else
|
||||
TODO_AARCH64();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -50,8 +57,11 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
|
|||
{
|
||||
# if ARCH(I386)
|
||||
ebp = bp;
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
rbp = bp;
|
||||
# else
|
||||
(void)bp;
|
||||
TODO_AARCH64();
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue