Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Fix framebuffer build issues and add framebuffer request to bootinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanPlant committed Feb 9, 2024
1 parent b63fc3c commit c1e3c79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
3 changes: 3 additions & 0 deletions charlotte_core/src/bootinfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
25 changes: 11 additions & 14 deletions charlotte_core/src/framebuffer/framebuffer.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,

}
}

Expand Down Expand Up @@ -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<FrameBufferInfo> {
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
Expand Down
5 changes: 0 additions & 5 deletions charlotte_core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c1e3c79

Please sign in to comment.