moduleparam.h revision 289624
1/* $FreeBSD: head/sys/ofed/include/linux/moduleparam.h 289624 2015-10-20 11:40:04Z hselasky $ */
2/*-
3 * Copyright (c) 2010 Isilon Systems, Inc.
4 * Copyright (c) 2010 iX Systems, Inc.
5 * Copyright (c) 2010 Panasas, Inc.
6 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice unmodified, this list of conditions, and the following
14 *    disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef	_LINUX_MODULEPARAM_H_
32#define	_LINUX_MODULEPARAM_H_
33
34#include <linux/types.h>
35
36/*
37 * These are presently not hooked up to anything.  In linux the parameters
38 * can be set when modules are loaded.  On FreeBSD these could be mapped
39 * to kenv in the future.
40 */
41struct kernel_param;
42
43typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
44typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
45
46struct kernel_param {
47	const char	*name;
48	u16		perm;
49	u16		flags;
50	param_set_fn	set;
51	param_get_fn	get;
52	union {
53		void	*arg;
54		struct kparam_string	*str;
55		struct kparam_array	*arr;
56	} un;
57};
58
59#define	KPARAM_ISBOOL	2
60
61struct kparam_string {
62	unsigned int maxlen;
63	char *string;
64};
65
66struct kparam_array
67{
68	unsigned int	max;
69	unsigned int	*num;
70	param_set_fn	set;
71	param_get_fn	get;
72	unsigned int	elemsize;
73	void 		*elem;
74};
75
76static inline void
77param_sysinit(struct kernel_param *param)
78{
79}
80
81#define	module_param_call(name, set, get, arg, perm)			\
82	static struct kernel_param __param_##name =			\
83	    { #name, perm, 0, set, get, { arg } };			\
84	SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,	\
85	    param_sysinit, &__param_##name);
86
87#define	module_param_string(name, string, len, perm)
88
89#define	module_param_named(name, var, type, mode)			\
90	module_param_call(name, param_set_##type, param_get_##type, &var, mode)
91
92#define	module_param(var, type, mode)					\
93	module_param_named(var, var, type, mode)
94
95#define module_param_array(var, type, addr_argc, mode)                  \
96        module_param_named(var, var, type, mode)
97
98#define	MODULE_PARM_DESC(name, desc)
99
100static inline int
101param_set_byte(const char *val, struct kernel_param *kp)
102{
103
104	return 0;
105}
106
107static inline int
108param_get_byte(char *buffer, struct kernel_param *kp)
109{
110
111	return 0;
112}
113
114
115static inline int
116param_set_short(const char *val, struct kernel_param *kp)
117{
118
119	return 0;
120}
121
122static inline int
123param_get_short(char *buffer, struct kernel_param *kp)
124{
125
126	return 0;
127}
128
129
130static inline int
131param_set_ushort(const char *val, struct kernel_param *kp)
132{
133
134	return 0;
135}
136
137static inline int
138param_get_ushort(char *buffer, struct kernel_param *kp)
139{
140
141	return 0;
142}
143
144
145static inline int
146param_set_int(const char *val, struct kernel_param *kp)
147{
148
149	return 0;
150}
151
152static inline int
153param_get_int(char *buffer, struct kernel_param *kp)
154{
155
156	return 0;
157}
158
159
160static inline int
161param_set_uint(const char *val, struct kernel_param *kp)
162{
163
164	return 0;
165}
166
167static inline int
168param_get_uint(char *buffer, struct kernel_param *kp)
169{
170
171	return 0;
172}
173
174
175static inline int
176param_set_long(const char *val, struct kernel_param *kp)
177{
178
179	return 0;
180}
181
182static inline int
183param_get_long(char *buffer, struct kernel_param *kp)
184{
185
186	return 0;
187}
188
189
190static inline int
191param_set_ulong(const char *val, struct kernel_param *kp)
192{
193
194	return 0;
195}
196
197static inline int
198param_get_ulong(char *buffer, struct kernel_param *kp)
199{
200
201	return 0;
202}
203
204
205static inline int
206param_set_charp(const char *val, struct kernel_param *kp)
207{
208
209	return 0;
210}
211
212static inline int
213param_get_charp(char *buffer, struct kernel_param *kp)
214{
215
216	return 0;
217}
218
219
220static inline int
221param_set_bool(const char *val, struct kernel_param *kp)
222{
223
224	return 0;
225}
226
227static inline int
228param_get_bool(char *buffer, struct kernel_param *kp)
229{
230
231	return 0;
232}
233
234#endif	/* _LINUX_MODULEPARAM_H_ */
235