./sys_ports_none.h:18:2: warning: #warning I/O port access not
available on this platform
isn't there a way to get access to I/O ports on kfreebsd?
Yes, there is.
On kfreebsd-i386 is available both ioperm() and iopl(),
on kfreebsd-amd64 is available only iopl().
The API is the same as on Linux (glibc).
Please use attached patch with iopl() usage.
It is based on original sys_ports_glibc.h
Petr
Index: sys_ports_kfreebsd.h
===================================================================
--- sys_ports_kfreebsd.h (revision 0)
+++ sys_ports_kfreebsd.h (revision 0)
@@ -0,0 +1,42 @@
+#include <string.h>
+#include <errno.h>
+
+#ifdef HAVE_SYS_IO_H
+#include <sys/io.h>
+#endif /* HAVE_SYS_IO_H */
+
+int
+enablePorts (int errorLevel, unsigned short int base, unsigned short int
count) {
+#ifdef HAVE_SYS_IO_H
+ if (iopl(3) != -1) return 1;
+ LogPrint(errorLevel, "Port enable error: %u.%u: %s", base, count,
strerror(errno));
+#else /* HAVE_SYS_IO_H */
+ LogPrint(errorLevel, "I/O ports not supported.");
+#endif /* HAVE_SYS_IO_H */
+ return 0;
+}
+
+int
+disablePorts (unsigned short int base, unsigned short int count) {
+#ifdef HAVE_SYS_IO_H
+ if (iopl(0) != -1) return 1;
+ LogPrint(LOG_ERR, "Port disable error: %u.%u: %s", base, count,
strerror(errno));
+#endif /* HAVE_SYS_IO_H */
+ return 0;
+}
+
+unsigned char
+readPort1 (unsigned short int port) {
+#ifdef HAVE_SYS_IO_H
+ return inb(port);
+#else /* HAVE_SYS_IO_H */
+ return 0;
+#endif /* HAVE_SYS_IO_H */
+}
+
+void
+writePort1 (unsigned short int port, unsigned char value) {
+#ifdef HAVE_SYS_IO_H
+ outb(value, port);
+#endif /* HAVE_SYS_IO_H */
+}
Index: sys_kfreebsd.c
===================================================================
--- sys_kfreebsd.c (revision 2949)
+++ sys_kfreebsd.c (working copy)
@@ -46,4 +46,4 @@
#include "sys_midi_none.h"
#endif /* ENABLE_MIDI_SUPPORT */
-#include "sys_ports_none.h"
+#include "sys_ports_kfreebsd.h"