summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/io.rs1
-rw-r--r--src/io/render.rs1
-rw-r--r--src/io/render/fb.rs2
-rw-r--r--src/io/render/fb/graphic.rs0
-rw-r--r--src/io/render/fb/text.rs1
-rw-r--r--src/lib.rs3
-rw-r--r--src/main.rs76
7 files changed, 84 insertions, 0 deletions
diff --git a/src/io.rs b/src/io.rs
new file mode 100644
index 0000000..cf25e6c
--- /dev/null
+++ b/src/io.rs
@@ -0,0 +1 @@
+pub mod render;
diff --git a/src/io/render.rs b/src/io/render.rs
new file mode 100644
index 0000000..402daf7
--- /dev/null
+++ b/src/io/render.rs
@@ -0,0 +1 @@
+pub mod fb;
diff --git a/src/io/render/fb.rs b/src/io/render/fb.rs
new file mode 100644
index 0000000..2924838
--- /dev/null
+++ b/src/io/render/fb.rs
@@ -0,0 +1,2 @@
+pub mod graphic;
+pub mod text;
diff --git a/src/io/render/fb/graphic.rs b/src/io/render/fb/graphic.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/io/render/fb/graphic.rs
diff --git a/src/io/render/fb/text.rs b/src/io/render/fb/text.rs
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/io/render/fb/text.rs
@@ -0,0 +1 @@
+
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..f0111d3
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,3 @@
+#![no_std]
+
+pub mod io;
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..bf338df
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,76 @@
+#![no_std]
+#![no_main]
+#![feature(used_with_arg)]
+
+use core::panic::PanicInfo;
+use font8x8::UnicodeFonts;
+use limine::{BaseRevision, request::FramebufferRequest};
+
+#[used(linker)]
+#[unsafe(link_section = ".requests")]
+static BASE_REVISION: BaseRevision = BaseRevision::new();
+
+#[used(linker)]
+#[unsafe(link_section = ".requests")]
+static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
+
+#[unsafe(no_mangle)]
+pub extern "C" fn _start() -> ! {
+ if !BASE_REVISION.is_supported() {
+ panic!("Limine Base Revision not supported");
+ }
+
+ if let Some(response) = FRAMEBUFFER_REQUEST.response() {
+ if let Some(fb) = response
+ .framebuffers()
+ .first()
+ {
+ let pitch = fb.pitch as usize;
+ let bpp = fb.bpp as usize;
+
+ if bpp == 32 {
+ let slice = unsafe { fb.as_slice_mut() };
+ let msg = "Hello World!";
+ let mut cursor_x = 10;
+ let cursor_y = 10;
+
+ for c in msg.chars() {
+ if let Some(glyph) = font8x8::BASIC_FONTS.get(c) {
+ for (y, row) in glyph
+ .iter()
+ .enumerate()
+ {
+ for x in 0..8 {
+ if (*row & (1 << x)) != 0 {
+ let pixel_offset = (cursor_y + y) * pitch + (cursor_x + x) * 4;
+ if pixel_offset + 3 < slice.len() {
+ slice[pixel_offset] = 0xFF; // B
+ slice[pixel_offset + 1] = 0xFF; // G
+ slice[pixel_offset + 2] = 0xFF; // R
+ }
+ }
+ }
+ }
+ }
+ cursor_x += 8;
+ }
+ }
+ }
+ }
+
+ hcf();
+}
+
+fn hcf() -> ! {
+ unsafe {
+ core::arch::asm!("cli");
+ loop {
+ core::arch::asm!("hlt");
+ }
+ }
+}
+
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ hcf()
+}