From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: Re: IRQ handling (was [Qemu-devel] qemu Makefile.target vl.h hw/acpi.c hw/adlib.c ...)
Date: Sun, 08 Apr 2007 09:49:55 +0200 [thread overview]
Message-ID: <1176018595.1516.115.camel@rapid> (raw)
In-Reply-To: <20070408000420.GJ21953@networkno.de>
On Sun, 2007-04-08 at 01:04 +0100, Thiemo Seufer wrote:
> J. Mayer wrote:
> [snip]
> > To give you an real example why arbitrary limits are not acceptable AT
> > ALL: I know an embedded Mips device (widely used !) with 2 CPU, 8 PIC
> > and about 500 IRQ sources.
>
> Care to tell which one this is?
I'm sorry, I'm no sure I can (NDA rules....).
Let's say it's a chips used in some consumer electronics products.
> > How can you even pretend add a limited
> > structure in the CPUState structure when this is exactly the kind of
> > device some people want to emulate in Qemu ? Your concept is completely
> > broken, you have to admit it. You can never put peripheral informations
> > in the CPUState structure.
>
> At least for MIPS it makes sense to put the CPU-internal controller
> in exactly that place.
It does not. If you look well, the IRQ controller is not in the CPU.
Only the exception are managed in the CPU. The "internal" IRQ controller
is a peripheral device located in the CP0. OK, the CP0 is tightly
coupled to the CPU so it's easier to consider it as part of the CPU,
when emulating it. But it seems like you could imagine a MIPS CPU
without a CP0 coprocessor (even if it will never happen in the real
world), no ?
The problem is also: what does this patch adds, but complexity and
arbitrary limitations ?
What do you need to route an IRQ ?
-> A peripheral destination
What we got now ?
-> a callback with 3 parameters: an opaque, a PIN (the n_IRQ) and a
state
Is more needed to have a generic routing approach ?
-> no. This can work to route any signal
Can we do with less ?
-> no. You need the 3 parameters.
Can we share data ?
-> It seems not. The opaque is used internally by the IRQ controller.
The PIN number has a meaning only inside the IRQ controller. And the
meaning of the state depends on the IRQ controller state.
The only thing that could be changed to hide the complexity is define a
structure that contain all information, like the struct IRQState.
But this structure cannot be shared as it has no signification outside
of an IRQ controller.
What can be done (but once again, it changes nothing, just hide the
"complexity"), is to replace the { callback, n_IRQ } in devices
structure by a IRQState structure and have the inline functions.
static inline void qemu_irq_set_state(struct IRQState *st, int level)
{
if (st->handler != NULL)
(*st->handler)(st->opaque, st->n, level);
}
static inline void qemu_irq_raise(struct IRQState *st)
{
qemu_irq_set_state(st, 1);
}
static inline void qemu_irq_lower(struct IRQState *st)
{
qemu_irq_set_state(st, 0);
}
If you want to be generic, as it is said it's supposed to be (but is not) to be able to manage any signal, then this is not sufficient.
One will also have to get the value. If you want to emulate GPIOs, for example, you need to store the current state
to be able to get it back easily. And for GPIO, you may prefer that changing the state has no action but just be able
to read back the current PIN level at any time.
To achieve this, you have to have a structure:
struct PINState {
qemu_pin_handler handler;
void *opaque;
int n;
int level;
};
static inline void qemu_pin_set_state(struct PINState *st, int level)
{
if (st->handler != NULL && level != st->level != level) {
(*st->handler)(st->opaque, st->n, level);
st->level = level;
}
}
static inline int qemu_pin_get_state(struct PINState *st)
{
return st->level;
}
static inline void qemu_ping_raise(struct PINState *st)
{
qemu_pin_pin_state(st, 1);
}
static inline void qemu_pin_lower(struct PINState *st)
{
qemu_pin_set_state(st, 0);
}
The hw/irq.c code is not needed and meaningless. The first function should be inlined, unless the goal is to slowdown the emulator.
The second function has no meaning: you can never globally allocate resources that have no meaning outside of a limited
scope, which is the case for IRQ or any physical connection on a real hardware.
The PINState structure can be store only in the peripheral device that will change the PIN state and the peripheral that will read this state.
Trying to store it in a generic place is completely meaningless: a PIN state (I talk about real hardware, now) has absolutelly
no generic meaning. It's only significant between two devices. You eventually can have more than one device changing the
PIN state (shared IRQ, I2C bus, ....) and more than one device using this PIN state (I2C, once again). But outside of the scope
of those devices, it means nothing. So the information is to be stored inside those devices, anywhere else is meaningless.
--
J. Mayer <l_indien@magic.fr>
Never organized
next prev parent reply other threads:[~2007-04-08 7:54 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-07 18:14 [Qemu-devel] qemu Makefile.target vl.h hw/acpi.c hw/adlib.c Paul Brook
2007-04-07 18:32 ` J. Mayer
2007-04-07 19:10 ` Paul Brook
2007-04-07 19:32 ` Blue Swirl
2007-04-07 19:46 ` Paul Brook
2007-04-07 20:28 ` J. Mayer
2007-04-07 20:45 ` Paul Brook
2007-04-07 22:18 ` J. Mayer
2007-04-07 22:49 ` Thiemo Seufer
2007-04-07 23:13 ` Paul Brook
2007-04-07 23:54 ` J. Mayer
2007-04-08 0:04 ` Thiemo Seufer
2007-04-08 7:49 ` J. Mayer [this message]
2007-04-08 8:38 ` IRQ handling (was [Qemu-devel] qemu Makefile.target vl.h hw/acpi.c hw/adlib.c ...) J. Mayer
2007-04-08 14:41 ` Thiemo Seufer
2007-04-08 16:31 ` J. Mayer
2007-04-08 20:43 ` QEMU Automated Testing " Natalia Portillo
2007-04-08 22:07 ` Eduardo Felipe
2007-04-08 23:53 ` Natalia Portillo
2007-04-09 9:36 ` Eduardo Felipe
2007-04-09 21:19 ` Rob Landley
2007-04-10 11:24 ` Jamie Lokier
2007-04-10 12:00 ` Pierre d'Herbemont
2007-07-27 14:21 ` Dan Shearer
2007-07-27 14:29 ` Anthony Liguori
2007-07-27 14:34 ` Dan Shearer
2007-07-27 14:58 ` Sunil Amitkumar Janki
2007-07-27 15:12 ` Dan Shearer
2007-07-27 15:50 ` Sunil Amitkumar Janki
2007-07-27 16:04 ` Dan Shearer
2007-07-27 16:50 ` Jan Marten Simons
2007-07-27 18:51 ` Thiemo Seufer
2007-07-27 19:55 ` Sunil Amitkumar Janki
2007-07-28 10:17 ` Thiemo Seufer
2007-07-28 11:41 ` Sunil Amitkumar Janki
2007-07-28 12:43 ` [Qemu-devel] Re: QEMU Automated Testing Stefan Weil
2007-07-27 18:54 ` QEMU Automated Testing (was [Qemu-devel] qemu Makefile.target vl.h hw/acpi.c hw/adlib.c ...) Andreas Färber
2007-07-28 10:36 ` Thiemo Seufer
2007-07-29 15:31 ` Andreas Färber
2007-04-10 11:17 ` IRQ handling " Jamie Lokier
2007-04-09 0:41 ` [Qemu-devel] Re: IRQ handling Paul Brook
2007-04-09 11:11 ` J. Mayer
2007-04-09 13:58 ` Paul Brook
2007-04-09 14:56 ` J. Mayer
2007-04-09 16:57 ` Paul Brook
2007-04-07 23:26 ` [Qemu-devel] qemu Makefile.target vl.h hw/acpi.c hw/adlib.c Fabrice Bellard
2007-04-08 13:06 ` Wang Cheng Yeh
2007-04-08 13:56 ` Thiemo Seufer
2007-04-08 22:45 ` Paul Brook
2007-04-07 21:20 ` Thiemo Seufer
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=1176018595.1516.115.camel@rapid \
--to=l_indien@magic.fr \
--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).