aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
blob: adef54cc3b57fee3332b0c79ccd4a2114a220969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const debug = @import("debugcon.zig");

const ALIGN = 1 << 0;
const MEMINFO = 1 << 1;
const MAGIC = 0x1BADB002;
const FLAGS = ALIGN | MEMINFO;

const MultibootHeader = extern struct {
    magic: i32,
    flags: i32,
    checksum: i32,
};

export const multiboot align(4) linksection(".multiboot") = MultibootHeader{
    .magic = MAGIC,
    .flags = FLAGS,
    .checksum = -(MAGIC + FLAGS),
};

export fn _start() callconv(.Naked) noreturn {
    asm volatile (
        \\ mov _sstack, %rsp
        \\ mov %rsp, %rbp
    );
    asm volatile ("jmp kmain");
}

export fn kmain() noreturn {
    debug.outb(0xe9, 'H');
    debug.outb(0xe9, 'i');
    debug.outb(0xe9, '!');
    debug.outb(0xe9, '\n');

    while (true) {}
}