From c1e3c79b1b9b12cdbefd77bd5e8caf5f566865de Mon Sep 17 00:00:00 2001 From: Ethan Plant Date: Thu, 8 Feb 2024 20:43:29 -0500 Subject: [PATCH] Fix framebuffer build issues and add framebuffer request to bootinfo --- charlotte_core/src/bootinfo/mod.rs | 3 +++ charlotte_core/src/framebuffer/framebuffer.rs | 25 ++++++++----------- charlotte_core/src/main.rs | 5 ---- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/charlotte_core/src/bootinfo/mod.rs b/charlotte_core/src/bootinfo/mod.rs index 28a935d..3bf7893 100644 --- a/charlotte_core/src/bootinfo/mod.rs +++ b/charlotte_core/src/bootinfo/mod.rs @@ -12,3 +12,6 @@ pub static BASE_REVISION: BaseRevision = BaseRevision::new(); pub static HHDM_REQUEST: HhdmRequest = HhdmRequest::new(); /// This request is used to obtain the memory map. pub static MEMORY_MAP_REQUEST: MemoryMapRequest = MemoryMapRequest::new(); + +/// This request is used to obtain the framebuffer +pub static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new(); diff --git a/charlotte_core/src/framebuffer/framebuffer.rs b/charlotte_core/src/framebuffer/framebuffer.rs index 10725ac..ff7709c 100644 --- a/charlotte_core/src/framebuffer/framebuffer.rs +++ b/charlotte_core/src/framebuffer/framebuffer.rs @@ -1,8 +1,9 @@ use crate::framebuffer::chars::{get_char_bitmap, FONT_HEIGHT, FONT_WIDTH}; +use crate::bootinfo::FRAMEBUFFER_REQUEST; // External crate for bootloader-specific functions and types. extern crate limine; -use limine::request::{FramebufferRequest}; use limine::framebuffer::Framebuffer; + /// A struct representing the framebuffer information, /// including its memory address, dimensions, pixel format, etc. pub struct FrameBufferInfo { @@ -28,11 +29,12 @@ impl FrameBufferInfo { /// * `framebuffer` - A reference to a limine `Framebuffer` struct. pub fn new(framebuffer: &Framebuffer) -> Self { Self { - address: framebuffer.address.as_ptr().unwrap() as *mut u32, - width: framebuffer.width as usize, - height: framebuffer.height as usize, - pitch: framebuffer.pitch as usize, - bpp: framebuffer.bpp as usize, + address: framebuffer.addr() as *mut u32, + width: framebuffer.width() as usize, + height: framebuffer.height() as usize, + pitch: framebuffer.pitch() as usize, + bpp: framebuffer.bpp() as usize, + } } @@ -231,19 +233,14 @@ impl FrameBufferInfo { } } - -/// A static request for framebuffer initialization via the limine protocol. -pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine:FramebufferRequest::new(0); - - /// Initializes the framebuffer and returns a `FrameBufferInfo` instance if successful. pub fn init_framebuffer() -> Option { - if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response().get() { - if framebuffer_response.framebuffer_count < 1 { + if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() { + if framebuffer_response.framebuffers().count() < 1 { return None; } - let framebuffer = &framebuffer_response.framebuffers()[0]; + let framebuffer = &framebuffer_response.framebuffers().next().unwrap(); Some(FrameBufferInfo::new(framebuffer)) } else { None diff --git a/charlotte_core/src/main.rs b/charlotte_core/src/main.rs index 5f91bc5..fee9ccf 100644 --- a/charlotte_core/src/main.rs +++ b/charlotte_core/src/main.rs @@ -15,11 +15,6 @@ use arch::{Api, ArchApi}; use framebuffer::framebuffer::{init_framebuffer, Point}; -// Set the limine revision to 1 -static BASE_REVISION: limine::BaseRevision = limine::BaseRevision::new(1); - - - #[no_mangle] unsafe extern "C" fn main() -> ! { let mut logger = ArchApi::get_logger();