goldfish_pipe_qemu.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * IMPORTANT: The following constants must match the ones used and defined in
  4. * external/qemu/include/hw/misc/goldfish_pipe.h
  5. */
  6. #ifndef GOLDFISH_PIPE_QEMU_H
  7. #define GOLDFISH_PIPE_QEMU_H
  8. /* List of bitflags returned in status of CMD_POLL command */
  9. enum PipePollFlags {
  10. PIPE_POLL_IN = 1 << 0,
  11. PIPE_POLL_OUT = 1 << 1,
  12. PIPE_POLL_HUP = 1 << 2
  13. };
  14. /* Possible status values used to signal errors */
  15. enum PipeErrors {
  16. PIPE_ERROR_INVAL = -1,
  17. PIPE_ERROR_AGAIN = -2,
  18. PIPE_ERROR_NOMEM = -3,
  19. PIPE_ERROR_IO = -4
  20. };
  21. /* Bit-flags used to signal events from the emulator */
  22. enum PipeWakeFlags {
  23. /* emulator closed pipe */
  24. PIPE_WAKE_CLOSED = 1 << 0,
  25. /* pipe can now be read from */
  26. PIPE_WAKE_READ = 1 << 1,
  27. /* pipe can now be written to */
  28. PIPE_WAKE_WRITE = 1 << 2,
  29. /* unlock this pipe's DMA buffer */
  30. PIPE_WAKE_UNLOCK_DMA = 1 << 3,
  31. /* unlock DMA buffer of the pipe shared to this pipe */
  32. PIPE_WAKE_UNLOCK_DMA_SHARED = 1 << 4,
  33. };
  34. /* Possible pipe closing reasons */
  35. enum PipeCloseReason {
  36. /* guest sent a close command */
  37. PIPE_CLOSE_GRACEFUL = 0,
  38. /* guest rebooted, we're closing the pipes */
  39. PIPE_CLOSE_REBOOT = 1,
  40. /* close old pipes on snapshot load */
  41. PIPE_CLOSE_LOAD_SNAPSHOT = 2,
  42. /* some unrecoverable error on the pipe */
  43. PIPE_CLOSE_ERROR = 3,
  44. };
  45. /* Bit flags for the 'flags' field */
  46. enum PipeFlagsBits {
  47. BIT_CLOSED_ON_HOST = 0, /* pipe closed by host */
  48. BIT_WAKE_ON_WRITE = 1, /* want to be woken on writes */
  49. BIT_WAKE_ON_READ = 2, /* want to be woken on reads */
  50. };
  51. enum PipeRegs {
  52. PIPE_REG_CMD = 0,
  53. PIPE_REG_SIGNAL_BUFFER_HIGH = 4,
  54. PIPE_REG_SIGNAL_BUFFER = 8,
  55. PIPE_REG_SIGNAL_BUFFER_COUNT = 12,
  56. PIPE_REG_OPEN_BUFFER_HIGH = 20,
  57. PIPE_REG_OPEN_BUFFER = 24,
  58. PIPE_REG_VERSION = 36,
  59. PIPE_REG_GET_SIGNALLED = 48,
  60. };
  61. enum PipeCmdCode {
  62. /* to be used by the pipe device itself */
  63. PIPE_CMD_OPEN = 1,
  64. PIPE_CMD_CLOSE,
  65. PIPE_CMD_POLL,
  66. PIPE_CMD_WRITE,
  67. PIPE_CMD_WAKE_ON_WRITE,
  68. PIPE_CMD_READ,
  69. PIPE_CMD_WAKE_ON_READ,
  70. /*
  71. * TODO(zyy): implement a deferred read/write execution to allow
  72. * parallel processing of pipe operations on the host.
  73. */
  74. PIPE_CMD_WAKE_ON_DONE_IO,
  75. };
  76. #endif /* GOLDFISH_PIPE_QEMU_H */