dynamically support display discovery

This commit is contained in:
Able 2023-05-08 03:53:15 -05:00
parent 308592cbf9
commit 4a8b56a474
3 changed files with 21 additions and 13 deletions

View file

@ -1,20 +1,27 @@
use virtio_drivers::transport::Transport;
use crate::arch::virtio::AbleosHal;
use {embedded_graphics::pixelcolor::Rgb888, virtio_drivers::device::gpu::VirtIOGpu};
use {limine::NonNullPtr, virtio_drivers::transport::Transport};
use {
crate::{arch::virtio::AbleosHal, kmain::DEVICE_TREE},
able_graphics_library::raw_pixel::Display,
embedded_graphics::prelude::*,
limine::FramebufferRequest,
embedded_graphics::{pixelcolor::Rgb888, prelude::*},
limine::{Framebuffer, FramebufferRequest},
spin::{Lazy, Mutex},
virtio_drivers::device::gpu::VirtIOGpu,
};
pub static DISPLAY: Lazy<Mutex<Display>> = Lazy::new(|| {
static FB_REQ: FramebufferRequest = FramebufferRequest::new(0);
let fb1 = &FB_REQ.get_response().get().unwrap().framebuffers()[0];
let fb1: &NonNullPtr<Framebuffer> = &FB_REQ.get_response().get().unwrap().framebuffers()[0];
{
use crate::alloc::string::ToString;
let mut dt = DEVICE_TREE.lock();
let mut disp = xml::XMLElement::new("display_0");
disp.set_attribute("width", fb1.width);
disp.set_attribute("height", fb1.height);
disp.set_attribute("bits per pixel", fb1.bpp);
dt.devices.insert("Displays".to_string(), alloc::vec![disp]);
}
let m = Mutex::new(Display {
fb: fb1.address.as_ptr().unwrap().cast(),
size: Size::new(fb1.width as u32, fb1.height as u32),

View file

@ -114,12 +114,10 @@ unsafe extern "C" fn _kernel_start() -> ! {
graphics::init();
let mut dis = DISPLAY.lock();
use {able_graphics_library::raw_pixel, embedded_graphics::prelude::RgbColor};
dis.set_color(Rgb888::GREEN);
dis.line(1, 1, 10, 10, 4);
// dis.line(1, 200, 100, 10, 1);
// dis.line(1, 1, 200, 10, 1);
dis.line(1, 1, 700, 1000, 1);
// dis.line(10, 10, 100, 10, 10);
// dis.line(100, 10, 1, 1, 10);
}
crate::kmain::kmain(
@ -162,3 +160,5 @@ pub fn hardware_random_u64() -> u64 {
ret
}
pub fn get_edid() {}

View file

@ -45,6 +45,7 @@ use crate::utils::TAB;
impl fmt::Display for DeviceTree {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f);
for (device_type, devices) in &self.devices {
writeln!(f, "\r{TAB}{}/\r", device_type)?;
for device in devices {