| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2008 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef _BINDER_MODULE_H_ | 
|  | 18 | #define _BINDER_MODULE_H_ | 
|  | 19 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | /* obtain structures and constants from the kernel header */ | 
|  | 21 |  | 
| Steven Moreland | 28723ae | 2019-04-01 18:52:30 -0700 | [diff] [blame] | 22 | // TODO(b/31559095): bionic on host | 
| Steven Moreland | ed3b563 | 2019-09-20 11:24:28 -0700 | [diff] [blame] | 23 | #ifndef __ANDROID__ | 
| Steven Moreland | 28723ae | 2019-04-01 18:52:30 -0700 | [diff] [blame] | 24 | #define __packed __attribute__((__packed__)) | 
|  | 25 | #endif | 
|  | 26 |  | 
|  | 27 | // TODO(b/31559095): bionic on host | 
|  | 28 | #if defined(B_PACK_CHARS) && !defined(_UAPI_LINUX_BINDER_H) | 
|  | 29 | #undef B_PACK_CHARS | 
|  | 30 | #endif | 
|  | 31 |  | 
| Christopher Ferris | 0170cd0 | 2016-07-18 16:57:34 -0700 | [diff] [blame] | 32 | #include <linux/android/binder.h> | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 33 | #include <sys/ioctl.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 |  | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 35 | #ifndef BR_FROZEN_REPLY | 
|  | 36 | // Temporary definition of BR_FROZEN_REPLY. For production | 
|  | 37 | // this will come from UAPI binder.h | 
|  | 38 | #define BR_FROZEN_REPLY _IO('r', 18) | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 39 | #endif // BR_FROZEN_REPLY | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 40 |  | 
|  | 41 | #ifndef BINDER_FREEZE | 
|  | 42 | /* | 
|  | 43 | * Temporary definitions for freeze support. For the final version | 
|  | 44 | * these will be defined in the UAPI binder.h file from upstream kernel. | 
|  | 45 | */ | 
|  | 46 | #define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info) | 
|  | 47 |  | 
|  | 48 | struct binder_freeze_info { | 
|  | 49 | // | 
|  | 50 | // Group-leader PID of process to be frozen | 
|  | 51 | // | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 52 | uint32_t pid; | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 53 | // | 
|  | 54 | // Enable(1) / Disable(0) freeze for given PID | 
|  | 55 | // | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 56 | uint32_t enable; | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 57 | // | 
|  | 58 | // Timeout to wait for transactions to drain. | 
|  | 59 | // 0: don't wait (ioctl will return EAGAIN if not drained) | 
|  | 60 | // N: number of ms to wait | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 61 | uint32_t timeout_ms; | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 62 | }; | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 63 | #endif // BINDER_FREEZE | 
| Marco Ballesio | 7ee1757 | 2020-09-08 10:30:03 -0700 | [diff] [blame] | 64 |  | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 65 | #ifndef BINDER_GET_FROZEN_INFO | 
|  | 66 |  | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 67 | #define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info) | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 68 |  | 
|  | 69 | struct binder_frozen_status_info { | 
|  | 70 | // | 
|  | 71 | // Group-leader PID of process to be queried | 
|  | 72 | // | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 73 | __u32 pid; | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 74 | // | 
|  | 75 | // Indicates whether the process has received any sync calls since last | 
|  | 76 | // freeze (cleared at freeze/unfreeze) | 
| Li Li | 6f05929 | 2021-09-10 09:59:30 -0700 | [diff] [blame] | 77 | // bit 0: received sync transaction after being frozen | 
|  | 78 | // bit 1: new pending sync transaction during freezing | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 79 | // | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 80 | __u32 sync_recv; | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 81 | // | 
|  | 82 | // Indicates whether the process has received any async calls since last | 
|  | 83 | // freeze (cleared at freeze/unfreeze) | 
|  | 84 | // | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 85 | __u32 async_recv; | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 86 | }; | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 87 | #endif // BINDER_GET_FROZEN_INFO | 
| Marco Ballesio | b09fc4a | 2020-09-11 16:17:21 -0700 | [diff] [blame] | 88 |  | 
| Hang Lu | b185ac0 | 2021-03-24 13:17:22 +0800 | [diff] [blame] | 89 | #ifndef BR_ONEWAY_SPAM_SUSPECT | 
|  | 90 | // Temporary definition of BR_ONEWAY_SPAM_SUSPECT. For production | 
|  | 91 | // this will come from UAPI binder.h | 
|  | 92 | #define BR_ONEWAY_SPAM_SUSPECT _IO('r', 19) | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 93 | #endif // BR_ONEWAY_SPAM_SUSPECT | 
| Hang Lu | b185ac0 | 2021-03-24 13:17:22 +0800 | [diff] [blame] | 94 |  | 
|  | 95 | #ifndef BINDER_ENABLE_ONEWAY_SPAM_DETECTION | 
|  | 96 | /* | 
|  | 97 | * Temporary definitions for oneway spam detection support. For the final version | 
|  | 98 | * these will be defined in the UAPI binder.h file from upstream kernel. | 
|  | 99 | */ | 
|  | 100 | #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) | 
| Steven Moreland | 6ba5a25 | 2021-05-04 22:49:00 +0000 | [diff] [blame] | 101 | #endif // BINDER_ENABLE_ONEWAY_SPAM_DETECTION | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 |  | 
| Carlos Llamas | b235b12 | 2021-12-20 06:38:44 -0800 | [diff] [blame] | 103 | #ifndef BINDER_GET_EXTENDED_ERROR | 
|  | 104 | /* struct binder_extened_error - extended error information | 
|  | 105 | * @id:      identifier for the failed operation | 
|  | 106 | * @command: command as defined by binder_driver_return_protocol | 
|  | 107 | * @param:   parameter holding a negative errno value | 
|  | 108 | * | 
|  | 109 | * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information | 
|  | 110 | * returned by the driver upon a failed operation. Userspace can pull this | 
|  | 111 | * data to properly handle specific error scenarios. | 
|  | 112 | */ | 
|  | 113 | struct binder_extended_error { | 
|  | 114 | __u32 id; | 
|  | 115 | __u32 command; | 
|  | 116 | __s32 param; | 
|  | 117 | }; | 
|  | 118 |  | 
|  | 119 | #define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error) | 
|  | 120 | #endif // BINDER_GET_EXTENDED_ERROR | 
|  | 121 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | #endif // _BINDER_MODULE_H_ |