File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,8 +99,14 @@ pub fn boot_next_processor() {
9999 #[ allow( unused_variables) ]
100100 let cpu_online = CPU_ONLINE . 0 . fetch_add ( 1 , Ordering :: Release ) ;
101101
102+ #[ allow( clippy:: needless_return) ]
103+ #[ cfg( feature = "uhyve" ) ]
104+ if crate :: env:: is_uhyve ( ) {
105+ return ;
106+ }
107+
102108 #[ cfg( all( target_os = "none" , feature = "smp" ) ) ]
103- if ! crate :: env :: is_uhyve ( ) && get_possible_cpus ( ) > 1 {
109+ if get_possible_cpus ( ) > 1 {
104110 use core:: arch:: asm;
105111 use core:: hint:: spin_loop;
106112
Original file line number Diff line number Diff line change @@ -262,6 +262,7 @@ pub fn supports_2mib_pages() -> bool {
262262}
263263
264264pub fn configure ( ) {
265+ #[ cfg( feature = "uhyve" ) ]
265266 if env:: is_uhyve ( ) {
266267 return ;
267268 }
Original file line number Diff line number Diff line change @@ -149,11 +149,14 @@ pub fn boot_next_processor() {
149149 // TODO: Old: Changing cpu_online will cause uhyve to start the next processor
150150 CPU_ONLINE . fetch_add ( 1 , Ordering :: Release ) ;
151151
152- //When running bare-metal/QEMU we use the firmware to start the next hart
153- if !env:: is_uhyve ( ) {
154- let start_addr = ( start:: _start as * const ( ) ) . expose_provenance ( ) ;
155- sbi_rt:: hart_start ( next_hart_id as usize , start_addr, 0 ) . unwrap ( ) ;
152+ #[ cfg( feature = "uhyve" ) ]
153+ if env:: is_uhyve ( ) {
154+ return ;
156155 }
156+
157+ //When running bare-metal/QEMU we use the firmware to start the next hart
158+ let start_addr = ( start:: _start as * const ( ) ) . expose_provenance ( ) ;
159+ sbi_rt:: hart_start ( next_hart_id as usize , start_addr, 0 ) . unwrap ( ) ;
157160}
158161
159162pub fn print_statistics ( ) {
Original file line number Diff line number Diff line change @@ -517,6 +517,7 @@ pub fn poweroff() {
517517}
518518
519519pub fn init ( ) {
520+ #[ cfg( feature = "uhyve" ) ]
520521 if env:: is_uhyve ( ) {
521522 return ;
522523 }
Original file line number Diff line number Diff line change @@ -506,19 +506,24 @@ fn default_apic() -> PhysAddr {
506506 default_local
507507}
508508
509+ fn apic_addr ( ) -> PhysAddr {
510+ #[ cfg( feature = "uhyve" ) ]
511+ if env:: is_uhyve ( ) {
512+ return default_apic ( ) ;
513+ }
514+
515+ detect_from_acpi ( )
516+ . or_else ( |( ) | detect_from_mp ( ) )
517+ . unwrap_or_else ( |( ) | default_apic ( ) )
518+ }
519+
509520pub fn eoi ( ) {
510521 local_apic_write ( IA32_X2APIC_EOI , APIC_EOI_ACK ) ;
511522}
512523
513524pub fn init ( ) {
514525 // Detect CPUs and APICs.
515- let local_apic_physical_address = if env:: is_uhyve ( ) {
516- default_apic ( )
517- } else {
518- detect_from_acpi ( )
519- . or_else ( |( ) | detect_from_mp ( ) )
520- . unwrap_or_else ( |( ) | default_apic ( ) )
521- } ;
526+ let local_apic_physical_address = apic_addr ( ) ;
522527
523528 // Initialize x2APIC or xAPIC, depending on what's available.
524529 if processor:: supports_x2apic ( ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ pub fn application_processor_init() {
110110}
111111
112112fn finish_processor_init ( ) {
113+ #[ cfg( feature = "uhyve" ) ]
113114 if env:: is_uhyve ( ) {
114115 // uhyve does not use apic::detect_from_acpi and therefore does not know the number of processors and
115116 // their APIC IDs in advance.
@@ -129,15 +130,18 @@ pub fn boot_next_processor() {
129130 // to initialize the next processor.
130131 let cpu_online = CPU_ONLINE . fetch_add ( 1 , Ordering :: Release ) ;
131132
132- if !env:: is_uhyve ( ) {
133- if cpu_online == 0 {
134- #[ cfg( all( target_os = "none" , feature = "smp" ) ) ]
135- apic:: boot_application_processors ( ) ;
136- }
133+ #[ cfg( feature = "uhyve" ) ]
134+ if env:: is_uhyve ( ) {
135+ return ;
136+ }
137137
138- if !cfg ! ( feature = "smp" ) {
139- apic:: print_information ( ) ;
140- }
138+ if cpu_online == 0 {
139+ #[ cfg( all( target_os = "none" , feature = "smp" ) ) ]
140+ apic:: boot_application_processors ( ) ;
141+ }
142+
143+ if !cfg ! ( feature = "smp" ) {
144+ apic:: print_information ( ) ;
141145 }
142146}
143147
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ impl VgaScreen {
133133}
134134
135135pub fn init ( ) {
136+ #[ cfg( feature = "uhyve" ) ]
136137 if crate :: env:: is_uhyve ( ) {
137138 return ;
138139 }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use ahash::RandomState;
1010use fdt:: Fdt ;
1111use hashbrown:: HashMap ;
1212use hashbrown:: hash_map:: Iter ;
13- use hermit_entry:: boot_info:: { BootInfo , PlatformInfo , RawBootInfo } ;
13+ use hermit_entry:: boot_info:: { BootInfo , RawBootInfo } ;
1414use hermit_sync:: OnceCell ;
1515use memory_addresses:: PhysAddr ;
1616
@@ -44,7 +44,10 @@ struct Cli {
4444}
4545
4646/// Whether Hermit is running under the "uhyve" hypervisor.
47+ #[ cfg( feature = "uhyve" ) ]
4748pub fn is_uhyve ( ) -> bool {
49+ use hermit_entry:: boot_info:: PlatformInfo ;
50+
4851 matches ! ( boot_info( ) . platform_info, PlatformInfo :: Uhyve { .. } )
4952}
5053
You can’t perform that action at this time.
0 commit comments