1 // Copyright 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #pragma once 15 16 #include <stddef.h> 17 #include <stdint.h> 18 19 // Shared type and constant declarations between android_pipe.h and 20 // android_pipe_host.h 21 22 // Buffer descriptor for android_pipe_guest_send() and 23 // android_pipe_guest_recv(). 24 typedef struct AndroidPipeBuffer { 25 uint8_t* data; 26 size_t size; 27 } AndroidPipeBuffer; 28 29 /* List of bitflags returned in status of CMD_POLL command */ 30 enum PipePollFlags { 31 PIPE_POLL_IN = 1 << 0, 32 PIPE_POLL_OUT = 1 << 1, 33 PIPE_POLL_HUP = 1 << 2 34 }; 35 36 /* Possible status values used to signal errors - see goldfish_pipe_error_convert */ 37 enum PipeErrors { 38 PIPE_ERROR_INVAL = -1, 39 PIPE_ERROR_AGAIN = -2, 40 PIPE_ERROR_NOMEM = -3, 41 PIPE_ERROR_IO = -4 42 }; 43 44 /* Bit-flags used to signal events from the emulator */ 45 enum PipeWakeFlags { 46 PIPE_WAKE_CLOSED = 1 << 0, /* emulator closed pipe */ 47 PIPE_WAKE_READ = 1 << 1, /* pipe can now be read from */ 48 PIPE_WAKE_WRITE = 1 << 2, /* pipe can now be written to */ 49 PIPE_WAKE_UNLOCK_DMA = 1 << 3, /* unlock this pipe's DMA buffer */ 50 PIPE_WAKE_UNLOCK_DMA_SHARED = 1 << 4, /* unlock DMA buffer of the pipe shared to this pipe */ 51 }; 52 53 /* Possible pipe closing reasons */ 54 typedef enum PipeCloseReason { 55 PIPE_CLOSE_GRACEFUL = 0, /* guest sent a close command */ 56 PIPE_CLOSE_REBOOT = 1, /* guest rebooted, we're closing the pipes */ 57 PIPE_CLOSE_LOAD_SNAPSHOT = 2, /* close old pipes on snapshot load */ 58 PIPE_CLOSE_ERROR = 3, /* some unrecoverable error on the pipe */ 59 } PipeCloseReason; 60 61 /* Pipe flags for special transports and properties */ 62 enum AndroidPipeFlags { 63 /* first 4 bits are about whether it's using the normal goldfish pipe 64 * or using virtio-gpu / address space */ 65 ANDROID_PIPE_DEFAULT = 0, 66 ANDROID_PIPE_VIRTIO_GPU_BIT = (1 << 0), 67 ANDROID_PIPE_ADDRESS_SPACE_BIT = (1 << 1), 68 ANDROID_PIPE_RESERVED0_BIT = (1 << 2), 69 ANDROID_PIPE_RESERVED1_BIT = (1 << 3), 70 ANDROID_PIPE_VIRTIO_VSOCK_BIT = (1 << 4), 71 }; 72