aboutsummaryrefslogtreecommitdiff
path: root/hw/hpet.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-06-14 11:29:28 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2010-06-14 11:12:53 -0500
commit40ac17cd56eb5c5a89559ea0fa53f7eea80cbd07 (patch)
tree5075aa9aac81afe13cf9115423b0ea523ddc87ef /hw/hpet.c
parent072c2c31c27204e8e1897c52e481d2ab0b4d075d (diff)
pass info about hpets to seabios.]
Currently HPET ACPI table is created regardless of whether qemu actually created hpet device. This may confuse some guests that don't check that hpet is functional before using it. Solve this by passing info about hpets in qemu to seabios via fw config interface. Additional benefit is that seabios no longer uses hard coded hpet configuration. Proposed interface supports up to 8 hpets. This is the number defined by hpet spec. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/hpet.c')
-rw-r--r--hw/hpet.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/hw/hpet.c b/hw/hpet.c
index e9b585c69b..0c80ee5da7 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -71,8 +71,11 @@ typedef struct HPETState {
uint64_t config; /* configuration */
uint64_t isr; /* interrupt status reg */
uint64_t hpet_counter; /* main counter */
+ uint8_t hpet_id; /* instance id */
} HPETState;
+struct hpet_fw_config hpet_cfg = {.count = ~0};
+
static uint32_t hpet_in_legacy_mode(HPETState *s)
{
return s->config & HPET_CFG_LEGACY;
@@ -228,6 +231,7 @@ static int hpet_post_load(void *opaque, int version_id)
/* Push number of timers into capability returned via HPET_ID */
s->capability &= ~HPET_ID_NUM_TIM_MASK;
s->capability |= (s->num_timers - 1) << HPET_ID_NUM_TIM_SHIFT;
+ hpet_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability;
/* Derive HPET_MSI_SUPPORT from the capability of the first timer. */
s->flags &= ~(1 << HPET_MSI_SUPPORT);
@@ -657,6 +661,8 @@ static void hpet_reset(DeviceState *d)
*/
hpet_pit_enable();
}
+ hpet_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability;
+ hpet_cfg.hpet[s->hpet_id].address = sysbus_from_qdev(d)->mmio[0].addr;
count = 1;
}
@@ -676,6 +682,16 @@ static int hpet_init(SysBusDevice *dev)
int i, iomemtype;
HPETTimer *timer;
+ if (hpet_cfg.count == ~0) /* first instance */
+ hpet_cfg.count = 0;
+
+ if (hpet_cfg.count == 8) {
+ fprintf(stderr, "Only 8 instances of HPET is allowed\n");
+ return -1;
+ }
+
+ s->hpet_id = hpet_cfg.count++;
+
for (i = 0; i < HPET_NUM_IRQ_ROUTES; i++) {
sysbus_init_irq(dev, &s->irqs[i]);
}