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

@ -80,9 +80,11 @@ typedef struct
#if defined(__amd64__)
typedef Elf64_auxv_t Elf_auxv_t;
#elif defined(__i386__)
typedef Elf64_auxv_t Elf_auxv_t;
typedef Elf32_auxv_t Elf_auxv_t;
#elif defined(__aarch64__)
typedef Elf64_auxv_t Elf_auxv_t;
#elif defined(__arm__)
typedef Elf32_auxv_t Elf_auxv_t;
#endif
typedef struct

View File

@ -90,8 +90,8 @@ extern "C"
long unsigned strlen_sse4_1(const char s[]);
long unsigned strlen_sse4_2(const char s[]);
long unsigned strlen(const char s[]);
int strncmp(const char *s1, const char *s2, unsigned long n);
size_t strlen(const char s[]);
int strncmp(const char *s1, const char *s2, size_t n);
char *strcat_unsafe(char *destination, const char *source);
char *strcpy_unsafe(char *destination, const char *source);
char *strncpy(char *destination, const char *source, unsigned long num);

View File

@ -1072,6 +1072,72 @@ namespace CPU
}
}
namespace arm
{
struct TrapFrame
{
uint32_t R0; /* Register R0 (argument / scratch) */
uint32_t R1; /* Register R1 (argument / scratch) */
uint32_t R2; /* Register R2 (argument / scratch) */
uint32_t R3; /* Register R3 (argument / scratch) */
uint32_t R4; /* Register R4 (callee-saved) */
uint32_t R5; /* Register R5 (callee-saved) */
uint32_t R6; /* Register R6 (callee-saved) */
uint32_t R7; /* Register R7 (callee-saved) */
uint32_t R8; /* Register R8 (callee-saved) */
uint32_t R9; /* Register R9 (platform-specific) */
uint32_t R10; /* Register R10 (callee-saved) */
uint32_t FP; /* Frame Pointer (R11) */
uint32_t IP; /* Intra-Procedure Scratch (R12) */
uint32_t SP; /* Stack Pointer (R13) */
uint32_t LR; /* Link Register (R14) */
uint32_t PC; /* Program Counter (R15) */
uint32_t CPSR; /* Current Program Status Register */
};
struct SchedulerFrame
{
uint32_t R0; /* Register R0 (argument / scratch) */
uint32_t R1; /* Register R1 (argument / scratch) */
uint32_t R2; /* Register R2 (argument / scratch) */
uint32_t R3; /* Register R3 (argument / scratch) */
uint32_t R4; /* Register R4 (callee-saved) */
uint32_t R5; /* Register R5 (callee-saved) */
uint32_t R6; /* Register R6 (callee-saved) */
uint32_t R7; /* Register R7 (callee-saved) */
uint32_t R8; /* Register R8 (callee-saved) */
uint32_t R9; /* Register R9 (platform-specific) */
uint32_t R10; /* Register R10 (callee-saved) */
uint32_t FP; /* Frame Pointer (R11) */
uint32_t IP; /* Intra-Procedure Scratch (R12) */
uint32_t SP; /* Stack Pointer (R13) */
uint32_t LR; /* Link Register (R14) */
uint32_t PC; /* Program Counter (R15) */
uint32_t CPSR; /* Current Program Status Register */
};
struct ExceptionFrame
{
uint32_t R0; /* Register R0 (argument / scratch) */
uint32_t R1; /* Register R1 (argument / scratch) */
uint32_t R2; /* Register R2 (argument / scratch) */
uint32_t R3; /* Register R3 (argument / scratch) */
uint32_t R4; /* Register R4 (callee-saved) */
uint32_t R5; /* Register R5 (callee-saved) */
uint32_t R6; /* Register R6 (callee-saved) */
uint32_t R7; /* Register R7 (callee-saved) */
uint32_t R8; /* Register R8 (callee-saved) */
uint32_t R9; /* Register R9 (platform-specific) */
uint32_t R10; /* Register R10 (callee-saved) */
uint32_t FP; /* Frame Pointer (R11) */
uint32_t IP; /* Intra-Procedure Scratch (R12) */
uint32_t SP; /* Stack Pointer (R13) */
uint32_t LR; /* Link Register (R14) */
uint32_t PC; /* Program Counter (R15) */
uint32_t CPSR; /* Current Program Status Register */
};
}
namespace aarch64
{
struct TrapFrame
@ -1123,6 +1189,15 @@ namespace CPU
typedef x32::TrapFrame TrapFrame;
typedef x32::SchedulerFrame SchedulerFrame;
typedef x32::ExceptionFrame ExceptionFrame;
#elif defined(__arm__)
/**
* CPU trap frame for the current architecture
*
* @note This is for arm
*/
typedef arm::TrapFrame TrapFrame;
typedef arm::SchedulerFrame SchedulerFrame;
typedef arm::ExceptionFrame ExceptionFrame;
#elif defined(__aarch64__)
/**
* CPU trap frame for the current architecture

View File

@ -962,7 +962,7 @@ typedef Elf64_Rel Elf_Rel;
typedef Elf64_Sym Elf_Sym;
typedef Elf64_Dyn Elf_Dyn;
typedef Elf64_Rela Elf_Rela;
#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

@ -59,7 +59,7 @@
#define USER_STACK_END 0xFFFFEFFF00000000 /* 256 MiB */
#define USER_STACK_BASE 0xFFFFEFFFFFFF0000
#elif defined(__i386__)
#elif defined(__i386__) || defined(__arm__)
#define KERNEL_VMA_OFFSET 0xC0000000
#define USER_ALLOC_BASE 0x80000000

View File

@ -67,6 +67,14 @@ typedef struct SyscallsFrame
uint64_t ExceptionSyndromeRegister;
uint64_t FaultAddressRegister;
uint64_t SavedProgramStatusRegister;
#elif defined(__arm__)
uint32_t ReturnAddress; /* r0 */
uint32_t x[14];
uint32_t StackPointer;
uint32_t ExceptionLinkRegister;
uint32_t ExceptionSyndromeRegister;
uint32_t FaultAddressRegister;
uint32_t SavedProgramStatusRegister;
#endif
uintptr_t ReturnValue() const

View File

@ -553,6 +553,8 @@ namespace Tasking
return x64;
#elif defined(__i386__)
return x32;
#elif defined(__arm__)
return ARM32;
#elif defined(__aarch64__)
return ARM64;
#endif

View File

@ -171,7 +171,7 @@ typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef int64_t clock_t;
typedef int32_t pid_t;
#elif defined(__i386__)
#elif defined(__i386__) || defined(__arm__)
typedef int32_t off_t;
typedef long long off64_t;
typedef uint32_t mode_t;