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_frozen_state_info { 119 binder_uintptr_t cookie; 120 __u32 is_frozen; 121 __u32 reserved; 122 }; 123 struct binder_extended_error { 124 __u32 id; 125 __u32 command; 126 __s32 param; 127 }; 128 enum { 129 BINDER_WRITE_READ = _IOWR('b', 1, struct binder_write_read), 130 BINDER_SET_IDLE_TIMEOUT = _IOW('b', 3, __s64), 131 BINDER_SET_MAX_THREADS = _IOW('b', 5, __u32), 132 BINDER_SET_IDLE_PRIORITY = _IOW('b', 6, __s32), 133 BINDER_SET_CONTEXT_MGR = _IOW('b', 7, __s32), 134 BINDER_THREAD_EXIT = _IOW('b', 8, __s32), 135 BINDER_VERSION = _IOWR('b', 9, struct binder_version), 136 BINDER_GET_NODE_DEBUG_INFO = _IOWR('b', 11, struct binder_node_debug_info), 137 BINDER_GET_NODE_INFO_FOR_REF = _IOWR('b', 12, struct binder_node_info_for_ref), 138 BINDER_SET_CONTEXT_MGR_EXT = _IOW('b', 13, struct flat_binder_object), 139 BINDER_FREEZE = _IOW('b', 14, struct binder_freeze_info), 140 BINDER_GET_FROZEN_INFO = _IOWR('b', 15, struct binder_frozen_status_info), 141 BINDER_ENABLE_ONEWAY_SPAM_DETECTION = _IOW('b', 16, __u32), 142 BINDER_GET_EXTENDED_ERROR = _IOWR('b', 17, struct binder_extended_error), 143 }; 144 enum transaction_flags { 145 TF_ONE_WAY = 0x01, 146 TF_ROOT_OBJECT = 0x04, 147 TF_STATUS_CODE = 0x08, 148 TF_ACCEPT_FDS = 0x10, 149 TF_CLEAR_BUF = 0x20, 150 TF_UPDATE_TXN = 0x40, 151 }; 152 struct binder_transaction_data { 153 union { 154 __u32 handle; 155 binder_uintptr_t ptr; 156 } target; 157 binder_uintptr_t cookie; 158 __u32 code; 159 __u32 flags; 160 __kernel_pid_t sender_pid; 161 __kernel_uid32_t sender_euid; 162 binder_size_t data_size; 163 binder_size_t offsets_size; 164 union { 165 struct { 166 binder_uintptr_t buffer; 167 binder_uintptr_t offsets; 168 } ptr; 169 __u8 buf[8]; 170 } data; 171 }; 172 struct binder_transaction_data_secctx { 173 struct binder_transaction_data transaction_data; 174 binder_uintptr_t secctx; 175 }; 176 struct binder_transaction_data_sg { 177 struct binder_transaction_data transaction_data; 178 binder_size_t buffers_size; 179 }; 180 struct binder_ptr_cookie { 181 binder_uintptr_t ptr; 182 binder_uintptr_t cookie; 183 }; 184 struct binder_handle_cookie { 185 __u32 handle; 186 binder_uintptr_t cookie; 187 } __attribute__((__packed__)); 188 struct binder_pri_desc { 189 __s32 priority; 190 __u32 desc; 191 }; 192 struct binder_pri_ptr_cookie { 193 __s32 priority; 194 binder_uintptr_t ptr; 195 binder_uintptr_t cookie; 196 }; 197 enum binder_driver_return_protocol { 198 BR_ERROR = _IOR('r', 0, __s32), 199 BR_OK = _IO('r', 1), 200 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx), 201 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), 202 BR_REPLY = _IOR('r', 3, struct binder_transaction_data), 203 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), 204 BR_DEAD_REPLY = _IO('r', 5), 205 BR_TRANSACTION_COMPLETE = _IO('r', 6), 206 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), 207 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), 208 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), 209 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), 210 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), 211 BR_NOOP = _IO('r', 12), 212 BR_SPAWN_LOOPER = _IO('r', 13), 213 BR_FINISHED = _IO('r', 14), 214 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), 215 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), 216 BR_FAILED_REPLY = _IO('r', 17), 217 BR_FROZEN_REPLY = _IO('r', 18), 218 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), 219 BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20), 220 BR_FROZEN_BINDER = _IOR('r', 21, struct binder_frozen_state_info), 221 BR_CLEAR_FREEZE_NOTIFICATION_DONE = _IOR('r', 22, binder_uintptr_t), 222 }; 223 enum binder_driver_command_protocol { 224 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), 225 BC_REPLY = _IOW('c', 1, struct binder_transaction_data), 226 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), 227 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), 228 BC_INCREFS = _IOW('c', 4, __u32), 229 BC_ACQUIRE = _IOW('c', 5, __u32), 230 BC_RELEASE = _IOW('c', 6, __u32), 231 BC_DECREFS = _IOW('c', 7, __u32), 232 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), 233 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), 234 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), 235 BC_REGISTER_LOOPER = _IO('c', 11), 236 BC_ENTER_LOOPER = _IO('c', 12), 237 BC_EXIT_LOOPER = _IO('c', 13), 238 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie), 239 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie), 240 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), 241 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg), 242 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg), 243 BC_REQUEST_FREEZE_NOTIFICATION = _IOW('c', 19, struct binder_handle_cookie), 244 BC_CLEAR_FREEZE_NOTIFICATION = _IOW('c', 20, struct binder_handle_cookie), 245 BC_FREEZE_NOTIFICATION_DONE = _IOW('c', 21, binder_uintptr_t), 246 }; 247 #endif 248