18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * IMPORTANT: The following constants must match the ones used and defined in 48c2ecf20Sopenharmony_ci * external/qemu/include/hw/misc/goldfish_pipe.h 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef GOLDFISH_PIPE_QEMU_H 88c2ecf20Sopenharmony_ci#define GOLDFISH_PIPE_QEMU_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* List of bitflags returned in status of CMD_POLL command */ 118c2ecf20Sopenharmony_cienum PipePollFlags { 128c2ecf20Sopenharmony_ci PIPE_POLL_IN = 1 << 0, 138c2ecf20Sopenharmony_ci PIPE_POLL_OUT = 1 << 1, 148c2ecf20Sopenharmony_ci PIPE_POLL_HUP = 1 << 2 158c2ecf20Sopenharmony_ci}; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* Possible status values used to signal errors */ 188c2ecf20Sopenharmony_cienum PipeErrors { 198c2ecf20Sopenharmony_ci PIPE_ERROR_INVAL = -1, 208c2ecf20Sopenharmony_ci PIPE_ERROR_AGAIN = -2, 218c2ecf20Sopenharmony_ci PIPE_ERROR_NOMEM = -3, 228c2ecf20Sopenharmony_ci PIPE_ERROR_IO = -4 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* Bit-flags used to signal events from the emulator */ 268c2ecf20Sopenharmony_cienum PipeWakeFlags { 278c2ecf20Sopenharmony_ci /* emulator closed pipe */ 288c2ecf20Sopenharmony_ci PIPE_WAKE_CLOSED = 1 << 0, 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci /* pipe can now be read from */ 318c2ecf20Sopenharmony_ci PIPE_WAKE_READ = 1 << 1, 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci /* pipe can now be written to */ 348c2ecf20Sopenharmony_ci PIPE_WAKE_WRITE = 1 << 2, 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci /* unlock this pipe's DMA buffer */ 378c2ecf20Sopenharmony_ci PIPE_WAKE_UNLOCK_DMA = 1 << 3, 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* unlock DMA buffer of the pipe shared to this pipe */ 408c2ecf20Sopenharmony_ci PIPE_WAKE_UNLOCK_DMA_SHARED = 1 << 4, 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Possible pipe closing reasons */ 448c2ecf20Sopenharmony_cienum PipeCloseReason { 458c2ecf20Sopenharmony_ci /* guest sent a close command */ 468c2ecf20Sopenharmony_ci PIPE_CLOSE_GRACEFUL = 0, 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /* guest rebooted, we're closing the pipes */ 498c2ecf20Sopenharmony_ci PIPE_CLOSE_REBOOT = 1, 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci /* close old pipes on snapshot load */ 528c2ecf20Sopenharmony_ci PIPE_CLOSE_LOAD_SNAPSHOT = 2, 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci /* some unrecoverable error on the pipe */ 558c2ecf20Sopenharmony_ci PIPE_CLOSE_ERROR = 3, 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* Bit flags for the 'flags' field */ 598c2ecf20Sopenharmony_cienum PipeFlagsBits { 608c2ecf20Sopenharmony_ci BIT_CLOSED_ON_HOST = 0, /* pipe closed by host */ 618c2ecf20Sopenharmony_ci BIT_WAKE_ON_WRITE = 1, /* want to be woken on writes */ 628c2ecf20Sopenharmony_ci BIT_WAKE_ON_READ = 2, /* want to be woken on reads */ 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cienum PipeRegs { 668c2ecf20Sopenharmony_ci PIPE_REG_CMD = 0, 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci PIPE_REG_SIGNAL_BUFFER_HIGH = 4, 698c2ecf20Sopenharmony_ci PIPE_REG_SIGNAL_BUFFER = 8, 708c2ecf20Sopenharmony_ci PIPE_REG_SIGNAL_BUFFER_COUNT = 12, 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci PIPE_REG_OPEN_BUFFER_HIGH = 20, 738c2ecf20Sopenharmony_ci PIPE_REG_OPEN_BUFFER = 24, 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci PIPE_REG_VERSION = 36, 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci PIPE_REG_GET_SIGNALLED = 48, 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cienum PipeCmdCode { 818c2ecf20Sopenharmony_ci /* to be used by the pipe device itself */ 828c2ecf20Sopenharmony_ci PIPE_CMD_OPEN = 1, 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci PIPE_CMD_CLOSE, 858c2ecf20Sopenharmony_ci PIPE_CMD_POLL, 868c2ecf20Sopenharmony_ci PIPE_CMD_WRITE, 878c2ecf20Sopenharmony_ci PIPE_CMD_WAKE_ON_WRITE, 888c2ecf20Sopenharmony_ci PIPE_CMD_READ, 898c2ecf20Sopenharmony_ci PIPE_CMD_WAKE_ON_READ, 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci /* 928c2ecf20Sopenharmony_ci * TODO(zyy): implement a deferred read/write execution to allow 938c2ecf20Sopenharmony_ci * parallel processing of pipe operations on the host. 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_ci PIPE_CMD_WAKE_ON_DONE_IO, 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif /* GOLDFISH_PIPE_QEMU_H */ 99