Skip to contentSkip to conversation

[5779] Native FreeBSD parallel port (Juergen Lock)

Qemu-devel Blue Swirl 2 participants 2 messages Nov 22, 2008

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

Revision: 5779

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5779
Author:   blueswir1
Date:     2008-11-22 20:49:12 +0000 (Sat, 22 Nov 2008)

Log Message:
-----------
Native FreeBSD parallel port (Juergen Lock)

Modified Paths:
--------------
trunk/qemu-char.c

Modified: trunk/qemu-char.c
===================================================================

qemu-char.c +65 -0
@@ -63,6 +63,8 @@
 #include <sys/stat.h>
 #ifdef __FreeBSD__
 #include <libutil.h>
+#include <dev/ppbus/ppi.h>
+#include <dev/ppbus/ppbconf.h>
 #else
 #include <util.h>
 #endif
@@ -1269,6 +1271,65 @@
 }
 #endif /* __linux__ */
 
+#if defined(__FreeBSD__)
+static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
+{
+    int fd = (int)chr->opaque;
+    uint8_t b;
+
+    switch(cmd) {
+    case CHR_IOCTL_PP_READ_DATA:
+        if (ioctl(fd, PPIGDATA, &b) < 0)
+            return -ENOTSUP;
+        *(uint8_t *)arg = b;
+        break;
+    case CHR_IOCTL_PP_WRITE_DATA:
+        b = *(uint8_t *)arg;
+        if (ioctl(fd, PPISDATA, &b) < 0)
+            return -ENOTSUP;
+        break;
+    case CHR_IOCTL_PP_READ_CONTROL:
+        if (ioctl(fd, PPIGCTRL, &b) < 0)
+            return -ENOTSUP;
+        *(uint8_t *)arg = b;
+        break;
+    case CHR_IOCTL_PP_WRITE_CONTROL:
+        b = *(uint8_t *)arg;
+        if (ioctl(fd, PPISCTRL, &b) < 0)
+            return -ENOTSUP;
+        break;
+    case CHR_IOCTL_PP_READ_STATUS:
+        if (ioctl(fd, PPIGSTATUS, &b) < 0)
+            return -ENOTSUP;
+        *(uint8_t *)arg = b;
+        break;
+    default:
+        return -ENOTSUP;
+    }
+    return 0;
+}
+
+static CharDriverState *qemu_chr_open_pp(const char *filename)
+{
+    CharDriverState *chr;
+    int fd;
+
+    fd = open(filename, O_RDWR);
+    if (fd < 0)
+        return NULL;
+
+    chr = qemu_mallocz(sizeof(CharDriverState));
+    if (!chr) {
+        close(fd);
+        return NULL;
+    }
+    chr->opaque = (void *)fd;
+    chr->chr_write = null_chr_write;
+    chr->chr_ioctl = pp_ioctl;
+    return chr;
+}
+#endif
+
 #else /* _WIN32 */
 
 typedef struct {
@@ -2110,6 +2171,10 @@
     if (strstart(filename, "/dev/parport", NULL)) {
         chr = qemu_chr_open_pp(filename);
     } else
+#elif defined(__FreeBSD__)
+    if (strstart(filename, "/dev/ppi", NULL)) {
+        chr = qemu_chr_open_pp(filename);
+    } else
 #endif
 #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
     || defined(__NetBSD__) || defined(__OpenBSD__)
#1 lore raw

In article <[email protected]> you write:

Quoted 8 lines

Revision: 5779

         http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5779
Author:   blueswir1
Date:     2008-11-22 20:49:12 +0000 (Sat, 22 Nov 2008)

Log Message:
-----------
Native FreeBSD parallel port (Juergen Lock)

Actually the original patch that first went into ports was submitted by Robert Jenssen from Australia, sorry I probably should have said somewhere. (I don't know whether he wants his full address public.)

Just thought I'd mention...
Juergen