1 /* 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 */ 7 #ifndef _UAPI_LINUX_BINDER_H 8 #define _UAPI_LINUX_BINDER_H 9 #include <linux/types.h> 10 #include <linux/ioctl.h> 11 #define B_PACK_CHARS(c1,c2,c3,c4) ((((c1) << 24)) | (((c2) << 16)) | (((c3) << 8)) | (c4)) 12 #define B_TYPE_LARGE 0x85 13 enum { 14 BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), 15 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), 19 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE), 20 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE), 21 }; 22 enum flat_binder_object_shifts { 23 FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT = 9, 24 }; 25 enum flat_binder_object_flags { 26 FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, 27 FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, 28 FLAT_BINDER_FLAG_SCHED_POLICY_MASK = 3U << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT, 29 FLAT_BINDER_FLAG_INHERIT_RT = 0x800, 30 FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000, 31 }; 32 #ifdef BINDER_IPC_32BIT 33 typedef __u32 binder_size_t; 34 typedef __u32 binder_uintptr_t; 35 #else 36 typedef __u64 binder_size_t; 37 typedef __u64 binder_uintptr_t; 38 #endif 39 struct binder_object_header { 40 __u32 type; 41 }; 42 struct flat_binder_object { 43 struct binder_object_header hdr; 44 __u32 flags; 45 union { 46 binder_uintptr_t binder; 47 __u32 handle; 48 }; 49 binder_uintptr_t cookie; 50 }; 51 struct 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 }; 60 struct 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 }; 68 enum { 69 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01, 70 }; 71 struct binder_fd_array_object { 72 struct binder_object_header hdr; 73 __u32 pad; 74 binder_size_t num_fds; 75 binder_size_t parent; 76 binder_size_t parent_offset; 77 }; 78 struct 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 struct binder_version { 87 __s32 protocol_version; 88 }; 89 #ifdef BINDER_IPC_32BIT 90 #define BINDER_CURRENT_PROTOCOL_VERSION 7 91 #else 92 #define BINDER_CURRENT_PROTOCOL_VERSION 8 93 #endif 94 struct 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 }; 100 struct 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 }; 108 struct binder_freeze_info { 109 __u32 pid; 110 __u32 enable; 111 __u32 timeout_ms; 112 }; 113 struct binder_frozen_status_info { 114 __u32 pid; 115 __u32 sync_recv; 116 __u32 async_recv; 117 }; 118 struct binder_extended_error { 119 __u32 id; 120 __u32 command; 121 __s32 param; 122 }; 123 enum { 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 }; 139 enum transaction_flags { 140 TF_ONE_WAY = 0x01, 141 TF_ROOT_OBJECT = 0x04, 142 TF_STATUS_CODE = 0x08, 143 TF_ACCEPT_FDS = 0x10, 144 TF_CLEAR_BUF = 0x20, 145 TF_UPDATE_TXN = 0x40, 146 }; 147 struct binder_transaction_data { 148 union { 149 __u32 handle; 150 binder_uintptr_t ptr; 151 } target; 152 binder_uintptr_t cookie; 153 __u32 code; 154 __u32 flags; 155 __kernel_pid_t sender_pid; 156 __kernel_uid32_t sender_euid; 157 binder_size_t data_size; 158 binder_size_t offsets_size; 159 union { 160 struct { 161 binder_uintptr_t buffer; 162 binder_uintptr_t offsets; 163 } ptr; 164 __u8 buf[8]; 165 } data; 166 }; 167 struct binder_transaction_data_secctx { 168 struct binder_transaction_data transaction_data; 169 binder_uintptr_t secctx; 170 }; 171 struct binder_transaction_data_sg { 172 struct binder_transaction_data transaction_data; 173 binder_size_t buffers_size; 174 }; 175 struct binder_ptr_cookie { 176 binder_uintptr_t ptr; 177 binder_uintptr_t cookie; 178 }; 179 struct binder_handle_cookie { 180 __u32 handle; 181 binder_uintptr_t cookie; 182 } __attribute__((__packed__)); 183 struct binder_pri_desc { 184 __s32 priority; 185 __u32 desc; 186 }; 187 struct binder_pri_ptr_cookie { 188 __s32 priority; 189 binder_uintptr_t ptr; 190 binder_uintptr_t cookie; 191 }; 192 enum binder_driver_return_protocol { 193 BR_ERROR = _IOR('r', 0, __s32), 194 BR_OK = _IO('r', 1), 195 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx), 196 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), 197 BR_REPLY = _IOR('r', 3, struct binder_transaction_data), 198 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), 202 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), 206 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), 210 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), 211 BR_FAILED_REPLY = _IO('r', 17), 212 BR_FROZEN_REPLY = _IO('r', 18), 213 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), 214 BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20), 215 }; 216 enum binder_driver_command_protocol { 217 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), 221 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), 225 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), 229 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), 233 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), 234 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg), 235 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg), 236 }; 237 #endif 238