qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-discuss] quick pointer on adding a new chardev


From: Herb Peyerl
Subject: [Qemu-discuss] quick pointer on adding a new chardev
Date: Fri, 17 Feb 2017 08:47:07 -0700

I’m in the process of writing new device emulator for some custom hardware (an 
FPGA core with some FIFOs and interrupts on an ARM platform) … My goal is to 
tie these FIFOs to a TCP socket on the Qemu side.     This is my first device 
emulation so I’m new to Qemu internals.

I’ve managed to get a basic qemu device written that responds to register 
reads/writes and inserts writes from the guest Linux instance into a Qemu Fifo. 
 Now I’m trying to hook the device up to a TCP socket listening on another host 
 (nc -l).

In essence, I’m trying to do this:

        -chardev socket,host=192.168.1.1,port=5000,id=myfoo0 \
        -device myfoo,chardev=myfoo0

What I seem to be unclear on at this point is how to create a chardev device 
that qemu recognizes as a ‘myfoo’  (instead of ‘serial’ or ‘usb-serial’) …

I understand on the receive side I need to do ‘qemu_chr_add_handlers()’ but I’m 
unclear on how a new chardev becomes instantiated.  I’ve looked at other device 
emulations like xilinx_uart.c and cadence_uart.c which appear to do that but I 
can’t seem to get my device to be acceptable to ‘-device …..’ 

As a side note, it appears that the API has changed in recent versions of qemu 
(CharBackend, and        DEFINE_PROP_CHR) but the version of Qemu I’m using 
from the Xilinx Qemu tree hasn’t been keeping up, as a result ‘CharBackend’ is 
not defined….   The old way appears to be " s->chr = 
qemu_char_get_next_serial();” which is failing for me and as a result 
qemu_chr_add_handlers() gets a SEGV.     ( 
https://github.com/Xilinx/qemu/blob/master/hw/char/cadence_uart.c#L479 )

My device is closest to a uart which is why I opted to start there.

I believe I’m going about this incorrectly so would be grateful for any 
pointers to documentation or help.  The error I’m at currently (if I statically 
allocate s->chr and call qemu_chr_add_handlers()) is:

> qemu-system-aarch64: Option ‘-device myfoo’ cannot be handled by this machine

so I think I’ve just not managed to register my device as a chardev.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]