arch/powerpc/include/asm/time.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/time.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/time.h- Extension
.h- Size
- 2949 bytes
- Lines
- 121
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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
linux/types.hlinux/percpu.hasm/processor.hasm/cpu_has_feature.hasm/vdso/timebase.h
Detected Declarations
struct div_resultfunction get_vtbfunction get_decfunction set_decfunction tb_ticks_sincefunction timer_get_next_tb
Annotated Snippet
struct div_result {
u64 result_high;
u64 result_low;
};
static inline u64 get_vtb(void)
{
if (cpu_has_feature(CPU_FTR_ARCH_207S))
return mfspr(SPRN_VTB);
return 0;
}
/* Accessor functions for the decrementer register.
* The 4xx doesn't even have a decrementer. I tried to use the
* generic timer interrupt code, which seems OK, with the 4xx PIT
* in auto-reload mode. The problem is PIT stops counting when it
* hits zero. If it would wrap, we could use it just like a decrementer.
*/
static inline u64 get_dec(void)
{
return mfspr(SPRN_DEC);
}
/*
* Note: Book E and 4xx processors differ from other PowerPC processors
* in when the decrementer generates its interrupt: on the 1 to 0
* transition for Book E/4xx, but on the 0 to -1 transition for others.
*/
static inline void set_dec(u64 val)
{
if (IS_ENABLED(CONFIG_BOOKE))
mtspr(SPRN_DEC, val);
else
mtspr(SPRN_DEC, val - 1);
}
static inline unsigned long tb_ticks_since(unsigned long tstamp)
{
return mftb() - tstamp;
}
#define mulhwu(x,y) \
({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
#ifdef CONFIG_PPC64
#define mulhdu(x,y) \
({unsigned long z; asm ("mulhdu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
#else
#define mulhdu(x, y) mul_u64_u64_shr(x, y, 64)
#endif
extern void secondary_cpu_time_init(void);
extern void __init time_init(void);
DECLARE_PER_CPU(u64, decrementers_next_tb);
static inline u64 timer_get_next_tb(void)
{
return __this_cpu_read(decrementers_next_tb);
}
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
void timer_rearm_host_dec(u64 now);
#endif
/* Convert timebase ticks to nanoseconds */
unsigned long long tb_to_ns(unsigned long long tb_ticks);
void timer_broadcast_interrupt(void);
/* SPLPAR and VIRT_CPU_ACCOUNTING_NATIVE */
void pseries_accumulate_stolen_time(void);
u64 pseries_calculate_stolen_time(u64 stop_tb);
#endif /* __KERNEL__ */
#endif /* __POWERPC_TIME_H */
Annotation
- Immediate include surface: `linux/types.h`, `linux/percpu.h`, `asm/processor.h`, `asm/cpu_has_feature.h`, `asm/vdso/timebase.h`.
- Detected declarations: `struct div_result`, `function get_vtb`, `function get_dec`, `function set_dec`, `function tb_ticks_since`, `function timer_get_next_tb`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.