diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-10-03 19:12:29 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-10-03 19:12:29 +0000 |
| commit | 2d9449bb49d2b63993e56d3c3cf4ad92fd41a329 (patch) | |
| tree | db28adcac3b265cab4acd1eccfe8bc85d4f8173e /sys | |
| parent | 02bddf7da46380295c0a2a92dd7f8194b75e41c4 (diff) | |
cons(9): New function cn_set_tab.
Increment of progress toward eliminating bare access to cn_tab so we
can make more things MP-safe without the kernel lock (and maybe some
day better formalize console detection and switching).
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/cons.c | 20 | ||||
| -rw-r--r-- | sys/dev/cons.h | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/sys/dev/cons.c b/sys/dev/cons.c index eef38cbbc51..5763736654b 100644 --- a/sys/dev/cons.c +++ b/sys/dev/cons.c @@ -1,4 +1,4 @@ -/* $NetBSD: cons.c,v 1.79 2022/08/22 00:20:56 riastradh Exp $ */ +/* $NetBSD: cons.c,v 1.80 2022/10/03 19:12:29 riastradh Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.79 2022/08/22 00:20:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.80 2022/10/03 19:12:29 riastradh Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -87,6 +87,22 @@ struct tty *constty = NULL; /* virtual console output device */ struct consdev *cn_tab; /* physical console device info */ struct vnode *cn_devvp[2]; /* vnode for underlying device. */ +void +cn_set_tab(struct consdev *tab) +{ + + /* + * This is a point that we should have KASSERT(cold) or add + * synchronization in case this can happen after cold boot. + * However, cn_tab initialization is so critical to any + * diagnostics or debugging that we need to tread carefully + * about introducing new ways to crash. So let's put the + * assertion in only after we've audited most or all of the + * cn_tab updates. + */ + cn_tab = tab; +} + int cnopen(dev_t dev, int flag, int mode, struct lwp *l) { diff --git a/sys/dev/cons.h b/sys/dev/cons.h index 7ccdc5d6e74..9fed7cb0eb0 100644 --- a/sys/dev/cons.h +++ b/sys/dev/cons.h @@ -1,4 +1,4 @@ -/* $NetBSD: cons.h,v 1.28 2022/08/28 09:52:43 riastradh Exp $ */ +/* $NetBSD: cons.h,v 1.29 2022/10/03 19:12:29 riastradh Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -76,6 +76,8 @@ struct consdev { extern struct consdev constab[]; extern struct consdev *cn_tab; +void cn_set_tab(struct consdev *); + void cninit(void); int cngetc(void); int cngetsn(char *, int); |
