pub fn new(header: &'static mut VirtIOHeader, event_buf: &'a mut [u64]) -> Result<Self> {
        if event_buf.len() < QUEUE_SIZE {
            return Err(Error::BufferTooSmall);
        }
        let event_buf: &mut [Event] = unsafe { core::mem::transmute(event_buf) };
        header.begin_init(|features| {
            let features = Feature::from_bits_truncate(features);
            info!("Device features: {:?}", features);
            // negotiate these flags only
            let supported_features = Feature::empty();
            (features & supported_features).bits()
        });

        // read configuration space
        let config = unsafe { &mut *(header.config_space() as *mut Config) };
        info!("Config: {:?}", config);

        let mut event_queue = VirtQueue::new(header, QUEUE_EVENT, QUEUE_SIZE as u16)?;
        let status_queue = VirtQueue::new(header, QUEUE_STATUS, QUEUE_SIZE as u16)?;
        for (i, event) in event_buf.iter_mut().enumerate() {
            let token = event_queue.add(&[], &[event.as_buf_mut()])?;
            assert_eq!(token, i as u16);
        }

        header.finish_init();

        Ok(VirtIOInput {
            header,
            event_queue,
            status_queue,
            event_buf,
            x: 0,
            y: 0,
        })
    }
/// Create a new VirtIO-Input driver.
Create a new VirtIO-Input driver.
Create a new VirtIO - Input driver .
pub fn new(header: &'static mut VirtIOHeader, event_buf: &'a mut [u64]) -> Result<Self> {
        if event_buf.len() < QUEUE_SIZE {
            return Err(Error::BufferTooSmall);
        }
        let event_buf: &mut [Event] = unsafe { core::mem::transmute(event_buf) };
        header.begin_init(|features| {
            let features = Feature::from_bits_truncate(features);
            info!("Device features: {:?}", features);
            // negotiate these flags only
            let supported_features = Feature::empty();
            (features & supported_features).bits()
        });
        // read configuration space
        let config = unsafe { &mut *(header.config_space() as *mut Config) };
        info!("Config: {:?}", config);
        let mut event_queue = VirtQueue::new(header, QUEUE_EVENT, QUEUE_SIZE as u16)?;
        let status_queue = VirtQueue::new(header, QUEUE_STATUS, QUEUE_SIZE as u16)?;
        for (i, event) in event_buf.iter_mut().enumerate() {
            let token = event_queue.add(&[], &[event.as_buf_mut()])?;
            assert_eq!(token, i as u16);
        }
        header.finish_init();
        Ok(VirtIOInput {
            header,
            event_queue,
            status_queue,
            event_buf,
            x: 0,
            y: 0,
        })
    }
pub fn new ( header : & ' static mut VirtIOHeader , event_buf : & ' a mut [ u64 ] ) -> Result < Self > { if event_buf . len ( ) < QUEUE_SIZE { return Err ( Error :: BufferTooSmall ) ; } let event_buf : & mut [ Event ] = unsafe { core :: mem :: transmute ( event_buf ) } ; header . begin_init ( | features | { let features = Feature :: from_bits_truncate ( features ) ; info ! ( " " features ) ; // negotiate these flags only let supported_features = Feature :: empty ( ) ; ( features & supported_features ) . bits ( ) } ) ; // read configuration space let config = unsafe { & mut * ( header . config_space ( ) as * mut Config ) } ; info ! ( " " config ) ; let mut event_queue = VirtQueue :: new ( header , QUEUE_EVENT , QUEUE_SIZE as u16 ) ? ; let status_queue = VirtQueue :: new ( header , QUEUE_STATUS , QUEUE_SIZE as u16 ) ? ; for ( i , event ) in event_buf . iter_mut ( ) . enumerate ( ) { let token = event_queue . add ( & [ ] , & [ event . as_buf_mut ( ) ] ) ? ; assert_eq ! ( token i as u16 ) ; } header . finish_init ( ) ; Ok ( VirtIOInput { header , event_queue , status_queue , event_buf , x : 0 , y : 0 , } ) }
Create a new VirtIO-Input driver.
Create a new VirtIO - Input driver .
header
&'static mut VirtIOHeader
event_buf
&'a mut [u64]
header
&'static mut VirtIOHeader
event_buf
&'a mut [u64]