xref: /linux/arch/mips/dec/prom/console.c (revision bba2c3615bd6cfee7456d1130f2e6b01b3f4e9ba)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *	DECstation PROM-based early console support.
4  *
5  *	Copyright (C) 2004, 2007, 2026  Maciej W. Rozycki
6  */
7 #include <linux/bug.h>
8 #include <linux/console.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 
13 #include <asm/dec/prom.h>
14 
15 static void __init prom_console_write(struct console *con, const char *s,
16 				      unsigned int c)
17 {
18 	static char buf[81] __initdata = { 0 };
19 	unsigned int chunk = sizeof(buf) - 1;
20 
21 	BUG_ON((long)buf != (int)(long)buf);
22 
23 	while (c > 0) {
24 		if (chunk > c)
25 			chunk = c;
26 		memcpy(buf, s, chunk);
27 		buf[chunk] = '\0';
28 		prom_printf("%s", buf);
29 		s += chunk;
30 		c -= chunk;
31 	}
32 }
33 
34 static struct console promcons __initdata = {
35 	.name	= "prom",
36 	.write	= prom_console_write,
37 	.flags	= CON_BOOT | CON_PRINTBUFFER,
38 	.index	= -1,
39 };
40 
41 void __init register_prom_console(void)
42 {
43 	register_console(&promcons);
44 }
45