]> git.lizzy.rs Git - rust.git/blob - src/libstd/os/fortanix_sgx/mod.rs
810965fc1b85af02892ba3126eb8db80ccaed161
[rust.git] / src / libstd / os / fortanix_sgx / mod.rs
1 //! Functionality specific to the `x86_64-fortanix-unknown-sgx` target.
2 //!
3 //! This includes functions to deal with memory isolation, usercalls, and the
4 //! SGX instruction set.
5
6 #![deny(missing_docs, missing_debug_implementations)]
7 #![unstable(feature = "sgx_platform", issue = "56975")]
8
9 /// Low-level interfaces to usercalls. See the [ABI documentation] for more
10 /// information.
11 ///
12 /// [ABI documentation]: https://docs.rs/fortanix-sgx-abi/
13 pub mod usercalls {
14     pub use sys::abi::usercalls::*;
15
16     /// Primitives for allocating memory in userspace as well as copying data
17     /// to and from user memory.
18     pub mod alloc {
19         pub use sys::abi::usercalls::alloc;
20     }
21
22     /// Lowest-level interfaces to usercalls and usercall ABI type definitions.
23     pub mod raw {
24         use sys::abi::usercalls::raw::invoke_with_usercalls;
25         pub use sys::abi::usercalls::raw::do_usercall;
26         pub use sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, close,
27                                            connect_stream, exit, flush, free, insecure_time,
28                                            launch_thread, read, read_alloc, send, wait, write};
29
30         macro_rules! define_usercallnrs {
31             ($(fn $f:ident($($n:ident: $t:ty),*) $(-> $r:ty)*; )*) => {
32                 /// Usercall numbers as per the ABI.
33                 #[repr(C)]
34                 #[unstable(feature = "sgx_platform", issue = "56975")]
35                 #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
36                 #[allow(missing_docs)]
37                 pub enum UsercallNrs {
38                     $($f,)*
39                 }
40             };
41         }
42         invoke_with_usercalls!(define_usercallnrs);
43
44         // fortanix-sgx-abi re-exports
45         pub use sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall};
46         pub use sys::abi::usercalls::raw::Error;
47         pub use sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL,
48                                            FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS,
49                                            USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO};
50         pub use sys::abi::usercalls::raw::{Fd, Result, Tcs};
51     }
52 }
53
54 /// Functions for querying mapping information for pointers.
55 pub mod mem {
56     pub use sys::abi::mem::*;
57 }
58
59 pub use sys::ext::{io, arch, ffi};