hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/boot.zig
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-07 21:43:38 +0200
committerhachem <im@hachem.wtf>2026-10-07 21:43:38 +0200
commite55291a32a8b3f7b5c105cd79e86f3c19f19b3d4 (patch)
tree0a52300c63a011683ceba1642e6f7c24e4d367ef /boot/boot.zig
parent5d4a723a5f157c0ed38a348099a600d1d21c3c2b (diff)
feat: tty and ttf, you'd think somethn starting with tt would be fun to do...
Diffstat (limited to 'boot/boot.zig')
-rw-r--r--boot/boot.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/boot/boot.zig b/boot/boot.zig
index 4918881..267fc3f 100644
--- a/boot/boot.zig
+++ b/boot/boot.zig
@@ -9,6 +9,7 @@ const heap = @import("heap.zig");
const vmm = @import("vmm.zig");
const user = @import("user.zig");
const elf = @import("elf.zig");
+const fontdata = @import("fonts.zig");
const keyboard = @import("keyboard.zig");
const timer = @import("timer.zig");
const sched = @import("sched.zig");
@@ -160,6 +161,38 @@ fn kTaskMax() u64 {
return sched.taskMax();
}
+// i dont actually like implementing fonts in any project
+// it be revel or any opengl or vulkan or whatever the fuck
+// fonts are always the ugh parts of a projects
+// just so much boilerplate
+const FontBlob = struct { name: []const u8, phys: u64, size: u64 };
+var g_fonts: [fontdata.fonts.len]FontBlob = undefined;
+
+fn loadFonts() void {
+ for (fontdata.fonts, 0..) |f, i| {
+ const pages = (f.bytes.len + 4095) / 4096;
+ const phys = pmm.allocContig(pages) orelse @panic("no room for an embedded font");
+ @memcpy(@as([*]u8, @ptrFromInt(pmm.physToVirt(phys)))[0..f.bytes.len], f.bytes);
+ g_fonts[i] = .{ .name = f.name, .phys = phys, .size = f.bytes.len };
+ }
+}
+
+fn kFontCount() u64 {
+ return g_fonts.len;
+}
+
+fn kFontPhys(i: u64) u64 {
+ return g_fonts[i].phys;
+}
+
+fn kFontName(i: u64) []const u8 {
+ return g_fonts[i].name;
+}
+
+fn kFontSize(i: u64) u64 {
+ return g_fonts[i].size;
+}
+
fn kTaskState(i: u64) u64 {
return sched.taskState(i);
}
@@ -206,6 +239,7 @@ export fn _start() callconv(.c) noreturn {
ata.init();
loadPrograms();
+ loadFonts();
// the event loop below is scheduler task 0 (the kernel), running in the
// current cr3. user tasks spawned by `run` get time fucked against it
sched.init(vmm.activePml4());
@@ -236,6 +270,10 @@ export fn _start() callconv(.c) noreturn {
.disk_read = &kDiskRead,
.disk_write = &kDiskWrite,
.alloc_contig = &kAllocContig,
+ .font_count = &kFontCount,
+ .font_phys = &kFontPhys,
+ .font_name = &kFontName,
+ .font_size = &kFontSize,
};
// hand the kernel heap + framebuffer + low level ops to revo and bring up the vm