2 * Copyright (C) 2008 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 _libs_hardware_qemu_h
17 #define _libs_hardware_qemu_h
25 /* returns 1 iff we're running in the emulator */
26 extern int qemu_check(void);
28 /* a structure used to hold enough state to connect to a given
29 * QEMU communication channel, either through a qemud socket or
32 * initialize the structure by zero-ing it out
42 /* try to open a qemu communication channel.
43 * returns a file descriptor on success, or -1 in case of
46 * 'channel' must be a QemuChannel structure that is empty
47 * on the first call. You can call this function several
48 * time to re-open the channel using the same 'channel'
49 * object to speed things a bit.
51 extern int qemu_channel_open( QemuChannel* channel,
55 /* create a command made of a 4-hexchar prefix followed
56 * by the content. the prefix contains the content's length
57 * in hexadecimal coding.
59 * 'buffer' must be at last 6 bytes
60 * returns -1 in case of overflow, or the command's total length
61 * otherwise (i.e. content length + 4)
63 extern int qemu_command_format( char* buffer,
68 /* directly sends a command through the 'control' channel.
69 * this will open the channel, send the formatted command, then
70 * close the channel automatically.
71 * returns 0 on success, or -1 on error.
73 extern int qemu_control_command( const char* fmt, ... );
75 /* sends a question to the control channel, then receive an answer in
76 * a user-allocated buffer. returns the lenght of the answer, or -1
79 * 'question' *must* have been formatted through qemu_command_format
81 extern int qemu_control_query( const char* question, int questionlen,
82 char* answer, int answersize );
84 #endif /* QEMU_HARDWARE */
86 /* use QEMU_FALLBACK(call) to call a QEMU-specific callback */
87 /* use QEMU_FALLBACK_VOID(call) if the function returns void */
89 # define QEMU_FALLBACK(x) \
94 # define QEMU_FALLBACK_VOID(x) \
102 # define QEMU_FALLBACK(x) ((void)0)
103 # define QEMU_FALLBACK_VOID(x) ((void)0)
110 #endif /* _libs_hardware_qemu_h */