4

I have been reading Linux Device Drivers 3rd edition and have been running linux 2.6 in QEMU. However, I am at the point where it requires real hardware. I attempted to emulate a paralleport connector in QEMU with no luck. The host has no parallel port connector.

qemu-system-x86_64 -parallel file:outputfile  --enable-kvm -smp 2   -initrd initramfs.igz -kernel arch/x86/boot/bzImage -m 1024 -append "console=ttyS0 loglevel=8" -nographic

I then wrote a module to access the parallel port connector via request_region(0x378,1,"parallelport");. However, whenever I attempt to write to the ioport region, none of the output is seen in the file "outputfile" in the working directory where QEMU was booted. I have also added the CONFIG_PARPORT option in the kernel and added some of its associated CONFIG's (i.e CONFIG_PARPORT_PC...) which seemed to only add the linux built-in driver or register an IRQ handler. With this, I was still unable to write to the parallelport "outputfile" on the host machine.

However, I can read and write to the ioport region (meaning whatever I do write with outb can be then read with inb. However, it is not written to the parallel port outfile, which leads me to believe something is still wrong.

I was wondering if I could get some suggestions as to what I might be doing wrong or how to start going about this? The only research I found was the different paralleport options for qemu (use host devices, over udp, etc...), which I tried with no luck. In addition, with using the outputfile option or any option that does not require a host machine parallel port, is it possible to simulate interrupts?

Update: After playing around a little more, it seems the operations of writing and reading from the ioport are working (still don't appear in the outputfile thought). This is because when I do -parallel none, I can obtain the ioport and write to it, but reading from it results in unprintable characters (not the ones I inputed). This doesn't happen by default (specifying no -parallel option or when -parallel file:outputfile.

Update2: From QEMU -device documentation I found that -parallel is legacy. So I changed my command to the following:

qemu-system-x86_64 -chardev file,path=./outputfile,id=parallel0 -device isa-parallel,chardev=parallel0,iobase=0x378,irq=7,index=0 --enable-kvm --smp 2   -initrd initramfs.igz -kernel arch/x86/boot/bzImage -m 1024 -append "console=ttyS0 loglevel=8" -nographic

and then loaded the driver and made a chardev /dev/parallel0. However, this still didn't work.

dylan7
  • 803
  • 1
  • 10
  • 22
  • The `path` parameter of the parallel device is your host's path to the device. Also, try removing `-device isa-parallel`. – Felipe Tonello Feb 07 '17 at 00:53
  • Yeah ./outputfile is the file on the host I want the parallel port data on the guest to get directed to. Which the qemu docs said could be just a regular "file". Since the host has no parallel port – dylan7 Feb 07 '17 at 00:55
  • Go to https://qemu.weilnetz.de/doc/qemu-doc.html#Character-device-options and search for *parallel*, there it says `*path* specifies the path to the parallel port device` – Felipe Tonello Feb 07 '17 at 01:20
  • Also on the link you posted it specifies : `chardev file ,id=id ,path=path Log all traffic received from the guest to a file. path specifies the path of the file to be opened. This file will be created if it does not already exist, and overwritten if it does. path is required.` This is also similiar to the first parameters I tried `-parallel file:outputfile`. – dylan7 Feb 07 '17 at 15:27
  • Perhaps it's better to ask on the mailing-list? https://lists.nongnu.org/mailman/listinfo/qemu-discuss – Felipe Tonello Feb 15 '17 at 17:06
  • Have you found the right solution? I'm facing the same issue. – bielu000 May 28 '23 at 09:29

0 Answers0