From ebca494958e80eb520d9d0102e9343339bedfda9 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Fri, 22 Nov 2024 09:24:32 +0100 Subject: [PATCH] Fix display code --- Cargo.lock | 22 +++++++++++----------- kernel/src/main.rs | 13 ++----------- kernel/src/{sys => misc}/display.rs | 4 +--- kernel/src/misc/mod.rs | 3 ++- kernel/src/sys/mod.rs | 1 - lib/kernel-common/src/paging.rs | 2 +- loader/src/display.rs | 9 +++------ 7 files changed, 20 insertions(+), 34 deletions(-) rename kernel/src/{sys => misc}/display.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 56775cb..1aa88d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -228,9 +228,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libloading" @@ -314,14 +314,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -496,7 +496,7 @@ checksum = "9b24e77d3fc1e617051e630f99da24bcae6328abab37b8f9216bb68d06804f9a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -518,9 +518,9 @@ checksum = "ab14ea9660d240e7865ce9d54ecdbd1cd9fa5802ae6f4512f093c7907e921533" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "windows-targets" diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 51e2571..3cb9160 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -23,18 +23,9 @@ use kernel_common::{ paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START}, }; use log::{error, info}; +use misc::display::{display_print, setup_display}; use spin::Mutex; -use sys::{ - acpica_osl::AE_OK, - display::{display_print, setup_display}, - early_acpi::EarlyACPIHandler, - hpet::setup_hpet, - lapic::setup_lapic_timer, - madt::parse_madt, - pic::disable_pic, - sync::LOCKS_HELD, - task::setup_multitasking, -}; +use sys::{acpica_osl::AE_OK, early_acpi::EarlyACPIHandler, hpet::setup_hpet, lapic::setup_lapic_timer, madt::parse_madt, pic::disable_pic, sync::LOCKS_HELD, task::setup_multitasking}; mod cpu; mod misc; diff --git a/kernel/src/sys/display.rs b/kernel/src/misc/display.rs similarity index 98% rename from kernel/src/sys/display.rs rename to kernel/src/misc/display.rs index 2b8fed2..94ab34c 100644 --- a/kernel/src/sys/display.rs +++ b/kernel/src/misc/display.rs @@ -13,9 +13,7 @@ use embedded_graphics::{ use kernel_common::loader_struct::FramebufferInfo; use spin::Mutex; -use crate::{cpu::paging::map_physical, misc::draw_target::FramebufferTarget}; - -use super::sync::Spinlock; +use crate::{cpu::paging::map_physical, misc::draw_target::FramebufferTarget, sys::sync::Spinlock}; static FRAMEBUFFER: Mutex> = Mutex::new(None); static FRAMEBUFFER_LOCK: Spinlock = Spinlock::new(); diff --git a/kernel/src/misc/mod.rs b/kernel/src/misc/mod.rs index c2bf383..b31dfe8 100644 --- a/kernel/src/misc/mod.rs +++ b/kernel/src/misc/mod.rs @@ -1,2 +1,3 @@ -pub mod draw_target; +pub mod display; +mod draw_target; pub mod wrapped_alloc; diff --git a/kernel/src/sys/mod.rs b/kernel/src/sys/mod.rs index 470d34e..9440a68 100644 --- a/kernel/src/sys/mod.rs +++ b/kernel/src/sys/mod.rs @@ -1,5 +1,4 @@ pub mod acpica_osl; -pub mod display; pub mod early_acpi; pub mod hpet; mod ioapic; diff --git a/lib/kernel-common/src/paging.rs b/lib/kernel-common/src/paging.rs index 11c498f..eb4ebe3 100644 --- a/lib/kernel-common/src/paging.rs +++ b/lib/kernel-common/src/paging.rs @@ -27,7 +27,7 @@ pub struct PageTable { pub const KERNEL_VIRT_START: u64 = 0xffffffff80000000; pub const KERNEL_HEAP_START: u64 = 0xfffffffe00000000; -pub const KERNEL_HEAP_INITIAL_SIZE: usize = 16 * 1024 * 1024; +pub const KERNEL_HEAP_INITIAL_SIZE: usize = 32 * 1024 * 1024; pub unsafe fn load_cr3(cr3: u64) { unsafe { diff --git a/loader/src/display.rs b/loader/src/display.rs index cd924c6..090c47d 100644 --- a/loader/src/display.rs +++ b/loader/src/display.rs @@ -9,17 +9,14 @@ pub fn setup_display() -> FramebufferInfo { let mut gop: ScopedProtocol = open_protocol_exclusive(gop_handle).unwrap(); let modes = gop.modes(); let mut best_mode = None; - let mut best_width = 0; - let mut best_height = 0; + let mut best_width = usize::MAX; + let mut best_height = usize::MAX; for i in modes { let info = i.info(); if info.pixel_format() != PixelFormat::Bgr { continue; } - if info.resolution().0 > 1280 || info.resolution().1 > 720 { - continue; - } - if info.resolution().0 > best_width || info.resolution().1 > best_height { + if info.resolution().0 < best_width || info.resolution().1 < best_height { best_width = info.resolution().0; best_height = info.resolution().1; best_mode = Some(i);