blob: 0d1f83d6c5ea93af9075f476db05300adabb1e2a [file] [log] [blame]
Christopher Ferris05d08e92016-02-04 13:16:38 -08001/****************************************************************************
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>
Christopher Ferris05d08e92016-02-04 13:16:38 -080023#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),
Christopher Ferris05d08e92016-02-04 13:16:38 -080027 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),
Christopher Ferris525ce912017-07-26 13:12:53 -070031 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
32 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
Christopher Ferris05d08e92016-02-04 13:16:38 -080033};
Christopher Ferris9584fa42019-12-09 15:36:13 -080034enum flat_binder_object_shifts {
35 FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT = 9,
36};
37enum flat_binder_object_flags {
Christopher Ferris05d08e92016-02-04 13:16:38 -080038 FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
39 FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
Christopher Ferris9584fa42019-12-09 15:36:13 -080040 FLAT_BINDER_FLAG_SCHED_POLICY_MASK = 3U << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT,
41 FLAT_BINDER_FLAG_INHERIT_RT = 0x800,
Christopher Ferrise6be5322019-03-20 15:33:33 -070042 FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000,
Christopher Ferris05d08e92016-02-04 13:16:38 -080043};
44#ifdef BINDER_IPC_32BIT
45typedef __u32 binder_size_t;
46typedef __u32 binder_uintptr_t;
Christopher Ferris05d08e92016-02-04 13:16:38 -080047#else
48typedef __u64 binder_size_t;
49typedef __u64 binder_uintptr_t;
50#endif
Christopher Ferris525ce912017-07-26 13:12:53 -070051struct binder_object_header {
Christopher Ferris05d08e92016-02-04 13:16:38 -080052 __u32 type;
Christopher Ferris525ce912017-07-26 13:12:53 -070053};
54struct flat_binder_object {
55 struct binder_object_header hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -080056 __u32 flags;
57 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -080058 binder_uintptr_t binder;
59 __u32 handle;
60 };
61 binder_uintptr_t cookie;
Christopher Ferris05d08e92016-02-04 13:16:38 -080062};
Christopher Ferris525ce912017-07-26 13:12:53 -070063struct binder_fd_object {
64 struct binder_object_header hdr;
65 __u32 pad_flags;
66 union {
67 binder_uintptr_t pad_binder;
68 __u32 fd;
69 };
70 binder_uintptr_t cookie;
71};
72struct binder_buffer_object {
73 struct binder_object_header hdr;
74 __u32 flags;
75 binder_uintptr_t buffer;
76 binder_size_t length;
77 binder_size_t parent;
78 binder_size_t parent_offset;
79};
80enum {
81 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
82};
Christopher Ferris1308ad32017-11-14 17:32:13 -080083struct binder_fd_array_object {
Christopher Ferris525ce912017-07-26 13:12:53 -070084 struct binder_object_header hdr;
Christopher Ferris1308ad32017-11-14 17:32:13 -080085 __u32 pad;
Christopher Ferris525ce912017-07-26 13:12:53 -070086 binder_size_t num_fds;
87 binder_size_t parent;
88 binder_size_t parent_offset;
89};
Christopher Ferris05d08e92016-02-04 13:16:38 -080090struct binder_write_read {
91 binder_size_t write_size;
92 binder_size_t write_consumed;
Christopher Ferris05d08e92016-02-04 13:16:38 -080093 binder_uintptr_t write_buffer;
94 binder_size_t read_size;
95 binder_size_t read_consumed;
96 binder_uintptr_t read_buffer;
Christopher Ferris05d08e92016-02-04 13:16:38 -080097};
98struct binder_version {
99 __s32 protocol_version;
100};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800101#ifdef BINDER_IPC_32BIT
102#define BINDER_CURRENT_PROTOCOL_VERSION 7
103#else
104#define BINDER_CURRENT_PROTOCOL_VERSION 8
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105#endif
Christopher Ferris1308ad32017-11-14 17:32:13 -0800106struct binder_node_debug_info {
107 binder_uintptr_t ptr;
108 binder_uintptr_t cookie;
109 __u32 has_strong_ref;
110 __u32 has_weak_ref;
111};
Christopher Ferris86a48372019-01-10 14:14:59 -0800112struct binder_node_info_for_ref {
113 __u32 handle;
114 __u32 strong_count;
115 __u32 weak_count;
116 __u32 reserved1;
117 __u32 reserved2;
118 __u32 reserved3;
119};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000120struct binder_freeze_info {
121 __u32 pid;
122 __u32 enable;
123 __u32 timeout_ms;
124};
125struct binder_frozen_status_info {
126 __u32 pid;
127 __u32 sync_recv;
128 __u32 async_recv;
129};
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700130struct binder_extended_error {
131 __u32 id;
132 __u32 command;
133 __s32 param;
134};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800135#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
136#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
137#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800138#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
139#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
140#define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
141#define BINDER_VERSION _IOWR('b', 9, struct binder_version)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800142#define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
Christopher Ferris86a48372019-01-10 14:14:59 -0800143#define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref)
Christopher Ferrise6be5322019-03-20 15:33:33 -0700144#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000145#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
146#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
147#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700148#define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800149enum transaction_flags {
150 TF_ONE_WAY = 0x01,
151 TF_ROOT_OBJECT = 0x04,
152 TF_STATUS_CODE = 0x08,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800153 TF_ACCEPT_FDS = 0x10,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800154 TF_CLEAR_BUF = 0x20,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700155 TF_UPDATE_TXN = 0x40,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800156};
157struct binder_transaction_data {
158 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800159 __u32 handle;
160 binder_uintptr_t ptr;
161 } target;
162 binder_uintptr_t cookie;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800163 __u32 code;
164 __u32 flags;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700165 __kernel_pid_t sender_pid;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700166 __kernel_uid32_t sender_euid;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800167 binder_size_t data_size;
168 binder_size_t offsets_size;
169 union {
170 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800171 binder_uintptr_t buffer;
172 binder_uintptr_t offsets;
173 } ptr;
174 __u8 buf[8];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800175 } data;
176};
Christopher Ferrise6be5322019-03-20 15:33:33 -0700177struct binder_transaction_data_secctx {
178 struct binder_transaction_data transaction_data;
179 binder_uintptr_t secctx;
180};
Christopher Ferris525ce912017-07-26 13:12:53 -0700181struct binder_transaction_data_sg {
182 struct binder_transaction_data transaction_data;
183 binder_size_t buffers_size;
184};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800185struct binder_ptr_cookie {
186 binder_uintptr_t ptr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800187 binder_uintptr_t cookie;
188};
189struct binder_handle_cookie {
190 __u32 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800191 binder_uintptr_t cookie;
Colin Cross4ac33222022-12-15 15:45:35 -0800192} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800193struct binder_pri_desc {
194 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800195 __u32 desc;
196};
197struct binder_pri_ptr_cookie {
198 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800199 binder_uintptr_t ptr;
200 binder_uintptr_t cookie;
201};
202enum binder_driver_return_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800203 BR_ERROR = _IOR('r', 0, __s32),
204 BR_OK = _IO('r', 1),
Christopher Ferrise6be5322019-03-20 15:33:33 -0700205 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
207 BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800208 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
209 BR_DEAD_REPLY = _IO('r', 5),
210 BR_TRANSACTION_COMPLETE = _IO('r', 6),
211 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800212 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
213 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
214 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
215 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800216 BR_NOOP = _IO('r', 12),
217 BR_SPAWN_LOOPER = _IO('r', 13),
218 BR_FINISHED = _IO('r', 14),
219 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800220 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
221 BR_FAILED_REPLY = _IO('r', 17),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000222 BR_FROZEN_REPLY = _IO('r', 18),
223 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000224 BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800225};
226enum binder_driver_command_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800227 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
228 BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
229 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
230 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800231 BC_INCREFS = _IOW('c', 4, __u32),
232 BC_ACQUIRE = _IOW('c', 5, __u32),
233 BC_RELEASE = _IOW('c', 6, __u32),
234 BC_DECREFS = _IOW('c', 7, __u32),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800235 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
236 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
237 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
238 BC_REGISTER_LOOPER = _IO('c', 11),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800239 BC_ENTER_LOOPER = _IO('c', 12),
240 BC_EXIT_LOOPER = _IO('c', 13),
241 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie),
242 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800243 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
Christopher Ferris525ce912017-07-26 13:12:53 -0700244 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
245 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800246};
247#endif