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