]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/android/binder_internal.h
Merge tag 'perf-urgent-for-mingo-5.7-20200403' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-jammy-kernel.git] / drivers / android / binder_internal.h
CommitLineData
3ad20fe3
CB
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _LINUX_BINDER_INTERNAL_H
4#define _LINUX_BINDER_INTERNAL_H
5
6#include <linux/export.h>
7#include <linux/fs.h>
8#include <linux/list.h>
9#include <linux/miscdevice.h>
10#include <linux/mutex.h>
f0fe2c0f 11#include <linux/refcount.h>
3ad20fe3
CB
12#include <linux/stddef.h>
13#include <linux/types.h>
14#include <linux/uidgid.h>
15
16struct binder_context {
17 struct binder_node *binder_context_mgr_node;
18 struct mutex context_mgr_node_lock;
19 kuid_t binder_context_mgr_uid;
20 const char *name;
21};
22
23/**
24 * struct binder_device - information about a binder device node
25 * @hlist: list of binder devices (only used for devices requested via
26 * CONFIG_ANDROID_BINDER_DEVICES)
27 * @miscdev: information about a binder character device node
28 * @context: binder context information
29 * @binderfs_inode: This is the inode of the root dentry of the super block
30 * belonging to a binderfs mount.
31 */
32struct binder_device {
33 struct hlist_node hlist;
34 struct miscdevice miscdev;
35 struct binder_context context;
36 struct inode *binderfs_inode;
f0fe2c0f 37 refcount_t ref;
3ad20fe3
CB
38};
39
4feb80fa
HV
40/**
41 * binderfs_mount_opts - mount options for binderfs
42 * @max: maximum number of allocatable binderfs binder devices
43 * @stats_mode: enable binder stats in binderfs.
44 */
45struct binderfs_mount_opts {
46 int max;
47 int stats_mode;
48};
49
50/**
51 * binderfs_info - information about a binderfs mount
52 * @ipc_ns: The ipc namespace the binderfs mount belongs to.
53 * @control_dentry: This records the dentry of this binderfs mount
54 * binder-control device.
55 * @root_uid: uid that needs to be used when a new binder device is
56 * created.
57 * @root_gid: gid that needs to be used when a new binder device is
58 * created.
59 * @mount_opts: The mount options in use.
60 * @device_count: The current number of allocated binder devices.
61 * @proc_log_dir: Pointer to the directory dentry containing process-specific
62 * logs.
63 */
64struct binderfs_info {
65 struct ipc_namespace *ipc_ns;
66 struct dentry *control_dentry;
67 kuid_t root_uid;
68 kgid_t root_gid;
69 struct binderfs_mount_opts mount_opts;
70 int device_count;
71 struct dentry *proc_log_dir;
72};
73
3ad20fe3
CB
74extern const struct file_operations binder_fops;
75
ca2864c6
HV
76extern char *binder_devices_param;
77
3ad20fe3
CB
78#ifdef CONFIG_ANDROID_BINDERFS
79extern bool is_binderfs_device(const struct inode *inode);
4feb80fa
HV
80extern struct dentry *binderfs_create_file(struct dentry *dir, const char *name,
81 const struct file_operations *fops,
82 void *data);
83extern void binderfs_remove_file(struct dentry *dentry);
3ad20fe3
CB
84#else
85static inline bool is_binderfs_device(const struct inode *inode)
86{
87 return false;
88}
4feb80fa
HV
89static inline struct dentry *binderfs_create_file(struct dentry *dir,
90 const char *name,
91 const struct file_operations *fops,
92 void *data)
93{
94 return NULL;
95}
96static inline void binderfs_remove_file(struct dentry *dentry) {}
3ad20fe3
CB
97#endif
98
5b9633af
CB
99#ifdef CONFIG_ANDROID_BINDERFS
100extern int __init init_binderfs(void);
101#else
102static inline int __init init_binderfs(void)
103{
104 return 0;
105}
106#endif
107
0e13e452
HV
108int binder_stats_show(struct seq_file *m, void *unused);
109DEFINE_SHOW_ATTRIBUTE(binder_stats);
110
111int binder_state_show(struct seq_file *m, void *unused);
112DEFINE_SHOW_ATTRIBUTE(binder_state);
113
114int binder_transactions_show(struct seq_file *m, void *unused);
115DEFINE_SHOW_ATTRIBUTE(binder_transactions);
03e2e07e
HV
116
117int binder_transaction_log_show(struct seq_file *m, void *unused);
118DEFINE_SHOW_ATTRIBUTE(binder_transaction_log);
119
120struct binder_transaction_log_entry {
121 int debug_id;
122 int debug_id_done;
123 int call_type;
124 int from_proc;
125 int from_thread;
126 int target_handle;
127 int to_proc;
128 int to_thread;
129 int to_node;
130 int data_size;
131 int offsets_size;
132 int return_error_line;
133 uint32_t return_error;
134 uint32_t return_error_param;
51d8a7ec 135 char context_name[BINDERFS_MAX_NAME + 1];
03e2e07e
HV
136};
137
138struct binder_transaction_log {
139 atomic_t cur;
140 bool full;
141 struct binder_transaction_log_entry entry[32];
142};
143
144extern struct binder_transaction_log binder_transaction_log;
145extern struct binder_transaction_log binder_transaction_log_failed;
3ad20fe3 146#endif /* _LINUX_BINDER_INTERNAL_H */