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 * 330ee893ebSBruce Evans * $Id: cpufunc.h,v 1.34 1995/03/03 22:14:42 davidg 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 1920ee893ebSBruce Evans static __inline unsigned 1930ee893ebSBruce Evans loadandclear(u_int *addr) 1940ee893ebSBruce Evans { 1950ee893ebSBruce Evans u_int result; 1960ee893ebSBruce Evans 1970ee893ebSBruce Evans __asm __volatile("xorl %0,%0; xchgl %1,%0" 1980ee893ebSBruce Evans : "=r" (result) : "m" (*addr)); 1990ee893ebSBruce Evans return (result); 2000ee893ebSBruce Evans } 2010ee893ebSBruce Evans 202004bedebSBruce Evans static __inline void 203004bedebSBruce Evans outbv(u_int port, u_char data) 204004bedebSBruce Evans { 205004bedebSBruce Evans u_char al; 206004bedebSBruce Evans /* 207004bedebSBruce Evans * Use an unnecessary assignment to help gcc's register allocator. 208004bedebSBruce Evans * This make a large difference for gcc-1.40 and a tiny difference 209004bedebSBruce Evans * for gcc-2.6.0. For gcc-1.40, al had to be ``asm("ax")'' for 210004bedebSBruce Evans * best results. gcc-2.6.0 can't handle this. 211004bedebSBruce Evans */ 212004bedebSBruce Evans al = data; 213004bedebSBruce Evans __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); 214004bedebSBruce Evans } 215004bedebSBruce Evans 216004bedebSBruce Evans static __inline void 217004bedebSBruce Evans outl(u_int port, u_long data) 218004bedebSBruce Evans { 219004bedebSBruce Evans /* 220004bedebSBruce Evans * outl() and outw() aren't used much so we haven't looked at 221004bedebSBruce Evans * possible micro-optimizations such as the unnecessary 222004bedebSBruce Evans * assignment for them. 223004bedebSBruce Evans */ 224004bedebSBruce Evans __asm __volatile("outl %0,%%dx" : : "a" (data), "d" (port)); 225004bedebSBruce Evans } 226004bedebSBruce Evans 227004bedebSBruce Evans static __inline void 228004bedebSBruce Evans outsb(u_int port, void *addr, size_t cnt) 229004bedebSBruce Evans { 230004bedebSBruce Evans __asm __volatile("cld; rep; outsb" 231004bedebSBruce Evans : : "d" (port), "S" (addr), "c" (cnt) 232b5ba45f6SDavid Greenman : "si", "cx"); 233004bedebSBruce Evans } 234004bedebSBruce Evans 235004bedebSBruce Evans static __inline void 236004bedebSBruce Evans outsw(u_int port, void *addr, size_t cnt) 237004bedebSBruce Evans { 238004bedebSBruce Evans __asm __volatile("cld; rep; outsw" 239004bedebSBruce Evans : : "d" (port), "S" (addr), "c" (cnt) 240b5ba45f6SDavid Greenman : "si", "cx"); 241004bedebSBruce Evans } 242004bedebSBruce Evans 243004bedebSBruce Evans static __inline void 244004bedebSBruce Evans outsl(u_int port, void *addr, size_t cnt) 245004bedebSBruce Evans { 246004bedebSBruce Evans __asm __volatile("cld; rep; outsl" 247004bedebSBruce Evans : : "d" (port), "S" (addr), "c" (cnt) 248b5ba45f6SDavid Greenman : "si", "cx"); 249004bedebSBruce Evans } 250004bedebSBruce Evans 251004bedebSBruce Evans static __inline void 252004bedebSBruce Evans outw(u_int port, u_short data) 253004bedebSBruce Evans { 254004bedebSBruce Evans __asm __volatile("outw %0,%%dx" : : "a" (data), "d" (port)); 255004bedebSBruce Evans } 256004bedebSBruce Evans 257004bedebSBruce Evans static __inline void 258004bedebSBruce Evans pmap_update(void) 259004bedebSBruce Evans { 260004bedebSBruce Evans u_long temp; 261004bedebSBruce Evans /* 262004bedebSBruce Evans * This should be implemented as load_cr3(rcr3()) when load_cr3() 263004bedebSBruce Evans * is inlined. 264004bedebSBruce Evans */ 265004bedebSBruce Evans __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp)); 266004bedebSBruce Evans } 267004bedebSBruce Evans 268004bedebSBruce Evans static __inline u_long 269004bedebSBruce Evans rcr2(void) 270004bedebSBruce Evans { 271004bedebSBruce Evans u_long data; 272004bedebSBruce Evans 273004bedebSBruce Evans __asm __volatile("movl %%cr2,%0" : "=r" (data)); 274004bedebSBruce Evans return (data); 275004bedebSBruce Evans } 276004bedebSBruce Evans 277004bedebSBruce Evans static __inline u_long 278004bedebSBruce Evans read_eflags(void) 2795b81b6b3SRodney W. Grimes { 2808db02de8SPaul Richards u_long ef; 281004bedebSBruce Evans 282004bedebSBruce Evans __asm __volatile("pushfl; popl %0" : "=r" (ef)); 2838db02de8SPaul Richards return (ef); 2845b81b6b3SRodney W. Grimes } 2855b81b6b3SRodney W. Grimes 286004bedebSBruce Evans static __inline void 2878db02de8SPaul Richards write_eflags(u_long ef) 2885b81b6b3SRodney W. Grimes { 289004bedebSBruce Evans __asm __volatile("pushl %0; popfl" : : "r" (ef)); 2905b81b6b3SRodney W. Grimes } 2915b81b6b3SRodney W. Grimes 292004bedebSBruce Evans /* 293004bedebSBruce Evans * XXX queue stuff belongs elsewhere. 294004bedebSBruce Evans */ 295ee06dc60SDavid Greenman struct quehead { 296ee06dc60SDavid Greenman struct quehead *qh_link; 297ee06dc60SDavid Greenman struct quehead *qh_rlink; 298ee06dc60SDavid Greenman }; 299ee06dc60SDavid Greenman 300004bedebSBruce Evans static __inline void 301ee06dc60SDavid Greenman insque(void *a, void *b) 302ee06dc60SDavid Greenman { 303004bedebSBruce Evans struct quehead *element = a, *head = b; 304004bedebSBruce Evans 305ee06dc60SDavid Greenman element->qh_link = head->qh_link; 306004bedebSBruce Evans element->qh_rlink = head; 3073b7517f8SDavid Greenman head->qh_link = element; 308004bedebSBruce Evans element->qh_link->qh_rlink = element; 309ee06dc60SDavid Greenman } 310ee06dc60SDavid Greenman 311004bedebSBruce Evans static __inline void 312ee06dc60SDavid Greenman remque(void *a) 313ee06dc60SDavid Greenman { 314004bedebSBruce Evans struct quehead *element = a; 315004bedebSBruce Evans 316004bedebSBruce Evans element->qh_link->qh_rlink = element->qh_rlink; 317004bedebSBruce Evans element->qh_rlink->qh_link = element->qh_link; 318ee06dc60SDavid Greenman element->qh_rlink = 0; 319ee06dc60SDavid Greenman } 320ee06dc60SDavid Greenman 321004bedebSBruce Evans #else /* !__GNUC__ */ 3225b81b6b3SRodney W. Grimes 3235b81b6b3SRodney W. Grimes int bdb __P((void)); 3245b81b6b3SRodney W. Grimes void disable_intr __P((void)); 3255b81b6b3SRodney W. Grimes void enable_intr __P((void)); 3265b81b6b3SRodney W. Grimes u_char inb __P((u_int port)); 327004bedebSBruce Evans u_long inl __P((u_int port)); 328004bedebSBruce Evans void insb __P((u_int port, void *addr, size_t cnt)); 329004bedebSBruce Evans void insl __P((u_int port, void *addr, size_t cnt)); 330004bedebSBruce Evans void insw __P((u_int port, void *addr, size_t cnt)); 331004bedebSBruce Evans u_short inw __P((u_int port)); 3320ee893ebSBruce Evans u_int loadandclear __P((u_int *addr)); 333004bedebSBruce Evans void outb __P((u_int port, u_char data)); 334004bedebSBruce Evans void outl __P((u_int port, u_long data)); 335004bedebSBruce Evans void outsb __P((u_int port, void *addr, size_t cnt)); 336004bedebSBruce Evans void outsl __P((u_int port, void *addr, size_t cnt)); 337004bedebSBruce Evans void outsw __P((u_int port, void *addr, size_t cnt)); 338004bedebSBruce Evans void outw __P((u_int port, u_short data)); 339ceb91b3eSBruce Evans void pmap_update __P((void)); 340004bedebSBruce Evans u_long read_eflags __P((void)); 341004bedebSBruce Evans u_long rcr2 __P((void)); 342004bedebSBruce Evans void write_eflags __P((u_long ef)); 343004bedebSBruce Evans 344004bedebSBruce Evans void insque __P((void *a, void *b)); 345ceb91b3eSBruce Evans void remque __P((void *a)); 3465b81b6b3SRodney W. Grimes 3475b81b6b3SRodney W. Grimes #endif /* __GNUC__ */ 3485b81b6b3SRodney W. Grimes 349004bedebSBruce Evans /* 350004bedebSBruce Evans * XXX the following declarations document garbage in support.s. 351004bedebSBruce Evans * gcc hasn't needed _divsi* for years. 352004bedebSBruce Evans * bcopy[bwx]() was used by pccons but isn't used now. 353004bedebSBruce Evans */ 354004bedebSBruce Evans int __divsi3 __P((int factor1, int factor2)); 355004bedebSBruce Evans u_int __udivsi3 __P((u_int factor1, u_int factor2)); 356004bedebSBruce Evans void bcopyb __P((const void *from, void *to, size_t len)); 357004bedebSBruce Evans void bcopyw __P((const void *from, void *to, size_t len)); 358004bedebSBruce Evans void bcopyx __P((const void *from, void *to, size_t len, 359004bedebSBruce Evans int stride)); 360004bedebSBruce Evans 361004bedebSBruce Evans #if 0 362004bedebSBruce Evans /* 363004bedebSBruce Evans * These functions in support.s are declared elsewhere. 364004bedebSBruce Evans */ 365004bedebSBruce Evans void bcopy __P((const void *from, void *to, size_t len)); 366004bedebSBruce Evans void blkclr __P((void *buf, size_t len)); 367004bedebSBruce Evans void bzero __P((void *buf, size_t len)); 368004bedebSBruce Evans int copyin __P((void *udaddr, void *kaddr, size_t len)); 369004bedebSBruce Evans int copyinstr __P((void *udaddr, void *kaddr, size_t len, 370004bedebSBruce Evans size_t *lencopied)); 371004bedebSBruce Evans int copyout __P((void *kaddr, void *udaddr, size_t len)); 372004bedebSBruce Evans int copystr __P((void *kfaddr, void *kdaddr, size_t len, 373004bedebSBruce Evans size_t *lencopied)); 374004bedebSBruce Evans int fubyte __P((void *base)); 375004bedebSBruce Evans int fuswintr __P((void *base)); 376004bedebSBruce Evans int fuibyte __P((void *base)); 377004bedebSBruce Evans int fuword __P((void *base)); 378004bedebSBruce Evans struct region_descriptor; 379004bedebSBruce Evans void lgdt __P((struct region_descriptor *rdp)); 380004bedebSBruce Evans void lidt __P((struct region_descriptor *rdp)); 381004bedebSBruce Evans void lldt __P((u_short sel)); 382004bedebSBruce Evans /* 383004bedebSBruce Evans * longjmp() and setjmp() are only used by ddb. They probably shouldn't 384004bedebSBruce Evans * shouldn't be supported in the kernel. 385004bedebSBruce Evans */ 386004bedebSBruce Evans #include <setjmp.h> 387004bedebSBruce Evans void longjmp __P((jmp_buf jb, int rv)); 388004bedebSBruce Evans void ovbcopy __P((const void *from, void *to, size_t len); 389004bedebSBruce Evans int setjmp __P((jmp_buf jb)); 390004bedebSBruce Evans struct soft_segment_descriptor; 391004bedebSBruce Evans union descriptor; 392004bedebSBruce Evans int ssdtosd __P((struct soft_segment_descriptor *ssdp, 393004bedebSBruce Evans union descriptor *sdp)); 394004bedebSBruce Evans int subyte __P((void *base, int byte)); 395004bedebSBruce Evans int suibyte __P((void *base, int byte)); 396004bedebSBruce Evans int suswintr __P((void *base, int word)); 397004bedebSBruce Evans int suword __P((void *base, int word)); 398004bedebSBruce Evans 399004bedebSBruce Evans /* 400004bedebSBruce Evans * These functions in support.s are declared elsewhere, but never used. 401004bedebSBruce Evans * A silly amount of effort went into copyoutstr(). It's not worth 402004bedebSBruce Evans * maintaining, since the string length is usually known so copyout 403004bedebSBruce Evans * works better, or is easy to find so copyout() can be used. 404004bedebSBruce Evans */ 405004bedebSBruce Evans int copyoutstr __P((void *kaddr, void *udaddr, size_t len, 406004bedebSBruce Evans size_t *lencopied)); 407004bedebSBruce Evans int fuiword __P((void *base)); 408004bedebSBruce Evans int suiword __P((void *base, int word)); 409004bedebSBruce Evans 410004bedebSBruce Evans /* 411004bedebSBruce Evans * These functions in support.s are also in libkern.a and are declared in 412004bedebSBruce Evans * libkern.h. 413004bedebSBruce Evans * ffs() is built in to gcc-2 and was buggy in gcc-2.4.5 so we may may the 414004bedebSBruce Evans * buggy version if we don't replace it by an inline. 415004bedebSBruce Evans */ 416004bedebSBruce Evans int bcmp __P((const void *b1, const void *b2, size_t length)); 417004bedebSBruce Evans int ffs __P((int mask)); 418004bedebSBruce Evans #endif /* 0 */ 419004bedebSBruce Evans 420004bedebSBruce Evans /* 421004bedebSBruce Evans * These variables and functions in support.s are used. 422004bedebSBruce Evans */ 423004bedebSBruce Evans extern u_int atdevbase; /* offset in virtual memory of ISA io mem */ 424004bedebSBruce Evans 425004bedebSBruce Evans void filli __P((int pat, void *base, size_t cnt)); 426004bedebSBruce Evans void fillw __P((int /*u_short*/ pat, void *base, size_t cnt)); 427004bedebSBruce Evans int fusword __P((void *base)); 428004bedebSBruce Evans void load_cr0 __P((u_long cr0)); 429004bedebSBruce Evans void load_cr3 __P((u_long cr3)); 430004bedebSBruce Evans void ltr __P((u_short sel)); 431aaf08d94SGarrett Wollman u_int rcr0 __P((void)); 432004bedebSBruce Evans u_long rcr3 __P((void)); 433004bedebSBruce Evans int rtcin __P((int val)); 4345b81b6b3SRodney W. Grimes 435004bedebSBruce Evans /* 436004bedebSBruce Evans * These functions are NOT in support.s and should be declared elsewhere. 437004bedebSBruce Evans */ 438ff030ea1SBruce Evans void Debugger __P((const char *msg)); 439004bedebSBruce Evans u_long kvtop __P((void *addr)); 440004bedebSBruce Evans typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, 441004bedebSBruce Evans u_int ss)); 442004bedebSBruce Evans void setidt __P((int idx, alias_for_inthand_t *func, int typ, 443004bedebSBruce Evans int dpl)); 44426931201SDavid Greenman 445004bedebSBruce Evans #endif /* !_MACHINE_CPUFUNC_H_ */ 446