arch/arm64/include/asm/arch_timer.h
Source file repositories/reference/linux-study-clean/arch/arm64/include/asm/arch_timer.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/include/asm/arch_timer.h- Extension
.h- Size
- 4737 bytes
- Lines
- 222
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/barrier.hasm/hwcap.hasm/sysreg.hlinux/bug.hlinux/init.hlinux/jump_label.hlinux/percpu.hlinux/types.hclocksource/arm_arch_timer.h
Detected Declarations
struct clock_event_devicestruct arch_timer_erratum_workaroundenum arch_timer_erratum_match_typefunction arch_timer_read_cntpct_el0function arch_timer_read_cntvct_el0function arch_timer_reg_write_cp15function arch_timer_reg_read_cp15function arch_timer_get_cntfrqfunction arch_timer_get_cntkctlfunction arch_timer_set_cntkctlfunction __arch_counter_get_cntpct_stablefunction __arch_counter_get_cntpctfunction __arch_counter_get_cntvct_stablefunction __arch_counter_get_cntvctfunction arch_timer_arch_initfunction arch_timer_set_evtstrm_featurefunction arch_timer_have_evtstrm_feature
Annotated Snippet
struct arch_timer_erratum_workaround {
enum arch_timer_erratum_match_type match_type;
const void *id;
const char *desc;
u64 (*read_cntpct_el0)(void);
u64 (*read_cntvct_el0)(void);
int (*set_next_event_phys)(unsigned long, struct clock_event_device *);
int (*set_next_event_virt)(unsigned long, struct clock_event_device *);
bool disable_compat_vdso;
};
DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
timer_unstable_counter_workaround);
static inline notrace u64 arch_timer_read_cntpct_el0(void)
{
u64 cnt;
asm volatile(ALTERNATIVE("isb\n mrs %0, cntpct_el0",
"nop\n" __mrs_s("%0", SYS_CNTPCTSS_EL0),
ARM64_HAS_ECV)
: "=r" (cnt));
return cnt;
}
static inline notrace u64 arch_timer_read_cntvct_el0(void)
{
u64 cnt;
asm volatile(ALTERNATIVE("isb\n mrs %0, cntvct_el0",
"nop\n" __mrs_s("%0", SYS_CNTVCTSS_EL0),
ARM64_HAS_ECV)
: "=r" (cnt));
return cnt;
}
#define arch_timer_reg_read_stable(reg) \
({ \
erratum_handler(read_ ## reg)(); \
})
/*
* These register accessors are marked inline so the compiler can
* nicely work out which register we want, and chuck away the rest of
* the code.
*/
static __always_inline
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u64 val)
{
if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) {
case ARCH_TIMER_REG_CTRL:
write_sysreg(val, cntp_ctl_el0);
isb();
break;
case ARCH_TIMER_REG_CVAL:
write_sysreg(val, cntp_cval_el0);
break;
default:
BUILD_BUG();
}
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
switch (reg) {
case ARCH_TIMER_REG_CTRL:
write_sysreg(val, cntv_ctl_el0);
isb();
break;
case ARCH_TIMER_REG_CVAL:
write_sysreg(val, cntv_cval_el0);
break;
default:
BUILD_BUG();
}
} else {
BUILD_BUG();
}
}
static __always_inline
u64 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
{
if (access == ARCH_TIMER_PHYS_ACCESS) {
switch (reg) {
case ARCH_TIMER_REG_CTRL:
return read_sysreg(cntp_ctl_el0);
default:
BUILD_BUG();
}
Annotation
- Immediate include surface: `asm/barrier.h`, `asm/hwcap.h`, `asm/sysreg.h`, `linux/bug.h`, `linux/init.h`, `linux/jump_label.h`, `linux/percpu.h`, `linux/types.h`.
- Detected declarations: `struct clock_event_device`, `struct arch_timer_erratum_workaround`, `enum arch_timer_erratum_match_type`, `function arch_timer_read_cntpct_el0`, `function arch_timer_read_cntvct_el0`, `function arch_timer_reg_write_cp15`, `function arch_timer_reg_read_cp15`, `function arch_timer_get_cntfrq`, `function arch_timer_get_cntkctl`, `function arch_timer_set_cntkctl`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
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.