blob: 6e64ebc30858be28f832652bf07cf708b48b7eaa [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 Ferrisb830ddf2024-03-28 11:48:08 -0700123enum {
124 BINDER_WRITE_READ = _IOWR('b', 1, struct binder_write_read),
125 BINDER_SET_IDLE_TIMEOUT = _IOW('b', 3, __s64),
126 BINDER_SET_MAX_THREADS = _IOW('b', 5, __u32),
127 BINDER_SET_IDLE_PRIORITY = _IOW('b', 6, __s32),
128 BINDER_SET_CONTEXT_MGR = _IOW('b', 7, __s32),
129 BINDER_THREAD_EXIT = _IOW('b', 8, __s32),
130 BINDER_VERSION = _IOWR('b', 9, struct binder_version),
131 BINDER_GET_NODE_DEBUG_INFO = _IOWR('b', 11, struct binder_node_debug_info),
132 BINDER_GET_NODE_INFO_FOR_REF = _IOWR('b', 12, struct binder_node_info_for_ref),
133 BINDER_SET_CONTEXT_MGR_EXT = _IOW('b', 13, struct flat_binder_object),
134 BINDER_FREEZE = _IOW('b', 14, struct binder_freeze_info),
135 BINDER_GET_FROZEN_INFO = _IOWR('b', 15, struct binder_frozen_status_info),
136 BINDER_ENABLE_ONEWAY_SPAM_DETECTION = _IOW('b', 16, __u32),
137 BINDER_GET_EXTENDED_ERROR = _IOWR('b', 17, struct binder_extended_error),
138};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800139enum transaction_flags {
140 TF_ONE_WAY = 0x01,
141 TF_ROOT_OBJECT = 0x04,
142 TF_STATUS_CODE = 0x08,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800143 TF_ACCEPT_FDS = 0x10,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800144 TF_CLEAR_BUF = 0x20,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700145 TF_UPDATE_TXN = 0x40,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800146};
147struct binder_transaction_data {
148 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800149 __u32 handle;
150 binder_uintptr_t ptr;
151 } target;
152 binder_uintptr_t cookie;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800153 __u32 code;
154 __u32 flags;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700155 __kernel_pid_t sender_pid;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700156 __kernel_uid32_t sender_euid;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800157 binder_size_t data_size;
158 binder_size_t offsets_size;
159 union {
160 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800161 binder_uintptr_t buffer;
162 binder_uintptr_t offsets;
163 } ptr;
164 __u8 buf[8];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800165 } data;
166};
Christopher Ferrise6be5322019-03-20 15:33:33 -0700167struct binder_transaction_data_secctx {
168 struct binder_transaction_data transaction_data;
169 binder_uintptr_t secctx;
170};
Christopher Ferris525ce912017-07-26 13:12:53 -0700171struct binder_transaction_data_sg {
172 struct binder_transaction_data transaction_data;
173 binder_size_t buffers_size;
174};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800175struct binder_ptr_cookie {
176 binder_uintptr_t ptr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800177 binder_uintptr_t cookie;
178};
179struct binder_handle_cookie {
180 __u32 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800181 binder_uintptr_t cookie;
Colin Cross4ac33222022-12-15 15:45:35 -0800182} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800183struct binder_pri_desc {
184 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800185 __u32 desc;
186};
187struct binder_pri_ptr_cookie {
188 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800189 binder_uintptr_t ptr;
190 binder_uintptr_t cookie;
191};
192enum binder_driver_return_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800193 BR_ERROR = _IOR('r', 0, __s32),
194 BR_OK = _IO('r', 1),
Christopher Ferrise6be5322019-03-20 15:33:33 -0700195 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800196 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
197 BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800198 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
199 BR_DEAD_REPLY = _IO('r', 5),
200 BR_TRANSACTION_COMPLETE = _IO('r', 6),
201 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800202 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
203 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
204 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
205 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206 BR_NOOP = _IO('r', 12),
207 BR_SPAWN_LOOPER = _IO('r', 13),
208 BR_FINISHED = _IO('r', 14),
209 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800210 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
211 BR_FAILED_REPLY = _IO('r', 17),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000212 BR_FROZEN_REPLY = _IO('r', 18),
213 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000214 BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800215};
216enum binder_driver_command_protocol {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800217 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
218 BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
219 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
220 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800221 BC_INCREFS = _IOW('c', 4, __u32),
222 BC_ACQUIRE = _IOW('c', 5, __u32),
223 BC_RELEASE = _IOW('c', 6, __u32),
224 BC_DECREFS = _IOW('c', 7, __u32),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800225 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
226 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
227 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
228 BC_REGISTER_LOOPER = _IO('c', 11),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800229 BC_ENTER_LOOPER = _IO('c', 12),
230 BC_EXIT_LOOPER = _IO('c', 13),
231 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie),
232 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800233 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
Christopher Ferris525ce912017-07-26 13:12:53 -0700234 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
235 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
Christopher Ferris05d08e92016-02-04 13:16:38 -0800236};
237#endif