init commit

This commit is contained in:
Faynot
2026-07-07 20:35:07 +03:00
commit 38cc34a6e9
33 changed files with 659 additions and 0 deletions

3
arch/x86_64/arch.mak Normal file
View File

@@ -0,0 +1,3 @@
# x86_64 architecture flags
ARCH_CFLAGS := -m64
ARCH_LDFLAGS := -m elf_x86_64

26
arch/x86_64/atomic_arch.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef _ELIBC_ATOMIC_ARCH_H
#define _ELIBC_ATOMIC_ARCH_H
/* x86_64: minimal atomic ops via locked cmpxchg (CPU-local, no syscall) */
static inline int a_cas(volatile int *p, int t, int s)
{
int old;
__asm__ volatile ("lock; cmpxchg %3, %1"
: "=a"(old), "=m"(*p)
: "a"(t), "r"(s), "m"(*p)
: "memory");
return old;
}
static inline void a_inc(volatile int *p)
{
__asm__ volatile ("lock; incl %0" : "=m"(*p) : "m"(*p) : "memory");
}
static inline void a_dec(volatile int *p)
{
__asm__ volatile ("lock; decl %0" : "=m"(*p) : "m"(*p) : "memory");
}
#endif

View File

@@ -0,0 +1,6 @@
TYPEDEF int ptrdiff_t;
TYPEDEF unsigned long size_t;
TYPEDEF long ssize_t;
TYPEDEF unsigned long uintptr_t;
TYPEDEF long intptr_t;
TYPEDEF int wchar_t;

21
arch/x86_64/kcall.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef _ELIBC_X86_64_KCALL_H
#define _ELIBC_X86_64_KCALL_H
#include <arch/generic/kcall.h>
/* x86_64: placeholder — Elyz kernel ABI not yet defined.
*
* When the ABI exists this will contain either:
* - a direct userspace→actor message-pipe write, or
* - a lightweight kernel entry that routes via the PMRouter.
*
* For now: return -ENOSYS and let the CPU halt.
*/
static inline long __kcall(struct elyz_kcall *msg)
{
(void)msg;
for (;;) __asm__ volatile("hlt");
return -38; /* -ENOSYS */
}
#endif

View File

@@ -0,0 +1,16 @@
#ifndef _ELIBC_X86_64_STARTUP_INFO_H
#define _ELIBC_X86_64_STARTUP_INFO_H
/* x86_64 process-startup ABI.
*
* The loader places an elyz_startup block at a known location (e.g. in a
* register or on a special stack page). The exact ABI depends on the
* kernel-to-userspace handoff which is not yet implemented.
*
* Current state: STUB — the process receives argc/argv on the stack as a
* fallback, and the initial memory pool comes from a fixed test region.
*/
#include <arch/generic/startup_info.h>
#endif