From: Anthony Liguori <anthony@codemonkey.ws>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Avi Kivity <avi@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition
Date: Tue, 31 Jan 2012 08:43:22 -0600 [thread overview]
Message-ID: <4F27FE0A.9070105@codemonkey.ws> (raw)
In-Reply-To: <4F27FA04.5050106@siemens.com>
On 01/31/2012 08:26 AM, Jan Kiszka wrote:
> On 2012-01-26 20:00, Anthony Liguori wrote:
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>> ---
>> hw/hpet.c | 38 +-------------------------
>> hw/hpet_emul.h | 40 ++++++++++++++++++++++++++++
>> hw/mc146818rtc.c | 30 ++-------------------
>> hw/mc146818rtc.h | 27 +++++++++++++++++++
>> hw/pc.c | 38 +++++----------------------
>> hw/piix_pci.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++-------
>> 6 files changed, 145 insertions(+), 104 deletions(-)
>>
>> diff --git a/hw/hpet.c b/hw/hpet.c
>> index b6ace4e..c5b8b9e 100644
>> --- a/hw/hpet.c
>> +++ b/hw/hpet.c
>> @@ -41,40 +41,6 @@
>>
>> #define HPET_MSI_SUPPORT 0
>>
>> -struct HPETState;
>> -typedef struct HPETTimer { /* timers */
>> - uint8_t tn; /*timer number*/
>> - QEMUTimer *qemu_timer;
>> - struct HPETState *state;
>> - /* Memory-mapped, software visible timer registers */
>> - uint64_t config; /* configuration/cap */
>> - uint64_t cmp; /* comparator */
>> - uint64_t fsb; /* FSB route */
>> - /* Hidden register state */
>> - uint64_t period; /* Last value written to comparator */
>> - uint8_t wrap_flag; /* timer pop will indicate wrap for one-shot 32-bit
>> - * mode. Next pop will be actual timer expiration.
>> - */
>> -} HPETTimer;
>> -
>> -typedef struct HPETState {
>> - SysBusDevice busdev;
>> - MemoryRegion iomem;
>> - uint64_t hpet_offset;
>> - qemu_irq irqs[HPET_NUM_IRQ_ROUTES];
>> - uint32_t flags;
>> - uint8_t rtc_irq_level;
>> - uint8_t num_timers;
>> - HPETTimer timer[HPET_MAX_TIMERS];
>> -
>> - /* Memory-mapped, software visible registers */
>> - uint64_t capability; /* capabilities */
>> - uint64_t config; /* configuration */
>> - uint64_t isr; /* interrupt status reg */
>> - uint64_t hpet_counter; /* main counter */
>> - uint8_t hpet_id; /* instance id */
>> -} HPETState;
>> -
>
> Both structs are private and should remain so, same for similar patches
> in this series. Does your composition concept requires publicizing them?
> If yes, can't it be fixed. Would be a step backward if not.
It doesn't strictly require it, no, but I like it. It encourages using proper
interfaces like:
void rtc_set_memory(RTCState *rtc, int addr, int val);
Instead of:
void rtc_set_memory(ISADevice *dev, int addr, int val);
Yes, we can achieve the same thing with forward declarations. The second thing
I like about this style is that it makes it easier to use a code generator to
generate serialization functions. Finally, I think embedded a devices memory
within its parent device provides a certain level of elegance.
> Also note that the HPET is not a part of the PIIX, so composition is
> wrong here.
There is no HPET in an i440fx system. The HPET usually sits on the LPC bus
(which replaces ISA in modern systems). It's sometimes a dedicated chip but can
certain co-exist in a Super IO chip. I think in terms of where it would live in
this hypothetical device model, putting it in the PIIX is rational.
> The RTC is again.
-ENOPARSE
Regards,
Anthony Liguori
>
> Jan
>
next prev parent reply other threads:[~2012-01-31 14:43 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 19:00 [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 01/15] pc: merge pc_piix.c into pc.c Anthony Liguori
2012-01-26 19:40 ` Anthony Liguori
2012-01-27 8:50 ` Jan Kiszka
2012-01-27 13:07 ` Anthony Liguori
2012-01-27 13:32 ` Jan Kiszka
2012-01-27 14:06 ` Anthony Liguori
2012-01-27 14:15 ` Jan Kiszka
2012-01-27 14:23 ` Anthony Liguori
2012-01-27 14:03 ` Andreas Färber
2012-01-27 14:14 ` Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 02/15] pc: make some functions static Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 03/15] piix3: make PIIX3-xen a subclass of PIIX3 Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 04/15] piix: prepare for composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition Anthony Liguori
2012-01-31 14:26 ` Jan Kiszka
2012-01-31 14:43 ` Anthony Liguori [this message]
2012-01-31 14:49 ` Jan Kiszka
2012-01-31 14:54 ` Anthony Liguori
2012-01-31 14:56 ` Jan Kiszka
2012-01-31 15:04 ` Anthony Liguori
2012-01-31 16:02 ` Jan Kiszka
2012-01-26 19:00 ` [Qemu-devel] [PATCH 06/15] piix: create i8254 " Anthony Liguori
2012-01-31 14:34 ` Jan Kiszka
2012-01-31 14:47 ` Anthony Liguori
2012-01-31 14:51 ` Jan Kiszka
2012-01-31 14:56 ` Anthony Liguori
2012-01-31 16:42 ` Jan Kiszka
2012-01-31 16:49 ` Anthony Liguori
2012-01-31 16:56 ` Jan Kiszka
2012-01-31 14:58 ` Paolo Bonzini
2012-01-31 16:04 ` Jan Kiszka
2012-01-31 16:12 ` Anthony Liguori
2012-01-31 16:19 ` Jan Kiszka
2012-01-31 16:47 ` Anthony Liguori
2012-01-31 16:59 ` Paolo Bonzini
2012-01-26 19:00 ` [Qemu-devel] [PATCH 07/15] i440fx: eliminate i440fx_common_init Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 08/15] i440fx: introduce some saner naming conventions Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 09/15] i440fx: create the PMC through composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 10/15] i440fx: move some logic to realize and make inheritance from PCIHost explicit Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 11/15] i440fx-pmc: refactor to take properties for memory geometry Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 12/15] i440fx-pmc: calculate PCI memory hole directly Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 13/15] i440fx: allocate MemoryRegion for pci memory space Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 14/15] i440fx: move bios loading to i440fx Anthony Liguori
2012-01-31 14:38 ` Jan Kiszka
2012-01-31 14:50 ` Anthony Liguori
2012-01-31 14:53 ` Jan Kiszka
2012-01-31 14:57 ` Anthony Liguori
2012-01-31 15:01 ` Jan Kiszka
2012-01-26 19:01 ` [Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc Anthony Liguori
2012-01-26 19:12 ` [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Peter Maydell
2012-01-26 19:36 ` Anthony Liguori
2012-01-29 10:42 ` Avi Kivity
2012-01-26 19:57 ` Markus Armbruster
2012-01-26 20:00 ` Anthony Liguori
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=4F27FE0A.9070105@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--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).