Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Weird clock behaviour with current (amd64) kernel



On Fri, 15 Jul 2022, Robert Elz wrote:

If that is all it is, it is barely worth fixing ... though this
must have happened sometime in the 9.99.9[78] series (sometime
after early last Dec).


Farther back than that I think: 9.2_STABLE does the same thing.

On Fri, 15 Jul 2022, Michael van Elst wrote:

Whatever driver you use either doesn't translate correctly or badly
assumes some hardware configuration (e.g. color palette) when booting.


Unsurprisingly, EFI also has a colour-index similar to VGA (see:
/usr/src/sys/external/bsd/gnu-efi/dist/inc/eficon.h). I tried fixing the
indexes like this, but, it doesn't for some (autoconfig?) reason. Can
only look into this after I come back from my road-trip.

---
diff -urN a/src/sys/arch/x86/x86/genfb_machdep.c b/src/sys/arch/x86/x86/genfb_machdep.c
--- a/src/sys/arch/x86/x86/genfb_machdep.c	2021-01-28 01:57:31.000000000 +0000
+++ b/src/sys/arch/x86/x86/genfb_machdep.c	2022-07-15 23:29:07.334415944 +0000
@@ -163,24 +163,60 @@
 	return 1;
 }

+/*
+ * translate WS(=ANSI) color codes to EFI/PC ones
+ */
+#define bg(x) ((x)<<4U)
+static const unsigned char fgansitopc[] = {
+	WSCOL_BLACK, WSCOL_BLUE, WSCOL_GREEN, WSCOL_CYAN, WSCOL_RED,
+	WSCOL_MAGENTA, WSCOL_BROWN, WSCOL_WHITE,
+	WSCOL_LIGHT_GREY, WSCOL_LIGHT_BLUE, WSCOL_LIGHT_GREEN, WSCOL_LIGHT_CYAN,
+	WSCOL_LIGHT_RED, WSCOL_LIGHT_MAGENTA, WSCOL_LIGHT_BROWN, WSCOL_LIGHT_WHITE
+}, bgansitopc[] = {
+	bg(WSCOL_BLACK), bg(WSCOL_BLUE), bg(WSCOL_GREEN), bg(WSCOL_CYAN),
+	bg(WSCOL_RED), bg(WSCOL_MAGENTA), bg(WSCOL_BROWN), bg(WSCOL_LIGHT_GREY)
+};
+#undef bg
+
+static void
+x86_genfb_pc_colour(long *attr)
+{
+	uint32_t fg, bg, flag;
+	long aa;
+
+	rasops_unpack_attr(*attr, &fg, &bg, NULL);
+	if (__predict_false(fg >= sizeof(fgansitopc) || bg >= sizeof(bgansitopc))) {
+		aprint_normal("x86_genfb_pc_colour: out of range\n");
+		return;
+	}
+	flag = *attr & 0xFFFFU;
+	aa = fgansitopc[fg] << 24 | bgansitopc[bg] << 16 | flag;
+	aprint_normal("x86_genfb_pc_colour: old = 0x%lX, new = 0x%lX\n", *attr, aa);
+	*attr = aa;
+}
+
 int
 x86_genfb_cnattach(void)
 {
 	static int ncalls = 0;
 	struct rasops_info *ri = &x86_genfb_console_screen.scr_ri;
-	long defattr;
+	long defattr = 0;

 	/* XXX jmcneill
 	 *  Defer console initialization until UVM is initialized
 	 */
+	aprint_normal("x86_genfb_cnattach()\n");
 	++ncalls;
 	if (ncalls < 3)
 		return -1;

-	if (!x86_genfb_init())
+	if (!x86_genfb_init()) {
+		aprint_normal("x86_genfb_init ERROR\n");
 		return 0;
+	}

 	ri->ri_ops.allocattr(ri, 0, 0, 0, &defattr);
+	x86_genfb_pc_colour(&defattr);
 	wsdisplay_preattach(&x86_genfb_stdscreen, ri, 0, 0, defattr);

 	return 1;
---

-RVP


Home | Main Index | Thread Index | Old Index