Microkernel thing OS experiment (Zig ⚡)
at dev 786 B view raw
1const std = @import("std"); 2const os = @import("os.zig"); 3const config = @import("config"); 4 5export fn _start() callconv(.c) noreturn { 6 _ = os.syscall1(SYS_poke, 0xB16B00B5BADBABE); 7 _ = os.syscall1(SYS_exit, 0x69696969); 8 asm volatile ("int3"); 9 asm volatile ( 10 \\ mov %[number], %%rdi 11 \\ xor %%rsi, %%rsi 12 \\ xor %%rbx, %%rbx 13 \\ mainloop: 14 \\ xor %%rax, %%rax 15 \\ delayloop: 16 \\ inc %%rax 17 \\ cmp $0x1000000, %%rax 18 \\ jnz delayloop 19 \\ inc %%rbx 20 \\ mov %%rsp, %%rsi 21 \\ syscall 22 \\ jmp mainloop 23 : 24 : [number] "r" (config.number), 25 ); 26 27 die(); 28} 29 30pub inline fn die() noreturn { 31 while (true) {} 32} 33 34pub const SYS_exit = 0x420; 35pub const SYS_poke = 0x69;