From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Markus Armbruster <armbru@redhat.com>,
Avi Kivity <avi@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 06/15] piix: create i8254 through composition
Date: Thu, 26 Jan 2012 13:00:51 -0600 [thread overview]
Message-ID: <1327604460-31142-7-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1327604460-31142-1-git-send-email-aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/i8254.c | 35 +++--------------------------------
hw/i8254.h | 38 ++++++++++++++++++++++++++++++++++++++
hw/pc.c | 5 +----
hw/piix_pci.c | 15 ++++++++++++++-
4 files changed, 56 insertions(+), 37 deletions(-)
create mode 100644 hw/i8254.h
diff --git a/hw/i8254.c b/hw/i8254.c
index 522fed8..fa70ff0 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -21,10 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "hw.h"
+
+#include "i8254.h"
#include "pc.h"
-#include "isa.h"
-#include "qemu-timer.h"
//#define DEBUG_PIT
@@ -33,34 +32,6 @@
#define RW_STATE_WORD0 3
#define RW_STATE_WORD1 4
-typedef struct PITChannelState {
- int count; /* can be 65536 */
- uint16_t latched_count;
- uint8_t count_latched;
- uint8_t status_latched;
- uint8_t status;
- uint8_t read_state;
- uint8_t write_state;
- uint8_t write_latch;
- uint8_t rw_mode;
- uint8_t mode;
- uint8_t bcd; /* not supported */
- uint8_t gate; /* timer start */
- int64_t count_load_time;
- /* irq handling */
- int64_t next_transition_time;
- QEMUTimer *irq_timer;
- qemu_irq irq;
-} PITChannelState;
-
-typedef struct PITState {
- ISADevice dev;
- MemoryRegion ioports;
- uint32_t irq;
- uint32_t iobase;
- PITChannelState channels[3];
-} PITState;
-
static PITState pit_state;
static void pit_irq_timer_update(PITChannelState *s, int64_t current_time);
@@ -553,7 +524,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data)
}
static TypeInfo pit_info = {
- .name = "isa-pit",
+ .name = TYPE_PIT,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(PITState),
.class_init = pit_class_initfn,
diff --git a/hw/i8254.h b/hw/i8254.h
new file mode 100644
index 0000000..1c3656d
--- /dev/null
+++ b/hw/i8254.h
@@ -0,0 +1,38 @@
+#ifndef QEMU_I8254_H
+#define QEMU_I8254_H
+
+#include "hw.h"
+#include "isa.h"
+#include "qemu-timer.h"
+
+#define TYPE_PIT "isa-pit"
+
+typedef struct PITChannelState {
+ int count; /* can be 65536 */
+ uint16_t latched_count;
+ uint8_t count_latched;
+ uint8_t status_latched;
+ uint8_t status;
+ uint8_t read_state;
+ uint8_t write_state;
+ uint8_t write_latch;
+ uint8_t rw_mode;
+ uint8_t mode;
+ uint8_t bcd; /* not supported */
+ uint8_t gate; /* timer start */
+ int64_t count_load_time;
+ /* irq handling */
+ int64_t next_transition_time;
+ QEMUTimer *irq_timer;
+ qemu_irq irq;
+} PITChannelState;
+
+typedef struct PITState {
+ ISADevice dev;
+ MemoryRegion ioports;
+ uint32_t irq;
+ uint32_t iobase;
+ PITChannelState channels[3];
+} PITState;
+
+#endif
diff --git a/hw/pc.c b/hw/pc.c
index d3eba63..95dd582 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1149,16 +1149,13 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
int i;
DriveInfo *fd[MAX_FD];
qemu_irq *a20_line;
- ISADevice *i8042, *port92, *vmmouse, *pit;
+ ISADevice *i8042, *port92, *vmmouse;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
- pit = pit_init(isa_bus, 0x40, 0);
- pcspk_init(pit);
-
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(isa_bus, i, serial_hds[i]);
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 5d7d175..4735d9c 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -32,6 +32,7 @@
#include "xen.h"
#include "hpet_emul.h"
#include "mc146818rtc.h"
+#include "i8254.h"
/*
* I440FX chipset data sheet.
@@ -69,6 +70,7 @@ typedef struct PIIX3State {
HPETState hpet;
RTCState rtc;
+ PITState pit;
ISABus *bus;
@@ -548,6 +550,13 @@ static int piix3_realize(PCIDevice *dev)
/* Setup the RTC IRQ */
s->rtc.irq = rtc_irq;
+ /* Realize the PIT */
+ qdev_set_parent_bus(DEVICE(&s->pit), BUS(s->bus));
+ qdev_init_nofail(DEVICE(&s->pit));
+
+ /* FIXME this should be refactored */
+ pcspk_init(ISA_DEVICE(&s->pit));
+
return 0;
}
@@ -560,8 +569,12 @@ static void piix3_initfn(Object *obj)
object_initialize(&s->rtc, TYPE_RTC);
object_property_add_child(obj, "rtc", OBJECT(&s->rtc), NULL);
-
qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000);
+
+ object_initialize(&s->pit, TYPE_PIT);
+ object_property_add_child(obj, "pit", OBJECT(&s->pit), NULL);
+ qdev_prop_set_uint32(DEVICE(&s->pit), "iobase", 0x40);
+ qdev_prop_set_uint32(DEVICE(&s->pit), "irq", 0);
}
static void piix3_class_init(ObjectClass *klass, void *data)
--
1.7.4.1
next prev parent reply other threads:[~2012-01-26 19:01 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
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 ` Anthony Liguori [this message]
2012-01-31 14:34 ` [Qemu-devel] [PATCH 06/15] piix: create i8254 " 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=1327604460-31142-7-git-send-email-aliguori@us.ibm.com \
--to=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).