1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2777783e0SGreg Kroah-Hartman /* 3777783e0SGreg Kroah-Hartman * Copyright (C) 2008 Google, Inc. 4777783e0SGreg Kroah-Hartman * 5777783e0SGreg Kroah-Hartman * Based on, but no longer compatible with, the original 6777783e0SGreg Kroah-Hartman * OpenBinder.org binder driver interface, which is: 7777783e0SGreg Kroah-Hartman * 8777783e0SGreg Kroah-Hartman * Copyright (c) 2005 Palmsource, Inc. 9777783e0SGreg Kroah-Hartman * 10777783e0SGreg Kroah-Hartman * This software is licensed under the terms of the GNU General Public 11777783e0SGreg Kroah-Hartman * License version 2, as published by the Free Software Foundation, and 12777783e0SGreg Kroah-Hartman * may be copied, distributed, and modified under those terms. 13777783e0SGreg Kroah-Hartman * 14777783e0SGreg Kroah-Hartman * This program is distributed in the hope that it will be useful, 15777783e0SGreg Kroah-Hartman * but WITHOUT ANY WARRANTY; without even the implied warranty of 16777783e0SGreg Kroah-Hartman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17777783e0SGreg Kroah-Hartman * GNU General Public License for more details. 18777783e0SGreg Kroah-Hartman * 19777783e0SGreg Kroah-Hartman */ 20777783e0SGreg Kroah-Hartman 21777783e0SGreg Kroah-Hartman #ifndef _UAPI_LINUX_BINDER_H 22777783e0SGreg Kroah-Hartman #define _UAPI_LINUX_BINDER_H 23777783e0SGreg Kroah-Hartman 24bc2d62a0SGreg Kroah-Hartman #include <linux/types.h> 25777783e0SGreg Kroah-Hartman #include <linux/ioctl.h> 26777783e0SGreg Kroah-Hartman 27777783e0SGreg Kroah-Hartman #define B_PACK_CHARS(c1, c2, c3, c4) \ 28777783e0SGreg Kroah-Hartman ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) 29777783e0SGreg Kroah-Hartman #define B_TYPE_LARGE 0x85 30777783e0SGreg Kroah-Hartman 31777783e0SGreg Kroah-Hartman enum { 32777783e0SGreg Kroah-Hartman BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), 33777783e0SGreg Kroah-Hartman BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), 34777783e0SGreg Kroah-Hartman BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), 35777783e0SGreg Kroah-Hartman BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), 36777783e0SGreg Kroah-Hartman BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), 37def95c73SMartijn Coenen BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE), 387980240bSMartijn Coenen BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE), 39777783e0SGreg Kroah-Hartman }; 40777783e0SGreg Kroah-Hartman 41777783e0SGreg Kroah-Hartman enum { 42777783e0SGreg Kroah-Hartman FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, 43777783e0SGreg Kroah-Hartman FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, 44ec74136dSTodd Kjos 45ec74136dSTodd Kjos /** 46ec74136dSTodd Kjos * @FLAT_BINDER_FLAG_TXN_SECURITY_CTX: request security contexts 47ec74136dSTodd Kjos * 48ec74136dSTodd Kjos * Only when set, causes senders to include their security 49ec74136dSTodd Kjos * context 50ec74136dSTodd Kjos */ 51ec74136dSTodd Kjos FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000, 52777783e0SGreg Kroah-Hartman }; 53777783e0SGreg Kroah-Hartman 54777783e0SGreg Kroah-Hartman #ifdef BINDER_IPC_32BIT 55777783e0SGreg Kroah-Hartman typedef __u32 binder_size_t; 56777783e0SGreg Kroah-Hartman typedef __u32 binder_uintptr_t; 57777783e0SGreg Kroah-Hartman #else 58777783e0SGreg Kroah-Hartman typedef __u64 binder_size_t; 59777783e0SGreg Kroah-Hartman typedef __u64 binder_uintptr_t; 60777783e0SGreg Kroah-Hartman #endif 61777783e0SGreg Kroah-Hartman 62feba3900SMartijn Coenen /** 63feba3900SMartijn Coenen * struct binder_object_header - header shared by all binder metadata objects. 64feba3900SMartijn Coenen * @type: type of the object 65feba3900SMartijn Coenen */ 66feba3900SMartijn Coenen struct binder_object_header { 67feba3900SMartijn Coenen __u32 type; 68feba3900SMartijn Coenen }; 69feba3900SMartijn Coenen 70777783e0SGreg Kroah-Hartman /* 71777783e0SGreg Kroah-Hartman * This is the flattened representation of a Binder object for transfer 72777783e0SGreg Kroah-Hartman * between processes. The 'offsets' supplied as part of a binder transaction 73777783e0SGreg Kroah-Hartman * contains offsets into the data where these structures occur. The Binder 74777783e0SGreg Kroah-Hartman * driver takes care of re-writing the structure type and data as it moves 75777783e0SGreg Kroah-Hartman * between processes. 76777783e0SGreg Kroah-Hartman */ 77777783e0SGreg Kroah-Hartman struct flat_binder_object { 78feba3900SMartijn Coenen struct binder_object_header hdr; 79777783e0SGreg Kroah-Hartman __u32 flags; 80777783e0SGreg Kroah-Hartman 81777783e0SGreg Kroah-Hartman /* 8 bytes of data. */ 82777783e0SGreg Kroah-Hartman union { 83777783e0SGreg Kroah-Hartman binder_uintptr_t binder; /* local object */ 84777783e0SGreg Kroah-Hartman __u32 handle; /* remote object */ 85777783e0SGreg Kroah-Hartman }; 86777783e0SGreg Kroah-Hartman 87777783e0SGreg Kroah-Hartman /* extra data associated with local object */ 88777783e0SGreg Kroah-Hartman binder_uintptr_t cookie; 89777783e0SGreg Kroah-Hartman }; 90777783e0SGreg Kroah-Hartman 91feba3900SMartijn Coenen /** 92feba3900SMartijn Coenen * struct binder_fd_object - describes a filedescriptor to be fixed up. 93feba3900SMartijn Coenen * @hdr: common header structure 94feba3900SMartijn Coenen * @pad_flags: padding to remain compatible with old userspace code 95feba3900SMartijn Coenen * @pad_binder: padding to remain compatible with old userspace code 96feba3900SMartijn Coenen * @fd: file descriptor 97feba3900SMartijn Coenen * @cookie: opaque data, used by user-space 98feba3900SMartijn Coenen */ 99feba3900SMartijn Coenen struct binder_fd_object { 100feba3900SMartijn Coenen struct binder_object_header hdr; 101feba3900SMartijn Coenen __u32 pad_flags; 102feba3900SMartijn Coenen union { 103feba3900SMartijn Coenen binder_uintptr_t pad_binder; 104feba3900SMartijn Coenen __u32 fd; 105feba3900SMartijn Coenen }; 106feba3900SMartijn Coenen 107feba3900SMartijn Coenen binder_uintptr_t cookie; 108feba3900SMartijn Coenen }; 1097980240bSMartijn Coenen 1107980240bSMartijn Coenen /* struct binder_buffer_object - object describing a userspace buffer 1117980240bSMartijn Coenen * @hdr: common header structure 1127980240bSMartijn Coenen * @flags: one or more BINDER_BUFFER_* flags 1137980240bSMartijn Coenen * @buffer: address of the buffer 1147980240bSMartijn Coenen * @length: length of the buffer 1157980240bSMartijn Coenen * @parent: index in offset array pointing to parent buffer 1167980240bSMartijn Coenen * @parent_offset: offset in @parent pointing to this buffer 1177980240bSMartijn Coenen * 1187980240bSMartijn Coenen * A binder_buffer object represents an object that the 1197980240bSMartijn Coenen * binder kernel driver can copy verbatim to the target 1207980240bSMartijn Coenen * address space. A buffer itself may be pointed to from 1217980240bSMartijn Coenen * within another buffer, meaning that the pointer inside 1227980240bSMartijn Coenen * that other buffer needs to be fixed up as well. This 1237980240bSMartijn Coenen * can be done by setting the BINDER_BUFFER_FLAG_HAS_PARENT 1247980240bSMartijn Coenen * flag in @flags, by setting @parent buffer to the index 1257980240bSMartijn Coenen * in the offset array pointing to the parent binder_buffer_object, 1267980240bSMartijn Coenen * and by setting @parent_offset to the offset in the parent buffer 1277980240bSMartijn Coenen * at which the pointer to this buffer is located. 1287980240bSMartijn Coenen */ 1297980240bSMartijn Coenen struct binder_buffer_object { 1307980240bSMartijn Coenen struct binder_object_header hdr; 1317980240bSMartijn Coenen __u32 flags; 1327980240bSMartijn Coenen binder_uintptr_t buffer; 1337980240bSMartijn Coenen binder_size_t length; 1347980240bSMartijn Coenen binder_size_t parent; 1357980240bSMartijn Coenen binder_size_t parent_offset; 1367980240bSMartijn Coenen }; 1377980240bSMartijn Coenen 1387980240bSMartijn Coenen enum { 1397980240bSMartijn Coenen BINDER_BUFFER_FLAG_HAS_PARENT = 0x01, 1407980240bSMartijn Coenen }; 1417980240bSMartijn Coenen 142def95c73SMartijn Coenen /* struct binder_fd_array_object - object describing an array of fds in a buffer 143def95c73SMartijn Coenen * @hdr: common header structure 1445cdcf4c6SMartijn Coenen * @pad: padding to ensure correct alignment 145def95c73SMartijn Coenen * @num_fds: number of file descriptors in the buffer 146def95c73SMartijn Coenen * @parent: index in offset array to buffer holding the fd array 147def95c73SMartijn Coenen * @parent_offset: start offset of fd array in the buffer 148def95c73SMartijn Coenen * 149def95c73SMartijn Coenen * A binder_fd_array object represents an array of file 150def95c73SMartijn Coenen * descriptors embedded in a binder_buffer_object. It is 151def95c73SMartijn Coenen * different from a regular binder_buffer_object because it 152def95c73SMartijn Coenen * describes a list of file descriptors to fix up, not an opaque 153def95c73SMartijn Coenen * blob of memory, and hence the kernel needs to treat it differently. 154def95c73SMartijn Coenen * 155def95c73SMartijn Coenen * An example of how this would be used is with Android's 156def95c73SMartijn Coenen * native_handle_t object, which is a struct with a list of integers 157def95c73SMartijn Coenen * and a list of file descriptors. The native_handle_t struct itself 158def95c73SMartijn Coenen * will be represented by a struct binder_buffer_objct, whereas the 159def95c73SMartijn Coenen * embedded list of file descriptors is represented by a 160def95c73SMartijn Coenen * struct binder_fd_array_object with that binder_buffer_object as 161def95c73SMartijn Coenen * a parent. 162def95c73SMartijn Coenen */ 163def95c73SMartijn Coenen struct binder_fd_array_object { 164def95c73SMartijn Coenen struct binder_object_header hdr; 1655cdcf4c6SMartijn Coenen __u32 pad; 166def95c73SMartijn Coenen binder_size_t num_fds; 167def95c73SMartijn Coenen binder_size_t parent; 168def95c73SMartijn Coenen binder_size_t parent_offset; 169def95c73SMartijn Coenen }; 170def95c73SMartijn Coenen 171777783e0SGreg Kroah-Hartman /* 172777783e0SGreg Kroah-Hartman * On 64-bit platforms where user code may run in 32-bits the driver must 173777783e0SGreg Kroah-Hartman * translate the buffer (and local binder) addresses appropriately. 174777783e0SGreg Kroah-Hartman */ 175777783e0SGreg Kroah-Hartman 176777783e0SGreg Kroah-Hartman struct binder_write_read { 177777783e0SGreg Kroah-Hartman binder_size_t write_size; /* bytes to write */ 178777783e0SGreg Kroah-Hartman binder_size_t write_consumed; /* bytes consumed by driver */ 179777783e0SGreg Kroah-Hartman binder_uintptr_t write_buffer; 180777783e0SGreg Kroah-Hartman binder_size_t read_size; /* bytes to read */ 181777783e0SGreg Kroah-Hartman binder_size_t read_consumed; /* bytes consumed by driver */ 182777783e0SGreg Kroah-Hartman binder_uintptr_t read_buffer; 183777783e0SGreg Kroah-Hartman }; 184777783e0SGreg Kroah-Hartman 185777783e0SGreg Kroah-Hartman /* Use with BINDER_VERSION, driver fills in fields. */ 186777783e0SGreg Kroah-Hartman struct binder_version { 187777783e0SGreg Kroah-Hartman /* driver protocol version -- increment with incompatible change */ 188777783e0SGreg Kroah-Hartman __s32 protocol_version; 189777783e0SGreg Kroah-Hartman }; 190777783e0SGreg Kroah-Hartman 191777783e0SGreg Kroah-Hartman /* This is the current protocol version. */ 192777783e0SGreg Kroah-Hartman #ifdef BINDER_IPC_32BIT 193777783e0SGreg Kroah-Hartman #define BINDER_CURRENT_PROTOCOL_VERSION 7 194777783e0SGreg Kroah-Hartman #else 195777783e0SGreg Kroah-Hartman #define BINDER_CURRENT_PROTOCOL_VERSION 8 196777783e0SGreg Kroah-Hartman #endif 197777783e0SGreg Kroah-Hartman 198abcc6153SColin Cross /* 199abcc6153SColin Cross * Use with BINDER_GET_NODE_DEBUG_INFO, driver reads ptr, writes to all fields. 200abcc6153SColin Cross * Set ptr to NULL for the first call to get the info for the first node, and 201abcc6153SColin Cross * then repeat the call passing the previously returned value to get the next 202abcc6153SColin Cross * nodes. ptr will be 0 when there are no more nodes. 203abcc6153SColin Cross */ 204abcc6153SColin Cross struct binder_node_debug_info { 205abcc6153SColin Cross binder_uintptr_t ptr; 206abcc6153SColin Cross binder_uintptr_t cookie; 207abcc6153SColin Cross __u32 has_strong_ref; 208abcc6153SColin Cross __u32 has_weak_ref; 209abcc6153SColin Cross }; 210abcc6153SColin Cross 211b7e6a896SMartijn Coenen struct binder_node_info_for_ref { 212b7e6a896SMartijn Coenen __u32 handle; 213b7e6a896SMartijn Coenen __u32 strong_count; 214b7e6a896SMartijn Coenen __u32 weak_count; 215b7e6a896SMartijn Coenen __u32 reserved1; 216b7e6a896SMartijn Coenen __u32 reserved2; 217b7e6a896SMartijn Coenen __u32 reserved3; 218b7e6a896SMartijn Coenen }; 219b7e6a896SMartijn Coenen 220432ff1e9SMarco Ballesio struct binder_freeze_info { 221432ff1e9SMarco Ballesio __u32 pid; 222432ff1e9SMarco Ballesio __u32 enable; 223432ff1e9SMarco Ballesio __u32 timeout_ms; 224432ff1e9SMarco Ballesio }; 225432ff1e9SMarco Ballesio 226ae28c1beSMarco Ballesio struct binder_frozen_status_info { 227ae28c1beSMarco Ballesio __u32 pid; 228b564171aSLi Li 229b564171aSLi Li /* process received sync transactions since last frozen 230b564171aSLi Li * bit 0: received sync transaction after being frozen 231b564171aSLi Li * bit 1: new pending sync transaction during freezing 232b564171aSLi Li */ 233ae28c1beSMarco Ballesio __u32 sync_recv; 234b564171aSLi Li 235b564171aSLi Li /* process received async transactions since last frozen */ 236ae28c1beSMarco Ballesio __u32 async_recv; 237ae28c1beSMarco Ballesio }; 238ae28c1beSMarco Ballesio 239*d579b04aSYu-Ting Tseng struct binder_frozen_state_info { 240*d579b04aSYu-Ting Tseng binder_uintptr_t cookie; 241*d579b04aSYu-Ting Tseng __u32 is_frozen; 242*d579b04aSYu-Ting Tseng __u32 reserved; 243*d579b04aSYu-Ting Tseng }; 244*d579b04aSYu-Ting Tseng 245bd32889eSCarlos Llamas /* struct binder_extened_error - extended error information 246bd32889eSCarlos Llamas * @id: identifier for the failed operation 247bd32889eSCarlos Llamas * @command: command as defined by binder_driver_return_protocol 248bd32889eSCarlos Llamas * @param: parameter holding a negative errno value 249bd32889eSCarlos Llamas * 250bd32889eSCarlos Llamas * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information 251bd32889eSCarlos Llamas * returned by the driver upon a failed operation. Userspace can pull this 252bd32889eSCarlos Llamas * data to properly handle specific error scenarios. 253bd32889eSCarlos Llamas */ 254bd32889eSCarlos Llamas struct binder_extended_error { 255bd32889eSCarlos Llamas __u32 id; 256bd32889eSCarlos Llamas __u32 command; 257bd32889eSCarlos Llamas __s32 param; 258bd32889eSCarlos Llamas }; 259bd32889eSCarlos Llamas 2603634783bSAlice Ryhl enum { 2613634783bSAlice Ryhl BINDER_WRITE_READ = _IOWR('b', 1, struct binder_write_read), 2623634783bSAlice Ryhl BINDER_SET_IDLE_TIMEOUT = _IOW('b', 3, __s64), 2633634783bSAlice Ryhl BINDER_SET_MAX_THREADS = _IOW('b', 5, __u32), 2643634783bSAlice Ryhl BINDER_SET_IDLE_PRIORITY = _IOW('b', 6, __s32), 2653634783bSAlice Ryhl BINDER_SET_CONTEXT_MGR = _IOW('b', 7, __s32), 2663634783bSAlice Ryhl BINDER_THREAD_EXIT = _IOW('b', 8, __s32), 2673634783bSAlice Ryhl BINDER_VERSION = _IOWR('b', 9, struct binder_version), 2683634783bSAlice Ryhl BINDER_GET_NODE_DEBUG_INFO = _IOWR('b', 11, struct binder_node_debug_info), 2693634783bSAlice Ryhl BINDER_GET_NODE_INFO_FOR_REF = _IOWR('b', 12, struct binder_node_info_for_ref), 2703634783bSAlice Ryhl BINDER_SET_CONTEXT_MGR_EXT = _IOW('b', 13, struct flat_binder_object), 2713634783bSAlice Ryhl BINDER_FREEZE = _IOW('b', 14, struct binder_freeze_info), 2723634783bSAlice Ryhl BINDER_GET_FROZEN_INFO = _IOWR('b', 15, struct binder_frozen_status_info), 2733634783bSAlice Ryhl BINDER_ENABLE_ONEWAY_SPAM_DETECTION = _IOW('b', 16, __u32), 2743634783bSAlice Ryhl BINDER_GET_EXTENDED_ERROR = _IOWR('b', 17, struct binder_extended_error), 2753634783bSAlice Ryhl }; 276777783e0SGreg Kroah-Hartman 277777783e0SGreg Kroah-Hartman /* 278777783e0SGreg Kroah-Hartman * NOTE: Two special error codes you should check for when calling 279777783e0SGreg Kroah-Hartman * in to the driver are: 280777783e0SGreg Kroah-Hartman * 281777783e0SGreg Kroah-Hartman * EINTR -- The operation has been interupted. This should be 282777783e0SGreg Kroah-Hartman * handled by retrying the ioctl() until a different error code 283777783e0SGreg Kroah-Hartman * is returned. 284777783e0SGreg Kroah-Hartman * 285777783e0SGreg Kroah-Hartman * ECONNREFUSED -- The driver is no longer accepting operations 286777783e0SGreg Kroah-Hartman * from your process. That is, the process is being destroyed. 287777783e0SGreg Kroah-Hartman * You should handle this by exiting from your process. Note 288777783e0SGreg Kroah-Hartman * that once this error code is returned, all further calls to 289777783e0SGreg Kroah-Hartman * the driver from any thread will return this same code. 290777783e0SGreg Kroah-Hartman */ 291777783e0SGreg Kroah-Hartman 292777783e0SGreg Kroah-Hartman enum transaction_flags { 293777783e0SGreg Kroah-Hartman TF_ONE_WAY = 0x01, /* this is a one-way call: async, no return */ 294777783e0SGreg Kroah-Hartman TF_ROOT_OBJECT = 0x04, /* contents are the component's root object */ 295777783e0SGreg Kroah-Hartman TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ 296777783e0SGreg Kroah-Hartman TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ 2970f966cbaSTodd Kjos TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */ 2989864bb48SLi Li TF_UPDATE_TXN = 0x40, /* update the outdated pending async txn */ 299777783e0SGreg Kroah-Hartman }; 300777783e0SGreg Kroah-Hartman 301777783e0SGreg Kroah-Hartman struct binder_transaction_data { 302777783e0SGreg Kroah-Hartman /* The first two are only used for bcTRANSACTION and brTRANSACTION, 303777783e0SGreg Kroah-Hartman * identifying the target and contents of the transaction. 304777783e0SGreg Kroah-Hartman */ 305777783e0SGreg Kroah-Hartman union { 306777783e0SGreg Kroah-Hartman /* target descriptor of command transaction */ 307777783e0SGreg Kroah-Hartman __u32 handle; 308777783e0SGreg Kroah-Hartman /* target descriptor of return transaction */ 309777783e0SGreg Kroah-Hartman binder_uintptr_t ptr; 310777783e0SGreg Kroah-Hartman } target; 311777783e0SGreg Kroah-Hartman binder_uintptr_t cookie; /* target object cookie */ 312777783e0SGreg Kroah-Hartman __u32 code; /* transaction command */ 313777783e0SGreg Kroah-Hartman 314777783e0SGreg Kroah-Hartman /* General information about the transaction. */ 315777783e0SGreg Kroah-Hartman __u32 flags; 316169adc2bSMasahiro Yamada __kernel_pid_t sender_pid; 3178cc5b032SCarlos Llamas __kernel_uid32_t sender_euid; 318777783e0SGreg Kroah-Hartman binder_size_t data_size; /* number of bytes of data */ 319777783e0SGreg Kroah-Hartman binder_size_t offsets_size; /* number of bytes of offsets */ 320777783e0SGreg Kroah-Hartman 321777783e0SGreg Kroah-Hartman /* If this transaction is inline, the data immediately 322777783e0SGreg Kroah-Hartman * follows here; otherwise, it ends with a pointer to 323777783e0SGreg Kroah-Hartman * the data buffer. 324777783e0SGreg Kroah-Hartman */ 325777783e0SGreg Kroah-Hartman union { 326777783e0SGreg Kroah-Hartman struct { 327777783e0SGreg Kroah-Hartman /* transaction data */ 328777783e0SGreg Kroah-Hartman binder_uintptr_t buffer; 329777783e0SGreg Kroah-Hartman /* offsets from buffer to flat_binder_object structs */ 330777783e0SGreg Kroah-Hartman binder_uintptr_t offsets; 331777783e0SGreg Kroah-Hartman } ptr; 332777783e0SGreg Kroah-Hartman __u8 buf[8]; 333777783e0SGreg Kroah-Hartman } data; 334777783e0SGreg Kroah-Hartman }; 335777783e0SGreg Kroah-Hartman 336ec74136dSTodd Kjos struct binder_transaction_data_secctx { 337ec74136dSTodd Kjos struct binder_transaction_data transaction_data; 338ec74136dSTodd Kjos binder_uintptr_t secctx; 339ec74136dSTodd Kjos }; 340ec74136dSTodd Kjos 3417980240bSMartijn Coenen struct binder_transaction_data_sg { 3427980240bSMartijn Coenen struct binder_transaction_data transaction_data; 3437980240bSMartijn Coenen binder_size_t buffers_size; 3447980240bSMartijn Coenen }; 3457980240bSMartijn Coenen 346777783e0SGreg Kroah-Hartman struct binder_ptr_cookie { 347777783e0SGreg Kroah-Hartman binder_uintptr_t ptr; 348777783e0SGreg Kroah-Hartman binder_uintptr_t cookie; 349777783e0SGreg Kroah-Hartman }; 350777783e0SGreg Kroah-Hartman 351777783e0SGreg Kroah-Hartman struct binder_handle_cookie { 352777783e0SGreg Kroah-Hartman __u32 handle; 353777783e0SGreg Kroah-Hartman binder_uintptr_t cookie; 354777783e0SGreg Kroah-Hartman } __packed; 355777783e0SGreg Kroah-Hartman 356777783e0SGreg Kroah-Hartman struct binder_pri_desc { 357777783e0SGreg Kroah-Hartman __s32 priority; 358777783e0SGreg Kroah-Hartman __u32 desc; 359777783e0SGreg Kroah-Hartman }; 360777783e0SGreg Kroah-Hartman 361777783e0SGreg Kroah-Hartman struct binder_pri_ptr_cookie { 362777783e0SGreg Kroah-Hartman __s32 priority; 363777783e0SGreg Kroah-Hartman binder_uintptr_t ptr; 364777783e0SGreg Kroah-Hartman binder_uintptr_t cookie; 365777783e0SGreg Kroah-Hartman }; 366777783e0SGreg Kroah-Hartman 367777783e0SGreg Kroah-Hartman enum binder_driver_return_protocol { 368777783e0SGreg Kroah-Hartman BR_ERROR = _IOR('r', 0, __s32), 369777783e0SGreg Kroah-Hartman /* 370777783e0SGreg Kroah-Hartman * int: error code 371777783e0SGreg Kroah-Hartman */ 372777783e0SGreg Kroah-Hartman 373777783e0SGreg Kroah-Hartman BR_OK = _IO('r', 1), 374777783e0SGreg Kroah-Hartman /* No parameters! */ 375777783e0SGreg Kroah-Hartman 376ec74136dSTodd Kjos BR_TRANSACTION_SEC_CTX = _IOR('r', 2, 377ec74136dSTodd Kjos struct binder_transaction_data_secctx), 378ec74136dSTodd Kjos /* 379ec74136dSTodd Kjos * binder_transaction_data_secctx: the received command. 380ec74136dSTodd Kjos */ 381777783e0SGreg Kroah-Hartman BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), 382777783e0SGreg Kroah-Hartman BR_REPLY = _IOR('r', 3, struct binder_transaction_data), 383777783e0SGreg Kroah-Hartman /* 384777783e0SGreg Kroah-Hartman * binder_transaction_data: the received command. 385777783e0SGreg Kroah-Hartman */ 386777783e0SGreg Kroah-Hartman 387777783e0SGreg Kroah-Hartman BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), 388777783e0SGreg Kroah-Hartman /* 389777783e0SGreg Kroah-Hartman * not currently supported 390777783e0SGreg Kroah-Hartman * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. 391777783e0SGreg Kroah-Hartman * Else the remote object has acquired a primary reference. 392777783e0SGreg Kroah-Hartman */ 393777783e0SGreg Kroah-Hartman 394777783e0SGreg Kroah-Hartman BR_DEAD_REPLY = _IO('r', 5), 395777783e0SGreg Kroah-Hartman /* 396777783e0SGreg Kroah-Hartman * The target of the last transaction (either a bcTRANSACTION or 397777783e0SGreg Kroah-Hartman * a bcATTEMPT_ACQUIRE) is no longer with us. No parameters. 398777783e0SGreg Kroah-Hartman */ 399777783e0SGreg Kroah-Hartman 400777783e0SGreg Kroah-Hartman BR_TRANSACTION_COMPLETE = _IO('r', 6), 401777783e0SGreg Kroah-Hartman /* 402777783e0SGreg Kroah-Hartman * No parameters... always refers to the last transaction requested 403777783e0SGreg Kroah-Hartman * (including replies). Note that this will be sent even for 404777783e0SGreg Kroah-Hartman * asynchronous transactions. 405777783e0SGreg Kroah-Hartman */ 406777783e0SGreg Kroah-Hartman 407777783e0SGreg Kroah-Hartman BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), 408777783e0SGreg Kroah-Hartman BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), 409777783e0SGreg Kroah-Hartman BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), 410777783e0SGreg Kroah-Hartman BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), 411777783e0SGreg Kroah-Hartman /* 412777783e0SGreg Kroah-Hartman * void *: ptr to binder 413777783e0SGreg Kroah-Hartman * void *: cookie for binder 414777783e0SGreg Kroah-Hartman */ 415777783e0SGreg Kroah-Hartman 416777783e0SGreg Kroah-Hartman BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), 417777783e0SGreg Kroah-Hartman /* 418777783e0SGreg Kroah-Hartman * not currently supported 419777783e0SGreg Kroah-Hartman * int: priority 420777783e0SGreg Kroah-Hartman * void *: ptr to binder 421777783e0SGreg Kroah-Hartman * void *: cookie for binder 422777783e0SGreg Kroah-Hartman */ 423777783e0SGreg Kroah-Hartman 424777783e0SGreg Kroah-Hartman BR_NOOP = _IO('r', 12), 425777783e0SGreg Kroah-Hartman /* 426777783e0SGreg Kroah-Hartman * No parameters. Do nothing and examine the next command. It exists 427777783e0SGreg Kroah-Hartman * primarily so that we can replace it with a BR_SPAWN_LOOPER command. 428777783e0SGreg Kroah-Hartman */ 429777783e0SGreg Kroah-Hartman 430777783e0SGreg Kroah-Hartman BR_SPAWN_LOOPER = _IO('r', 13), 431777783e0SGreg Kroah-Hartman /* 432777783e0SGreg Kroah-Hartman * No parameters. The driver has determined that a process has no 433777783e0SGreg Kroah-Hartman * threads waiting to service incoming transactions. When a process 434777783e0SGreg Kroah-Hartman * receives this command, it must spawn a new service thread and 435777783e0SGreg Kroah-Hartman * register it via bcENTER_LOOPER. 436777783e0SGreg Kroah-Hartman */ 437777783e0SGreg Kroah-Hartman 438777783e0SGreg Kroah-Hartman BR_FINISHED = _IO('r', 14), 439777783e0SGreg Kroah-Hartman /* 440777783e0SGreg Kroah-Hartman * not currently supported 441777783e0SGreg Kroah-Hartman * stop threadpool thread 442777783e0SGreg Kroah-Hartman */ 443777783e0SGreg Kroah-Hartman 444777783e0SGreg Kroah-Hartman BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), 445777783e0SGreg Kroah-Hartman /* 446777783e0SGreg Kroah-Hartman * void *: cookie 447777783e0SGreg Kroah-Hartman */ 448777783e0SGreg Kroah-Hartman BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), 449777783e0SGreg Kroah-Hartman /* 450777783e0SGreg Kroah-Hartman * void *: cookie 451777783e0SGreg Kroah-Hartman */ 452777783e0SGreg Kroah-Hartman 453777783e0SGreg Kroah-Hartman BR_FAILED_REPLY = _IO('r', 17), 454777783e0SGreg Kroah-Hartman /* 4551859f4ebSRandy Dunlap * The last transaction (either a bcTRANSACTION or 456777783e0SGreg Kroah-Hartman * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory). No parameters. 457777783e0SGreg Kroah-Hartman */ 458432ff1e9SMarco Ballesio 459432ff1e9SMarco Ballesio BR_FROZEN_REPLY = _IO('r', 18), 460432ff1e9SMarco Ballesio /* 4610567461aSLi Li * The target of the last sync transaction (either a bcTRANSACTION or 462432ff1e9SMarco Ballesio * a bcATTEMPT_ACQUIRE) is frozen. No parameters. 463432ff1e9SMarco Ballesio */ 464a7dc1e6fSHang Lu 465a7dc1e6fSHang Lu BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), 466a7dc1e6fSHang Lu /* 467a7dc1e6fSHang Lu * Current process sent too many oneway calls to target, and the last 468a7dc1e6fSHang Lu * asynchronous transaction makes the allocated async buffer size exceed 469a7dc1e6fSHang Lu * detection threshold. No parameters. 470a7dc1e6fSHang Lu */ 4710567461aSLi Li 4720567461aSLi Li BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20), 4730567461aSLi Li /* 4740567461aSLi Li * The target of the last async transaction is frozen. No parameters. 4750567461aSLi Li */ 476*d579b04aSYu-Ting Tseng 477*d579b04aSYu-Ting Tseng BR_FROZEN_BINDER = _IOR('r', 21, struct binder_frozen_state_info), 478*d579b04aSYu-Ting Tseng /* 479*d579b04aSYu-Ting Tseng * The cookie and a boolean (is_frozen) that indicates whether the process 480*d579b04aSYu-Ting Tseng * transitioned into a frozen or an unfrozen state. 481*d579b04aSYu-Ting Tseng */ 482*d579b04aSYu-Ting Tseng 483*d579b04aSYu-Ting Tseng BR_CLEAR_FREEZE_NOTIFICATION_DONE = _IOR('r', 22, binder_uintptr_t), 484*d579b04aSYu-Ting Tseng /* 485*d579b04aSYu-Ting Tseng * void *: cookie 486*d579b04aSYu-Ting Tseng */ 487777783e0SGreg Kroah-Hartman }; 488777783e0SGreg Kroah-Hartman 489777783e0SGreg Kroah-Hartman enum binder_driver_command_protocol { 490777783e0SGreg Kroah-Hartman BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), 491777783e0SGreg Kroah-Hartman BC_REPLY = _IOW('c', 1, struct binder_transaction_data), 492777783e0SGreg Kroah-Hartman /* 493777783e0SGreg Kroah-Hartman * binder_transaction_data: the sent command. 494777783e0SGreg Kroah-Hartman */ 495777783e0SGreg Kroah-Hartman 496777783e0SGreg Kroah-Hartman BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), 497777783e0SGreg Kroah-Hartman /* 498777783e0SGreg Kroah-Hartman * not currently supported 499777783e0SGreg Kroah-Hartman * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. 500777783e0SGreg Kroah-Hartman * Else you have acquired a primary reference on the object. 501777783e0SGreg Kroah-Hartman */ 502777783e0SGreg Kroah-Hartman 503777783e0SGreg Kroah-Hartman BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), 504777783e0SGreg Kroah-Hartman /* 505777783e0SGreg Kroah-Hartman * void *: ptr to transaction data received on a read 506777783e0SGreg Kroah-Hartman */ 507777783e0SGreg Kroah-Hartman 508777783e0SGreg Kroah-Hartman BC_INCREFS = _IOW('c', 4, __u32), 509777783e0SGreg Kroah-Hartman BC_ACQUIRE = _IOW('c', 5, __u32), 510777783e0SGreg Kroah-Hartman BC_RELEASE = _IOW('c', 6, __u32), 511777783e0SGreg Kroah-Hartman BC_DECREFS = _IOW('c', 7, __u32), 512777783e0SGreg Kroah-Hartman /* 513777783e0SGreg Kroah-Hartman * int: descriptor 514777783e0SGreg Kroah-Hartman */ 515777783e0SGreg Kroah-Hartman 516777783e0SGreg Kroah-Hartman BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), 517777783e0SGreg Kroah-Hartman BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), 518777783e0SGreg Kroah-Hartman /* 519777783e0SGreg Kroah-Hartman * void *: ptr to binder 520777783e0SGreg Kroah-Hartman * void *: cookie for binder 521777783e0SGreg Kroah-Hartman */ 522777783e0SGreg Kroah-Hartman 523777783e0SGreg Kroah-Hartman BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), 524777783e0SGreg Kroah-Hartman /* 525777783e0SGreg Kroah-Hartman * not currently supported 526777783e0SGreg Kroah-Hartman * int: priority 527777783e0SGreg Kroah-Hartman * int: descriptor 528777783e0SGreg Kroah-Hartman */ 529777783e0SGreg Kroah-Hartman 530777783e0SGreg Kroah-Hartman BC_REGISTER_LOOPER = _IO('c', 11), 531777783e0SGreg Kroah-Hartman /* 532777783e0SGreg Kroah-Hartman * No parameters. 533777783e0SGreg Kroah-Hartman * Register a spawned looper thread with the device. 534777783e0SGreg Kroah-Hartman */ 535777783e0SGreg Kroah-Hartman 536777783e0SGreg Kroah-Hartman BC_ENTER_LOOPER = _IO('c', 12), 537777783e0SGreg Kroah-Hartman BC_EXIT_LOOPER = _IO('c', 13), 538777783e0SGreg Kroah-Hartman /* 539777783e0SGreg Kroah-Hartman * No parameters. 540777783e0SGreg Kroah-Hartman * These two commands are sent as an application-level thread 541777783e0SGreg Kroah-Hartman * enters and exits the binder loop, respectively. They are 542777783e0SGreg Kroah-Hartman * used so the binder can have an accurate count of the number 543777783e0SGreg Kroah-Hartman * of looping threads it has available. 544777783e0SGreg Kroah-Hartman */ 545777783e0SGreg Kroah-Hartman 546777783e0SGreg Kroah-Hartman BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, 547777783e0SGreg Kroah-Hartman struct binder_handle_cookie), 548777783e0SGreg Kroah-Hartman /* 549777783e0SGreg Kroah-Hartman * int: handle 550777783e0SGreg Kroah-Hartman * void *: cookie 551777783e0SGreg Kroah-Hartman */ 552777783e0SGreg Kroah-Hartman 553777783e0SGreg Kroah-Hartman BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, 554777783e0SGreg Kroah-Hartman struct binder_handle_cookie), 555777783e0SGreg Kroah-Hartman /* 556777783e0SGreg Kroah-Hartman * int: handle 557777783e0SGreg Kroah-Hartman * void *: cookie 558777783e0SGreg Kroah-Hartman */ 559777783e0SGreg Kroah-Hartman 560777783e0SGreg Kroah-Hartman BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), 561777783e0SGreg Kroah-Hartman /* 562777783e0SGreg Kroah-Hartman * void *: cookie 563777783e0SGreg Kroah-Hartman */ 5647980240bSMartijn Coenen 5657980240bSMartijn Coenen BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg), 5667980240bSMartijn Coenen BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg), 5677980240bSMartijn Coenen /* 5687980240bSMartijn Coenen * binder_transaction_data_sg: the sent command. 5697980240bSMartijn Coenen */ 570*d579b04aSYu-Ting Tseng 571*d579b04aSYu-Ting Tseng BC_REQUEST_FREEZE_NOTIFICATION = 572*d579b04aSYu-Ting Tseng _IOW('c', 19, struct binder_handle_cookie), 573*d579b04aSYu-Ting Tseng /* 574*d579b04aSYu-Ting Tseng * int: handle 575*d579b04aSYu-Ting Tseng * void *: cookie 576*d579b04aSYu-Ting Tseng */ 577*d579b04aSYu-Ting Tseng 578*d579b04aSYu-Ting Tseng BC_CLEAR_FREEZE_NOTIFICATION = _IOW('c', 20, 579*d579b04aSYu-Ting Tseng struct binder_handle_cookie), 580*d579b04aSYu-Ting Tseng /* 581*d579b04aSYu-Ting Tseng * int: handle 582*d579b04aSYu-Ting Tseng * void *: cookie 583*d579b04aSYu-Ting Tseng */ 584*d579b04aSYu-Ting Tseng 585*d579b04aSYu-Ting Tseng BC_FREEZE_NOTIFICATION_DONE = _IOW('c', 21, binder_uintptr_t), 586*d579b04aSYu-Ting Tseng /* 587*d579b04aSYu-Ting Tseng * void *: cookie 588*d579b04aSYu-Ting Tseng */ 589777783e0SGreg Kroah-Hartman }; 590777783e0SGreg Kroah-Hartman 591777783e0SGreg Kroah-Hartman #endif /* _UAPI_LINUX_BINDER_H */ 592777783e0SGreg Kroah-Hartman 593