Deleted Added
full compact
cpufunc.h (132888) cpufunc.h (143063)
1/*-
2 * Copyright (c) 2003 Peter Wemm.
3 * Copyright (c) 1993 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
1/*-
2 * Copyright (c) 2003 Peter Wemm.
3 * Copyright (c) 1993 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sys/amd64/include/cpufunc.h 132888 2004-07-30 16:44:29Z ps $
30 * $FreeBSD: head/sys/amd64/include/cpufunc.h 143063 2005-03-02 21:33:29Z joerg $
31 */
32
33/*
34 * Functions to provide access to special i386 instructions.
35 * This in included in sys/systm.h, and that file should be
36 * used in preference to this.
37 */
38
39#ifndef _MACHINE_CPUFUNC_H_
40#define _MACHINE_CPUFUNC_H_
41
31 */
32
33/*
34 * Functions to provide access to special i386 instructions.
35 * This in included in sys/systm.h, and that file should be
36 * used in preference to this.
37 */
38
39#ifndef _MACHINE_CPUFUNC_H_
40#define _MACHINE_CPUFUNC_H_
41
42#ifndef _SYS_CDEFS_H_
43#error this file needs sys/cdefs.h as a prerequisite
44#endif
45
42struct region_descriptor;
43
44#define readb(va) (*(volatile u_int8_t *) (va))
45#define readw(va) (*(volatile u_int16_t *) (va))
46#define readl(va) (*(volatile u_int32_t *) (va))
47#define readq(va) (*(volatile u_int64_t *) (va))
48
49#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d))
50#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
51#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
52#define writeq(va, d) (*(volatile u_int64_t *) (va) = (d))
53
46struct region_descriptor;
47
48#define readb(va) (*(volatile u_int8_t *) (va))
49#define readw(va) (*(volatile u_int16_t *) (va))
50#define readl(va) (*(volatile u_int32_t *) (va))
51#define readq(va) (*(volatile u_int64_t *) (va))
52
53#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d))
54#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
55#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
56#define writeq(va, d) (*(volatile u_int64_t *) (va) = (d))
57
54#ifdef __GNUC__
58#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
55
56static __inline void
57breakpoint(void)
58{
59 __asm __volatile("int $3");
60}
61
62static __inline u_int

--- 84 unchanged lines hidden (view full) ---

147#endif /* _KERNEL */
148
149static __inline void
150halt(void)
151{
152 __asm __volatile("hlt");
153}
154
59
60static __inline void
61breakpoint(void)
62{
63 __asm __volatile("int $3");
64}
65
66static __inline u_int

--- 84 unchanged lines hidden (view full) ---

151#endif /* _KERNEL */
152
153static __inline void
154halt(void)
155{
156 __asm __volatile("hlt");
157}
158
155#if __GNUC__ < 2
159#if !defined(__GNUCLIKE_BUILTIN_CONSTANT_P) || __GNUCLIKE_ASM < 3
156
157#define inb(port) inbv(port)
158#define outb(port, data) outbv(port, data)
159
160
161#define inb(port) inbv(port)
162#define outb(port, data) outbv(port, data)
163
160#else /* __GNUC >= 2 */
164#else /* __GNUCLIKE_BUILTIN_CONSTANT_P && __GNUCLIKE_ASM >= 3 */
161
162/*
163 * The following complications are to get around gcc not having a
164 * constraint letter for the range 0..255. We still put "d" in the
165 * constraint because "i" isn't a valid constraint when the port
166 * isn't constant. This only matters for -O0 because otherwise
167 * the non-working version gets optimized away.
168 *

--- 30 unchanged lines hidden (view full) ---

199}
200
201static __inline void
202outbc(u_int port, u_char data)
203{
204 __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port)));
205}
206
165
166/*
167 * The following complications are to get around gcc not having a
168 * constraint letter for the range 0..255. We still put "d" in the
169 * constraint because "i" isn't a valid constraint when the port
170 * isn't constant. This only matters for -O0 because otherwise
171 * the non-working version gets optimized away.
172 *

--- 30 unchanged lines hidden (view full) ---

203}
204
205static __inline void
206outbc(u_int port, u_char data)
207{
208 __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port)));
209}
210
207#endif /* __GNUC <= 2 */
211#endif /* __GNUCLIKE_BUILTIN_CONSTANT_P */
208
209static __inline u_char
210inbv(u_int port)
211{
212 u_char data;
213 /*
214 * We use %%dx and not %1 here because i/o is done at %dx and not at
215 * %edx, while gcc generates inferior code (movw instead of movl)

--- 475 unchanged lines hidden (view full) ---

691}
692
693static __inline void
694intr_restore(register_t rflags)
695{
696 write_rflags(rflags);
697}
698
212
213static __inline u_char
214inbv(u_int port)
215{
216 u_char data;
217 /*
218 * We use %%dx and not %1 here because i/o is done at %dx and not at
219 * %edx, while gcc generates inferior code (movw instead of movl)

--- 475 unchanged lines hidden (view full) ---

695}
696
697static __inline void
698intr_restore(register_t rflags)
699{
700 write_rflags(rflags);
701}
702
699#else /* !__GNUC__ */
703#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
700
701int breakpoint(void);
702u_int bsfl(u_int mask);
703u_int bsrl(u_int mask);
704void disable_intr(void);
705void do_cpuid(u_int ax, u_int *p);
706void enable_intr(void);
707void halt(void);

--- 48 unchanged lines hidden (view full) ---

756u_int64_t rdtsc(void);
757u_int read_rflags(void);
758u_int rfs(void);
759u_int rgs(void);
760void wbinvd(void);
761void write_rflags(u_int rf);
762void wrmsr(u_int msr, u_int64_t newval);
763
704
705int breakpoint(void);
706u_int bsfl(u_int mask);
707u_int bsrl(u_int mask);
708void disable_intr(void);
709void do_cpuid(u_int ax, u_int *p);
710void enable_intr(void);
711void halt(void);

--- 48 unchanged lines hidden (view full) ---

760u_int64_t rdtsc(void);
761u_int read_rflags(void);
762u_int rfs(void);
763u_int rgs(void);
764void wbinvd(void);
765void write_rflags(u_int rf);
766void wrmsr(u_int msr, u_int64_t newval);
767
764#endif /* __GNUC__ */
768#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
765
766void reset_dbregs(void);
767
768#endif /* !_MACHINE_CPUFUNC_H_ */
769
770void reset_dbregs(void);
771
772#endif /* !_MACHINE_CPUFUNC_H_ */