class PipeIo

Defined at line 27 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.h

PipeIo is a generic library drivers could use to read from and write to

goldfish Pipe devices. It supports blocking and non-blocking read / write

and read / write with frame headers, which are used in some QEMUD pipes

like goldfish sensor pipe.

Public Methods

void PipeIo (fidl::WireSyncClient<fuchsia_hardware_goldfish_pipe::Bus> pipe_bus, const char * pipe_name)

Defined at line 29 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

template <class T>
ReadResult<T> Read (size_t size, bool blocking)

Read |size| elements of type |T| from the pipe.

Returns:

- |ZX_OK|: if read succeeds.

- |ZX_ERR_SHOULD_WAIT|: only occurs when |blocking| = false, when fewer

than |size| bytes can be read from the pipe without waiting.

- Other errors: if pipe read fails, or event wait fails.

Defined at line 45 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.h

template <class T>
ReadResult<T> Call (cpp20::span<const WriteSrc> write_sources, size_t read_size, bool blocking)

First write all the |write_sources| to the pipe, then read |read_size|

elements of type |T| from the pipe. The operations will be executed within

a single pipe call command.

Returns:

- |ZX_OK| and data read from pipe: if write and read succeeds.

- |ZX_ERR_SHOULD_WAIT|: only occurs when |blocking| = false, when

|write_sources| cannot be written to the pipe or fewer than

|size| bytes can be read from the pipe without waiting.

- Other errors: if pipe write/read fails, or event wait fails.

Defined at line 131 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.h

void ~PipeIo ()

Defined at line 137 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

const zx::event & pipe_event ()

Defined at line 157 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.h

bool valid ()

Defined at line 158 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.h

ReadResult<char> ReadWithHeader (bool blocking)

First read the header for payload size, then read the payload.

Returns:

- |ZX_OK|: if read succeeds.

- |ZX_ERR_SHOULD_WAIT|: only occurs when |blocking| = false, when less than

4 bytes cannot be read (for header), or fewer than |size| bytes

can be read from the pipe without waiting.

Other errors: if pipe read fails, or event wait fails.

Defined at line 275 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

zx_status_t Write (cpp20::span<const WriteSrc> sources, bool blocking)

Write |sources| to the pipe. All the write operations will be executed

in a single pipe command.

Returns:

- |ZX_OK|: if write succeeds.

- |ZX_ERR_SHOULD_WAIT|: only occurs when |blocking| = false, when fewer

than the payload size can be written to the pipe without waiting.

Other errors: if pipe write fails, or event wait fails.

Defined at line 448 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

zx_status_t Write (const char * payload, bool blocking)

Write a null-terminated string |payload| to the pipe. The terminator '

\

0'

will be sent to the pipe as well.

Returns: Same as "Write(cpp20::span<const WriteSrc>, bool)"

Defined at line 456 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

zx_status_t Write (const std::vector<uint8_t> & payload, bool blocking)

Write a byte vector |payload| to the pipe. The terminator '

\

0'

will be sent to the pipe as well.

Returns: Same as "Write(cpp20::span<const WriteSrc>, bool)".

Defined at line 461 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

zx_status_t WriteWithHeader (const char * payload, bool blocking)

First write the header of the payload (4-bytes size in hexadecimal), then

write the payload.

Returns:

- |ZX_OK|: if write succeeds.

- |ZX_ERR_SHOULD_WAIT|: only occurs when |blocking| = false, when less than

4 bytes cannot be written (for header), or fewer than |size| bytes

can be written to the pipe without waiting.

Other errors: if pipe read fails, or event wait fails.

Defined at line 466 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

zx_status_t WriteWithHeader (const std::vector<uint8_t> & payload, bool blocking)

First write the header of the payload (4-bytes size), then write the

payload.

Returns: Same as "WriteWithHeader(const char*, bool)".

Defined at line 472 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

fzl::PinnedVmo PinVmo (zx::vmo & vmo, uint32_t options)

Pin pages of |vmo| and grant goldfish pipe device the ability to access the

VMO pages, using |options| as defined in |zx_bti_pin()| syscall.

The caller *must* unpin all the VMOs before destroying |PipeIo|.

Defined at line 489 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

fzl::PinnedVmo PinVmo (zx::vmo & vmo, uint32_t options, size_t offset, size_t size)

Pin pages of the range [offset, offset + size) of |vmo| and grant goldfish

pipe device the ability to access the VMO pages, using |options| as

defined in |zx_bti_pin()| syscall.

The caller *must* unpin all the VMOs before destroying |PipeIo|.

Defined at line 497 of file ../../src/devices/lib/goldfish/pipe_io/pipe_io.cc

Records