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

32
crt/crt1.c Normal file
View File

@@ -0,0 +1,32 @@
/* Minimal C runtime — entry point before main.
*
* Elyz process startup:
* the loader transfers control here with an initial capability wallet
* (CNode) and a pool of untyped memory. No traditional syscalls exist;
* all kernel interaction goes through capability invocation.
*
* Current state: STUB — the kernel ABI is under construction.
* - argc/argv passed on stack (convention inherited from limine boot)
* - initial memory pool not yet wired; __libc_init sets up a tiny bump
* arena for development.
*/
void _start(void)
{
extern int main(int, char **, char **);
extern void __libc_init(void);
register long *args __asm__("rsp");
int argc = (int)args[0];
char **argv = (char **)(args + 1);
char **envp = argv + argc + 1;
__libc_init();
int ret = main(argc, argv, envp);
/* No _exit syscall in Elyz — send an Exit message to the PM actor.
* For now: infinite halt. */
for (;;) __asm__ volatile("hlt");
(void)ret;
}