arch/mips/mti-malta/malta-time.c
Source file repositories/reference/linux-study-clean/arch/mips/mti-malta/malta-time.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/mti-malta/malta-time.c- Extension
.c- Size
- 5846 bytes
- Lines
- 254
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/i8253.hlinux/init.hlinux/kernel_stat.hlinux/libfdt.hlinux/math64.hlinux/sched.hlinux/spinlock.hlinux/interrupt.hlinux/timex.hlinux/mc146818rtc.hasm/cpu.hasm/mipsregs.hasm/mipsmtregs.hasm/hardirq.hasm/irq.hasm/div64.hasm/setup.hasm/time.hasm/mc146818-time.hasm/msc01_ic.hasm/mips-cps.hasm/mips-boards/generic.hasm/mips-boards/maltaint.h
Detected Declarations
function mips_timer_dispatchfunction mips_perf_dispatchfunction freqroundfunction estimate_frequenciesfunction read_persistent_clock64function get_c0_fdc_intfunction get_c0_perfcount_intfunction get_c0_compare_intfunction init_rtcfunction update_gic_frequency_dtfunction plat_time_initexport get_c0_perfcount_int
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Carsten Langgaard, carstenl@mips.com
* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
*
* Setting up the clock on the MIPS boards.
*/
#include <linux/types.h>
#include <linux/i8253.h>
#include <linux/init.h>
#include <linux/kernel_stat.h>
#include <linux/libfdt.h>
#include <linux/math64.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/timex.h>
#include <linux/mc146818rtc.h>
#include <asm/cpu.h>
#include <asm/mipsregs.h>
#include <asm/mipsmtregs.h>
#include <asm/hardirq.h>
#include <asm/irq.h>
#include <asm/div64.h>
#include <asm/setup.h>
#include <asm/time.h>
#include <asm/mc146818-time.h>
#include <asm/msc01_ic.h>
#include <asm/mips-cps.h>
#include <asm/mips-boards/generic.h>
#include <asm/mips-boards/maltaint.h>
static int mips_cpu_timer_irq;
static int mips_cpu_perf_irq;
extern int cp0_perfcount_irq;
static unsigned int gic_frequency;
static void mips_timer_dispatch(void)
{
do_IRQ(mips_cpu_timer_irq);
}
static void mips_perf_dispatch(void)
{
do_IRQ(mips_cpu_perf_irq);
}
static unsigned int freqround(unsigned int freq, unsigned int amount)
{
freq += amount;
freq -= freq % (amount*2);
return freq;
}
/*
* Estimate CPU and GIC frequencies.
*/
static void __init estimate_frequencies(void)
{
unsigned long flags;
unsigned int count, start;
unsigned char secs1, secs2, ctrl;
int secs;
u64 giccount = 0, gicstart = 0;
local_irq_save(flags);
if (mips_gic_present())
clear_gic_config(GIC_CONFIG_COUNTSTOP);
/*
* Read counters exactly on rising edge of update flag.
* This helps get an accurate reading under virtualisation.
*/
while (CMOS_READ(RTC_REG_A) & RTC_UIP);
while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
start = read_c0_count();
if (mips_gic_present())
gicstart = read_gic_counter();
/* Wait for falling edge before reading RTC. */
while (CMOS_READ(RTC_REG_A) & RTC_UIP);
secs1 = CMOS_READ(RTC_SECONDS);
/* Read counters again exactly on rising edge of update flag. */
while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
count = read_c0_count();
Annotation
- Immediate include surface: `linux/types.h`, `linux/i8253.h`, `linux/init.h`, `linux/kernel_stat.h`, `linux/libfdt.h`, `linux/math64.h`, `linux/sched.h`, `linux/spinlock.h`.
- Detected declarations: `function mips_timer_dispatch`, `function mips_perf_dispatch`, `function freqround`, `function estimate_frequencies`, `function read_persistent_clock64`, `function get_c0_fdc_int`, `function get_c0_perfcount_int`, `function get_c0_compare_int`, `function init_rtc`, `function update_gic_frequency_dt`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration 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.