Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/wscons wsdisplay(4): Make most of struct vcons_data ...
details: https://anonhg.NetBSD.org/src/rev/7cd2b6fe158a
branches: trunk
changeset: 368547:7cd2b6fe158a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Jul 17 20:23:17 2022 +0000
description:
wsdisplay(4): Make most of struct vcons_data private.
More importantly, make sizeof(struct vcons_data) independent of
whether VCONS_DRAW_INTR &c. is defined.
Allocate the private space with kmem rather than in the caller.
This still doesn't have very good separation between interface
parameters and internal state, but it's better than before, and is
necessary to make genfb usable in modules.
In arm_simplefb.c, this removes use of the use_intr member. That
assignment became redundant with the introduction of vcons_earlyinit,
so there's no need to replace it by anything.
diffstat:
sys/arch/arm/fdt/arm_simplefb.c | 7 +-
sys/dev/wscons/wsdisplay_vcons.c | 327 ++++++++++++++++++++++-------------
sys/dev/wscons/wsdisplay_vconsvar.h | 50 +----
3 files changed, 207 insertions(+), 177 deletions(-)
diffs (truncated from 998 to 300 lines):
diff -r 95cb14a4dd42 -r 7cd2b6fe158a sys/arch/arm/fdt/arm_simplefb.c
--- a/sys/arch/arm/fdt/arm_simplefb.c Sun Jul 17 18:45:48 2022 +0000
+++ b/sys/arch/arm/fdt/arm_simplefb.c Sun Jul 17 20:23:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_simplefb.c,v 1.11 2021/08/30 22:47:24 jmcneill Exp $ */
+/* $NetBSD: arm_simplefb.c,v 1.12 2022/07/17 20:23:17 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include "opt_vcons.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.11 2021/08/30 22:47:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.12 2022/07/17 20:23:17 riastradh Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -281,9 +281,6 @@
vcons_earlyinit(&arm_simplefb_vcons_data, sc, &arm_simplefb_stdscreen,
&arm_simplefb_accessops);
arm_simplefb_vcons_data.init_screen = arm_simplefb_init_screen;
-#ifdef VCONS_DRAW_INTR
- arm_simplefb_vcons_data.use_intr = 0;
-#endif
vcons_init_screen(&arm_simplefb_vcons_data, &arm_simplefb_screen, 1,
&defattr);
arm_simplefb_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
diff -r 95cb14a4dd42 -r 7cd2b6fe158a sys/dev/wscons/wsdisplay_vcons.c
--- a/sys/dev/wscons/wsdisplay_vcons.c Sun Jul 17 18:45:48 2022 +0000
+++ b/sys/dev/wscons/wsdisplay_vcons.c Sun Jul 17 20:23:17 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplay_vcons.c,v 1.62 2022/07/17 11:43:39 riastradh Exp $ */
+/* $NetBSD: wsdisplay_vcons.c,v 1.63 2022/07/17 20:23:17 riastradh Exp $ */
/*-
* Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.62 2022/07/17 11:43:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.63 2022/07/17 20:23:17 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -43,6 +43,7 @@
#include <sys/kthread.h>
#include <sys/tprintf.h>
#include <sys/atomic.h>
+#include <sys/kmem.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@@ -63,6 +64,40 @@
#define DPRINTF if (0) printf
#endif
+struct vcons_data_private {
+ /* accessops */
+ int (*ioctl)(void *, void *, u_long, void *, int, struct lwp *);
+
+ /* rasops */
+ void (*copycols)(void *, int, int, int, int);
+ void (*erasecols)(void *, int, int, int, long);
+ void (*copyrows)(void *, int, int, int);
+ void (*eraserows)(void *, int, int, long);
+ void (*cursor)(void *, int, int, int);
+
+ /* virtual screen management stuff */
+ void (*switch_cb)(void *, int, int);
+ void *switch_cb_arg;
+ struct callout switch_callout;
+ uint32_t switch_pending;
+ LIST_HEAD(, vcons_screen) screens;
+ struct vcons_screen *wanted;
+ const struct wsscreen_descr *currenttype;
+ struct wsscreen_descr *defaulttype;
+ int switch_poll_count;
+
+#ifdef VCONS_DRAW_INTR
+ int cells;
+ long *attrs;
+ uint32_t *chars;
+ int cursor_offset;
+ callout_t intr;
+ int intr_valid;
+ void *intr_softint;
+ int use_intr; /* use intr drawing when non-zero */
+#endif
+};
+
static void vcons_dummy_init_screen(void *, struct vcons_screen *, int,
long *);
@@ -123,13 +158,14 @@
static void vcons_intr(void *);
static void vcons_softintr(void *);
static void vcons_init_thread(void *);
+static void vcons_invalidate_cache(struct vcons_data *);
#endif
static inline bool
vcons_use_intr(const struct vcons_screen *scr)
{
#ifdef VCONS_DRAW_INTR
- return scr->scr_vd->use_intr;
+ return scr->scr_vd->private->use_intr;
#else
return false;
#endif
@@ -149,10 +185,12 @@
struct wsscreen_descr *def, struct wsdisplay_accessops *ao,
int enable_intr)
{
+ struct vcons_data_private *vdp;
/* zero out everything so we can rely on untouched fields being 0 */
memset(vd, 0, sizeof(struct vcons_data));
+ vd->private = vdp = kmem_zalloc(sizeof(*vdp), KM_SLEEP);
vd->cookie = cookie;
vd->init_screen = vcons_dummy_init_screen;
@@ -160,7 +198,7 @@
/* keep a copy of the accessops that we replace below with our
* own wrappers */
- vd->ioctl = ao->ioctl;
+ vdp->ioctl = ao->ioctl;
/* configure the accessops */
ao->ioctl = vcons_ioctl;
@@ -172,18 +210,18 @@
ao->scroll = vcons_scroll;
#endif
- LIST_INIT(&vd->screens);
+ LIST_INIT(&vdp->screens);
vd->active = NULL;
- vd->wanted = NULL;
- vd->currenttype = def;
- vd->defaulttype = def;
- callout_init(&vd->switch_callout, 0);
- callout_setfunc(&vd->switch_callout, vcons_do_switch, vd);
+ vdp->wanted = NULL;
+ vdp->currenttype = def;
+ vdp->defaulttype = def;
+ callout_init(&vdp->switch_callout, 0);
+ callout_setfunc(&vdp->switch_callout, vcons_do_switch, vd);
#ifdef VCONS_DRAW_INTR
- vd->cells = 0;
- vd->attrs = NULL;
- vd->chars = NULL;
- vd->cursor_offset = -1;
+ vdp->cells = 0;
+ vdp->attrs = NULL;
+ vdp->chars = NULL;
+ vdp->cursor_offset = -1;
#endif
/*
@@ -192,15 +230,15 @@
* operation in progress
*/
#ifdef DIAGNOSTIC
- vd->switch_poll_count = 0;
+ vdp->switch_poll_count = 0;
#endif
#ifdef VCONS_DRAW_INTR
if (enable_intr) {
- vd->intr_softint = softint_establish(SOFTINT_SERIAL,
+ vdp->intr_softint = softint_establish(SOFTINT_SERIAL,
vcons_softintr, vd);
- callout_init(&vd->intr, CALLOUT_MPSAFE);
- callout_setfunc(&vd->intr, vcons_intr, vd);
- vd->intr_valid = 1;
+ callout_init(&vdp->intr, CALLOUT_MPSAFE);
+ callout_setfunc(&vdp->intr, vcons_intr, vd);
+ vdp->intr_valid = 1;
if (kthread_create(PRI_NONE, 0, NULL, vcons_init_thread, vd,
NULL, "vcons_init") != 0) {
@@ -275,6 +313,7 @@
struct rasops_info *ri = &scr->scr_ri;
int cnt, i;
#ifdef VCONS_DRAW_INTR
+ struct vcons_data_private *vdp = vd->private;
int size;
#endif
@@ -314,13 +353,13 @@
#ifdef VCONS_DRAW_INTR
size = ri->ri_cols * ri->ri_rows;
- if (size > vd->cells) {
- if (vd->chars != NULL) free(vd->chars, M_DEVBUF);
- if (vd->attrs != NULL) free(vd->attrs, M_DEVBUF);
- vd->cells = size;
- vd->chars = malloc(size * sizeof(uint32_t), M_DEVBUF,
+ if (size > vdp->cells) {
+ if (vdp->chars != NULL) free(vdp->chars, M_DEVBUF);
+ if (vdp->attrs != NULL) free(vdp->attrs, M_DEVBUF);
+ vdp->cells = size;
+ vdp->chars = malloc(size * sizeof(uint32_t), M_DEVBUF,
M_WAITOK|M_ZERO);
- vd->attrs = malloc(size * sizeof(long), M_DEVBUF,
+ vdp->attrs = malloc(size * sizeof(long), M_DEVBUF,
M_WAITOK|M_ZERO);
vcons_invalidate_cache(vd);
} else if (SCREEN_IS_VISIBLE(scr))
@@ -333,6 +372,7 @@
vcons_init_screen(struct vcons_data *vd, struct vcons_screen *scr,
int existing, long *defattr)
{
+ struct vcons_data_private *vdp = vd->private;
struct rasops_info *ri = &scr->scr_ri;
int i;
@@ -341,7 +381,7 @@
scr->scr_busy = 0;
if (scr->scr_type == NULL)
- scr->scr_type = vd->defaulttype;
+ scr->scr_type = vdp->defaulttype;
/*
* call the driver-supplied init_screen function which is expected
@@ -353,26 +393,26 @@
* save the non virtual console aware rasops and replace them with
* our wrappers
*/
- vd->eraserows = ri->ri_ops.eraserows;
- vd->erasecols = ri->ri_ops.erasecols;
+ vdp->eraserows = ri->ri_ops.eraserows;
+ vdp->erasecols = ri->ri_ops.erasecols;
scr->putchar = ri->ri_ops.putchar;
if (scr->scr_flags & VCONS_NO_COPYCOLS) {
- vd->copycols = vcons_copycols_noread;
+ vdp->copycols = vcons_copycols_noread;
} else {
- vd->copycols = ri->ri_ops.copycols;
+ vdp->copycols = ri->ri_ops.copycols;
}
if (scr->scr_flags & VCONS_NO_COPYROWS) {
- vd->copyrows = vcons_copyrows_noread;
+ vdp->copyrows = vcons_copyrows_noread;
} else {
- vd->copyrows = ri->ri_ops.copyrows;
+ vdp->copyrows = ri->ri_ops.copyrows;
}
if (scr->scr_flags & VCONS_NO_CURSOR) {
- vd->cursor = vcons_cursor_noread;
+ vdp->cursor = vcons_cursor_noread;
} else {
- vd->cursor = ri->ri_ops.cursor;
+ vdp->cursor = ri->ri_ops.cursor;
}
ri->ri_ops.eraserows = vcons_eraserows;
@@ -396,7 +436,7 @@
vcons_alloc_buffers(vd, scr);
- if(vd->active == NULL) {
+ if (vd->active == NULL) {
vd->active = scr;
SCREEN_VISIBLE(scr);
}
@@ -408,7 +448,7 @@
SCREEN_INVISIBLE(scr);
}
- LIST_INSERT_HEAD(&vd->screens, scr, next);
+ LIST_INSERT_HEAD(&vdp->screens, scr, next);
return 0;
}
@@ -416,6 +456,7 @@
vcons_load_font(void *v, void *cookie, struct wsdisplay_font *f)
{
struct vcons_data *vd = v;
+ struct vcons_data_private *vdp = vd->private;
struct vcons_screen *scr = cookie;
struct rasops_info *ri;
struct wsdisplay_font *font;
@@ -447,11 +488,11 @@
/* ok, we got a font. Now clear the screen with the old parameters */
if (SCREEN_IS_VISIBLE(scr))
- vd->eraserows(ri, 0, ri->ri_rows, scr->scr_defattr);
+ vdp->eraserows(ri, 0, ri->ri_rows, scr->scr_defattr);
vcons_lock(vd->active);
#ifdef VCONS_DRAW_INTR
- callout_halt(&vd->intr, NULL);
+ callout_halt(&vdp->intr, NULL);
Home |
Main Index |
Thread Index |
Old Index