hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/boot.zig
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-04 00:52:49 +0200
committerhachem <im@hachem.wtf>2026-10-04 00:52:49 +0200
commit627f05098785327744e666c9149375125499d2ff (patch)
treea72f3949e0729f1e73ad39ccb1809698a5ed8298 /boot/boot.zig
parent09982d80c45805715984cc1cae96c37e4fc148c3 (diff)
feat: revelfs type shi
Diffstat (limited to 'boot/boot.zig')
-rw-r--r--boot/boot.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/boot/boot.zig b/boot/boot.zig
index 9f384fa..28fb8c1 100644
--- a/boot/boot.zig
+++ b/boot/boot.zig
@@ -12,6 +12,7 @@ const elf = @import("elf.zig");
const keyboard = @import("keyboard.zig");
const timer = @import("timer.zig");
const sched = @import("sched.zig");
+const ata = @import("ata.zig");
const bridge = @import("bridge");
// we need a panic handler otherwise zig wont be happy,
@@ -100,6 +101,22 @@ fn kProcCount() u64 {
return sched.procCount();
}
+// block device, revo builds the filesystem on top of these
+fn kDiskPresent() u64 {
+ return if (ata.present()) 1 else 0;
+}
+fn kDiskSectors() u64 {
+ return ata.sectorCount();
+}
+fn kDiskRead(lba: u64, phys: u64) u64 {
+ const buf: *[ata.SECTOR]u8 = @ptrFromInt(pmm.physToVirt(phys));
+ return if (ata.read(@truncate(lba), buf)) 1 else 0;
+}
+fn kDiskWrite(lba: u64, phys: u64) u64 {
+ const buf: *const [ata.SECTOR]u8 = @ptrFromInt(pmm.physToVirt(phys));
+ return if (ata.write(@truncate(lba), buf)) 1 else 0;
+}
+
// entry(_start)
export fn _start() callconv(.c) noreturn {
serial.init();
@@ -124,6 +141,7 @@ export fn _start() callconv(.c) noreturn {
pmmSelfTest();
vmmSelfTest();
+ ata.init();
const elf_pages = (elf.hello_elf.len + 4095) / 4096;
const elf_phys = pmm.allocContig(elf_pages) orelse @panic("no room for the embedded ELF");
@@ -150,6 +168,10 @@ export fn _start() callconv(.c) noreturn {
.proc_count = &kProcCount,
.elf_phys = elf_phys,
.elf_size = elf.hello_elf.len,
+ .disk_present = &kDiskPresent,
+ .disk_sectors = &kDiskSectors,
+ .disk_read = &kDiskRead,
+ .disk_write = &kDiskWrite,
};
// hand the kernel heap + framebuffer + low level ops to revo and bring up the vm