arch/mips/cavium-octeon/csrc-octeon.c
Source file repositories/reference/linux-study-clean/arch/mips/cavium-octeon/csrc-octeon.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/cavium-octeon/csrc-octeon.c- Extension
.c- Size
- 4983 bytes
- Lines
- 215
- 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/clocksource.hlinux/sched/clock.hlinux/export.hlinux/init.hlinux/smp.hasm/cpu-info.hasm/cpu-type.hasm/time.hasm/octeon/octeon.hasm/octeon/cvmx-ipd-defs.hasm/octeon/cvmx-mio-defs.hasm/octeon/cvmx-rst-defs.hasm/octeon/cvmx-fpa-defs.h
Detected Declarations
function octeon_setup_delaysfunction octeon_init_cvmcountfunction octeon_cvmcount_readfunction sched_clockfunction plat_time_initfunction __udelayfunction __ndelayfunction __delayfunction octeon_io_clk_delayexport __udelayexport __ndelayexport __delayexport octeon_io_clk_delay
Annotated Snippet
if (rdiv != 0) {
clk_count *= rdiv;
if (f != 0) {
asm("dmultu\t%[cnt],%[f]\n\t"
"mfhi\t%[cnt]"
: [cnt] "+r" (clk_count)
: [f] "r" (f)
: "hi", "lo");
}
}
write_c0_cvmcount(clk_count);
}
local_irq_restore(flags);
}
static u64 octeon_cvmcount_read(struct clocksource *cs)
{
return read_c0_cvmcount();
}
static struct clocksource clocksource_mips = {
.name = "OCTEON_CVMCOUNT",
.read = octeon_cvmcount_read,
.mask = CLOCKSOURCE_MASK(64),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
unsigned long long notrace sched_clock(void)
{
/* 64-bit arithmetic can overflow, so use 128-bit. */
u64 t1, t2, t3;
unsigned long long rv;
u64 mult = clocksource_mips.mult;
u64 shift = clocksource_mips.shift;
u64 cnt = read_c0_cvmcount();
asm (
"dmultu\t%[cnt],%[mult]\n\t"
"nor\t%[t1],$0,%[shift]\n\t"
"mfhi\t%[t2]\n\t"
"mflo\t%[t3]\n\t"
"dsll\t%[t2],%[t2],1\n\t"
"dsrlv\t%[rv],%[t3],%[shift]\n\t"
"dsllv\t%[t1],%[t2],%[t1]\n\t"
"or\t%[rv],%[t1],%[rv]\n\t"
: [rv] "=&r" (rv), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3)
: [cnt] "r" (cnt), [mult] "r" (mult), [shift] "r" (shift)
: "hi", "lo");
return rv;
}
void __init plat_time_init(void)
{
clocksource_mips.rating = 300;
clocksource_register_hz(&clocksource_mips, octeon_get_clock_rate());
}
void __udelay(unsigned long us)
{
u64 cur, end, inc;
cur = read_c0_cvmcount();
inc = us * octeon_udelay_factor;
end = cur + inc;
while (end > cur)
cur = read_c0_cvmcount();
}
EXPORT_SYMBOL(__udelay);
void __ndelay(unsigned long ns)
{
u64 cur, end, inc;
cur = read_c0_cvmcount();
inc = ((ns * octeon_ndelay_factor) >> 16);
end = cur + inc;
while (end > cur)
cur = read_c0_cvmcount();
}
EXPORT_SYMBOL(__ndelay);
void __delay(unsigned long loops)
{
u64 cur, end;
cur = read_c0_cvmcount();
Annotation
- Immediate include surface: `linux/clocksource.h`, `linux/sched/clock.h`, `linux/export.h`, `linux/init.h`, `linux/smp.h`, `asm/cpu-info.h`, `asm/cpu-type.h`, `asm/time.h`.
- Detected declarations: `function octeon_setup_delays`, `function octeon_init_cvmcount`, `function octeon_cvmcount_read`, `function sched_clock`, `function plat_time_init`, `function __udelay`, `function __ndelay`, `function __delay`, `function octeon_io_clk_delay`, `export __udelay`.
- 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.