]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/systm.h
Add five GEOM oriented ioctls to get basic information about a geom device.
[FreeBSD/FreeBSD.git] / sys / sys / systm.h
1 /*-
2  * Copyright (c) 1982, 1988, 1991, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  * (c) UNIX System Laboratories, Inc.
5  * All or some portions of this file are derived from material licensed
6  * to the University of California by American Telephone and Telegraph
7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8  * the permission of UNIX System Laboratories, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following 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  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the University of
21  *      California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *      @(#)systm.h     8.7 (Berkeley) 3/29/95
39  * $FreeBSD$
40  */
41
42 #ifndef _SYS_SYSTM_H_
43 #define _SYS_SYSTM_H_
44
45 #include <machine/atomic.h>
46 #include <machine/cpufunc.h>
47 #include <sys/callout.h>
48
49 extern int securelevel;         /* system security level (see init(8)) */
50 extern int suser_enabled;       /* suser_xxx() is permitted to return 0 */
51
52 extern int cold;                /* nonzero if we are doing a cold boot */
53 extern const char *panicstr;    /* panic message */
54 extern int dumping;             /* system is dumping */
55 extern char version[];          /* system version */
56 extern char copyright[];        /* system copyright */
57
58 extern int nswap;               /* size of swap space */
59
60 extern int nselcoll;            /* select collisions since boot */
61 extern struct mtx sellock;      /* select lock variable */
62 extern struct cv selwait;       /* select conditional variable */
63
64 extern int physmem;             /* physical memory */
65
66 extern dev_t dumpdev;           /* dump device */
67 extern long dumplo;             /* offset into dumpdev */
68
69 extern dev_t rootdev;           /* root device */
70 extern dev_t rootdevs[2];       /* possible root devices */
71 extern char *rootdevnames[2];   /* names of possible root devices */
72 extern struct vnode *rootvp;    /* vnode equivalent to above */
73
74 extern int boothowto;           /* reboot flags, from console subsystem */
75 extern int bootverbose;         /* nonzero to print verbose messages */
76
77 extern int maxusers;            /* system tune hint */
78
79 #ifdef  INVARIANTS              /* The option is always available */
80 #define KASSERT(exp,msg)        do { if (!(exp)) panic msg; } while (0)
81 #else
82 #define KASSERT(exp,msg)
83 #endif
84
85 /*
86  * XXX the hints declarations are even more misplaced than most declarations
87  * in this file, since they are needed in one file (per arch) and only used
88  * in two files.
89  * XXX most of these variables should be const.
90  */
91 extern int envmode;
92 extern int hintmode;            /* 0 = off. 1 = config, 2 = fallback */
93 extern char *kern_envp;
94 extern char static_env[];
95 extern char static_hints[];     /* by config for now */
96
97 /*
98  * General function declarations.
99  */
100
101 struct clockframe;
102 struct malloc_type;
103 struct mtx;
104 struct proc;
105 struct kse;
106 struct thread;
107 struct tty;
108 struct ucred;
109 struct uio;
110 struct _jmp_buf;
111
112 int     setjmp __P((struct _jmp_buf *));
113 void    longjmp __P((struct _jmp_buf *, int)) __dead2;
114 void    Debugger __P((const char *msg));
115 int     dumpstatus __P((vm_offset_t addr, off_t count));
116 int     nullop __P((void));
117 int     eopnotsupp __P((void));
118 int     seltrue __P((dev_t dev, int which, struct thread *td));
119 int     ureadc __P((int, struct uio *));
120 void    *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
121 void    *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
122
123 #ifdef RESTARTABLE_PANICS
124 void    panic __P((const char *, ...)) __printflike(1, 2);
125 #else
126 void    panic __P((const char *, ...)) __dead2 __printflike(1, 2);
127 #endif
128
129 void    cpu_boot __P((int));
130 void    cpu_rootconf __P((void));
131 void    critical_enter __P((void));
132 void    critical_exit __P((void));
133 void    init_param1 __P((void));
134 void    init_param2 __P((int physpages));
135 void    tablefull __P((const char *));
136 int     kvprintf __P((char const *, void (*)(int, void*), void *, int,
137                       _BSD_VA_LIST_)) __printflike(1, 0);
138 void    log __P((int, const char *, ...)) __printflike(2, 3);
139 void    log_console __P((struct uio *));
140 int     printf __P((const char *, ...)) __printflike(1, 2);
141 int     snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
142 int     sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
143 int     uprintf __P((const char *, ...)) __printflike(1, 2);
144 int     vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
145 int     vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
146 int     vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
147 int     ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
148 int     sscanf __P((const char *, char const *, ...));
149 int     vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
150 long    strtol __P((const char *, char **, int));
151 u_long  strtoul __P((const char *, char **, int));
152 quad_t  strtoq __P((const char *, char **, int));
153 u_quad_t strtouq __P((const char *, char **, int));
154 void    tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4);
155
156 void    bcopy __P((const void *from, void *to, size_t len));
157 void    ovbcopy __P((const void *from, void *to, size_t len));
158
159 #ifdef __i386__
160 extern void     (*bzero) __P((void *buf, size_t len));
161 #else
162 void    bzero __P((void *buf, size_t len));
163 #endif
164
165 void    *memcpy __P((void *to, const void *from, size_t len));
166
167 int     copystr __P((const void *kfaddr, void *kdaddr, size_t len,
168                 size_t *lencopied));
169 int     copyinstr __P((const void *udaddr, void *kaddr, size_t len,
170                 size_t *lencopied));
171 int     copyin __P((const void *udaddr, void *kaddr, size_t len));
172 int     copyout __P((const void *kaddr, void *udaddr, size_t len));
173
174 int     fubyte __P((const void *base));
175 int     subyte __P((void *base, int byte));
176 int     suibyte __P((void *base, int byte));
177 long    fuword __P((const void *base));
178 int     suword __P((void *base, long word));
179 int     fusword __P((void *base));
180 int     susword __P((void *base, int word));
181
182 void    realitexpire __P((void *));
183
184 void    hardclock __P((struct clockframe *frame));
185 void    hardclock_process __P((struct thread *td, int user));
186 void    softclock __P((void *));
187 void    statclock __P((struct clockframe *frame));
188 void    statclock_process __P((struct kse *ke, register_t pc, int user));
189
190 void    startprofclock __P((struct proc *));
191 void    stopprofclock __P((struct proc *));
192 void    setstatclockrate __P((int hzrate));
193
194 /* flags for suser_xxx() */
195 #define PRISON_ROOT     1
196
197 int     suser __P((struct proc *));
198 int     suser_td __P((struct thread *));
199 int     suser_xxx __P((struct ucred *cred, struct proc *proc, int flag));
200 int     suser_xxx_td __P((struct ucred *cred, struct thread *thread, int flag));
201 int     cr_cansee __P((struct ucred *u1, struct ucred *u2));
202
203 char    *getenv __P((const char *name));
204 int     getenv_int __P((const char *name, int *data));
205 int     getenv_string __P((const char *name, char *data, int size));
206 int     getenv_quad __P((const char *name, quad_t *data));
207
208 #ifdef APM_FIXUP_CALLTODO 
209 struct timeval;
210 void    adjust_timeout_calltodo __P((struct timeval *time_change)); 
211 #endif /* APM_FIXUP_CALLTODO */ 
212
213 #include <sys/libkern.h>
214
215 /* Initialize the world */
216 void    consinit __P((void));
217 void    cpu_initclocks __P((void));
218 void    usrinfoinit __P((void));
219
220 /* Finalize the world. */
221 void    shutdown_nice __P((int));
222
223 /*
224  * Kernel to clock driver interface.
225  */
226 void    inittodr __P((time_t base));
227 void    resettodr __P((void));
228 void    startrtclock __P((void));
229
230 /* Timeouts */
231 typedef void timeout_t __P((void *));   /* timeout function type */
232 #define CALLOUT_HANDLE_INITIALIZER(handle)      \
233         { NULL }
234
235 void    callout_handle_init __P((struct callout_handle *));
236 struct  callout_handle timeout __P((timeout_t *, void *, int));
237 void    untimeout __P((timeout_t *, void *, struct callout_handle));
238 caddr_t kern_timeout_callwheel_alloc __P((caddr_t v));
239 void    kern_timeout_callwheel_init __P((void));
240
241 /* Stubs for obsolete functions that used to be for interrupt  management */
242 static __inline void            spl0(void)              { return; }
243 static __inline intrmask_t      splbio(void)            { return 0; }
244 static __inline intrmask_t      splcam(void)            { return 0; }
245 static __inline intrmask_t      splclock(void)          { return 0; }
246 static __inline intrmask_t      splhigh(void)           { return 0; }
247 static __inline intrmask_t      splimp(void)            { return 0; }
248 static __inline intrmask_t      splnet(void)            { return 0; }
249 static __inline intrmask_t      splsoftcam(void)        { return 0; }
250 static __inline intrmask_t      splsoftclock(void)      { return 0; }
251 static __inline intrmask_t      splsofttty(void)        { return 0; }
252 static __inline intrmask_t      splsoftvm(void)         { return 0; }
253 static __inline intrmask_t      splsofttq(void)         { return 0; }
254 static __inline intrmask_t      splstatclock(void)      { return 0; }
255 static __inline intrmask_t      spltty(void)            { return 0; }
256 static __inline intrmask_t      splvm(void)             { return 0; }
257 static __inline void            splx(intrmask_t ipl)    { return; }
258
259 /*
260  * Various callout lists.
261  */
262
263 /* Exit callout list declarations. */
264 typedef void (*exitlist_fn) __P((struct proc *procp));
265
266 int     at_exit __P((exitlist_fn function));
267 int     rm_at_exit __P((exitlist_fn function));
268
269 /* Fork callout list declarations. */
270 typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
271                                  int flags));
272
273 int     at_fork __P((forklist_fn function));
274 int     rm_at_fork __P((forklist_fn function));
275
276 /* Exec callout list declarations. */
277 typedef void (*execlist_fn) __P((struct proc *procp));
278
279 int     at_exec __P((execlist_fn function));
280 int     rm_at_exec __P((execlist_fn function));
281
282 /*
283  * Not exactly a callout LIST, but a callout entry.
284  * Allow an external module to define a hardware watchdog tickler.
285  * Normally a process would do this, but there are times when the
286  * kernel needs to be able to hold off the watchdog, when the process
287  * is not active, e.g., when dumping core.
288  */
289 typedef void (*watchdog_tickle_fn) __P((void));
290
291 extern watchdog_tickle_fn       wdog_tickler;
292
293 /* 
294  * Common `proc' functions are declared here so that proc.h can be included
295  * less often.
296  */
297 int     msleep __P((void *chan, struct mtx *mtx, int pri, const char *wmesg,
298                     int timo));
299 #define tsleep(chan, pri, wmesg, timo)  msleep(chan, NULL, pri, wmesg, timo)
300 void    wakeup __P((void *chan));
301 void    wakeup_one __P((void *chan));
302
303 /*
304  * Common `dev_t' stuff are declared here to avoid #include poisoning
305  */
306
307 int major(dev_t x);
308 int minor(dev_t x);
309 dev_t makedev(int x, int y);
310 udev_t dev2udev(dev_t x);
311 dev_t udev2dev(udev_t x, int b);
312 int uminor(udev_t dev);
313 int umajor(udev_t dev);
314 udev_t makeudev(int x, int y);
315
316 /* XXX: Should be void nanodelay(u_int nsec); */
317 void    DELAY __P((int usec));
318
319 #endif /* !_SYS_SYSTM_H_ */