Because of unavailability of IOAPIC interrupt lines, HPET currently
supports only legacy mode, where the legacy timer interrupt (inti2) is
used. This patch makes this explicit by reducing the number of timers
supported by HPET to 2 (the 2 legacy timers) and advertising no
available IOAPIC interrupt lines.
This patch also adds a check, suggested by Andriy Gapon, to ensure that
the interrupt chosen by the guest is one of those advertised by the HPET
as available. This is currently a noop since HPET advertises none as
available, but in the event of future expansion and availability of
IOAPIC interrupt lines, or implementation of level-triggered interrupts
that can share interrupt lines, this code will be in place.
This subset of HPET capability (legacy-only) is reasonable, since the
basic operation of linux and windows only uses the HPET in legacy mode,
at least that's what all my testing so far has shown. Only userspace
access to the hpet would use non-legacy timers.
diff --git a/hw/hpet.c b/hw/hpet.c
index 01b10aa..56fa27c 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -47,12 +47,16 @@ uint32_t hpet_in_legacy_mode(void)
return 0;
}
-static uint32_t timer_int_route(struct HPETTimer *timer)
-{
- uint32_t route;
- route = (timer->config & HPET_TN_INT_ROUTE_MASK) >>
HPET_TN_INT_ROUTE_SHIFT;
- return route;
-}
+/* future code for when non-legacy interrupts are supported
+ * (when spare ioapic interrupts are available)
+ * static uint32_t timer_int_route(struct HPETTimer *timer)
+ * {
+ * uint32_t route;
+ * route = (timer->config & HPET_TN_INT_ROUTE_CNF_MASK)
+ * >> HPET_TN_INT_ROUTE_CNF_SHIFT;
+ * return route;
+ *}
+ */