hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/framebuffer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'boot/framebuffer.zig')
-rw-r--r--boot/framebuffer.zig26
1 files changed, 26 insertions, 0 deletions
diff --git a/boot/framebuffer.zig b/boot/framebuffer.zig
new file mode 100644
index 0000000..6518b17
--- /dev/null
+++ b/boot/framebuffer.zig
@@ -0,0 +1,26 @@
+// linear framebuffer type shi you feel me?
+// see: https://wiki.osdev.org/Limine_Bare_Bones
+
+const limine = @import("limine.zig");
+
+pub const Framebuffer = limine.Framebuffer;
+
+// the request placed in .limine_requests so the loader finds and fills it
+// idk why this sounds vaguely erotic, like yeah fill me harder lol
+export var request: limine.FramebufferRequest linksection(".limine_requests") = .{};
+
+// the response pointer is written by Limine before we run, so read it through a
+// volatile pointer or the optimizer assumes it's still null
+pub fn get() ?*Framebuffer {
+ const req: *volatile limine.FramebufferRequest = &request;
+ const resp = req.response orelse return null;
+ if (resp.framebuffer_count == 0) return null;
+ return resp.framebuffers.?[0];
+}
+
+// assumes the usual Limine RGB 32-bpp layout im sure i wont forget about this layout
+// later and i wont fuck me over
+pub fn putpixel(fb: *Framebuffer, x: usize, y: usize, color: u32) void {
+ const pixel: *align(1) u32 = @ptrCast(fb.address + y * fb.pitch + x * 4);
+ pixel.* = color;
+}