00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _BINDER_MODULE_H_
00014 #define _BINDER_MODULE_H_
00015
00016 #include <support/TypeConstants.h>
00017
00018 #if TARGET_HOST == TARGET_HOST_PALMOS
00019 #include <linux/types.h>
00020 #include <asm/ioctl.h>
00021 #endif
00022
00023 #ifdef __cplusplus
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace support {
00027 #endif
00028 #endif
00029
00030
00031 enum {
00032 kPackedLargeBinderType = B_PACK_LARGE_TYPE(B_BINDER_TYPE),
00033 kPackedLargeBinderWeakType = B_PACK_LARGE_TYPE(B_BINDER_WEAK_TYPE),
00034 kPackedLargeBinderHandleType = B_PACK_LARGE_TYPE(B_BINDER_HANDLE_TYPE),
00035 kPackedLargeBinderWeakHandleType = B_PACK_LARGE_TYPE(B_BINDER_WEAK_HANDLE_TYPE),
00036 kPackedLargeBinderNodeType = B_PACK_LARGE_TYPE(B_BINDER_NODE_TYPE),
00037 kPackedLargeBinderWeakNodeType = B_PACK_LARGE_TYPE(B_BINDER_WEAK_NODE_TYPE),
00038 };
00039
00040
00041 struct binder_node;
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 typedef struct flat_binder_object
00053 {
00054
00055 unsigned long type;
00056 unsigned long length;
00057
00058
00059 union {
00060 void* binder;
00061 signed long handle;
00062 struct binder_node* node;
00063 };
00064 void* cookie;
00065 } flat_binder_object_t;
00066
00067
00068
00069
00070
00071
00072 typedef struct binder_write_read {
00073 signed long write_size;
00074 signed long write_consumed;
00075 unsigned long write_buffer;
00076 signed long read_size;
00077 signed long read_consumed;
00078 unsigned long read_buffer;
00079 } binder_write_read_t;
00080
00081
00082 typedef struct binder_version {
00083 signed long protocol_version;
00084 } binder_version_t;
00085
00086
00087 #define BINDER_CURRENT_PROTOCOL_VERSION 4
00088
00089 #define BINDER_IOC_MAGIC 'b'
00090 #define BINDER_WRITE_READ _IOWR(BINDER_IOC_MAGIC, 1, binder_write_read_t)
00091 #define BINDER_SET_WAKEUP_TIME _IOW(BINDER_IOC_MAGIC, 2, binder_wakeup_time_t)
00092 #define BINDER_SET_IDLE_TIMEOUT _IOW(BINDER_IOC_MAGIC, 3, bigtime_t)
00093 #define BINDER_SET_REPLY_TIMEOUT _IOW(BINDER_IOC_MAGIC, 4, bigtime_t)
00094 #define BINDER_SET_MAX_THREADS _IOW(BINDER_IOC_MAGIC, 5, size_t)
00095 #define BINDER_SET_IDLE_PRIORITY _IOW(BINDER_IOC_MAGIC, 6, int)
00096 #define BINDER_SET_CONTEXT_MGR _IOW(BINDER_IOC_MAGIC, 7, int)
00097 #define BINDER_THREAD_EXIT _IOW(BINDER_IOC_MAGIC, 8, int)
00098 #define BINDER_VERSION _IOWR(BINDER_IOC_MAGIC, 9, binder_version_t)
00099 #define BINDER_IOC_MAXNR 9
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 typedef int64_t bigtime_t;
00115
00116 enum transaction_flags {
00117 tfInline = 0x01,
00118 tfSynchronous = 0x02,
00119 tfRootObject = 0x04,
00120 tfStatusCode = 0x08
00121 };
00122
00123 typedef struct binder_transaction_data
00124 {
00125
00126
00127 union {
00128 unsigned long handle;
00129 void *ptr;
00130 } target;
00131 unsigned int code;
00132
00133
00134 unsigned int flags;
00135 int priority;
00136 size_t data_size;
00137 size_t offsets_size;
00138
00139
00140
00141
00142 union {
00143 struct {
00144 const void *buffer;
00145 const void *offsets;
00146 } ptr;
00147 uint8_t buf[8];
00148 } data;
00149 } binder_transaction_data_t;
00150
00151 typedef struct binder_wakeup_time
00152 {
00153 bigtime_t time;
00154 int priority;
00155 } binder_wakeup_time_t;
00156
00157 enum BinderDriverReturnProtocol {
00158 brERROR = -1,
00159
00160
00161
00162
00163 brOK = 0,
00164 brTIMEOUT,
00165 brWAKEUP,
00166
00167
00168 brTRANSACTION,
00169 brREPLY,
00170
00171
00172
00173
00174 brACQUIRE_RESULT,
00175
00176
00177
00178
00179
00180 brDEAD_REPLY,
00181
00182
00183
00184
00185
00186 brTRANSACTION_COMPLETE,
00187
00188
00189
00190
00191
00192
00193 brINCREFS,
00194 brACQUIRE,
00195 brRELEASE,
00196 brDECREFS,
00197
00198
00199
00200
00201
00202 brATTEMPT_ACQUIRE,
00203
00204
00205
00206
00207
00208
00209 brEVENT_OCCURRED,
00210
00211
00212
00213
00214
00215
00216
00217 brNOOP,
00218
00219
00220
00221
00222
00223 brSPAWN_LOOPER,
00224
00225
00226
00227
00228
00229
00230
00231 brFINISHED
00232 };
00233
00234 enum BinderDriverCommandProtocol {
00235 bcNOOP = 0,
00236
00237
00238 bcTRANSACTION,
00239 bcREPLY,
00240
00241
00242
00243
00244 bcACQUIRE_RESULT,
00245
00246
00247
00248
00249
00250 bcFREE_BUFFER,
00251
00252
00253
00254
00255 bcTRANSACTION_COMPLETE,
00256
00257
00258
00259
00260 bcINCREFS,
00261 bcACQUIRE,
00262 bcRELEASE,
00263 bcDECREFS,
00264
00265
00266
00267
00268 bcINCREFS_DONE,
00269 bcACQUIRE_DONE,
00270
00271
00272
00273
00274
00275 bcATTEMPT_ACQUIRE,
00276
00277
00278
00279
00280
00281 bcRETRIEVE_ROOT_OBJECT,
00282
00283
00284
00285
00286 bcSET_THREAD_ENTRY,
00287
00288
00289
00290
00291
00292 bcREGISTER_LOOPER,
00293
00294
00295
00296
00297
00298
00299
00300 bcENTER_LOOPER,
00301 bcEXIT_LOOPER,
00302
00303
00304
00305
00306
00307
00308
00309
00310 bcSYNC,
00311
00312
00313
00314
00315
00316
00317 #if 0
00318 bcCATCH_ROOT_OBJECTS,
00319
00320
00321
00322
00323
00324
00325
00326
00327 #endif
00328
00329 bcSTOP_PROCESS,
00330
00331
00332
00333
00334
00335 bcSTOP_SELF
00336
00337
00338
00339 };
00340
00341 #if 0
00342
00343 #if BINDER_DEBUG_LIB
00344
00345 struct binder_write_read
00346 {
00347 ssize_t write_size;
00348 const void* write_buffer;
00349 ssize_t read_size;
00350 void* read_buffer;
00351 };
00352
00353
00354
00355
00356
00357 extern int open_binder(int teamID=0);
00358 extern status_t close_binder(int desc);
00359 extern status_t ioctl_binder(int desc, int cmd, void *data, int len);
00360 extern ssize_t read_binder(int desc, void *data, size_t numBytes);
00361 extern ssize_t write_binder(int desc, void *data, size_t numBytes);
00362
00363 #else
00364
00365 #include <unistd.h>
00366 inline int open_binder(int ) { return open("/dev/misc/binder2",O_RDWR|O_CLOEXEC); };
00367 inline status_t close_binder(int desc) { return close(desc); };
00368 inline status_t ioctl_binder(int desc, int cmd, void *data, int len) { return ioctl(desc,cmd,data,len); };
00369 inline ssize_t read_binder(int desc, void *data, size_t numBytes) { return read(desc,data,numBytes); };
00370 inline ssize_t write_binder(int desc, void *data, size_t numBytes) { return write(desc,data,numBytes); };
00371
00372 #endif
00373 #endif
00374
00375 #ifdef __cplusplus
00376 #if _SUPPORTS_NAMESPACE
00377 } }
00378 #endif
00379 #endif
00380
00381 #endif // _BINDER_MODULE_H_