File tree 1 file changed +6
-4
lines changed
src/drivers/virtio/transport 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -525,22 +525,24 @@ impl ComCfg {
525
525
526
526
/// Returns the features offered by the device. Coded in a 64bit value.
527
527
pub fn dev_features ( & mut self ) -> u64 {
528
+ let device_feature_select = ptr:: from_mut ( & mut self . com_cfg . device_feature_select ) ;
529
+ let device_feature = ptr:: from_mut ( & mut self . com_cfg . device_feature ) ;
528
530
// Indicate device to show high 32 bits in device_feature field.
529
531
// See Virtio specification v1.1. - 4.1.4.3
530
532
memory_barrier ( ) ;
531
- self . com_cfg . device_feature_select = 1 ;
533
+ unsafe { device_feature_select . write_volatile ( 1 ) } ;
532
534
memory_barrier ( ) ;
533
535
534
536
// read high 32 bits of device features
535
- let mut dev_feat = u64:: from ( self . com_cfg . device_feature ) << 32 ;
537
+ let mut dev_feat = u64:: from ( unsafe { device_feature. read_volatile ( ) } ) << 32 ;
536
538
537
539
// Indicate device to show low 32 bits in device_feature field.
538
540
// See Virtio specification v1.1. - 4.1.4.3
539
- self . com_cfg . device_feature_select = 0 ;
541
+ unsafe { device_feature_select . write_volatile ( 0 ) } ;
540
542
memory_barrier ( ) ;
541
543
542
544
// read low 32 bits of device features
543
- dev_feat |= u64:: from ( self . com_cfg . device_feature ) ;
545
+ dev_feat |= u64:: from ( unsafe { device_feature. read_volatile ( ) } ) ;
544
546
545
547
dev_feat
546
548
}
You can’t perform that action at this time.
0 commit comments