cpufunc.h (128019) | cpufunc.h (143063) |
---|---|
1/*- 2 * Copyright (c) 1993 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 1993 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/i386/include/cpufunc.h 128019 2004-04-07 20:46:16Z imp $ | 29 * $FreeBSD: head/sys/i386/include/cpufunc.h 143063 2005-03-02 21:33:29Z joerg $ |
30 */ 31 32/* 33 * Functions to provide access to special i386 instructions. 34 * This in included in sys/systm.h, and that file should be 35 * used in preference to this. 36 */ 37 38#ifndef _MACHINE_CPUFUNC_H_ 39#define _MACHINE_CPUFUNC_H_ 40 | 30 */ 31 32/* 33 * Functions to provide access to special i386 instructions. 34 * This in included in sys/systm.h, and that file should be 35 * used in preference to this. 36 */ 37 38#ifndef _MACHINE_CPUFUNC_H_ 39#define _MACHINE_CPUFUNC_H_ 40 |
41#ifndef _SYS_CDEFS_H_ 42#error this file needs sys/cdefs.h as a prerequisite 43#endif 44 |
|
41struct region_descriptor; 42 43#define readb(va) (*(volatile u_int8_t *) (va)) 44#define readw(va) (*(volatile u_int16_t *) (va)) 45#define readl(va) (*(volatile u_int32_t *) (va)) 46 47#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d)) 48#define writew(va, d) (*(volatile u_int16_t *) (va) = (d)) 49#define writel(va, d) (*(volatile u_int32_t *) (va) = (d)) 50 | 45struct region_descriptor; 46 47#define readb(va) (*(volatile u_int8_t *) (va)) 48#define readw(va) (*(volatile u_int16_t *) (va)) 49#define readl(va) (*(volatile u_int32_t *) (va)) 50 51#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d)) 52#define writew(va, d) (*(volatile u_int16_t *) (va) = (d)) 53#define writel(va, d) (*(volatile u_int32_t *) (va) = (d)) 54 |
51#if defined(__GNUC__) || defined(__INTEL_COMPILER) | 55#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE) |
52 53static __inline void 54breakpoint(void) 55{ 56 __asm __volatile("int $3"); 57} 58 59static __inline u_int --- 61 unchanged lines hidden (view full) --- 121#endif /* _KERNEL */ 122 123static __inline void 124halt(void) 125{ 126 __asm __volatile("hlt"); 127} 128 | 56 57static __inline void 58breakpoint(void) 59{ 60 __asm __volatile("int $3"); 61} 62 63static __inline u_int --- 61 unchanged lines hidden (view full) --- 125#endif /* _KERNEL */ 126 127static __inline void 128halt(void) 129{ 130 __asm __volatile("hlt"); 131} 132 |
129#if __GNUC__ < 2 | 133#if !defined(__GNUCLIKE_BUILTIN_CONSTANT_P) || __GNUCLIKE_ASM < 3 |
130 131#define inb(port) inbv(port) 132#define outb(port, data) outbv(port, data) 133 | 134 135#define inb(port) inbv(port) 136#define outb(port, data) outbv(port, data) 137 |
134#else /* __GNUC >= 2 */ | 138#else /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3 */ |
135 136/* 137 * The following complications are to get around gcc not having a 138 * constraint letter for the range 0..255. We still put "d" in the 139 * constraint because "i" isn't a valid constraint when the port 140 * isn't constant. This only matters for -O0 because otherwise 141 * the non-working version gets optimized away. 142 * --- 30 unchanged lines hidden (view full) --- 173} 174 175static __inline void 176outbc(u_int port, u_char data) 177{ 178 __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); 179} 180 | 139 140/* 141 * The following complications are to get around gcc not having a 142 * constraint letter for the range 0..255. We still put "d" in the 143 * constraint because "i" isn't a valid constraint when the port 144 * isn't constant. This only matters for -O0 because otherwise 145 * the non-working version gets optimized away. 146 * --- 30 unchanged lines hidden (view full) --- 177} 178 179static __inline void 180outbc(u_int port, u_char data) 181{ 182 __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); 183} 184 |
181#endif /* __GNUC <= 2 */ | 185#endif /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3*/ |
182 183static __inline u_char 184inbv(u_int port) 185{ 186 u_char data; 187 /* 188 * We use %%dx and not %1 here because i/o is done at %dx and not at 189 * %edx, while gcc generates inferior code (movw instead of movl) --- 423 unchanged lines hidden (view full) --- 613} 614 615static __inline void 616intr_restore(register_t eflags) 617{ 618 write_eflags(eflags); 619} 620 | 186 187static __inline u_char 188inbv(u_int port) 189{ 190 u_char data; 191 /* 192 * We use %%dx and not %1 here because i/o is done at %dx and not at 193 * %edx, while gcc generates inferior code (movw instead of movl) --- 423 unchanged lines hidden (view full) --- 617} 618 619static __inline void 620intr_restore(register_t eflags) 621{ 622 write_eflags(eflags); 623} 624 |
621#else /* !(__GNUC__ || __INTEL_COMPILER) */ | 625#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */ |
622 623int breakpoint(void); 624u_int bsfl(u_int mask); 625u_int bsrl(u_int mask); 626void disable_intr(void); 627void do_cpuid(u_int ax, u_int *p); 628void enable_intr(void); 629void halt(void); --- 48 unchanged lines hidden (view full) --- 678u_int64_t rdtsc(void); 679u_int read_eflags(void); 680u_int rfs(void); 681u_int rgs(void); 682void wbinvd(void); 683void write_eflags(u_int ef); 684void wrmsr(u_int msr, u_int64_t newval); 685 | 626 627int breakpoint(void); 628u_int bsfl(u_int mask); 629u_int bsrl(u_int mask); 630void disable_intr(void); 631void do_cpuid(u_int ax, u_int *p); 632void enable_intr(void); 633void halt(void); --- 48 unchanged lines hidden (view full) --- 682u_int64_t rdtsc(void); 683u_int read_eflags(void); 684u_int rfs(void); 685u_int rgs(void); 686void wbinvd(void); 687void write_eflags(u_int ef); 688void wrmsr(u_int msr, u_int64_t newval); 689 |
686#endif /* __GNUC__ || __INTEL_COMPILER */ | 690#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */ |
687 688void reset_dbregs(void); 689 690#endif /* !_MACHINE_CPUFUNC_H_ */ | 691 692void reset_dbregs(void); 693 694#endif /* !_MACHINE_CPUFUNC_H_ */ |