svn commit: r259777 - in head/sys: dev/fb dev/vt dev/vt/hw/fb kern sys
Aleksandr Rybalko
ray at FreeBSD.org
Mon Dec 23 18:09:12 UTC 2013
Author: ray
Date: Mon Dec 23 18:09:10 2013
New Revision: 259777
URL: http://svnweb.freebsd.org/changeset/base/259777
Log:
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
Modified:
head/sys/dev/fb/fbd.c
head/sys/dev/vt/hw/fb/vt_fb.c
head/sys/dev/vt/vt.h
head/sys/dev/vt/vt_consolectl.c
head/sys/dev/vt/vt_core.c
head/sys/dev/vt/vt_sysmouse.c
head/sys/kern/subr_terminal.c
head/sys/sys/fbio.h
head/sys/sys/terminal.h
Modified: head/sys/dev/fb/fbd.c
==============================================================================
--- head/sys/dev/fb/fbd.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/fb/fbd.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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
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);
}
Modified: head/sys/dev/vt/hw/fb/vt_fb.c
==============================================================================
--- head/sys/dev/vt/hw/fb/vt_fb.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/vt/hw/fb/vt_fb.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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)
{
Modified: head/sys/dev/vt/vt.h
==============================================================================
--- head/sys/dev/vt/vt.h Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/vt/vt.h Mon Dec 23 18:09:10 2013 (r259777)
@@ -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_de
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;
Modified: head/sys/dev/vt/vt_consolectl.c
==============================================================================
--- head/sys/dev/vt/vt_consolectl.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/vt/vt_consolectl.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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>
Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/vt/vt_core.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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);
Modified: head/sys/dev/vt/vt_sysmouse.c
==============================================================================
--- head/sys/dev/vt/vt_sysmouse.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/dev/vt/vt_sysmouse.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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>
Modified: head/sys/kern/subr_terminal.c
==============================================================================
--- head/sys/kern/subr_terminal.c Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/kern/subr_terminal.c Mon Dec 23 18:09:10 2013 (r259777)
@@ -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
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.
*/
Modified: head/sys/sys/fbio.h
==============================================================================
--- head/sys/sys/fbio.h Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/sys/fbio.h Mon Dec 23 18:09:10 2013 (r259777)
@@ -125,6 +125,10 @@ typedef void fb_wr1_t(struct fb_info *sc
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;
Modified: head/sys/sys/terminal.h
==============================================================================
--- head/sys/sys/terminal.h Mon Dec 23 17:49:12 2013 (r259776)
+++ head/sys/sys/terminal.h Mon Dec 23 18:09:10 2013 (r259777)
@@ -95,6 +95,8 @@ typedef int tc_cngetc_t(struct terminal
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;
};
More information about the svn-src-all
mailing list