blob: 62da43900195be56531f26e9199826c7ca3a3b3d [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.
library fuchsia.hardware.goldfish;
using zx;
/// Signal that will be active on event handle if the Read() method
/// will return data.
const uint32 SIGNAL_READABLE = 0x01000000; // ZX_USER_SIGNAL_0
/// Signal that will be active on event handle if the Write() method
/// will accept data.
const uint32 SIGNAL_WRITABLE = 0x02000000; // ZX_USER_SIGNAL_1
/// Signal that will be active on event handle if the device has been
/// disconnected.
const uint32 SIGNAL_HANGUP = 0x04000000; // ZX_USER_SIGNAL_2
/// Interface for the Goldfish pipe driver.
[Layout = "Simple"]
protocol PipeDevice {
/// Open pipe. A protocol request `pipe_request` provides an interface
/// to the pipe. Multiple pipes can be opened for a single device.
/// Closing the device connection will also close all pipe connections.
/// TODO(DX-1766): Unify `device` and `pipe`.
OpenPipe(request<Pipe> pipe_request);
};
[Layout = "Simple"]
protocol Pipe {
/// Request new IO buffer size. Can fail if out of memory. Discards
/// contents of existing buffer on success. Leaves existing buffer
/// intact on failure.
SetBufferSize(uint64 size) -> (zx.status res);
/// Set event used to signal device state. Discards existing event
/// after having transferred device state to the new event.
SetEvent(handle<event> event);
/// Acquire VMO for IO buffer. Can be called multiple times. Each call
/// returns a new handle to the VMO.
GetBuffer() -> (zx.status res, handle<vmo>? vmo);
/// Attempt to read up to count bytes into IO buffer at specified offset.
/// Returns `ZX_ERR_SHOULD_WAIT` if pipe device is not readable.
Read(uint64 count, uint64 offset) -> (zx.status res, uint64 actual);
/// Writes up to count bytes from the IO buffer at specified offset.
/// Returns `ZX_ERR_SHOULD_WAIT` if pipe device is not writable.
Write(uint64 count, uint64 offset) -> (zx.status res, uint64 actual);
/// Writes count bytes from the IO buffer at specified write
/// offset. Blocks if pipe device is not writable. Subsequently reads
/// read_count bytes into the IO buffer at specified read offset.
/// Returns `ZX_ERR_SHOULD_WAIT` if pipe device is not readable.
Call(uint64 count, uint64 offset, uint64 read_count, uint64 read_offset)
-> (zx.status res, uint64 actual);
};