qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <graf@campus.tu-berlin.de>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] hw/arm: add Lego NXT board
Date: Mon, 14 Jul 2014 20:09:48 +0200	[thread overview]
Message-ID: <53C41CEC.5030705@campus.tu-berlin.de> (raw)
In-Reply-To: <53C3C32A.4060705@redhat.com>

On 07/14/2014 01:46 PM, Paolo Bonzini wrote:
> Il 13/07/2014 16:20, Alexander Graf ha scritto:

>> The
>> environment simulator is an external program which is connected to
>> several qemu instances via posix named pipes using a simple
>> communication protocol. Without pipe interaction the emulator can still
>> be used to debug NXT firmware images without sensor/actuator interaction.
>
> What does your protocol look like, and what kind of bus do the actual
> sensors and actuators use?
 >
 > If it is I2C or SPI, having generic i2c-over-chardev or spi-over-chardev
 > protocols and devices would be a nice addition to QEMU.

The actual sensor hardware is not emulated. This was not required for my 
demand to inject sonsor values. I use an abstraction over the sensor 
hardware using IO memory. My firmware is something like:

uint32_t readUltrasonicSensor()
{
#ifdef QEMU_SIMULATION_IMAGE
	// This triggers pipe communication in Qemu
	// No hardware emulation
	return SOME_IO_MEMORY_REGISTER_SPECIFIC_FOR_THE_SENSOR;
#else
	// do the actual I2C bus transaction to read the value
#endif
}

So the protocol basically allows to forward read and write accesses on 
IO memory to processes outside of Qemu.

My protocol uses two named pipes as transport. One from Qemu to an 
outside process and one back into Qemu. It is a binary protocol with 
basically three messages:

get:
request: REQUEST_GET | uint16_t sequence # | uint16_t requested register
response: uint16_t sequence # | uint32_t register content

set:
request: REQUEST_SET | uint16_t sequence # | uint16_t register | 
uint32_t register value
response: uint16_t sequence #

sync tick:
request: REQUEST_TICK | uint16_t sequence #
response: uint16_t sequence #

Get and set transactions are triggered by Qemu on an IO memory read 
operation or write operation respectively. The pipe communication blocks 
Qemu until a value is available/the value was published.

The sync tick operation is to tell the remote process that the system 
tick timer interrupt has occured. (Another requirement for my SIL 
simulator.) For a generic memory-io-over-chardev device this could be 
removed. In addition for a truly generic implementation the memory 
access size (byte, word, ... access) needs to be integrated into the 
protocol.

I like the *-over-chardev idea. This could be a benefit for people who 
want to couple simulators or test oracles for embedded system tests or 
in general to other software in a simple way.

Regards
Alexander

  reply	other threads:[~2014-07-14 18:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 14:20 [Qemu-devel] hw/arm: add Lego NXT board Alexander Graf
2014-07-14 11:23 ` Peter Crosthwaite
2014-07-14 11:46 ` Paolo Bonzini
2014-07-14 18:09   ` Alexander Graf [this message]
2014-07-14 20:37     ` Paolo Bonzini
2014-07-14 21:10       ` Alexander Graf
2014-07-14 22:48         ` Peter Maydell
2014-07-15  7:06           ` Paolo Bonzini
2014-07-15 10:26             ` Alexander Graf
2014-07-15 10:53               ` Paolo Bonzini
2014-07-15 18:55                 ` Alexander Graf
2014-07-15 20:09                   ` Paolo Bonzini
2014-07-16  8:40                     ` Alexander Graf
2014-07-16  8:50                       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C41CEC.5030705@campus.tu-berlin.de \
    --to=graf@campus.tu-berlin.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).