2012-10-24 17:45:23 +00:00
|
|
|
/* Copyright 2008 The Android Open Source Project
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BINDER_H_
|
|
|
|
#define _BINDER_H_
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <linux/binder.h>
|
|
|
|
|
|
|
|
struct binder_state;
|
|
|
|
|
|
|
|
struct binder_io
|
|
|
|
{
|
|
|
|
char *data; /* pointer to read/write from */
|
2014-01-29 05:25:12 +00:00
|
|
|
binder_size_t *offs; /* array of offsets */
|
2014-01-10 15:48:29 +00:00
|
|
|
size_t data_avail; /* bytes available in data buffer */
|
|
|
|
size_t offs_avail; /* entries available in offsets array */
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
char *data0; /* start of data buffer */
|
2014-01-29 05:25:12 +00:00
|
|
|
binder_size_t *offs0; /* start of offsets buffer */
|
2012-10-24 17:45:23 +00:00
|
|
|
uint32_t flags;
|
|
|
|
uint32_t unused;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct binder_death {
|
|
|
|
void (*func)(struct binder_state *bs, void *ptr);
|
|
|
|
void *ptr;
|
2014-01-10 15:48:29 +00:00
|
|
|
};
|
2012-10-24 17:45:23 +00:00
|
|
|
|
2014-01-30 14:07:34 +00:00
|
|
|
/* the one magic handle */
|
|
|
|
#define BINDER_SERVICE_MANAGER 0U
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
#define SVC_MGR_NAME "android.os.IServiceManager"
|
|
|
|
|
|
|
|
enum {
|
2014-01-29 05:35:03 +00:00
|
|
|
/* Must match definitions in IBinder.h and IServiceManager.h */
|
|
|
|
PING_TRANSACTION = B_PACK_CHARS('_','P','N','G'),
|
2012-10-24 17:45:23 +00:00
|
|
|
SVC_MGR_GET_SERVICE = 1,
|
|
|
|
SVC_MGR_CHECK_SERVICE,
|
|
|
|
SVC_MGR_ADD_SERVICE,
|
|
|
|
SVC_MGR_LIST_SERVICES,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef int (*binder_handler)(struct binder_state *bs,
|
2014-01-10 13:56:27 +00:00
|
|
|
struct binder_transaction_data *txn,
|
2012-10-24 17:45:23 +00:00
|
|
|
struct binder_io *msg,
|
|
|
|
struct binder_io *reply);
|
|
|
|
|
2014-01-10 15:48:29 +00:00
|
|
|
struct binder_state *binder_open(size_t mapsize);
|
2012-10-24 17:45:23 +00:00
|
|
|
void binder_close(struct binder_state *bs);
|
|
|
|
|
|
|
|
/* initiate a blocking binder call
|
|
|
|
* - returns zero on success
|
|
|
|
*/
|
|
|
|
int binder_call(struct binder_state *bs,
|
|
|
|
struct binder_io *msg, struct binder_io *reply,
|
2014-01-30 14:07:34 +00:00
|
|
|
uint32_t target, uint32_t code);
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
/* release any state associate with the binder_io
|
|
|
|
* - call once any necessary data has been extracted from the
|
|
|
|
* binder_io after binder_call() returns
|
|
|
|
* - can safely be called even if binder_call() fails
|
|
|
|
*/
|
|
|
|
void binder_done(struct binder_state *bs,
|
|
|
|
struct binder_io *msg, struct binder_io *reply);
|
|
|
|
|
|
|
|
/* manipulate strong references */
|
2014-01-30 14:07:34 +00:00
|
|
|
void binder_acquire(struct binder_state *bs, uint32_t target);
|
|
|
|
void binder_release(struct binder_state *bs, uint32_t target);
|
2012-10-24 17:45:23 +00:00
|
|
|
|
2014-01-30 14:07:34 +00:00
|
|
|
void binder_link_to_death(struct binder_state *bs, uint32_t target, struct binder_death *death);
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
void binder_loop(struct binder_state *bs, binder_handler func);
|
|
|
|
|
|
|
|
int binder_become_context_manager(struct binder_state *bs);
|
|
|
|
|
|
|
|
/* allocate a binder_io, providing a stack-allocated working
|
|
|
|
* buffer, size of the working buffer, and how many object
|
|
|
|
* offset entries to reserve from the buffer
|
|
|
|
*/
|
|
|
|
void bio_init(struct binder_io *bio, void *data,
|
2014-01-10 15:48:29 +00:00
|
|
|
size_t maxdata, size_t maxobjects);
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
void bio_put_obj(struct binder_io *bio, void *ptr);
|
2014-01-30 14:07:34 +00:00
|
|
|
void bio_put_ref(struct binder_io *bio, uint32_t handle);
|
2012-10-24 17:45:23 +00:00
|
|
|
void bio_put_uint32(struct binder_io *bio, uint32_t n);
|
|
|
|
void bio_put_string16(struct binder_io *bio, const uint16_t *str);
|
|
|
|
void bio_put_string16_x(struct binder_io *bio, const char *_str);
|
|
|
|
|
|
|
|
uint32_t bio_get_uint32(struct binder_io *bio);
|
2014-01-10 15:48:29 +00:00
|
|
|
uint16_t *bio_get_string16(struct binder_io *bio, size_t *sz);
|
2014-01-30 14:07:34 +00:00
|
|
|
uint32_t bio_get_ref(struct binder_io *bio);
|
2012-10-24 17:45:23 +00:00
|
|
|
|
|
|
|
#endif
|