|
| 1 | +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +//! Functionality specific to the `x86_64-fortanix-unknown-sgx` target. |
| 12 | +//! |
| 13 | +//! This includes functions to deal with memory isolation, usercalls, and the |
| 14 | +//! SGX instruction set. |
| 15 | +
|
| 16 | +#![deny(missing_docs, missing_debug_implementations)] |
| 17 | +#![unstable(feature = "sgx_platform", issue = "56975")] |
| 18 | + |
| 19 | +/// Low-level interfaces to usercalls. See the [ABI documentation] for more |
| 20 | +/// information. |
| 21 | +/// |
| 22 | +/// [ABI documentation]: https://docs.rs/fortanix-sgx-abi/ |
| 23 | +pub mod usercalls { |
| 24 | + pub use sys::abi::usercalls::*; |
| 25 | + |
| 26 | + /// Primitives for allocating memory in userspace as well as copying data |
| 27 | + /// to and from user memory. |
| 28 | + pub mod alloc { |
| 29 | + pub use sys::abi::usercalls::alloc; |
| 30 | + } |
| 31 | + |
| 32 | + /// Lowest-level interfaces to usercalls and usercall ABI type definitions. |
| 33 | + pub mod raw { |
| 34 | + use sys::abi::usercalls::raw::invoke_with_usercalls; |
| 35 | + pub use sys::abi::usercalls::raw::do_usercall; |
| 36 | + pub use sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, close, |
| 37 | + connect_stream, exit, flush, free, insecure_time, |
| 38 | + launch_thread, read, read_alloc, send, wait, write}; |
| 39 | + |
| 40 | + macro_rules! define_usercallnrs { |
| 41 | + ($(fn $f:ident($($n:ident: $t:ty),*) $(-> $r:ty)*; )*) => { |
| 42 | + /// Usercall numbers as per the ABI. |
| 43 | + #[repr(C)] |
| 44 | + #[unstable(feature = "sgx_platform", issue = "56975")] |
| 45 | + #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] |
| 46 | + #[allow(missing_docs)] |
| 47 | + pub enum UsercallNrs { |
| 48 | + $($f,)* |
| 49 | + } |
| 50 | + }; |
| 51 | + } |
| 52 | + invoke_with_usercalls!(define_usercallnrs); |
| 53 | + |
| 54 | + // fortanix-sgx-abi re-exports |
| 55 | + pub use sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall}; |
| 56 | + pub use sys::abi::usercalls::raw::Error; |
| 57 | + pub use sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL, |
| 58 | + FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS, |
| 59 | + USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO}; |
| 60 | + pub use sys::abi::usercalls::raw::{Fd, Result, Tcs}; |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +/// Functions for querying mapping information for pointers. |
| 65 | +pub mod mem { |
| 66 | + pub use sys::abi::mem::*; |
| 67 | +} |
0 commit comments