diff --git a/bios/stage-4/src/main.rs b/bios/stage-4/src/main.rs index 6042e463..acabab3a 100644 --- a/bios/stage-4/src/main.rs +++ b/bios/stage-4/src/main.rs @@ -130,20 +130,20 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! { #[allow(deprecated)] if config - .frame_buffer_physical + .frame_buffer .minimum_framebuffer_height .is_none() { - config.frame_buffer_physical.minimum_framebuffer_height = + config.frame_buffer.minimum_framebuffer_height = kernel.config.frame_buffer.minimum_framebuffer_height; } #[allow(deprecated)] if config - .frame_buffer_physical + .frame_buffer .minimum_framebuffer_width .is_none() { - config.frame_buffer_physical.minimum_framebuffer_width = + config.frame_buffer.minimum_framebuffer_width = kernel.config.frame_buffer.minimum_framebuffer_width; } let framebuffer_info = init_logger( diff --git a/common/config/src/lib.rs b/common/config/src/lib.rs index 2ee11fc0..1b294331 100644 --- a/common/config/src/lib.rs +++ b/common/config/src/lib.rs @@ -7,11 +7,8 @@ use serde::{Deserialize, Serialize}; #[serde(default)] #[non_exhaustive] pub struct BootConfig { - /// Configuration for the frame buffer setup on physical hardware. - pub frame_buffer_physical: FrameBuffer, - - /// Configuration for the frame buffer setup in a virtual machine - pub frame_buffer_virtual: FrameBuffer, + /// Configuration for the frame buffer setup. + pub frame_buffer: FrameBuffer, /// The minimum log level that is printed to the screen during boot. /// @@ -35,8 +32,7 @@ pub struct BootConfig { impl Default for BootConfig { fn default() -> Self { Self { - frame_buffer_virtual: Default::default(), - frame_buffer_physical: Default::default(), + frame_buffer: Default::default(), log_level: Default::default(), frame_buffer_logging: true, serial_logging: true, diff --git a/uefi/src/main.rs b/uefi/src/main.rs index 160ef517..79533c7a 100644 --- a/uefi/src/main.rs +++ b/uefi/src/main.rs @@ -13,7 +13,6 @@ use core::{ ops::{Deref, DerefMut}, ptr, slice, }; -use raw_cpuid::{CpuId, Hypervisor}; use uefi::{ prelude::{entry, Boot, Handle, Status, SystemTable}, proto::{ @@ -98,21 +97,13 @@ fn main_inner(image: Handle, mut st: SystemTable) -> Status { }; #[allow(deprecated)] - if config - .frame_buffer_physical - .minimum_framebuffer_height - .is_none() - { - config.frame_buffer_physical.minimum_framebuffer_height = + if config.frame_buffer.minimum_framebuffer_height.is_none() { + config.frame_buffer.minimum_framebuffer_height = kernel.config.frame_buffer.minimum_framebuffer_height; } #[allow(deprecated)] - if config - .frame_buffer_physical - .minimum_framebuffer_width - .is_none() - { - config.frame_buffer_physical.minimum_framebuffer_width = + if config.frame_buffer.minimum_framebuffer_width.is_none() { + config.frame_buffer.minimum_framebuffer_width = kernel.config.frame_buffer.minimum_framebuffer_width; } let framebuffer = init_logger(image, &st, &config); @@ -175,7 +166,7 @@ fn main_inner(image: Handle, mut st: SystemTable) -> Status { }, ramdisk_addr, ramdisk_len, - rt_table_addr: Some(system_table.get_current_system_table_addr()), + rt_table_addr: Some(&system_table as *const _ as u64), }; bootloader_x86_64_common::load_and_switch_to_kernel( @@ -482,82 +473,25 @@ fn init_logger( let mode = { let modes = gop.modes(); - - if let Some(hypervisor) = CpuId::new().get_hypervisor_info() { - if let Hypervisor::Xen = hypervisor.identify() { - // Use same rules as real hardware since Xen uses the whole screen - match ( - config - .frame_buffer_physical - .minimum_framebuffer_height - .map(|v| usize::try_from(v).unwrap()), - config - .frame_buffer_physical - .minimum_framebuffer_width - .map(|v| usize::try_from(v).unwrap()), - ) { - (Some(height), Some(width)) => modes - .filter(|m| { - let res = m.info().resolution(); - res.1 >= height && res.0 >= width - }) - .last(), - (Some(height), None) => { - modes.filter(|m| m.info().resolution().1 >= height).last() - } - (None, Some(width)) => { - modes.filter(|m| m.info().resolution().0 >= width).last() - } - _ => None, - } - } else { - match ( - config - .frame_buffer_virtual - .minimum_framebuffer_height - .map(|v| usize::try_from(v).unwrap()), - config - .frame_buffer_virtual - .minimum_framebuffer_width - .map(|v| usize::try_from(v).unwrap()), - ) { - (Some(height), Some(width)) => modes - .filter(|m| { - let res = m.info().resolution(); - res.1 >= height && res.0 >= width - }) - .last(), - (Some(height), None) => { - modes.filter(|m| m.info().resolution().1 >= height).last() - } - (None, Some(width)) => { - modes.filter(|m| m.info().resolution().0 >= width).last() - } - _ => None, - } - } - } else { - // On real hardware; set rules accordingly - match ( - config - .frame_buffer_physical - .minimum_framebuffer_height - .map(|v| usize::try_from(v).unwrap()), - config - .frame_buffer_physical - .minimum_framebuffer_width - .map(|v| usize::try_from(v).unwrap()), - ) { - (Some(height), Some(width)) => modes - .filter(|m| { - let res = m.info().resolution(); - res.1 >= height && res.0 >= width - }) - .last(), - (Some(height), None) => modes.filter(|m| m.info().resolution().1 >= height).last(), - (None, Some(width)) => modes.filter(|m| m.info().resolution().0 >= width).last(), - _ => None, - } + match ( + config + .frame_buffer + .minimum_framebuffer_height + .map(|v| usize::try_from(v).unwrap()), + config + .frame_buffer + .minimum_framebuffer_width + .map(|v| usize::try_from(v).unwrap()), + ) { + (Some(height), Some(width)) => modes + .filter(|m| { + let res = m.info().resolution(); + res.1 >= height && res.0 >= width + }) + .last(), + (Some(height), None) => modes.filter(|m| m.info().resolution().1 >= height).last(), + (None, Some(width)) => modes.filter(|m| m.info().resolution().0 >= width).last(), + _ => None, } }; if let Some(mode) = mode { @@ -620,4 +554,4 @@ fn panic(info: &core::panic::PanicInfo) -> ! { loop { unsafe { asm!("cli; hlt") }; } -} +} \ No newline at end of file