Skip to content

Commit

Permalink
Undo changes in pull request rust-osdev#364
Browse files Browse the repository at this point in the history
  • Loading branch information
kennystrawnmusic committed Oct 22, 2023
1 parent 82ea900 commit e531ee0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 102 deletions.
8 changes: 4 additions & 4 deletions bios/stage-4/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Check failure on line 140 in bios/stage-4/src/main.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/bootloader/bootloader/bios/stage-4/src/main.rs
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(
Expand Down
10 changes: 3 additions & 7 deletions common/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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,
Expand Down
116 changes: 25 additions & 91 deletions uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -98,21 +97,13 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> 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);
Expand Down Expand Up @@ -175,7 +166,7 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> 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(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -620,4 +554,4 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
loop {
unsafe { asm!("cli; hlt") };

Check failure on line 555 in uefi/src/main.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/bootloader/bootloader/uefi/src/main.rs
}
}
}

0 comments on commit e531ee0

Please sign in to comment.