hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-06 12:49:46 +0200
committerhachem <im@hachem.wtf>2026-10-06 12:49:46 +0200
commit5d4a723a5f157c0ed38a348099a600d1d21c3c2b (patch)
tree70e5fdf560a64cd0eb3a13d88ce046ddd29fd077 /boot
parent52dab7fc85d877e80e3032f0afabae906adebad8 (diff)
feat: gils core utils and other shit
Diffstat (limited to 'boot')
-rw-r--r--boot/boot.zig21
-rw-r--r--boot/idt.zig2
-rw-r--r--boot/regs.zig2
-rw-r--r--boot/sched.zig2
4 files changed, 23 insertions, 4 deletions
diff --git a/boot/boot.zig b/boot/boot.zig
index fff8a6b..4918881 100644
--- a/boot/boot.zig
+++ b/boot/boot.zig
@@ -60,6 +60,9 @@ fn kPhysToVirt(p: u64) u64 {
fn kAllocFrame() u64 {
return pmm.alloc() orelse 0;
}
+fn kAllocContig(n: u64) u64 {
+ return pmm.allocContig(@intCast(n)) orelse 0;
+}
fn kCreateAddrspace() u64 {
return vmm.createAddressSpace() orelse 0;
}
@@ -91,7 +94,7 @@ fn kMemmapLen(i: u64) u64 {
}
fn kMemmapKind(i: u64) u64 {
- return if (memmapEntry(i)) |e| @intFromEnum(e.type) else 0;
+ return if (memmapEntry(i)) |e| @backingInt(e.type) else 0;
}
fn kMemFree() u64 {
@@ -161,8 +164,23 @@ fn kTaskState(i: u64) u64 {
return sched.taskState(i);
}
+// limine doesnt fully enable SSE the only reason i need this
+// is because Zig 0.17 bullshit
+inline fn enableSse() void {
+ asm volatile (
+ \\ mov %%cr0, %%rax
+ \\ and $0xfffb, %%ax
+ \\ or $0x2, %%ax
+ \\ mov %%rax, %%cr0
+ \\ mov %%cr4, %%rax
+ \\ or $0x600, %%rax
+ \\ mov %%rax, %%cr4
+ ::: .{ .rax = true, .memory = true });
+}
+
// entry(_start)
export fn _start() callconv(.c) noreturn {
+ enableSse();
serial.init();
serial.write("if you see this, it means revel didn't shit the bed\r\n");
@@ -217,6 +235,7 @@ export fn _start() callconv(.c) noreturn {
.disk_sectors = &kDiskSectors,
.disk_read = &kDiskRead,
.disk_write = &kDiskWrite,
+ .alloc_contig = &kAllocContig,
};
// hand the kernel heap + framebuffer + low level ops to revo and bring up the vm
diff --git a/boot/idt.zig b/boot/idt.zig
index 0ffd116..15e6588 100644
--- a/boot/idt.zig
+++ b/boot/idt.zig
@@ -29,7 +29,7 @@ const Idtr = packed struct {
base: u64,
};
-var idt = [_]Gate{@bitCast(@as(u128, 0))} ** 256;
+var idt: [256]Gate = @splat(@bitCast(@as(u128, 0)));
var idtr: Idtr = undefined;
const names = [_][]const u8{
diff --git a/boot/regs.zig b/boot/regs.zig
index 7b2bb88..3a30860 100644
--- a/boot/regs.zig
+++ b/boot/regs.zig
@@ -24,7 +24,7 @@ pub const Frame = extern struct {
ss: u64,
};
-// push/pop the 15 gprs in frames exact order
+// push/pop the 15 gprs in frames exact order
// (rax pushed first -> highest field, r15 last -> at rsp = &frame)
pub const PUSH_GPRS =
\\push %rax
diff --git a/boot/sched.zig b/boot/sched.zig
index 1842309..383b40d 100644
--- a/boot/sched.zig
+++ b/boot/sched.zig
@@ -84,7 +84,7 @@ pub fn taskMax() u64 {
}
pub fn taskState(i: u64) u64 {
if (i >= MAX_TASKS) return 0;
- return @intFromEnum(tasks[i].state);
+ return @backingInt(tasks[i].state);
}
var proc_exited_flag: bool = false;