xref: /freebsd/sys/amd64/include/cpufunc.h (revision b5ba45f6f3e4f97320fe94902e3f3533eb8debfd)
13c4dd356SDavid Greenman /*-
23c4dd356SDavid Greenman  * Copyright (c) 1993 The Regents of the University of California.
33c4dd356SDavid Greenman  * All rights reserved.
43c4dd356SDavid Greenman  *
53c4dd356SDavid Greenman  * Redistribution and use in source and binary forms, with or without
63c4dd356SDavid Greenman  * modification, are permitted provided that the following conditions
73c4dd356SDavid Greenman  * are met:
83c4dd356SDavid Greenman  * 1. Redistributions of source code must retain the above copyright
93c4dd356SDavid Greenman  *    notice, this list of conditions and the following disclaimer.
103c4dd356SDavid Greenman  * 2. Redistributions in binary form must reproduce the above copyright
113c4dd356SDavid Greenman  *    notice, this list of conditions and the following disclaimer in the
123c4dd356SDavid Greenman  *    documentation and/or other materials provided with the distribution.
133c4dd356SDavid Greenman  * 3. All advertising materials mentioning features or use of this software
143c4dd356SDavid Greenman  *    must display the following acknowledgement:
153c4dd356SDavid Greenman  *	This product includes software developed by the University of
163c4dd356SDavid Greenman  *	California, Berkeley and its contributors.
173c4dd356SDavid Greenman  * 4. Neither the name of the University nor the names of its contributors
183c4dd356SDavid Greenman  *    may be used to endorse or promote products derived from this software
193c4dd356SDavid Greenman  *    without specific prior written permission.
203c4dd356SDavid Greenman  *
213c4dd356SDavid Greenman  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
223c4dd356SDavid Greenman  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
233c4dd356SDavid Greenman  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
243c4dd356SDavid Greenman  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
253c4dd356SDavid Greenman  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
263c4dd356SDavid Greenman  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
273c4dd356SDavid Greenman  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
283c4dd356SDavid Greenman  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
293c4dd356SDavid Greenman  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
303c4dd356SDavid Greenman  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313c4dd356SDavid Greenman  * SUCH DAMAGE.
323c4dd356SDavid Greenman  *
33b5ba45f6SDavid Greenman  *	$Id: cpufunc.h,v 1.30 1994/11/15 14:55:25 bde Exp $
343c4dd356SDavid Greenman  */
353c4dd356SDavid Greenman 
365b81b6b3SRodney W. Grimes /*
375b81b6b3SRodney W. Grimes  * Functions to provide access to special i386 instructions.
385b81b6b3SRodney W. Grimes  */
395b81b6b3SRodney W. Grimes 
406e393973SGarrett Wollman #ifndef _MACHINE_CPUFUNC_H_
41004bedebSBruce Evans #define	_MACHINE_CPUFUNC_H_
426e393973SGarrett Wollman 
435b81b6b3SRodney W. Grimes #include <sys/cdefs.h>
445b81b6b3SRodney W. Grimes #include <sys/types.h>
455b81b6b3SRodney W. Grimes 
46004bedebSBruce Evans #include <machine/spl.h>	/* XXX belongs elsewhere */
47d2306226SDavid Greenman 
485b81b6b3SRodney W. Grimes #ifdef	__GNUC__
495b81b6b3SRodney W. Grimes 
50004bedebSBruce Evans #ifdef BDE_DEBUGGER
515b81b6b3SRodney W. Grimes extern int	bdb_exists;
525b81b6b3SRodney W. Grimes 
53004bedebSBruce Evans static __inline int
54004bedebSBruce Evans bdb(void)
55004bedebSBruce Evans {
565b81b6b3SRodney W. Grimes 	if (!bdb_exists)
575b81b6b3SRodney W. Grimes 		return (0);
58004bedebSBruce Evans 	__asm __volatile("int $3");
595b81b6b3SRodney W. Grimes 	return (1);
605b81b6b3SRodney W. Grimes }
61004bedebSBruce Evans #endif /* BDE_DEBUGGER */
625b81b6b3SRodney W. Grimes 
63004bedebSBruce Evans static __inline void
645b81b6b3SRodney W. Grimes disable_intr(void)
655b81b6b3SRodney W. Grimes {
665b81b6b3SRodney W. Grimes 	__asm __volatile("cli");
675b81b6b3SRodney W. Grimes }
685b81b6b3SRodney W. Grimes 
69004bedebSBruce Evans static __inline void
705b81b6b3SRodney W. Grimes enable_intr(void)
715b81b6b3SRodney W. Grimes {
725b81b6b3SRodney W. Grimes 	__asm __volatile("sti");
735b81b6b3SRodney W. Grimes }
745b81b6b3SRodney W. Grimes 
75004bedebSBruce Evans #define	HAVE_INLINE_FFS
76004bedebSBruce Evans 
77004bedebSBruce Evans static __inline int
78004bedebSBruce Evans ffs(int mask)
79004bedebSBruce Evans {
80004bedebSBruce Evans 	int	result;
81004bedebSBruce Evans 	/*
82004bedebSBruce Evans 	 * bsfl turns out to be not all that slow on 486's.  It can beaten
83004bedebSBruce Evans 	 * using a binary search to reduce to 4 bits and then a table lookup,
84004bedebSBruce Evans 	 * but only if the code is inlined and in the cache, and the code
85004bedebSBruce Evans 	 * is quite large so inlining it probably busts the cache.
86004bedebSBruce Evans 	 *
87004bedebSBruce Evans 	 * Note that gcc-2's builtin ffs would be used if we didn't declare
88004bedebSBruce Evans 	 * this inline or turn off the builtin.  The builtin is faster but
89004bedebSBruce Evans 	 * broken in gcc-2.4.5 and slower but working in gcc-2.5 and 2.6.
90004bedebSBruce Evans 	 */
91004bedebSBruce Evans 	__asm __volatile("testl %0,%0; je 1f; bsfl %0,%0; incl %0; 1:"
92004bedebSBruce Evans 			 : "=r" (result) : "0" (mask));
93004bedebSBruce Evans 	return (result);
94004bedebSBruce Evans }
95004bedebSBruce Evans 
96004bedebSBruce Evans #if __GNUC__ < 2
97004bedebSBruce Evans 
98004bedebSBruce Evans #define	inb(port)		inbv(port)
99004bedebSBruce Evans #define	outb(port, data)	outbv(port, data)
100004bedebSBruce Evans 
101004bedebSBruce Evans #else /* __GNUC >= 2 */
102004bedebSBruce Evans 
103004bedebSBruce Evans /*
104004bedebSBruce Evans  * Use an expression-statement instead of a conditional expression
105004bedebSBruce Evans  * because gcc-2.6.0 would promote the operands of the conditional
106004bedebSBruce Evans  * and produce poor code for "if ((inb(var) & const1) == const2)".
107004bedebSBruce Evans  */
108004bedebSBruce Evans #define	inb(port)	({						\
109004bedebSBruce Evans 	u_char	_data;							\
110004bedebSBruce Evans 	if (__builtin_constant_p((int) (port)) && (port) < 256ul)	\
111004bedebSBruce Evans 		_data = inbc(port);					\
112004bedebSBruce Evans 	else								\
113004bedebSBruce Evans 		_data = inbv(port);					\
114004bedebSBruce Evans 	_data; })
115004bedebSBruce Evans 
116004bedebSBruce Evans #define	outb(port, data) \
117004bedebSBruce Evans 	(__builtin_constant_p((int) (port)) && (port) < 256ul \
118004bedebSBruce Evans 	 ? outbc(port, data) : outbv(port, data))
119004bedebSBruce Evans 
120004bedebSBruce Evans static __inline u_char
121004bedebSBruce Evans inbc(u_int port)
122004bedebSBruce Evans {
123004bedebSBruce Evans 	u_char	data;
124004bedebSBruce Evans 
125004bedebSBruce Evans 	__asm __volatile("inb %1,%0" : "=a" (data) : "i" (port));
126004bedebSBruce Evans 	return (data);
127004bedebSBruce Evans }
128004bedebSBruce Evans 
129004bedebSBruce Evans static __inline void
130004bedebSBruce Evans outbc(u_int port, u_char data)
131004bedebSBruce Evans {
132004bedebSBruce Evans 	__asm __volatile("outb %0,%1" : : "a" (data), "i" (port));
133004bedebSBruce Evans }
134004bedebSBruce Evans 
135004bedebSBruce Evans #endif /* __GNUC <= 2 */
136004bedebSBruce Evans 
137004bedebSBruce Evans static __inline u_char
138004bedebSBruce Evans inbv(u_int port)
139004bedebSBruce Evans {
140004bedebSBruce Evans 	u_char	data;
141004bedebSBruce Evans 	/*
142004bedebSBruce Evans 	 * We use %%dx and not %1 here because i/o is done at %dx and not at
143004bedebSBruce Evans 	 * %edx, while gcc generates inferior code (movw instead of movl)
144004bedebSBruce Evans 	 * if we tell it to load (u_short) port.
145004bedebSBruce Evans 	 */
146004bedebSBruce Evans 	__asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
147004bedebSBruce Evans 	return (data);
148004bedebSBruce Evans }
149004bedebSBruce Evans 
150004bedebSBruce Evans static __inline u_long
151004bedebSBruce Evans inl(u_int port)
152004bedebSBruce Evans {
153004bedebSBruce Evans 	u_long	data;
154004bedebSBruce Evans 
155004bedebSBruce Evans 	__asm __volatile("inl %%dx,%0" : "=a" (data) : "d" (port));
156004bedebSBruce Evans 	return (data);
157004bedebSBruce Evans }
158004bedebSBruce Evans 
159004bedebSBruce Evans static __inline void
160004bedebSBruce Evans insb(u_int port, void *addr, size_t cnt)
161004bedebSBruce Evans {
162004bedebSBruce Evans 	__asm __volatile("cld; rep; insb"
163004bedebSBruce Evans 			 : : "d" (port), "D" (addr), "c" (cnt)
164004bedebSBruce Evans 			 : "di", "cx", "memory");
165004bedebSBruce Evans }
166004bedebSBruce Evans 
167004bedebSBruce Evans static __inline void
168004bedebSBruce Evans insw(u_int port, void *addr, size_t cnt)
169004bedebSBruce Evans {
170004bedebSBruce Evans 	__asm __volatile("cld; rep; insw"
171004bedebSBruce Evans 			 : : "d" (port), "D" (addr), "c" (cnt)
172004bedebSBruce Evans 			 : "di", "cx", "memory");
173004bedebSBruce Evans }
174004bedebSBruce Evans 
175004bedebSBruce Evans static __inline void
176004bedebSBruce Evans insl(u_int port, void *addr, size_t cnt)
177004bedebSBruce Evans {
178004bedebSBruce Evans 	__asm __volatile("cld; rep; insl"
179004bedebSBruce Evans 			 : : "d" (port), "D" (addr), "c" (cnt)
180004bedebSBruce Evans 			 : "di", "cx", "memory");
181004bedebSBruce Evans }
182004bedebSBruce Evans 
183004bedebSBruce Evans static __inline u_short
184004bedebSBruce Evans inw(u_int port)
185004bedebSBruce Evans {
186004bedebSBruce Evans 	u_short	data;
187004bedebSBruce Evans 
188004bedebSBruce Evans 	__asm __volatile("inw %%dx,%0" : "=a" (data) : "d" (port));
189004bedebSBruce Evans 	return (data);
190004bedebSBruce Evans }
191004bedebSBruce Evans 
192004bedebSBruce Evans static __inline void
193004bedebSBruce Evans outbv(u_int port, u_char data)
194004bedebSBruce Evans {
195004bedebSBruce Evans 	u_char	al;
196004bedebSBruce Evans 	/*
197004bedebSBruce Evans 	 * Use an unnecessary assignment to help gcc's register allocator.
198004bedebSBruce Evans 	 * This make a large difference for gcc-1.40 and a tiny difference
199004bedebSBruce Evans 	 * for gcc-2.6.0.  For gcc-1.40, al had to be ``asm("ax")'' for
200004bedebSBruce Evans 	 * best results.  gcc-2.6.0 can't handle this.
201004bedebSBruce Evans 	 */
202004bedebSBruce Evans 	al = data;
203004bedebSBruce Evans 	__asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
204004bedebSBruce Evans }
205004bedebSBruce Evans 
206004bedebSBruce Evans static __inline void
207004bedebSBruce Evans outl(u_int port, u_long data)
208004bedebSBruce Evans {
209004bedebSBruce Evans 	/*
210004bedebSBruce Evans 	 * outl() and outw() aren't used much so we haven't looked at
211004bedebSBruce Evans 	 * possible micro-optimizations such as the unnecessary
212004bedebSBruce Evans 	 * assignment for them.
213004bedebSBruce Evans 	 */
214004bedebSBruce Evans 	__asm __volatile("outl %0,%%dx" : : "a" (data), "d" (port));
215004bedebSBruce Evans }
216004bedebSBruce Evans 
217004bedebSBruce Evans static __inline void
218004bedebSBruce Evans outsb(u_int port, void *addr, size_t cnt)
219004bedebSBruce Evans {
220004bedebSBruce Evans 	__asm __volatile("cld; rep; outsb"
221004bedebSBruce Evans 			 : : "d" (port), "S" (addr), "c" (cnt)
222b5ba45f6SDavid Greenman 			 : "si", "cx");
223004bedebSBruce Evans }
224004bedebSBruce Evans 
225004bedebSBruce Evans static __inline void
226004bedebSBruce Evans outsw(u_int port, void *addr, size_t cnt)
227004bedebSBruce Evans {
228004bedebSBruce Evans 	__asm __volatile("cld; rep; outsw"
229004bedebSBruce Evans 			 : : "d" (port), "S" (addr), "c" (cnt)
230b5ba45f6SDavid Greenman 			 : "si", "cx");
231004bedebSBruce Evans }
232004bedebSBruce Evans 
233004bedebSBruce Evans static __inline void
234004bedebSBruce Evans outsl(u_int port, void *addr, size_t cnt)
235004bedebSBruce Evans {
236004bedebSBruce Evans 	__asm __volatile("cld; rep; outsl"
237004bedebSBruce Evans 			 : : "d" (port), "S" (addr), "c" (cnt)
238b5ba45f6SDavid Greenman 			 : "si", "cx");
239004bedebSBruce Evans }
240004bedebSBruce Evans 
241004bedebSBruce Evans static __inline void
242004bedebSBruce Evans outw(u_int port, u_short data)
243004bedebSBruce Evans {
244004bedebSBruce Evans 	__asm __volatile("outw %0,%%dx" : : "a" (data), "d" (port));
245004bedebSBruce Evans }
246004bedebSBruce Evans 
247004bedebSBruce Evans static __inline void
248004bedebSBruce Evans pmap_update(void)
249004bedebSBruce Evans {
250004bedebSBruce Evans 	u_long	temp;
251004bedebSBruce Evans 	/*
252004bedebSBruce Evans 	 * This should be implemented as load_cr3(rcr3()) when load_cr3()
253004bedebSBruce Evans 	 * is inlined.
254004bedebSBruce Evans 	 */
255004bedebSBruce Evans 	__asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp));
256004bedebSBruce Evans }
257004bedebSBruce Evans 
258004bedebSBruce Evans static __inline u_long
259004bedebSBruce Evans rcr2(void)
260004bedebSBruce Evans {
261004bedebSBruce Evans 	u_long	data;
262004bedebSBruce Evans 
263004bedebSBruce Evans 	__asm __volatile("movl %%cr2,%0" : "=r" (data));
264004bedebSBruce Evans 	return (data);
265004bedebSBruce Evans }
266004bedebSBruce Evans 
267004bedebSBruce Evans static __inline u_long
268004bedebSBruce Evans read_eflags(void)
2695b81b6b3SRodney W. Grimes {
2708db02de8SPaul Richards 	u_long	ef;
271004bedebSBruce Evans 
272004bedebSBruce Evans 	__asm __volatile("pushfl; popl %0" : "=r" (ef));
2738db02de8SPaul Richards 	return (ef);
2745b81b6b3SRodney W. Grimes }
2755b81b6b3SRodney W. Grimes 
276004bedebSBruce Evans static __inline void
2778db02de8SPaul Richards write_eflags(u_long ef)
2785b81b6b3SRodney W. Grimes {
279004bedebSBruce Evans 	__asm __volatile("pushl %0; popfl" : : "r" (ef));
2805b81b6b3SRodney W. Grimes }
2815b81b6b3SRodney W. Grimes 
282004bedebSBruce Evans /*
283004bedebSBruce Evans  * XXX queue stuff belongs elsewhere.
284004bedebSBruce Evans  */
285ee06dc60SDavid Greenman struct quehead {
286ee06dc60SDavid Greenman 	struct quehead *qh_link;
287ee06dc60SDavid Greenman 	struct quehead *qh_rlink;
288ee06dc60SDavid Greenman };
289ee06dc60SDavid Greenman 
290004bedebSBruce Evans static __inline void
291ee06dc60SDavid Greenman insque(void *a, void *b)
292ee06dc60SDavid Greenman {
293004bedebSBruce Evans 	struct quehead *element = a, *head = b;
294004bedebSBruce Evans 
295ee06dc60SDavid Greenman 	element->qh_link = head->qh_link;
296004bedebSBruce Evans 	head->qh_link = element;
297004bedebSBruce Evans 	element->qh_rlink = head;
298004bedebSBruce Evans 	element->qh_link->qh_rlink = element;
299ee06dc60SDavid Greenman }
300ee06dc60SDavid Greenman 
301004bedebSBruce Evans static __inline void
302ee06dc60SDavid Greenman remque(void *a)
303ee06dc60SDavid Greenman {
304004bedebSBruce Evans 	struct quehead *element = a;
305004bedebSBruce Evans 
306004bedebSBruce Evans 	element->qh_link->qh_rlink = element->qh_rlink;
307004bedebSBruce Evans 	element->qh_rlink->qh_link = element->qh_link;
308ee06dc60SDavid Greenman 	element->qh_rlink = 0;
309ee06dc60SDavid Greenman }
310ee06dc60SDavid Greenman 
311004bedebSBruce Evans #else /* !__GNUC__ */
3125b81b6b3SRodney W. Grimes 
3135b81b6b3SRodney W. Grimes int	bdb		__P((void));
3145b81b6b3SRodney W. Grimes void	disable_intr	__P((void));
3155b81b6b3SRodney W. Grimes void	enable_intr	__P((void));
3165b81b6b3SRodney W. Grimes u_char	inb		__P((u_int port));
317004bedebSBruce Evans u_long	inl		__P((u_int port));
318004bedebSBruce Evans void	insb		__P((u_int port, void *addr, size_t cnt));
319004bedebSBruce Evans void	insl		__P((u_int port, void *addr, size_t cnt));
320004bedebSBruce Evans void	insw		__P((u_int port, void *addr, size_t cnt));
321004bedebSBruce Evans u_short	inw		__P((u_int port));
322004bedebSBruce Evans void	outb		__P((u_int port, u_char data));
323004bedebSBruce Evans void	outl		__P((u_int port, u_long data));
324004bedebSBruce Evans void	outsb		__P((u_int port, void *addr, size_t cnt));
325004bedebSBruce Evans void	outsl		__P((u_int port, void *addr, size_t cnt));
326004bedebSBruce Evans void	outsw		__P((u_int port, void *addr, size_t cnt));
327004bedebSBruce Evans void	outw		__P((u_int port, u_short data));
328004bedebSBruce Evans void	void pmap_update  __P((void));
329004bedebSBruce Evans u_long	read_eflags	__P((void));
330004bedebSBruce Evans u_long	rcr2		__P((void));
331004bedebSBruce Evans void	write_eflags	__P((u_long ef));
332004bedebSBruce Evans 
333004bedebSBruce Evans void	insque		__P((void *a, void *b));
334004bedebSBruce Evans void	remque		__P((void *a))
3355b81b6b3SRodney W. Grimes 
3365b81b6b3SRodney W. Grimes #endif	/* __GNUC__ */
3375b81b6b3SRodney W. Grimes 
338004bedebSBruce Evans /*
339004bedebSBruce Evans  * XXX the following declarations document garbage in support.s.
340004bedebSBruce Evans  * gcc hasn't needed _divsi* for years.
341004bedebSBruce Evans  * bcopy[bwx]() was used by pccons but isn't used now.
342004bedebSBruce Evans  */
343004bedebSBruce Evans int	__divsi3	__P((int factor1, int factor2));
344004bedebSBruce Evans u_int	__udivsi3	__P((u_int factor1, u_int factor2));
345004bedebSBruce Evans void	bcopyb		__P((const void *from, void *to, size_t len));
346004bedebSBruce Evans void	bcopyw		__P((const void *from, void *to, size_t len));
347004bedebSBruce Evans void	bcopyx		__P((const void *from, void *to, size_t len,
348004bedebSBruce Evans 			     int stride));
349004bedebSBruce Evans 
350004bedebSBruce Evans #if 0
351004bedebSBruce Evans /*
352004bedebSBruce Evans  * These functions in support.s are declared elsewhere.
353004bedebSBruce Evans  */
354004bedebSBruce Evans void	bcopy		__P((const void *from, void *to, size_t len));
355004bedebSBruce Evans void	blkclr		__P((void *buf, size_t len));
356004bedebSBruce Evans void	bzero		__P((void *buf, size_t len));
357004bedebSBruce Evans int	copyin		__P((void *udaddr, void *kaddr, size_t len));
358004bedebSBruce Evans int	copyinstr	__P((void *udaddr, void *kaddr, size_t len,
359004bedebSBruce Evans 			     size_t *lencopied));
360004bedebSBruce Evans int	copyout		__P((void *kaddr, void *udaddr, size_t len));
361004bedebSBruce Evans int	copystr		__P((void *kfaddr, void *kdaddr, size_t len,
362004bedebSBruce Evans 			     size_t *lencopied));
363004bedebSBruce Evans int	fubyte		__P((void *base));
364004bedebSBruce Evans int	fuswintr	__P((void *base));
365004bedebSBruce Evans int	fuibyte		__P((void *base));
366004bedebSBruce Evans int	fuword		__P((void *base));
367004bedebSBruce Evans struct	region_descriptor;
368004bedebSBruce Evans void	lgdt		__P((struct region_descriptor *rdp));
369004bedebSBruce Evans void	lidt		__P((struct region_descriptor *rdp));
370004bedebSBruce Evans void	lldt		__P((u_short sel));
371004bedebSBruce Evans /*
372004bedebSBruce Evans  * longjmp() and setjmp() are only used by ddb.  They probably shouldn't
373004bedebSBruce Evans  * shouldn't be supported in the kernel.
374004bedebSBruce Evans  */
375004bedebSBruce Evans #include <setjmp.h>
376004bedebSBruce Evans void	longjmp		__P((jmp_buf jb, int rv));
377004bedebSBruce Evans void	ovbcopy		__P((const void *from, void *to, size_t len);
378004bedebSBruce Evans int	setjmp		__P((jmp_buf jb));
379004bedebSBruce Evans struct soft_segment_descriptor;
380004bedebSBruce Evans union descriptor;
381004bedebSBruce Evans int	ssdtosd		__P((struct soft_segment_descriptor *ssdp,
382004bedebSBruce Evans 			     union descriptor *sdp));
383004bedebSBruce Evans int	subyte		__P((void *base, int byte));
384004bedebSBruce Evans int	suibyte		__P((void *base, int byte));
385004bedebSBruce Evans int	suswintr	__P((void *base, int word));
386004bedebSBruce Evans int	suword		__P((void *base, int word));
387004bedebSBruce Evans 
388004bedebSBruce Evans /*
389004bedebSBruce Evans  * These functions in support.s are declared elsewhere, but never used.
390004bedebSBruce Evans  * A silly amount of effort went into copyoutstr().  It's not worth
391004bedebSBruce Evans  * maintaining, since the string length is usually known so copyout
392004bedebSBruce Evans  * works better, or is easy to find so copyout() can be used.
393004bedebSBruce Evans  */
394004bedebSBruce Evans int	copyoutstr	__P((void *kaddr, void *udaddr, size_t len,
395004bedebSBruce Evans 			     size_t *lencopied));
396004bedebSBruce Evans int	fuiword		__P((void *base));
397004bedebSBruce Evans int	suiword		__P((void *base, int word));
398004bedebSBruce Evans 
399004bedebSBruce Evans /*
400004bedebSBruce Evans  * These functions in support.s are also in libkern.a and are declared in
401004bedebSBruce Evans  * libkern.h.
402004bedebSBruce Evans  * ffs() is built in to gcc-2 and was buggy in gcc-2.4.5 so we may may the
403004bedebSBruce Evans  * buggy version if we don't replace it by an inline.
404004bedebSBruce Evans  */
405004bedebSBruce Evans int	bcmp		__P((const void *b1, const void *b2, size_t length));
406004bedebSBruce Evans int	ffs		__P((int mask));
407004bedebSBruce Evans #endif /* 0 */
408004bedebSBruce Evans 
409004bedebSBruce Evans /*
410004bedebSBruce Evans  * These variables and functions in support.s are used.
411004bedebSBruce Evans  */
412004bedebSBruce Evans extern u_int atdevbase;	/* offset in virtual memory of ISA io mem */
413004bedebSBruce Evans 
414004bedebSBruce Evans void	filli		__P((int pat, void *base, size_t cnt));
415004bedebSBruce Evans void	fillw		__P((int /*u_short*/ pat, void *base, size_t cnt));
416004bedebSBruce Evans int	fusword		__P((void *base));
417004bedebSBruce Evans void	load_cr0	__P((u_long cr0));
418004bedebSBruce Evans void	load_cr3	__P((u_long cr3));
419004bedebSBruce Evans void	ltr		__P((u_short sel));
420aaf08d94SGarrett Wollman u_int	rcr0		__P((void));
421004bedebSBruce Evans u_long	rcr3		__P((void));
422004bedebSBruce Evans int	rtcin		__P((int val));
423004bedebSBruce Evans int	susword		__P((void *base, int word));
4245b81b6b3SRodney W. Grimes 
425004bedebSBruce Evans /*
426004bedebSBruce Evans  * These functions are NOT in support.s and should be declared elsewhere.
427004bedebSBruce Evans  */
428ff030ea1SBruce Evans void	Debugger	__P((const char *msg));
429004bedebSBruce Evans u_long	kvtop		__P((void *addr));
430004bedebSBruce Evans typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp,
431004bedebSBruce Evans 				      u_int ss));
432004bedebSBruce Evans void	setidt		__P((int idx, alias_for_inthand_t *func, int typ,
433004bedebSBruce Evans 			     int dpl));
43426931201SDavid Greenman 
435004bedebSBruce Evans #endif /* !_MACHINE_CPUFUNC_H_ */
436