Commit 6972f93538fc3ad18e791c69ffa1342da11d7159
1 parent
5f8712aa
Native FreeBSD parallel port (Juergen Lock)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5779 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
65 additions
and
0 deletions
qemu-char.c
@@ -63,6 +63,8 @@ | @@ -63,6 +63,8 @@ | ||
63 | #include <sys/stat.h> | 63 | #include <sys/stat.h> |
64 | #ifdef __FreeBSD__ | 64 | #ifdef __FreeBSD__ |
65 | #include <libutil.h> | 65 | #include <libutil.h> |
66 | +#include <dev/ppbus/ppi.h> | ||
67 | +#include <dev/ppbus/ppbconf.h> | ||
66 | #else | 68 | #else |
67 | #include <util.h> | 69 | #include <util.h> |
68 | #endif | 70 | #endif |
@@ -1269,6 +1271,65 @@ static CharDriverState *qemu_chr_open_pp(const char *filename) | @@ -1269,6 +1271,65 @@ static CharDriverState *qemu_chr_open_pp(const char *filename) | ||
1269 | } | 1271 | } |
1270 | #endif /* __linux__ */ | 1272 | #endif /* __linux__ */ |
1271 | 1273 | ||
1274 | +#if defined(__FreeBSD__) | ||
1275 | +static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) | ||
1276 | +{ | ||
1277 | + int fd = (int)chr->opaque; | ||
1278 | + uint8_t b; | ||
1279 | + | ||
1280 | + switch(cmd) { | ||
1281 | + case CHR_IOCTL_PP_READ_DATA: | ||
1282 | + if (ioctl(fd, PPIGDATA, &b) < 0) | ||
1283 | + return -ENOTSUP; | ||
1284 | + *(uint8_t *)arg = b; | ||
1285 | + break; | ||
1286 | + case CHR_IOCTL_PP_WRITE_DATA: | ||
1287 | + b = *(uint8_t *)arg; | ||
1288 | + if (ioctl(fd, PPISDATA, &b) < 0) | ||
1289 | + return -ENOTSUP; | ||
1290 | + break; | ||
1291 | + case CHR_IOCTL_PP_READ_CONTROL: | ||
1292 | + if (ioctl(fd, PPIGCTRL, &b) < 0) | ||
1293 | + return -ENOTSUP; | ||
1294 | + *(uint8_t *)arg = b; | ||
1295 | + break; | ||
1296 | + case CHR_IOCTL_PP_WRITE_CONTROL: | ||
1297 | + b = *(uint8_t *)arg; | ||
1298 | + if (ioctl(fd, PPISCTRL, &b) < 0) | ||
1299 | + return -ENOTSUP; | ||
1300 | + break; | ||
1301 | + case CHR_IOCTL_PP_READ_STATUS: | ||
1302 | + if (ioctl(fd, PPIGSTATUS, &b) < 0) | ||
1303 | + return -ENOTSUP; | ||
1304 | + *(uint8_t *)arg = b; | ||
1305 | + break; | ||
1306 | + default: | ||
1307 | + return -ENOTSUP; | ||
1308 | + } | ||
1309 | + return 0; | ||
1310 | +} | ||
1311 | + | ||
1312 | +static CharDriverState *qemu_chr_open_pp(const char *filename) | ||
1313 | +{ | ||
1314 | + CharDriverState *chr; | ||
1315 | + int fd; | ||
1316 | + | ||
1317 | + fd = open(filename, O_RDWR); | ||
1318 | + if (fd < 0) | ||
1319 | + return NULL; | ||
1320 | + | ||
1321 | + chr = qemu_mallocz(sizeof(CharDriverState)); | ||
1322 | + if (!chr) { | ||
1323 | + close(fd); | ||
1324 | + return NULL; | ||
1325 | + } | ||
1326 | + chr->opaque = (void *)fd; | ||
1327 | + chr->chr_write = null_chr_write; | ||
1328 | + chr->chr_ioctl = pp_ioctl; | ||
1329 | + return chr; | ||
1330 | +} | ||
1331 | +#endif | ||
1332 | + | ||
1272 | #else /* _WIN32 */ | 1333 | #else /* _WIN32 */ |
1273 | 1334 | ||
1274 | typedef struct { | 1335 | typedef struct { |
@@ -2110,6 +2171,10 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename) | @@ -2110,6 +2171,10 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename) | ||
2110 | if (strstart(filename, "/dev/parport", NULL)) { | 2171 | if (strstart(filename, "/dev/parport", NULL)) { |
2111 | chr = qemu_chr_open_pp(filename); | 2172 | chr = qemu_chr_open_pp(filename); |
2112 | } else | 2173 | } else |
2174 | +#elif defined(__FreeBSD__) | ||
2175 | + if (strstart(filename, "/dev/ppi", NULL)) { | ||
2176 | + chr = qemu_chr_open_pp(filename); | ||
2177 | + } else | ||
2113 | #endif | 2178 | #endif |
2114 | #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ | 2179 | #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ |
2115 | || defined(__NetBSD__) || defined(__OpenBSD__) | 2180 | || defined(__NetBSD__) || defined(__OpenBSD__) |