Skip to content
Snippets Groups Projects
Verified Commit 1b2a28a4 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Use FRAMEBUFFER variables for graphical debug

parent 413238a0
No related branches found
No related tags found
No related merge requests found
use core::str;
use spin::Mutex;
use crate::memory::Frame;
......@@ -7,31 +8,45 @@ use crate::paging::mapper::PageFlushAll;
pub use self::debug::DebugDisplay;
use self::display::Display;
use self::mode_info::VBEModeInfo;
use self::primitive::fast_set64;
pub mod debug;
pub mod display;
pub mod mode_info;
pub mod primitive;
pub static FONT: &'static [u8] = include_bytes!("../../../../res/unifont.font");
pub static DEBUG_DISPLAY: Mutex<Option<DebugDisplay>> = Mutex::new(None);
pub fn init(active_table: &mut ActivePageTable) {
pub fn init(active_table: &mut ActivePageTable, env: &[u8]) {
println!("Starting graphical debug");
let width;
let height;
let physbaseptr;
let mut width = 0;
let mut height = 0;
let mut physbaseptr = 0;
{
let mode_info_addr = 0x5200 + crate::PHYS_OFFSET;
let mode_info = unsafe { &*(mode_info_addr as *const VBEModeInfo) };
width = mode_info.xresolution as usize;
height = mode_info.yresolution as usize;
physbaseptr = mode_info.physbaseptr as usize;
//TODO: should errors be reported?
for line in str::from_utf8(env).unwrap_or("").lines() {
let mut parts = line.splitn(2, '=');
let name = parts.next().unwrap_or("");
let value = parts.next().unwrap_or("");
if name == "FRAMEBUFFER_ADDR" {
physbaseptr = usize::from_str_radix(value, 16).unwrap_or(0);
}
if name == "FRAMEBUFFER_WIDTH" {
width = usize::from_str_radix(value, 16).unwrap_or(0);
}
if name == "FRAMEBUFFER_HEIGHT" {
height = usize::from_str_radix(value, 16).unwrap_or(0);
}
}
if physbaseptr == 0 || width == 0 || height == 0 {
println!("Framebuffer not found");
return;
}
println!("Framebuffer {}x{} at {:X}", width, height, physbaseptr);
......
/// The info of the VBE mode
#[derive(Copy, Clone, Default, Debug)]
#[repr(packed)]
pub struct VBEModeInfo {
attributes: u16,
win_a: u8,
win_b: u8,
granularity: u16,
winsize: u16,
segment_a: u16,
segment_b: u16,
winfuncptr: u32,
bytesperscanline: u16,
pub xresolution: u16,
pub yresolution: u16,
xcharsize: u8,
ycharsize: u8,
numberofplanes: u8,
bitsperpixel: u8,
numberofbanks: u8,
memorymodel: u8,
banksize: u8,
numberofimagepages: u8,
unused: u8,
redmasksize: u8,
redfieldposition: u8,
greenmasksize: u8,
greenfieldposition: u8,
bluemasksize: u8,
bluefieldposition: u8,
rsvdmasksize: u8,
rsvdfieldposition: u8,
directcolormodeinfo: u8,
pub physbaseptr: u32,
offscreenmemoryoffset: u32,
offscreenmemsize: u16,
}
......@@ -149,9 +149,12 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
// Activate memory logging
log::init();
// Convert env to slice
let env = slice::from_raw_parts((env_base + crate::PHYS_OFFSET) as *const u8, env_size);
// Use graphical debug
#[cfg(feature="graphical_debug")]
graphical_debug::init(&mut active_table);
graphical_debug::init(&mut active_table, env);
#[cfg(feature = "system76_ec_debug")]
device::system76_ec::init();
......@@ -175,7 +178,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
BSP_READY.store(true, Ordering::SeqCst);
slice::from_raw_parts((env_base + crate::PHYS_OFFSET) as *const u8, env_size)
env
};
crate::kmain(CPU_COUNT.load(Ordering::SeqCst), env);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment