0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef _UAPI_LINUX_BINDER_H
0022 #define _UAPI_LINUX_BINDER_H
0023
0024 #include <linux/types.h>
0025 #include <linux/ioctl.h>
0026
0027 #define B_PACK_CHARS(c1, c2, c3, c4) \
0028 ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
0029 #define B_TYPE_LARGE 0x85
0030
0031 enum {
0032 BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE),
0033 BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE),
0034 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
0035 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
0036 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
0037 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
0038 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
0039 };
0040
0041 enum {
0042 FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
0043 FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
0044
0045
0046
0047
0048
0049
0050
0051 FLAT_BINDER_FLAG_TXN_SECURITY_CTX = 0x1000,
0052 };
0053
0054 #ifdef BINDER_IPC_32BIT
0055 typedef __u32 binder_size_t;
0056 typedef __u32 binder_uintptr_t;
0057 #else
0058 typedef __u64 binder_size_t;
0059 typedef __u64 binder_uintptr_t;
0060 #endif
0061
0062
0063
0064
0065
0066 struct binder_object_header {
0067 __u32 type;
0068 };
0069
0070
0071
0072
0073
0074
0075
0076
0077 struct flat_binder_object {
0078 struct binder_object_header hdr;
0079 __u32 flags;
0080
0081
0082 union {
0083 binder_uintptr_t binder;
0084 __u32 handle;
0085 };
0086
0087
0088 binder_uintptr_t cookie;
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 struct binder_fd_object {
0100 struct binder_object_header hdr;
0101 __u32 pad_flags;
0102 union {
0103 binder_uintptr_t pad_binder;
0104 __u32 fd;
0105 };
0106
0107 binder_uintptr_t cookie;
0108 };
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 struct binder_buffer_object {
0130 struct binder_object_header hdr;
0131 __u32 flags;
0132 binder_uintptr_t buffer;
0133 binder_size_t length;
0134 binder_size_t parent;
0135 binder_size_t parent_offset;
0136 };
0137
0138 enum {
0139 BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
0140 };
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163 struct binder_fd_array_object {
0164 struct binder_object_header hdr;
0165 __u32 pad;
0166 binder_size_t num_fds;
0167 binder_size_t parent;
0168 binder_size_t parent_offset;
0169 };
0170
0171
0172
0173
0174
0175
0176 struct binder_write_read {
0177 binder_size_t write_size;
0178 binder_size_t write_consumed;
0179 binder_uintptr_t write_buffer;
0180 binder_size_t read_size;
0181 binder_size_t read_consumed;
0182 binder_uintptr_t read_buffer;
0183 };
0184
0185
0186 struct binder_version {
0187
0188 __s32 protocol_version;
0189 };
0190
0191
0192 #ifdef BINDER_IPC_32BIT
0193 #define BINDER_CURRENT_PROTOCOL_VERSION 7
0194 #else
0195 #define BINDER_CURRENT_PROTOCOL_VERSION 8
0196 #endif
0197
0198
0199
0200
0201
0202
0203
0204 struct binder_node_debug_info {
0205 binder_uintptr_t ptr;
0206 binder_uintptr_t cookie;
0207 __u32 has_strong_ref;
0208 __u32 has_weak_ref;
0209 };
0210
0211 struct binder_node_info_for_ref {
0212 __u32 handle;
0213 __u32 strong_count;
0214 __u32 weak_count;
0215 __u32 reserved1;
0216 __u32 reserved2;
0217 __u32 reserved3;
0218 };
0219
0220 struct binder_freeze_info {
0221 __u32 pid;
0222 __u32 enable;
0223 __u32 timeout_ms;
0224 };
0225
0226 struct binder_frozen_status_info {
0227 __u32 pid;
0228
0229
0230
0231
0232
0233 __u32 sync_recv;
0234
0235
0236 __u32 async_recv;
0237 };
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248 struct binder_extended_error {
0249 __u32 id;
0250 __u32 command;
0251 __s32 param;
0252 };
0253
0254 #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
0255 #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
0256 #define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
0257 #define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32)
0258 #define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32)
0259 #define BINDER_THREAD_EXIT _IOW('b', 8, __s32)
0260 #define BINDER_VERSION _IOWR('b', 9, struct binder_version)
0261 #define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
0262 #define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref)
0263 #define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
0264 #define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
0265 #define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
0266 #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
0267 #define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error)
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284 enum transaction_flags {
0285 TF_ONE_WAY = 0x01,
0286 TF_ROOT_OBJECT = 0x04,
0287 TF_STATUS_CODE = 0x08,
0288 TF_ACCEPT_FDS = 0x10,
0289 TF_CLEAR_BUF = 0x20,
0290 TF_UPDATE_TXN = 0x40,
0291 };
0292
0293 struct binder_transaction_data {
0294
0295
0296
0297 union {
0298
0299 __u32 handle;
0300
0301 binder_uintptr_t ptr;
0302 } target;
0303 binder_uintptr_t cookie;
0304 __u32 code;
0305
0306
0307 __u32 flags;
0308 __kernel_pid_t sender_pid;
0309 __kernel_uid32_t sender_euid;
0310 binder_size_t data_size;
0311 binder_size_t offsets_size;
0312
0313
0314
0315
0316
0317 union {
0318 struct {
0319
0320 binder_uintptr_t buffer;
0321
0322 binder_uintptr_t offsets;
0323 } ptr;
0324 __u8 buf[8];
0325 } data;
0326 };
0327
0328 struct binder_transaction_data_secctx {
0329 struct binder_transaction_data transaction_data;
0330 binder_uintptr_t secctx;
0331 };
0332
0333 struct binder_transaction_data_sg {
0334 struct binder_transaction_data transaction_data;
0335 binder_size_t buffers_size;
0336 };
0337
0338 struct binder_ptr_cookie {
0339 binder_uintptr_t ptr;
0340 binder_uintptr_t cookie;
0341 };
0342
0343 struct binder_handle_cookie {
0344 __u32 handle;
0345 binder_uintptr_t cookie;
0346 } __packed;
0347
0348 struct binder_pri_desc {
0349 __s32 priority;
0350 __u32 desc;
0351 };
0352
0353 struct binder_pri_ptr_cookie {
0354 __s32 priority;
0355 binder_uintptr_t ptr;
0356 binder_uintptr_t cookie;
0357 };
0358
0359 enum binder_driver_return_protocol {
0360 BR_ERROR = _IOR('r', 0, __s32),
0361
0362
0363
0364
0365 BR_OK = _IO('r', 1),
0366
0367
0368 BR_TRANSACTION_SEC_CTX = _IOR('r', 2,
0369 struct binder_transaction_data_secctx),
0370
0371
0372
0373 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data),
0374 BR_REPLY = _IOR('r', 3, struct binder_transaction_data),
0375
0376
0377
0378
0379 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32),
0380
0381
0382
0383
0384
0385
0386 BR_DEAD_REPLY = _IO('r', 5),
0387
0388
0389
0390
0391
0392 BR_TRANSACTION_COMPLETE = _IO('r', 6),
0393
0394
0395
0396
0397
0398
0399 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie),
0400 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie),
0401 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie),
0402 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie),
0403
0404
0405
0406
0407
0408 BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie),
0409
0410
0411
0412
0413
0414
0415
0416 BR_NOOP = _IO('r', 12),
0417
0418
0419
0420
0421
0422 BR_SPAWN_LOOPER = _IO('r', 13),
0423
0424
0425
0426
0427
0428
0429
0430 BR_FINISHED = _IO('r', 14),
0431
0432
0433
0434
0435
0436 BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t),
0437
0438
0439
0440 BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t),
0441
0442
0443
0444
0445 BR_FAILED_REPLY = _IO('r', 17),
0446
0447
0448
0449
0450
0451 BR_FROZEN_REPLY = _IO('r', 18),
0452
0453
0454
0455
0456
0457 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19),
0458
0459
0460
0461
0462
0463 };
0464
0465 enum binder_driver_command_protocol {
0466 BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
0467 BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
0468
0469
0470
0471
0472 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32),
0473
0474
0475
0476
0477
0478
0479 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t),
0480
0481
0482
0483
0484 BC_INCREFS = _IOW('c', 4, __u32),
0485 BC_ACQUIRE = _IOW('c', 5, __u32),
0486 BC_RELEASE = _IOW('c', 6, __u32),
0487 BC_DECREFS = _IOW('c', 7, __u32),
0488
0489
0490
0491
0492 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie),
0493 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie),
0494
0495
0496
0497
0498
0499 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc),
0500
0501
0502
0503
0504
0505
0506 BC_REGISTER_LOOPER = _IO('c', 11),
0507
0508
0509
0510
0511
0512 BC_ENTER_LOOPER = _IO('c', 12),
0513 BC_EXIT_LOOPER = _IO('c', 13),
0514
0515
0516
0517
0518
0519
0520
0521
0522 BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14,
0523 struct binder_handle_cookie),
0524
0525
0526
0527
0528
0529 BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15,
0530 struct binder_handle_cookie),
0531
0532
0533
0534
0535
0536 BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t),
0537
0538
0539
0540
0541 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
0542 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
0543
0544
0545
0546 };
0547
0548 #endif
0549