Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UEFI: Add support for different framebuffer configs on real hardware vs VMs #364

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a2fc6ce
Refactor UEFI implementation for compliance with rust-lang/rust#10745…
kennystrawnmusic Mar 27, 2023
fd818fc
rustfmt
kennystrawnmusic Mar 27, 2023
57bd85d
rust-osdev/bootloader#360: Resolve @phil-opp's concerns (1/5)
kennystrawnmusic Apr 12, 2023
ec7cbaa
rust-osdev/bootloader#360: Resolve @phil-opp's concerns (2/5)
kennystrawnmusic Apr 12, 2023
d18076e
rust-osdev/bootloader#360: Resolve @phil-opp's concerns (3/5 + 4/5)
kennystrawnmusic Apr 12, 2023
5d153e3
Update tests/runner/src/lib.rs
kennystrawnmusic Apr 12, 2023
02ecbb2
Fix unused import warning
phil-opp Apr 13, 2023
2aa4abf
Merge branch 'rust-osdev:main' into master
kennystrawnmusic Apr 15, 2023
84d3f62
Use highest resolution available on real hardware
kennystrawnmusic Apr 15, 2023
d8d4b9c
rustfmt
kennystrawnmusic Apr 15, 2023
ccb8bb2
Merge branch 'rust-osdev:main' into master
kennystrawnmusic Apr 30, 2023
16330cd
#364: Use different configs for VMs vs real hardware
kennystrawnmusic Apr 30, 2023
2f66e58
#364: rustfmt
kennystrawnmusic Apr 30, 2023
fb182e7
Merge branch 'rust-osdev:main' into master
kennystrawnmusic Sep 6, 2023
299a670
Pass the UEFI runtime services table address to the BootInfo if runni…
kennystrawnmusic Oct 2, 2023
68a123e
Pass the UEFI runtime services table address to the BootInfo if runni…
kennystrawnmusic Oct 2, 2023
c5b6e04
rustfmt
kennystrawnmusic Oct 2, 2023
31f77fa
Merge remote-tracking branch 'origin/patch-1'
kennystrawnmusic Oct 2, 2023
0b028db
Remove redundant dependencies
kennystrawnmusic Oct 2, 2023
35bcae6
Add back the Copy and Clone impls
kennystrawnmusic Oct 2, 2023
5578f36
Fix doc comments
kennystrawnmusic Oct 2, 2023
20dbee7
rustfmt
kennystrawnmusic Oct 2, 2023
82ea900
Merge commits pushed to pull request
kennystrawnmusic Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ log = "0.4.14"
x86_64 = "0.14.8"
serde-json-core = "0.5.0"
uefi = "0.20.0"
raw-cpuid = "10.7.0"
50 changes: 30 additions & 20 deletions uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use core::{
ops::{Deref, DerefMut},
ptr, slice,
};
use raw_cpuid::CpuId;
use uefi::{
prelude::{entry, Boot, Handle, Status, SystemTable},
proto::{
Expand Down Expand Up @@ -469,26 +470,35 @@ fn init_logger(
};

let mode = {
let modes = gop.modes();
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,
let mut modes = gop.modes();

if let Some(_) = CpuId::new().get_hypervisor_info() {
kennystrawnmusic marked this conversation as resolved.
Show resolved Hide resolved
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,
}
} else {
// Default to using the highest resolution available on real hardware
let x = gop.modes().map(|m| m.info().resolution().0).max().unwrap();
let y = gop.modes().map(|m| m.info().resolution().1).max().unwrap();

modes.find(|m| m.info().resolution().0 == x && m.info().resolution().1 == y)
kennystrawnmusic marked this conversation as resolved.
Show resolved Hide resolved
}
};
if let Some(mode) = mode {
Expand Down