1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef _UAPI_LINUX_BINDER_H
21#define _UAPI_LINUX_BINDER_H
22
23#include <linux/types.h>
24#include <linux/ioctl.h>
25
26#define B_PACK_CHARS(c1, c2, c3, c4) \
27 ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
28#define B_TYPE_LARGE 0x85
29
30enum {
31 BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
32 BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
33 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
34 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
35 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
36};
37
38enum {
39 FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
40 FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
41};
42
43#ifdef BINDER_IPC_32BIT
44typedef __u32 binder_size_t;
45typedef __u32 binder_uintptr_t;
46#else
47typedef __u64 binder_size_t;
48typedef __u64 binder_uintptr_t;
49#endif
50
51
52
53
54
55
56
57
58struct flat_binder_object {
59
60 __u32 type;
61 __u32 flags;
62
63
64 union {
65 binder_uintptr_t binder;
66 __u32 handle;
67 };
68
69
70 binder_uintptr_t cookie;
71};
72
73
74
75
76
77
78struct binder_write_read {
79 binder_size_t write_size;
80 binder_size_t write_consumed;
81 binder_uintptr_t write_buffer;
82 binder_size_t read_size;
83 binder_size_t read_consumed;
84 binder_uintptr_t read_buffer;
85};
86
87
88struct binder_version {
89
90 __s32 protocol_version;
91};
92
93
94#ifdef BINDER_IPC_32BIT
95#define BINDER_CURRENT_PROTOCOL_VERSION 7
96#else
97#define BINDER_CURRENT_PROTOCOL_VERSION 8
98#endif
99
100#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
101#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
102#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
103#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
104#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
105#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
106#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123enum transaction_flags {
124 TF_ONE_WAY = 0x01,
125 TF_ROOT_OBJECT = 0x04,
126 TF_STATUS_CODE = 0x08,
127 TF_ACCEPT_FDS = 0x10,
128};
129
130struct binder_transaction_data {
131
132
133
134 union {
135
136 __u32 handle;
137
138 binder_uintptr_t ptr;
139 } target;
140 binder_uintptr_t cookie;
141 __u32 code;
142
143
144 __u32 flags;
145 pid_t sender_pid;
146 uid_t sender_euid;
147 binder_size_t data_size;
148 binder_size_t offsets_size;
149
150
151
152
153
154 union {
155 struct {
156
157 binder_uintptr_t buffer;
158
159 binder_uintptr_t offsets;
160 } ptr;
161 __u8 buf[8];
162 } data;
163};
164
165struct binder_ptr_cookie {
166 binder_uintptr_t ptr;
167 binder_uintptr_t cookie;
168};
169
170struct binder_handle_cookie {
171 __u32 handle;
172 binder_uintptr_t cookie;
173} __packed;
174
175struct binder_pri_desc {
176 __s32 priority;
177 __u32 desc;
178};
179
180struct binder_pri_ptr_cookie {
181 __s32 priority;
182 binder_uintptr_t ptr;
183 binder_uintptr_t cookie;
184};
185
186enum binder_driver_return_protocol {
187 BR_ERROR = _IOR('r', 0, __s32),
188
189
190
191
192 BR_OK = _IO('r', 1),
193
194
195 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
196 BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
197
198
199
200
201 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
202
203
204
205
206
207
208 BR_DEAD_REPLY = _IO('r', 5),
209
210
211
212
213
214 BR_TRANSACTION_COMPLETE = _IO('r', 6),
215
216
217
218
219
220
221 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
222 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
223 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
224 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
225
226
227
228
229
230 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
231
232
233
234
235
236
237
238 BR_NOOP = _IO('r', 12),
239
240
241
242
243
244 BR_SPAWN_LOOPER = _IO('r', 13),
245
246
247
248
249
250
251
252 BR_FINISHED = _IO('r', 14),
253
254
255
256
257
258 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
259
260
261
262 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
263
264
265
266
267 BR_FAILED_REPLY = _IO('r', 17),
268
269
270
271
272};
273
274enum binder_driver_command_protocol {
275 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
276 BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
277
278
279
280
281 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
282
283
284
285
286
287
288 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
289
290
291
292
293 BC_INCREFS = _IOW('c', 4, __u32),
294 BC_ACQUIRE = _IOW('c', 5, __u32),
295 BC_RELEASE = _IOW('c', 6, __u32),
296 BC_DECREFS = _IOW('c', 7, __u32),
297
298
299
300
301 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
302 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
303
304
305
306
307
308 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
309
310
311
312
313
314
315 BC_REGISTER_LOOPER = _IO('c', 11),
316
317
318
319
320
321 BC_ENTER_LOOPER = _IO('c', 12),
322 BC_EXIT_LOOPER = _IO('c', 13),
323
324
325
326
327
328
329
330
331 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14,
332 struct binder_handle_cookie),
333
334
335
336
337
338 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15,
339 struct binder_handle_cookie),
340
341
342
343
344
345 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
346
347
348
349};
350
351#endif
352
353