From owner-svn-src-head@FreeBSD.ORG Wed Mar 5 14:37:46 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 644FE378; Wed, 5 Mar 2014 14:37:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 43E4FF98; Wed, 5 Mar 2014 14:37:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s25EbkHE042211; Wed, 5 Mar 2014 14:37:46 GMT (envelope-from ray@svn.freebsd.org) Received: (from ray@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s25EbkPv042210; Wed, 5 Mar 2014 14:37:46 GMT (envelope-from ray@svn.freebsd.org) Message-Id: <201403051437.s25EbkPv042210@svn.freebsd.org> From: Aleksandr Rybalko Date: Wed, 5 Mar 2014 14:37:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262785 - head/sys/dev/vt/hw/efifb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2014 14:37:46 -0000 Author: ray Date: Wed Mar 5 14:37:45 2014 New Revision: 262785 URL: http://svnweb.freebsd.org/changeset/base/262785 Log: Add efifb driver. Driver uses the data passed by UEFI compatible loader/BIOS and enable to use framebuffer created by those loader. Added: head/sys/dev/vt/hw/efifb/ head/sys/dev/vt/hw/efifb/efifb.c (contents, props changed) Added: head/sys/dev/vt/hw/efifb/efifb.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/vt/hw/efifb/efifb.c Wed Mar 5 14:37:45 2014 (r262785) @@ -0,0 +1,143 @@ +/*- + * 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. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "opt_platform.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static vd_init_t vt_efb_init; + +static struct vt_driver vt_efb_driver = { + .vd_init = vt_efb_init, + .vd_blank = vt_fb_blank, + .vd_bitbltchr = vt_fb_bitbltchr, + /* Better than VGA, but still generic driver. */ + .vd_priority = VD_PRIORITY_GENERIC + 1, +}; + +static struct fb_info info; +VT_CONSDEV_DECLARE(vt_efb_driver, + MAX(80, PIXEL_WIDTH(VT_FB_DEFAULT_WIDTH)), + MAX(25, PIXEL_HEIGHT(VT_FB_DEFAULT_HEIGHT)), &info); + +static int +vt_efb_init(struct vt_device *vd) +{ + int depth, d, disable, i, len; + struct fb_info *info; + struct efi_fb *efifb; + caddr_t kmdp; + + info = vd->vd_softc; + + disable = 0; + TUNABLE_INT_FETCH("hw.syscons.disable", &disable); + if (disable != 0) + return (CN_DEAD); + + kmdp = preload_search_by_type("elf kernel"); + if (kmdp == NULL) + kmdp = preload_search_by_type("elf64 kernel"); + efifb = (struct efi_fb *)preload_search_info(kmdp, + MODINFO_METADATA | MODINFOMD_EFI_FB); + if (!efifb->fb_present) + return (CN_DEAD); + + 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_stride = efifb->fb_stride * (depth / 8); + + vt_generate_vga_palette(info->fb_cmap, COLOR_FORMAT_RGB, + efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, + efifb->fb_mask_green, ffs(efifb->fb_mask_green) - 1, + efifb->fb_mask_blue, ffs(efifb->fb_mask_blue) - 1); + + info->fb_size = info->fb_height * info->fb_stride; + info->fb_pbase = efifb->fb_addr; + /* + * We could use pmap_mapdev here except that the kernel pmap + * hasn't been created yet and hence any attempt to lock it will + * fail. + */ + info->fb_vbase = PHYS_TO_DMAP(efifb->fb_addr); + + /* blank full size */ + len = info->fb_size / 4; + for (i = 0; i < len; i++) { + ((uint32_t *)info->fb_vbase)[i] = 0; + } + + /* 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); + + fb_probe(info); + vt_fb_init(vd); + + + return (CN_INTERNAL); +} +