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