blob: d22271fa7b940d789fd67917cbf9e857fcdd8028 [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.pipe;
using zx;
/// Codes for supported pipe commands.
type PipeCmdCode = strict enum : int32 {
OPEN = 1;
CLOSE = 2;
POLL = 3;
WRITE = 4;
WAKE_ON_WRITE = 5;
READ = 6;
WAKE_ON_READ = 7;
CALL = 11;
};
/// Pipe device wake flags.
type PipeWakeFlag = strict enum : int32 {
CLOSED = 1;
READ = 2;
WRITE = 4;
};
/// Pipe command errors. 0 is success.
type PipeError = strict enum : int32 {
INVAL = -1;
AGAIN = -2;
NOMEM = -3;
IO = -4;
};
/// This interface can be used to establish a goldfish pipe connection. The
/// client is responsible for managing the command structure associated with
/// the pipe and should issue a 'close' command before destroying a previously
/// opened pipe. Failure to do so may result in host side resources that are
/// not cleaned up properly.
@discoverable
closed protocol GoldfishPipe {
/// Create a new pipe connection. The |id| identifies the pipe and must be
/// used for all subsequent commands. The memory that will be used as
/// command structure is returned in |vmo|.
strict Create() -> (resource struct {
id int32;
vmo zx.Handle:VMO;
}) error zx.Status;
/// Destroy a previously created pipe connection.
strict Destroy(struct {
id int32;
}) -> ();
/// Set event used to signal device state. Discards existing event
/// after having transferred device state to the new event, if event
/// exists.
///
/// Return error states from `zx_object_wait_one` and `zx_object_signal`
/// if existing events on `pipe_event` cannot be transferred to the call.
/// Otherwise returns `ZX_OK`.
strict SetEvent(resource struct {
id int32;
pipe_event zx.Handle:EVENT;
}) -> () error zx.Status;
/// Open pipe connection. This must be called before any other
/// commands are issued and will cause the physical address of the
/// command structure to be a associated with the pipe. The command
/// structure must contain {.cmd = OPEN, .id = id} at the time this
/// request is issued.
strict Open(struct {
id int32;
}) -> ();
/// Execute pipe command stored in associated command structure.
strict Exec(struct {
id int32;
}) -> ();
/// Get BTI that can be used create IO buffers for read/write commands.
strict GetBti() -> (resource struct {
bti zx.Handle:BTI;
}) error zx.Status;
};
service Service {
device client_end:GoldfishPipe;
};