~vijaykumar

[ Home | Feed | Twitter | Vector Art | Ascii Art | Tutorials ]

qemu-char Abstraction

Thu, 16 Apr 2009

A simulated serial peripheral is generally attached to an external interface, that will act as source for receiving data and sink for trasmitted data. This article describes the internal design of Qemu, that helps to simplify the work for people writing simulations for serial peripherals.

Qemu allows simulated serial ports to be connected to several different external interfaces, including

  1. File

  2. Physical serial port /dev/ttySX

  3. Unix/UDP/TCP socket server/client

  4. Telnet server/client

  5. stdio

  6. Braille device!

Qemu has an internal abstraction layer called the qemu-char abstraction. Each of the various external interfaces mentioned above are accessed within Qemu through a common qemu-char API. Some functions in the qemu-char API are given below.

  1. qemu_chr_read() - to read data from the external interface

  2. qemu_chr_write() - to write data to the external interface

  3. qemu_chr_ioctl() - to perform control operations on the external interface

All the simulated serial peripherals use these API to send and receive data. This greatly simplifies the implementation of the peripherals, since the code for accessing the external interfaces does not have to be repeated in each of the serial peripherals.

The qemu-char abstraction layer, its relation with the external interfaces and the simulated serial devices is shown in the following block diagram.

http://www.bravegnu.org/blog//qemu-char.png
qemu-char abstraction

Permalink | Add Comment | Share: Twitter, Facebook, Buzz, ... | Tags: qemu

blog comments powered by Disqus

Powered by Python | Made with PyBlosxom | Valid XHTML 1.1 | Best Viewed With Any Browser | Icon Credits | CC-BY-SA