• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #ifdef __cplusplus
21 namespace android {
22 #endif
23 
24 #if defined(HAVE_ANDROID_OS)
25 
26 /* obtain structures and constants from the kernel header */
27 
28 #include <sys/ioctl.h>
29 #include <linux/binder.h>
30 
31 #else
32 
33 /* Some parts of the simulator need fake versions of this
34  * stuff in order to compile.  Really this should go away
35  * entirely...
36  */
37 
38 #define BINDER_CURRENT_PROTOCOL_VERSION 7
39 
40 #define BINDER_TYPE_BINDER 1
41 #define BINDER_TYPE_WEAK_BINDER 2
42 #define BINDER_TYPE_HANDLE 3
43 #define BINDER_TYPE_WEAK_HANDLE 4
44 #define BINDER_TYPE_FD 5
45 
46 struct flat_binder_object {
47     unsigned long type;
48     unsigned long flags;
49     union {
50         void *binder;
51         signed long handle;
52     };
53     void *cookie;
54 };
55 
56 struct binder_write_read {
57     signed long write_size;
58     signed long write_consumed;
59     unsigned long write_buffer;
60     signed long read_size;
61     signed long read_consumed;
62     unsigned long read_buffer;
63 };
64 
65 struct binder_transaction_data {
66     union {
67         size_t handle;
68         void *ptr;
69     } target;
70     void *cookie;
71     unsigned int code;
72 
73     unsigned int flags;
74     pid_t sender_pid;
75     uid_t sender_euid;
76     size_t data_size;
77     size_t offsets_size;
78 
79     union {
80         struct {
81             const void *buffer;
82             const void *offsets;
83         } ptr;
84         uint8_t buf[8];
85     } data;
86 };
87 
88 enum transaction_flags {
89     TF_ONE_WAY = 0x01,
90     TF_ROOT_OBJECT = 0x04,
91     TF_STATUS_CODE = 0x08,
92     TF_ACCEPT_FDS = 0x10,
93 };
94 
95 
96 enum {
97     FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
98     FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
99 };
100 
101 enum BinderDriverReturnProtocol {
102     BR_ERROR,
103     BR_OK,
104     BR_TRANSACTION,
105     BR_REPLY,
106     BR_ACQUIRE_RESULT,
107     BR_DEAD_REPLY,
108     BR_TRANSACTION_COMPLETE,
109     BR_INCREFS,
110     BR_ACQUIRE,
111     BR_RELEASE,
112     BR_DECREFS,
113     BR_ATTEMPT_ACQUIRE,
114     BR_NOOP,
115     BR_SPAWN_LOOPER,
116     BR_FINISHED,
117     BR_DEAD_BINDER,
118     BR_CLEAR_DEATH_NOTIFICATION_DONE,
119     BR_FAILED_REPLY,
120 };
121 
122 enum BinderDriverCommandProtocol {
123     BC_TRANSACTION,
124     BC_REPLY,
125     BC_ACQUIRE_RESULT,
126     BC_FREE_BUFFER,
127     BC_INCREFS,
128     BC_ACQUIRE,
129     BC_RELEASE,
130     BC_DECREFS,
131     BC_INCREFS_DONE,
132     BC_ACQUIRE_DONE,
133     BC_ATTEMPT_ACQUIRE,
134     BC_REGISTER_LOOPER,
135     BC_ENTER_LOOPER,
136     BC_EXIT_LOOPER,
137     BC_REQUEST_DEATH_NOTIFICATION,
138     BC_CLEAR_DEATH_NOTIFICATION,
139     BC_DEAD_BINDER_DONE,
140 };
141 
142 #endif
143 
144 #ifdef __cplusplus
145 }   // namespace android
146 #endif
147 
148 #endif // _BINDER_MODULE_H_
149