init commit
This commit is contained in:
3
arch/generic/arch.mak
Normal file
3
arch/generic/arch.mak
Normal file
@@ -0,0 +1,3 @@
|
||||
# Generic architecture flags — override per port
|
||||
ARCH_CFLAGS :=
|
||||
ARCH_LDFLAGS :=
|
||||
7
arch/generic/bits/alltypes.h.in
Normal file
7
arch/generic/bits/alltypes.h.in
Normal file
@@ -0,0 +1,7 @@
|
||||
/* Generic type sizes — override per arch if different */
|
||||
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;
|
||||
30
arch/generic/kcall.h
Normal file
30
arch/generic/kcall.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _ELIBC_KCALL_H
|
||||
#define _ELIBC_KCALL_H
|
||||
|
||||
/* Elyz kernel-call abstraction.
|
||||
*
|
||||
* Elyz has NO syscall instruction. Communication with the kernel and PM
|
||||
* actors happens through capability invocation — a mechanism defined by the
|
||||
* kernel ABI (not finalised yet). This header describes the abstract
|
||||
* interface; the arch-specific implementation (arch/<arch>/kcall.h) fills in
|
||||
* the concrete mechanism.
|
||||
*
|
||||
* Current state: STUB — returns -ENOSYS until the Elyz kernel ABI is
|
||||
* stabilised.
|
||||
*/
|
||||
|
||||
#define ELYZ_OP_ALLOCATE 1
|
||||
#define ELYZ_OP_FREE 2
|
||||
#define ELYZ_OP_CARVE 3
|
||||
#define ELYZ_OP_EXIT 4
|
||||
|
||||
struct elyz_kcall {
|
||||
unsigned long opcode;
|
||||
unsigned long arg1;
|
||||
unsigned long arg2;
|
||||
unsigned short channel_id;
|
||||
};
|
||||
|
||||
long __kcall(struct elyz_kcall *msg);
|
||||
|
||||
#endif
|
||||
22
arch/generic/startup_info.h
Normal file
22
arch/generic/startup_info.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _ELIBC_STARTUP_INFO_H
|
||||
#define _ELIBC_STARTUP_INFO_H
|
||||
|
||||
/* Process-startup information block.
|
||||
*
|
||||
* The Elyz loader passes an opaque structure to every new process.
|
||||
* Layout and content are arch-defined (see arch/<arch>/startup_info.h).
|
||||
* At minimum the process receives:
|
||||
* - an initial memory pool (capability / region)
|
||||
* - argc / argv from the parent
|
||||
* - a capability-wallet (CNode) root
|
||||
*/
|
||||
|
||||
struct elyz_startup {
|
||||
unsigned long initial_cnode_cap;
|
||||
unsigned long initial_pool_addr;
|
||||
unsigned long initial_pool_size;
|
||||
int argc;
|
||||
char **argv;
|
||||
};
|
||||
|
||||
#endif
|
||||
3
arch/x86_64/arch.mak
Normal file
3
arch/x86_64/arch.mak
Normal 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
26
arch/x86_64/atomic_arch.h
Normal 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
|
||||
6
arch/x86_64/bits/alltypes.h.in
Normal file
6
arch/x86_64/bits/alltypes.h.in
Normal 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
21
arch/x86_64/kcall.h
Normal 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
|
||||
16
arch/x86_64/startup_info.h
Normal file
16
arch/x86_64/startup_info.h
Normal 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
|
||||
Reference in New Issue
Block a user