[RFC v2 25/26] hw/timer/hpet: Add HPET_TN_BASE macro
Zhao Liu <[email protected]> Wed, 8 Jul 2026 16:10:51 +0800
| Newsgroups | org.nongnu.qemu-rust,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
Use the HPET_TN_BASE macro instead of a hardcoded value to support next HPET test case. Signed-off-by: Zhao Liu <[email protected]> --- Changes since v1: * New commit. --- hw/timer/hpet.c | 8 ++++---- include/hw/timer/hpet.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 42285cff762b..84405e7cb4cb 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -450,7 +450,7 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr, QEMU_LOCK_GUARD(&s->lock); /*address range of all global regs*/ - if (addr <= 0xff) { + if (addr < HPET_TN_BASE) { switch (addr) { case HPET_ID: // including HPET_PERIOD return s->capability >> shift; @@ -463,7 +463,7 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr, break; } } else { - uint8_t timer_id = (addr - 0x100) / 0x20; + uint8_t timer_id = (addr - HPET_TN_BASE) / 0x20; HPETTimer *timer; if (timer_id >= s->num_timers) { @@ -501,7 +501,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr, addr &= ~4; /*address range of all global regs*/ - if (addr <= 0xff) { + if (addr < HPET_TN_BASE) { switch (addr) { case HPET_ID: return; @@ -564,7 +564,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr, break; } } else { - uint8_t timer_id = (addr - 0x100) / 0x20; + uint8_t timer_id = (addr - HPET_TN_BASE) / 0x20; HPETTimer *timer; trace_hpet_ram_write_timer_id(timer_id); diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h index 84be4c3529a7..cc1e48706327 100644 --- a/include/hw/timer/hpet.h +++ b/include/hw/timer/hpet.h @@ -37,6 +37,7 @@ #define HPET_CFG 0x010 #define HPET_STATUS 0x020 #define HPET_COUNTER 0x0f0 +#define HPET_TN_BASE 0x100 #define HPET_TN_CFG 0x000 #define HPET_TN_CMP 0x008 #define HPET_TN_ROUTE 0x010 -- 2.34.1