arch/csky/lib/delay.c

Source file repositories/reference/linux-study-clean/arch/csky/lib/delay.c

File Facts

System
Linux kernel
Corpus path
arch/csky/lib/delay.c
Extension
.c
Size
825 bytes
Lines
40
Domain
Architecture Layer
Bucket
arch/csky
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>

void __aligned(8) __delay(unsigned long loops)
{
	asm volatile (
		"mov r0, r0\n"
		"1:declt %0\n"
		"bf	1b"
		: "=r"(loops)
		: "0"(loops));
}
EXPORT_SYMBOL(__delay);

void __const_udelay(unsigned long xloops)
{
	unsigned long long loops;

	loops = (unsigned long long)xloops * loops_per_jiffy * HZ;

	__delay(loops >> 32);
}
EXPORT_SYMBOL(__const_udelay);

void __udelay(unsigned long usecs)
{
	__const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
}
EXPORT_SYMBOL(__udelay);

void __ndelay(unsigned long nsecs)
{
	__const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
}
EXPORT_SYMBOL(__ndelay);

Annotation

Implementation Notes