XenevaOS
Loading...
Searching...
No Matches
poll.h
Go to the documentation of this file.
1#ifndef __LINUX_POLL_H__
2#define __LINUX_POLL_H__
3
4/*
5 * DCL <linux/poll.h> -- the epoll bits tty_poll() and n_tty poll through.
6 *
7 * The masks are mainline's values so a byte handed to userspace means the
8 * same thing it would on Linux.
9 *
10 * poll_wait() is a deliberate no-op, and it is worth being explicit about
11 * why: it exists so that the *next* wait (a state change or a timeout) wakes
12 * a blocked select(). DCL has no sleeping scheduler to block in, so a
13 * blocking poll would never wake through this path -- it re-reads state on
14 * the caller's own timeout instead, which is exactly what Xeneva's select
15 * does (it takes a timeout argument). The consequence is honest and local:
16 * select() on a tty with no data waits out its timeout rather than returning
17 * early when a byte arrives mid-wait. Real wake-up registration arrives with
18 * stage 5's wait-queue work.
19 *
20 * Bodies in DCL/linux_irq_shim.c.
21 */
22
23struct file;
24struct wait_queue_head;
26
27#define EPOLLIN 0x00000001
28#define EPOLLPRI 0x00000002
29#define EPOLLOUT 0x00000004
30#define EPOLLERR 0x00000008
31#define EPOLLHUP 0x00000010
32#define EPOLLNVAL 0x00000020
33#define EPOLLRDNORM 0x00000040
34#define EPOLLWRNORM 0x00000100
35#define EPOLLRDHUP 0x00002000
36
37#define POLLIN 0x0001
38#define POLLPRI 0x0002
39#define POLLOUT 0x0004
40#define POLLERR 0x0008
41#define POLLHUP 0x0010
42#define POLLNVAL 0x0020
43
44/*
45 * POLL_OUT / POLL_IN -- the *signal band* half of kill_fasync(), not the
46 * poll(2) event. virtio_console.c:1319 does
47 *
48 * kill_fasync(&port->fasync, SIGIO, POLL_OUT);
49 *
50 * where mainline takes POLL_OUT from <linux/poll.h> (it is the same word as
51 * POLLOUT, 0x0004) and SIGIO from <linux/signal.h>, reached through
52 * <linux/fs.h>. DCL's fs.h is pinned and carries neither, and there is no
53 * <linux/signal.h> in this tree -- so both names live here, beside the
54 * kill_fasync() declaration, because this header is where the file's
55 * notification surface already sits.
56 *
57 * SIGIO is 29, the generic-ABI value arm64 uses (asm-generic/signal.h:30);
58 * SIGRTMIN-style numbering is not in play because nothing raises it. DCL
59 * delivers no signals (signal_pending() is 0, kernel.h), so both names are
60 * ABI shape: kill_fasync() is a no-op and the band is never read.
61 */
62#define POLL_IN 0x0001
63#define POLL_OUT 0x0004
64#define SIGIO 29
65
66#define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM)
67
68void poll_wait(struct file* file, struct wait_queue_head* wait_address,
69 poll_table* p);
70
71/*
72 * fasync_helper() and kill_fasync() -- the two fcntl.c entry points the
73 * driver's .fasync fops and its notify paths call:
74 *
75 * .fasync = virtio_console_fasync -> fasync_helper(fd, filp, on,
76 * &port->fasync) :1079
77 * kill_fasync(&port->fasync, SIGIO, POLL_OUT) :1319
78 *
79 * mainline declares both in <linux/fs.h>, which is the one header DCL does
80 * not touch, and neither belongs in <linux/poll.h> upstream -- but POLL_IN /
81 * POLL_OUT and SIGIO above are already here for the kill_fasync() call, and
82 * this header is where the file's notification surface sits in DCL. Keeping
83 * the three together beats scattering them: a call site has to see the band,
84 * the signal and the function that takes them, and it reaches this header
85 * whether or not it can reach fs.h.
86 *
87 * `struct fasync_struct` is complete in mainline's fs.h; here it is only ever
88 * named behind a `&port->fasync` and passed on, so a forward declaration is
89 * the whole of its type a caller can use -- port->fasync itself is a member
90 * of a struct the driver declares in mainline's shape, where the member is a
91 * pointer.
92 *
93 * Bodies in DCL/linux_cdev_shim.c. fasync_helper() returns 0, which is what
94 * it returns when the entry was inserted or removed cleanly; DCL delivers no
95 * signals (SIGIO is defined above as ABI shape), so nothing can observe the
96 * difference between a registered fasync and an unregistered one. That is
97 * not a stub pretending to work -- it is the correct answer for a kernel with
98 * no signal delivery, and kill_fasync() being a no-op is its necessary
99 * corollary.
100 */
101struct fasync_struct;
102
103int fasync_helper(int fd, struct file* filp, int on,
104 struct fasync_struct** fapp);
105void kill_fasync(struct fasync_struct** fp, int sig, int band);
106
107#endif /* __LINUX_POLL_H__ */
void kill_fasync(struct fasync_struct **fp, int sig, int band)
int fasync_helper(int fd, struct file *filp, int on, struct fasync_struct **fapp)
void poll_wait(struct file *file, struct wait_queue_head *wait_address, poll_table *p)
Definition file.h:140
Definition fs.h:142
Definition fs.h:52
Definition wait.h:75