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.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
38 * @(#)systm.h 8.7 (Berkeley) 3/29/95
45 #include <machine/atomic.h>
46 #include <machine/cpufunc.h>
47 #include <sys/callout.h>
49 extern int securelevel; /* system security level (see init(8)) */
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 */
57 extern int nswap; /* size of swap space */
59 extern int selwait; /* select timeout address */
61 extern int physmem; /* physical memory */
63 extern dev_t dumpdev; /* dump device */
64 extern long dumplo; /* offset into dumpdev */
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 */
71 extern int boothowto; /* reboot flags, from console subsystem */
72 extern int bootverbose; /* nonzero to print verbose messages */
74 #ifdef INVARIANTS /* The option is always available */
75 #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0)
77 #define KASSERT(exp,msg)
81 * General function declarations.
93 void Debugger __P((const char *msg));
94 int nullop __P((void));
95 int eopnotsupp __P((void));
96 int einval __P((void));
97 int seltrue __P((dev_t dev, int which, struct proc *p));
98 int ureadc __P((int, struct uio *));
99 void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
100 void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
102 void cpu_boot __P((int));
103 void cpu_rootconf __P((void));
104 void tablefull __P((const char *));
105 int kvprintf __P((char const *, void (*)(int, void*), void *, int,
106 _BSD_VA_LIST_)) __printflike(1, 0);
107 void log __P((int, const char *, ...)) __printflike(2, 3);
108 void log_console __P((struct uio *));
109 int printf __P((const char *, ...)) __printflike(1, 2);
110 int snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
111 int sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
112 int uprintf __P((const char *, ...)) __printflike(1, 2);
113 int vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
114 int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
115 int vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
116 int ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
117 int sscanf __P((const char *, char const *, ...));
118 int vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
119 long strtol __P((const char *, char **, int));
120 u_long strtoul __P((const char *, char **, int));
121 quad_t strtoq __P((const char *, char **, int));
122 u_quad_t strtouq __P((const char *, char **, int));
123 void tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4);
125 void bcopy __P((const void *from, void *to, size_t len));
126 void ovbcopy __P((const void *from, void *to, size_t len));
129 extern void (*bzero) __P((void *buf, size_t len));
131 void bzero __P((void *buf, size_t len));
134 void *memcpy __P((void *to, const void *from, size_t len));
136 int copystr __P((const void *kfaddr, void *kdaddr, size_t len,
138 int copyinstr __P((const void *udaddr, void *kaddr, size_t len,
140 int copyin __P((const void *udaddr, void *kaddr, size_t len));
141 int copyout __P((const void *kaddr, void *udaddr, size_t len));
143 int fubyte __P((const void *base));
144 int subyte __P((void *base, int byte));
145 int suibyte __P((void *base, int byte));
146 long fuword __P((const void *base));
147 int suword __P((void *base, long word));
148 int fusword __P((void *base));
149 int susword __P((void *base, int word));
151 void realitexpire __P((void *));
153 void hardclock __P((struct clockframe *frame));
154 void softclock __P((void *));
155 void statclock __P((struct clockframe *frame));
157 void startprofclock __P((struct proc *));
158 void stopprofclock __P((struct proc *));
159 void setstatclockrate __P((int hzrate));
161 /* flags for suser_xxx() */
162 #define PRISON_ROOT 1
164 int suser __P((struct proc *));
165 int suser_xxx __P((struct ucred *cred, struct proc *proc, int flag));
167 char *getenv __P((char *name));
168 int getenv_int __P((char *name, int *data));
169 quad_t getenv_quad __P((char *name, quad_t *data));
170 extern char *kern_envp;
172 #ifdef APM_FIXUP_CALLTODO
173 void adjust_timeout_calltodo __P((struct timeval *time_change));
174 #endif /* APM_FIXUP_CALLTODO */
176 #include <sys/libkern.h>
178 /* Initialize the world */
179 void consinit __P((void));
180 void cpu_initclocks __P((void));
181 void usrinfoinit __P((void));
183 /* Finalize the world. */
184 void shutdown_nice __P((int));
187 * Kernel to clock driver interface.
189 void inittodr __P((time_t base));
190 void resettodr __P((void));
191 void startrtclock __P((void));
194 typedef void timeout_t __P((void *)); /* timeout function type */
195 #define CALLOUT_HANDLE_INITIALIZER(handle) \
198 void callout_handle_init __P((struct callout_handle *));
199 struct callout_handle timeout __P((timeout_t *, void *, int));
200 void untimeout __P((timeout_t *, void *, struct callout_handle));
202 /* Stubs for obsolete functions that used to be for interrupt management */
203 static __inline void spl0(void) { return; }
204 static __inline intrmask_t splbio(void) { return 0; }
205 static __inline intrmask_t splcam(void) { return 0; }
206 static __inline intrmask_t splclock(void) { return 0; }
207 static __inline intrmask_t splhigh(void) { return 0; }
208 static __inline intrmask_t splimp(void) { return 0; }
209 static __inline intrmask_t splnet(void) { return 0; }
210 static __inline intrmask_t splsoftcam(void) { return 0; }
211 static __inline intrmask_t splsoftclock(void) { return 0; }
212 static __inline intrmask_t splsofttty(void) { return 0; }
213 static __inline intrmask_t splsoftvm(void) { return 0; }
214 static __inline intrmask_t splsofttq(void) { return 0; }
215 static __inline intrmask_t splstatclock(void) { return 0; }
216 static __inline intrmask_t spltty(void) { return 0; }
217 static __inline intrmask_t splvm(void) { return 0; }
218 static __inline void splx(intrmask_t ipl) { return; }
221 * Various callout lists.
224 /* Exit callout list declarations. */
225 typedef void (*exitlist_fn) __P((struct proc *procp));
227 int at_exit __P((exitlist_fn function));
228 int rm_at_exit __P((exitlist_fn function));
230 /* Fork callout list declarations. */
231 typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
234 int at_fork __P((forklist_fn function));
235 int rm_at_fork __P((forklist_fn function));
238 * Not exactly a callout LIST, but a callout entry.
239 * Allow an external module to define a hardware watchdog tickler.
240 * Normally a process would do this, but there are times when the
241 * kernel needs to be able to hold off the watchdog, when the process
242 * is not active, e.g., when dumping core.
244 typedef void (*watchdog_tickle_fn) __P((void));
246 extern watchdog_tickle_fn wdog_tickler;
249 * Common `proc' functions are declared here so that proc.h can be included
252 int msleep __P((void *chan, struct mtx *mtx, int pri, const char *wmesg,
254 #define tsleep(chan, pri, wmesg, timo) msleep(chan, NULL, pri, wmesg, timo)
255 int asleep __P((void *chan, int pri, const char *wmesg, int timo));
256 #define await(pri, timo) mawait(NULL, pri, timo)
257 int mawait __P((struct mtx *mtx, int pri, int timo));
258 void wakeup __P((void *chan));
259 void wakeup_one __P((void *chan));
262 * Common `dev_t' stuff are declared here to avoid #include poisoning
267 dev_t makedev(int x, int y);
268 udev_t dev2udev(dev_t x);
269 dev_t udev2dev(udev_t x, int b);
270 int uminor(udev_t dev);
271 int umajor(udev_t dev);
272 udev_t makeudev(int x, int y);
274 /* XXX: Should be void nanodelay(u_int nsec); */
275 void DELAY __P((int usec));
277 #endif /* !_SYS_SYSTM_H_ */