Add VT driver for VBE framebuffer device
Implement vt_vbefb to support Vesa Bios Extensions (VBE) framebuffer with VT. vt_vbefb is built based on vt_efifb and is assuming similar data for initialization, use MODINFOMD_VBE_FB to identify the structure vbe_fb in kernel metadata. struct vbe_fb, is populated by boot loader, and is passed to kernel via metadata payload. Differential Revision: https://reviews.freebsd.org/D27373
This commit is contained in:
parent
52a832072d
commit
a4a10b37d4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=368168
@ -218,6 +218,7 @@ options SC_PIXEL_MODE # add support for the raster text mode
|
||||
device vt
|
||||
device vt_vga
|
||||
device vt_efifb
|
||||
device vt_vbefb
|
||||
|
||||
device agp # support several AGP chipsets
|
||||
|
||||
|
@ -126,6 +126,7 @@ options SC_PIXEL_MODE # add support for the raster text mode
|
||||
device vt
|
||||
device vt_vga
|
||||
device vt_efifb
|
||||
device vt_vbefb
|
||||
|
||||
device agp # support several AGP chipsets
|
||||
|
||||
|
@ -255,6 +255,7 @@ options VGA_DEBUG
|
||||
# vt(4) drivers.
|
||||
device vt_vga # VGA
|
||||
device vt_efifb # EFI framebuffer
|
||||
device vt_vbefb # VBE framebuffer
|
||||
|
||||
# Linear framebuffer driver for S3 VESA 1.2 cards. Works on top of VESA.
|
||||
device s3pci
|
||||
|
@ -3474,6 +3474,7 @@ dev/vt/colors/vt_termcolors.c optional vt
|
||||
dev/vt/font/vt_font_default.c optional vt
|
||||
dev/vt/font/vt_mouse_cursor.c optional vt
|
||||
dev/vt/hw/efifb/efifb.c optional vt_efifb
|
||||
dev/vt/hw/vbefb/vbefb.c optional vt_vbefb
|
||||
dev/vt/hw/fb/vt_fb.c optional vt
|
||||
dev/vt/hw/vga/vt_vga.c optional vt vt_vga
|
||||
dev/vt/logo/logo_freebsd.c optional vt splash
|
||||
|
@ -1337,8 +1337,8 @@ vmbus_get_mmio_res(device_t dev)
|
||||
/*
|
||||
* On Gen2 VMs, Hyper-V provides mmio space for framebuffer.
|
||||
* This mmio address range is not useable for other PCI devices.
|
||||
* Currently only efifb driver is using this range without reserving
|
||||
* it from system.
|
||||
* Currently only efifb and vbefb drivers are using this range without
|
||||
* reserving it from system.
|
||||
* Therefore, vmbus driver reserves it before any other PCI device
|
||||
* drivers start to request mmio addresses.
|
||||
*/
|
||||
@ -1348,6 +1348,9 @@ static void
|
||||
vmbus_fb_mmio_res(device_t dev)
|
||||
{
|
||||
struct efi_fb *efifb;
|
||||
struct vbe_fb *vbefb;
|
||||
rman_res_t fb_start, fb_end, fb_count;
|
||||
int fb_height, fb_width;
|
||||
caddr_t kmdp;
|
||||
|
||||
struct vmbus_softc *sc = device_get_softc(dev);
|
||||
@ -1359,30 +1362,43 @@ vmbus_fb_mmio_res(device_t dev)
|
||||
efifb = (struct efi_fb *)preload_search_info(kmdp,
|
||||
MODINFO_METADATA | MODINFOMD_EFI_FB);
|
||||
if (efifb == NULL) {
|
||||
vbefb = (struct vbe_fb *)preload_search_info(kmdp,
|
||||
MODINFO_METADATA | MODINFOMD_VBE_FB);
|
||||
fb_start = vbefb->fb_addr;
|
||||
fb_end = vbefb->fb_addr + vbefb->fb_size;
|
||||
fb_count = vbefb->fb_size;
|
||||
fb_height = efifb->fb_height;
|
||||
fb_width = efifb->fb_width;
|
||||
} else {
|
||||
fb_start = efifb->fb_addr;
|
||||
fb_end = efifb->fb_addr + efifb->fb_size;
|
||||
fb_count = efifb->fb_size;
|
||||
fb_height = efifb->fb_height;
|
||||
fb_width = efifb->fb_width;
|
||||
}
|
||||
if (fb_start == 0) {
|
||||
if (bootverbose)
|
||||
device_printf(dev,
|
||||
"fb has no preloaded kernel efi information\n");
|
||||
"no preloaded kernel fb information\n");
|
||||
/* We are on Gen1 VM, just return. */
|
||||
return;
|
||||
} else {
|
||||
if (bootverbose)
|
||||
device_printf(dev,
|
||||
"efifb: fb_addr: %#jx, size: %#jx, "
|
||||
"fb: fb_addr: %#jx, size: %#jx, "
|
||||
"actual size needed: 0x%x\n",
|
||||
efifb->fb_addr, efifb->fb_size,
|
||||
(int) efifb->fb_height * efifb->fb_width);
|
||||
fb_start, fb_count, fb_height * fb_width);
|
||||
}
|
||||
|
||||
hv_fb_res = pcib_host_res_alloc(&sc->vmbus_mmio_res, dev,
|
||||
SYS_RES_MEMORY, &rid,
|
||||
efifb->fb_addr, efifb->fb_addr + efifb->fb_size, efifb->fb_size,
|
||||
SYS_RES_MEMORY, &rid, fb_start, fb_end, fb_count,
|
||||
RF_ACTIVE | rman_make_alignment_flags(PAGE_SIZE));
|
||||
|
||||
if (hv_fb_res && bootverbose)
|
||||
device_printf(dev,
|
||||
"successfully reserved memory for framebuffer "
|
||||
"starting at %#jx, size %#jx\n",
|
||||
efifb->fb_addr, efifb->fb_size);
|
||||
fb_start, fb_count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
153
sys/dev/vt/hw/vbefb/vbefb.c
Normal file
153
sys/dev/vt/hw/vbefb/vbefb.c
Normal file
@ -0,0 +1,153 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2014 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Aleksandr Rybalko under sponsorship from the
|
||||
* FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/fbio.h>
|
||||
#include <sys/linker.h>
|
||||
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <machine/metadata.h>
|
||||
#include <machine/vmparam.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#include <dev/vt/vt.h>
|
||||
#include <dev/vt/hw/fb/vt_fb.h>
|
||||
#include <dev/vt/colors/vt_termcolors.h>
|
||||
|
||||
static vd_init_t vt_vbefb_init;
|
||||
static vd_probe_t vt_vbefb_probe;
|
||||
|
||||
static struct vt_driver vt_vbefb_driver = {
|
||||
.vd_name = "vbefb",
|
||||
.vd_probe = vt_vbefb_probe,
|
||||
.vd_init = vt_vbefb_init,
|
||||
.vd_blank = vt_fb_blank,
|
||||
.vd_bitblt_text = vt_fb_bitblt_text,
|
||||
.vd_invalidate_text = vt_fb_invalidate_text,
|
||||
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
|
||||
.vd_drawrect = vt_fb_drawrect,
|
||||
.vd_setpixel = vt_fb_setpixel,
|
||||
.vd_fb_ioctl = vt_fb_ioctl,
|
||||
.vd_fb_mmap = vt_fb_mmap,
|
||||
.vd_suspend = vt_suspend,
|
||||
.vd_resume = vt_resume,
|
||||
/* Better than VGA, but still generic driver. */
|
||||
.vd_priority = VD_PRIORITY_GENERIC + 1,
|
||||
};
|
||||
|
||||
static struct fb_info local_vbe_info;
|
||||
VT_DRIVER_DECLARE(vt_vbefb, vt_vbefb_driver);
|
||||
|
||||
static int
|
||||
vt_vbefb_probe(struct vt_device *vd)
|
||||
{
|
||||
int disabled;
|
||||
struct vbe_fb *vbefb;
|
||||
caddr_t kmdp;
|
||||
|
||||
disabled = 0;
|
||||
TUNABLE_INT_FETCH("hw.syscons.disable", &disabled);
|
||||
if (disabled != 0)
|
||||
return (CN_DEAD);
|
||||
|
||||
kmdp = preload_search_by_type("elf kernel");
|
||||
if (kmdp == NULL)
|
||||
kmdp = preload_search_by_type("elf64 kernel");
|
||||
vbefb = (struct vbe_fb *)preload_search_info(kmdp,
|
||||
MODINFO_METADATA | MODINFOMD_VBE_FB);
|
||||
if (vbefb == NULL)
|
||||
return (CN_DEAD);
|
||||
|
||||
return (CN_INTERNAL);
|
||||
}
|
||||
|
||||
static int
|
||||
vt_vbefb_init(struct vt_device *vd)
|
||||
{
|
||||
struct fb_info *info;
|
||||
struct vbe_fb *vbefb;
|
||||
caddr_t kmdp;
|
||||
int format, roff, goff, boff;
|
||||
|
||||
info = vd->vd_softc;
|
||||
if (info == NULL)
|
||||
info = vd->vd_softc = (void *)&local_vbe_info;
|
||||
|
||||
kmdp = preload_search_by_type("elf kernel");
|
||||
if (kmdp == NULL)
|
||||
kmdp = preload_search_by_type("elf64 kernel");
|
||||
vbefb = (struct vbe_fb *)preload_search_info(kmdp,
|
||||
MODINFO_METADATA | MODINFOMD_VBE_FB);
|
||||
if (vbefb == NULL)
|
||||
return (CN_DEAD);
|
||||
|
||||
info->fb_height = vbefb->fb_height;
|
||||
info->fb_width = vbefb->fb_width;
|
||||
|
||||
info->fb_depth = vbefb->fb_bpp;
|
||||
/* Round to a multiple of the bits in a byte. */
|
||||
info->fb_bpp = roundup2(vbefb->fb_bpp, NBBY);
|
||||
|
||||
/* Stride in bytes, not pixels */
|
||||
info->fb_stride = vbefb->fb_stride * (info->fb_bpp / NBBY);
|
||||
|
||||
if (info->fb_depth == 8)
|
||||
format = COLOR_FORMAT_VGA;
|
||||
else
|
||||
format = COLOR_FORMAT_RGB;
|
||||
|
||||
roff = ffs(vbefb->fb_mask_red) - 1;
|
||||
goff = ffs(vbefb->fb_mask_green) - 1;
|
||||
boff = ffs(vbefb->fb_mask_blue) - 1;
|
||||
vt_generate_cons_palette(info->fb_cmap, format,
|
||||
vbefb->fb_mask_red >> roff, roff,
|
||||
vbefb->fb_mask_green >> goff, goff,
|
||||
vbefb->fb_mask_blue >> boff, boff);
|
||||
|
||||
/* Mark cmap initialized. */
|
||||
info->fb_cmsize = NCOLORS;
|
||||
|
||||
info->fb_size = info->fb_height * info->fb_stride;
|
||||
info->fb_pbase = vbefb->fb_addr;
|
||||
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);
|
||||
}
|
@ -126,6 +126,7 @@ options SC_PIXEL_MODE # add support for the raster text mode
|
||||
device vt
|
||||
device vt_vga
|
||||
device vt_efifb
|
||||
device vt_vbefb
|
||||
|
||||
device agp # support several AGP chipsets
|
||||
|
||||
|
@ -415,6 +415,11 @@ preload_modinfo_type(struct sbuf *sbp, int type)
|
||||
case MODINFOMD_MODULEP:
|
||||
sbuf_cat(sbp, "MODINFOMD_MODULEP");
|
||||
break;
|
||||
#endif
|
||||
#ifdef MODINFOMD_VBE_FB
|
||||
case MODINFOMD_VBE_FB:
|
||||
sbuf_cat(sbp, "MODINFOMD_VBE_FB");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
sbuf_cat(sbp, "unrecognized metadata type");
|
||||
@ -461,6 +466,9 @@ preload_modinfo_value(struct sbuf *sbp, uint32_t *bptr, int type, int len)
|
||||
#endif
|
||||
#ifdef MODINFOMD_EFI_FB
|
||||
case MODINFO_METADATA | MODINFOMD_EFI_FB:
|
||||
#endif
|
||||
#ifdef MODINFOMD_VBE_FB
|
||||
case MODINFO_METADATA | MODINFOMD_VBE_FB:
|
||||
#endif
|
||||
sbuf_print_vmoffset(sbp, *(vm_offset_t *)bptr);
|
||||
break;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define MODINFOMD_EFI_MAP 0x1004
|
||||
#define MODINFOMD_EFI_FB 0x1005
|
||||
#define MODINFOMD_MODULEP 0x1006
|
||||
#define MODINFOMD_VBE_FB 0x1007
|
||||
|
||||
struct efi_map_header {
|
||||
uint64_t memory_size;
|
||||
@ -54,4 +55,17 @@ struct efi_fb {
|
||||
uint32_t fb_mask_reserved;
|
||||
};
|
||||
|
||||
struct vbe_fb {
|
||||
uint64_t fb_addr;
|
||||
uint64_t fb_size;
|
||||
uint32_t fb_height;
|
||||
uint32_t fb_width;
|
||||
uint32_t fb_stride;
|
||||
uint32_t fb_mask_red;
|
||||
uint32_t fb_mask_green;
|
||||
uint32_t fb_mask_blue;
|
||||
uint32_t fb_mask_reserved;
|
||||
uint32_t fb_bpp;
|
||||
};
|
||||
|
||||
#endif /* !_MACHINE_METADATA_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user