]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/systm.h
This commit was generated by cvs2svn to compensate for changes in r91041,
[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 struct cv selwait;       /* select conditional variable */
61
62 extern int physmem;             /* physical memory */
63
64 extern dev_t dumpdev;           /* dump device */
65 extern long dumplo;             /* offset into dumpdev */
66
67 extern dev_t rootdev;           /* root device */
68 extern dev_t rootdevs[2];       /* possible root devices */
69 extern char *rootdevnames[2];   /* names of possible root devices */
70 extern struct vnode *rootvp;    /* vnode equivalent to above */
71
72 extern int boothowto;           /* reboot flags, from console subsystem */
73 extern int bootverbose;         /* nonzero to print verbose messages */
74
75 extern int maxusers;            /* system tune hint */
76
77 #ifdef  INVARIANTS              /* The option is always available */
78 #define KASSERT(exp,msg)        do { if (!(exp)) panic msg; } while (0)
79 #else
80 #define KASSERT(exp,msg)
81 #endif
82
83 /*
84  * XXX the hints declarations are even more misplaced than most declarations
85  * in this file, since they are needed in one file (per arch) and only used
86  * in two files.
87  * XXX most of these variables should be const.
88  */
89 extern int envmode;
90 extern int hintmode;            /* 0 = off. 1 = config, 2 = fallback */
91 extern char *kern_envp;
92 extern char static_env[];
93 extern char static_hints[];     /* by config for now */
94
95 /*
96  * General function declarations.
97  */
98
99 struct clockframe;
100 struct malloc_type;
101 struct mtx;
102 struct proc;
103 struct kse;
104 struct thread;
105 struct tty;
106 struct ucred;
107 struct uio;
108 struct _jmp_buf;
109
110 int     setjmp __P((struct _jmp_buf *));
111 void    longjmp __P((struct _jmp_buf *, int)) __dead2;
112 void    Debugger __P((const char *msg));
113 int     dumpstatus __P((vm_offset_t addr, off_t count));
114 int     nullop __P((void));
115 int     eopnotsupp __P((void));
116 int     seltrue __P((dev_t dev, int which, struct thread *td));
117 int     ureadc __P((int, struct uio *));
118 void    *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
119 void    *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
120
121 #ifdef RESTARTABLE_PANICS
122 void    panic __P((const char *, ...)) __printflike(1, 2);
123 #else
124 void    panic __P((const char *, ...)) __dead2 __printflike(1, 2);
125 #endif
126
127 void    cpu_boot __P((int));
128 void    cpu_rootconf __P((void));
129 void    critical_enter __P((void));
130 void    critical_exit __P((void));
131 void    init_param1 __P((void));
132 void    init_param2 __P((int physpages));
133 void    tablefull __P((const char *));
134 int     kvprintf __P((char const *, void (*)(int, void*), void *, int,
135                       _BSD_VA_LIST_)) __printflike(1, 0);
136 void    log __P((int, const char *, ...)) __printflike(2, 3);
137 void    log_console __P((struct uio *));
138 int     printf __P((const char *, ...)) __printflike(1, 2);
139 int     snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
140 int     sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
141 int     uprintf __P((const char *, ...)) __printflike(1, 2);
142 int     vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
143 int     vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
144 int     vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
145 int     ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
146 int     sscanf __P((const char *, char const *, ...));
147 int     vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
148 long    strtol __P((const char *, char **, int));
149 u_long  strtoul __P((const char *, char **, int));
150 quad_t  strtoq __P((const char *, char **, int));
151 u_quad_t strtouq __P((const char *, char **, int));
152 void    tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4);
153
154 void    bcopy __P((const void *from, void *to, size_t len));
155 void    ovbcopy __P((const void *from, void *to, size_t len));
156
157 #ifdef __i386__
158 extern void     (*bzero) __P((volatile void *buf, size_t len));
159 #else
160 void    bzero __P((void *buf, size_t len));
161 #endif
162
163 void    *memcpy __P((void *to, const void *from, size_t len));
164
165 int     copystr __P((const void *kfaddr, void *kdaddr, size_t len,
166                 size_t *lencopied));
167 int     copyinstr __P((const void *udaddr, void *kaddr, size_t len,
168                 size_t *lencopied));
169 int     copyin __P((const void *udaddr, void *kaddr, size_t len));
170 int     copyout __P((const void *kaddr, void *udaddr, size_t len));
171
172 int     fubyte __P((const void *base));
173 int     subyte __P((void *base, int byte));
174 int     suibyte __P((void *base, int byte));
175 long    fuword __P((const void *base));
176 int     suword __P((void *base, long word));
177 int     fusword __P((void *base));
178 int     susword __P((void *base, int word));
179
180 void    realitexpire __P((void *));
181
182 void    hardclock __P((struct clockframe *frame));
183 void    hardclock_process __P((struct thread *td, int user));
184 void    softclock __P((void *));
185 void    statclock __P((struct clockframe *frame));
186 void    statclock_process __P((struct kse *ke, register_t pc, int user));
187
188 void    startprofclock __P((struct proc *));
189 void    stopprofclock __P((struct proc *));
190 void    setstatclockrate __P((int hzrate));
191
192 /* flags for suser_xxx() */
193 #define PRISON_ROOT     1
194
195 int     suser __P((struct proc *));
196 int     suser_td __P((struct thread *));
197 int     suser_xxx __P((struct ucred *cred, struct proc *proc, int flag));
198 int     suser_xxx_td __P((struct ucred *cred, struct thread *thread, int flag));
199 int     cr_cansee __P((struct ucred *u1, struct ucred *u2));
200
201 char    *getenv __P((const char *name));
202 int     getenv_int __P((const char *name, int *data));
203 int     getenv_string __P((const char *name, char *data, int size));
204 int     getenv_quad __P((const char *name, quad_t *data));
205
206 #ifdef APM_FIXUP_CALLTODO 
207 struct timeval;
208 void    adjust_timeout_calltodo __P((struct timeval *time_change)); 
209 #endif /* APM_FIXUP_CALLTODO */ 
210
211 #include <sys/libkern.h>
212
213 /* Initialize the world */
214 void    consinit __P((void));
215 void    cpu_initclocks __P((void));
216 void    usrinfoinit __P((void));
217
218 /* Finalize the world. */
219 void    shutdown_nice __P((int));
220
221 /*
222  * Kernel to clock driver interface.
223  */
224 void    inittodr __P((time_t base));
225 void    resettodr __P((void));
226 void    startrtclock __P((void));
227
228 /* Timeouts */
229 typedef void timeout_t __P((void *));   /* timeout function type */
230 #define CALLOUT_HANDLE_INITIALIZER(handle)      \
231         { NULL }
232
233 void    callout_handle_init __P((struct callout_handle *));
234 struct  callout_handle timeout __P((timeout_t *, void *, int));
235 void    untimeout __P((timeout_t *, void *, struct callout_handle));
236 caddr_t kern_timeout_callwheel_alloc __P((caddr_t v));
237 void    kern_timeout_callwheel_init __P((void));
238
239 /* Stubs for obsolete functions that used to be for interrupt  management */
240 static __inline void            spl0(void)              { return; }
241 static __inline intrmask_t      splbio(void)            { return 0; }
242 static __inline intrmask_t      splcam(void)            { return 0; }
243 static __inline intrmask_t      splclock(void)          { return 0; }
244 static __inline intrmask_t      splhigh(void)           { return 0; }
245 static __inline intrmask_t      splimp(void)            { return 0; }
246 static __inline intrmask_t      splnet(void)            { return 0; }
247 static __inline intrmask_t      splsoftcam(void)        { return 0; }
248 static __inline intrmask_t      splsoftclock(void)      { return 0; }
249 static __inline intrmask_t      splsofttty(void)        { return 0; }
250 static __inline intrmask_t      splsoftvm(void)         { return 0; }
251 static __inline intrmask_t      splsofttq(void)         { return 0; }
252 static __inline intrmask_t      splstatclock(void)      { return 0; }
253 static __inline intrmask_t      spltty(void)            { return 0; }
254 static __inline intrmask_t      splvm(void)             { return 0; }
255 static __inline void            splx(intrmask_t ipl)    { return; }
256
257 /*
258  * Various callout lists.
259  */
260
261 /* Exit callout list declarations. */
262 typedef void (*exitlist_fn) __P((struct proc *procp));
263
264 int     at_exit __P((exitlist_fn function));
265 int     rm_at_exit __P((exitlist_fn function));
266
267 /* Fork callout list declarations. */
268 typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
269                                  int flags));
270
271 int     at_fork __P((forklist_fn function));
272 int     rm_at_fork __P((forklist_fn function));
273
274 /* Exec callout list declarations. */
275 typedef void (*execlist_fn) __P((struct proc *procp));
276
277 int     at_exec __P((execlist_fn function));
278 int     rm_at_exec __P((execlist_fn function));
279
280 /*
281  * Not exactly a callout LIST, but a callout entry.
282  * Allow an external module to define a hardware watchdog tickler.
283  * Normally a process would do this, but there are times when the
284  * kernel needs to be able to hold off the watchdog, when the process
285  * is not active, e.g., when dumping core.
286  */
287 typedef void (*watchdog_tickle_fn) __P((void));
288
289 extern watchdog_tickle_fn       wdog_tickler;
290
291 /* 
292  * Common `proc' functions are declared here so that proc.h can be included
293  * less often.
294  */
295 int     msleep __P((void *chan, struct mtx *mtx, int pri, const char *wmesg,
296                     int timo));
297 #define tsleep(chan, pri, wmesg, timo)  msleep(chan, NULL, pri, wmesg, timo)
298 void    wakeup __P((void *chan));
299 void    wakeup_one __P((void *chan));
300
301 /*
302  * Common `dev_t' stuff are declared here to avoid #include poisoning
303  */
304
305 int major(dev_t x);
306 int minor(dev_t x);
307 dev_t makedev(int x, int y);
308 udev_t dev2udev(dev_t x);
309 dev_t udev2dev(udev_t x, int b);
310 int uminor(udev_t dev);
311 int umajor(udev_t dev);
312 udev_t makeudev(int x, int y);
313
314 /* XXX: Should be void nanodelay(u_int nsec); */
315 void    DELAY __P((int usec));
316
317 #endif /* !_SYS_SYSTM_H_ */