Fix display code
All checks were successful
Build / build (push) Successful in 1m21s

This commit is contained in:
Mathieu Strypsteen 2024-11-22 09:24:32 +01:00
parent 7a2c54645d
commit ebca494958
7 changed files with 20 additions and 34 deletions

22
Cargo.lock generated
View file

@ -64,7 +64,7 @@ dependencies = [
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn 2.0.87", "syn 2.0.89",
] ]
[[package]] [[package]]
@ -228,9 +228,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.162" version = "0.2.164"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -314,14 +314,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.87", "syn 2.0.89",
] ]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.89" version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -448,9 +448,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.87" version = "2.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -496,7 +496,7 @@ checksum = "9b24e77d3fc1e617051e630f99da24bcae6328abab37b8f9216bb68d06804f9a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.87", "syn 2.0.89",
] ]
[[package]] [[package]]
@ -518,9 +518,9 @@ checksum = "ab14ea9660d240e7865ce9d54ecdbd1cd9fa5802ae6f4512f093c7907e921533"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.13" version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"

View file

@ -23,18 +23,9 @@ use kernel_common::{
paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START}, paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START},
}; };
use log::{error, info}; use log::{error, info};
use misc::display::{display_print, setup_display};
use spin::Mutex; use spin::Mutex;
use sys::{ 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};
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,
};
mod cpu; mod cpu;
mod misc; mod misc;

View file

@ -13,9 +13,7 @@ use embedded_graphics::{
use kernel_common::loader_struct::FramebufferInfo; use kernel_common::loader_struct::FramebufferInfo;
use spin::Mutex; use spin::Mutex;
use crate::{cpu::paging::map_physical, misc::draw_target::FramebufferTarget}; use crate::{cpu::paging::map_physical, misc::draw_target::FramebufferTarget, sys::sync::Spinlock};
use super::sync::Spinlock;
static FRAMEBUFFER: Mutex<Option<FramebufferTarget>> = Mutex::new(None); static FRAMEBUFFER: Mutex<Option<FramebufferTarget>> = Mutex::new(None);
static FRAMEBUFFER_LOCK: Spinlock = Spinlock::new(); static FRAMEBUFFER_LOCK: Spinlock = Spinlock::new();

View file

@ -1,2 +1,3 @@
pub mod draw_target; pub mod display;
mod draw_target;
pub mod wrapped_alloc; pub mod wrapped_alloc;

View file

@ -1,5 +1,4 @@
pub mod acpica_osl; pub mod acpica_osl;
pub mod display;
pub mod early_acpi; pub mod early_acpi;
pub mod hpet; pub mod hpet;
mod ioapic; mod ioapic;

View file

@ -27,7 +27,7 @@ pub struct PageTable {
pub const KERNEL_VIRT_START: u64 = 0xffffffff80000000; pub const KERNEL_VIRT_START: u64 = 0xffffffff80000000;
pub const KERNEL_HEAP_START: u64 = 0xfffffffe00000000; 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) { pub unsafe fn load_cr3(cr3: u64) {
unsafe { unsafe {

View file

@ -9,17 +9,14 @@ pub fn setup_display() -> FramebufferInfo {
let mut gop: ScopedProtocol<GraphicsOutput> = open_protocol_exclusive(gop_handle).unwrap(); let mut gop: ScopedProtocol<GraphicsOutput> = open_protocol_exclusive(gop_handle).unwrap();
let modes = gop.modes(); let modes = gop.modes();
let mut best_mode = None; let mut best_mode = None;
let mut best_width = 0; let mut best_width = usize::MAX;
let mut best_height = 0; let mut best_height = usize::MAX;
for i in modes { for i in modes {
let info = i.info(); let info = i.info();
if info.pixel_format() != PixelFormat::Bgr { if info.pixel_format() != PixelFormat::Bgr {
continue; continue;
} }
if info.resolution().0 > 1280 || info.resolution().1 > 720 { if info.resolution().0 < best_width || info.resolution().1 < best_height {
continue;
}
if info.resolution().0 > best_width || info.resolution().1 > best_height {
best_width = info.resolution().0; best_width = info.resolution().0;
best_height = info.resolution().1; best_height = info.resolution().1;
best_mode = Some(i); best_mode = Some(i);