shithub: choc

Download patch

ref: c423d770e9a05e762a2382e342ddd0bb7e6f3996
parent: 02e3e618472e4afa9a58950a9853aa0356b59504
author: Simon Howard <[email protected]>
date: Tue Mar 10 18:19:29 EDT 2009

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

Subversion-branch: /branches/opl-branch
Subversion-revision: 1460

--- 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 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 =