yboot: pick higher fb resolutions

This commit is contained in:
2025-05-17 11:22:14 +03:00
parent 8c4a882766
commit 2fcf800cc8
6 changed files with 31 additions and 32 deletions
+18 -10
View File
@@ -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::<GraphicsOutput>()?;
let mut gop = bs.open_protocol_exclusive::<GraphicsOutput>(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 _;
+3 -5
View File
@@ -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<Vec<IpiQueue<ArchitectureImpl>>> = 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 {
+3 -5
View File
@@ -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 {
+5 -8
View File
@@ -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<Vec<IpiQueue<ArchitectureImpl>>> = 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 {
+2 -3
View File
@@ -9,8 +9,7 @@ use std::{
use crate::error::Error;
pub struct Display<'a> {
}
pub struct Display<'a> {}
pub struct Point<T>(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();
-1
View File
@@ -286,7 +286,6 @@ impl MetadataImpl for Metadata {
}
fn convert_file_time(time: SystemTime) -> chrono::DateTime<chrono::Utc> {
log::info!("time = {time:?}");
let timestamp = time.duration_since(SystemTime::UNIX_EPOCH).unwrap();
chrono::DateTime::from_timestamp(timestamp.as_secs() as _, 0).unwrap()
}