static __inline__ int enable_os_io(void) { if (i386_iopl(1) < 0) { perror("i386_iopl"); return errno; } return 0; }
int mapio(void) { int res; res = i386_iopl(1); if (res) warn("i386_iopl"); return res; }
void xf86DisableIO() { if (!ExtendedEnabled) return; i386_iopl(FALSE); ExtendedEnabled = FALSE; return; }
static __inline__ int disable_os_io(void) { #if !defined(USE_I386_IOPL) close(io_fd); #else if (i386_iopl(0) < 0) { perror("i386_iopl"); return(errno); } #endif /* NetBSD1_1 */ return(0); }
static void CloseIO() { #ifdef LINUX /* LINUX */ if (iopl_counter == 1) iopl(0); if (iopl_counter > 0) --iopl_counter; #elif NETBSD i386_iopl(0); #else /* FreeBSD */ close(iofl); #endif }
port_t::port_t(int iport) { port = -1; #ifdef LOCKING if (lock(iport) == -1) { #ifdef DEBUG fprintf(stderr, "port 0x%x already locked\n", iport); #endif /* DEBUG */ return; } #endif /* LOCKING */ #ifdef LINUX #if defined(arm) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__) if ((devport = open("/dev/port", O_RDWR)) < 0) { perror("open /dev/port"); return; } #else if (ioperm(iport, 3, 1) == -1) { perror("ioperm()"); return; } #endif /* arm */ #elif defined(FREEBSD) if ((devio = fopen("/dev/io", "r+")) == NULL) { perror("fopen /dev/io"); return; } #elif defined(OPENBSD) if (i386_iopl(1) == -1) { perror("i386_iopl"); return; } #elif defined(LYNX) if (io_access() < 0) { perror("io_access"); return; } #elif defined(SOLARIS) if (openiop()) { perror("openiop"); return; } #endif /* which OS */ port = iport; port1 = port + 1; port2 = port + 2; control_reg = read_control(); }
static __inline__ int enable_os_io(void) { io_fd = -1 ; #if !defined(USE_I386_IOPL) if ((io_fd = open("/dev/io", O_RDWR, 0)) < 0) { perror("/dev/io"); return(errno); } #else if (i386_iopl(1) < 0) { perror("i386_iopl"); return(errno); } #endif /* USE_I386_IOPL */ return(0); }
static int OpenIO() { #ifdef LINUX /* LINUX */ if (iopl_counter == 0) { if (iopl(3) < 0) return -1; } ++iopl_counter; #elif NETBSD return i386_iopl(1); #else /* FreeBSD */ if ((iofl = open("/dev/io",000)) < 0) return -1; #endif return 0; }
void set_iopl(void) { #ifdef OPENBSD if (i386_iopl(3) == -1) { #else if (iopl(3) == -1) { #endif perror(NULL); exit(1); } } int main(int argc, char **argv) { int i; char *infilename, *outfilename; infilename = outfilename = NULL; for (i = 1; i < argc; ++i) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) usage(); else if (!strcmp(argv[i], "-d")) ++dflag; else if (infilename == NULL) infilename = argv[i]; else if (outfilename == NULL) outfilename = argv[i]; else usage(); } if (!infilename) usage(); if (!outfilename) set_iopl(); pcspkr_play(infilename, outfilename); exit(0); }
void xf86EnableIO() { if (ExtendedEnabled) return; if (i386_iopl(TRUE) < 0) { #ifndef __OpenBSD__ FatalError("%s: Failed to set IOPL for extended I/O", "xf86EnableIO"); #else FatalError("%s: Failed to set IOPL for extended I/O\n%s", "xf86EnableIO", SYSCTL_MSG); #endif } ExtendedEnabled = TRUE; return; }
Bool xf86EnableIO() { if (ExtendedEnabled) return TRUE; if (i386_iopl(TRUE) < 0) { #ifndef __OpenBSD__ xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O", "xf86EnableIO"); #else xf86Msg(X_WARNING, "%s: Failed to set IOPL for extended I/O\n%s", "xf86EnableIO", SYSCTL_MSG); #endif return FALSE; } ExtendedEnabled = TRUE; return TRUE; }
int sys_sysarch(struct proc *p, void *v, register_t *retval) { struct sys_sysarch_args /* { syscallarg(int) op; syscallarg(void *) parms; } */ *uap = v; int error = 0; switch(SCARG(uap, op)) { #ifdef USER_LDT case I386_GET_LDT: error = i386_get_ldt(p, SCARG(uap, parms), retval); break; case I386_SET_LDT: error = i386_set_ldt(p, SCARG(uap, parms), retval); break; #endif case I386_IOPL: error = i386_iopl(p, SCARG(uap, parms), retval); break; case I386_GET_IOPERM: error = i386_get_ioperm(p, SCARG(uap, parms), retval); break; case I386_SET_IOPERM: error = i386_set_ioperm(p, SCARG(uap, parms), retval); break; #ifdef VM86 case I386_VM86: error = i386_vm86(p, SCARG(uap, parms), retval); break; #endif case I386_GET_FSBASE: { uint32_t base = i386_get_threadbase(p, TSEG_FS); error = copyout(&base, SCARG(uap, parms), sizeof(base)); break; } case I386_SET_FSBASE: { uint32_t base; if ((error = copyin(SCARG(uap, parms), &base, sizeof(base)))) break; error = i386_set_threadbase(p, base, TSEG_FS); break; } case I386_GET_GSBASE: { uint32_t base = i386_get_threadbase(p, TSEG_GS); error = copyout(&base, SCARG(uap, parms), sizeof(base)); break; } case I386_SET_GSBASE: { uint32_t base; if ((error = copyin(SCARG(uap, parms), &base, sizeof(base)))) break; error = i386_set_threadbase(p, base, TSEG_GS); break; } default: error = EINVAL; break; } return (error); }
static int iopl(int lvl) { return i386_iopl(lvl); }