mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 00:06:34 +00:00
26 lines
641 B
Rust
26 lines
641 B
Rust
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
use alloc::sync::Arc;
|
|
|
|
use aster_virtio::device::socket::{get_device, register_recv_callback, DEVICE_NAME};
|
|
use common::VsockSpace;
|
|
use spin::Once;
|
|
|
|
pub mod addr;
|
|
pub mod common;
|
|
pub mod stream;
|
|
pub use stream::VsockStreamSocket;
|
|
|
|
// init static driver
|
|
pub static VSOCK_GLOBAL: Once<Arc<VsockSpace>> = Once::new();
|
|
|
|
pub fn init() {
|
|
if get_device(DEVICE_NAME).is_some() {
|
|
VSOCK_GLOBAL.call_once(|| Arc::new(VsockSpace::new()));
|
|
register_recv_callback(DEVICE_NAME, || {
|
|
let vsockspace = VSOCK_GLOBAL.get().unwrap();
|
|
let _ = vsockspace.poll();
|
|
})
|
|
}
|
|
}
|