Re: [PATCH v2 3/3] efi: earlycon: Add support for generic framebuffers and move to console subsystem
flat view
From: Andy Shevchenko <hidden>
Date: 2022-08-06 21:38:20
Also in:
dri-devel, linux-doc, linux-efi, linux-serial, lkml, phone-devel
On Sat, Aug 6, 2022 at 6:38 PM Markuss Broks [off-list ref] wrote:
Add early console support for generic linear framebuffer devices. This driver supports probing from cmdline early parameters or from the device-tree using information in simple-framebuffer node. The EFI functionality should be retained in whole. The driver was disabled on ARM because of a bug in early_ioremap
We refer to functions like func().
implementation on ARM and on IA64 because of lack of early_memremap_prot.
Ditto. ...
+#include <asm/early_ioremap.h>
Can it be placed after linux/* ones?
quoted hunk ↗ jump to hunk
+#include <linux/console.h> +#include <linux/efi.h> +#include <linux/font.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/of.h> +#include <linux/of_fdt.h> +#include <linux/serial_core.h> +#include <linux/screen_info.h>
...
quoted hunk ↗ jump to hunk
+static int __init simplefb_earlycon_remap_fb(void) +{ + unsigned long mapping;
+ Blank line.
quoted hunk ↗ jump to hunk
+ /* bail if there is no bootconsole or it has been disabled already */ + if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED)) + return 0; + + if (region_intersects(info.phys_base, info.size, + IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == REGION_INTERSECTS) + mapping = MEMREMAP_WB; + else + mapping = MEMREMAP_WC;
quoted hunk ↗ jump to hunk
+ info.virt_base = memremap(info.phys_base, info.size, mapping); + + return info.virt_base ? 0 : -ENOMEM;
Easier to read the standard pattern:
if (!info.virt_base)
return -ENOMEM;
return 0;
+}
...
quoted hunk ↗ jump to hunk
+static void simplefb_earlycon_write_char(u8 *dst, unsigned char c, unsigned int h) +{ + const u8 *src; + int m, n, bytes; + u8 x; + + bytes = BITS_TO_BYTES(font->width); + src = font->data + c * font->height * bytes + h * bytes; + + for (m = 0; m < font->width; m++) { + n = m % 8; + x = *(src + m / 8);
I would write it as x = src[m / 8];
+ if ((x >> (7 - n)) & 1)
+ memset(dst, 0xff, (info.depth / 8));
Too many parentheses.
+ else + memset(dst, 0, (info.depth / 8));
Ditto.
+ dst += (info.depth / 8);
Ditto.
+ } +}
-- With Best Regards, Andy Shevchenko