aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr Rybalko <ray@FreeBSD.org>2013-12-23 18:09:10 +0000
committerAleksandr Rybalko <ray@FreeBSD.org>2013-12-23 18:09:10 +0000
commit7a1a32c4ef277b98b9164496091f7d50f203fb81 (patch)
tree8096d9fdebc1dab4523716b5f83ba8d7bb6ff9ec
parentddc31191a463cda5957cb5b2bf606738c074576a (diff)
downloadsrc-7a1a32c4ef277b98b9164496091f7d50f203fb81.tar.gz
src-7a1a32c4ef277b98b9164496091f7d50f203fb81.zip
o Add virtual terminal mmap request handler.
o Forward termianl framebuffer ioctl to fbd. o Forward terminal mmap request to fbd. o Move inclusion of sys/conf.h to vt.h. Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=259777
-rw-r--r--sys/dev/fb/fbd.c11
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.c33
-rw-r--r--sys/dev/vt/vt.h10
-rw-r--r--sys/dev/vt/vt_consolectl.c1
-rw-r--r--sys/dev/vt/vt_core.c24
-rw-r--r--sys/dev/vt/vt_sysmouse.c1
-rw-r--r--sys/kern/subr_terminal.c11
-rw-r--r--sys/sys/fbio.h8
-rw-r--r--sys/sys/terminal.h5
9 files changed, 100 insertions, 4 deletions
diff --git a/sys/dev/fb/fbd.c b/sys/dev/fb/fbd.c
index 4fbf5eeb7fae..b75ca33516c4 100644
--- a/sys/dev/fb/fbd.c
+++ b/sys/dev/fb/fbd.c
@@ -255,8 +255,12 @@ fb_probe(struct fb_info *info)
info->wr4 = &vt_fb_indir_wr4;
info->copy = &vt_fb_indir_copy;
} else if (info->fb_vbase != 0) {
- if (info->fb_pbase == 0)
+ if (info->fb_pbase == 0) {
info->fb_flags |= FB_FLAG_NOMMAP;
+ } else {
+ if (info->fb_mmap == NULL)
+ info->fb_mmap = &fb_mmap;
+ }
info->wr1 = &vt_fb_mem_wr1;
info->wr2 = &vt_fb_mem_wr2;
info->wr4 = &vt_fb_mem_wr4;
@@ -264,6 +268,10 @@ fb_probe(struct fb_info *info)
} else
return (ENXIO);
+ if (info->fb_ioctl == NULL)
+ info->fb_ioctl = &fb_ioctl;
+
+
return (0);
}
@@ -277,6 +285,7 @@ fb_init(struct fb_list_entry *entry, int unit)
entry->fb_si = make_dev(&fb_cdevsw, unit, UID_ROOT, GID_WHEEL,
0600, "fb%d", unit);
entry->fb_si->si_drv1 = info;
+ info->fb_cdev = entry->fb_si;
return (0);
}
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index f1b673cda271..261d72b05076 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -41,14 +41,47 @@ __FBSDID("$FreeBSD$");
#include <dev/vt/hw/fb/vt_fb.h>
#include <dev/vt/colors/vt_termcolors.h>
+static int vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data,
+ struct thread *td);
+static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset,
+ vm_paddr_t *paddr, int prot, vm_memattr_t *memattr);
+
static struct vt_driver vt_fb_driver = {
.vd_init = vt_fb_init,
.vd_blank = vt_fb_blank,
.vd_bitbltchr = vt_fb_bitbltchr,
.vd_postswitch = vt_fb_postswitch,
.vd_priority = VD_PRIORITY_GENERIC+10,
+ .vd_fb_ioctl = vt_fb_ioctl,
+ .vd_fb_mmap = vt_fb_mmap,
};
+static int
+vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread *td)
+{
+ struct fb_info *info;
+
+ info = vd->vd_softc;
+
+ if (info->fb_ioctl == NULL)
+ return (-1);
+
+ return (info->fb_ioctl(info->fb_cdev, cmd, data, 0, td));
+}
+
+static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset,
+ vm_paddr_t *paddr, int prot, vm_memattr_t *memattr)
+{
+ struct fb_info *info;
+
+ info = vd->vd_softc;
+
+ if (info->fb_ioctl == NULL)
+ return (ENXIO);
+
+ return (info->fb_mmap(info->fb_cdev, offset, paddr, prot, memattr));
+}
+
void
vt_fb_blank(struct vt_device *vd, term_color_t color)
{
diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index 9c1eb1ef5ceb..1bfd82117061 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -40,6 +40,7 @@
#include <sys/_mutex.h>
#include <sys/callout.h>
#include <sys/condvar.h>
+#include <sys/conf.h>
#include <sys/consio.h>
#include <sys/kbio.h>
#include <sys/mouse.h>
@@ -282,6 +283,9 @@ typedef void vd_bitbltchr_t(struct vt_device *vd, const uint8_t *src,
unsigned int width, unsigned int height, term_color_t fg, term_color_t bg);
typedef void vd_putchar_t(struct vt_device *vd, term_char_t,
vt_axis_t top, vt_axis_t left, term_color_t fg, term_color_t bg);
+typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
+typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
+ vm_memattr_t *);
struct vt_driver {
/* Console attachment. */
@@ -291,6 +295,12 @@ struct vt_driver {
vd_blank_t *vd_blank;
vd_bitbltchr_t *vd_bitbltchr;
+ /* Framebuffer ioctls, if present. */
+ vd_fb_ioctl_t *vd_fb_ioctl;
+
+ /* Framebuffer mmap, if present. */
+ vd_fb_mmap_t *vd_fb_mmap;
+
/* Text mode operation. */
vd_putchar_t *vd_putchar;
diff --git a/sys/dev/vt/vt_consolectl.c b/sys/dev/vt/vt_consolectl.c
index c4180a18f7b5..f9c451780fc7 100644
--- a/sys/dev/vt/vt_consolectl.c
+++ b/sys/dev/vt/vt_consolectl.c
@@ -31,7 +31,6 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
-#include <sys/conf.h>
#include <sys/consio.h>
#include <sys/kernel.h>
#include <sys/systm.h>
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index bc4188d99dc9..5734cc6fb7f2 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -72,6 +72,7 @@ static tc_cngetc_t vtterm_cngetc;
static tc_opened_t vtterm_opened;
static tc_ioctl_t vtterm_ioctl;
+static tc_mmap_t vtterm_mmap;
const struct terminal_class vt_termclass = {
.tc_bell = vtterm_bell,
@@ -87,6 +88,7 @@ const struct terminal_class vt_termclass = {
.tc_opened = vtterm_opened,
.tc_ioctl = vtterm_ioctl,
+ .tc_mmap = vtterm_mmap,
};
/*
@@ -1348,6 +1350,20 @@ vt_mouse_state(int show)
#endif
static int
+vtterm_mmap(struct terminal *tm, vm_ooffset_t offset, vm_paddr_t * paddr,
+ int nprot, vm_memattr_t *memattr)
+{
+ struct vt_window *vw = tm->tm_softc;
+ struct vt_device *vd = vw->vw_device;
+
+ if (vd->vd_driver->vd_fb_mmap)
+ return (vd->vd_driver->vd_fb_mmap(vd, offset, paddr, nprot,
+ memattr));
+
+ return (ENXIO);
+}
+
+static int
vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data,
struct thread *td)
{
@@ -1474,6 +1490,14 @@ skip_thunk:
return (EINVAL);
}
}
+ case FBIOGTYPE:
+ case FBIO_GETWINORG: /* get frame buffer window origin */
+ case FBIO_GETDISPSTART: /* get display start address */
+ case FBIO_GETLINEWIDTH: /* get scan line width in bytes */
+ case FBIO_BLANK: /* blank display */
+ if (vd->vd_driver->vd_fb_ioctl)
+ return (vd->vd_driver->vd_fb_ioctl(vd, cmd, data, td));
+ break;
case CONS_BLANKTIME:
/* XXX */
return (0);
diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c
index 42fc5aa58e6c..73ef39d735f2 100644
--- a/sys/dev/vt/vt_sysmouse.c
+++ b/sys/dev/vt/vt_sysmouse.c
@@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/condvar.h>
-#include <sys/conf.h>
#include <sys/consio.h>
#include <sys/fcntl.h>
#include <sys/filio.h>
diff --git a/sys/kern/subr_terminal.c b/sys/kern/subr_terminal.c
index 54636e408c29..b30c9c075fa5 100644
--- a/sys/kern/subr_terminal.c
+++ b/sys/kern/subr_terminal.c
@@ -85,12 +85,14 @@ static tsw_open_t termtty_open;
static tsw_close_t termtty_close;
static tsw_outwakeup_t termtty_outwakeup;
static tsw_ioctl_t termtty_ioctl;
+static tsw_mmap_t termtty_mmap;
static struct ttydevsw terminal_tty_class = {
.tsw_open = termtty_open,
.tsw_close = termtty_close,
.tsw_outwakeup = termtty_outwakeup,
.tsw_ioctl = termtty_ioctl,
+ .tsw_mmap = termtty_mmap,
};
/*
@@ -409,6 +411,15 @@ termtty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
return (error);
}
+static int
+termtty_mmap(struct tty *tp, vm_ooffset_t offset, vm_paddr_t * paddr,
+ int nprot, vm_memattr_t *memattr)
+{
+ struct terminal *tm = tty_softc(tp);
+
+ return (tm->tm_class->tc_mmap(tm, offset, paddr, nprot, memattr));
+}
+
/*
* Binding with the kernel and debug console.
*/
diff --git a/sys/sys/fbio.h b/sys/sys/fbio.h
index fe941a2263cb..160eb7a6145b 100644
--- a/sys/sys/fbio.h
+++ b/sys/sys/fbio.h
@@ -125,6 +125,10 @@ typedef void fb_wr1_t(struct fb_info *sc, uint32_t offset, uint8_t value);
typedef void fb_wr2_t(struct fb_info *sc, uint32_t offset, uint16_t value);
typedef void fb_wr4_t(struct fb_info *sc, uint32_t offset, uint32_t value);
+typedef int fb_ioctl_t(struct cdev *, u_long, caddr_t, int, struct thread *);
+typedef int fb_mmap_t(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
+ int prot, vm_memattr_t *memattr);
+
struct fb_info {
/* Raw copy of fbtype. Do not change. */
int fb_type; /* as defined above */
@@ -137,6 +141,10 @@ struct fb_info {
/* Methods. */
fb_write_t *fb_write; /* if NULL, direct mem write. */
fb_read_t *fb_read; /* if NULL, direct mem read. */
+ fb_ioctl_t *fb_ioctl; /* Can be NULL. */
+ fb_mmap_t *fb_mmap; /* Can be NULL. */
+
+ struct cdev *fb_cdev;
fb_wr1_t *wr1;
fb_wr2_t *wr2;
diff --git a/sys/sys/terminal.h b/sys/sys/terminal.h
index e76190b500a5..1809c0ac941c 100644
--- a/sys/sys/terminal.h
+++ b/sys/sys/terminal.h
@@ -95,6 +95,8 @@ typedef int tc_cngetc_t(struct terminal *tm);
typedef void tc_opened_t(struct terminal *tm, int opened);
typedef int tc_ioctl_t(struct terminal *tm, u_long cmd, caddr_t data,
struct thread *td);
+typedef int tc_mmap_t(struct terminal *tm, vm_ooffset_t offset,
+ vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr);
typedef void tc_bell_t(struct terminal *tm);
struct terminal_class {
@@ -109,10 +111,11 @@ struct terminal_class {
/* Low-level console interface. */
tc_cnprobe_t *tc_cnprobe;
tc_cngetc_t *tc_cngetc;
-
+
/* Misc. */
tc_opened_t *tc_opened;
tc_ioctl_t *tc_ioctl;
+ tc_mmap_t *tc_mmap;
tc_bell_t *tc_bell;
};