xref: /aosp_15_r20/external/crosvm/rutabaga_gfx/src/rutabaga_os/defines.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2024 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use std::time::Duration;
6 
7 use crate::rutabaga_utils::RutabagaMapping;
8 
9 pub enum TubeType {
10     Stream,
11     Packet,
12 }
13 
14 pub enum WaitTimeout {
15     Finite(Duration),
16     NoTimeout,
17 }
18 
19 pub struct WaitEvent {
20     pub connection_id: u64,
21     pub hung_up: bool,
22     pub readable: bool,
23 }
24 
25 #[allow(dead_code)]
26 pub const WAIT_CONTEXT_MAX: usize = 16;
27 
28 pub enum DescriptorType {
29     Unknown,
30     Memory(u32),
31     WritePipe,
32 }
33 
34 /// # Safety
35 ///
36 /// Caller must ensure that MappedRegion's lifetime contains the lifetime of
37 /// pointer returned.
38 pub unsafe trait MappedRegion: Send + Sync {
39     /// Returns a pointer to the beginning of the memory region. Should only be
40     /// used for passing this region to ioctls for setting guest memory.
as_ptr(&self) -> *mut u841     fn as_ptr(&self) -> *mut u8;
42 
43     /// Returns the size of the memory region in bytes.
size(&self) -> usize44     fn size(&self) -> usize;
45 
46     /// Returns rutabaga mapping representation of the region
as_rutabaga_mapping(&self) -> RutabagaMapping47     fn as_rutabaga_mapping(&self) -> RutabagaMapping;
48 }
49