XenevaOS
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1#ifndef __LINUX_CONSOLE_H__
2#define __LINUX_CONSOLE_H__
3
4/*
5 * DCL <linux/console.h> -- the console registration surface serial_core and
6 * 8250 use.
7 *
8 * The load-bearing decision here: register_console() records a console so
9 * that console_is_registered() answers true and callers stop asking -- but it
10 * does *not* hand the UART over. Xeneva's boot log is written to the same
11 * serial port by UARTDebugOut(), and letting mainline's uart console drive
12 * those registers as well would mean two writers interleaving characters at
13 * register level: a garbled console rather than a working one, and a fault
14 * that would only show up under load. Native output keeps ownership; the
15 * registration API is satisfied because serial_core.c:2574 calls
16 * register_console() and then expects console_is_registered() to be true, and
17 * because uart_add_one_port() returns through it (serial_core.c:2991, :2999).
18 *
19 * console_lock()/console_unlock() are the printk console semaphore. There is
20 * exactly one writer here, so the lock is uncontended by construction -- but
21 * they must exist as calls, because serial_core.c:2530 and tty_io.c:3589 take
22 * them around tty-device lookups, and a missing symbol would take the whole
23 * registration path down.
24 *
25 * console_suspend() is called from uart_suspend_port()/uart_resume_port();
26 * Xeneva has no suspend path, so it is a no-op that keeps the call site
27 * readable rather than sending anyone to find out why the symbol is missing.
28 *
29 * console_suspend_enabled mirrors mainline's default for a kernel without
30 * CONFIG_PM_SLEEP: false. serial_core.c:2319 branches on it -- with false the
31 * suspend path stops RX and returns early, which is the behaviour that makes
32 * sense for a console that is never suspended.
33 */
34
35struct tty_port;
36struct device;
37struct tty_device;
38
39struct console {
40 char name[16];
41 void (*write)(struct console* con, const char* s, unsigned int count);
42 /* tty_io.c:3570 region resolves a console back to its tty through this */
43 struct tty_device* (*device)(struct console* con, int* index);
44 int (*setup)(struct console* con, char* options);
45 int (*exit)(struct console* con);
46 int (*match)(struct console* con, struct device** dev, int idx);
47 void (*cleanup)(struct console* con);
48 void* data;
49 int index;
50 int cflag;
51 unsigned int ispeed;
52 unsigned int ospeed;
53 unsigned int flags;
54};
55
56/* mainline include/linux/console.h flag values */
57#define CON_PRINTBUFFER 0x00000001
58#define CON_CONSDEV 0x00000002
59#define CON_ENABLED 0x00000004
60#define CON_BOOT 0x00000008
61#define CON_ANYTIME 0x00000010
62#define CON_BUILTIN 0x00000020
63#define CON_SUSPENDED 0x00000040
64#define CON_DRIVERBLANK 0x00000080
65#define CON_SYSFS 0x00000100
66/* tty_io.c:3575 tests this to reject atomic consoles. DCL registers no nbcon
67 * console, so the bit only has to exist and not collide with the others. */
68#define CON_NBCON 0x00000200
69
71
72int register_console(struct console* con);
73int unregister_console(struct console* con);
75
76void console_lock(void);
77void console_unlock(void);
78void console_trylock(void);
79void console_suspend(struct console* con);
80
81
82/*
83 * console_is_registered_locked() -- the same answer as
84 * console_is_registered(), taken with the console list lock held.
85 *
86 * mainline splits these because the unlocked one has to take a lock itself,
87 * and calling it while already holding it would deadlock. DCL's
88 * console_lock()/console_unlock() are empty (DCL/linux_irq_shim.c) and the
89 * registry is a plain array scan, so there is no lock to re-enter and no
90 * separate locked path to maintain -- one body, two names, and the reason the
91 * second one does not take a lock is that neither does the first.
92 *
93 * The caller is uart_console_registered_locked() in serial_core.h:1376, which
94 * asks whether the port's console is on the list while already holding the
95 * port lock. Answering the same thing twice under two names is fine;
96 * answering it differently would be the bug.
97 */
98static inline bool console_is_registered_locked(struct console* con)
99{
100 return console_is_registered(con) != 0;
101}
102
103/*
104 * console_resume() -- the other half of console_suspend() above, which this
105 * header already declares. It is called with console_suspend_enabled
106 * already tested (serial_core.c:2419) and its job upstream is to undo the
107 * CON_SUSPENDED/CON_ENABLED bookkeeping suspend() did.
108 *
109 * DCL has no suspend path -- console_suspend() is a body in
110 * DCL/linux_irq_shim.c:570 saying so, next to console_lock() -- so there is
111 * no suspended state to clear, and clearing one would mean writing CON_ENABLED
112 * back on a console that was never taken off. The declaration is here because
113 * mainline's is, the body goes beside console_suspend()'s so the pair stays
114 * readable together, and both agree with the no-op lock functions in the same
115 * shim: mainline's calls are paired, and so are DCL's.
116 */
117void console_resume(struct console* con);
118#endif /* __LINUX_CONSOLE_H__ */
void console_trylock(void)
int console_is_registered(struct console *con)
int register_console(struct console *con)
void console_resume(struct console *con)
int console_suspend_enabled
void console_lock(void)
void console_suspend(struct console *con)
int unregister_console(struct console *con)
void console_unlock(void)
const struct device * dev
Definition drm_print.h:519
@ options
Definition m_menu.c:234
Definition console.h:39
int(* exit)(struct console *con)
Definition console.h:45
int(* setup)(struct console *con, char *options)
Definition console.h:44
void(* write)(struct console *con, const char *s, unsigned int count)
Definition console.h:41
unsigned int flags
Definition console.h:53
void * data
Definition console.h:48
int(* match)(struct console *con, struct device **dev, int idx)
Definition console.h:46
char name[16]
Definition console.h:40
int index
Definition console.h:49
void(* cleanup)(struct console *con)
Definition console.h:47
unsigned int ispeed
Definition console.h:51
unsigned int ospeed
Definition console.h:52
int cflag
Definition console.h:50
Definition fs.h:255
Definition tty_port.h:79