Skip to content

Commit e531ee0

Browse files
Undo changes in pull request rust-osdev#364
1 parent 82ea900 commit e531ee0

File tree

3 files changed

+32
-102
lines changed

3 files changed

+32
-102
lines changed

bios/stage-4/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,20 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! {
130130

131131
#[allow(deprecated)]
132132
if config
133-
.frame_buffer_physical
133+
.frame_buffer
134134
.minimum_framebuffer_height
135135
.is_none()
136136
{
137-
config.frame_buffer_physical.minimum_framebuffer_height =
137+
config.frame_buffer.minimum_framebuffer_height =
138138
kernel.config.frame_buffer.minimum_framebuffer_height;
139139
}
140140
#[allow(deprecated)]
141141
if config
142-
.frame_buffer_physical
142+
.frame_buffer
143143
.minimum_framebuffer_width
144144
.is_none()
145145
{
146-
config.frame_buffer_physical.minimum_framebuffer_width =
146+
config.frame_buffer.minimum_framebuffer_width =
147147
kernel.config.frame_buffer.minimum_framebuffer_width;
148148
}
149149
let framebuffer_info = init_logger(

common/config/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ use serde::{Deserialize, Serialize};
77
#[serde(default)]
88
#[non_exhaustive]
99
pub struct BootConfig {
10-
/// Configuration for the frame buffer setup on physical hardware.
11-
pub frame_buffer_physical: FrameBuffer,
12-
13-
/// Configuration for the frame buffer setup in a virtual machine
14-
pub frame_buffer_virtual: FrameBuffer,
10+
/// Configuration for the frame buffer setup.
11+
pub frame_buffer: FrameBuffer,
1512

1613
/// The minimum log level that is printed to the screen during boot.
1714
///
@@ -35,8 +32,7 @@ pub struct BootConfig {
3532
impl Default for BootConfig {
3633
fn default() -> Self {
3734
Self {
38-
frame_buffer_virtual: Default::default(),
39-
frame_buffer_physical: Default::default(),
35+
frame_buffer: Default::default(),
4036
log_level: Default::default(),
4137
frame_buffer_logging: true,
4238
serial_logging: true,

uefi/src/main.rs

Lines changed: 25 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use core::{
1313
ops::{Deref, DerefMut},
1414
ptr, slice,
1515
};
16-
use raw_cpuid::{CpuId, Hypervisor};
1716
use uefi::{
1817
prelude::{entry, Boot, Handle, Status, SystemTable},
1918
proto::{
@@ -98,21 +97,13 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> Status {
9897
};
9998

10099
#[allow(deprecated)]
101-
if config
102-
.frame_buffer_physical
103-
.minimum_framebuffer_height
104-
.is_none()
105-
{
106-
config.frame_buffer_physical.minimum_framebuffer_height =
100+
if config.frame_buffer.minimum_framebuffer_height.is_none() {
101+
config.frame_buffer.minimum_framebuffer_height =
107102
kernel.config.frame_buffer.minimum_framebuffer_height;
108103
}
109104
#[allow(deprecated)]
110-
if config
111-
.frame_buffer_physical
112-
.minimum_framebuffer_width
113-
.is_none()
114-
{
115-
config.frame_buffer_physical.minimum_framebuffer_width =
105+
if config.frame_buffer.minimum_framebuffer_width.is_none() {
106+
config.frame_buffer.minimum_framebuffer_width =
116107
kernel.config.frame_buffer.minimum_framebuffer_width;
117108
}
118109
let framebuffer = init_logger(image, &st, &config);
@@ -175,7 +166,7 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> Status {
175166
},
176167
ramdisk_addr,
177168
ramdisk_len,
178-
rt_table_addr: Some(system_table.get_current_system_table_addr()),
169+
rt_table_addr: Some(&system_table as *const _ as u64),
179170
};
180171

181172
bootloader_x86_64_common::load_and_switch_to_kernel(
@@ -482,82 +473,25 @@ fn init_logger(
482473

483474
let mode = {
484475
let modes = gop.modes();
485-
486-
if let Some(hypervisor) = CpuId::new().get_hypervisor_info() {
487-
if let Hypervisor::Xen = hypervisor.identify() {
488-
// Use same rules as real hardware since Xen uses the whole screen
489-
match (
490-
config
491-
.frame_buffer_physical
492-
.minimum_framebuffer_height
493-
.map(|v| usize::try_from(v).unwrap()),
494-
config
495-
.frame_buffer_physical
496-
.minimum_framebuffer_width
497-
.map(|v| usize::try_from(v).unwrap()),
498-
) {
499-
(Some(height), Some(width)) => modes
500-
.filter(|m| {
501-
let res = m.info().resolution();
502-
res.1 >= height && res.0 >= width
503-
})
504-
.last(),
505-
(Some(height), None) => {
506-
modes.filter(|m| m.info().resolution().1 >= height).last()
507-
}
508-
(None, Some(width)) => {
509-
modes.filter(|m| m.info().resolution().0 >= width).last()
510-
}
511-
_ => None,
512-
}
513-
} else {
514-
match (
515-
config
516-
.frame_buffer_virtual
517-
.minimum_framebuffer_height
518-
.map(|v| usize::try_from(v).unwrap()),
519-
config
520-
.frame_buffer_virtual
521-
.minimum_framebuffer_width
522-
.map(|v| usize::try_from(v).unwrap()),
523-
) {
524-
(Some(height), Some(width)) => modes
525-
.filter(|m| {
526-
let res = m.info().resolution();
527-
res.1 >= height && res.0 >= width
528-
})
529-
.last(),
530-
(Some(height), None) => {
531-
modes.filter(|m| m.info().resolution().1 >= height).last()
532-
}
533-
(None, Some(width)) => {
534-
modes.filter(|m| m.info().resolution().0 >= width).last()
535-
}
536-
_ => None,
537-
}
538-
}
539-
} else {
540-
// On real hardware; set rules accordingly
541-
match (
542-
config
543-
.frame_buffer_physical
544-
.minimum_framebuffer_height
545-
.map(|v| usize::try_from(v).unwrap()),
546-
config
547-
.frame_buffer_physical
548-
.minimum_framebuffer_width
549-
.map(|v| usize::try_from(v).unwrap()),
550-
) {
551-
(Some(height), Some(width)) => modes
552-
.filter(|m| {
553-
let res = m.info().resolution();
554-
res.1 >= height && res.0 >= width
555-
})
556-
.last(),
557-
(Some(height), None) => modes.filter(|m| m.info().resolution().1 >= height).last(),
558-
(None, Some(width)) => modes.filter(|m| m.info().resolution().0 >= width).last(),
559-
_ => None,
560-
}
476+
match (
477+
config
478+
.frame_buffer
479+
.minimum_framebuffer_height
480+
.map(|v| usize::try_from(v).unwrap()),
481+
config
482+
.frame_buffer
483+
.minimum_framebuffer_width
484+
.map(|v| usize::try_from(v).unwrap()),
485+
) {
486+
(Some(height), Some(width)) => modes
487+
.filter(|m| {
488+
let res = m.info().resolution();
489+
res.1 >= height && res.0 >= width
490+
})
491+
.last(),
492+
(Some(height), None) => modes.filter(|m| m.info().resolution().1 >= height).last(),
493+
(None, Some(width)) => modes.filter(|m| m.info().resolution().0 >= width).last(),
494+
_ => None,
561495
}
562496
};
563497
if let Some(mode) = mode {
@@ -620,4 +554,4 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
620554
loop {
621555
unsafe { asm!("cli; hlt") };
622556
}
623-
}
557+
}

0 commit comments

Comments
 (0)