Index: sys/dev/fb/fbd.c =================================================================== --- sys/dev/fb/fbd.c (revision 259726) +++ sys/dev/fb/fbd.c (working copy) @@ -255,8 +255,12 @@ 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 @@ } else return (ENXIO); + if (info->fb_ioctl == NULL) + info->fb_ioctl = &fb_ioctl; + + return (0); } @@ -277,6 +285,7 @@ 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); } Index: sys/dev/vt/hw/fb/vt_fb.c =================================================================== --- sys/dev/vt/hw/fb/vt_fb.c (revision 259726) +++ sys/dev/vt/hw/fb/vt_fb.c (working copy) @@ -41,6 +41,11 @@ #include #include +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, @@ -47,8 +52,36 @@ .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) { Index: sys/dev/vt/vt.h =================================================================== --- sys/dev/vt/vt.h (revision 259726) +++ sys/dev/vt/vt.h (working copy) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -282,6 +283,9 @@ 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 @@ 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; Index: sys/dev/vt/vt_consolectl.c =================================================================== --- sys/dev/vt/vt_consolectl.c (revision 259726) +++ sys/dev/vt/vt_consolectl.c (working copy) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include Index: sys/dev/vt/vt_core.c =================================================================== --- sys/dev/vt/vt_core.c (revision 259727) +++ sys/dev/vt/vt_core.c (working copy) @@ -72,6 +72,7 @@ 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 @@ .tc_opened = vtterm_opened, .tc_ioctl = vtterm_ioctl, + .tc_mmap = vtterm_mmap, }; /* @@ -1348,6 +1350,20 @@ #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 @@ 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); Index: sys/dev/vt/vt_sysmouse.c =================================================================== --- sys/dev/vt/vt_sysmouse.c (revision 259726) +++ sys/dev/vt/vt_sysmouse.c (working copy) @@ -35,7 +35,6 @@ #include #include -#include #include #include #include Index: sys/kern/subr_terminal.c =================================================================== --- sys/kern/subr_terminal.c (revision 259726) +++ sys/kern/subr_terminal.c (working copy) @@ -85,6 +85,7 @@ 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, @@ -91,6 +92,7 @@ .tsw_close = termtty_close, .tsw_outwakeup = termtty_outwakeup, .tsw_ioctl = termtty_ioctl, + .tsw_mmap = termtty_mmap, }; /* @@ -409,6 +411,15 @@ 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. */ Index: sys/sys/fbio.h =================================================================== --- sys/sys/fbio.h (revision 259726) +++ sys/sys/fbio.h (working copy) @@ -125,6 +125,10 @@ 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,7 +141,11 @@ /* 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; fb_wr4_t *wr4; Index: sys/sys/terminal.h =================================================================== --- sys/sys/terminal.h (revision 259726) +++ sys/sys/terminal.h (working copy) @@ -95,6 +95,8 @@ 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 @@ /* 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; };