arch/x86/kernel/hpet.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/hpet.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/hpet.c- Extension
.c- Size
- 37029 bytes
- Lines
- 1457
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clockchips.hlinux/interrupt.hlinux/export.hlinux/delay.hlinux/hpet.hlinux/cpu.hlinux/irq.hasm/cpuid/api.hasm/irq_remapping.hasm/hpet.hasm/time.hasm/mwait.hasm/msr.hlinux/mc146818rtc.hlinux/rtc.h
Detected Declarations
struct hpet_channelstruct hpet_baseenum hpet_modefunction hpet_readlfunction hpet_writelfunction hpet_set_mappingfunction hpet_clear_mappingfunction hpet_setupfunction disable_hpetfunction is_hpet_capablefunction is_hpet_enabledfunction _hpet_print_configfunction driverfunction hpet_select_device_channelfunction hpet_reserve_platform_timersfunction hpet_reset_counterfunction hpet_start_counterfunction hpet_restart_counterfunction hpet_resume_devicefunction hpet_resume_counterfunction hpet_enable_legacy_intfunction hpet_clkevt_set_state_periodicfunction hpet_clkevt_set_state_oneshotfunction hpet_clkevt_set_state_shutdownfunction hpet_clkevt_legacy_resumefunction hpet_clkevt_set_next_eventfunction hpet_init_clockeventfunction hpet_legacy_clockevent_registerfunction hpet_msi_unmaskfunction hpet_msi_maskfunction hpet_msi_writefunction hpet_msi_write_msgfunction hpet_msi_initfunction hpet_dev_idfunction hpet_assign_irqfunction hpet_clkevt_msi_resumefunction hpet_msi_interrupt_handlerfunction hpet_setup_msi_irqfunction init_one_hpet_msi_clockeventfunction hpet_cpuhp_onlinefunction hpet_cpuhp_deadfunction hpet_select_clockeventsfunction hpet_select_clockeventsfunction read_hpetfunction read_hpetfunction hpet_cfg_workingfunction hpet_countingfunction mwait_pc10_supported
Annotated Snippet
struct hpet_channel {
struct clock_event_device evt;
unsigned int num;
unsigned int cpu;
unsigned int irq;
unsigned int in_use;
enum hpet_mode mode;
unsigned int boot_cfg;
char name[10];
};
struct hpet_base {
unsigned int nr_channels;
unsigned int nr_clockevents;
unsigned int boot_cfg;
struct hpet_channel *channels;
};
#define HPET_MASK CLOCKSOURCE_MASK(32)
#define HPET_MIN_CYCLES 128
#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1))
/*
* HPET address is set in acpi/boot.c, when an ACPI entry exists
*/
unsigned long hpet_address;
u8 hpet_blockid; /* OS timer block num */
bool hpet_msi_disable;
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_GENERIC_MSI_IRQ)
static DEFINE_PER_CPU(struct hpet_channel *, cpu_hpet_channel);
static struct irq_domain *hpet_domain;
#endif
static void __iomem *hpet_virt_address;
static struct hpet_base hpet_base;
static bool hpet_legacy_int_enabled;
static unsigned long hpet_freq;
bool boot_hpet_disable;
bool hpet_force_user;
static bool hpet_verbose;
static inline
struct hpet_channel *clockevent_to_channel(struct clock_event_device *evt)
{
return container_of(evt, struct hpet_channel, evt);
}
inline unsigned int hpet_readl(unsigned int a)
{
return readl(hpet_virt_address + a);
}
static inline void hpet_writel(unsigned int d, unsigned int a)
{
writel(d, hpet_virt_address + a);
}
static inline void hpet_set_mapping(void)
{
hpet_virt_address = ioremap(hpet_address, HPET_MMAP_SIZE);
}
static inline void hpet_clear_mapping(void)
{
iounmap(hpet_virt_address);
hpet_virt_address = NULL;
}
/*
* HPET command line enable / disable
*/
static int __init hpet_setup(char *str)
{
while (str) {
char *next = strchr(str, ',');
if (next)
*next++ = 0;
if (!strncmp("disable", str, 7))
boot_hpet_disable = true;
if (!strncmp("force", str, 5))
hpet_force_user = true;
if (!strncmp("verbose", str, 7))
hpet_verbose = true;
str = next;
Annotation
- Immediate include surface: `linux/clockchips.h`, `linux/interrupt.h`, `linux/export.h`, `linux/delay.h`, `linux/hpet.h`, `linux/cpu.h`, `linux/irq.h`, `asm/cpuid/api.h`.
- Detected declarations: `struct hpet_channel`, `struct hpet_base`, `enum hpet_mode`, `function hpet_readl`, `function hpet_writel`, `function hpet_set_mapping`, `function hpet_clear_mapping`, `function hpet_setup`, `function disable_hpet`, `function is_hpet_capable`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.