11541Srgrimes/*-
21541Srgrimes * Copyright (c) 1982, 1988, 1991, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes * (c) UNIX System Laboratories, Inc.
51541Srgrimes * All or some portions of this file are derived from material licensed
61541Srgrimes * to the University of California by American Telephone and Telegraph
71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81541Srgrimes * the permission of UNIX System Laboratories, Inc.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 4. Neither the name of the University nor the names of its contributors
191541Srgrimes *    may be used to endorse or promote products derived from this software
201541Srgrimes *    without specific prior written permission.
211541Srgrimes *
221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321541Srgrimes * SUCH DAMAGE.
331541Srgrimes *
3414508Shsu *	@(#)systm.h	8.7 (Berkeley) 3/29/95
3550477Speter * $FreeBSD: stable/11/sys/sys/systm.h 354405 2019-11-06 18:02:18Z mav $
361541Srgrimes */
371541Srgrimes
382165Spaul#ifndef _SYS_SYSTM_H_
392865Sbde#define	_SYS_SYSTM_H_
402165Spaul
4149043Salc#include <machine/atomic.h>
421549Srgrimes#include <machine/cpufunc.h>
4329683Sgibbs#include <sys/callout.h>
44120610Smux#include <sys/cdefs.h>
4594936Smux#include <sys/queue.h>
46112367Sphk#include <sys/stdint.h>		/* for people using printf mainly */
471549Srgrimes
48315282Spfg__NULLABILITY_PRAGMA_PUSH
49315282Spfg
507090Sbdeextern int cold;		/* nonzero if we are doing a cold boot */
51288446Scpercivaextern int suspend_blocked;	/* block suspend due to pending shutdown */
52214004Smarcelextern int rebooting;		/* kern_reboot() has been called. */
531541Srgrimesextern const char *panicstr;	/* panic message */
541541Srgrimesextern char version[];		/* system version */
55246254Savgextern char compiler_version[];	/* compiler version */
561541Srgrimesextern char copyright[];	/* system copyright */
57103083Speterextern int kstack_pages;	/* number of kernel stack pages */
581541Srgrimes
59197316Salcextern u_long pagesizes[];	/* supported page sizes */
60102600Speterextern long physmem;		/* physical memory */
61142834Swesextern long realmem;		/* 'real' memory */
621541Srgrimes
6336809Sbdeextern char *rootdevnames[2];	/* names of possible root devices */
641541Srgrimes
651541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
6615113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
671541Srgrimes
6880418Speterextern int maxusers;		/* system tune hint */
69202143Sbrooksextern int ngroups_max;		/* max # of supplemental groups */
70204420Salcextern int vm_guest;		/* Running as virtual machine guest? */
7180418Speter
72204633Sivoras/*
73204633Sivoras * Detected virtual machine guest types. The intention is to expand
74204611Sivoras * and/or add to the VM_GUEST_VM type if specific VM functionality is
75204633Sivoras * ever implemented (e.g. vendor-specific paravirtualization features).
76258001Spluknet * Keep in sync with vm_guest_sysctl_names[].
77204633Sivoras */
78258069Spluknetenum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
79320568Saraujo		VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_LAST };
80204420Salc
81302349Sglebius#if defined(WITNESS) || defined(INVARIANT_SUPPORT)
82253007Salfredvoid	kassert_panic(const char *fmt, ...)  __printflike(1, 2);
83244105Salfred#endif
84243980Salfred
85244105Salfred#ifdef	INVARIANTS		/* The option is always available */
86120610Smux#define	KASSERT(exp,msg) do {						\
87120610Smux	if (__predict_false(!(exp)))					\
88287931Sglebius		kassert_panic msg;					\
89120610Smux} while (0)
90141458Sphk#define	VNASSERT(exp, vp, msg) do {					\
91141458Sphk	if (__predict_false(!(exp))) {					\
92182909Sjhb		vn_printf(vp, "VNASSERT failed\n");			\
93287931Sglebius		kassert_panic msg;					\
94141458Sphk	}								\
95141458Sphk} while (0)
9642408Seivind#else
97165547Skmacy#define	KASSERT(exp,msg) do { \
98165547Skmacy} while (0)
99165547Skmacy
100165547Skmacy#define	VNASSERT(exp, vp, msg) do { \
101165547Skmacy} while (0)
10242408Seivind#endif
10342408Seivind
104228478Sed#ifndef CTASSERT	/* Allow lint to override */
105228478Sed#define	CTASSERT(x)	_Static_assert(x, "compile-time assertion failed")
106109316Sphk#endif
10793600Sjake
108196334Sattilio/*
109196334Sattilio * Assert that a pointer can be loaded from memory atomically.
110196334Sattilio *
111196334Sattilio * This assertion enforces stronger alignment than necessary.  For example,
112196334Sattilio * on some architectures, atomicity for unaligned loads will depend on
113196334Sattilio * whether or not the load spans multiple cache lines.
114196334Sattilio */
115196334Sattilio#define	ASSERT_ATOMIC_LOAD_PTR(var, msg)				\
116196334Sattilio	KASSERT(sizeof(var) == sizeof(void *) &&			\
117196334Sattilio	    ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg)
118196226Sbz
1191541Srgrimes/*
120249189Sglebius * Assert that a thread is in critical(9) section.
121249189Sglebius */
122249189Sglebius#define	CRITICAL_ASSERT(td)						\
123249189Sglebius	KASSERT((td)->td_critnest >= 1, ("Not in critical section"));
124249189Sglebius
125249189Sglebius/*
126228424Savg * If we have already panic'd and this is the thread that called
127228424Savg * panic(), then don't block on any mutexes but silently succeed.
128228424Savg * Otherwise, the kernel will deadlock since the scheduler isn't
129228424Savg * going to run the thread that holds any lock we need.
130228424Savg */
131315386Smjg#define	SCHEDULER_STOPPED_TD(td)  ({					\
132315386Smjg	MPASS((td) == curthread);					\
133315386Smjg	__predict_false((td)->td_stopsched);				\
134315386Smjg})
135315386Smjg#define	SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
136228424Savg
137228424Savg/*
138315284Smjg * Align variables.
139315284Smjg */
140315284Smjg#define	__read_mostly		__section(".data.read_mostly")
141327409Smjg#define	__read_frequently	__section(".data.read_frequently")
142315284Smjg#define	__exclusive_cache_line	__aligned(CACHE_LINE_SIZE) \
143315284Smjg				    __section(".data.exclusive_cache_line")
144315284Smjg/*
14583595Speter * XXX the hints declarations are even more misplaced than most declarations
14683595Speter * in this file, since they are needed in one file (per arch) and only used
14783595Speter * in two files.
14883595Speter * XXX most of these variables should be const.
14983595Speter */
150174253Skibextern int osreldate;
151337336Skevansextern bool dynamic_kenv;
152160217Sscottlextern struct mtx kenv_lock;
15383595Speterextern char *kern_envp;
154337333Skevansextern char *md_envp;
15583595Speterextern char static_env[];
15683595Speterextern char static_hints[];	/* by config for now */
15783595Speter
15894936Smuxextern char **kenvp;
15994936Smux
160221853Smdfextern const void *zero_region;	/* address space maps to a zeroed page	*/
161221853Smdf
162248508Skibextern int unmapped_buf_allowed;
163231949Skib
164297493Sjhb#ifdef __LP64__
165297493Sjhb#define	IOSIZE_MAX		iosize_max()
166297493Sjhb#define	DEVFS_IOSIZE_MAX	devfs_iosize_max()
167297493Sjhb#else
168297493Sjhb#define	IOSIZE_MAX		SSIZE_MAX
169297493Sjhb#define	DEVFS_IOSIZE_MAX	SSIZE_MAX
170297493Sjhb#endif
171297493Sjhb
17283595Speter/*
1731541Srgrimes * General function declarations.
1741541Srgrimes */
17530282Sphk
176183982Sbzstruct inpcb;
177167387Sjhbstruct lock_object;
17830282Sphkstruct malloc_type;
17965708Sjakestruct mtx;
18033777Sbdestruct proc;
18192976Srwatsonstruct socket;
18283366Sjulianstruct thread;
18333777Sbdestruct tty;
18467893Sphkstruct ucred;
18533777Sbdestruct uio;
18679418Sjulianstruct _jmp_buf;
187210131Smavstruct trapframe;
188264041Sianstruct eventtimer;
18930282Sphk
190234785Sdimint	setjmp(struct _jmp_buf *) __returns_twice;
19192719Salfredvoid	longjmp(struct _jmp_buf *, int) __dead2;
19292719Salfredint	dumpstatus(vm_offset_t addr, off_t count);
19392719Salfredint	nullop(void);
19492719Salfredint	eopnotsupp(void);
19592719Salfredint	ureadc(int, struct uio *);
19699098Siedowsevoid	hashdestroy(void *, struct malloc_type *, u_long);
197220987Skibvoid	*hashinit(int count, struct malloc_type *type, u_long *hashmask);
198166022Srrsvoid	*hashinit_flags(int count, struct malloc_type *type,
199166022Srrs    u_long *hashmask, int flags);
200166022Srrs#define	HASH_NOWAIT	0x00000001
201166022Srrs#define	HASH_WAITOK	0x00000002
202166022Srrs
20392719Salfredvoid	*phashinit(int count, struct malloc_type *type, u_long *nentries);
204298956Ssephevoid	*phashinit_flags(int count, struct malloc_type *type, u_long *nentries,
205298956Ssephe    int flags);
206136836Sphkvoid	g_waitidle(void);
2071541Srgrimes
208130164Sphkvoid	panic(const char *, ...) __dead2 __printflike(1, 2);
209281915Smarkjvoid	vpanic(const char *, __va_list) __dead2 __printflike(1, 0);
21090503Sbde
21192719Salfredvoid	cpu_boot(int);
212192323Smarcelvoid	cpu_flush_dcache(void *, size_t);
21392719Salfredvoid	cpu_rootconf(void);
21492719Salfredvoid	critical_enter(void);
21592719Salfredvoid	critical_exit(void);
21692719Salfredvoid	init_param1(void);
217102600Spetervoid	init_param2(long physpages);
218202050Simpvoid	init_static_kenv(char *, size_t);
21992719Salfredvoid	tablefull(const char *);
220261038Simp#ifdef  EARLY_PRINTF
221261786Siantypedef void early_putc_t(int ch);
222261786Sianextern early_putc_t *early_putc;
223261038Simp#endif
22492719Salfredint	kvprintf(char const *, void (*)(int, void*), void *, int,
225102227Smike	    __va_list) __printflike(1, 0);
22692719Salfredvoid	log(int, const char *, ...) __printflike(2, 3);
22792719Salfredvoid	log_console(struct uio *);
228291058Smarkjvoid	vlog(int, const char *, __va_list) __printflike(2, 0);
229279433Srstoneint	asprintf(char **ret, struct malloc_type *mtp, const char *format,
230279433Srstone	    ...) __printflike(3, 4);
23192719Salfredint	printf(const char *, ...) __printflike(1, 2);
23292719Salfredint	snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
23392719Salfredint	sprintf(char *buf, const char *, ...) __printflike(2, 3);
23492719Salfredint	uprintf(const char *, ...) __printflike(1, 2);
235102227Smikeint	vprintf(const char *, __va_list) __printflike(1, 0);
236279433Srstoneint	vasprintf(char **ret, struct malloc_type *mtp, const char *format,
237279433Srstone	    __va_list ap) __printflike(3, 0);
238102227Smikeint	vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
239137098Sdesint	vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
240102227Smikeint	vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
24192719Salfredint	ttyprintf(struct tty *, const char *, ...) __printflike(2, 3);
242315282Spfgint	sscanf(const char *, char const * _Nonnull, ...) __scanflike(2, 3);
243315282Spfgint	vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list)  __scanflike(2, 0);
244315282Spfglong	strtol(const char *, char **, int);
245315282Spfgu_long	strtoul(const char *, char **, int);
246315282Spfgquad_t	strtoq(const char *, char **, int);
247315282Spfgu_quad_t strtouq(const char *, char **, int);
24892719Salfredvoid	tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
249255351Snpvoid	vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
250144706Sphkvoid	hexdump(const void *ptr, int length, const char *hdr, int flags);
251123215Sscottl#define	HD_COLUMN_MASK	0xff
252123215Sscottl#define	HD_DELIM_MASK	0xff00
253123215Sscottl#define	HD_OMIT_COUNT	(1 << 16)
254123215Sscottl#define	HD_OMIT_HEX	(1 << 17)
255123215Sscottl#define	HD_OMIT_CHARS	(1 << 18)
2561541Srgrimes
257113090Sdes#define ovbcopy(f, t, l) bcopy((f), (t), (l))
258315282Spfgvoid	bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
259315282Spfgvoid	bzero(void * _Nonnull buf, size_t len);
260315282Spfgvoid	explicit_bzero(void * _Nonnull, size_t);
2611541Srgrimes
262315282Spfgvoid	*memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
263315282Spfgvoid	*memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n);
2648215Sdg
265315282Spfgint	copystr(const void * _Nonnull __restrict kfaddr,
266315282Spfg	    void * _Nonnull __restrict kdaddr, size_t len,
267315282Spfg	    size_t * __restrict lencopied);
268315282Spfgint	copyinstr(const void * __restrict udaddr,
269315282Spfg	    void * _Nonnull __restrict kaddr, size_t len,
270315282Spfg	    size_t * __restrict lencopied);
271330691Skibint	copyin(const void * __restrict udaddr,
272315282Spfg	    void * _Nonnull __restrict kaddr, size_t len);
273330691Skibint	copyin_nofault(const void * __restrict udaddr,
274315282Spfg	    void * _Nonnull __restrict kaddr, size_t len);
275315282Spfgint	copyout(const void * _Nonnull __restrict kaddr,
276330691Skib	    void * __restrict udaddr, size_t len);
277315282Spfgint	copyout_nofault(const void * _Nonnull __restrict kaddr,
278330691Skib	    void * __restrict udaddr, size_t len);
2791541Srgrimes
280273911Skibint	fubyte(volatile const void *base);
281273911Skiblong	fuword(volatile const void *base);
282273911Skibint	fuword16(volatile const void *base);
283273911Skibint32_t	fuword32(volatile const void *base);
284273911Skibint64_t	fuword64(volatile const void *base);
285273911Skibint	fueword(volatile const void *base, long *val);
286273911Skibint	fueword32(volatile const void *base, int32_t *val);
287273911Skibint	fueword64(volatile const void *base, int64_t *val);
288273911Skibint	subyte(volatile void *base, int byte);
289273911Skibint	suword(volatile void *base, long word);
290273911Skibint	suword16(volatile void *base, int word);
291273911Skibint	suword32(volatile void *base, int32_t word);
292273911Skibint	suword64(volatile void *base, int64_t word);
293163449Sdavidxuuint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
294273783Skibu_long	casuword(volatile u_long *p, u_long oldval, u_long newval);
295273783Skibint	casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,
296273783Skib	    uint32_t newval);
297273783Skibint	casueword(volatile u_long *p, u_long oldval, u_long *oldvalp,
298273783Skib	    u_long newval);
2991541Srgrimes
30092719Salfredvoid	realitexpire(void *);
3011541Srgrimes
302177642Sphkint	sysbeep(int hertz, int period);
303177642Sphk
304153666Sjhbvoid	hardclock(int usermode, uintfptr_t pc);
305232783Smavvoid	hardclock_cnt(int cnt, int usermode);
306153666Sjhbvoid	hardclock_cpu(int usermode);
307212541Smavvoid	hardclock_sync(int cpu);
30892719Salfredvoid	softclock(void *);
309153666Sjhbvoid	statclock(int usermode);
310232783Smavvoid	statclock_cnt(int cnt, int usermode);
311153666Sjhbvoid	profclock(int usermode, uintfptr_t pc);
312232783Smavvoid	profclock_cnt(int cnt, int usermode, uintfptr_t pc);
3131541Srgrimes
314212541Smavint	hardclockintr(void);
315210131Smav
31692719Salfredvoid	startprofclock(struct proc *);
31792719Salfredvoid	stopprofclock(struct proc *);
318110296Sjakevoid	cpu_startprofclock(void);
319110296Sjakevoid	cpu_stopprofclock(void);
320335656Savgvoid	suspendclock(void);
321335656Savgvoid	resumeclock(void);
322247454Sdavidesbintime_t 	cpu_idleclock(void);
323212541Smavvoid	cpu_activeclock(void);
324247777Sdavidevoid	cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);
325264041Sianvoid	cpu_et_frequency(struct eventtimer *et, uint64_t newfreq);
326276724Sjhbextern int	cpu_disable_c2_sleep;
327276724Sjhbextern int	cpu_disable_c3_sleep;
3281541Srgrimes
32992719Salfredint	cr_cansee(struct ucred *u1, struct ucred *u2);
33092976Srwatsonint	cr_canseesocket(struct ucred *cred, struct socket *so);
331183982Sbzint	cr_canseeinpcb(struct ucred *cred, struct inpcb *inp);
33267893Sphk
333273174Sdavidechar	*kern_getenv(const char *name);
33494936Smuxvoid	freeenv(char *env);
33592719Salfredint	getenv_int(const char *name, int *data);
336172612Sdesint	getenv_uint(const char *name, unsigned int *data);
337172612Sdesint	getenv_long(const char *name, long *data);
338172612Sdesint	getenv_ulong(const char *name, unsigned long *data);
33992719Salfredint	getenv_string(const char *name, char *data, int size);
340298025Simpint	getenv_int64(const char *name, int64_t *data);
341298025Simpint	getenv_uint64(const char *name, uint64_t *data);
34292719Salfredint	getenv_quad(const char *name, quad_t *data);
343273174Sdavideint	kern_setenv(const char *name, const char *value);
344273174Sdavideint	kern_unsetenv(const char *name);
34594936Smuxint	testenv(const char *name);
34640096Smsmith
347335699Shselaskyint	getenv_array(const char *name, void *data, int size, int *psize,
348335699Shselasky    int type_size, bool allow_signed);
349335699Shselasky#define	GETENV_UNSIGNED	false	/* negative numbers not allowed */
350335699Shselasky#define	GETENV_SIGNED	true	/* negative numbers allowed */
351335699Shselasky
352155534Sphktypedef uint64_t (cpu_tick_f)(void);
353155534Sphkvoid set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var);
354155534Sphkextern cpu_tick_f *cpu_ticks;
355155534Sphkuint64_t cpu_tickrate(void);
356155534Sphkuint64_t cputick2usec(uint64_t tick);
357155444Sphk
358137098Sdes#ifdef APM_FIXUP_CALLTODO
35983595Speterstruct timeval;
360137098Sdesvoid	adjust_timeout_calltodo(struct timeval *time_change);
361137098Sdes#endif /* APM_FIXUP_CALLTODO */
36231960Snate
3637109Sphk#include <sys/libkern.h>
3642112Swollman
3652112Swollman/* Initialize the world */
36692719Salfredvoid	consinit(void);
36792719Salfredvoid	cpu_initclocks(void);
368209371Smavvoid	cpu_initclocks_bsp(void);
369209371Smavvoid	cpu_initclocks_ap(void);
37092719Salfredvoid	usrinfoinit(void);
3712112Swollman
372167111Sthomas/* Finalize the world */
373214004Smarcelvoid	kern_reboot(int) __dead2;
37492719Salfredvoid	shutdown_nice(int);
3757090Sbde
3762112Swollman/* Timeouts */
37792719Salfredtypedef void timeout_t(void *);	/* timeout function type */
37829683Sgibbs#define CALLOUT_HANDLE_INITIALIZER(handle)	\
37929683Sgibbs	{ NULL }
3802112Swollman
38192719Salfredvoid	callout_handle_init(struct callout_handle *);
38292719Salfredstruct	callout_handle timeout(timeout_t *, void *, int);
38392719Salfredvoid	untimeout(timeout_t *, void *, struct callout_handle);
3842165Spaul
385167111Sthomas/* Stubs for obsolete functions that used to be for interrupt management */
38671240Speterstatic __inline intrmask_t	splbio(void)		{ return 0; }
38771240Speterstatic __inline intrmask_t	splcam(void)		{ return 0; }
38871240Speterstatic __inline intrmask_t	splclock(void)		{ return 0; }
38971240Speterstatic __inline intrmask_t	splhigh(void)		{ return 0; }
39071240Speterstatic __inline intrmask_t	splimp(void)		{ return 0; }
39171240Speterstatic __inline intrmask_t	splnet(void)		{ return 0; }
39271240Speterstatic __inline intrmask_t	spltty(void)		{ return 0; }
393100073Smarkmstatic __inline void		splx(intrmask_t ipl __unused)	{ return; }
39426312Speter
395137098Sdes/*
39618884Sbde * Common `proc' functions are declared here so that proc.h can be included
39718884Sbde * less often.
39818884Sbde */
399315282Spfgint	_sleep(void * _Nonnull chan, struct lock_object *lock, int pri,
400315282Spfg	   const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
401167387Sjhb#define	msleep(chan, mtx, pri, wmesg, timo)				\
402247787Sdavide	_sleep((chan), &(mtx)->lock_object, (pri), (wmesg),		\
403247787Sdavide	    tick_sbt * (timo), 0, C_HARDCLOCK)
404247787Sdavide#define	msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags)		\
405247787Sdavide	_sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr),	\
406247787Sdavide	    (flags))
407315282Spfgint	msleep_spin_sbt(void * _Nonnull chan, struct mtx *mtx,
408315282Spfg	    const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
409247787Sdavide#define	msleep_spin(chan, mtx, wmesg, timo)				\
410247787Sdavide	msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo),	\
411247787Sdavide	    0, C_HARDCLOCK)
412247787Sdavideint	pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
413247787Sdavide	    int flags);
414247787Sdavide#define	pause(wmesg, timo)						\
415247787Sdavide	pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK)
416330850Shselasky#define	pause_sig(wmesg, timo)						\
417330850Shselasky	pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH)
418167387Sjhb#define	tsleep(chan, pri, wmesg, timo)					\
419247787Sdavide	_sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo),		\
420247787Sdavide	    0, C_HARDCLOCK)
421247787Sdavide#define	tsleep_sbt(chan, pri, wmesg, bt, pr, flags)			\
422247787Sdavide	_sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags))
423315282Spfgvoid	wakeup(void * chan);
424315282Spfgvoid	wakeup_one(void * chan);
425354405Smavvoid	wakeup_any(void * chan);
42618884Sbde
42747028Sphk/*
428130585Sphk * Common `struct cdev *' stuff are declared here to avoid #include poisoning
42947028Sphk */
43047028Sphk
431138509Sphkstruct cdev;
432130640Sphkdev_t dev2udev(struct cdev *x);
433143622Sphkconst char *devtoname(struct cdev *cdev);
43467158Sphk
435297493Sjhb#ifdef __LP64__
436297493Sjhbsize_t	devfs_iosize_max(void);
437297493Sjhbsize_t	iosize_max(void);
438297493Sjhb#endif
439297493Sjhb
440189450Skibint poll_no_poll(int events);
441189450Skib
44267158Sphk/* XXX: Should be void nanodelay(u_int nsec); */
44392719Salfredvoid	DELAY(int usec);
44467158Sphk
445145250Sphk/* Root mount holdback API */
446145250Sphkstruct root_hold_token;
447145250Sphk
448190878Sthompsastruct root_hold_token *root_mount_hold(const char *identifier);
449145250Sphkvoid root_mount_rel(struct root_hold_token *h);
450168506Spjdint root_mounted(void);
451145250Sphk
452145250Sphk
453135956Sphk/*
454135956Sphk * Unit number allocation API. (kern/subr_unit.c)
455135956Sphk */
456135956Sphkstruct unrhdr;
457143283Sphkstruct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
458255057Skibvoid init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex);
459136945Sphkvoid delete_unrhdr(struct unrhdr *uh);
460171202Skibvoid clean_unrhdr(struct unrhdr *uh);
461171202Skibvoid clean_unrhdrl(struct unrhdr *uh);
462143283Sphkint alloc_unr(struct unrhdr *uh);
463209710Sjhint alloc_unr_specific(struct unrhdr *uh, u_int item);
464143283Sphkint alloc_unrl(struct unrhdr *uh);
465135956Sphkvoid free_unr(struct unrhdr *uh, u_int item);
466135956Sphk
467272536Skibvoid	intr_prof_stack_use(struct thread *td, struct trapframe *frame);
468272536Skib
469303432Skibvoid counted_warning(unsigned *counter, const char *msg);
470303432Skib
471331747Sbrooks/*
472331747Sbrooks * APIs to manage deprecation and obsolescence.
473331747Sbrooks */
474331747Sbrooksstruct device;
475331747Sbrooksvoid _gone_in(int major, const char *msg);
476331747Sbrooksvoid _gone_in_dev(struct device *dev, int major, const char *msg);
477331747Sbrooks#ifdef NO_OBSOLETE_CODE
478331747Sbrooks#define __gone_ok(m, msg)					 \
479331747Sbrooks	_Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)),	 \
480331747Sbrooks	    "Obsolete code" msg);
481331747Sbrooks#else
482331747Sbrooks#define	__gone_ok(m, msg)
483331747Sbrooks#endif
484331747Sbrooks#define gone_in(major, msg)		__gone_ok(major, msg) _gone_in(major, msg)
485331747Sbrooks#define gone_in_dev(dev, major, msg)	__gone_ok(major, msg) _gone_in_dev(dev, major, msg)
486347962Sbrooks#define	gone_by_fcp101_dev(dev)						\
487347962Sbrooks	gone_in_dev((dev), 13,						\
488347962Sbrooks	    "see https://github.com/freebsd/fcp/blob/master/fcp-0101.md")
489331747Sbrooks
490315282Spfg__NULLABILITY_PRAGMA_POP
491315282Spfg
4922865Sbde#endif /* !_SYS_SYSTM_H_ */
493