Files
elibc/crt/crt1.c
2026-07-07 20:35:07 +03:00

33 lines
1009 B
C

/* 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;
}