akaros/kern/drivers/timers/hpet.h
<<
>>
Prefs
   1/* Copyright (c) 2020 Google Inc
   2 * Barret Rhoden <brho@cs.berkeley.edu>
   3 * See LICENSE for details.
   4 *
   5 * HPET nonsense */
   6
   7#pragma once
   8
   9#include <acpi.h>
  10#include <atomic.h>
  11
  12struct hpet_timer {
  13        uintptr_t base;
  14        uint64_t enable_cmd;
  15        bool bit64;
  16        bool fsb;
  17        bool in_use;
  18        struct hpet_block *hpb;
  19};
  20
  21struct hpet_block {
  22        spinlock_t lock;
  23        uintptr_t base;
  24        uint64_t cap_id;
  25        uint32_t period;
  26        uint32_t nsec_per_tick;
  27        uint32_t reach32;
  28        unsigned int nr_timers;
  29        struct hpet_timer timers[32];
  30};
  31
  32struct hpet_timer *hpet_get_magic_timer(void);
  33void hpet_put_timer(struct hpet_timer *ht);
  34
  35void hpet_timer_enable(struct hpet_timer *ht);
  36void hpet_timer_disable(struct hpet_timer *ht);
  37bool hpet_check_spurious_64(struct hpet_timer *ht);
  38void hpet_magic_timer_setup(struct hpet_timer *ht, uint8_t vno, uint8_t dmode);
  39void hpet_timer_increment_comparator(struct hpet_timer *ht, uint64_t nsec);
  40
  41struct Atable *parsehpet(struct Atable *parent,
  42                         char *name, uint8_t *p, size_t rawsize);
  43