1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| void binder_loop(struct binder_state *bs, binder_handler func){ ...... readbuf[0] = BC_ENTER_LOOPER; binder_write(bs, readbuf, sizeof(uint32_t)); ...... for (;;) { ...... res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr); ...... res = binder_parse(bs, 0, (uintptr_t) readbuf, bwr.read_consumed,func); ...... } ...... }
int binder_write(struct binder_state *bs, void *data, size_t len){ struct binder_write_read bwr; ...... bwr.write_buffer = (uintptr_t) data; ...... res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr); ...... return res; }
static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg){ ...... void __user *ubuf = (void __user *)arg; ...... switch (cmd) case BINDER_WRITE_READ: struct binder_write_read bwr; copy_from_user(&bwr, ubuf, sizeof(bwr)) ...... if (bwr.write_size > 0) { ret = binder_thread_write(proc, thread, (void __user*)bwr.write_buffer, bwr.write_size, &bwr.write_consumed); } ...... copy_to_user(ubuf, &bwr, sizeof(bwr)) ...... }
|