efifb.c (285911) | efifb.c (286667) |
---|---|
1/*- 2 * Copyright (c) 2014 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Aleksandr Rybalko under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Aleksandr Rybalko under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/vt/hw/efifb/efifb.c 285911 2015-07-27 14:03:34Z marius $"); | 31__FBSDID("$FreeBSD: head/sys/dev/vt/hw/efifb/efifb.c 286667 2015-08-12 15:26:32Z marcel $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/fbio.h> 37#include <sys/linker.h> 38 39#include "opt_platform.h" --- 6 unchanged lines hidden (view full) --- 46#include <machine/pmap.h> 47 48#include <dev/vt/vt.h> 49#include <dev/vt/hw/fb/vt_fb.h> 50#include <dev/vt/colors/vt_termcolors.h> 51 52static vd_init_t vt_efifb_init; 53static vd_probe_t vt_efifb_probe; | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/fbio.h> 37#include <sys/linker.h> 38 39#include "opt_platform.h" --- 6 unchanged lines hidden (view full) --- 46#include <machine/pmap.h> 47 48#include <dev/vt/vt.h> 49#include <dev/vt/hw/fb/vt_fb.h> 50#include <dev/vt/colors/vt_termcolors.h> 51 52static vd_init_t vt_efifb_init; 53static vd_probe_t vt_efifb_probe; |
54static void vt_efifb_remap(void *efifb_data); | |
55 56static struct vt_driver vt_efifb_driver = { 57 .vd_name = "efifb", 58 .vd_probe = vt_efifb_probe, 59 .vd_init = vt_efifb_init, 60 .vd_blank = vt_fb_blank, 61 .vd_bitblt_text = vt_fb_bitblt_text, 62 .vd_bitblt_bmp = vt_fb_bitblt_bitmap, 63 .vd_drawrect = vt_fb_drawrect, 64 .vd_setpixel = vt_fb_setpixel, 65 .vd_fb_ioctl = vt_fb_ioctl, 66 .vd_fb_mmap = vt_fb_mmap, 67 /* Better than VGA, but still generic driver. */ 68 .vd_priority = VD_PRIORITY_GENERIC + 1, 69}; 70 71static struct fb_info local_info; 72VT_DRIVER_DECLARE(vt_efifb, vt_efifb_driver); 73 | 54 55static struct vt_driver vt_efifb_driver = { 56 .vd_name = "efifb", 57 .vd_probe = vt_efifb_probe, 58 .vd_init = vt_efifb_init, 59 .vd_blank = vt_fb_blank, 60 .vd_bitblt_text = vt_fb_bitblt_text, 61 .vd_bitblt_bmp = vt_fb_bitblt_bitmap, 62 .vd_drawrect = vt_fb_drawrect, 63 .vd_setpixel = vt_fb_setpixel, 64 .vd_fb_ioctl = vt_fb_ioctl, 65 .vd_fb_mmap = vt_fb_mmap, 66 /* Better than VGA, but still generic driver. */ 67 .vd_priority = VD_PRIORITY_GENERIC + 1, 68}; 69 70static struct fb_info local_info; 71VT_DRIVER_DECLARE(vt_efifb, vt_efifb_driver); 72 |
74SYSINIT(efifb_remap, SI_SUB_KMEM, SI_ORDER_ANY, vt_efifb_remap, &local_info); 75 | |
76static int 77vt_efifb_probe(struct vt_device *vd) 78{ 79 int disabled; 80 struct efi_fb *efifb; 81 caddr_t kmdp; 82 83 disabled = 0; --- 48 unchanged lines hidden (view full) --- 132 133 vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 134 efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, 135 efifb->fb_mask_green, ffs(efifb->fb_mask_green) - 1, 136 efifb->fb_mask_blue, ffs(efifb->fb_mask_blue) - 1); 137 138 info->fb_size = info->fb_height * info->fb_stride; 139 info->fb_pbase = efifb->fb_addr; | 73static int 74vt_efifb_probe(struct vt_device *vd) 75{ 76 int disabled; 77 struct efi_fb *efifb; 78 caddr_t kmdp; 79 80 disabled = 0; --- 48 unchanged lines hidden (view full) --- 129 130 vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, 131 efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, 132 efifb->fb_mask_green, ffs(efifb->fb_mask_green) - 1, 133 efifb->fb_mask_blue, ffs(efifb->fb_mask_blue) - 1); 134 135 info->fb_size = info->fb_height * info->fb_stride; 136 info->fb_pbase = efifb->fb_addr; |
140 /* 141 * Use the direct map as a crutch until pmap is available. Once pmap 142 * is online, the framebuffer will be remapped by vt_efifb_remap() 143 * using pmap_mapdev_attr(). 144 */ 145 info->fb_vbase = PHYS_TO_DMAP(efifb->fb_addr); | 137 info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase, 138 info->fb_size, VM_MEMATTR_WRITE_COMBINING); |
146 147 /* Get pixel storage size. */ 148 info->fb_bpp = info->fb_stride / info->fb_width * 8; 149 150 /* 151 * Early FB driver work with static window buffer, so reduce to minimal 152 * size, buffer or screen. 153 */ 154 info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH); 155 info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT); 156 157 vt_fb_init(vd); 158 159 return (CN_INTERNAL); 160} | 139 140 /* Get pixel storage size. */ 141 info->fb_bpp = info->fb_stride / info->fb_width * 8; 142 143 /* 144 * Early FB driver work with static window buffer, so reduce to minimal 145 * size, buffer or screen. 146 */ 147 info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH); 148 info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT); 149 150 vt_fb_init(vd); 151 152 return (CN_INTERNAL); 153} |
161 162static void 163vt_efifb_remap(void *xinfo) 164{ 165 struct fb_info *info = xinfo; 166 167 if (info->fb_pbase == 0) 168 return; 169 170 /* 171 * Remap as write-combining. This massively improves performance and 172 * happens very early in kernel initialization, when everything is 173 * still single-threaded and interrupts are off, so replacing the 174 * mapping address is safe. 175 */ 176 info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase, 177 info->fb_size, VM_MEMATTR_WRITE_COMBINING); 178} | |