cpufunc.h revision 1.2 1 /*
2 * Functions to provide access to special i386 instructions.
3 * XXX - bezillions more are defined in locore.s but are not declared anywhere.
4 *
5 * $Id: cpufunc.h,v 1.2 1993/08/02 17:52:24 mycroft Exp $
6 */
7
8 #include <sys/cdefs.h>
9 #include <sys/types.h>
10
11 #ifdef __GNUC__
12
13 static __inline int bdb(void)
14 {
15 extern int bdb_exists;
16
17 if (!bdb_exists)
18 return (0);
19 __asm("int $3");
20 return (1);
21 }
22
23 static __inline void
24 disable_intr(void)
25 {
26 __asm __volatile("cli");
27 }
28
29 static __inline void
30 enable_intr(void)
31 {
32 __asm __volatile("sti");
33 }
34
35 /*
36 * This roundabout method of returning a u_char helps stop gcc-1.40 from
37 * generating unnecessary movzbl's.
38 */
39 #define inb(port) ((u_char) u_int_inb(port))
40
41 static __inline u_int
42 u_int_inb(u_int port)
43 {
44 u_char data;
45 /*
46 * We use %%dx and not %1 here because i/o is done at %dx and not at
47 * %edx, while gcc-2.2.2 generates inferior code (movw instead of movl)
48 * if we tell it to load (u_short) port.
49 */
50 __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
51 return data;
52 }
53
54 static __inline void
55 outb(u_int port, u_char data)
56 {
57 register u_char al asm("ax");
58
59 al = data; /* help gcc-1.40's register allocator */
60 __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
61 }
62
63 #else /* not __GNUC__ */
64
65 int bdb __P((void));
66 void disable_intr __P((void));
67 void enable_intr __P((void));
68 u_char inb __P((u_int port));
69 void outb __P((u_int port, u_int data)); /* XXX - incompat */
70
71 #endif /* __GNUC__ */
72
73 #define really_u_int int /* XXX */
74 #define really_void int /* XXX */
75
76 void load_cr0 __P((u_int cr0));
77 really_u_int rcr0 __P((void));
78
79 #ifdef notyet
80 really_void setidt __P((int idx, /*XXX*/caddr_t func, int typ, int dpl));
81 #endif
82
83 #undef really_u_int
84 #undef really_void
85