binder.h revision 525ce914edf136d2bd02ac8c404d56c52e737f4d
1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ***   To edit the content of this header, modify the corresponding
11 ***   source file (e.g. under external/kernel-headers/original/) then
12 ***   run bionic/libc/kernel/tools/update_all.py
13 ***
14 ***   Any manual change here will be lost the next time this script will
15 ***   be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_BINDER_H
20#define _UAPI_LINUX_BINDER_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
23#define B_PACK_CHARS(c1,c2,c3,c4) ((((c1) << 24)) | (((c2) << 16)) | (((c3) << 8)) | (c4))
24#define B_TYPE_LARGE 0x85
25enum {
26  BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
27  BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
28  BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
29  BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
30  BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
31  BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
32  BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
33};
34enum {
35  FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
36  FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
37};
38#ifdef BINDER_IPC_32BIT
39typedef __u32 binder_size_t;
40typedef __u32 binder_uintptr_t;
41#else
42typedef __u64 binder_size_t;
43typedef __u64 binder_uintptr_t;
44#endif
45struct binder_object_header {
46  __u32 type;
47};
48struct flat_binder_object {
49  struct binder_object_header hdr;
50  __u32 flags;
51  union {
52    binder_uintptr_t binder;
53    __u32 handle;
54  };
55  binder_uintptr_t cookie;
56};
57struct binder_fd_object {
58  struct binder_object_header hdr;
59  __u32 pad_flags;
60  union {
61    binder_uintptr_t pad_binder;
62    __u32 fd;
63  };
64  binder_uintptr_t cookie;
65};
66struct binder_buffer_object {
67  struct binder_object_header hdr;
68  __u32 flags;
69  binder_uintptr_t buffer;
70  binder_size_t length;
71  binder_size_t parent;
72  binder_size_t parent_offset;
73};
74enum {
75  BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
76};
77struct __kernel_binder_fd_array_object {
78  struct binder_object_header hdr;
79  binder_size_t num_fds;
80  binder_size_t parent;
81  binder_size_t parent_offset;
82};
83struct binder_write_read {
84  binder_size_t write_size;
85  binder_size_t write_consumed;
86  binder_uintptr_t write_buffer;
87  binder_size_t read_size;
88  binder_size_t read_consumed;
89  binder_uintptr_t read_buffer;
90};
91struct binder_version {
92  __s32 protocol_version;
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#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
100#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
101#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
102#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
103#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
104#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
105#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
106enum transaction_flags {
107  TF_ONE_WAY = 0x01,
108  TF_ROOT_OBJECT = 0x04,
109  TF_STATUS_CODE = 0x08,
110  TF_ACCEPT_FDS = 0x10,
111};
112struct binder_transaction_data {
113  union {
114    __u32 handle;
115    binder_uintptr_t ptr;
116  } target;
117  binder_uintptr_t cookie;
118  __u32 code;
119  __u32 flags;
120  pid_t sender_pid;
121  uid_t sender_euid;
122  binder_size_t data_size;
123  binder_size_t offsets_size;
124  union {
125    struct {
126      binder_uintptr_t buffer;
127      binder_uintptr_t offsets;
128    } ptr;
129    __u8 buf[8];
130  } data;
131};
132struct binder_transaction_data_sg {
133  struct binder_transaction_data transaction_data;
134  binder_size_t buffers_size;
135};
136struct binder_ptr_cookie {
137  binder_uintptr_t ptr;
138  binder_uintptr_t cookie;
139};
140struct binder_handle_cookie {
141  __u32 handle;
142  binder_uintptr_t cookie;
143} __packed;
144struct binder_pri_desc {
145  __s32 priority;
146  __u32 desc;
147};
148struct binder_pri_ptr_cookie {
149  __s32 priority;
150  binder_uintptr_t ptr;
151  binder_uintptr_t cookie;
152};
153enum binder_driver_return_protocol {
154  BR_ERROR = _IOR('r', 0, __s32),
155  BR_OK = _IO('r', 1),
156  BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
157  BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
158  BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
159  BR_DEAD_REPLY = _IO('r', 5),
160  BR_TRANSACTION_COMPLETE = _IO('r', 6),
161  BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
162  BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
163  BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
164  BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
165  BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
166  BR_NOOP = _IO('r', 12),
167  BR_SPAWN_LOOPER = _IO('r', 13),
168  BR_FINISHED = _IO('r', 14),
169  BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
170  BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
171  BR_FAILED_REPLY = _IO('r', 17),
172};
173enum binder_driver_command_protocol {
174  BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
175  BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
176  BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
177  BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
178  BC_INCREFS = _IOW('c', 4, __u32),
179  BC_ACQUIRE = _IOW('c', 5, __u32),
180  BC_RELEASE = _IOW('c', 6, __u32),
181  BC_DECREFS = _IOW('c', 7, __u32),
182  BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
183  BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
184  BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
185  BC_REGISTER_LOOPER = _IO('c', 11),
186  BC_ENTER_LOOPER = _IO('c', 12),
187  BC_EXIT_LOOPER = _IO('c', 13),
188  BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie),
189  BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie),
190  BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
191  BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
192  BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
193};
194#endif
195