kernel: add arm architecture support
Some checks failed
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 5m35s
Build OS / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Has been cancelled
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Build OS / Build amd64 (push) Has been cancelled
Build OS / Build i386 (push) Has been cancelled
Build OS / Build aarch64 (push) Has been cancelled
Build OS / Build arm (push) Has been cancelled

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
2025-01-10 18:55:34 +02:00
parent e6933acfb0
commit fbe9fbfbd1
44 changed files with 1019 additions and 29 deletions

View File

@ -50,7 +50,7 @@ extern "C"
#define P_tmpdir "/tmp/"
typedef long fpos_t;
typedef unsigned long size_t;
typedef __SIZE_TYPE__ size_t;
struct _IO_FILE
{

View File

@ -46,7 +46,7 @@ extern "C"
long rem;
} ldiv_t;
typedef unsigned long size_t;
typedef __SIZE_TYPE__ size_t;
// typedef __WCHAR_TYPE__ wchar_t;
long a64l(const char *);

View File

@ -108,7 +108,7 @@ extern "C"
char __data;
} pthread_barrier_t;
typedef unsigned long size_t;
typedef __SIZE_TYPE__ size_t;
typedef long ssize_t;
typedef long suseconds_t;

View File

@ -189,6 +189,15 @@ enum RelocationTypes
R_AARCH64_RELATIVE = 1027,
R_AARCH64_TLS_DTPMOD64 = 1028,
R_ARM_NONE = 0,
R_ARM_COPY = 1024,
R_ARM_GLOB_DAT = 1025,
R_ARM_JUMP_SLOT = 1026,
R_ARM_RELATIVE = 1027,
R_ARM_TLS_DTPMOD32 = 1028,
R_ARM_TLS_DTPOFF32 = 1029,
R_ARM_TLS_TPOFF32 = 1030,
#if defined(__x86_64__)
R_NONE = R_X86_64_NONE,
R_COPY = R_X86_64_COPY,
@ -216,6 +225,15 @@ enum RelocationTypes
R_DTPMOD64 = R_AARCH64_TLS_DTPMOD64,
R_DTPOFF64 = R_AARCH64_NONE,
R_TPOFF64 = R_AARCH64_NONE,
#elif defined(__arm__)
R_NONE = R_ARM_NONE,
R_COPY = R_ARM_COPY,
R_GLOB_DAT = R_ARM_GLOB_DAT,
R_JMP_SLOT = R_ARM_JUMP_SLOT,
R_RELATIVE = R_ARM_RELATIVE,
R_DTPMOD64 = R_ARM_TLS_DTPMOD32,
R_DTPOFF64 = R_ARM_TLS_DTPOFF32,
R_TPOFF64 = R_ARM_TLS_TPOFF32,
#endif
};
@ -1002,7 +1020,7 @@ typedef Elf64_Rela Elf_Rela;
#define ELF_ST_BIND(info) ELF64_ST_BIND(info)
#define ELF_ST_TYPE(info) ELF64_ST_TYPE(info)
#define ELF_ST_INFO(bind, type) ELF64_ST_INFO(bind, type)
#elif defined(__i386__)
#elif defined(__i386__) || defined(__arm__)
typedef Elf32_Addr Elf_Addr;
typedef Elf32_Half Elf_Half;
typedef Elf32_Off Elf_Off;

View File

@ -128,6 +128,8 @@ __attribute__((naked, used, no_stack_protector)) void _start()
"call _exit\n"); /* Call _exit */
#elif defined(__i386__)
#warning "i386 _start not implemented"
#elif defined(__arm__)
#warning "arm _start not implemented"
#elif defined(__aarch64__)
#warning "aarch64 _start not implemented"
#else

View File

@ -68,6 +68,8 @@ __attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
"call _exit\n");
#elif defined(__i386__)
#warning "i386 _start not implemented"
#elif defined(__arm__)
#warning "arm _start not implemented"
#elif defined(__aarch64__)
#warning "aarch64 _start not implemented"
#else

View File

