summaryrefslogtreecommitdiffstats
path: root/sys/dev/vt
diff options
context:
space:
mode:
authorroyger <royger@FreeBSD.org>2014-12-22 16:46:07 +0000
committerroyger <royger@FreeBSD.org>2014-12-22 16:46:07 +0000
commit52c278b4627b92fae99c73ae740be3edb343dc4c (patch)
treee8412de71fe7b61e5bafbb180a3076b05bb0c353 /sys/dev/vt
parentd9885d34c5bd7d9e0be507b6eb1481ae62af33d8 (diff)
downloadFreeBSD-src-52c278b4627b92fae99c73ae740be3edb343dc4c.zip
FreeBSD-src-52c278b4627b92fae99c73ae740be3edb343dc4c.tar.gz
vt: register the memory regions used by the vt drivers
Current VT drivers don't register the memory regions they use with the nexus. This patch makes vt_vga and vt_efifb register the memory regions they use. This is needed (at least) for Xen support, since the FreeBSD kernel will try to use the holes in the memory map to map memory from other domains and setup it's grant table. Sponsored by: Citrix Systems R&D Reported by: sbruno Tested by: emaste Reviewed by: ray PR: 195537 Differential Revision: https://reviews.freebsd.org/D1291
Diffstat (limited to 'sys/dev/vt')
-rw-r--r--sys/dev/vt/hw/efifb/efifb.c53
-rw-r--r--sys/dev/vt/hw/vga/vt_vga.c55
2 files changed, 108 insertions, 0 deletions
diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c
index 05b2d79..7695547 100644
--- a/sys/dev/vt/hw/efifb/efifb.c
+++ b/sys/dev/vt/hw/efifb/efifb.c
@@ -37,6 +37,9 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/fbio.h>
#include <sys/linker.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/rman.h>
#include "opt_platform.h"
@@ -179,3 +182,53 @@ vt_efifb_remap(void *xinfo)
info->fb_size, VM_MEMATTR_WRITE_COMBINING);
}
+/* Dummy NewBus functions to reserve the resources used by the efifb driver */
+static void
+vtefifb_identify(driver_t *driver, device_t parent)
+{
+
+ if (local_info.fb_pbase == 0 || local_info.fb_size == 0)
+ return;
+
+ if (BUS_ADD_CHILD(parent, 0, driver->name, 0) == NULL)
+ panic("Unable to attach vt_efifb console");
+}
+
+static int
+vtefifb_probe(device_t dev)
+{
+
+ device_set_desc(dev, "vt_efifb driver");
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static int
+vtefifb_attach(device_t dev)
+{
+ struct resource *pseudo_phys_res;
+ int res_id;
+
+ res_id = 0;
+ pseudo_phys_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
+ &res_id, local_info.fb_pbase,
+ local_info.fb_pbase + local_info.fb_size,
+ local_info.fb_size, RF_ACTIVE);
+ if (pseudo_phys_res == NULL)
+ panic("Unable to reserve vt_efifb memory");
+ return (0);
+}
+
+/*-------------------- Private Device Attachment Data -----------------------*/
+static device_method_t vtefifb_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_identify, vtefifb_identify),
+ DEVMETHOD(device_probe, vtefifb_probe),
+ DEVMETHOD(device_attach, vtefifb_attach),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(vtefifb, vtefifb_driver, vtefifb_methods, 0);
+devclass_t vtefifb_devclass;
+
+DRIVER_MODULE(vtefifb, nexus, vtefifb_driver, vtefifb_devclass, NULL, NULL);
diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index abddbf5..7f35053 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -36,6 +36,9 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/rman.h>
#include <dev/vt/vt.h>
#include <dev/vt/hw/vga/vt_vga_reg.h>
@@ -56,6 +59,7 @@ struct vga_softc {
bus_space_handle_t vga_reg_handle;
int vga_wmode;
term_color_t vga_curfg, vga_curbg;
+ boolean_t vga_enabled;
};
/* Convenience macros. */
@@ -1228,6 +1232,7 @@ vga_init(struct vt_device *vd)
vd->vd_height = VT_VGA_HEIGHT;
}
vga_initialize(vd, textmode);
+ sc->vga_enabled = true;
return (CN_INTERNAL);
}
@@ -1241,3 +1246,53 @@ vga_postswitch(struct vt_device *vd)
/* Ask vt(9) to update chars on visible area. */
vd->vd_flags |= VDF_INVALID;
}
+
+/* Dummy NewBus functions to reserve the resources used by the vt_vga driver */
+static void
+vtvga_identify(driver_t *driver, device_t parent)
+{
+
+ if (!vga_conssoftc.vga_enabled)
+ return;
+
+ if (BUS_ADD_CHILD(parent, 0, driver->name, 0) == NULL)
+ panic("Unable to attach vt_vga console");
+}
+
+static int
+vtvga_probe(device_t dev)
+{
+
+ device_set_desc(dev, "vt_vga driver");
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static int
+vtvga_attach(device_t dev)
+{
+ struct resource *pseudo_phys_res;
+ int res_id;
+
+ res_id = 0;
+ pseudo_phys_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
+ &res_id, VGA_MEM_BASE, VGA_MEM_BASE + VGA_MEM_SIZE,
+ VGA_MEM_SIZE, RF_ACTIVE);
+ if (pseudo_phys_res == NULL)
+ panic("Unable to reserve vt_vga memory");
+ return (0);
+}
+
+/*-------------------- Private Device Attachment Data -----------------------*/
+static device_method_t vtvga_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_identify, vtvga_identify),
+ DEVMETHOD(device_probe, vtvga_probe),
+ DEVMETHOD(device_attach, vtvga_attach),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(vtvga, vtvga_driver, vtvga_methods, 0);
+devclass_t vtvga_devclass;
+
+DRIVER_MODULE(vtvga, nexus, vtvga_driver, vtvga_devclass, NULL, NULL);
OpenPOWER on IntegriCloud