diff --git a/boot/yboot/src/main.rs b/boot/yboot/src/main.rs index de24c6c6..5324aed2 100644 --- a/boot/yboot/src/main.rs +++ b/boot/yboot/src/main.rs @@ -16,7 +16,7 @@ use log::{debug, error, info}; use uefi::{ prelude::*, proto::{ - console::gop::{GraphicsOutput, PixelFormat}, + console::gop::{self, GraphicsOutput, PixelFormat}, device_path::DevicePath, loaded_image::LoadedImage, media::{file::Directory, fs::SimpleFileSystem}, @@ -32,23 +32,31 @@ use yboot_proto::{ LoadProtocolV1, LOADER_MAGIC, }; -use crate::{mem::MemoryDescriptorExt, protocol_ext::GraphicsOutputExt}; +use crate::mem::MemoryDescriptorExt; + +fn mode_score(mode: &gop::Mode) -> usize { + let (w, h) = mode.info().resolution(); + let mut size_score = w * h; + if w > 1920 || h > 1080 { + // Don't pick too large sizes + size_score = 0; + } + size_score +} fn setup_framebuffer(bs: &BootServices, fb: &mut FramebufferOption) -> Result<(), Error> { let gop_handle = bs.get_handle_for_protocol::()?; let mut gop = bs.open_protocol_exclusive::(gop_handle)?; - // Find the requested mode - let mode = gop.match_mode(fb.req_width, fb.req_height).ok_or_else(|| { - error!( - "Requested mode is not supported: {}x{}", - fb.req_width, fb.req_height - ); + let mode = gop.modes().max_by_key(mode_score).ok_or_else(|| { + error!("No mode found"); Error::new(Status::INVALID_PARAMETER, ()) })?; gop.set_mode(&mode)?; + let (res_width, res_height) = mode.info().resolution(); + let mut result = gop.frame_buffer(); let format = match mode.info().pixel_format() { @@ -57,8 +65,8 @@ fn setup_framebuffer(bs: &BootServices, fb: &mut FramebufferOption) -> Result<() _ => 0, }; - fb.res_width = fb.req_width; - fb.res_height = fb.req_height; + fb.res_width = res_width as _; + fb.res_height = res_height as _; fb.res_address = result.as_mut_ptr() as _; fb.res_stride = mode.info().stride() as u64 * 4; fb.res_size = result.size() as _; diff --git a/kernel/arch/aarch64/src/lib.rs b/kernel/arch/aarch64/src/lib.rs index fc8d4e45..beeea550 100644 --- a/kernel/arch/aarch64/src/lib.rs +++ b/kernel/arch/aarch64/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(naked_functions, decl_macro)] +#![feature(decl_macro)] #![allow(clippy::new_without_default)] extern crate alloc; @@ -40,11 +40,9 @@ impl CpuData for PerCpuData {} static IPI_QUEUES: OneTimeInit>> = OneTimeInit::new(); pub static CPU_COUNT: AtomicUsize = AtomicUsize::new(1); -#[naked] +#[unsafe(naked)] extern "C" fn idle_task(_: usize) -> ! { - unsafe { - core::arch::naked_asm!("1: nop; b 1b"); - } + core::arch::naked_asm!("1: nop; b 1b"); } impl ArchitectureImpl { diff --git a/kernel/arch/riscv64/src/lib.rs b/kernel/arch/riscv64/src/lib.rs index 5b7c919d..1f3bbcdd 100644 --- a/kernel/arch/riscv64/src/lib.rs +++ b/kernel/arch/riscv64/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(decl_macro, naked_functions)] +#![feature(decl_macro)] #![no_std] extern crate alloc; @@ -60,11 +60,9 @@ impl CpuData for PerCpuData { } } -#[naked] +#[unsafe(naked)] extern "C" fn idle_task(_: usize) -> ! { - unsafe { - core::arch::naked_asm!("1: nop; j 1b"); - } + core::arch::naked_asm!("1: nop; j 1b"); } impl ArchitectureImpl { diff --git a/kernel/arch/x86_64/src/lib.rs b/kernel/arch/x86_64/src/lib.rs index baee22a6..c98e2441 100644 --- a/kernel/arch/x86_64/src/lib.rs +++ b/kernel/arch/x86_64/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] #![allow(clippy::new_without_default)] -#![feature(naked_functions)] extern crate alloc; @@ -69,18 +68,16 @@ impl PerCpuData { static IPI_QUEUES: OneTimeInit>> = OneTimeInit::new(); pub static CPU_COUNT: AtomicUsize = AtomicUsize::new(1); -#[naked] +#[unsafe(naked)] extern "C" fn idle_task(_: usize) -> ! { - unsafe { - core::arch::naked_asm!( - r#" + core::arch::naked_asm!( + r#" 1: nop jmp 1b "#, - options(att_syntax) - ); - } + options(att_syntax) + ); } impl ArchitectureImpl { diff --git a/userspace/graphics/colors/src/display.rs b/userspace/graphics/colors/src/display.rs index 09051fe7..50f152e8 100644 --- a/userspace/graphics/colors/src/display.rs +++ b/userspace/graphics/colors/src/display.rs @@ -9,8 +9,7 @@ use std::{ use crate::error::Error; -pub struct Display<'a> { -} +pub struct Display<'a> {} pub struct Point(pub T, pub T); @@ -47,7 +46,7 @@ impl Display<'_> { let src_chunk = &source[src_offset..src_offset + w]; let dst_chunk = &mut self.data[dst_offset..dst_offset + w]; - dst_chunk.copy_from_slice(src_chunk); + dst_chunk.copy_nonoverlapping(src_chunk); } self.flush(); diff --git a/userspace/sysutils/src/ls.rs b/userspace/sysutils/src/ls.rs index 23267496..f2731fa3 100644 --- a/userspace/sysutils/src/ls.rs +++ b/userspace/sysutils/src/ls.rs @@ -286,7 +286,6 @@ impl MetadataImpl for Metadata { } fn convert_file_time(time: SystemTime) -> chrono::DateTime { - log::info!("time = {time:?}"); let timestamp = time.duration_since(SystemTime::UNIX_EPOCH).unwrap(); chrono::DateTime::from_timestamp(timestamp.as_secs() as _, 0).unwrap() }