@ -68,6 +68,8 @@ __attribute__((naked, used, no_stack_protector, section(".text"))) void _start()
"call _exit\n");
#elif defined(__i386__)
#warning "i386 _start not implemented"
#elif defined(__arm__)
#warning "arm _start not implemented"
#elif defined(__aarch64__)
#warning "aarch64 _start not implemented"
#else

View File

@ -19,3 +19,176 @@ double __trunctfdf2(long double a)
{
return (double)a;
}
int __aeabi_dcmple(long double a, long double b)
{
return a <= b;
}
long long __aeabi_d2lz(double a)
{
return (long long)a;
}
int __aeabi_dcmplt(long double a, long double b)
{
return a < b;
}
typedef union
{
double d;
struct
{
__UINT64_TYPE__ mantissa : 52;
__UINT64_TYPE__ exponent : 11;
__UINT64_TYPE__ sign : 1;
} parts;
} aeabi_double_t;
aeabi_double_t __aeabi_ddiv(aeabi_double_t a, aeabi_double_t b)
{
aeabi_double_t result;
result.d = a.d / b.d;
return result;
}
aeabi_double_t __aeabi_dmul(aeabi_double_t a, aeabi_double_t b)
{
aeabi_double_t result;
result.d = a.d * b.d;
return result;
}
aeabi_double_t __aeabi_dadd(aeabi_double_t a, aeabi_double_t b)
{
aeabi_double_t result;
result.d = a.d + b.d;
return result;
}
int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
{
return a.d > b.d;
}
int __aeabi_dcmpge(aeabi_double_t a, aeabi_double_t b)
{
return a.d >= b.d;
}
aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
{
aeabi_double_t result;
result.d = a.d - b.d;
return result;
}
aeabi_double_t __aeabi_i2d(int a)
{
aeabi_double_t result;
result.d = (double)a;
return result;
}
aeabi_double_t __aeabi_l2d(long long a)
{
aeabi_double_t result;
result.d = (double)a;
return result;
}
int __aeabi_dcmpeq(aeabi_double_t a, aeabi_double_t b)
{
return a.d == b.d;
}
int __aeabi_d2iz(aeabi_double_t a)
{
return (int)a.d;
}
struct ldivmod_result
{
long quot;
long rem;
};
struct ldivmod_result __aeabi_ldivmod(long numerator, long denominator)
{
struct ldivmod_result result;
result.quot = numerator / denominator;
result.rem = numerator % denominator;
return result;
}
signed __aeabi_idiv(signed numerator, signed denominator)
{
return numerator / denominator;
}
signed __aeabi_idivmod(signed numerator, signed denominator)
{
signed quotient = numerator / denominator;
signed remainder = numerator % denominator;
return (quotient << 16) | remainder;
}
unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator)
{
return numerator / denominator;
}
unsigned __aeabi_uidivmod(unsigned numerator, unsigned denominator)
{
unsigned quotient = numerator / denominator;
unsigned remainder = numerator % denominator;
return (quotient << 16) | remainder;
}
__UINT64_TYPE__ __udivmoddi4(__UINT64_TYPE__ numerator, __UINT64_TYPE__ denominator, __UINT64_TYPE__ *remainder)
{
__UINT64_TYPE__ quotient = 0;
__UINT64_TYPE__ bit = 1;
if (denominator == 0)
{
*remainder = numerator;
return ~0ULL;
}
while (denominator < numerator && (denominator & (1ULL << 63)) == 0)
{
denominator <<= 1;
bit <<= 1;
}
while (bit)
{
if (numerator >= denominator)
{
numerator -= denominator;
quotient |= bit;
}
denominator >>= 1;
bit >>= 1;
}
if (remainder)
*remainder = numerator;
return quotient;
}
struct udivmod_result
{
__UINT64_TYPE__ quot;
__UINT64_TYPE__ rem;
};
struct udivmod_result __aeabi_uldivmod(__UINT64_TYPE__ numerator, __UINT64_TYPE__ denominator)
{
struct udivmod_result result;
result.quot = __udivmoddi4(numerator, denominator, &result.rem);
return result;
}