OSDev.org
https://forum.osdev.org/

Qemu HPET comparator_count is 2?
https://forum.osdev.org/viewtopic.php?f=1&t=33102
Page 1 of 1

Author:  zaptor [ Thu Aug 02, 2018 9:15 pm ]
Post subject:  Qemu HPET comparator_count is 2?

According to https://wiki.osdev.org/HPET#HPET_-_timer_vs_comparators:

Quote:
There're from 3 to 32 comparators, and the exact amount is indicated by comparator_count field in the above hpet structure.


However, when I print the value of comparator_count in the acpi HPET table, I'm seeing 2. I use the exact struct shown on that osdev page, namely:

Code:
struct address_structure
{
    uint8_t address_space_id;    // 0 - system memory, 1 - system I/O
    uint8_t register_bit_width;
    uint8_t register_bit_offset;
    uint8_t reserved;
    uint64_t address;
} __attribute__((packed));

struct description_table_header
{
    char signature[4];    // 'HPET' in case of HPET table
    uint32_t length;
    uint8_t revision;
    uint8_t checksum;
    char oemid[6];
    uint64_t oem_tableid;
    uint32_t oem_revision;
    uint32_t creator_id;
    uint32_t creator_revision;
} __attribute__((packed));

struct hpet : public description_table_header
{
    uint8_t hardware_rev_id;
    uint8_t comparator_count:5;
    uint8_t counter_size:1;
    uint8_t reserved:1;
    uint8_t legacy_replacement:1;
    uint16_t pci_vendor_id;
    address_structure address;
    uint8_t hpet_number;
    uint16_t minimum_tick;
    uint8_t page_protection;
} __attribute__((packed));


When I print comparator_count, I'm seeing the value 2 which is not between 3 and 32. What's going on here?

Author:  MollenOS [ Fri Aug 03, 2018 2:34 am ]
Post subject:  Re: Qemu HPET comparator_count is 2?

It uses 5 bits to keep comparator count which technically the count can max be 31. This probably means that you need to add 1 to the actual count, as 0 = 1.... 31 = 32 to get the actual number of comparators.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/