18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * DECstation PROM-based early console support. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2007 Maciej W. Rozycki 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/console.h> 88c2ecf20Sopenharmony_ci#include <linux/init.h> 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <linux/string.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <asm/dec/prom.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic void __init prom_console_write(struct console *con, const char *s, 158c2ecf20Sopenharmony_ci unsigned int c) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci char buf[81]; 188c2ecf20Sopenharmony_ci unsigned int chunk = sizeof(buf) - 1; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci while (c > 0) { 218c2ecf20Sopenharmony_ci if (chunk > c) 228c2ecf20Sopenharmony_ci chunk = c; 238c2ecf20Sopenharmony_ci memcpy(buf, s, chunk); 248c2ecf20Sopenharmony_ci buf[chunk] = '\0'; 258c2ecf20Sopenharmony_ci prom_printf("%s", buf); 268c2ecf20Sopenharmony_ci s += chunk; 278c2ecf20Sopenharmony_ci c -= chunk; 288c2ecf20Sopenharmony_ci } 298c2ecf20Sopenharmony_ci} 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic struct console promcons __initdata = { 328c2ecf20Sopenharmony_ci .name = "prom", 338c2ecf20Sopenharmony_ci .write = prom_console_write, 348c2ecf20Sopenharmony_ci .flags = CON_BOOT | CON_PRINTBUFFER, 358c2ecf20Sopenharmony_ci .index = -1, 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_civoid __init register_prom_console(void) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci register_console(&promcons); 418c2ecf20Sopenharmony_ci} 42