1a67022b5cfeeefd96325b751d14a9d360def954
2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
17 #define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
19 #include <sys/cdefs.h>
23 #include <pthread.h> /* for pthread_once() */
29 # define D(...) do{}while(0)
32 /* Try to open a new Qemu fast-pipe. This function returns a file descriptor
33 * that can be used to communicate with a named service managed by the
36 * This file descriptor can be used as a standard pipe/socket descriptor.
38 * 'pipeName' is the name of the emulator service you want to connect to.
39 * E.g. 'opengles' or 'camera'.
41 * On success, return a valid file descriptor
42 * Returns -1 on error, and errno gives the error code, e.g.:
44 * EINVAL -> unknown/unsupported pipeName
45 * ENOSYS -> fast pipes not available in this system.
47 * ENOSYS should never happen, except if you're trying to run within a
48 * misconfigured emulator.
50 * You should be able to open several pipes to the same pipe service,
51 * except for a few special cases (e.g. GSM modem), where EBUSY will be
52 * returned if more than one client tries to connect to it.
55 qemu_pipe_open(const char* pipeName
)
61 if (pipeName
== NULL
|| pipeName
[0] == '\0') {
66 snprintf(buff
, sizeof buff
, "pipe:%s", pipeName
);
68 fd
= open("/dev/qemu_pipe", O_RDWR
);
70 D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__
, strerror(errno
));
75 buffLen
= strlen(buff
);
77 ret
= TEMP_FAILURE_RETRY(write(fd
, buff
, buffLen
+1));
78 if (ret
!= buffLen
+1) {
79 D("%s: Could not connect to %s pipe service: %s", __FUNCTION__
, pipeName
, strerror(errno
));
91 #endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */