Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Created May 30, 2025 16:59
Show Gist options
  • Save tsutsui/4bad01a62d6007d54c95fd94e26bf8e1 to your computer and use it in GitHub Desktop.
Save tsutsui/4bad01a62d6007d54c95fd94e26bf8e1 to your computer and use it in GitHub Desktop.
debug NetBSD/hp300 sti(4) framebuffer console with com(4) console output
Index: arch/hp300/dev/com_dio.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/dev/com_dio.c,v
retrieving revision 1.10
diff -u -p -d -r1.10 com_dio.c
--- arch/hp300/dev/com_dio.c 16 Jan 2024 05:48:28 -0000 1.10
+++ arch/hp300/dev/com_dio.c 30 May 2025 16:52:13 -0000
@@ -182,7 +182,7 @@ com_dio_cnattach(bus_space_tag_t bst, bu
bus_space_unmap(iot, iohdca, DCA_SIZE);
switch (id) {
-#ifdef CONSCODE
+#if 1// #ifdef CONSCODE
case DCAID0:
case DCAID1:
#endif
Index: arch/hp300/hp300/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/autoconf.c,v
retrieving revision 1.117
diff -u -p -d -r1.117 autoconf.c
--- arch/hp300/hp300/autoconf.c 27 May 2025 18:56:27 -0000 1.117
+++ arch/hp300/hp300/autoconf.c 30 May 2025 16:52:13 -0000
@@ -825,11 +825,19 @@ hp300_cninit(void)
#if NCOM_FRODO > 0
if (!com_frodo_cnattach(bst, FRODO_BASE + FRODO_APCI_OFFSET(1),
CONSCODE_INTERNAL))
+#if 0
return;
+#else
+ ; /* continue to probe framebufrers with com(4) console */
+#endif
#endif
#if NCOM_DIO > 0
if (!dio_scan(com_dio_cnattach))
+#if 0
return;
+#else
+ ; /* continue to probe framebufrers with com(4) console */
+#endif
#endif
#if NDCM > 0
if (!dio_scan(dcmcnattach))
Index: dev/ic/sti.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/sti.c,v
retrieving revision 1.46
diff -u -p -d -r1.46 sti.c
--- dev/ic/sti.c 30 May 2025 13:42:33 -0000 1.46
+++ dev/ic/sti.c 30 May 2025 16:52:13 -0000
@@ -1486,6 +1486,23 @@ sti_alloc_attr(void *v, int fg, int bg,
return 0;
}
+#define STIDEBUG_COMCONSOLE
+#ifdef STIDEBUG_COMCONSOLE
+#define COM_MAJOR 12 /* on hp300 */
+#define COM_MINOR 0 /* 1 for 425e frodo */
+#include <dev/cons.h>
+extern void comcnputc(dev_t, int);
+static void (*cnputc_save)(dev_t, int);
+static dev_t cn_dev_com;
+
+static void
+cnputc_debug(dev_t dev, int c)
+{
+ (*cnputc_save)(dev, c);
+ comcnputc(cn_dev_com, c);
+}
+#endif
+
/*
* Early console support. Only used on hp300, currently
*/
@@ -1521,6 +1538,12 @@ sti_cnattach(struct sti_rom *rom, struct
sti_alloc_attr(scr, 0, 0, 0, &defattr);
wsdisplay_cnattach(&scr->scr_wsd, scr, 0, 0, defattr);
+#ifdef STIDEBUG_COMCONSOLE
+ cn_dev_com = makedev(COM_MAJOR, COM_MINOR);
+ cnputc_save = cn_tab->cn_putc;
+ cn_tab->cn_putc = cnputc_debug;
+#endif
+
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment