Remap the UEFI buffer early such that we can use a write combining mapping
authorkettenis <kettenis@openbsd.org>
Sat, 22 Sep 2018 17:41:52 +0000 (17:41 +0000)
committerkettenis <kettenis@openbsd.org>
Sat, 22 Sep 2018 17:41:52 +0000 (17:41 +0000)
which speeds things up considerably compared to an uncached mapping.

ok deraadt@

sys/arch/amd64/amd64/efifb.c
sys/arch/amd64/amd64/mainbus.c
sys/arch/amd64/include/efifbvar.h

index 3a2ed36..255b8f7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: efifb.c,v 1.17 2018/07/12 12:47:57 fcambus Exp $      */
+/*     $OpenBSD: efifb.c,v 1.18 2018/09/22 17:41:52 kettenis Exp $     */
 
 /*
  * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -215,11 +215,6 @@ efifb_attach(struct device *parent, struct device *self, void *aux)
                ccol = ri->ri_ccol;
                crow = ri->ri_crow;
 
-               if (bus_space_map(iot, fb->paddr, fb->psize,
-                   BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR,
-                   &ioh) == 0)
-                       ri->ri_origbits = bus_space_vaddr(iot, ioh);
-
                efifb_rasops_preinit(fb);
                ri->ri_flg &= ~RI_CLEAR;
                ri->ri_flg |= RI_VCONS | RI_WRONLY;
@@ -428,6 +423,7 @@ efifb_efiinfo_init(struct efifb *fb)
        fb->psize = bios_efiinfo->fb_height *
            bios_efiinfo->fb_pixpsl * (fb->depth / 8);
 }
+
 void
 efifb_cnattach_common(void)
 {
@@ -452,6 +448,28 @@ efifb_cnattach_common(void)
        wsdisplay_cnattach(&efifb_std_descr, ri, 0, 0, defattr);
 }
 
+void
+efifb_cnremap(void)
+{
+       struct efifb            *fb = &efifb_console;
+       struct rasops_info      *ri = &fb->rinfo;
+       bus_space_tag_t          iot = X86_BUS_SPACE_MEM;
+       bus_space_handle_t       ioh;
+
+       if (fb->paddr == 0)
+               return;
+
+       if (_bus_space_map(iot, fb->paddr, fb->psize,
+           BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR, &ioh) == 0)
+               ri->ri_origbits = bus_space_vaddr(iot, ioh);
+
+       efifb_rasops_preinit(fb);
+       ri->ri_flg &= ~RI_CLEAR;
+       ri->ri_flg |= RI_CENTER | RI_WRONLY;
+
+       rasops_init(ri, efifb_std_descr.nrows, efifb_std_descr.ncols);
+}
+
 int
 efifb_is_console(struct pci_attach_args *pa)
 {
index 2f0a74f..f4fb3ec 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mainbus.c,v 1.44 2018/07/13 08:30:34 sf Exp $ */
+/*     $OpenBSD: mainbus.c,v 1.45 2018/09/22 17:41:52 kettenis Exp $   */
 /*     $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */
 
 /*
@@ -171,6 +171,10 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
                pvbus_identify();
 #endif
 
+#if NEFIFB > 0
+       efifb_cnremap();
+#endif
+
 #if NBIOS > 0
        {
                mba.mba_bios.ba_name = "bios";
index 5581996..a900cd0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: efifbvar.h,v 1.7 2018/04/25 00:46:28 jsg Exp $        */
+/*     $OpenBSD: efifbvar.h,v 1.8 2018/09/22 17:41:52 kettenis Exp $   */
 
 /*
  * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -26,6 +26,7 @@ struct efifb_attach_args {
 struct pci_attach_args;
 
 int efifb_cnattach(void);
+void efifb_cnremap(void);
 int efifb_is_console(struct pci_attach_args *);
 void efifb_cndetach(void);
 void efifb_cnreattach(void);