blob: f42069cf8c514dc4e23e9e10b7479d150bb58869 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(fxb/39732): This should be read as "library zx".
library zz;
[Transport = "Syscall"]
protocol vmo {
/// Create a VM object.
vmo_create(uint64 size, uint32 options) -> (status status, handle<vmo> out);
// TODO(scottmg): This syscall is very weird, it's currently:
// (handle, buffer, offset, buffer_size)
// rather than:
// (handle, buffer, buffer_size, offset)
// which means the vector<byte> buffer won't work. Unfortunately offset and
// buffer_size have the same underlying type, so moving them will be
// error-prone.
/// Read bytes from the VMO.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_READ.
[blocking,
ArgReorder = "handle, buffer, offset, buffer_size"]
vmo_read(handle<vmo> handle, uint64 offset) -> (status status, vector_void buffer);
// TODO(scottmg): Same problem as Read() above.
/// Write bytes to the VMO.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_WRITE.
[blocking,
ArgReorder = "handle, buffer, offset, buffer_size"]
vmo_write(handle<vmo> handle, vector_void buffer, uint64 offset) -> (status status);
// TODO(ZX-2967): No rights required?
/// Read the current size of a VMO object.
vmo_get_size(handle<vmo> handle) -> (status status, uint64 size);
/// Resize a VMO object.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_WRITE.
vmo_set_size(handle<vmo> handle, uint64 size) -> (status status);
/// Perform an operation on a range of a VMO.
/// Rights: If op is ZX_VMO_OP_COMMIT, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_WRITE.
/// Rights: If op is ZX_VMO_OP_DECOMMIT, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_WRITE.
/// Rights: If op is ZX_VMO_OP_CACHE_SYNC, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_READ.
/// Rights: If op is ZX_VMO_OP_CACHE_INVALIDATE, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_WRITE.
/// Rights: If op is ZX_VMO_OP_CACHE_CLEAN, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_READ.
/// Rights: If op is ZX_VMO_OP_CACHE_CLEAN_INVALIDATE, handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_READ.
[blocking]
vmo_op_range(handle<vmo> handle,
uint32 op,
uint64 offset,
uint64 size,
mutable_vector_void buffer)
-> (status status);
/// Create a child of a VM Object.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_DUPLICATE and have ZX_RIGHT_READ.
vmo_create_child(handle<vmo> handle, uint32 options, uint64 offset, uint64 size)
-> (status status, handle<vmo> out);
/// Set the caching policy for pages held by a VMO.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO and have ZX_RIGHT_MAP.
vmo_set_cache_policy(handle<vmo> handle, uint32 cache_policy) -> (status status);
// TODO(ZX-2967): handle: No rights required, ZX_RIGHT_EXECUTE added to dup out
// TODO(ZX-2967): vmex == ZX_HANDLE_INVALID also accepted.
/// Add execute rights to a VMO.
/// Rights: handle must be of type ZX_OBJ_TYPE_VMO.
/// Rights: vmex must have resource kind ZX_RSRC_KIND_VMEX.
vmo_replace_as_executable(handle<vmo> handle, handle<resource> vmex)
-> (status status, handle<vmo> out);
/// Rights: bti must be of type ZX_OBJ_TYPE_BTI and have ZX_RIGHT_MAP.
vmo_create_contiguous(handle<bti> bti, usize size, uint32 alignment_log2)
-> (status status, handle<vmo> out);
/// Create a VM object referring to a specific contiguous range of physical memory.
/// Rights: resource must have resource kind ZX_RSRC_KIND_MMIO.
vmo_create_physical(handle<resource> resource, paddr paddr, usize size)
-> (status status, handle<vmo> out);
};