forked from rcore-os/zCore
Merge pull request #141 from iLFTH/master
Preliminary code comments have been added for Zircon-syscalls
This commit is contained in:
commit
a0cc7ddaec
|
@ -9,8 +9,8 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Read a message from a channel.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// Read/Receive a message from a channel.
|
||||
pub fn sys_channel_read(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -74,7 +74,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Write a message to a channel.
|
||||
pub fn sys_channel_write(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -114,7 +114,7 @@ impl Syscall<'_> {
|
|||
channel.write(MessagePacket { data, handles })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a new channel.
|
||||
pub fn sys_channel_create(
|
||||
&self,
|
||||
options: u32,
|
||||
|
@ -134,6 +134,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
pub async fn sys_channel_call_noretry(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -210,7 +211,7 @@ impl Syscall<'_> {
|
|||
Err(ZxError::BAD_STATE)
|
||||
}
|
||||
}
|
||||
|
||||
/// Write a message to a channel.
|
||||
pub fn sys_channel_write_etc(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
use super::*;
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Draw random bytes from the kernel CPRNG.
|
||||
///
|
||||
/// This data should be suitable for cryptographic applications.
|
||||
///
|
||||
/// Clients that require a large volume of randomness should consider using these bytes to seed a user-space random number generator for better performance.
|
||||
pub fn sys_cprng_draw_once(&self, mut buf: UserOutPtr<u8>, len: usize) -> ZxResult {
|
||||
info!("cprng_draw_once: buf=({:?}; {:?})", buf, len);
|
||||
let mut res = vec![0u8; len];
|
||||
// Fill random bytes to the buffer
|
||||
kernel_hal::fill_random(&mut res);
|
||||
buf.write_array(&res)?;
|
||||
Ok(())
|
||||
|
|
|
@ -6,6 +6,7 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a new object in the kernel representing an IOMMU device.
|
||||
pub fn sys_iommu_create(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
|
@ -37,7 +38,11 @@ impl Syscall<'_> {
|
|||
out.write(handle)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates a new bus transaction initiator.
|
||||
///
|
||||
/// `iommu: HandleValue`, a handle to an IOMMU.
|
||||
/// `options: u32`, must be 0 (reserved for future definition of creation flags).
|
||||
/// `bti_id: u64`, a hardware transaction identifier for a device downstream of that IOMMU.
|
||||
pub fn sys_bti_create(
|
||||
&self,
|
||||
iommu: HandleValue,
|
||||
|
@ -64,6 +69,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// Pin pages and grant devices access to them.
|
||||
pub fn sys_bti_pin(
|
||||
&self,
|
||||
bti: HandleValue,
|
||||
|
@ -107,6 +113,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Unpins pages that were previously pinned by `zx_bti_pin()`.
|
||||
pub fn sys_pmt_unpin(&self, pmt: HandleValue) -> ZxResult {
|
||||
info!("pmt.unpin: pmt={:#x}", pmt);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -115,6 +122,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Releases all quarantined PMTs for the given BTI.
|
||||
pub fn sys_bti_release_quarantine(&self, bti: HandleValue) -> ZxResult {
|
||||
info!("bti.release_quarantine: bti = {:#x}", bti);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -123,6 +131,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
pub fn sys_pc_firmware_tables(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
|
@ -139,6 +148,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates an interrupt object which represents a physical or virtual interrupt.
|
||||
pub fn sys_interrupt_create(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
|
@ -167,6 +177,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Binds or unbinds an interrupt object to a port.
|
||||
///
|
||||
/// The key used when binding the interrupt will be present in the key field of the `zx_port_packet_t`.
|
||||
pub fn sys_interrupt_bind(
|
||||
&self,
|
||||
interrupt: HandleValue,
|
||||
|
@ -193,6 +206,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Triggers a virtual interrupt object.
|
||||
pub fn sys_interrupt_trigger(
|
||||
&self,
|
||||
interrupt: HandleValue,
|
||||
|
@ -210,6 +224,9 @@ impl Syscall<'_> {
|
|||
interrupt.trigger(timestamp)
|
||||
}
|
||||
|
||||
/// Acknowledge an interrupt and re-arm it.
|
||||
///
|
||||
/// This system call acknowledges an interrupt object, causing it to be eligible to trigger again (and delivering a packet to the port it is bound to).
|
||||
pub fn sys_interrupt_ack(&self, interrupt: HandleValue) -> ZxResult {
|
||||
info!("interupt.ack: interrupt={:?}", interrupt);
|
||||
let interrupt = self
|
||||
|
@ -219,12 +236,14 @@ impl Syscall<'_> {
|
|||
interrupt.ack()
|
||||
}
|
||||
|
||||
/// Destroys an interrupt object.
|
||||
pub fn sys_interrupt_destroy(&self, interrupt: HandleValue) -> ZxResult {
|
||||
info!("interupt.destory: interrupt={:?}", interrupt);
|
||||
let interrupt = self.thread.proc().get_object::<Interrupt>(interrupt)?;
|
||||
interrupt.destroy()
|
||||
}
|
||||
|
||||
/// A blocking syscall which causes the caller to wait until an interrupt is triggered.
|
||||
pub async fn sys_interrupt_wait(
|
||||
&self,
|
||||
interrupt: HandleValue,
|
||||
|
|
|
@ -2,6 +2,7 @@ use super::*;
|
|||
use zircon_object::dev::*;
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Write debug info to the serial port.
|
||||
pub fn sys_debug_write(&self, buf: UserInPtr<u8>, len: usize) -> ZxResult {
|
||||
info!("debug.write: buf=({:?}; {:#x})", buf, len);
|
||||
let data = buf.read_array(len)?;
|
||||
|
@ -9,6 +10,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read debug info from the serial port.
|
||||
pub async fn sys_debug_read(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
|
|
@ -4,6 +4,7 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a kernel managed debuglog reader or writer.
|
||||
pub fn sys_debuglog_create(
|
||||
&self,
|
||||
rsrc: HandleValue,
|
||||
|
@ -31,6 +32,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write log entry to debuglog.
|
||||
pub fn sys_debuglog_write(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -60,6 +62,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
/// Read log entries from debuglog.
|
||||
pub fn sys_debuglog_read(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use {super::*, numeric_enum_macro::numeric_enum, zircon_object::task::*};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Creates a channel which will receive exceptions from the thread, process, or job.
|
||||
pub fn sys_create_exception_channel(
|
||||
&self,
|
||||
task: HandleValue,
|
||||
|
@ -54,6 +55,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a handle for the exception's thread.
|
||||
///
|
||||
/// The exception handle out will be filled with a new handle to the exception thread.
|
||||
pub fn sys_exception_get_thread(
|
||||
&self,
|
||||
exception: HandleValue,
|
||||
|
@ -69,6 +73,11 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a handle for the exception's process.
|
||||
///
|
||||
/// The exception handle out will be filled with a new handle to the exception process.
|
||||
/// > Only available for job and process exception channels.
|
||||
/// > Thread exceptions cannot access their parent process handles.
|
||||
pub fn sys_exception_get_process(
|
||||
&self,
|
||||
exception: HandleValue,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use {super::*, zircon_object::ipc::Fifo};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Creates a fifo, which is actually a pair of fifos of `elem_count` entries of `elem_size` bytes.
|
||||
pub fn sys_fifo_create(
|
||||
&self,
|
||||
elem_count: usize,
|
||||
|
@ -28,6 +29,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write data to a fifo.
|
||||
pub fn sys_fifo_write(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -51,6 +53,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read data from a fifo.
|
||||
pub fn sys_fifo_read(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use {super::*, zircon_object::task::ThreadState};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Wait on a futex.
|
||||
///
|
||||
/// This system call function atomically verifies that `value_ptr` still contains the value `current_value`
|
||||
/// and sleeps until the futex is made available by a call to `zx_futex_wake`
|
||||
pub async fn sys_futex_wait(
|
||||
&self,
|
||||
value_ptr: UserInPtr<AtomicI32>,
|
||||
|
@ -29,7 +33,9 @@ impl Syscall<'_> {
|
|||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Wake some waiters and requeue other waiters.
|
||||
///
|
||||
/// Wake some number of threads waiting on a futex, and move more waiters to another wait queue.
|
||||
pub fn sys_futex_requeue(
|
||||
&self,
|
||||
value_ptr: UserInPtr<AtomicI32>,
|
||||
|
@ -69,6 +75,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Wake some number of threads waiting on a futex.
|
||||
///
|
||||
/// > Waking up zero threads is not an error condition. Passing in an unallocated address for value_ptr is not an error condition.
|
||||
pub fn sys_futex_wake(&self, value_ptr: UserInPtr<AtomicI32>, count: u32) -> ZxResult {
|
||||
info!("futex.wake: value_ptr={:?}, count={:#x}", value_ptr, count);
|
||||
if value_ptr.is_null() || value_ptr.as_ptr() as usize % 4 != 0 {
|
||||
|
@ -81,6 +90,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Wake some number of threads waiting on a futex, and move more waiters to another wait queue.
|
||||
pub fn sys_futex_wake_single_owner(&self, value_ptr: UserInPtr<AtomicI32>) -> ZxResult {
|
||||
info!("futex.wake_single_owner: value_ptr={:?}", value_ptr);
|
||||
if value_ptr.is_null() || value_ptr.as_ptr() as usize % 4 != 0 {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use {super::*, core::convert::TryFrom};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Creates a duplicate of handle.
|
||||
///
|
||||
/// Referring to the same underlying object, with new access rights rights.
|
||||
pub fn sys_handle_duplicate(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -30,6 +33,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Close a handle and reclaim the underlying object if no other handles to it exist.
|
||||
pub fn sys_handle_close(&self, handle: HandleValue) -> ZxResult {
|
||||
info!("handle.close: handle={:?}", handle);
|
||||
if handle == INVALID_HANDLE {
|
||||
|
@ -40,6 +44,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Close a number of handles.
|
||||
pub fn sys_handle_close_many(
|
||||
&self,
|
||||
handles: UserInPtr<HandleValue>,
|
||||
|
@ -60,6 +65,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates a replacement for handle.
|
||||
///
|
||||
/// Referring to the same underlying object, with new access rights rights.
|
||||
pub fn sys_handle_replace(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -10,6 +10,9 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Creates a guest virtual machine.
|
||||
///
|
||||
/// The guest is a virtual machine that can be run within the hypervisor, with `vmar_handle` used to represent the physical address space of the guest.
|
||||
pub fn sys_guest_create(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
|
@ -49,6 +52,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Set a trap within a guest.
|
||||
pub fn sys_guest_set_trap(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -75,6 +79,9 @@ impl Syscall<'_> {
|
|||
guest.set_trap(kind, addr as usize, size as usize, port, key)
|
||||
}
|
||||
|
||||
/// Create a VCPU within a guest.
|
||||
///
|
||||
/// The VCPU allows for execution within the virtual machine.
|
||||
pub fn sys_vcpu_create(
|
||||
&self,
|
||||
guest_handle: HandleValue,
|
||||
|
@ -97,6 +104,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Resume execution of a VCPU.
|
||||
pub fn sys_vcpu_resume(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -113,6 +121,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Raise an interrupt on a VCPU and may be called from any thread.
|
||||
pub fn sys_vcpu_interrupt(&self, handle: HandleValue, vector: u32) -> ZxResult {
|
||||
info!(
|
||||
"hypervisor.vcpu_interrupt: handle={:#x?}, vector={:?}",
|
||||
|
@ -124,6 +133,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read the state of a VCPU.
|
||||
pub fn sys_vcpu_read_state(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -148,6 +158,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write the state of a VCPU.
|
||||
///
|
||||
/// > It is only valid to write the state of handle when execution has been paused.
|
||||
pub fn sys_vcpu_write_state(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
|
|
@ -7,6 +7,11 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Ask for various properties of various kernel objects.
|
||||
///
|
||||
/// `handle_value: HandleValue`, indicates the target kernel object.
|
||||
/// `property: u32`, indicates which property to get/set.
|
||||
/// `buffer: usize`, holds the property value, and must be a pointer to a buffer of value_size bytes.
|
||||
pub fn sys_object_get_property(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -104,6 +109,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set various properties of various kernel objects.
|
||||
pub fn sys_object_set_property(
|
||||
&mut self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -182,6 +188,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A blocking syscall waits for signals on an object.
|
||||
pub async fn sys_object_wait_one(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -217,6 +224,10 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Query information about an object.
|
||||
///
|
||||
/// `topic: u32`, indicates what specific information is desired.
|
||||
/// `buffer: usize`, a pointer to a buffer of size buffer_size to return the information.
|
||||
pub fn sys_object_get_info(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -353,6 +364,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Asserts and deasserts the userspace-accessible signal bits on the object's peer.
|
||||
pub fn sys_object_signal_peer(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -372,6 +384,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// A non-blocking syscall subscribes for signals on an object.
|
||||
pub fn sys_object_wait_async(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -396,6 +409,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Signal an object.
|
||||
///
|
||||
/// Asserts and deasserts the userspace-accessible signal bits on an object.
|
||||
pub fn sys_object_signal(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -416,6 +432,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Wait for signals on multiple objects.
|
||||
pub async fn sys_object_wait_many(
|
||||
&self,
|
||||
mut user_items: UserInOutPtr<UserWaitItem>,
|
||||
|
@ -445,6 +462,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Find the child of an object by its kid.
|
||||
///
|
||||
/// Given a kernel object with children objects, obtain a handle to the child specified by the provided kernel object id.
|
||||
pub fn sys_object_get_child(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
|
|
@ -4,6 +4,7 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create an IO port.
|
||||
pub fn sys_port_create(&self, options: u32, mut out: UserOutPtr<HandleValue>) -> ZxResult {
|
||||
info!("port.create: options={:#x}", options);
|
||||
let port_handle = Handle::new(Port::new(options)?, Rights::DEFAULT_PORT);
|
||||
|
@ -12,6 +13,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Wait for a packet arrival in a port.
|
||||
pub async fn sys_port_wait(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -35,6 +37,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Queue a packet to a port.
|
||||
pub fn sys_port_queue(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -2,6 +2,7 @@ use {super::*, core::convert::TryFrom, zircon_object::dev::*};
|
|||
|
||||
impl Syscall<'_> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// Create a resource object for use with other DDK syscalls.
|
||||
pub fn sys_resource_create(
|
||||
&self,
|
||||
parent_rsrc: HandleValue,
|
||||
|
|
|
@ -5,6 +5,9 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a timer.
|
||||
///
|
||||
/// The timer is an object that can signal when a specified point in time has been reached.
|
||||
pub fn sys_timer_create(
|
||||
&self,
|
||||
options: u32,
|
||||
|
@ -31,6 +34,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create an event.
|
||||
pub fn sys_event_create(&self, options: u32, mut out: UserOutPtr<HandleValue>) -> ZxResult {
|
||||
info!("event.create: options={:#x}", options);
|
||||
if options != 0 {
|
||||
|
@ -43,6 +47,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create an event pair.
|
||||
pub fn sys_eventpair_create(
|
||||
&self,
|
||||
options: u32,
|
||||
|
@ -63,6 +68,10 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Start a timer.
|
||||
///
|
||||
/// To fire the timer immediately pass a deadline less than or equal to 0.
|
||||
/// The slack parameter specifies a range from deadline - slack to deadline + slack during which the timer is allowed to fire.
|
||||
pub fn sys_timer_set(&self, handle: HandleValue, deadline: Deadline, slack: i64) -> ZxResult {
|
||||
info!(
|
||||
"timer.set: handle={:#x}, deadline={:#x?}, slack={:#x}",
|
||||
|
@ -77,6 +86,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Cancel a timer.
|
||||
pub fn sys_timer_cancel(&self, handle: HandleValue) -> ZxResult {
|
||||
info!("timer.cancel: handle={:#x}", handle);
|
||||
let proc = self.thread.proc();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use {super::*, zircon_object::ipc::Socket, zircon_object::ipc::SocketFlags};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a socket.
|
||||
///
|
||||
/// Socket is a connected pair of bidirectional stream transports, that can move only data, and that have a maximum capacity.
|
||||
pub fn sys_socket_create(
|
||||
&self,
|
||||
options: u32,
|
||||
|
@ -17,6 +20,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write data to a socket.
|
||||
///
|
||||
/// Attempts to write `count: usize` bytes to the socket specified by `handle_value`.
|
||||
pub fn sys_socket_write(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -43,6 +49,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read data from a socket.
|
||||
pub fn sys_socket_read(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -72,6 +79,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Prevent future reading or writing on a socket.
|
||||
pub fn sys_socket_shutdown(&self, socket: HandleValue, options: u32) -> ZxResult {
|
||||
let options = SocketFlags::from_bits_truncate(options);
|
||||
info!(
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use {super::*, bitflags::bitflags, zircon_object::vm::*};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a stream from a VMO.
|
||||
///
|
||||
/// Stream for reads and writes the data in an underlying VMO.
|
||||
pub fn sys_stream_create(
|
||||
&self,
|
||||
options: u32,
|
||||
|
@ -38,6 +41,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write data to a stream at the current seek offset.
|
||||
pub fn sys_stream_writev(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -68,6 +72,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write data to a stream at the given offset.
|
||||
pub fn sys_stream_writev_at(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -96,6 +101,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read data from a stream at the current seek offset.
|
||||
pub fn sys_stream_readv(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -122,6 +128,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read data from a stream at the given offset.
|
||||
pub fn sys_stream_readv_at(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -150,6 +157,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Modify the seek offset.
|
||||
///
|
||||
/// Sets the seek offset of the stream to `offset` relative to `whence`.
|
||||
pub fn sys_stream_seek(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -5,6 +5,16 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Retrieve a handle to a system event.
|
||||
///
|
||||
/// `root_job: HandleValue`, must be a handle to the root job of the system.
|
||||
/// `kind: u32`, must be one of the following:
|
||||
/// ```rust
|
||||
/// const EVENT_OUT_OF_MEMORY: u32 = 1;
|
||||
/// const EVENT_MEMORY_PRESSURE_CRITICAL: u32 = 2;
|
||||
/// const EVENT_MEMORY_PRESSURE_WARNING: u32 = 3;
|
||||
/// const EVENT_MEMORY_PRESSURE_NORMAL: u32 = 4;
|
||||
/// ```
|
||||
pub fn sys_system_get_event(
|
||||
&self,
|
||||
root_job: HandleValue,
|
||||
|
|
|
@ -2,6 +2,9 @@ use core::convert::TryFrom;
|
|||
use {super::*, zircon_object::task::*};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a new process.
|
||||
///
|
||||
/// Upon success, handles for the new process and the root of its address space are returned.
|
||||
pub fn sys_process_create(
|
||||
&self,
|
||||
job: HandleValue,
|
||||
|
@ -32,6 +35,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Exits the currently running process.
|
||||
pub fn sys_process_exit(&mut self, code: i64) -> ZxResult {
|
||||
info!("proc.exit: code={:?}", code);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -40,6 +44,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates a thread within the specified process.
|
||||
///
|
||||
/// Upon success a handle for the new thread is returned.
|
||||
pub fn sys_thread_create(
|
||||
&self,
|
||||
proc_handle: HandleValue,
|
||||
|
@ -62,6 +69,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Start execution on a process.
|
||||
///
|
||||
/// This system call is similar to `zx_thread_start()`, but is used for the purpose of starting the first thread in a process.
|
||||
pub fn sys_process_start(
|
||||
&self,
|
||||
proc_handle: HandleValue,
|
||||
|
@ -93,6 +103,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write one aspect of thread state.
|
||||
///
|
||||
/// The thread state may only be written when the thread is halted for an exception or the thread is suspended.
|
||||
pub fn sys_thread_write_state(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -112,6 +125,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets process as critical to job.
|
||||
///
|
||||
/// When process terminates, job will be terminated as if `zx_task_kill()` was called on it.
|
||||
pub fn sys_job_set_critical(
|
||||
&self,
|
||||
job_handle: HandleValue,
|
||||
|
@ -136,6 +152,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Start execution on a thread.
|
||||
pub fn sys_thread_start(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -157,6 +174,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Terminate the current running thread.
|
||||
///
|
||||
/// Causes the currently running thread to cease running and exit.
|
||||
pub fn sys_thread_exit(&mut self) -> ZxResult {
|
||||
info!("thread.exit:");
|
||||
self.thread.exit();
|
||||
|
@ -164,6 +184,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Suspend the given task.
|
||||
///
|
||||
/// > This function replaces task_suspend. When all callers are updated, `zx_task_suspend()` will be deleted and this function will be renamed ```zx_task_suspend()```.
|
||||
pub fn sys_task_suspend_token(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -190,6 +213,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Kill the provided task (job, process, or thread).
|
||||
pub fn sys_task_kill(&mut self, handle: HandleValue) -> ZxResult {
|
||||
info!("task.kill: handle={:?}", handle);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -220,6 +244,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a new child job object given a parent job.
|
||||
pub fn sys_job_create(
|
||||
&self,
|
||||
parent: HandleValue,
|
||||
|
@ -243,6 +268,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets one or more security and/or resource policies to an empty job.
|
||||
pub fn sys_job_set_policy(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -283,6 +309,9 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Read from the given process's address space.
|
||||
///
|
||||
/// > This function will eventually be replaced with something vmo-centric.
|
||||
pub fn sys_process_read_memory(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -304,6 +333,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write into the given process's address space.
|
||||
pub fn sys_process_write_memory(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
|
|
@ -16,6 +16,7 @@ const ZX_CLOCK_UTC: u32 = 1;
|
|||
const ZX_CLOCK_THREAD: u32 = 2;
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a new clock object.
|
||||
pub fn sys_clock_create(
|
||||
&self,
|
||||
_options: u64,
|
||||
|
@ -26,6 +27,10 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Acquire the current time.
|
||||
///
|
||||
/// + Returns the current time of clock_id via `time`.
|
||||
/// + Returns whether `clock_id` was valid.
|
||||
pub fn sys_clock_get(&self, clock_id: u32, mut time: UserOutPtr<u64>) -> ZxResult {
|
||||
info!("clock.get: id={}", clock_id);
|
||||
match clock_id {
|
||||
|
@ -45,6 +50,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Perform a basic read of the clock.
|
||||
pub fn sys_clock_read(&self, handle: HandleValue, mut now: UserOutPtr<u64>) -> ZxResult {
|
||||
info!("clock.read: handle={:#x?}", handle);
|
||||
warn!("ignore clock handle");
|
||||
|
@ -52,6 +58,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
pub fn sys_clock_adjust(&self, resource: HandleValue, clock_id: u32, offset: u64) -> ZxResult {
|
||||
info!(
|
||||
"clock.adjust: resource={:#x?}, id={:#x}, offset={:#x}",
|
||||
|
@ -70,6 +77,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Make adjustments to a clock object.
|
||||
pub fn sys_clock_update(
|
||||
&self,
|
||||
_handle: HandleValue,
|
||||
|
@ -80,6 +88,9 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Sleep for some number of nanoseconds.
|
||||
///
|
||||
/// A `deadline` value less than or equal to 0 immediately yields the thread.
|
||||
pub async fn sys_nanosleep(&self, deadline: Deadline) -> ZxResult {
|
||||
info!("nanosleep: deadline={:?}", deadline);
|
||||
if deadline.0 <= 0 {
|
||||
|
|
|
@ -13,6 +13,9 @@ fn amount_of_alignments(options: u32) -> ZxResult<usize> {
|
|||
}
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Allocate a new subregion.
|
||||
///
|
||||
/// Creates a new VMAR within the one specified by `parent_vmar`.
|
||||
pub fn sys_vmar_allocate(
|
||||
&self,
|
||||
parent_vmar: HandleValue,
|
||||
|
@ -73,6 +76,9 @@ impl Syscall<'_> {
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// Add a memory mapping.
|
||||
///
|
||||
/// Maps the given VMO into the given virtual memory address region.
|
||||
pub fn sys_vmar_map(
|
||||
&self,
|
||||
vmar_handle: HandleValue,
|
||||
|
@ -158,6 +164,10 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Destroy a virtual memory address region.
|
||||
///
|
||||
/// Unmaps all mappings within the given region, and destroys all sub-regions of the region.
|
||||
/// > This operation is logically recursive.
|
||||
pub fn sys_vmar_destroy(&self, handle_value: HandleValue) -> ZxResult {
|
||||
info!("vmar.destroy: handle={:?}", handle_value);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -166,6 +176,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Set protection of virtual memory pages.
|
||||
pub fn sys_vmar_protect(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -194,6 +205,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Unmap virtual memory pages.
|
||||
pub fn sys_vmar_unmap(&self, handle_value: HandleValue, addr: usize, len: usize) -> ZxResult {
|
||||
info!(
|
||||
"vmar.unmap: handle_value={:#x}, addr={:#x}, len={:#x}",
|
||||
|
|
|
@ -7,6 +7,7 @@ use {
|
|||
};
|
||||
|
||||
impl Syscall<'_> {
|
||||
/// Create a new virtual memory object(VMO).
|
||||
pub fn sys_vmo_create(
|
||||
&self,
|
||||
size: u64,
|
||||
|
@ -28,6 +29,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Read bytes from a VMO.
|
||||
pub fn sys_vmo_read(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -52,6 +54,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write bytes to a VMO.
|
||||
pub fn sys_vmo_write(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -72,6 +75,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Add execute rights to a VMO.
|
||||
pub fn sys_vmo_replace_as_executable(
|
||||
&self,
|
||||
handle: HandleValue,
|
||||
|
@ -98,6 +102,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Obtain the current size of a VMO object.
|
||||
pub fn sys_vmo_get_size(&self, handle: HandleValue, mut size: UserOutPtr<usize>) -> ZxResult {
|
||||
info!("vmo.get_size: handle={:?}", handle);
|
||||
let proc = self.thread.proc();
|
||||
|
@ -106,6 +111,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a child of an existing VMO (new virtual memory object).
|
||||
pub fn sys_vmo_create_child(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -169,6 +175,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a VM object referring to a specific contiguous range of physical memory.
|
||||
pub fn sys_vmo_create_physical(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
|
@ -197,6 +204,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a VM object referring to a specific contiguous range of physical frame.
|
||||
pub fn sys_vmo_create_contiguous(
|
||||
&self,
|
||||
bti: HandleValue,
|
||||
|
@ -228,6 +236,7 @@ impl Syscall<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Resize a VMO object.
|
||||
pub fn sys_vmo_set_size(&self, handle_value: HandleValue, size: usize) -> ZxResult {
|
||||
let proc = self.thread.proc();
|
||||
let vmo = proc.get_object_with_rights::<VmObject>(handle_value, Rights::WRITE)?;
|
||||
|
@ -240,6 +249,9 @@ impl Syscall<'_> {
|
|||
vmo.set_len(size)
|
||||
}
|
||||
|
||||
/// Perform an operation on a range of a VMO.
|
||||
///
|
||||
/// Performs cache and memory operations against pages held by the VMO.
|
||||
pub fn sys_vmo_op_range(
|
||||
&self,
|
||||
handle_value: HandleValue,
|
||||
|
@ -286,6 +298,7 @@ impl Syscall<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the caching policy for pages held by a VMO.
|
||||
pub fn sys_vmo_cache_policy(&self, handle_value: HandleValue, policy: u32) -> ZxResult {
|
||||
let proc = self.thread.proc();
|
||||
let vmo = proc.get_object_with_rights::<VmObject>(handle_value, Rights::MAP)?;
|
||||
|
|
Loading…
Reference in New Issue