add ioperm/iopl syscalls
authorRich Felker <dalias@aerifal.cx>
Mon, 23 Jul 2012 20:54:53 +0000 (16:54 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 23 Jul 2012 20:54:53 +0000 (16:54 -0400)
based on patches by orc and Isaac Dunham, with some fixes. sys/io.h
exists and contains prototypes for these functions regardless of
whether the target arch has them; this is a bit unorthodox but I don't
think it will break anything. the function definitions do not exist
unless the appropriate SYS_* syscall number macro is defined, which
should make sure configure scripts looking for these functions don't
find them on other systems.

presently, sys/io.h does not have the inb/outb/etc. port io
macros/functions. I'd be surprised if ioperm/iopl are useful without
them, so they probably need to be added at some point in appropriate
bits/io.h files...

include/sys/io.h [new file with mode: 0644]
src/linux/ioperm.c [new file with mode: 0644]
src/linux/iopl.c [new file with mode: 0644]

diff --git a/include/sys/io.h b/include/sys/io.h
new file mode 100644 (file)
index 0000000..a6ba467
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef        _SYS_IO_H
+#define        _SYS_IO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ioperm(unsigned long, unsigned long, int);
+int iopl(int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/linux/ioperm.c b/src/linux/ioperm.c
new file mode 100644 (file)
index 0000000..6d7c37d
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sys/io.h>
+#include "syscall.h"
+
+#ifdef SYS_ioperm
+int ioperm(unsigned long from, unsigned long num, int turn_on)
+{
+       return syscall(SYS_ioperm, from, num, turn_on);
+}
+#endif
diff --git a/src/linux/iopl.c b/src/linux/iopl.c
new file mode 100644 (file)
index 0000000..5a626e1
--- /dev/null
@@ -0,0 +1,9 @@
+#include <sys/io.h>
+#include "syscall.h"
+
+#ifdef SYS_iopl
+int iopl(int level)
+{
+       return syscall(SYS_iopl, level);
+}
+#endif