XenevaOS
Loading...
Searching...
No Matches
delay.h
Go to the documentation of this file.
1#ifndef __LINUX_DELAY_H__
2#define __LINUX_DELAY_H__
3
4/*
5 * DCL <linux/delay.h> -- this header exists so mainline's
6 * `#include <linux/delay.h>` resolves; the primitives themselves already live
7 * in <linux/kernel.h>:
8 *
9 * #define udelay(us) AA64SleepUS(us)
10 * #define mdelay(ms) AA64SleepMS(ms)
11 * #define msleep(ms) mdelay(ms)
12 *
13 * and both land on the generic timer (KernelAA64/Hal/aa64cpu.c:232). That
14 * matters more than it looks: 8250_port.c waits 1-20us on THRE/RI transitions
15 * inside polling loops (lines 1243, 1988, 2194, 2198), so a millisecond floor
16 * under udelay() would turn wait_for_xmitr() into a ~1000x crawl and put the
17 * "send a byte" path far past its timeout. A real microsecond sleep is the
18 * difference between an 8250 driver that works and one that appears to hang.
19 *
20 * The three variants below are the rest of mainline's set. None of the nine
21 * serial/tty files uses them today; they are here so the next driver that
22 * does does not have to add a header to compile.
23 */
24
25#include <linux/kernel.h> /* udelay, mdelay, msleep */
26
27#define ndelay(ns) udelay(((unsigned long)(ns) + 999UL) / 1000UL)
28
29#define ssleep(sec) mdelay((unsigned long)(sec) * 1000UL)
30
31/*
32 * usleep_range() is a latency hint in mainline: sleeping anywhere between min
33 * and max is correct, and >= min is the contract that matters. DCL honours it
34 * exactly by sleeping min -- the window exists to let a coalescing timer cut
35 * power, and there is no timer wheel to coalesce into.
36 */
37static inline void usleep_range(unsigned long min, unsigned long max) {
38 (void)max;
39 udelay((unsigned int)min);
40}
41
42/*
43 * "Interruptible" only means "may return early on a signal". Nothing here
44 * sleeps on a signal, so it never does -- returning 0 says so honestly rather
45 * than pretending a wait was cut short.
46 */
47static inline unsigned int msleep_interruptible(unsigned int ms) {
48 mdelay(ms);
49 return 0;
50}
51
52#endif /* __LINUX_DELAY_H__ */
#define udelay(us)
Definition kernel.h:134
#define mdelay(ms)
Definition kernel.h:135
#define min(a, b)
Definition minmax.h:24
#define max(a, b)
Definition minmax.h:28