]>
git.proxmox.com Git - mirror_spl.git/blob - include/splat-ctl.h
89b8eb7b0ea82fd8f81813db4559cb0107d3d132
5 #include <asm/ioctls.h>
6 #include <asm/uaccess.h>
7 #include <linux/list.h>
10 #define KZT_VERSION "v1.0"
11 #define KZT_VERSION_SIZE 64
13 #define KZT_MAJOR 229 /* XXX - Arbitrary */
15 #define KZT_DEV "/dev/kztctl"
17 #define KZT_NAME_SIZE 12
18 #define KZT_DESC_SIZE 60
20 typedef struct kzt_user
{
21 char name
[KZT_NAME_SIZE
]; /* short name */
22 char desc
[KZT_DESC_SIZE
]; /* short description */
23 int id
; /* unique numeric id */
26 #define KZT_CFG_MAGIC 0x15263748U
27 typedef struct kzt_cfg
{
28 unsigned int cfg_magic
; /* Unique magic */
29 int cfg_cmd
; /* Config command */
30 int cfg_arg1
; /* Config command arg 1 */
31 int cfg_rc1
; /* Config response 1 */
44 #define KZT_CMD_MAGIC 0x9daebfc0U
45 typedef struct kzt_cmd
{
46 unsigned int cmd_magic
; /* Unique magic */
47 int cmd_subsystem
; /* Target subsystem */
48 int cmd_test
; /* Subsystem test */
49 int cmd_data_size
; /* Extra opaque data */
50 char cmd_data_str
[0]; /* Opaque data region */
54 #define KZT_CFG _IOWR('f', 101, long)
55 #define KZT_CMD _IOWR('f', 102, long)
57 /* Valid configuration commands */
58 #define KZT_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
59 #define KZT_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
60 #define KZT_CFG_SUBSYSTEM_COUNT 0x101 /* Number of subsystem */
61 #define KZT_CFG_SUBSYSTEM_LIST 0x102 /* List of N subsystems */
62 #define KZT_CFG_TEST_COUNT 0x201 /* Number of tests */
63 #define KZT_CFG_TEST_LIST 0x202 /* List of N tests */
65 /* Valid subsystem and test commands defined in each subsystem, we do
66 * need to be careful to avoid colisions. That alone may argue to define
67 * them all here, for now we just define the global error codes.
69 #define KZT_SUBSYSTEM_UNKNOWN 0xF00
70 #define KZT_TEST_UNKNOWN 0xFFF
74 #define KZT_SUBSYSTEM_INIT(type) \
75 ({ kzt_subsystem_t *_sub_; \
77 _sub_ = (kzt_subsystem_t *)kzt_##type##_init(); \
78 if (_sub_ == NULL) { \
79 printk(KERN_ERR "Error initializing: " #type "\n"); \
81 spin_lock(&kzt_module_lock); \
82 list_add_tail(&(_sub_->subsystem_list), \
84 spin_unlock(&kzt_module_lock); \
88 #define KZT_SUBSYSTEM_FINI(type) \
89 ({ kzt_subsystem_t *_sub_, *_tmp_; \
90 int _id_, _flag_ = 0; \
92 _id_ = kzt_##type##_id(); \
93 spin_lock(&kzt_module_lock); \
94 list_for_each_entry_safe(_sub_, _tmp_, &kzt_module_list, \
96 if (_sub_->desc.id == _id_) { \
97 list_del_init(&(_sub_->subsystem_list)); \
98 spin_unlock(&kzt_module_lock); \
99 kzt_##type##_fini(_sub_); \
100 spin_lock(&kzt_module_lock); \
104 spin_unlock(&kzt_module_lock); \
107 printk(KERN_ERR "Error finalizing: " #type "\n"); \
110 #define KZT_TEST_INIT(sub, n, d, tid, func) \
111 ({ kzt_test_t *_test_; \
113 _test_ = (kzt_test_t *)kmalloc(sizeof(*_test_), GFP_KERNEL); \
114 if (_test_ == NULL) { \
115 printk(KERN_ERR "Error initializing: " n "/" #tid" \n");\
117 memset(_test_, 0, sizeof(*_test_)); \
118 strncpy(_test_->desc.name, n, KZT_NAME_SIZE); \
119 strncpy(_test_->desc.desc, d, KZT_DESC_SIZE); \
120 _test_->desc.id = tid; \
121 _test_->test = func; \
122 INIT_LIST_HEAD(&(_test_->test_list)); \
123 spin_lock(&((sub)->test_lock)); \
124 list_add_tail(&(_test_->test_list),&((sub)->test_list));\
125 spin_unlock(&((sub)->test_lock)); \
129 #define KZT_TEST_FINI(sub, tid) \
130 ({ kzt_test_t *_test_, *_tmp_; \
133 spin_lock(&((sub)->test_lock)); \
134 list_for_each_entry_safe(_test_, _tmp_, \
135 &((sub)->test_list), test_list) { \
136 if (_test_->desc.id == tid) { \
137 list_del_init(&(_test_->test_list)); \
141 spin_unlock(&((sub)->test_lock)); \
144 printk(KERN_ERR "Error finalizing: " #tid "\n"); \
147 typedef int (*kzt_test_func_t
)(struct file
*, void *);
149 typedef struct kzt_test
{
150 struct list_head test_list
;
152 kzt_test_func_t test
;
155 typedef struct kzt_subsystem
{
156 struct list_head subsystem_list
;/* List had to chain entries */
158 spinlock_t test_lock
;
159 struct list_head test_list
;
162 #define KZT_INFO_BUFFER_SIZE 65536
163 #define KZT_INFO_BUFFER_REDZONE 256
165 typedef struct kzt_info
{
166 spinlock_t info_lock
;
169 char *info_head
; /* Internal kernel use only */
172 #define sym2str(sym) (char *)(#sym)
174 #define kzt_print(file, format, args...) \
175 ({ kzt_info_t *_info_ = (kzt_info_t *)file->private_data; \
179 ASSERT(_info_->info_buffer); \
181 spin_lock(&_info_->info_lock); \
183 /* Don't allow the kernel to start a write in the red zone */ \
184 if ((int)(_info_->info_head - _info_->info_buffer) > \
185 (KZT_INFO_BUFFER_SIZE -KZT_INFO_BUFFER_REDZONE)) { \
188 _rc_ = sprintf(_info_->info_head, format, args); \
190 _info_->info_head += _rc_; \
193 spin_unlock(&_info_->info_lock); \
197 #define kzt_vprint(file, test, format, args...) \
198 kzt_print(file, "%*s: " format, KZT_NAME_SIZE, test, args)
200 kzt_subsystem_t
* kzt_condvar_init(void);
201 kzt_subsystem_t
* kzt_kmem_init(void);
202 kzt_subsystem_t
* kzt_mutex_init(void);
203 kzt_subsystem_t
* kzt_krng_init(void);
204 kzt_subsystem_t
* kzt_rwlock_init(void);
205 kzt_subsystem_t
* kzt_taskq_init(void);
206 kzt_subsystem_t
* kzt_thread_init(void);
207 kzt_subsystem_t
* kzt_time_init(void);
211 #endif /* _SPLAY_CTL_H */