mirror of
https://git.freebsd.org/ports.git
synced 2025-05-22 03:45:17 -04:00
- Respect CFLAGS [2] - Support parallel port under FreeBSD [3] PR: ports/102154 [1], ports/102188 [2] Submitted by: Juergen Lock <nox@jelal.kn-bremen.de> [1], Stanislav Sedov <ssedov@mbsd.msk.ru> [2], Robert Jenssen (via freebsd-ports) [3] Approved by: Juergen Lock <nox@jelal.kn-bremen.de> (maintainer) [2] [3]
92 lines
2.3 KiB
Text
92 lines
2.3 KiB
Text
--- vl.c.orig Mon Aug 21 23:06:11 2006
|
|
+++ vl.c Mon Aug 21 23:04:49 2006
|
|
@@ -48,6 +48,8 @@
|
|
#endif
|
|
#ifdef __FreeBSD__
|
|
#include <sys/module.h>
|
|
+#include <dev/ppbus/ppi.h>
|
|
+#include <dev/ppbus/ppbconf.h>
|
|
#endif
|
|
#else
|
|
#ifndef __sun__
|
|
@@ -1728,7 +1730,65 @@
|
|
chr->chr_ioctl = pp_ioctl;
|
|
return chr;
|
|
}
|
|
-#endif /* defined(__linux__) */
|
|
+#elif 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;
|
|
+}
|
|
+
|
|
+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_add_read_handler = null_chr_add_read_handler;
|
|
+ chr->chr_ioctl = pp_ioctl;
|
|
+ return chr;
|
|
+}
|
|
+#endif
|
|
|
|
#else
|
|
CharDriverState *qemu_chr_open_pty(void)
|
|
@@ -2562,6 +2622,13 @@
|
|
#endif
|
|
#if defined(__linux__)
|
|
if (strstart(filename, "/dev/parport", NULL)) {
|
|
+ return qemu_chr_open_pp(filename);
|
|
+ } else
|
|
+ if (strstart(filename, "/dev/", NULL)) {
|
|
+ return qemu_chr_open_tty(filename);
|
|
+ } else
|
|
+#elif defined(__FreeBSD__)
|
|
+ if (strstart(filename, "/dev/ppi", NULL)) {
|
|
return qemu_chr_open_pp(filename);
|
|
} else
|
|
if (strstart(filename, "/dev/", NULL)) {
|