@@ -13,7 +13,7 @@ use core::{
13
13
ops:: { Deref , DerefMut } ,
14
14
ptr, slice,
15
15
} ;
16
- use raw_cpuid:: CpuId ;
16
+ use raw_cpuid:: { CpuId , Hypervisor } ;
17
17
use uefi:: {
18
18
prelude:: { entry, Boot , Handle , Status , SystemTable } ,
19
19
proto:: {
@@ -98,13 +98,13 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> Status {
98
98
} ;
99
99
100
100
#[ allow( deprecated) ]
101
- if config. frame_buffer . minimum_framebuffer_height . is_none ( ) {
102
- config. frame_buffer . minimum_framebuffer_height =
101
+ if config. frame_buffer_physical . minimum_framebuffer_height . is_none ( ) {
102
+ config. frame_buffer_physical . minimum_framebuffer_height =
103
103
kernel. config . frame_buffer . minimum_framebuffer_height ;
104
104
}
105
105
#[ allow( deprecated) ]
106
- if config. frame_buffer . minimum_framebuffer_width . is_none ( ) {
107
- config. frame_buffer . minimum_framebuffer_width =
106
+ if config. frame_buffer_physical . minimum_framebuffer_width . is_none ( ) {
107
+ config. frame_buffer_physical . minimum_framebuffer_width =
108
108
kernel. config . frame_buffer . minimum_framebuffer_width ;
109
109
}
110
110
let framebuffer = init_logger ( image, & st, & config) ;
@@ -472,16 +472,62 @@ fn init_logger(
472
472
} ;
473
473
474
474
let mode = {
475
- let mut modes = gop. modes ( ) ;
476
-
477
- if let Some ( _) = CpuId :: new ( ) . get_hypervisor_info ( ) {
475
+ let modes = gop. modes ( ) ;
476
+
477
+ if let Some ( hypervisor) = CpuId :: new ( ) . get_hypervisor_info ( ) {
478
+ if let Hypervisor :: Xen = hypervisor. identify ( ) {
479
+ // Use same rules as real hardware since Xen uses the whole screen
480
+ match (
481
+ config
482
+ . frame_buffer_physical
483
+ . minimum_framebuffer_height
484
+ . map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
485
+ config
486
+ . frame_buffer_physical
487
+ . minimum_framebuffer_width
488
+ . map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
489
+ ) {
490
+ ( Some ( height) , Some ( width) ) => modes
491
+ . filter ( |m| {
492
+ let res = m. info ( ) . resolution ( ) ;
493
+ res. 1 >= height && res. 0 >= width
494
+ } )
495
+ . last ( ) ,
496
+ ( Some ( height) , None ) => modes. filter ( |m| m. info ( ) . resolution ( ) . 1 >= height) . last ( ) ,
497
+ ( None , Some ( width) ) => modes. filter ( |m| m. info ( ) . resolution ( ) . 0 >= width) . last ( ) ,
498
+ _ => None ,
499
+ }
500
+ } else {
501
+ match (
502
+ config
503
+ . frame_buffer_virtual
504
+ . minimum_framebuffer_height
505
+ . map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
506
+ config
507
+ . frame_buffer_virtual
508
+ . minimum_framebuffer_width
509
+ . map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
510
+ ) {
511
+ ( Some ( height) , Some ( width) ) => modes
512
+ . filter ( |m| {
513
+ let res = m. info ( ) . resolution ( ) ;
514
+ res. 1 >= height && res. 0 >= width
515
+ } )
516
+ . last ( ) ,
517
+ ( Some ( height) , None ) => modes. filter ( |m| m. info ( ) . resolution ( ) . 1 >= height) . last ( ) ,
518
+ ( None , Some ( width) ) => modes. filter ( |m| m. info ( ) . resolution ( ) . 0 >= width) . last ( ) ,
519
+ _ => None ,
520
+ }
521
+ }
522
+ } else {
523
+ // On real hardware; set rules accordingly
478
524
match (
479
525
config
480
- . frame_buffer
526
+ . frame_buffer_physical
481
527
. minimum_framebuffer_height
482
528
. map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
483
529
config
484
- . frame_buffer
530
+ . frame_buffer_physical
485
531
. minimum_framebuffer_width
486
532
. map ( |v| usize:: try_from ( v) . unwrap ( ) ) ,
487
533
) {
@@ -495,12 +541,6 @@ fn init_logger(
495
541
( None , Some ( width) ) => modes. filter ( |m| m. info ( ) . resolution ( ) . 0 >= width) . last ( ) ,
496
542
_ => None ,
497
543
}
498
- } else {
499
- // Default to using the highest resolution available on real hardware
500
- let x = gop. modes ( ) . map ( |m| m. info ( ) . resolution ( ) . 0 ) . max ( ) . unwrap ( ) ;
501
- let y = gop. modes ( ) . map ( |m| m. info ( ) . resolution ( ) . 1 ) . max ( ) . unwrap ( ) ;
502
-
503
- modes. find ( |m| m. info ( ) . resolution ( ) . 0 == x && m. info ( ) . resolution ( ) . 1 == y)
504
544
}
505
545
} ;
506
546
if let Some ( mode) = mode {
0 commit comments