Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 #ifndef ANDROID_CORE_INCLUDE_QEMU_PIPE_H
     17 #define ANDROID_CORE_INCLUDE_QEMU_PIPE_H
     18 
     19 #include <stddef.h>
     20 
     21 #ifdef __cplusplus
     22 extern "C" {
     23 #endif
     24 // Try to open a new Qemu fast-pipe. This function returns a file descriptor
     25 // that can be used to communicate with a named service managed by the
     26 // emulator.
     27 //
     28 // This file descriptor can be used as a standard pipe/socket descriptor.
     29 //
     30 // 'pipeName' is the name of the emulator service you want to connect to,
     31 // and should begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles').
     32 // For backward compatibility, the 'pipe:' prefix can be omitted, and in
     33 // that case, qemu_pipe_open will add it for you.
     34 
     35 // On success, return a valid file descriptor, or -1/errno on failure. E.g.:
     36 //
     37 // EINVAL  -> unknown/unsupported pipeName
     38 // ENOSYS  -> fast pipes not available in this system.
     39 //
     40 // ENOSYS should never happen, except if you're trying to run within a
     41 // misconfigured emulator.
     42 //
     43 // You should be able to open several pipes to the same pipe service,
     44 // except for a few special cases (e.g. GSM modem), where EBUSY will be
     45 // returned if more than one client tries to connect to it.
     46 int qemu_pipe_open(const char* pipeName);
     47 
     48 // Send a framed message |buff| of |len| bytes through the |fd| descriptor.
     49 // This really adds a 4-hexchar prefix describing the payload size.
     50 // Returns 0 on success, and -1 on error.
     51 int qemu_pipe_frame_send(int fd, const void* buff, size_t len);
     52 
     53 // Read a frame message from |fd|, and store it into |buff| of |len| bytes.
     54 // If the framed message is larger than |len|, then this returns -1 and the
     55 // content is lost. Otherwise, this returns the size of the message. NOTE:
     56 // empty messages are possible in a framed wire protocol and do not mean
     57 // end-of-stream.
     58 int qemu_pipe_frame_recv(int fd, void* buff, size_t len);
     59 
     60 #ifdef __cplusplus
     61 }
     62 #endif
     63 
     64 #endif /* ANDROID_CORE_INCLUDE_QEMU_PIPE_H */
     65