]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/arm/kernel/early_printk.c
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
[thirdparty/kernel/stable.git] / arch / arm / kernel / early_printk.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
93fd03a8
CM
2/*
3 * linux/arch/arm/kernel/early_printk.c
4 *
5 * Copyright (C) 2009 Sascha Hauer <s.hauer@pengutronix.de>
93fd03a8
CM
6 */
7
8#include <linux/kernel.h>
9#include <linux/console.h>
10#include <linux/init.h>
de880632 11#include <linux/string.h>
93fd03a8 12
de880632 13extern void printascii(const char *);
93fd03a8
CM
14
15static void early_write(const char *s, unsigned n)
16{
de880632
NP
17 char buf[128];
18 while (n) {
19 unsigned l = min(n, sizeof(buf)-1);
20 memcpy(buf, s, l);
21 buf[l] = 0;
22 s += l;
23 n -= l;
24 printascii(buf);
93fd03a8
CM
25 }
26}
27
28static void early_console_write(struct console *con, const char *s, unsigned n)
29{
30 early_write(s, n);
31}
32
d0380e6c 33static struct console early_console_dev = {
93fd03a8
CM
34 .name = "earlycon",
35 .write = early_console_write,
36 .flags = CON_PRINTBUFFER | CON_BOOT,
37 .index = -1,
38};
39
93fd03a8
CM
40static int __init setup_early_printk(char *buf)
41{
d0380e6c
TG
42 early_console = &early_console_dev;
43 register_console(&early_console_dev);
93fd03a8
CM
44 return 0;
45}
46
47early_param("earlyprintk", setup_early_printk);