Skip to main content

fidl_data_zx/
zx_common.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// DO NOT EDIT.
6// Generated from FIDL library `zx` by zither, a Fuchsia platform tool.
7
8use zerocopy::{IntoBytes, TryFromBytes};
9
10pub type Status = i32;
11
12pub type Time = i64;
13
14pub type InstantMono = i64;
15
16pub type InstantBoot = i64;
17
18pub type Ticks = i64;
19
20pub type InstantMonoTicks = i64;
21
22pub type InstantBootTicks = i64;
23
24pub type Duration = i64;
25
26pub type DurationMono = i64;
27
28pub type DurationBoot = i64;
29
30pub type Koid = u64;
31
32pub type Off = u64;
33
34pub type Signals = u32;
35
36pub const CHANNEL_MAX_MSG_BYTES: u64 = 65536;
37
38pub const CHANNEL_MAX_MSG_HANDLES: u64 = 64;
39
40pub const IOB_MAX_REGIONS: u64 = 64;
41
42pub const MAX_NAME_LEN: u64 = 32;
43
44pub const MAX_CPUS: u64 = 512;
45
46#[repr(u32)]
47#[derive(Clone, Copy, Debug, Eq, Hash, IntoBytes, PartialEq, TryFromBytes)]
48pub enum ObjType {
49    None = 0,
50    Process = 1,
51    Thread = 2,
52    Vmo = 3,
53    Channel = 4,
54    Event = 5,
55    Port = 6,
56    Interrupt = 9,
57    PciDevice = 11,
58    Log = 12,
59    Socket = 14,
60    Resource = 15,
61    Eventpair = 16,
62    Job = 17,
63    Vmar = 18,
64    Fifo = 19,
65    Guest = 20,
66    Vcpu = 21,
67    Timer = 22,
68    Iommu = 23,
69    Bti = 24,
70    Profile = 25,
71    Pmt = 26,
72    SuspendToken = 27,
73    Pager = 28,
74    Exception = 29,
75    Clock = 30,
76    Stream = 31,
77    Msi = 32,
78    Iob = 33,
79    Counter = 34,
80}
81
82impl ObjType {
83    pub fn from_raw(raw: u32) -> Option<Self> {
84        match raw {
85            0 => Some(Self::None),
86
87            1 => Some(Self::Process),
88
89            2 => Some(Self::Thread),
90
91            3 => Some(Self::Vmo),
92
93            4 => Some(Self::Channel),
94
95            5 => Some(Self::Event),
96
97            6 => Some(Self::Port),
98
99            9 => Some(Self::Interrupt),
100
101            11 => Some(Self::PciDevice),
102
103            12 => Some(Self::Log),
104
105            14 => Some(Self::Socket),
106
107            15 => Some(Self::Resource),
108
109            16 => Some(Self::Eventpair),
110
111            17 => Some(Self::Job),
112
113            18 => Some(Self::Vmar),
114
115            19 => Some(Self::Fifo),
116
117            20 => Some(Self::Guest),
118
119            21 => Some(Self::Vcpu),
120
121            22 => Some(Self::Timer),
122
123            23 => Some(Self::Iommu),
124
125            24 => Some(Self::Bti),
126
127            25 => Some(Self::Profile),
128
129            26 => Some(Self::Pmt),
130
131            27 => Some(Self::SuspendToken),
132
133            28 => Some(Self::Pager),
134
135            29 => Some(Self::Exception),
136
137            30 => Some(Self::Clock),
138
139            31 => Some(Self::Stream),
140
141            32 => Some(Self::Msi),
142
143            33 => Some(Self::Iob),
144
145            34 => Some(Self::Counter),
146
147            _ => None,
148        }
149    }
150}
151
152impl From<ObjType> for u32 {
153    fn from(val: ObjType) -> Self {
154        val as Self
155    }
156}
157
158pub type Handle = u32;