From 0d0dc3092f134901df8edda2b837d8291b303389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sun, 20 Jul 2025 01:12:47 +0200 Subject: [PATCH 1/8] First Try --- .github/workflows/rust.yml | 2 +- src/framebuffer.rs | 109 +++++++++++++++++++++++++++++++++++++ src/irq_interrupt.rs | 2 +- src/lib.rs | 1 + src/mailbox.rs | 2 +- src/main.rs | 5 ++ src/peripherals/uart.rs | 1 - 7 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 src/framebuffer.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4fc74df..ee92f12 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,7 +21,7 @@ jobs: - name: Run format check run: cargo fmt --check - name: Run lint - run: cargo clippy + run: cargo clippy -- -D warnings build: runs-on: ubuntu-latest diff --git a/src/framebuffer.rs b/src/framebuffer.rs new file mode 100644 index 0000000..4a85e41 --- /dev/null +++ b/src/framebuffer.rs @@ -0,0 +1,109 @@ +use crate::{ + mailbox::{read_mailbox, write_mailbox}, + peripherals::uart::{print, print_u32}, +}; + +const ALLOCATE_BUFFER: u32 = 0x00040001; +const GET_PHYSICAL_DISPLAY_WH: u32 = 0x00040003; +const SET_PHYSICAL_DISPLAY_WH: u32 = 0x00048003; +const SET_VIRTUAL_DISPLAY_WH: u32 = 0x00048004; +const SET_PIXEL_DEPTH: u32 = 0x00048005; +const SET_PIXEL_ORDER: u32 = 0x00048006; +const SET_FB_OFFSET: u32 = 0x00048009; + +pub fn init_fb() { + let mut mailbox = [0; 32]; + mailbox[0] = 32 * 4; + mailbox[1] = 0; + + mailbox[2] = SET_PHYSICAL_DISPLAY_WH; + mailbox[3] = 8; + mailbox[4] = 8; + mailbox[5] = 1920; + mailbox[6] = 1200; + + mailbox[7] = SET_VIRTUAL_DISPLAY_WH; + mailbox[8] = 8; + mailbox[9] = 8; + mailbox[10] = 1920; + mailbox[11] = 1200; + + mailbox[12] = SET_PIXEL_DEPTH; + mailbox[13] = 4; + mailbox[14] = 4; + mailbox[15] = 32; // 32 bit per pixel + + mailbox[16] = SET_PIXEL_ORDER; + mailbox[17] = 4; + mailbox[18] = 4; + mailbox[19] = 0x1; // RGB + + mailbox[20] = SET_FB_OFFSET; + mailbox[21] = 8; + mailbox[22] = 8; + mailbox[24] = 0; // X in pixels + mailbox[25] = 0; // Y in pixels + + mailbox[26] = ALLOCATE_BUFFER; + mailbox[27] = 8; + mailbox[28] = 4; + mailbox[29] = 4096; // Alignment + mailbox[30] = 0; + + mailbox[31] = 0; // End tag + + // TODO: validate responses + + let addr = core::ptr::addr_of!(mailbox[0]) as u32; + + write_mailbox(8, addr); + + let _ = read_mailbox(8); + if mailbox[1] == 0 { + print("Failed\r\n"); + } + + print_u32(mailbox[29]); + + mailbox[29] = (mailbox[29] & 0x00FF_FFFF) | 0x3F00_0000; + + let mut fb: *mut u32 = mailbox[29] as *mut u32; + + fb = unsafe { fb.add(1920 * 500 + 500) }; + + for x in 0..500 { + for y in 0..10 { + unsafe { + *fb = 0xFFFFBB00; + fb = fb.add(1); + }; + } + } +} + +pub fn print_display_resolution() { + let mut mailbox = [0; 8]; + mailbox[0] = 8 * 4; + mailbox[1] = 0; + mailbox[2] = GET_PHYSICAL_DISPLAY_WH; + mailbox[3] = 8; + mailbox[4] = 0; + mailbox[5] = 0; + mailbox[6] = 0; + mailbox[7] = 0; + + let addr = core::ptr::addr_of!(mailbox[0]) as u32; + + write_mailbox(8, addr); + + let _ = read_mailbox(8); + if mailbox[1] == 0 { + print("Failed\r\n"); + } + + print("Width x Height: "); + print_u32(mailbox[5]); + print(" x "); + print_u32(mailbox[6]); + print("\r\n"); +} diff --git a/src/irq_interrupt.rs b/src/irq_interrupt.rs index 8e03285..b42d8ad 100644 --- a/src/irq_interrupt.rs +++ b/src/irq_interrupt.rs @@ -9,7 +9,7 @@ use crate::{ gpio::{blink_gpio, SpecificGpio}, uart::print, }, - timer::{sleep_ms, sleep_s}, + timer::sleep_s, }; const INTERRUPT_BASE: u32 = 0x3F00_B000; diff --git a/src/lib.rs b/src/lib.rs index 61a00be..2f92229 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ use core::ptr::{read_volatile, write_volatile}; pub mod peripherals; pub mod configuration; +pub mod framebuffer; pub mod irq_interrupt; pub mod mailbox; pub mod timer; diff --git a/src/mailbox.rs b/src/mailbox.rs index 3f94599..63084a8 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -34,7 +34,7 @@ pub fn write_mailbox(channel: u32, data: u32) { } pub fn read_soc_temp() -> u32 { - let mut mailbox = [0; 36]; + let mut mailbox = [0; 8]; mailbox[0] = 8 * 4; // Total size in bytes mailbox[1] = 0; // Request mailbox[2] = 0x00030006; // Tag diff --git a/src/main.rs b/src/main.rs index 81c3b16..da47fc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use core::{ }; use nova::{ + framebuffer::{init_fb, print_display_resolution}, irq_interrupt::enable_irq_source, mailbox::read_soc_temp, peripherals::{ @@ -92,9 +93,13 @@ pub extern "C" fn kernel_main() -> ! { gpio_pull_up(26); set_falling_edge_detect(26, true); + print_display_resolution(); + init_fb(); + loop { let temp = read_soc_temp(); print_u32(temp); + print("\r\n"); blink_gpio(SpecificGpio::OnboardLed as u8, 500); } diff --git a/src/peripherals/uart.rs b/src/peripherals/uart.rs index 30bd345..ebe45b4 100644 --- a/src/peripherals/uart.rs +++ b/src/peripherals/uart.rs @@ -57,7 +57,6 @@ pub fn print_u32(mut val: u32) { let s = str::from_utf8(&data).unwrap(); print(s); } - print("\r\n"); } /// Initialize UART peripheral From 955c4c57855752fc13397ea8a71fc2768638c830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sat, 26 Jul 2025 15:29:05 +0200 Subject: [PATCH 2/8] Functioning draw --- src/framebuffer.rs | 156 +++++++++++++++++++++++++++------------- src/main.rs | 20 +++++- src/peripherals/uart.rs | 33 +++++++++ 3 files changed, 156 insertions(+), 53 deletions(-) diff --git a/src/framebuffer.rs b/src/framebuffer.rs index 4a85e41..aa80896 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -1,7 +1,11 @@ +use core::ptr::write_volatile; + use crate::{ mailbox::{read_mailbox, write_mailbox}, - peripherals::uart::{print, print_u32}, + peripherals::uart::{print, print_u32, print_u32_hex}, }; +#[repr(align(16))] +struct Mailbox([u32; 36]); const ALLOCATE_BUFFER: u32 = 0x00040001; const GET_PHYSICAL_DISPLAY_WH: u32 = 0x00040003; @@ -10,79 +14,129 @@ const SET_VIRTUAL_DISPLAY_WH: u32 = 0x00048004; const SET_PIXEL_DEPTH: u32 = 0x00048005; const SET_PIXEL_ORDER: u32 = 0x00048006; const SET_FB_OFFSET: u32 = 0x00048009; +const GET_PITCH: u32 = 0x00040008; -pub fn init_fb() { - let mut mailbox = [0; 32]; - mailbox[0] = 32 * 4; - mailbox[1] = 0; +pub struct FrameBuffer { + pixel_depth: u32, // Bits per pixel + pitch: u32, // Pixel per row + rows: u32, // Rows + start_addr: *mut u32, + size: u32, //Bytes +} - mailbox[2] = SET_PHYSICAL_DISPLAY_WH; - mailbox[3] = 8; - mailbox[4] = 8; - mailbox[5] = 1920; - mailbox[6] = 1200; +impl FrameBuffer { + pub fn new() -> Self { + let mut mailbox = Mailbox([0; 36]); + mailbox.0[0] = 35 * 4; + mailbox.0[1] = 0; - mailbox[7] = SET_VIRTUAL_DISPLAY_WH; - mailbox[8] = 8; - mailbox[9] = 8; - mailbox[10] = 1920; - mailbox[11] = 1200; + mailbox.0[2] = SET_PHYSICAL_DISPLAY_WH; + mailbox.0[3] = 8; + mailbox.0[4] = 8; + mailbox.0[5] = 1920; + mailbox.0[6] = 1080; - mailbox[12] = SET_PIXEL_DEPTH; - mailbox[13] = 4; - mailbox[14] = 4; - mailbox[15] = 32; // 32 bit per pixel + mailbox.0[7] = SET_VIRTUAL_DISPLAY_WH; + mailbox.0[8] = 8; + mailbox.0[9] = 8; + mailbox.0[10] = 1920; + mailbox.0[11] = 1080; - mailbox[16] = SET_PIXEL_ORDER; - mailbox[17] = 4; - mailbox[18] = 4; - mailbox[19] = 0x1; // RGB + mailbox.0[12] = SET_PIXEL_DEPTH; + mailbox.0[13] = 4; + mailbox.0[14] = 4; + mailbox.0[15] = 32; // 32 bit per pixel - mailbox[20] = SET_FB_OFFSET; - mailbox[21] = 8; - mailbox[22] = 8; - mailbox[24] = 0; // X in pixels - mailbox[25] = 0; // Y in pixels + mailbox.0[16] = SET_PIXEL_ORDER; + mailbox.0[17] = 4; + mailbox.0[18] = 4; + mailbox.0[19] = 0x1; // RGB - mailbox[26] = ALLOCATE_BUFFER; - mailbox[27] = 8; - mailbox[28] = 4; - mailbox[29] = 4096; // Alignment - mailbox[30] = 0; + mailbox.0[20] = SET_FB_OFFSET; + mailbox.0[21] = 8; + mailbox.0[22] = 8; + mailbox.0[23] = 0; // X in pixels + mailbox.0[24] = 0; // Y in pixels - mailbox[31] = 0; // End tag + mailbox.0[25] = ALLOCATE_BUFFER; + mailbox.0[26] = 8; + mailbox.0[27] = 4; + mailbox.0[28] = 4096; // Alignment + mailbox.0[29] = 0; - // TODO: validate responses + mailbox.0[30] = GET_PITCH; + mailbox.0[31] = 4; + mailbox.0[32] = 0; + mailbox.0[33] = 0; - let addr = core::ptr::addr_of!(mailbox[0]) as u32; + mailbox.0[34] = 0; // End tag - write_mailbox(8, addr); + // TODO: validate responses - let _ = read_mailbox(8); - if mailbox[1] == 0 { - print("Failed\r\n"); + let addr = core::ptr::addr_of!(mailbox.0[0]) as u32; + + write_mailbox(8, addr); + + let _ = read_mailbox(8); + if mailbox.0[1] == 0 { + print("Failed\r\n"); + } + + print_u32_hex(mailbox.0[28]); + print("\r\n"); + + mailbox.0[28] &= 0x3FFFFFFF; + + Self { + pixel_depth: mailbox.0[15], + pitch: mailbox.0[33] / (mailbox.0[15] / 8), + rows: mailbox.0[29] / mailbox.0[33], + start_addr: mailbox.0[28] as *mut u32, + size: mailbox.0[29], + } } - print_u32(mailbox[29]); + pub fn draw_pixel(&self, x: u32, y: u32) { + let offset = x + y * self.pitch; + unsafe { + write_volatile(self.start_addr.add(offset as usize), 0x00AAFFFF); + } + } - mailbox[29] = (mailbox[29] & 0x00FF_FFFF) | 0x3F00_0000; + /*Bresenham's line algorithm */ + pub fn draw_line(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + if x1 == x2 { + for y in y1..=y2 { + self.draw_pixel(x1, y); + } + return; + } + let dx = x2 as i32 - x1 as i32; + let mut dy = y2 as i32 - y1 as i32; + let mut yi = 1; - let mut fb: *mut u32 = mailbox[29] as *mut u32; + let mut d = 2 * dy - dx; + let mut y = y1 as i32; - fb = unsafe { fb.add(1920 * 500 + 500) }; + if dy < 0 { + yi = -1; + dy = -dy; + } - for x in 0..500 { - for y in 0..10 { - unsafe { - *fb = 0xFFFFBB00; - fb = fb.add(1); - }; + for x in x1..=x2 { + self.draw_pixel(x, y as u32); + if d > 0 { + y = y + yi; + d += 2 * (dy - dx); + } else { + d += 2 * dy; + } } } } pub fn print_display_resolution() { - let mut mailbox = [0; 8]; + let mut mailbox: [u32; 8] = [0; 8]; mailbox[0] = 8 * 4; mailbox[1] = 0; mailbox[2] = GET_PHYSICAL_DISPLAY_WH; diff --git a/src/main.rs b/src/main.rs index da47fc7..c072687 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use core::{ }; use nova::{ - framebuffer::{init_fb, print_display_resolution}, + framebuffer::{print_display_resolution, FrameBuffer}, irq_interrupt::enable_irq_source, mailbox::read_soc_temp, peripherals::{ @@ -94,7 +94,23 @@ pub extern "C" fn kernel_main() -> ! { set_falling_edge_detect(26, true); print_display_resolution(); - init_fb(); + let fb = FrameBuffer::new(); + print_display_resolution(); + + fb.draw_line(10, 10, 1000, 10); + fb.draw_line(10, 10, 1000, 200); + fb.draw_line(10, 10, 1000, 300); + fb.draw_line(10, 10, 1000, 400); + fb.draw_line(10, 10, 1000, 500); + fb.draw_line(10, 10, 1000, 600); + fb.draw_line(10, 10, 1000, 700); + fb.draw_line(10, 10, 1000, 800); + fb.draw_line(10, 10, 1000, 900); + fb.draw_line(10, 10, 1000, 1000); + fb.draw_line(10, 10, 100, 1000); + + fb.draw_line(1800, 10, 1000, 900); + fb.draw_line(1800, 500, 1000, 100); loop { let temp = read_soc_temp(); diff --git a/src/peripherals/uart.rs b/src/peripherals/uart.rs index ebe45b4..92e76a2 100644 --- a/src/peripherals/uart.rs +++ b/src/peripherals/uart.rs @@ -59,6 +59,39 @@ pub fn print_u32(mut val: u32) { } } +pub fn print_u32_hex(mut val: u32) { + let mut last_valid = 0; + let mut values = [0u32; 8]; + for (i, c) in (&mut values).iter_mut().enumerate() { + if val == 0 { + break; + } + + *c = val % 16; + val /= 16; + if *c != 0 { + last_valid = i; + } + } + + for (i, c) in values.iter().enumerate().rev() { + if i > last_valid { + continue; + } + + let ascii_byte = if *c < 10 { + b'0' + *c as u8 + } else { + b'A' - 10 + *c as u8 + }; + + let data = [ascii_byte]; + + let s = str::from_utf8(&data).unwrap(); + print(s); + } +} + /// Initialize UART peripheral pub fn uart_init() { let baud_div_times_64 = (UART_CLK * 4) / BAUD; From 80c4c3604c5c9fd0156e72bcc543267fc99c3170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sat, 26 Jul 2025 17:17:05 +0200 Subject: [PATCH 3/8] Support lines in all directions and add squares --- README.md | 3 ++- src/framebuffer.rs | 67 ++++++++++++++++++++++++++++++++++++++++++++-- src/main.rs | 18 ++++--------- 3 files changed, 72 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 372bebc..325091c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ NovaOS is a expository project where I build a kernel from scratch for a Raspber - UART ✓ - GPIOs ✓ - GPIO Interrupts ✓ -- Frame Buffer +- Communicate with peripherals via mailboxes ✓ +- Frame Buffer ✓ - MMU - Basic Terminal over UART diff --git a/src/framebuffer.rs b/src/framebuffer.rs index aa80896..939e3cf 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -103,7 +103,9 @@ impl FrameBuffer { } } - /*Bresenham's line algorithm */ + /*Bresenham's line algorithm + TODO: check if its possible to optimize y1==y2 case + */ pub fn draw_line(&self, x1: u32, y1: u32, x2: u32, y2: u32) { if x1 == x2 { for y in y1..=y2 { @@ -111,6 +113,44 @@ impl FrameBuffer { } return; } + + if (y2 as i32 - y1 as i32).abs() < (x2 as i32 - x1 as i32).abs() { + if x1 > x2 { + self.plot_line_low(x2, y2, x1, y1); + } else { + self.plot_line_low(x1, y1, x2, y2); + } + } else { + if y1 > y2 { + self.plot_line_high(x2, y2, x1, y1); + } else { + self.plot_line_high(x1, y1, x2, y2); + } + } + } + + pub fn draw_square(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + self.draw_line(x1, y1, x2, y1); + self.draw_line(x1, y2, x2, y2); + self.draw_line(x1, y1, x1, y2); + self.draw_line(x2, y1, x2, y2); + } + + pub fn draw_square_fill(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + let mut y_start = y1; + let mut y_end = y2; + + if y2 < y1 { + y_start = y2; + y_end = y1; + } + + for y in y_start..=y_end { + self.draw_line(x1, y, x2, y); + } + } + + fn plot_line_low(&self, x1: u32, y1: u32, x2: u32, y2: u32) { let dx = x2 as i32 - x1 as i32; let mut dy = y2 as i32 - y1 as i32; let mut yi = 1; @@ -126,13 +166,36 @@ impl FrameBuffer { for x in x1..=x2 { self.draw_pixel(x, y as u32); if d > 0 { - y = y + yi; + y += yi; d += 2 * (dy - dx); } else { d += 2 * dy; } } } + fn plot_line_high(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + let mut dx = x2 as i32 - x1 as i32; + let dy = y2 as i32 - y1 as i32; + let mut xi: i32 = 1; + + let mut d = 2 * dy - dx; + let mut x = x1 as i32; + + if dx < 0 { + xi = -1; + dx = -dx; + } + + for y in y1..=y2 { + self.draw_pixel(x as u32, y); + if d > 0 { + x += xi; + d += 2 * (dx - dy); + } else { + d += 2 * dx; + } + } + } } pub fn print_display_resolution() { diff --git a/src/main.rs b/src/main.rs index c072687..591688f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,19 +98,11 @@ pub extern "C" fn kernel_main() -> ! { print_display_resolution(); fb.draw_line(10, 10, 1000, 10); - fb.draw_line(10, 10, 1000, 200); - fb.draw_line(10, 10, 1000, 300); - fb.draw_line(10, 10, 1000, 400); - fb.draw_line(10, 10, 1000, 500); - fb.draw_line(10, 10, 1000, 600); - fb.draw_line(10, 10, 1000, 700); - fb.draw_line(10, 10, 1000, 800); - fb.draw_line(10, 10, 1000, 900); - fb.draw_line(10, 10, 1000, 1000); - fb.draw_line(10, 10, 100, 1000); - - fb.draw_line(1800, 10, 1000, 900); - fb.draw_line(1800, 500, 1000, 100); + fb.draw_line(1000, 20, 10, 20); + fb.draw_square(500, 500, 600, 700); + fb.draw_square_fill(800, 800, 900, 900); + fb.draw_square_fill(1000, 800, 1200, 700); + fb.draw_square_fill(900, 100, 800, 150); loop { let temp = read_soc_temp(); From a4250898c04421348333c4070a6914eec63bde45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sun, 27 Jul 2025 11:03:52 +0200 Subject: [PATCH 4/8] Draw a line in each direction --- Cargo.lock | 9 +++++++++ Cargo.toml | 3 +++ src/lib.rs | 1 + src/main.rs | 8 ++++++-- src/math.rs | 5 +++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/math.rs diff --git a/Cargo.lock b/Cargo.lock index 8c89787..e68673b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + [[package]] name = "nova" version = "0.1.0" +dependencies = [ + "libm", +] diff --git a/Cargo.toml b/Cargo.toml index c8de713..8de0a0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,6 @@ opt-level = 0 [profile.release] panic = "abort" + +[dependencies] +libm = "0.2.15" diff --git a/src/lib.rs b/src/lib.rs index 2f92229..34e4c56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ pub mod configuration; pub mod framebuffer; pub mod irq_interrupt; pub mod mailbox; +pub mod math; pub mod timer; pub fn mmio_read(address: u32) -> u32 { diff --git a/src/main.rs b/src/main.rs index 591688f..b7df778 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use nova::{ framebuffer::{print_display_resolution, FrameBuffer}, irq_interrupt::enable_irq_source, mailbox::read_soc_temp, + math::polar_to_cartesian, peripherals::{ gpio::{ blink_gpio, gpio_pull_up, set_falling_edge_detect, set_gpio_function, GPIOFunction, @@ -97,8 +98,11 @@ pub extern "C" fn kernel_main() -> ! { let fb = FrameBuffer::new(); print_display_resolution(); - fb.draw_line(10, 10, 1000, 10); - fb.draw_line(1000, 20, 10, 20); + for a in 0..360 { + let (x, y) = polar_to_cartesian(100.0, a as f32); + fb.draw_line(150, 150, (150.0 + x) as u32, (150.0 + y) as u32); + } + fb.draw_square(500, 500, 600, 700); fb.draw_square_fill(800, 800, 900, 900); fb.draw_square_fill(1000, 800, 1200, 700); diff --git a/src/math.rs b/src/math.rs new file mode 100644 index 0000000..4597857 --- /dev/null +++ b/src/math.rs @@ -0,0 +1,5 @@ +pub fn polar_to_cartesian(r: f32, theta_rad: f32) -> (f32, f32) { + let x = r * libm::cosf(theta_rad); + let y = r * libm::sinf(theta_rad); + (x, y) +} From e6899097fc5ea936ce89ed4c26e446f80ed9693d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sun, 27 Jul 2025 21:06:17 +0200 Subject: [PATCH 5/8] Write letters --- src/framebuffer.rs | 20 ++++++ src/framebuffer/bitmaps.rs | 132 +++++++++++++++++++++++++++++++++++++ src/main.rs | 1 + tools/start_simulator.sh | 1 - 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 src/framebuffer/bitmaps.rs diff --git a/src/framebuffer.rs b/src/framebuffer.rs index 939e3cf..f33d643 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -1,5 +1,9 @@ use core::ptr::write_volatile; +mod bitmaps; + +use bitmaps::BASIC_LEGACY; + use crate::{ mailbox::{read_mailbox, write_mailbox}, peripherals::uart::{print, print_u32, print_u32_hex}, @@ -196,6 +200,22 @@ impl FrameBuffer { } } } + + pub fn draw_letter(&self, x: u32, y: u32, scale: u32) { + for (y_offset, row) in (&BASIC_LEGACY[0x70]).iter().enumerate() { + for bit in 0..8 { + match row & (1 << bit) { + 0 => {} + _ => self.draw_square_fill( + x + (bit * scale), + y + (y_offset as u32 * scale), + x + ((bit + 1) * scale), + y + ((y_offset + 1) as u32 * scale), + ), + } + } + } + } } pub fn print_display_resolution() { diff --git a/src/framebuffer/bitmaps.rs b/src/framebuffer/bitmaps.rs new file mode 100644 index 0000000..813c59f --- /dev/null +++ b/src/framebuffer/bitmaps.rs @@ -0,0 +1,132 @@ +pub const NOTHING_TO_DISPLAY: [u8; 8] = [0x00; 8]; + +pub const BASIC_LEGACY: [[u8; 8]; 128] = [ + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + NOTHING_TO_DISPLAY, + [0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00], + [0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + [0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00], + [0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00], + [0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00], + [0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00], + [0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00], + [0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00], + [0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00], + [0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00], + [0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00], + [0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06], + [0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00], + [0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00], + [0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00], + [0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00], + [0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00], + [0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00], + [0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00], + [0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00], + [0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00], + [0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00], + [0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00], + [0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00], + [0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00], + [0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00], + [0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06], + [0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00], + [0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00], + [0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00], + [0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00], + [0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00], + [0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00], + [0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00], + [0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00], + [0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00], + [0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00], + [0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00], + [0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00], + [0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00], + [0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00], + [0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00], + [0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00], + [0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00], + [0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00], + [0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00], + [0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00], + [0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00], + [0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00], + [0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00], + [0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00], + [0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00], + [0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00], + [0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00], + [0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00], + [0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00], + [0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00], + [0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00], + [0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00], + [0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00], + [0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00], + [0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00], + [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF], + [0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00], + [0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00], + [0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00], + [0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00], + [0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00], + [0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00], + [0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00], + [0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F], + [0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00], + [0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00], + [0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E], + [0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00], + [0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00], + [0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00], + [0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00], + [0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00], + [0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F], + [0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78], + [0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00], + [0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00], + [0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00], + [0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00], + [0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00], + [0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00], + [0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00], + [0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F], + [0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00], + [0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00], + [0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00], + [0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00], + [0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + NOTHING_TO_DISPLAY, +]; diff --git a/src/main.rs b/src/main.rs index b7df778..270c63d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,6 +107,7 @@ pub extern "C" fn kernel_main() -> ! { fb.draw_square_fill(800, 800, 900, 900); fb.draw_square_fill(1000, 800, 1200, 700); fb.draw_square_fill(900, 100, 800, 150); + fb.draw_letter(500, 5, 4); loop { let temp = read_soc_temp(); diff --git a/tools/start_simulator.sh b/tools/start_simulator.sh index f313b93..0955560 100755 --- a/tools/start_simulator.sh +++ b/tools/start_simulator.sh @@ -8,5 +8,4 @@ qemu-system-aarch64 \ -cpu cortex-a53 \ -serial stdio \ -sd ../sd.img \ - -display none \ -kernel ../target/aarch64-unknown-none/release/kernel8.img From 4e38beb87e1b454a6849825406737c5b5e662eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Tue, 29 Jul 2025 20:32:53 +0200 Subject: [PATCH 6/8] Print String --- src/framebuffer.rs | 21 +++++++++++++++++++-- src/main.rs | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/framebuffer.rs b/src/framebuffer.rs index f33d643..729d7c8 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -201,8 +201,25 @@ impl FrameBuffer { } } - pub fn draw_letter(&self, x: u32, y: u32, scale: u32) { - for (y_offset, row) in (&BASIC_LEGACY[0x70]).iter().enumerate() { + //TODO: Scale in pixels + pub fn draw_string(&self, string: &str, x: u32, mut y: u32, scale: u32) { + let mut offset = 0; + for c in string.bytes() { + match c { + b'\n' => { + y += 8 * scale; + offset = 0; + } + _ => { + self.draw_ascii(x + (offset as u32 * 8 * scale), y, c as usize, scale); + offset += 1 + } + } + } + } + + fn draw_ascii(&self, x: u32, y: u32, char: usize, scale: u32) { + for (y_offset, row) in (&BASIC_LEGACY[char]).iter().enumerate() { for bit in 0..8 { match row & (1 << bit) { 0 => {} diff --git a/src/main.rs b/src/main.rs index 270c63d..6e27811 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,7 +107,7 @@ pub extern "C" fn kernel_main() -> ! { fb.draw_square_fill(800, 800, 900, 900); fb.draw_square_fill(1000, 800, 1200, 700); fb.draw_square_fill(900, 100, 800, 150); - fb.draw_letter(500, 5, 4); + fb.draw_string("Hello World! :D\nTest next Line", 500, 5, 3); loop { let temp = read_soc_temp(); From 6c7c35685847f4127eb9900b7eb5ee683026f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Tue, 29 Jul 2025 21:03:05 +0200 Subject: [PATCH 7/8] Add colors and draw a rainbow --- src/framebuffer.rs | 60 ++++++++++++++++++++++++++++------------------ src/main.rs | 30 +++++++++++++++++------ 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/src/framebuffer.rs b/src/framebuffer.rs index 729d7c8..ccc3818 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -28,6 +28,12 @@ pub struct FrameBuffer { size: u32, //Bytes } +pub const RED: u32 = 0x00FF0000; +pub const GREEN: u32 = 0x0000FF00; +pub const BLUE: u32 = 0x000000FF; +pub const ORANGE: u32 = 0x00FFA500; +pub const YELLOW: u32 = 0x00FFFF00; + impl FrameBuffer { pub fn new() -> Self { let mut mailbox = Mailbox([0; 36]); @@ -54,7 +60,7 @@ impl FrameBuffer { mailbox.0[16] = SET_PIXEL_ORDER; mailbox.0[17] = 4; mailbox.0[18] = 4; - mailbox.0[19] = 0x1; // RGB + mailbox.0[19] = 0x0; // RGB mailbox.0[20] = SET_FB_OFFSET; mailbox.0[21] = 8; @@ -100,47 +106,47 @@ impl FrameBuffer { } } - pub fn draw_pixel(&self, x: u32, y: u32) { + pub fn draw_pixel(&self, x: u32, y: u32, color: u32) { let offset = x + y * self.pitch; unsafe { - write_volatile(self.start_addr.add(offset as usize), 0x00AAFFFF); + write_volatile(self.start_addr.add(offset as usize), color); } } /*Bresenham's line algorithm TODO: check if its possible to optimize y1==y2 case */ - pub fn draw_line(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + pub fn draw_line(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { if x1 == x2 { for y in y1..=y2 { - self.draw_pixel(x1, y); + self.draw_pixel(x1, y, color); } return; } if (y2 as i32 - y1 as i32).abs() < (x2 as i32 - x1 as i32).abs() { if x1 > x2 { - self.plot_line_low(x2, y2, x1, y1); + self.plot_line_low(x2, y2, x1, y1, color); } else { - self.plot_line_low(x1, y1, x2, y2); + self.plot_line_low(x1, y1, x2, y2, color); } } else { if y1 > y2 { - self.plot_line_high(x2, y2, x1, y1); + self.plot_line_high(x2, y2, x1, y1, color); } else { - self.plot_line_high(x1, y1, x2, y2); + self.plot_line_high(x1, y1, x2, y2, color); } } } - pub fn draw_square(&self, x1: u32, y1: u32, x2: u32, y2: u32) { - self.draw_line(x1, y1, x2, y1); - self.draw_line(x1, y2, x2, y2); - self.draw_line(x1, y1, x1, y2); - self.draw_line(x2, y1, x2, y2); + pub fn draw_square(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { + self.draw_line(x1, y1, x2, y1, color); + self.draw_line(x1, y2, x2, y2, color); + self.draw_line(x1, y1, x1, y2, color); + self.draw_line(x2, y1, x2, y2, color); } - pub fn draw_square_fill(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + pub fn draw_square_fill(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { let mut y_start = y1; let mut y_end = y2; @@ -150,11 +156,11 @@ impl FrameBuffer { } for y in y_start..=y_end { - self.draw_line(x1, y, x2, y); + self.draw_line(x1, y, x2, y, color); } } - fn plot_line_low(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + fn plot_line_low(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { let dx = x2 as i32 - x1 as i32; let mut dy = y2 as i32 - y1 as i32; let mut yi = 1; @@ -168,7 +174,7 @@ impl FrameBuffer { } for x in x1..=x2 { - self.draw_pixel(x, y as u32); + self.draw_pixel(x, y as u32, color); if d > 0 { y += yi; d += 2 * (dy - dx); @@ -177,7 +183,7 @@ impl FrameBuffer { } } } - fn plot_line_high(&self, x1: u32, y1: u32, x2: u32, y2: u32) { + fn plot_line_high(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { let mut dx = x2 as i32 - x1 as i32; let dy = y2 as i32 - y1 as i32; let mut xi: i32 = 1; @@ -191,7 +197,7 @@ impl FrameBuffer { } for y in y1..=y2 { - self.draw_pixel(x as u32, y); + self.draw_pixel(x as u32, y, color); if d > 0 { x += xi; d += 2 * (dx - dy); @@ -202,7 +208,7 @@ impl FrameBuffer { } //TODO: Scale in pixels - pub fn draw_string(&self, string: &str, x: u32, mut y: u32, scale: u32) { + pub fn draw_string(&self, string: &str, x: u32, mut y: u32, scale: u32, color: u32) { let mut offset = 0; for c in string.bytes() { match c { @@ -211,14 +217,14 @@ impl FrameBuffer { offset = 0; } _ => { - self.draw_ascii(x + (offset as u32 * 8 * scale), y, c as usize, scale); + self.draw_ascii(x + (offset as u32 * 8 * scale), y, c as usize, scale, color); offset += 1 } } } } - fn draw_ascii(&self, x: u32, y: u32, char: usize, scale: u32) { + fn draw_ascii(&self, x: u32, y: u32, char: usize, scale: u32, color: u32) { for (y_offset, row) in (&BASIC_LEGACY[char]).iter().enumerate() { for bit in 0..8 { match row & (1 << bit) { @@ -228,11 +234,19 @@ impl FrameBuffer { y + (y_offset as u32 * scale), x + ((bit + 1) * scale), y + ((y_offset + 1) as u32 * scale), + color, ), } } } } + + pub fn draw_function(&self, f: fn(u32) -> f64, x_offset: i32, y_offset: i32, color: u32) { + for x in 0..self.pitch as i32 { + let y = f(x as u32); + self.draw_pixel((x + x_offset) as u32, (y + y_offset as f64) as u32, color); + } + } } pub fn print_display_resolution() { diff --git a/src/main.rs b/src/main.rs index 6e27811..5c364ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use core::{ }; use nova::{ - framebuffer::{print_display_resolution, FrameBuffer}, + framebuffer::{print_display_resolution, FrameBuffer, BLUE, GREEN, ORANGE, RED, YELLOW}, irq_interrupt::enable_irq_source, mailbox::read_soc_temp, math::polar_to_cartesian, @@ -100,14 +100,26 @@ pub extern "C" fn kernel_main() -> ! { for a in 0..360 { let (x, y) = polar_to_cartesian(100.0, a as f32); - fb.draw_line(150, 150, (150.0 + x) as u32, (150.0 + y) as u32); + fb.draw_line( + 150, + 150, + (150.0 + x) as u32, + (150.0 + y) as u32, + a * (0x00FFFFFF / 360), + ); } - fb.draw_square(500, 500, 600, 700); - fb.draw_square_fill(800, 800, 900, 900); - fb.draw_square_fill(1000, 800, 1200, 700); - fb.draw_square_fill(900, 100, 800, 150); - fb.draw_string("Hello World! :D\nTest next Line", 500, 5, 3); + fb.draw_square(500, 500, 600, 700, RED); + fb.draw_square_fill(800, 800, 900, 900, GREEN); + fb.draw_square_fill(1000, 800, 1200, 700, BLUE); + fb.draw_square_fill(900, 100, 800, 150, RED | BLUE); + fb.draw_string("Hello World! :D\nTest next Line", 500, 5, 3, BLUE); + + fb.draw_function(cos, 100, 101, RED); + fb.draw_function(cos, 100, 102, ORANGE); + fb.draw_function(cos, 100, 103, YELLOW); + fb.draw_function(cos, 100, 104, GREEN); + fb.draw_function(cos, 100, 105, BLUE); loop { let temp = read_soc_temp(); @@ -118,6 +130,10 @@ pub extern "C" fn kernel_main() -> ! { } } +fn cos(x: u32) -> f64 { + libm::cos(x as f64 * 0.1) * 20.0 +} + pub fn get_current_el() -> u64 { let el: u64; unsafe { From 77910cf1c9f17720e76803a2c8426d009ba96991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Neuh=C3=A4user?= Date: Sat, 30 Aug 2025 15:36:20 +0200 Subject: [PATCH 8/8] Cleanup --- src/framebuffer.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/framebuffer.rs b/src/framebuffer.rs index ccc3818..537a927 100644 --- a/src/framebuffer.rs +++ b/src/framebuffer.rs @@ -92,9 +92,6 @@ impl FrameBuffer { print("Failed\r\n"); } - print_u32_hex(mailbox.0[28]); - print("\r\n"); - mailbox.0[28] &= 0x3FFFFFFF; Self { @@ -114,7 +111,7 @@ impl FrameBuffer { } /*Bresenham's line algorithm - TODO: check if its possible to optimize y1==y2 case + TODO: check if its possible to optimize y1==y2 case (ARM neon?) */ pub fn draw_line(&self, x1: u32, y1: u32, x2: u32, y2: u32, color: u32) { if x1 == x2 {