一、用户空间宏
1. 用户空间code相关宏
class IBinder : public virtual RefBase //binder/IBinder.h { public: enum { /* binder服务函数code从1开始 */ FIRST_CALL_TRANSACTION = 0x00000001, LAST_CALL_TRANSACTION = 0x00ffffff, /* binder系统的code */ PING_TRANSACTION = 0x5f504e47 DUMP_TRANSACTION = 0x5f444d50 SHELL_COMMAND_TRANSACTION = 0x5f434d44 INTERFACE_TRANSACTION = 0x5f4e5446 INTERFACE_TRANSACTION2 = 0x5f4e5447 SYSPROPS_TRANSACTION = 0x5f535052 EXTENSION_TRANSACTION = 0x5f455854 DEBUG_PID_TRANSACTION = 0x5f504944 TWEET_TRANSACTION = 0x5f545754 LIKE_TRANSACTION = 0x5f4c494b }; ... }
二、内核空间宏
1. 直接宏定义的
enum { BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), //0x73622a85=sb*+85 BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), //0x77622a85 BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), //0x73682a85 BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), //0x77682a85 BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), //0x66642a85 BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE), //0x66646185 BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE), //0x70742a85 }; #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) //0xc0306201 #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) //0x40086203 #define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) //0x40046205 #define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) //0x40046206 #define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) //0x40046207 #define BINDER_THREAD_EXIT _IOW('b', 8, __s32) //0x40046208 #define BINDER_VERSION _IOWR('b', 9, struct binder_version) //0xc0046209 #define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info) //0xc018620b #define BINDER_GET_NODE_INFO_FOR_REF _IOWR('b', 12, struct binder_node_info_for_ref) //0xc018620c #define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object) //0x4018620d #define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info) //0x400c620e #define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info) //0xc00c620f #define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32) //0x40046210
2. binder_driver_return_protocol
enum binder_driver_return_protocol { BR_ERROR = _IOR('r', 0, __s32), //0x80047200 BR_OK = _IO('r', 1), //0x7201 BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx), //0x80487202 BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), //0x80407202 BR_REPLY = _IOR('r', 3, struct binder_transaction_data), //0x80407203 BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), //0x80047204 BR_DEAD_REPLY = _IO('r', 5), //0x7205 BR_TRANSACTION_COMPLETE = _IO('r', 6), //0x7206 BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), //0x80107207 BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), //0x80107208 BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), //0x80107209 BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), //0x8010720a BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), //0x8018720b BR_NOOP = _IO('r', 12), //0x720c BR_SPAWN_LOOPER = _IO('r', 13), //0x720d BR_FINISHED = _IO('r', 14), //0x720e BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), //0x8008720f BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), //0x80087210 BR_FAILED_REPLY = _IO('r', 17), //0x7211 BR_FROZEN_REPLY = _IO('r', 18), //0x7212 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), //0x7213 };
3 binder_driver_command_protocol
enum binder_driver_command_protocol { BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), //0x40406300 BC_REPLY = _IOW('c', 1, struct binder_transaction_data), //0x40406301 BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), //0x40046302 BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), //0x40086303 BC_INCREFS = _IOW('c', 4, __u32), //0x40046304 BC_ACQUIRE = _IOW('c', 5, __u32), //0x40046305 BC_RELEASE = _IOW('c', 6, __u32), //0x40046306 BC_DECREFS = _IOW('c', 7, __u32), //0x40046307 BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), //0x40106308 BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), //0x40106309 BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), //0x4008630a BC_REGISTER_LOOPER = _IO('c', 11), //0x630b BC_ENTER_LOOPER = _IO('c', 12), //0x630c BC_EXIT_LOOPER = _IO('c', 13), //0x630d BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie), //0x400c630e BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie), //0x400c630f BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), //0x40086310 BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg), //0x40486311 BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg), //0x40486312 };
三、打印函数
1. 用户空间打印函数
#include <stdio.h> #define B_PACK_CHARS(c1, c2, c3, c4) ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) enum { FIRST_CALL_TRANSACTION = 0x00000001, LAST_CALL_TRANSACTION = 0x00ffffff, PING_TRANSACTION = B_PACK_CHARS('_', 'P', 'N', 'G'), DUMP_TRANSACTION = B_PACK_CHARS('_', 'D', 'M', 'P'), SHELL_COMMAND_TRANSACTION = B_PACK_CHARS('_', 'C', 'M', 'D'), INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'), INTERFACE_TRANSACTION2 = B_PACK_CHARS('_', 'N', 'T', 'F') + 1, SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'), EXTENSION_TRANSACTION = B_PACK_CHARS('_', 'E', 'X', 'T'), DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'), TWEET_TRANSACTION = B_PACK_CHARS('_', 'T', 'W', 'T'), LIKE_TRANSACTION = B_PACK_CHARS('_', 'L', 'I', 'K'), }; void main() { printf("PING_TRANSACTION = 0x%x\n \ DUMP_TRANSACTION = 0x%x\n \ SHELL_COMMAND_TRANSACTION = 0x%x\n \ INTERFACE_TRANSACTION = 0x%x\n \ INTERFACE_TRANSACTION2 = 0x%x\n \ SYSPROPS_TRANSACTION = 0x%x\n \ EXTENSION_TRANSACTION = 0x%x\n \ DEBUG_PID_TRANSACTION = 0x%x\n \ TWEET_TRANSACTION = 0x%x\n \ LIKE_TRANSACTION = 0x%x\n", PING_TRANSACTION, DUMP_TRANSACTION, SHELL_COMMAND_TRANSACTION, INTERFACE_TRANSACTION, INTERFACE_TRANSACTION2, SYSPROPS_TRANSACTION, EXTENSION_TRANSACTION, DEBUG_PID_TRANSACTION, TWEET_TRANSACTION, LIKE_TRANSACTION ); }
2. 内核空间打印函数
static void dump_binder_cmd_val(void) { printk("BINDER_TYPE_BINDER=0x%x, BINDER_TYPE_WEAK_BINDER=0x%x, BINDER_TYPE_HANDLE=0x%x, BINDER_TYPE_WEAK_HANDLE=0x%x, \ BINDER_TYPE_FD=0x%x, BINDER_TYPE_FDA=0x%x, BINDER_TYPE_PTR=0x%x\n", BINDER_TYPE_BINDER, BINDER_TYPE_WEAK_BINDER, BINDER_TYPE_HANDLE, BINDER_TYPE_WEAK_HANDLE, BINDER_TYPE_FD, BINDER_TYPE_FDA, BINDER_TYPE_PTR); printk("BINDER_WRITE_READ=0x%x, BINDER_SET_IDLE_TIMEOUT=0x%x, BINDER_SET_MAX_THREADS=0x%x, BINDER_SET_IDLE_PRIORITY=0x%x, \ BINDER_SET_CONTEXT_MGR=0x%x, BINDER_THREAD_EXIT=0x%x, BINDER_VERSION=0x%x, BINDER_GET_NODE_DEBUG_INFO=0x%x, BINDER_GET_NODE_INFO_FOR_REF=0x%x, BINDER_SET_CONTEXT_MGR_EXT=0x%x, BINDER_FREEZE=0x%x, BINDER_GET_FROZEN_INFO=0x%x, \ BINDER_ENABLE_ONEWAY_SPAM_DETECTION=0x%x\n", BINDER_WRITE_READ, BINDER_SET_IDLE_TIMEOUT, BINDER_SET_MAX_THREADS, BINDER_SET_IDLE_PRIORITY, BINDER_SET_CONTEXT_MGR, BINDER_THREAD_EXIT, BINDER_VERSION, BINDER_GET_NODE_DEBUG_INFO, BINDER_GET_NODE_INFO_FOR_REF, BINDER_SET_CONTEXT_MGR_EXT, BINDER_FREEZE, BINDER_GET_FROZEN_INFO, \ BINDER_ENABLE_ONEWAY_SPAM_DETECTION); printk("BR_ERROR=0x%x, BR_OK=0x%x, BR_TRANSACTION_SEC_CTX=0x%x, BR_TRANSACTION=0x%x, \ BR_REPLY=0x%x, BR_ACQUIRE_RESULT=0x%x, BR_DEAD_REPLY=0x%x, BR_TRANSACTION_COMPLETE=0x%x, \ BR_INCREFS=0x%x, BR_ACQUIRE=0x%x, BR_RELEASE=0x%x, BR_DECREFS=0x%x, \ BR_ATTEMPT_ACQUIRE=0x%x, BR_NOOP=0x%x, BR_SPAWN_LOOPER=0x%x, BR_FINISHED=0x%x, \ BR_DEAD_BINDER=0x%x, BR_CLEAR_DEATH_NOTIFICATION_DONE=0x%x, BR_FAILED_REPLY=0x%x, BR_FROZEN_REPLY=0x%x, \ BR_ONEWAY_SPAM_SUSPECT=0x%x\n", BR_ERROR, BR_OK, BR_TRANSACTION_SEC_CTX, BR_TRANSACTION, BR_REPLY, BR_ACQUIRE_RESULT, BR_DEAD_REPLY, BR_TRANSACTION_COMPLETE, BR_INCREFS, BR_ACQUIRE, BR_RELEASE, BR_DECREFS, BR_ATTEMPT_ACQUIRE, BR_NOOP, BR_SPAWN_LOOPER, BR_FINISHED, BR_DEAD_BINDER, BR_CLEAR_DEATH_NOTIFICATION_DONE, BR_FAILED_REPLY, BR_FROZEN_REPLY, BR_ONEWAY_SPAM_SUSPECT); printk("BC_TRANSACTION=0x%x, BC_REPLY=0x%x, BC_ACQUIRE_RESULT=0x%x, BC_FREE_BUFFER=0x%x, \ BC_INCREFS=0x%x, BC_ACQUIRE=0x%x, BC_RELEASE=0x%x, BC_DECREFS=0x%x, \ BC_INCREFS_DONE=0x%x, BC_ACQUIRE_DONE=0x%x, BC_ATTEMPT_ACQUIRE=0x%x, BC_REGISTER_LOOPER=0x%x, \ BC_ENTER_LOOPER=0x%x, BC_EXIT_LOOPER=0x%x, BC_REQUEST_DEATH_NOTIFICATION=0x%x, BC_CLEAR_DEATH_NOTIFICATION=0x%x, \ BC_DEAD_BINDER_DONE=0x%x, BC_TRANSACTION_SG=0x%x, BC_REPLY_SG=0x%x\n", BC_TRANSACTION, BC_REPLY, BC_ACQUIRE_RESULT, BC_FREE_BUFFER, BC_INCREFS, BC_ACQUIRE, BC_RELEASE, BC_DECREFS, BC_INCREFS_DONE, BC_ACQUIRE_DONE, BC_ATTEMPT_ACQUIRE, BC_REGISTER_LOOPER, BC_ENTER_LOOPER, BC_EXIT_LOOPER, BC_REQUEST_DEATH_NOTIFICATION, BC_CLEAR_DEATH_NOTIFICATION, BC_DEAD_BINDER_DONE, BC_TRANSACTION_SG, BC_REPLY_SG); }
标签:BC,BINDER,Binder,宏值,BR,debug,binder,TYPE,0x% From: https://www.cnblogs.com/hellokitty2/p/17965846