summaryrefslogtreecommitdiffstats
path: root/sys/dev/vt/hw
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/vt/hw')
-rw-r--r--sys/dev/vt/hw/efifb/efifb.c56
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.c10
-rw-r--r--sys/dev/vt/hw/vga/vt_vga.c20
-rw-r--r--sys/dev/vt/hw/vga/vt_vga_reg.h2
4 files changed, 27 insertions, 61 deletions
diff --git a/sys/dev/vt/hw/efifb/efifb.c b/sys/dev/vt/hw/efifb/efifb.c
index 05b2d79..2451277 100644
--- a/sys/dev/vt/hw/efifb/efifb.c
+++ b/sys/dev/vt/hw/efifb/efifb.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
static vd_init_t vt_efifb_init;
static vd_probe_t vt_efifb_probe;
-static void vt_efifb_remap(void *efifb_data);
static struct vt_driver vt_efifb_driver = {
.vd_name = "efifb",
@@ -73,8 +72,6 @@ static struct vt_driver vt_efifb_driver = {
static struct fb_info local_info;
VT_DRIVER_DECLARE(vt_efifb, vt_efifb_driver);
-SYSINIT(efifb_remap, SI_SUB_KMEM, SI_ORDER_ANY, vt_efifb_remap, &local_info);
-
static int
vt_efifb_probe(struct vt_device *vd)
{
@@ -101,7 +98,6 @@ vt_efifb_probe(struct vt_device *vd)
static int
vt_efifb_init(struct vt_device *vd)
{
- int depth, d;
struct fb_info *info;
struct efi_fb *efifb;
caddr_t kmdp;
@@ -121,16 +117,13 @@ vt_efifb_init(struct vt_device *vd)
info->fb_height = efifb->fb_height;
info->fb_width = efifb->fb_width;
- depth = fls(efifb->fb_mask_red);
- d = fls(efifb->fb_mask_green);
- depth = d > depth ? d : depth;
- d = fls(efifb->fb_mask_blue);
- depth = d > depth ? d : depth;
- d = fls(efifb->fb_mask_reserved);
- depth = d > depth ? d : depth;
- info->fb_depth = depth;
+ info->fb_depth = fls(efifb->fb_mask_red | efifb->fb_mask_green |
+ efifb->fb_mask_blue | efifb->fb_mask_reserved);
+ /* Round to a multiple of the bits in a byte. */
+ info->fb_bpp = (info->fb_depth + NBBY - 1) & ~(NBBY - 1);
- info->fb_stride = efifb->fb_stride * (depth / 8);
+ /* Stride in bytes, not pixels */
+ info->fb_stride = efifb->fb_stride * (info->fb_bpp / NBBY);
vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB,
efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1,
@@ -139,43 +132,10 @@ vt_efifb_init(struct vt_device *vd)
info->fb_size = info->fb_height * info->fb_stride;
info->fb_pbase = efifb->fb_addr;
- /*
- * Use the direct map as a crutch until pmap is available. Once pmap
- * is online, the framebuffer will be remapped by vt_efifb_remap()
- * using pmap_mapdev_attr().
- */
- info->fb_vbase = PHYS_TO_DMAP(efifb->fb_addr);
-
- /* Get pixel storage size. */
- info->fb_bpp = info->fb_stride / info->fb_width * 8;
-
- /*
- * Early FB driver work with static window buffer, so reduce to minimal
- * size, buffer or screen.
- */
- info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH);
- info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT);
+ info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
+ info->fb_size, VM_MEMATTR_WRITE_COMBINING);
vt_fb_init(vd);
return (CN_INTERNAL);
}
-
-static void
-vt_efifb_remap(void *xinfo)
-{
- struct fb_info *info = xinfo;
-
- if (info->fb_pbase == 0)
- return;
-
- /*
- * Remap as write-combining. This massively improves performance and
- * happens very early in kernel initialization, when everything is
- * still single-threaded and interrupts are off, so replacing the
- * mapping address is safe.
- */
- info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase,
- info->fb_size, VM_MEMATTR_WRITE_COMBINING);
-}
-
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index 9028fb0..ff36d18 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -280,6 +280,7 @@ vt_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
if (mask != NULL && (mask[byte] & bit) == 0)
continue;
o = (y + yi) * info->fb_stride + (x + xi) * bpp;
+ o += vd->vd_transpose;
cc = pattern[byte] & bit ? fgc : bgc;
switch(bpp) {
@@ -397,11 +398,16 @@ int
vt_fb_init(struct vt_device *vd)
{
struct fb_info *info;
+ u_int margin;
int err;
info = vd->vd_softc;
- vd->vd_height = info->fb_height;
- vd->vd_width = info->fb_width;
+ vd->vd_height = MIN(VT_FB_DEFAULT_HEIGHT, info->fb_height);
+ margin = (info->fb_height - vd->vd_height) >> 1;
+ vd->vd_transpose = margin * info->fb_stride;
+ vd->vd_width = MIN(VT_FB_DEFAULT_WIDTH, info->fb_width);
+ margin = (info->fb_width - vd->vd_width) >> 1;
+ vd->vd_transpose += margin * (info->fb_bpp / NBBY);
if (info->fb_size == 0)
return (CN_DEAD);
diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index bce1c61..62e409f 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -42,13 +42,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
-#if defined(__amd64__) || defined(__i386__)
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/pmap.h>
-#include <machine/vmparam.h>
-#endif /* __amd64__ || __i386__ */
-
struct vga_softc {
bus_space_tag_t vga_fb_tag;
bus_space_handle_t vga_fb_handle;
@@ -885,9 +878,9 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw,
/* Convert colors to VGA attributes. */
attr = bg << 4 | fg;
- MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 0,
+ MEM_WRITE1(sc, (row * 80 + col) * 2 + 0,
ch);
- MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 1,
+ MEM_WRITE1(sc, (row * 80 + col) * 2 + 1,
attr);
}
}
@@ -1211,9 +1204,7 @@ vga_init(struct vt_device *vd)
#if defined(__amd64__) || defined(__i386__)
sc->vga_fb_tag = X86_BUS_SPACE_MEM;
- sc->vga_fb_handle = KERNBASE + VGA_MEM_BASE;
sc->vga_reg_tag = X86_BUS_SPACE_IO;
- sc->vga_reg_handle = VGA_REG_BASE;
#elif defined(__ia64__)
sc->vga_fb_tag = IA64_BUS_SPACE_MEM;
sc->vga_fb_handle = IA64_PHYS_TO_RR6(VGA_MEM_BASE);
@@ -1223,14 +1214,21 @@ vga_init(struct vt_device *vd)
# error "Architecture not yet supported!"
#endif
+ bus_space_map(sc->vga_reg_tag, VGA_REG_BASE, VGA_REG_SIZE, 0,
+ &sc->vga_reg_handle);
+
TUNABLE_INT_FETCH("hw.vga.textmode", &textmode);
if (textmode) {
vd->vd_flags |= VDF_TEXTMODE;
vd->vd_width = 80;
vd->vd_height = 25;
+ bus_space_map(sc->vga_fb_tag, VGA_TXT_BASE, VGA_TXT_SIZE, 0,
+ &sc->vga_fb_handle);
} else {
vd->vd_width = VT_VGA_WIDTH;
vd->vd_height = VT_VGA_HEIGHT;
+ bus_space_map(sc->vga_fb_tag, VGA_MEM_BASE, VGA_MEM_SIZE, 0,
+ &sc->vga_fb_handle);
}
vga_initialize(vd, textmode);
diff --git a/sys/dev/vt/hw/vga/vt_vga_reg.h b/sys/dev/vt/hw/vga/vt_vga_reg.h
index 5bfb8ce..cf33a37 100644
--- a/sys/dev/vt/hw/vga/vt_vga_reg.h
+++ b/sys/dev/vt/hw/vga/vt_vga_reg.h
@@ -49,6 +49,8 @@
#define VGA_MEM_BASE 0xA0000
#define VGA_MEM_SIZE 0x10000
+#define VGA_TXT_BASE 0xB8000
+#define VGA_TXT_SIZE 0x08000
#define VGA_REG_BASE 0x3c0
#define VGA_REG_SIZE 0x10+0x0c
OpenPOWER on IntegriCloud