MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / _start

Function _start

euralios_std/src/lib.rs:61–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59
60#[no_mangle]
61pub unsafe extern "sysv64" fn _start() -> ! {
62 // Information passed from the operating system
63 let heap_start: usize;
64 let heap_size: usize;
65 let args_address: usize;
66 let env_address: usize;
67 asm!("",
68 lateout("rax") heap_start,
69 lateout("rcx") heap_size,
70 lateout("rdx") args_address,
71 lateout("rdi") env_address,
72 options(pure, nomem, nostack)
73 );
74 memory::init(heap_start, heap_size);
75
76 if args_address != 0 {
77 // Command-line arguments
78
79 ARGS_SLICE = unsafe{
80 let length = *(args_address as *mut i32) as usize;
81 slice::from_raw_parts((args_address + 4) as *const u8, length)
82 };
83 }
84
85 if env_address != 0 {
86 // Environment
87
88 ENV_SLICE = unsafe{
89 let length = *(env_address as *mut i32) as usize;
90 slice::from_raw_parts((env_address + 4) as *const u8, length)
91 };
92 }
93
94 // Call the user program
95 #[cfg(not(test))]
96 main();
97
98 #[cfg(test)]
99 test_main();
100
101 syscalls::thread_exit();
102}
103
104// Custom test framework
105

Callers

nothing calls this directly

Calls 3

thread_exitFunction · 0.85
initFunction · 0.70
mainFunction · 0.50

Tested by

no test coverage detected