foxygit / doom Log in
commit c423d770e9a05e762a2382e342ddd0bb7e6f3996
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Mar 10 22:19:29 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Mar 10 22:19:29 2009 +0000

    Fix outb() call, display error message if unable to gain port
    permissions.

    Subversion-branch: /branches/opl-branch
    Subversion-revision: 1460
---
 opl/opl_linux.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/opl/opl_linux.c b/opl/opl_linux.c
index 438b091a..d1d1e466 100644
--- a/opl/opl_linux.c
+++ b/opl/opl_linux.c
@@ -27,6 +27,9 @@

 #ifdef HAVE_IOPERM

+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
 #include <unistd.h>
 #include <sys/io.h>

@@ -35,12 +38,14 @@

 static unsigned int opl_port_base;

-static void OPL_Linux_Init(unsigned int port_base)
+static int OPL_Linux_Init(unsigned int port_base)
 {
     // Try to get permissions:

     if (ioperm(port_base, 2, 1) < 0)
     {
+        fprintf(stderr, "Failed to get I/O port permissions for 0x%x: %s\n",
+                        port_base, strerror(errno));
         return 0;
     }

@@ -63,7 +68,7 @@ static unsigned int OPL_Linux_PortRead(opl_port_t port)

 static void OPL_Linux_PortWrite(opl_port_t port, unsigned int value)
 {
-    outb(opl_port_base + port, value);
+    outb(value, opl_port_base + port);
 }

 opl_driver_t opl_linux_driver =