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