blob: 1abb3a307fecddce63ccf147edb5b6f5f711a066 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris05d08e92016-02-04 13:16:38 -08007#ifndef _UAPI_LINUX_BINDER_H
8#define _UAPI_LINUX_BINDER_H
9#include <linux/types.h>
10#include <linux/ioctl.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080011#define B_PACK_CHARS(c1,c2,c3,c4) ((((c1) << 24)) | (((c2) << 16)) | (((c3) << 8)) | (c4))
12#define B_TYPE_LARGE 0x85
13enum {
14 BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
Christopher Ferris05d08e92016-02-04 13:16:38 -080015 BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
16 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
17 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
18 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
Christopher Ferris525ce912017-07-26 13:12:53 -070019 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
20 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
Christopher Ferris05d08e92016-02-04 13:16:38 -080021};
Christopher Ferris9584fa42019-12-09 15:36:13 -080022enum flat_binder_object_shifts {
23 FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT = 9,
24};
25enum flat_binder_object_flags {
Christopher Ferris05d08e92016-02-04 13:16:38 -080026 FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
27 FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
Christopher Ferris9584fa42019-12-09 15:36:13 -080028 FLAT_BINDER_FLAG_SCHED_POLICY_MASK = 3U << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT,
29 FLAT_BINDER_FLAG_INHERIT_RT = 0x800,
Christopher Ferrise6be5322019-03-20 15:33:33 -070030 FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000,
Christopher Ferris05d08e92016-02-04 13:16:38 -080031};
32#ifdef BINDER_IPC_32BIT
33typedef __u32 binder_size_t;
34typedef __u32 binder_uintptr_t;
Christopher Ferris05d08e92016-02-04 13:16:38 -080035#else
36typedef __u64 binder_size_t;
37typedef __u64 binder_uintptr_t;
38#endif
Christopher Ferris525ce912017-07-26 13:12:53 -070039struct binder_object_header {
Christopher Ferris05d08e92016-02-04 13:16:38 -080040 __u32 type;
Christopher Ferris525ce912017-07-26 13:12:53 -070041};
42struct flat_binder_object {
43 struct binder_object_header hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -080044 __u32 flags;
45 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -080046 binder_uintptr_t binder;
47 __u32 handle;
48 };
49 binder_uintptr_t cookie;
Christopher Ferris05d08e92016-02-04 13:16:38 -080050};
Christopher Ferris525ce912017-07-26 13:12:53 -070051struct binder_fd_object {
52 struct binder_object_header hdr;
53 __u32 pad_flags;
54 union {
55 binder_uintptr_t pad_binder;
56 __u32 fd;
57 };
58 binder_uintptr_t cookie;
59};
60struct binder_buffer_object {
61 struct binder_object_header hdr;
62 __u32 flags;
63 binder_uintptr_t buffer;
64 binder_size_t length;
65 binder_size_t parent;
66 binder_size_t parent_offset;
67};
68enum {
69 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
70};
Christopher Ferris1308ad32017-11-14 17:32:13 -080071struct binder_fd_array_object {
Christopher Ferris525ce912017-07-26 13:12:53 -070072 struct binder_object_header hdr;
Christopher Ferris1308ad32017-11-14 17:32:13 -080073 __u32 pad;
Christopher Ferris525ce912017-07-26 13:12:53 -070074 binder_size_t num_fds;
75 binder_size_t parent;
76 binder_size_t parent_offset;
77};
Christopher Ferris05d08e92016-02-04 13:16:38 -080078struct binder_write_read {
79 binder_size_t write_size;
80 binder_size_t write_consumed;
Christopher Ferris05d08e92016-02-04 13:16:38 -080081 binder_uintptr_t write_buffer;
82 binder_size_t read_size;
83 binder_size_t read_consumed;
84 binder_uintptr_t read_buffer;
Christopher Ferris05d08e92016-02-04 13:16:38 -080085};
86struct binder_version {
87 __s32 protocol_version;
88};
Christopher Ferris05d08e92016-02-04 13:16:38 -080089#ifdef BINDER_IPC_32BIT
90#define BINDER_CURRENT_PROTOCOL_VERSION 7
91#else
92#define BINDER_CURRENT_PROTOCOL_VERSION 8
Christopher Ferris05d08e92016-02-04 13:16:38 -080093#endif
Christopher Ferris1308ad32017-11-14 17:32:13 -080094struct binder_node_debug_info {
95 binder_uintptr_t ptr;
96 binder_uintptr_t cookie;
97 __u32 has_strong_ref;
98 __u32 has_weak_ref;
99};
Christopher Ferris86a48372019-01-10 14:14:59 -0800100struct binder_node_info_for_ref {
101 __u32 handle;
102 __u32 strong_count;
103 __u32 weak_count;
104 __u32 reserved1;
105 __u32 reserved2;
106 __u32 reserved3;
107};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000108struct binder_freeze_info {
109 __u32 pid;
110 __u32 enable;
111 __u32 timeout_ms;
112};
113struct binder_frozen_status_info {
114 __u32 pid;
115 __u32 sync_recv;
116 __u32 async_recv;
117};
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700118struct binder_extended_error {
119 __u32 id;
120 __u32 command;
121 __s32 param;
122};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800123#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
124#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
125#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
127#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
128#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
129#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800130#define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
Christopher Ferris86a48372019-01-10 14:14:59 -0800131#define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref)
Christopher Ferrise6be5322019-03-20 15:33:33 -0700132#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000133#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
134#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
135#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700136#define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800137enum transaction_flags {
138 TF_ONE_WAY = 0x01,
139 TF_ROOT_OBJECT = 0x04,
140 TF_STATUS_CODE = 0x08,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800141 TF_ACCEPT_FDS = 0x10,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800142 TF_CLEAR_BUF = 0x20,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700143 TF_UPDATE_TXN = 0x40,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800144};
145struct binder_transaction_data {
146 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800147 __u32 handle;
148 binder_uintptr_t ptr;
149 } target;
150 binder_uintptr_t cookie;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800151 __u32 code;
152 __u32 flags;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700153 __kernel_pid_t sender_pid;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700154 __kernel_uid32_t sender_euid;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800155 binder_size_t data_size;
156 binder_size_t offsets_size;
157 union {
158 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800159 binder_uintptr_t buffer;
160 binder_uintptr_t offsets;
161 } ptr;
162 __u8 buf[8];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800163 } data;
164};
Christopher Ferrise6be5322019-03-20 15:33:33 -0700165struct binder_transaction_data_secctx {
166 struct binder_transaction_data transaction_data;
167 binder_uintptr_t secctx;
168};
Christopher Ferris525ce912017-07-26 13:12:53 -0700169struct binder_transaction_data_sg {
170 struct binder_transaction_data transaction_data;
171 binder_size_t buffers_size;
172};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800173struct binder_ptr_cookie {
174 binder_uintptr_t ptr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800175 binder_uintptr_t cookie;
176};
177struct binder_handle_cookie {
178 __u32 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800179 binder_uintptr_t cookie;
Colin Cross4ac33222022-12-15 15:45:35 -0800180} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800181struct binder_pri_desc {
182 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800183 __u32 desc;
184};
185struct binder_pri_ptr_cookie {
186 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800187 binder_uintptr_t ptr;
188 binder_uintptr_t cookie;
189};
190enum binder_driver_return_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800191 BR_ERROR = _IOR('r', 0, __s32),
192 BR_OK = _IO('r', 1),
Christopher Ferrise6be5322019-03-20 15:33:33 -0700193 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800194 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
195 BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800196 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
197 BR_DEAD_REPLY = _IO('r', 5),
198 BR_TRANSACTION_COMPLETE = _IO('r', 6),
199 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800200 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
201 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
202 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
203 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800204 BR_NOOP = _IO('r', 12),
205 BR_SPAWN_LOOPER = _IO('r', 13),
206 BR_FINISHED = _IO('r', 14),
207 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800208 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
209 BR_FAILED_REPLY = _IO('r', 17),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000210 BR_FROZEN_REPLY = _IO('r', 18),
211 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000212 BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800213};
214enum binder_driver_command_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800215 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
216 BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
217 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
218 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800219 BC_INCREFS = _IOW('c', 4, __u32),
220 BC_ACQUIRE = _IOW('c', 5, __u32),
221 BC_RELEASE = _IOW('c', 6, __u32),
222 BC_DECREFS = _IOW('c', 7, __u32),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800223 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
224 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
225 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
226 BC_REGISTER_LOOPER = _IO('c', 11),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800227 BC_ENTER_LOOPER = _IO('c', 12),
228 BC_EXIT_LOOPER = _IO('c', 13),
229 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie),
230 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800231 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
Christopher Ferris525ce912017-07-26 13:12:53 -0700232 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
233 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800234};
235#endif